@khanacademy/wonder-blocks-tooltip 4.1.69 → 4.1.71
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 +18 -0
- package/dist/es/index.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-tooltip
|
|
2
2
|
|
|
3
|
+
## 4.1.71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 00e6dda: Updates internal WB typography references to use the new system (Heading and BodyText)
|
|
8
|
+
- Updated dependencies [488728a]
|
|
9
|
+
- Updated dependencies [00e6dda]
|
|
10
|
+
- @khanacademy/wonder-blocks-tokens@16.2.0
|
|
11
|
+
- @khanacademy/wonder-blocks-typography@4.3.0
|
|
12
|
+
- @khanacademy/wonder-blocks-layout@3.1.47
|
|
13
|
+
- @khanacademy/wonder-blocks-modal@8.6.2
|
|
14
|
+
|
|
15
|
+
## 4.1.70
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @khanacademy/wonder-blocks-modal@8.6.1
|
|
20
|
+
|
|
3
21
|
## 4.1.69
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { maybeGetPortalMountedModalHostElement } from '@khanacademy/wonder-block
|
|
|
6
6
|
import { StyleSheet, css } from 'aphrodite';
|
|
7
7
|
import { spacing, semanticColor, color, border, boxShadow } from '@khanacademy/wonder-blocks-tokens';
|
|
8
8
|
import { Strut } from '@khanacademy/wonder-blocks-layout';
|
|
9
|
-
import {
|
|
9
|
+
import { Heading, BodyText } from '@khanacademy/wonder-blocks-typography';
|
|
10
10
|
import { Popper } from 'react-popper';
|
|
11
11
|
|
|
12
12
|
class ActiveTracker{_getIndex(who){return this._subscribers.findIndex(v=>v===who)}steal(who){const wasActive=!!this._active;this._active=true;for(const anchor of this._subscribers){if(anchor===who){continue}anchor.activeStateStolen();}return wasActive}giveup(){this._active=false;}subscribe(who){if(this._getIndex(who)>=0){throw new Error("Already subscribed.")}this._subscribers.push(who);const unsubscribe=()=>{const index=this._getIndex(who);this._subscribers.splice(index,1);};return unsubscribe}constructor(){this._subscribers=[];this._active=false;}}
|
|
@@ -19,7 +19,7 @@ let tempIdCounter=0;class TooltipTail extends React.Component{_calculateDimensio
|
|
|
19
19
|
|
|
20
20
|
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}=this.props;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]}],children:children}),jsx(TooltipTail,{updateRef:updateTailRef,placement:placement,offset:tailOffset,color:backgroundColor})]})}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:"transparent",color:"transparent"},"content-top":{flexDirection:"column"},"content-right":{flexDirection:"row-reverse"},"content-bottom":{flexDirection:"column-reverse"},"content-left":{flexDirection:"row"},content:{maxWidth: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"}});
|
|
21
21
|
|
|
22
|
-
class TooltipContent extends React.Component{_renderTitle(){const{title}=this.props;if(title){if(typeof title==="string"){return jsx(
|
|
22
|
+
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&&children&&jsx(Strut,{size:spacing.xxxSmall_4}),children]})}}const styles=StyleSheet.create({withoutTitle:{padding:`10px ${spacing.medium_16}px`},withTitle:{padding:spacing.medium_16}});
|
|
23
23
|
|
|
24
24
|
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})({});
|
|
25
25
|
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ let tempIdCounter=0;class TooltipTail extends React__namespace.Component{_calcul
|
|
|
44
44
|
|
|
45
45
|
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}=this.props;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]}],children:children}),jsxRuntime.jsx(TooltipTail,{updateRef:updateTailRef,placement:placement,offset:tailOffset,color:backgroundColor})]})}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:"transparent",color:"transparent"},"content-top":{flexDirection:"column"},"content-right":{flexDirection:"row-reverse"},"content-bottom":{flexDirection:"column-reverse"},"content-left":{flexDirection:"row"},content:{maxWidth: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"}});
|
|
46
46
|
|
|
47
|
-
class TooltipContent extends React__namespace.Component{_renderTitle(){const{title}=this.props;if(title){if(typeof title==="string"){return jsxRuntime.jsx(wonderBlocksTypography.
|
|
47
|
+
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&&children&&jsxRuntime.jsx(wonderBlocksLayout.Strut,{size:wonderBlocksTokens.spacing.xxxSmall_4}),children]})}}const styles=aphrodite.StyleSheet.create({withoutTitle:{padding:`10px ${wonderBlocksTokens.spacing.medium_16}px`},withTitle:{padding:wonderBlocksTokens.spacing.medium_16}});
|
|
48
48
|
|
|
49
49
|
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})({});
|
|
50
50
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "4.1.
|
|
6
|
+
"version": "4.1.71",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@khanacademy/wonder-blocks-core": "12.4.3",
|
|
24
|
-
"@khanacademy/wonder-blocks-layout": "3.1.
|
|
25
|
-
"@khanacademy/wonder-blocks-modal": "8.6.
|
|
26
|
-
"@khanacademy/wonder-blocks-tokens": "16.
|
|
27
|
-
"@khanacademy/wonder-blocks-typography": "4.
|
|
24
|
+
"@khanacademy/wonder-blocks-layout": "3.1.47",
|
|
25
|
+
"@khanacademy/wonder-blocks-modal": "8.6.2",
|
|
26
|
+
"@khanacademy/wonder-blocks-tokens": "16.2.0",
|
|
27
|
+
"@khanacademy/wonder-blocks-typography": "4.3.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@popperjs/core": "^2.10.1",
|