@elyra/canvas 12.12.2 → 12.14.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/.stylelintrc.json +17 -16
- package/README.md +1 -1
- package/dist/canvas-controller-8e2bb291.js +2 -0
- package/dist/canvas-controller-8e2bb291.js.map +1 -0
- package/dist/canvas-controller-bd0d8d59.js +2 -0
- package/dist/canvas-controller-bd0d8d59.js.map +1 -0
- package/dist/common-canvas-69fe4a67.js +2 -0
- package/dist/common-canvas-69fe4a67.js.map +1 -0
- package/dist/common-canvas-f5e4af65.js +2 -0
- package/dist/common-canvas-f5e4af65.js.map +1 -0
- package/dist/common-canvas.es.js +1 -1
- package/dist/common-canvas.js +1 -1
- package/dist/common-properties-40648163.js +2 -0
- package/dist/common-properties-40648163.js.map +1 -0
- package/dist/common-properties-6d839df1.js +2 -0
- package/dist/common-properties-6d839df1.js.map +1 -0
- package/dist/{extends-7fdcdc52.js → extends-1139e06f.js} +2 -2
- package/dist/{extends-7fdcdc52.js.map → extends-1139e06f.js.map} +1 -1
- package/dist/{flexible-table-a13cb7d0.js → flexible-table-d3598aa8.js} +2 -2
- package/dist/flexible-table-d3598aa8.js.map +1 -0
- package/dist/{flexible-table-50ce600a.js → flexible-table-fe7fbc13.js} +2 -2
- package/dist/flexible-table-fe7fbc13.js.map +1 -0
- package/dist/{icon-bf77b2aa.js → icon-918d2dd3.js} +2 -2
- package/dist/{icon-bf77b2aa.js.map → icon-918d2dd3.js.map} +1 -1
- package/dist/{index-f2c306ba.js → index-669f95a7.js} +2 -2
- package/dist/{index-f2c306ba.js.map → index-669f95a7.js.map} +1 -1
- package/dist/{index-0e6c8b9c.js → index-6d3404e1.js} +2 -2
- package/dist/{index-0e6c8b9c.js.map → index-6d3404e1.js.map} +1 -1
- package/dist/lib/canvas-controller.es.js +1 -1
- package/dist/lib/canvas-controller.js +1 -1
- package/dist/lib/canvas.es.js +1 -1
- package/dist/lib/canvas.js +1 -1
- package/dist/lib/context-menu.es.js +1 -1
- package/dist/lib/properties/field-picker.es.js +1 -1
- package/dist/lib/properties/field-picker.js +1 -1
- package/dist/lib/properties/flexible-table.es.js +1 -1
- package/dist/lib/properties/flexible-table.js +1 -1
- package/dist/lib/properties.es.js +1 -1
- package/dist/lib/properties.js +1 -1
- package/dist/lib/tooltip.es.js +1 -1
- package/dist/lib/tooltip.es.js.map +1 -1
- package/dist/lib/tooltip.js +1 -1
- package/dist/lib/tooltip.js.map +1 -1
- package/dist/styles/common-canvas.min.css +1 -1
- package/dist/styles/common-canvas.min.css.map +1 -1
- package/dist/toolbar-29ec7983.js +2 -0
- package/dist/toolbar-29ec7983.js.map +1 -0
- package/dist/toolbar-3f4b173f.js +2 -0
- package/dist/toolbar-3f4b173f.js.map +1 -0
- package/locales/command-actions/locales/de.json +50 -8
- package/locales/command-actions/locales/en.json +1 -1
- package/locales/command-actions/locales/es.json +50 -8
- package/locales/command-actions/locales/fr.json +50 -8
- package/locales/command-actions/locales/index.js +2 -2
- package/locales/command-actions/locales/it.json +50 -8
- package/locales/command-actions/locales/ja.json +50 -8
- package/locales/command-actions/locales/ko.json +42 -0
- package/locales/command-actions/locales/pt-br.json +50 -8
- package/locales/command-actions/locales/zh-CN.json +51 -0
- package/locales/command-actions/locales/zh-TW.json +51 -0
- package/locales/common-canvas/locales/de.json +36 -26
- package/locales/common-canvas/locales/en.json +14 -1
- package/locales/common-canvas/locales/eo.json +14 -1
- package/locales/common-canvas/locales/es.json +36 -26
- package/locales/common-canvas/locales/fr.json +36 -26
- package/locales/common-canvas/locales/index.js +2 -2
- package/locales/common-canvas/locales/it.json +36 -26
- package/locales/common-canvas/locales/ja.json +36 -26
- package/locales/common-canvas/locales/ko.json +7 -2
- package/locales/common-canvas/locales/pt-br.json +36 -26
- package/locales/common-canvas/locales/zh-CN.json +37 -0
- package/locales/common-canvas/locales/zh-TW.json +37 -0
- package/locales/common-properties/locales/de.json +92 -92
- package/locales/common-properties/locales/en.json +1 -1
- package/locales/common-properties/locales/es.json +92 -92
- package/locales/common-properties/locales/fr.json +92 -92
- package/locales/common-properties/locales/index.js +2 -2
- package/locales/common-properties/locales/it.json +92 -92
- package/locales/common-properties/locales/ja.json +92 -92
- package/locales/common-properties/locales/ko.json +1 -1
- package/locales/common-properties/locales/pt-br.json +92 -92
- package/locales/common-properties/locales/zh-CN.json +93 -0
- package/locales/common-properties/locales/zh-TW.json +93 -0
- package/locales/palette/locales/de.json +9 -9
- package/locales/palette/locales/en.json +6 -6
- package/locales/palette/locales/es.json +9 -9
- package/locales/palette/locales/fr.json +9 -9
- package/locales/palette/locales/index.js +2 -2
- package/locales/palette/locales/it.json +9 -9
- package/locales/palette/locales/ja.json +9 -9
- package/locales/palette/locales/pt-br.json +9 -9
- package/locales/palette/locales/zh-CN.json +10 -0
- package/locales/palette/locales/zh-TW.json +10 -0
- package/locales/toolbar/locales/de.json +7 -7
- package/locales/toolbar/locales/en.json +1 -1
- package/locales/toolbar/locales/es.json +7 -7
- package/locales/toolbar/locales/fr.json +7 -7
- package/locales/toolbar/locales/index.js +2 -2
- package/locales/toolbar/locales/it.json +7 -7
- package/locales/toolbar/locales/ja.json +7 -7
- package/locales/toolbar/locales/pt-br.json +7 -7
- package/locales/toolbar/locales/zh-CN.json +8 -0
- package/locales/toolbar/locales/zh-TW.json +8 -0
- package/package.json +3 -2
- package/src/common-canvas/canvas-controller.js +19 -3
- package/src/common-canvas/cc-bottom-panel.jsx +37 -21
- package/src/common-canvas/cc-central-items.jsx +1 -1
- package/src/common-canvas/cc-contents.jsx +10 -3
- package/src/common-canvas/cc-text-toolbar.jsx +141 -0
- package/src/common-canvas/cc-toolbar.jsx +8 -6
- package/src/common-canvas/common-canvas.scss +52 -5
- package/src/common-canvas/svg-canvas-d3.scss +159 -16
- package/src/common-canvas/svg-canvas-renderer.js +204 -26
- package/src/common-canvas/svg-canvas-utils-markdown.js +515 -0
- package/src/common-properties/components/control-item/control-item.scss +1 -1
- package/src/common-properties/components/flexible-table/flexible-table.jsx +14 -3
- package/src/common-properties/components/flexible-table/flexible-table.scss +20 -0
- package/src/common-properties/controls/abstract-table.jsx +2 -0
- package/src/common-properties/controls/checkbox/checkbox.jsx +1 -1
- package/src/common-properties/controls/checkboxset/checkboxset.jsx +36 -11
- package/src/common-properties/controls/checkboxset/checkboxset.scss +6 -0
- package/src/common-properties/controls/list/list.jsx +1 -0
- package/src/common-properties/controls/radioset/radioset.jsx +25 -1
- package/src/common-properties/controls/radioset/radioset.scss +19 -0
- package/src/common-properties/controls/selectcolumns/selectcolumns.jsx +1 -0
- package/src/common-properties/controls/someofselect/someofselect.jsx +1 -0
- package/src/common-properties/form/ControlInfo.js +3 -0
- package/src/common-properties/form/EditorForm.js +45 -3
- package/src/common-properties/panels/action-panel/action-panel.jsx +38 -3
- package/src/common-properties/panels/action-panel/action-panel.scss +3 -0
- package/src/common-properties/panels/text-panel/text-panel.jsx +38 -7
- package/src/common-properties/panels/text-panel/text-panel.scss +4 -3
- package/src/common-properties/properties-controller.js +39 -12
- package/src/common-properties/ui-conditions/conditions-utils.js +14 -8
- package/src/common-properties/util/L10nProvider.js +6 -0
- package/src/object-model/config-utils.js +1 -0
- package/src/object-model/layout-dimensions.js +10 -0
- package/src/object-model/object-model.js +12 -0
- package/src/object-model/redux/canvas-store.js +4 -1
- package/src/object-model/redux/reducers/bottompanel.js +1 -3
- package/src/object-model/redux/reducers/texttoolbar.js +29 -0
- package/src/palette/palette-content-list-item.jsx +12 -2
- package/src/palette/palette-content-list.jsx +11 -19
- package/src/palette/palette-dialog-content-grid.jsx +1 -6
- package/src/palette/palette-dialog-content.jsx +13 -11
- package/src/palette/palette-flyout-content-category.jsx +26 -24
- package/src/palette/palette-flyout-content.jsx +4 -24
- package/src/palette/palette.scss +71 -43
- package/src/toolbar/toolbar-action-item.jsx +9 -6
- package/src/toolbar/toolbar-overflow-item.jsx +1 -0
- package/src/toolbar/toolbar.jsx +12 -15
- package/src/tooltip/tooltip.jsx +14 -5
- package/stats.html +1 -1
- package/dist/canvas-controller-de76a796.js +0 -2
- package/dist/canvas-controller-de76a796.js.map +0 -1
- package/dist/canvas-controller-e91d037b.js +0 -2
- package/dist/canvas-controller-e91d037b.js.map +0 -1
- package/dist/common-canvas-522f6263.js +0 -2
- package/dist/common-canvas-522f6263.js.map +0 -1
- package/dist/common-canvas-90539c97.js +0 -2
- package/dist/common-canvas-90539c97.js.map +0 -1
- package/dist/common-properties-245c4711.js +0 -2
- package/dist/common-properties-245c4711.js.map +0 -1
- package/dist/common-properties-49e6bb67.js +0 -2
- package/dist/common-properties-49e6bb67.js.map +0 -1
- package/dist/flexible-table-50ce600a.js.map +0 -1
- package/dist/flexible-table-a13cb7d0.js.map +0 -1
- package/dist/toolbar-1c181339.js +0 -2
- package/dist/toolbar-1c181339.js.map +0 -1
- package/dist/toolbar-c6fa3cdb.js +0 -2
- package/dist/toolbar-c6fa3cdb.js.map +0 -1
- package/locales/command-actions/locales/zh-cn.json +0 -9
- package/locales/command-actions/locales/zh-tw.json +0 -9
- package/locales/common-canvas/locales/zh-cn.json +0 -27
- package/locales/common-canvas/locales/zh-tw.json +0 -27
- package/locales/common-properties/locales/zh-cn.json +0 -93
- package/locales/common-properties/locales/zh-tw.json +0 -93
- package/locales/palette/locales/zh-cn.json +0 -10
- package/locales/palette/locales/zh-tw.json +0 -10
- package/locales/toolbar/locales/zh-cn.json +0 -8
- package/locales/toolbar/locales/zh-tw.json +0 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";require("../createClass-6db89a23.js"),require("../isArrayLikeObject-f3b27f64.js");var e=require("../canvas-controller-
|
|
1
|
+
"use strict";require("../createClass-6db89a23.js"),require("../isArrayLikeObject-f3b27f64.js");var e=require("../canvas-controller-bd0d8d59.js");require("./command-stack.js"),require("../canvas-constants-34cdb7df.js"),require("../canvas-logger-a0f1beaa.js"),require("../getPrototypeOf-bf88242f.js"),require("../datarecord-metadata-v3-schema-6b6384ff.js"),require("../en-7a0f1db1.js"),require("uuid"),require("redux"),require("jsonschema"),require("@elyra/pipeline-schemas"),require("immutable"),module.exports=e.CanvasController;
|
|
2
2
|
//# sourceMappingURL=canvas-controller.js.map
|
package/dist/lib/canvas.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{c as CommonCanvas}from"../common-canvas-
|
|
1
|
+
export{c as CommonCanvas}from"../common-canvas-f5e4af65.js";export{C as CanvasController}from"../canvas-controller-8e2bb291.js";import"../createClass-32a0cf0f.js";import"../getPrototypeOf-a1c3fe64.js";import"react";import"react-redux";import"react-intl";import"../isArrayLikeObject-a9c7973b.js";import"../icon-918d2dd3.js";import"../extends-1139e06f.js";import"react-inlinesvg";import"@carbon/icons-react";import"../canvas-constants-3c09c7f6.js";import"../toolbar-29ec7983.js";import"../datarecord-metadata-v3-schema-81228a9a.js";import"../en-8647c347.js";import"react-resize-detector";import"./tooltip.es.js";import"react-portal";import"carbon-components-react";import"../canvas-logger-815781bb.js";import"./context-menu.es.js";import"react-contextmenu";import"../_baseForOwn-d38b560e.js";import"./command-stack.es.js";import"immutable";import"uuid";import"redux";import"jsonschema";import"@elyra/pipeline-schemas";
|
|
2
2
|
//# sourceMappingURL=canvas.es.js.map
|
package/dist/lib/canvas.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../common-canvas-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../common-canvas-69fe4a67.js"),r=require("../canvas-controller-bd0d8d59.js");require("../createClass-6db89a23.js"),require("../getPrototypeOf-bf88242f.js"),require("react"),require("react-redux"),require("react-intl"),require("../isArrayLikeObject-f3b27f64.js"),require("../icon-4882a57f.js"),require("../extends-8d17c85c.js"),require("react-inlinesvg"),require("@carbon/icons-react"),require("../canvas-constants-34cdb7df.js"),require("../toolbar-3f4b173f.js"),require("../datarecord-metadata-v3-schema-6b6384ff.js"),require("../en-7a0f1db1.js"),require("react-resize-detector"),require("./tooltip.js"),require("react-portal"),require("carbon-components-react"),require("../canvas-logger-a0f1beaa.js"),require("./context-menu.js"),require("react-contextmenu"),require("../_baseForOwn-7d4e8506.js"),require("./command-stack.js"),require("immutable"),require("uuid"),require("redux"),require("jsonschema"),require("@elyra/pipeline-schemas"),exports.CommonCanvas=e.commonCanvas,exports.CanvasController=r.CanvasController;
|
|
2
2
|
//# sourceMappingURL=canvas.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,a as t}from"../createClass-32a0cf0f.js";import{_ as n,a as o,b as c,c as r}from"../getPrototypeOf-a1c3fe64.js";import i from"react";import{_ as a,C as l}from"../canvas-constants-3c09c7f6.js";import{_ as u}from"../extends-
|
|
1
|
+
import{_ as e,a as t}from"../createClass-32a0cf0f.js";import{_ as n,a as o,b as c,c as r}from"../getPrototypeOf-a1c3fe64.js";import i from"react";import{_ as a,C as l}from"../canvas-constants-3c09c7f6.js";import{_ as u}from"../extends-1139e06f.js";import{MenuItem as s,SubMenu as d}from"react-contextmenu";import{I as m}from"../icon-918d2dd3.js";import{L as f}from"../canvas-logger-815781bb.js";import"react-inlinesvg";import"@carbon/icons-react";function p(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=o(e);if(t){var i=o(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}var h=function(o){n(a,o);var c=p(a);function a(t){var n;return e(this,a),(n=c.call(this,t)).logger=new f("CC-ContextMenu"),n.onClick=n.onClick.bind(r(n)),n}return t(a,[{key:"onClick",value:function(e){var t=e.target.dataset.color;this.props.clickActionHandler(t)}},{key:"render",value:function(){return this.logger.log("render"),i.createElement("div",{className:"color-picker-panel",onClick:this.onClick},i.createElement("div",{tabIndex:"0","data-color":"bkg-col-white-0",className:"color-picker-item white-0"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-yellow-20",className:"color-picker-item yellow-20"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-gray-20",className:"color-picker-item gray-20"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-green-20",className:"color-picker-item green-20"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-teal-20",className:"color-picker-item teal-20"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-cyan-20",className:"color-picker-item cyan-20"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-red-50",className:"color-picker-item red-50"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-orange-40",className:"color-picker-item orange-40"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-gray-50",className:"color-picker-item gray-50"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-green-50",className:"color-picker-item green-50"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-teal-50",className:"color-picker-item teal-50"}),i.createElement("div",{tabIndex:"0","data-color":"bkg-col-cyan-50",className:"color-picker-item cyan-50"}))}}]),a}(i.Component);function v(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=o(e);if(t){var i=o(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}var k=function(o){n(f,o);var c=v(f);function f(t){var n;return e(this,f),(n=c.call(this,t)).state={},n.itemSelected=n.itemSelected.bind(r(n)),n.colorClicked=n.colorClicked.bind(r(n)),n}return t(f,[{key:"onContextMenu",value:function(e){e.preventDefault()}},{key:"itemSelected",value:function(e,t){this.props.contextHandler(e),t&&t.stopPropagation()}},{key:"colorClicked",value:function(e){this.props.contextHandler("colorSelectedObjects",{color:e})}},{key:"calculateMenuSize",value:function(e){for(var t=0,n=0;n<e.length;++n){e[n].divider&&t++}return{height:30*(e.length-t)+1*t,width:160}}},{key:"calculateMenuPos",value:function(e,t,n){var o={x:e.x,y:e.y};return e.y+t.height>n.height&&(o.y=n.height-t.height-5,o.y<0&&(o.y=0)),e.x+t.width>n.width&&(o.x-=t.width),o}},{key:"areAllSubmenuItemsDisabled",value:function(e){var t=0,n=0;return e.forEach((function(e){e.divider||t++,!1===e.enable&&n++})),n===t}},{key:"buildMenu",value:function(e,t,n,o){for(var c={className:"contextmenu-divider"},r=[],a=0,l=!1,d=0;d<e.length;++d){var m=e[d].divider,f=e[d].submenu;if(m)l||(r.push(i.createElement(s,{attributes:c,key:d+1,onClick:function(){},divider:!0})),a+=1,l=!0);else if(f)if(l=!1,"colorPicker"===e[d].menu){var p={width:160,height:50},h=this.buildColorPickerPanel(),v=this.buildSubMenu(e,d,h,a,n,t,p,o,!1);r.push(v),a+=30}else{var k={disabled:this.areAllSubmenuItemsDisabled(e[d].menu)},b=this.calculateMenuSize(e[d].menu),y=this.buildMenu(e[d].menu,t,n,o),g=this.buildSubMenu(e,d,y,a,n,t,b,o,k);r.push(g),a+=30}else{l=!1;var x={disabled:!1===e[d].enable};r.push(i.createElement(s,u({onClick:this.itemSelected.bind(null,e[d].action),key:d+1},x),e[d].label)),a+=30}}return r}},{key:"buildColorPickerPanel",value:function(){return i.createElement(h,a({clickActionHandler:this.colorPickHandler},"clickActionHandler",this.colorClicked))}},{key:"buildSubMenu",value:function(e,t,n,o,c,r,a,s,f){var p=this.buildRtlState(c,r,a,s),h=this.buildSubMenuPosStyle(o,c,a,s),v=i.createElement(m,{type:l.CHEVRONARROWS.RIGHT,disabled:!1,className:"react-contextmenu-submenu-icon"}),k=i.createElement("div",null,e[t].label,v," ");return i.createElement(d,u({title:k,key:t+1,className:"contextmenu-submenu",rtl:p},f),i.createElement("div",{key:t+1,style:h,className:"context-menu-popover"},n))}},{key:"buildRtlState",value:function(e,t,n,o){return e.x+t.width+n.width>o.right}},{key:"buildSubMenuPosStyle",value:function(e,t,n,o){var c=o.bottom-(t.y+e+n.height);return{top:(c>0?0:c-5)+"px"}}},{key:"render",value:function(){var e=this.calculateMenuSize(this.props.menuDefinition),t=this.calculateMenuPos(this.props.mousePos,e,this.props.canvasRect),n={left:t.x+"px",top:t.y+"px"},o=this.buildMenu(this.props.menuDefinition,e,t,this.props.canvasRect);return i.createElement("div",{id:"context-menu-popover",className:"context-menu-popover",style:n,onContextMenu:this.onContextMenu},o)}}]),f}(i.Component);function b(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=o(e);if(t){var i=o(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return c(this,n)}}var y=function(o){n(a,o);var c=b(a);function a(t){var n;return e(this,a),(n=c.call(this,t)).state={},n.contextMenuClicked=n.contextMenuClicked.bind(r(n)),n.handleClickOutside=n.handleClickOutside.bind(r(n)),n}return t(a,[{key:"componentDidMount",value:function(){document.addEventListener("click",this.handleClickOutside,!0)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.handleClickOutside,!0)}},{key:"getCanvasRect",value:function(){var e=document.getElementById(this.props.containingDivId).getBoundingClientRect();return{top:0,bottom:e.bottom-e.top,left:0,right:e.right-e.left,height:e.height,width:e.width}}},{key:"handleClickOutside",value:function(e){if(2===e.button||e.ctrlKey)e.stopPropagation();else{var t=document.getElementById("context-menu-popover");t&&!t.contains(e.target)&&(this.props.stopPropagation&&e.stopPropagation(),this.props.closeContextMenu())}}},{key:"contextMenuClicked",value:function(e,t){this.props.contextMenuActionHandler(e,t)}},{key:"render",value:function(){return i.createElement(k,{contextHandler:this.contextMenuClicked,menuDefinition:this.props.contextMenuDef,canvasRect:this.getCanvasRect(),mousePos:this.props.contextMenuPos})}}]),a}(i.Component);export{y as default};
|
|
2
2
|
//# sourceMappingURL=context-menu.es.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{F as default}from"../../index-
|
|
1
|
+
export{F as default}from"../../index-6d3404e1.js";import"../../createClass-32a0cf0f.js";import"../../getPrototypeOf-a1c3fe64.js";import"../../isArrayLikeObject-a9c7973b.js";import"../../flexible-table-d3598aa8.js";import"../../extends-1139e06f.js";import"react";import"react-intl";import"react-dom";import"carbon-components-react";import"../../_baseForOwn-d38b560e.js";import"react-virtualized";import"react-draggable";import"@carbon/icons-react";import"../tooltip.es.js";import"react-portal";import"uuid";import"react-resize-detector";import"../../canvas-constants-3c09c7f6.js";import"../../en-8647c347.js";import"../../icon-918d2dd3.js";import"react-inlinesvg";
|
|
2
2
|
//# sourceMappingURL=field-picker.es.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../index-
|
|
1
|
+
"use strict";var e=require("../../index-669f95a7.js");require("../../createClass-6db89a23.js"),require("../../getPrototypeOf-bf88242f.js"),require("../../isArrayLikeObject-f3b27f64.js"),require("../../flexible-table-fe7fbc13.js"),require("../../extends-8d17c85c.js"),require("react"),require("react-intl"),require("react-dom"),require("carbon-components-react"),require("../../_baseForOwn-7d4e8506.js"),require("react-virtualized"),require("react-draggable"),require("@carbon/icons-react"),require("../tooltip.js"),require("react-portal"),require("uuid"),require("react-resize-detector"),require("../../canvas-constants-34cdb7df.js"),require("../../en-7a0f1db1.js"),require("../../icon-4882a57f.js"),require("react-inlinesvg"),module.exports=e.FieldPicker;
|
|
2
2
|
//# sourceMappingURL=field-picker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as t}from"../../flexible-table-
|
|
1
|
+
import{F as t}from"../../flexible-table-d3598aa8.js";export{F as default}from"../../flexible-table-d3598aa8.js";import"../../extends-1139e06f.js";import"../../getPrototypeOf-a1c3fe64.js";import"../../createClass-32a0cf0f.js";import"../../isArrayLikeObject-a9c7973b.js";import"react";import"react-intl";import"react-dom";import"carbon-components-react";import"../../_baseForOwn-d38b560e.js";import"react-virtualized";import"react-draggable";import"@carbon/icons-react";import"../tooltip.es.js";import"react-portal";import"uuid";import"react-resize-detector";
|
|
2
2
|
//# sourceMappingURL=flexible-table.es.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../flexible-table-
|
|
1
|
+
"use strict";var e=require("../../flexible-table-fe7fbc13.js");require("../../extends-8d17c85c.js"),require("../../getPrototypeOf-bf88242f.js"),require("../../createClass-6db89a23.js"),require("../../isArrayLikeObject-f3b27f64.js"),require("react"),require("react-intl"),require("react-dom"),require("carbon-components-react"),require("../../_baseForOwn-7d4e8506.js"),require("react-virtualized"),require("react-draggable"),require("@carbon/icons-react"),require("../tooltip.js"),require("react-portal"),require("uuid"),require("react-resize-detector"),module.exports=e.FlexibleTable;
|
|
2
2
|
//# sourceMappingURL=flexible-table.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{c as CommonProperties,P as PropertiesController}from"../common-properties-
|
|
1
|
+
export{c as CommonProperties,P as PropertiesController}from"../common-properties-40648163.js";export{F as FlexibleTable}from"../flexible-table-d3598aa8.js";export{F as FieldPicker}from"../index-6d3404e1.js";import"../createClass-32a0cf0f.js";import"../getPrototypeOf-a1c3fe64.js";import"react";import"../en-8647c347.js";import"../isArrayLikeObject-a9c7973b.js";import"../datarecord-metadata-v3-schema-81228a9a.js";import"carbon-components-react";import"../extends-1139e06f.js";import"react-portal";import"react-redux";import"@carbon/icons-react";import"react-dom";import"../icon-918d2dd3.js";import"react-inlinesvg";import"../canvas-constants-3c09c7f6.js";import"uuid";import"./tooltip.es.js";import"redux";import"seedrandom";import"./command-stack.es.js";import"immutable";import"react-intl";import"date-fns";import"prop-types";import"../toolbar-29ec7983.js";import"react-resize-detector";import"react-codemirror2";import"jsonschema";import"../_baseForOwn-d38b560e.js";import"react-virtualized";import"react-draggable";
|
|
2
2
|
//# sourceMappingURL=properties.es.js.map
|
package/dist/lib/properties.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../common-properties-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../common-properties-6d839df1.js"),r=require("../flexible-table-fe7fbc13.js"),i=require("../index-669f95a7.js");require("../createClass-6db89a23.js"),require("../getPrototypeOf-bf88242f.js"),require("react"),require("../en-7a0f1db1.js"),require("../isArrayLikeObject-f3b27f64.js"),require("../datarecord-metadata-v3-schema-6b6384ff.js"),require("carbon-components-react"),require("../extends-8d17c85c.js"),require("react-portal"),require("react-redux"),require("@carbon/icons-react"),require("react-dom"),require("../icon-4882a57f.js"),require("react-inlinesvg"),require("../canvas-constants-34cdb7df.js"),require("uuid"),require("./tooltip.js"),require("redux"),require("seedrandom"),require("./command-stack.js"),require("immutable"),require("react-intl"),require("date-fns"),require("prop-types"),require("../toolbar-3f4b173f.js"),require("react-resize-detector"),require("react-codemirror2"),require("jsonschema"),require("../_baseForOwn-7d4e8506.js"),require("react-virtualized"),require("react-draggable"),exports.CommonProperties=e.commonProperties,exports.PropertiesController=e.PropertiesController,exports.FlexibleTable=r.FlexibleTable,exports.FieldPicker=i.FieldPicker;
|
|
2
2
|
//# sourceMappingURL=properties.js.map
|
package/dist/lib/tooltip.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as t,a as e,b as i,c as o,d as l}from"../getPrototypeOf-a1c3fe64.js";import{_ as s,a as n}from"../createClass-32a0cf0f.js";import r from"react";import{Portal as p}from"react-portal";import{Link as h}from"carbon-components-react";function a(t){var o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var l,s=e(t);if(o){var n=e(this).constructor;l=Reflect.construct(s,arguments,n)}else l=s.apply(this,arguments);return i(this,l)}}var u=function(e){t(u,e);var i=a(u);function u(t){var e;return s(this,u),(e=i.call(this,t)).state={isTooltipVisible:!1},e.pendingTooltip=null,e.hideTooltipOnScrollAndResize=e.hideTooltipOnScrollAndResize.bind(o(e)),e}return n(u,[{key:"componentDidMount",value:function(){window.addEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.addEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.props.targetObj&&this.setTooltipVisible(!0)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.removeEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.pendingTooltip&&clearTimeout(this.pendingTooltip)}},{key:"setTooltipVisible",value:function(t){if((!this.showTooltip()||!t&&this.pendingTooltip)&&(clearTimeout(this.pendingTooltip),this.pendingTooltip=null,this.setState({isTooltipVisible:!1})),this.showTooltip()){var e=document.querySelector("[data-id='"+this.props.id+"']");if(this.pendingTooltip=null,this.setState({isTooltipVisible:t}),t){var i=null;(i=this.props.targetObj?this.props.targetObj:document.querySelector("[data-id='"+this.props.id+"-trigger']"))&&e&&this.updateTooltipLayout(e,i,e.getAttribute("direction"))}}}},{key:"getStyleValue",value:function(t){return t+"px"}},{key:"getNewDirection",value:function(t){var e;switch(t){case"top":e="bottom";break;case"bottom":e="top";break;case"left":e="right";break;default:e="left"}return e}},{key:"showTooltip",value:function(){var t=this.canDisplayFullText(this.triggerRef);return!this.props.disable&&!this.props.showToolTipIfTruncated||!this.props.disable&&this.props.showToolTipIfTruncated&&!t}},{key:"canDisplayFullText",value:function(t){if(t){var e=t.firstChild&&t.firstChild.scrollWidth?t.firstChild.scrollWidth:0,i=t.offsetWidth,o=e;0===e&&(o=t.scrollWidth);var l=o<=i;return l}return!1}},{key:"showTooltipWithDelay",value:function(){if(!this.pendingTooltip&&this.showTooltip()){var t=this;this.pendingTooltip=setTimeout((function(){t.setTooltipVisible(!0)}),this.props.delay)}}},{key:"updateTooltipLayout",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=e.getBoundingClientRect(),r=t.querySelector("svg"),p=r.getBoundingClientRect();if(t.style.left=this.getStyleValue(n.left),t.style.top=this.getStyleValue(n.top),this.props.mousePos)this.updateLocationBasedOnMousePos(t,this.props.mousePos,i);else{if("top"===o||"bottom"===o){var h=n.left;t.offsetWidth>n.width?(h-=(t.offsetWidth-n.width)/2)<0&&(h=2):t.offsetWidth<n.width&&(h+=(n.width-t.offsetWidth)/2),t.style.left=this.getStyleValue(h),h+t.offsetWidth>l&&(t.style.left=this.getStyleValue(l-t.offsetWidth))}else if("left"===o)for(;t.offsetLeft+t.offsetWidth+p.width>n.left;)t.style.left=this.getStyleValue(n.left-t.offsetWidth-p.width);else"right"===o&&(t.style.left=this.getStyleValue(n.right+p.width));if("top"===o)t.style.top=this.getStyleValue(n.top-p.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(n.bottom+p.height);else if("left"===o||"right"===o){var a=n.top;t.offsetHeight>n.height?(a-=(t.offsetHeight-n.height)/2)<0&&(a=n.top):t.offsetHeight<n.height&&(a+=(n.height-t.offsetHeight)/2),t.style.top=this.getStyleValue(a+1),s-t.offsetHeight<n.top&&(t.style.top=this.getStyleValue(s-t.offsetHeight))}"top"===o||"bottom"===o?r.style.left=this.getStyleValue(n.left-t.getBoundingClientRect().left+e.getBoundingClientRect().width/2-p.width/2+1):"left"===o?r.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(r.style.left=this.getStyleValue(2-p.width)),"top"===o?r.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?r.style.top="-11px":"left"!==o&&"right"!==o||(r.style.top=this.getStyleValue(n.top-t.getBoundingClientRect().top+e.offsetHeight/2-p.height/2))}if(this.isOutOfBounds(t)&&t.getAttribute("direction")===o){var u=this.getNewDirection(o);return this.updateTooltipLayout(t,e,u),void t.setAttribute("direction",u)}}},{key:"updateLocationBasedOnMousePos",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=t.querySelector("svg"),r=n.getBoundingClientRect(),p=this.props.mousePos.x,h=this.props.mousePos.y;if("top"===o||"bottom"===o){var a=p-t.offsetWidth/2;l-t.offsetWidth<a?a=l-t.offsetWidth:a<0&&(a=2),t.style.left=this.getStyleValue(a)}else"left"===o?t.style.left=this.getStyleValue(p-t.offsetWidth-r.width-5):"right"===o&&(t.style.left=this.getStyleValue(p+r.width+5));if("top"===o)t.style.top=this.getStyleValue(h-r.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(h+2*r.height);else if("left"===o||"right"===o){var u=h-t.offsetHeight/2;s-t.offsetHeight<u?u=s-t.offsetHeight:u<0&&(u=2),t.style.top=this.getStyleValue(u+1)}"top"===o||"bottom"===o?n.style.left=this.getStyleValue(p-t.getBoundingClientRect().left-r.width/2):"left"===o?n.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(n.style.left=this.getStyleValue(2-r.width)),"top"===o?n.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?n.style.top="-11px":"left"!==o&&"right"!==o||(n.style.top=this.getStyleValue(h-t.getBoundingClientRect().top-r.height/2))}},{key:"isOutOfBounds",value:function(t){var e=parseFloat(t.style.left),i=parseFloat(t.style.top);return e+t.offsetWidth>document.documentElement.clientWidth||e<0||i<0||i+t.offsetHeight>document.documentElement.clientHeight}},{key:"toggleTooltipOnClick",value:function(t){t.stopPropagation(),t.preventDefault(),this.state.isTooltipVisible?this.setTooltipVisible(!1):this.setTooltipVisible(!0)}},{key:"hideTooltipOnScrollAndResize",value:function(t){this.state.isTooltipVisible&&this.setTooltipVisible(!1)}},{key:"tooltipLinkOnClick",value:function(t){window.open(t,"_blank","noopener")}},{key:"render",value:function(){var t=this,e=null,i=null;if(this.props.children){i=r.createElement("div",{"data-id":this.props.id+"-trigger",className:"tooltip-trigger",onMouseOver:this.props.showToolTipOnClick?null:function(){return t.setTooltipVisible(!0)},onMouseLeave:this.props.showToolTipOnClick?null:function(){return t.setTooltipVisible(!1)},onMouseDown:this.props.showToolTipOnClick?null:function(){return t.setTooltipVisible(!1)},onClick:this.props.showToolTipOnClick?function(e){return t.toggleTooltipOnClick(e)}:null,onFocus:this.props.showToolTipOnClick?function(){return t.showTooltipWithDelay()}:null,onBlur:this.props.showToolTipOnClick?function(e){null!==e.relatedTarget&&t.setTooltipVisible(!1)}:null,tabIndex:this.props.showToolTipOnClick?0:null,ref:function(e){return t.triggerRef=e}},this.props.children)}"string"==typeof this.props.tip?e=r.createElement("span",{id:"tooltipContainer"},this.props.tip):"object"===l(this.props.tip)
|
|
1
|
+
import{_ as t,a as e,b as i,c as o,d as l}from"../getPrototypeOf-a1c3fe64.js";import{_ as s,a as n}from"../createClass-32a0cf0f.js";import r from"react";import{Portal as p}from"react-portal";import{Link as h}from"carbon-components-react";function a(t){var o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var l,s=e(t);if(o){var n=e(this).constructor;l=Reflect.construct(s,arguments,n)}else l=s.apply(this,arguments);return i(this,l)}}var u=function(e){t(u,e);var i=a(u);function u(t){var e;return s(this,u),(e=i.call(this,t)).state={isTooltipVisible:!1},e.pendingTooltip=null,e.hideTooltipOnScrollAndResize=e.hideTooltipOnScrollAndResize.bind(o(e)),e}return n(u,[{key:"componentDidMount",value:function(){window.addEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.addEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.props.targetObj&&this.setTooltipVisible(!0)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.removeEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.pendingTooltip&&clearTimeout(this.pendingTooltip)}},{key:"setTooltipVisible",value:function(t){if((!this.showTooltip()||!t&&this.pendingTooltip)&&(clearTimeout(this.pendingTooltip),this.pendingTooltip=null,this.setState({isTooltipVisible:!1})),this.showTooltip()){var e=document.querySelector("[data-id='"+this.props.id+"']");if(this.pendingTooltip=null,this.setState({isTooltipVisible:t}),t){var i=null;(i=this.props.targetObj?this.props.targetObj:document.querySelector("[data-id='"+this.props.id+"-trigger']"))&&e&&this.updateTooltipLayout(e,i,e.getAttribute("direction"))}}}},{key:"getStyleValue",value:function(t){return t+"px"}},{key:"getNewDirection",value:function(t){var e;switch(t){case"top":e="bottom";break;case"bottom":e="top";break;case"left":e="right";break;default:e="left"}return e}},{key:"showTooltip",value:function(){var t=this.canDisplayFullText(this.triggerRef);return!this.props.disable&&!this.props.showToolTipIfTruncated||!this.props.disable&&this.props.showToolTipIfTruncated&&!t}},{key:"canDisplayFullText",value:function(t){if(t){var e=t.firstChild&&t.firstChild.scrollWidth?t.firstChild.scrollWidth:0,i=t.offsetWidth,o=e;0===e&&(o=t.scrollWidth);var l=o<=i;return l}return!1}},{key:"showTooltipWithDelay",value:function(){if(!this.pendingTooltip&&this.showTooltip()){var t=this;this.pendingTooltip=setTimeout((function(){t.setTooltipVisible(!0)}),this.props.delay)}}},{key:"updateTooltipLayout",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=e.getBoundingClientRect(),r=t.querySelector("svg"),p=r.getBoundingClientRect();if(t.style.left=this.getStyleValue(n.left),t.style.top=this.getStyleValue(n.top),this.props.mousePos)this.updateLocationBasedOnMousePos(t,this.props.mousePos,i);else{if("top"===o||"bottom"===o){var h=n.left;t.offsetWidth>n.width?(h-=(t.offsetWidth-n.width)/2)<0&&(h=2):t.offsetWidth<n.width&&(h+=(n.width-t.offsetWidth)/2),t.style.left=this.getStyleValue(h),h+t.offsetWidth>l&&(t.style.left=this.getStyleValue(l-t.offsetWidth))}else if("left"===o)for(;t.offsetLeft+t.offsetWidth+p.width>Math.round(n.left);)t.style.left=this.getStyleValue(n.left-t.offsetWidth-p.width);else"right"===o&&(t.style.left=this.getStyleValue(n.right+p.width));if("top"===o)t.style.top=this.getStyleValue(n.top-p.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(n.bottom+p.height);else if("left"===o||"right"===o){var a=n.top;t.offsetHeight>n.height?(a-=(t.offsetHeight-n.height)/2)<0&&(a=n.top):t.offsetHeight<n.height&&(a+=(n.height-t.offsetHeight)/2),t.style.top=this.getStyleValue(a+1),s-t.offsetHeight<n.top&&(t.style.top=this.getStyleValue(s-t.offsetHeight))}"top"===o||"bottom"===o?r.style.left=this.getStyleValue(n.left-t.getBoundingClientRect().left+e.getBoundingClientRect().width/2-p.width/2+1):"left"===o?r.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(r.style.left=this.getStyleValue(2-p.width)),"top"===o?r.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?r.style.top="-11px":"left"!==o&&"right"!==o||(r.style.top=this.getStyleValue(n.top-t.getBoundingClientRect().top+e.offsetHeight/2-p.height/2))}if(this.isOutOfBounds(t)&&t.getAttribute("direction")===o){var u=this.getNewDirection(o);return this.updateTooltipLayout(t,e,u),void t.setAttribute("direction",u)}}},{key:"updateLocationBasedOnMousePos",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=t.querySelector("svg"),r=n.getBoundingClientRect(),p=this.props.mousePos.x,h=this.props.mousePos.y;if("top"===o||"bottom"===o){var a=p-t.offsetWidth/2;l-t.offsetWidth<a?a=l-t.offsetWidth:a<0&&(a=2),t.style.left=this.getStyleValue(a)}else"left"===o?t.style.left=this.getStyleValue(p-t.offsetWidth-r.width-5):"right"===o&&(t.style.left=this.getStyleValue(p+r.width+5));if("top"===o)t.style.top=this.getStyleValue(h-r.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(h+2*r.height);else if("left"===o||"right"===o){var u=h-t.offsetHeight/2;s-t.offsetHeight<u?u=s-t.offsetHeight:u<0&&(u=2),t.style.top=this.getStyleValue(u+1)}"top"===o||"bottom"===o?n.style.left=this.getStyleValue(p-t.getBoundingClientRect().left-r.width/2):"left"===o?n.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(n.style.left=this.getStyleValue(2-r.width)),"top"===o?n.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?n.style.top="-11px":"left"!==o&&"right"!==o||(n.style.top=this.getStyleValue(h-t.getBoundingClientRect().top-r.height/2))}},{key:"isOutOfBounds",value:function(t){var e=parseFloat(t.style.left),i=parseFloat(t.style.top);return e+t.offsetWidth>document.documentElement.clientWidth||e<0||i<0||i+t.offsetHeight>document.documentElement.clientHeight}},{key:"toggleTooltipOnClick",value:function(t){t.stopPropagation(),t.preventDefault(),this.state.isTooltipVisible?this.setTooltipVisible(!1):this.setTooltipVisible(!0)}},{key:"hideTooltipOnScrollAndResize",value:function(t){this.state.isTooltipVisible&&this.setTooltipVisible(!1)}},{key:"tooltipLinkOnClick",value:function(t){window.open(t,"_blank","noopener")}},{key:"render",value:function(){var t=this,e=null,i=null;if(this.props.children){i=r.createElement("div",{"data-id":this.props.id+"-trigger",className:"tooltip-trigger",onMouseOver:this.props.showToolTipOnClick?null:function(){return t.setTooltipVisible(!0)},onMouseLeave:this.props.showToolTipOnClick?null:function(){return t.setTooltipVisible(!1)},onMouseDown:this.props.showToolTipOnClick?null:function(){return t.setTooltipVisible(!1)},onClick:this.props.showToolTipOnClick?function(e){return t.toggleTooltipOnClick(e)}:null,onFocus:this.props.showToolTipOnClick?function(){return t.showTooltipWithDelay()}:null,onBlur:this.props.showToolTipOnClick?function(e){null!==e.relatedTarget&&t.setTooltipVisible(!1)}:null,tabIndex:this.props.showToolTipOnClick?0:null,ref:function(e){return t.triggerRef=e}},this.props.children)}"string"==typeof this.props.tip?e=r.createElement("span",{id:"tooltipContainer"},this.props.tip):"object"===l(this.props.tip)?e=r.createElement("div",{id:"tooltipContainer"},this.props.tip):"function"==typeof this.props.tip&&(e=this.props.tip());var o="common-canvas-tooltip";this.props.className&&(o+=" "+this.props.className);var s=null;if(this.state.isTooltipVisible&&this.props.tooltipLinkHandler&&this.props.link){var n=this.props.tooltipLinkHandler(this.props.link);"object"===l(n)&&n.label&&n.url&&(s=r.createElement(h,{className:"tooltip-link",id:this.props.link.id,onClick:this.tooltipLinkOnClick.bind(this,n.url)},n.label))}var a=null;return(e||s)&&(a=r.createElement(p,null,r.createElement("div",{"data-id":this.props.id,className:o,"aria-hidden":!this.state.isTooltipVisible,direction:this.props.direction},r.createElement("svg",{id:"tipArrow",x:"0px",y:"0px",viewBox:"0 0 9.1 16.1"},r.createElement("polyline",{points:"9.1,15.7 1.4,8.1 9.1,0.5"}),r.createElement("polygon",{points:"8.1,16.1 0,8.1 8.1,0 8.1,1.4 1.4,8.1 8.1,14.7"})),e,s))),r.createElement("div",{className:"tooltip-container"},i,a)}}]),u}(r.Component);u.defaultProps={delay:200,direction:"bottom",showToolTipIfTruncated:!1,showToolTipOnClick:!1};export{u as default};
|
|
2
2
|
//# sourceMappingURL=tooltip.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.es.js","sources":["../../src/tooltip/tooltip.jsx"],"sourcesContent":["/*\n * Copyright 2017-2022 Elyra Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*\n\tThis code is a modified version from portal-common-api for the Elyra canvas tooltips\n*/\n\nimport React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Portal } from \"react-portal\";\nimport { Link } from \"carbon-components-react\";\n\nclass ToolTip extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\tisTooltipVisible: false\n\t\t};\n\n\t\tthis.pendingTooltip = null;\n\t\tthis.hideTooltipOnScrollAndResize = this.hideTooltipOnScrollAndResize.bind(this);\n\t}\n\n\tcomponentDidMount() {\n\t\twindow.addEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.addEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.props.targetObj) {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\twindow.removeEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.removeEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.pendingTooltip) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t}\n\t}\n\n\tsetTooltipVisible(visible) {\n\t\t// clear the display timer if set\n\t\tif (!this.showTooltip() || (!visible && this.pendingTooltip)) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: false\n\t\t\t});\n\t\t}\n\n\n\t\tif (this.showTooltip()) {\n\t\t\tconst tooltip = document.querySelector(\"[data-id='\" + this.props.id + \"']\");\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: visible\n\t\t\t});\n\t\t\t// updates the tooltip display\n\t\t\tif (visible) {\n\t\t\t\tlet tooltipTrigger = null;\n\t\t\t\tif (this.props.targetObj) {\n\t\t\t\t\ttooltipTrigger = this.props.targetObj;\n\t\t\t\t} else {\n\t\t\t\t\ttooltipTrigger = document.querySelector(\"[data-id='\" + this.props.id + \"-trigger']\");\n\t\t\t\t}\n\t\t\t\tif (tooltipTrigger && tooltip) {\n\t\t\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, tooltip.getAttribute(\"direction\"));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tgetStyleValue(value) {\n\t\treturn value + \"px\";\n\t}\n\n\tgetNewDirection(currentDirection) {\n\t\tlet newDirection;\n\t\tswitch (currentDirection) {\n\t\tcase \"top\":\n\t\t\tnewDirection = \"bottom\";\n\t\t\tbreak;\n\t\tcase \"bottom\":\n\t\t\tnewDirection = \"top\";\n\t\t\tbreak;\n\t\tcase \"left\":\n\t\t\tnewDirection = \"right\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tnewDirection = \"left\";\n\t\t}\n\t\treturn newDirection;\n\t}\n\n\tshowTooltip() {\n\t\tconst canDisplayFullText = this.canDisplayFullText(this.triggerRef);\n\t\tconst showToolTip = (\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is false\n\t\t\t(!this.props.disable && !this.props.showToolTipIfTruncated) ||\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is true and string is truncated\n\t\t\t(!this.props.disable && this.props.showToolTipIfTruncated && !canDisplayFullText));\n\t\treturn showToolTip;\n\t}\n\n\t// Return true if the string can be displayed in the available space\n\t// Return false if the string is truncated and ellipsis is shown on the UI\n\t// (offsetWidth) is a measurement in pixels of the element's CSS width, including any borders, padding, and vertical scrollbars\n\t// (scrollWidth) value is equal to the minimum width the element would require\n\t// in order to fit all the content in the viewport without using a horizontal scrollbar\n\tcanDisplayFullText(elem) {\n\t\tif (elem) {\n\t\t\tconst firstChildWidth = elem.firstChild && elem.firstChild.scrollWidth ? elem.firstChild.scrollWidth : 0;\n\t\t\tconst displayWidth = elem.offsetWidth;\n\t\t\tlet fullWidth = firstChildWidth;\n\t\t\tif (firstChildWidth === 0) {\n\t\t\t\tfullWidth = elem.scrollWidth;\n\t\t\t}\n\t\t\tconst canDisplayFullText = fullWidth <= displayWidth;\n\t\t\treturn canDisplayFullText;\n\t\t}\n\t\treturn false; // Show tooltip if we cannot read the width (Canvas objects)\n\t}\n\n\tshowTooltipWithDelay() {\n\n\t\t// set a delay on displaying the tooltip\n\t\tif (!this.pendingTooltip && this.showTooltip()) {\n\t\t\tconst that = this;\n\t\t\tthis.pendingTooltip = setTimeout(function() {\n\t\t\t\tthat.setTooltipVisible(true);\n\t\t\t}, this.props.delay);\n\t\t}\n\n\t}\n\n\tupdateTooltipLayout(tooltip, tooltipTrigger, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst triggerLayout = tooltipTrigger.getBoundingClientRect();\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\t// always initialize tooltip location so it's all visible to ensure adjustments are done on the right size\n\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left);\n\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top);\n\n\t\tif (this.props.mousePos) {\n\t\t\tthis.updateLocationBasedOnMousePos(tooltip, this.props.mousePos, direction);\n\t\t} else { // tooltip relativ to element\n\t\t\t// tooltip - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tlet tooltipLeft = triggerLayout.left;\n\t\t\t\tif (tooltip.offsetWidth > triggerLayout.width) {\n\t\t\t\t\ttooltipLeft -= (tooltip.offsetWidth - triggerLayout.width) / 2; // distribute overlap evenly left and right\n\t\t\t\t\tif (tooltipLeft < 0) {\n\t\t\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetWidth < triggerLayout.width) {\n\t\t\t\t\ttooltipLeft += (triggerLayout.width - tooltip.offsetWidth) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t\t\tif ((tooltipLeft + tooltip.offsetWidth) > viewPortWidth) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(viewPortWidth - tooltip.offsetWidth); // hitting right border\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\t// For long tooltips, tooltip.offsetWidth is updated after setting tooltip.style.left. Ensure tooltip doesn't overlap tooltipTrigger element.\n\t\t\t\twhile ((tooltip.offsetLeft + tooltip.offsetWidth + pointerLayout.width) > triggerLayout.left) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left - tooltip.offsetWidth - pointerLayout.width);\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.right + pointerLayout.width);\n\t\t\t}\n\n\t\t\t// tooltip - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top - pointerLayout.height - tooltip.offsetHeight);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.bottom + pointerLayout.height);\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tlet tooltipTop = triggerLayout.top;\n\t\t\t\tif (tooltip.offsetHeight > triggerLayout.height) {\n\t\t\t\t\ttooltipTop -= (tooltip.offsetHeight - triggerLayout.height) / 2; // distribute overlap evenly top and bottom\n\t\t\t\t\tif (tooltipTop < 0) {\n\t\t\t\t\t\ttooltipTop = triggerLayout.top; // hitting top border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetHeight < triggerLayout.height) {\n\t\t\t\t\ttooltipTop += (triggerLayout.height - tooltip.offsetHeight) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < triggerLayout.top) {\n\t\t\t\t\ttooltip.style.top = this.getStyleValue(viewPortHeight - tooltip.offsetHeight); // hitting bottom border\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// pointer - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(triggerLayout.left - tooltip.getBoundingClientRect().left +\n\t\t\t\t\ttooltipTrigger.getBoundingClientRect().width / 2 - pointerLayout.width / 2\t + pointerCorrection);\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t\t}\n\n\t\t\t// pointer - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.top = \"-11px\";\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(triggerLayout.top - tooltip.getBoundingClientRect().top +\n\t\t\t\t\ttooltipTrigger.offsetHeight / 2 - pointerLayout.height / 2);\n\t\t\t}\n\t\t}\n\n\t\t// check if out-of-bounds at the end and if so, trigger new layout on opposite site if not already re-rendered already\n\t\tif (this.isOutOfBounds(tooltip) && tooltip.getAttribute(\"direction\") === tooltipDirection) {\n\t\t\tconst newDirection = this.getNewDirection(tooltipDirection);\n\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, newDirection);\n\t\t\t// update class name directly, otherwise setState triggers re-render loop in canvas\n\t\t\t// also call after updateTooltipLayout, otherwise the newDirection and class of trigger are the same\n\t\t\ttooltip.setAttribute(\"direction\", newDirection);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tupdateLocationBasedOnMousePos(tooltip, mousePos, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\tconst mouseX = this.props.mousePos.x;\n\t\tconst mouseY = this.props.mousePos.y;\n\t\t// if mouse position is passed in, use the cursor as reference point\n\n\t\t// tooltip - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tlet tooltipLeft = mouseX - tooltip.offsetWidth / 2;\n\t\t\tif ((viewPortWidth - tooltip.offsetWidth) < tooltipLeft) {\n\t\t\t\ttooltipLeft = viewPortWidth - tooltip.offsetWidth; // hitting right border\n\t\t\t} else if (tooltipLeft < 0) {\n\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t}\n\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX - tooltip.offsetWidth - pointerLayout.width - 5);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX + pointerLayout.width + 5);\n\t\t}\n\n\t\t// tooltip - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY - pointerLayout.height - tooltip.offsetHeight);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY + 2 * pointerLayout.height);\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tlet tooltipTop = mouseY - tooltip.offsetHeight / 2;\n\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < tooltipTop) {\n\t\t\t\ttooltipTop = viewPortHeight - tooltip.offsetHeight; // hitting bottom border\n\t\t\t} else if (tooltipTop < 0) {\n\t\t\t\ttooltipTop = 2; // hitting top border\n\t\t\t}\n\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t}\n\n\t\t// pointer - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.left = this.getStyleValue(mouseX - tooltip.getBoundingClientRect().left - pointerLayout.width / 2);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t}\n\n\t\t// pointer - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.top = \"-11px\";\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tpointer.style.top = this.getStyleValue(mouseY - tooltip.getBoundingClientRect().top - pointerLayout.height / 2);\n\t\t}\n\t}\n\n\tisOutOfBounds(tooltip) {\n\t\tconst tooltipLeft = parseFloat(tooltip.style.left);\n\t\tconst tooltipTop = parseFloat(tooltip.style.top);\n\t\treturn (((tooltipLeft + tooltip.offsetWidth) > document.documentElement.clientWidth) || // to the right\n\t\t\t\t(tooltipLeft < 0) || // to the left\n\t\t\t\t(tooltipTop < 0) || // to the top\n\t\t\t\t((tooltipTop + tooltip.offsetHeight) > document.documentElement.clientHeight)); // to the bottom\n\t}\n\n\ttoggleTooltipOnClick(evt) {\n\t\t// 'blur' event occurs before 'click' event. Because of this, onBlur function is called which hides the tooltip.\n\t\t// To prevent this default behavior, stopPropagation and preventDefault is used.\n\t\tevt.stopPropagation();\n\t\tevt.preventDefault();\n\t\tif (this.state.isTooltipVisible) {\n\t\t\t// Tooltip is visible and user clicks on trigger element again, hide tooltip\n\t\t\tthis.setTooltipVisible(false);\n\t\t} else {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\thideTooltipOnScrollAndResize(evt) {\n\t\tif (this.state.isTooltipVisible) {\n\t\t\tthis.setTooltipVisible(false);\n\t\t}\n\t}\n\n\ttooltipLinkOnClick(url) {\n\t\twindow.open(url, \"_blank\", \"noopener\");\n\t}\n\n\trender() {\n\t\tlet tooltipContent = null;\n\t\tlet triggerContent = null;\n\t\tif (this.props.children) {\n\t\t\t// when children are passed in, tooltip will handle show/hide, otherwise consumer has to hide show/hide tooltip\n\t\t\tconst mouseover = () => this.setTooltipVisible(true);\n\t\t\tconst mouseleave = () => this.setTooltipVisible(false);\n\t\t\tconst mousedown = () => this.setTooltipVisible(false);\n\t\t\t// `focus` event occurs before `click`. Adding timeout in onFocus function to ensure click is executed first.\n\t\t\t// Ref - https://stackoverflow.com/a/49512400\n\t\t\tconst onFocus = () => this.showTooltipWithDelay();\n\t\t\tconst onBlur = (evt) => {\n\t\t\t\t// Keep tooltip visible when clicked on a link.\n\t\t\t\t// Since link is an anchor tag without \"href\" attribute, it has relatedTarget=null\n\t\t\t\tif (evt.relatedTarget !== null) {\n\t\t\t\t\tthis.setTooltipVisible(false);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst click = (evt) => this.toggleTooltipOnClick(evt);\n\n\t\t\ttriggerContent = (<div\n\t\t\t\tdata-id={this.props.id + \"-trigger\"}\n\t\t\t\tclassName=\"tooltip-trigger\"\n\t\t\t\tonMouseOver={!this.props.showToolTipOnClick ? mouseover : null}\n\t\t\t\tonMouseLeave={!this.props.showToolTipOnClick ? mouseleave : null}\n\t\t\t\tonMouseDown={!this.props.showToolTipOnClick ? mousedown : null}\n\t\t\t\tonClick={this.props.showToolTipOnClick ? click : null}\n\t\t\t\tonFocus={this.props.showToolTipOnClick ? onFocus : null} // When focused using keyboard\n\t\t\t\tonBlur={this.props.showToolTipOnClick ? onBlur : null}\n\t\t\t\ttabIndex={this.props.showToolTipOnClick ? 0 : null}\n\t\t\t\tref={(ref) => (this.triggerRef = ref)}\n\t\t\t>\n\t\t\t\t{this.props.children}\n\t\t\t</div>);\n\t\t}\n\n\t\tif ((typeof this.props.tip) === \"string\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<span id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</span>\n\t\t\t);\n\t\t} else if ((typeof this.props.tip) === \"object\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<div id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tlet tipClass = \"common-canvas-tooltip\";\n\t\tif (this.props.className) {\n\t\t\ttipClass += \" \" + this.props.className;\n\t\t}\n\n\t\tlet link = null;\n\t\tif (this.state.isTooltipVisible && this.props.tooltipLinkHandler && this.props.link) {\n\t\t\tconst linkInformation = this.props.tooltipLinkHandler(this.props.link);\n\t\t\t// Verify tooltipLinkHandler returns object in correct format\n\t\t\tif (typeof linkInformation === \"object\" && linkInformation.label && linkInformation.url) {\n\t\t\t\tlink = (<Link\n\t\t\t\t\tclassName=\"tooltip-link\"\n\t\t\t\t\tid={this.props.link.id}\n\t\t\t\t\tonClick={this.tooltipLinkOnClick.bind(this, linkInformation.url)}\n\t\t\t\t>\n\t\t\t\t\t{linkInformation.label}\n\t\t\t\t</Link>);\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<div className=\"tooltip-container\">\n\t\t\t\t{triggerContent}\n\t\t\t\t<Portal>\n\t\t\t\t\t<div data-id={this.props.id} className={tipClass} aria-hidden={!this.state.isTooltipVisible} direction={this.props.direction}>\n\t\t\t\t\t\t<svg id=\"tipArrow\" x=\"0px\" y=\"0px\" viewBox=\"0 0 9.1 16.1\">\n\t\t\t\t\t\t\t<polyline points=\"9.1,15.7 1.4,8.1 9.1,0.5\" />\n\t\t\t\t\t\t\t<polygon points=\"8.1,16.1 0,8.1 8.1,0 8.1,1.4 1.4,8.1 8.1,14.7\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t{tooltipContent}\n\t\t\t\t\t\t{link}\n\t\t\t\t\t</div>\n\t\t\t\t</Portal>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nToolTip.propTypes = {\n\ttip: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,\n\tlink: PropTypes.object,\n\ttooltipLinkHandler: PropTypes.func,\n\tdirection: PropTypes.oneOf([\"left\", \"right\", \"top\", \"bottom\"]),\n\tchildren: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n\ttargetObj: PropTypes.object,\n\tid: PropTypes.string.isRequired,\n\tclassName: PropTypes.string,\n\tmousePos: PropTypes.object,\n\tdisable: PropTypes.bool, // Tooltip will not show if disabled\n\tshowToolTipIfTruncated: PropTypes.bool, // Set to true to only display tooltip if full text does not fit in displayable width\n\tdelay: PropTypes.number,\n\tshowToolTipOnClick: PropTypes.bool\n};\n\nToolTip.defaultProps = {\n\tdelay: 200,\n\tdirection: \"bottom\",\n\tshowToolTipIfTruncated: false, // False will always show Tooltip even when whole word can be displayed\n\tshowToolTipOnClick: false\n};\n\nexport default ToolTip;\n"],"names":["ToolTip","props","_classCallCheck","_this","state","isTooltipVisible","pendingTooltip","hideTooltipOnScrollAndResize","bind","window","addEventListener","this","targetObj","setTooltipVisible","removeEventListener","clearTimeout","visible","showTooltip","setState","tooltip","document","querySelector","id","tooltipTrigger","updateTooltipLayout","getAttribute","value","currentDirection","newDirection","canDisplayFullText","triggerRef","disable","showToolTipIfTruncated","elem","firstChildWidth","firstChild","scrollWidth","displayWidth","offsetWidth","fullWidth","that","setTimeout","delay","direction","tooltipDirection","viewPortWidth","documentElement","clientWidth","viewPortHeight","clientHeight","triggerLayout","getBoundingClientRect","pointer","pointerLayout","style","left","getStyleValue","top","mousePos","updateLocationBasedOnMousePos","tooltipLeft","width","offsetLeft","right","height","offsetHeight","bottom","tooltipTop","isOutOfBounds","getNewDirection","setAttribute","mouseX","x","mouseY","y","parseFloat","evt","stopPropagation","preventDefault","url","open","tooltipContent","triggerContent","children","React","className","onMouseOver","showToolTipOnClick","_this2","onMouseLeave","onMouseDown","onClick","toggleTooltipOnClick","onFocus","showTooltipWithDelay","onBlur","relatedTarget","tabIndex","ref","tip","_typeof","tipClass","link","tooltipLinkHandler","linkInformation","label","Link","tooltipLinkOnClick","Portal","viewBox","points","Component","defaultProps"],"m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pF,IAAME,EAAkB7F,KAAKV,MAAMsG,mBAAmB5F,KAAKV,MAAMqG,MAElC,WAA3BF,EAAOI,IAAgCA,EAAgBC,OAASD,EAAgBzB,MACnFuB,EAAQlB,gBAACsB,GACRrB,UAAU,eACV/D,GAAIX,KAAKV,MAAMqG,KAAKhF,GACpBqE,QAAShF,KAAKgG,mBAAmBnG,KAAKG,KAAM6F,EAAgBzB,MAE3DyB,EAAgBC,QAKpB,OACCrB,uBAAKC,UAAU,qBACbH,EACDE,gBAACwB,OACAxB,uBAAK,UAASzE,KAAKV,MAAMqB,GAAI+D,UAAWgB,EAAU,eAAc1F,KAAKP,MAAMC,iBAAkBsC,UAAWhC,KAAKV,MAAM0C,WAClHyC,uBAAK9D,GAAG,WAAWkD,EAAE,MAAME,EAAE,MAAMmC,QAAQ,gBAC1CzB,4BAAU0B,OAAO,6BACjB1B,2BAAS0B,OAAO,mDAEhB7B,EACAqB,YApYelB,EAAM2B,WA4Z5B/G,EAAQgH,aAAe,CACtBtE,MAAO,IACPC,UAAW,SACXX,wBAAwB,EACxBuD,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"tooltip.es.js","sources":["../../src/tooltip/tooltip.jsx"],"sourcesContent":["/*\n * Copyright 2017-2022 Elyra Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*\n\tThis code is a modified version from portal-common-api for the Elyra canvas tooltips\n*/\n\nimport React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Portal } from \"react-portal\";\nimport { Link } from \"carbon-components-react\";\n\nclass ToolTip extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\tisTooltipVisible: false\n\t\t};\n\n\t\tthis.pendingTooltip = null;\n\t\tthis.hideTooltipOnScrollAndResize = this.hideTooltipOnScrollAndResize.bind(this);\n\t}\n\n\tcomponentDidMount() {\n\t\twindow.addEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.addEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.props.targetObj) {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\twindow.removeEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.removeEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.pendingTooltip) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t}\n\t}\n\n\tsetTooltipVisible(visible) {\n\t\t// clear the display timer if set\n\t\tif (!this.showTooltip() || (!visible && this.pendingTooltip)) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: false\n\t\t\t});\n\t\t}\n\n\n\t\tif (this.showTooltip()) {\n\t\t\tconst tooltip = document.querySelector(\"[data-id='\" + this.props.id + \"']\");\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: visible\n\t\t\t});\n\t\t\t// updates the tooltip display\n\t\t\tif (visible) {\n\t\t\t\tlet tooltipTrigger = null;\n\t\t\t\tif (this.props.targetObj) {\n\t\t\t\t\ttooltipTrigger = this.props.targetObj;\n\t\t\t\t} else {\n\t\t\t\t\ttooltipTrigger = document.querySelector(\"[data-id='\" + this.props.id + \"-trigger']\");\n\t\t\t\t}\n\t\t\t\tif (tooltipTrigger && tooltip) {\n\t\t\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, tooltip.getAttribute(\"direction\"));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tgetStyleValue(value) {\n\t\treturn value + \"px\";\n\t}\n\n\tgetNewDirection(currentDirection) {\n\t\tlet newDirection;\n\t\tswitch (currentDirection) {\n\t\tcase \"top\":\n\t\t\tnewDirection = \"bottom\";\n\t\t\tbreak;\n\t\tcase \"bottom\":\n\t\t\tnewDirection = \"top\";\n\t\t\tbreak;\n\t\tcase \"left\":\n\t\t\tnewDirection = \"right\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tnewDirection = \"left\";\n\t\t}\n\t\treturn newDirection;\n\t}\n\n\tshowTooltip() {\n\t\tconst canDisplayFullText = this.canDisplayFullText(this.triggerRef);\n\t\tconst showToolTip = (\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is false\n\t\t\t(!this.props.disable && !this.props.showToolTipIfTruncated) ||\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is true and string is truncated\n\t\t\t(!this.props.disable && this.props.showToolTipIfTruncated && !canDisplayFullText));\n\t\treturn showToolTip;\n\t}\n\n\t// Return true if the string can be displayed in the available space\n\t// Return false if the string is truncated and ellipsis is shown on the UI\n\t// (offsetWidth) is a measurement in pixels of the element's CSS width, including any borders, padding, and vertical scrollbars\n\t// (scrollWidth) value is equal to the minimum width the element would require\n\t// in order to fit all the content in the viewport without using a horizontal scrollbar\n\tcanDisplayFullText(elem) {\n\t\tif (elem) {\n\t\t\tconst firstChildWidth = elem.firstChild && elem.firstChild.scrollWidth ? elem.firstChild.scrollWidth : 0;\n\t\t\tconst displayWidth = elem.offsetWidth;\n\t\t\tlet fullWidth = firstChildWidth;\n\t\t\tif (firstChildWidth === 0) {\n\t\t\t\tfullWidth = elem.scrollWidth;\n\t\t\t}\n\t\t\tconst canDisplayFullText = fullWidth <= displayWidth;\n\t\t\treturn canDisplayFullText;\n\t\t}\n\t\treturn false; // Show tooltip if we cannot read the width (Canvas objects)\n\t}\n\n\tshowTooltipWithDelay() {\n\n\t\t// set a delay on displaying the tooltip\n\t\tif (!this.pendingTooltip && this.showTooltip()) {\n\t\t\tconst that = this;\n\t\t\tthis.pendingTooltip = setTimeout(function() {\n\t\t\t\tthat.setTooltipVisible(true);\n\t\t\t}, this.props.delay);\n\t\t}\n\n\t}\n\n\tupdateTooltipLayout(tooltip, tooltipTrigger, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst triggerLayout = tooltipTrigger.getBoundingClientRect();\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\t// always initialize tooltip location so it's all visible to ensure adjustments are done on the right size\n\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left);\n\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top);\n\n\t\tif (this.props.mousePos) {\n\t\t\tthis.updateLocationBasedOnMousePos(tooltip, this.props.mousePos, direction);\n\t\t} else { // tooltip relativ to element\n\t\t\t// tooltip - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tlet tooltipLeft = triggerLayout.left;\n\t\t\t\tif (tooltip.offsetWidth > triggerLayout.width) {\n\t\t\t\t\ttooltipLeft -= (tooltip.offsetWidth - triggerLayout.width) / 2; // distribute overlap evenly left and right\n\t\t\t\t\tif (tooltipLeft < 0) {\n\t\t\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetWidth < triggerLayout.width) {\n\t\t\t\t\ttooltipLeft += (triggerLayout.width - tooltip.offsetWidth) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t\t\tif ((tooltipLeft + tooltip.offsetWidth) > viewPortWidth) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(viewPortWidth - tooltip.offsetWidth); // hitting right border\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\t// For long tooltips, tooltip.offsetWidth is updated after setting tooltip.style.left. Ensure tooltip doesn't overlap tooltipTrigger element.\n\t\t\t\twhile ((tooltip.offsetLeft + tooltip.offsetWidth + pointerLayout.width) > Math.round(triggerLayout.left)) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left - tooltip.offsetWidth - pointerLayout.width);\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.right + pointerLayout.width);\n\t\t\t}\n\n\t\t\t// tooltip - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top - pointerLayout.height - tooltip.offsetHeight);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.bottom + pointerLayout.height);\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tlet tooltipTop = triggerLayout.top;\n\t\t\t\tif (tooltip.offsetHeight > triggerLayout.height) {\n\t\t\t\t\ttooltipTop -= (tooltip.offsetHeight - triggerLayout.height) / 2; // distribute overlap evenly top and bottom\n\t\t\t\t\tif (tooltipTop < 0) {\n\t\t\t\t\t\ttooltipTop = triggerLayout.top; // hitting top border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetHeight < triggerLayout.height) {\n\t\t\t\t\ttooltipTop += (triggerLayout.height - tooltip.offsetHeight) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < triggerLayout.top) {\n\t\t\t\t\ttooltip.style.top = this.getStyleValue(viewPortHeight - tooltip.offsetHeight); // hitting bottom border\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// pointer - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(triggerLayout.left - tooltip.getBoundingClientRect().left +\n\t\t\t\t\ttooltipTrigger.getBoundingClientRect().width / 2 - pointerLayout.width / 2\t + pointerCorrection);\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t\t}\n\n\t\t\t// pointer - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.top = \"-11px\";\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(triggerLayout.top - tooltip.getBoundingClientRect().top +\n\t\t\t\t\ttooltipTrigger.offsetHeight / 2 - pointerLayout.height / 2);\n\t\t\t}\n\t\t}\n\n\t\t// check if out-of-bounds at the end and if so, trigger new layout on opposite site if not already re-rendered already\n\t\tif (this.isOutOfBounds(tooltip) && tooltip.getAttribute(\"direction\") === tooltipDirection) {\n\t\t\tconst newDirection = this.getNewDirection(tooltipDirection);\n\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, newDirection);\n\t\t\t// update class name directly, otherwise setState triggers re-render loop in canvas\n\t\t\t// also call after updateTooltipLayout, otherwise the newDirection and class of trigger are the same\n\t\t\ttooltip.setAttribute(\"direction\", newDirection);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tupdateLocationBasedOnMousePos(tooltip, mousePos, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\tconst mouseX = this.props.mousePos.x;\n\t\tconst mouseY = this.props.mousePos.y;\n\t\t// if mouse position is passed in, use the cursor as reference point\n\n\t\t// tooltip - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tlet tooltipLeft = mouseX - tooltip.offsetWidth / 2;\n\t\t\tif ((viewPortWidth - tooltip.offsetWidth) < tooltipLeft) {\n\t\t\t\ttooltipLeft = viewPortWidth - tooltip.offsetWidth; // hitting right border\n\t\t\t} else if (tooltipLeft < 0) {\n\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t}\n\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX - tooltip.offsetWidth - pointerLayout.width - 5);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX + pointerLayout.width + 5);\n\t\t}\n\n\t\t// tooltip - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY - pointerLayout.height - tooltip.offsetHeight);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY + 2 * pointerLayout.height);\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tlet tooltipTop = mouseY - tooltip.offsetHeight / 2;\n\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < tooltipTop) {\n\t\t\t\ttooltipTop = viewPortHeight - tooltip.offsetHeight; // hitting bottom border\n\t\t\t} else if (tooltipTop < 0) {\n\t\t\t\ttooltipTop = 2; // hitting top border\n\t\t\t}\n\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t}\n\n\t\t// pointer - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.left = this.getStyleValue(mouseX - tooltip.getBoundingClientRect().left - pointerLayout.width / 2);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t}\n\n\t\t// pointer - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.top = \"-11px\";\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tpointer.style.top = this.getStyleValue(mouseY - tooltip.getBoundingClientRect().top - pointerLayout.height / 2);\n\t\t}\n\t}\n\n\tisOutOfBounds(tooltip) {\n\t\tconst tooltipLeft = parseFloat(tooltip.style.left);\n\t\tconst tooltipTop = parseFloat(tooltip.style.top);\n\t\treturn (((tooltipLeft + tooltip.offsetWidth) > document.documentElement.clientWidth) || // to the right\n\t\t\t\t(tooltipLeft < 0) || // to the left\n\t\t\t\t(tooltipTop < 0) || // to the top\n\t\t\t\t((tooltipTop + tooltip.offsetHeight) > document.documentElement.clientHeight)); // to the bottom\n\t}\n\n\ttoggleTooltipOnClick(evt) {\n\t\t// 'blur' event occurs before 'click' event. Because of this, onBlur function is called which hides the tooltip.\n\t\t// To prevent this default behavior, stopPropagation and preventDefault is used.\n\t\tevt.stopPropagation();\n\t\tevt.preventDefault();\n\t\tif (this.state.isTooltipVisible) {\n\t\t\t// Tooltip is visible and user clicks on trigger element again, hide tooltip\n\t\t\tthis.setTooltipVisible(false);\n\t\t} else {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\thideTooltipOnScrollAndResize(evt) {\n\t\tif (this.state.isTooltipVisible) {\n\t\t\tthis.setTooltipVisible(false);\n\t\t}\n\t}\n\n\ttooltipLinkOnClick(url) {\n\t\twindow.open(url, \"_blank\", \"noopener\");\n\t}\n\n\trender() {\n\t\tlet tooltipContent = null;\n\t\tlet triggerContent = null;\n\t\tif (this.props.children) {\n\t\t\t// when children are passed in, tooltip will handle show/hide, otherwise consumer has to hide show/hide tooltip\n\t\t\tconst mouseover = () => this.setTooltipVisible(true);\n\t\t\tconst mouseleave = () => this.setTooltipVisible(false);\n\t\t\tconst mousedown = () => this.setTooltipVisible(false);\n\t\t\t// `focus` event occurs before `click`. Adding timeout in onFocus function to ensure click is executed first.\n\t\t\t// Ref - https://stackoverflow.com/a/49512400\n\t\t\tconst onFocus = () => this.showTooltipWithDelay();\n\t\t\tconst onBlur = (evt) => {\n\t\t\t\t// Keep tooltip visible when clicked on a link.\n\t\t\t\t// Since link is an anchor tag without \"href\" attribute, it has relatedTarget=null\n\t\t\t\tif (evt.relatedTarget !== null) {\n\t\t\t\t\tthis.setTooltipVisible(false);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst click = (evt) => this.toggleTooltipOnClick(evt);\n\n\t\t\ttriggerContent = (<div\n\t\t\t\tdata-id={this.props.id + \"-trigger\"}\n\t\t\t\tclassName=\"tooltip-trigger\"\n\t\t\t\tonMouseOver={!this.props.showToolTipOnClick ? mouseover : null}\n\t\t\t\tonMouseLeave={!this.props.showToolTipOnClick ? mouseleave : null}\n\t\t\t\tonMouseDown={!this.props.showToolTipOnClick ? mousedown : null}\n\t\t\t\tonClick={this.props.showToolTipOnClick ? click : null}\n\t\t\t\tonFocus={this.props.showToolTipOnClick ? onFocus : null} // When focused using keyboard\n\t\t\t\tonBlur={this.props.showToolTipOnClick ? onBlur : null}\n\t\t\t\ttabIndex={this.props.showToolTipOnClick ? 0 : null}\n\t\t\t\tref={(ref) => (this.triggerRef = ref)}\n\t\t\t>\n\t\t\t\t{this.props.children}\n\t\t\t</div>);\n\t\t}\n\n\t\tif ((typeof this.props.tip) === \"string\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<span id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</span>\n\t\t\t);\n\t\t} else if ((typeof this.props.tip) === \"object\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<div id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</div>\n\t\t\t);\n\t\t} else if ((typeof this.props.tip) === \"function\") {\n\t\t\ttooltipContent = this.props.tip();\n\t\t}\n\n\t\tlet tipClass = \"common-canvas-tooltip\";\n\t\tif (this.props.className) {\n\t\t\ttipClass += \" \" + this.props.className;\n\t\t}\n\n\t\tlet link = null;\n\t\tif (this.state.isTooltipVisible && this.props.tooltipLinkHandler && this.props.link) {\n\t\t\tconst linkInformation = this.props.tooltipLinkHandler(this.props.link);\n\t\t\t// Verify tooltipLinkHandler returns object in correct format\n\t\t\tif (typeof linkInformation === \"object\" && linkInformation.label && linkInformation.url) {\n\t\t\t\tlink = (<Link\n\t\t\t\t\tclassName=\"tooltip-link\"\n\t\t\t\t\tid={this.props.link.id}\n\t\t\t\t\tonClick={this.tooltipLinkOnClick.bind(this, linkInformation.url)}\n\t\t\t\t>\n\t\t\t\t\t{linkInformation.label}\n\t\t\t\t</Link>);\n\t\t\t}\n\t\t}\n\n\t\tlet tooltip = null;\n\t\tif (tooltipContent || link) {\n\t\t\ttooltip = (\n\t\t\t\t<Portal>\n\t\t\t\t\t<div data-id={this.props.id} className={tipClass} aria-hidden={!this.state.isTooltipVisible} direction={this.props.direction}>\n\t\t\t\t\t\t<svg id=\"tipArrow\" x=\"0px\" y=\"0px\" viewBox=\"0 0 9.1 16.1\">\n\t\t\t\t\t\t\t<polyline points=\"9.1,15.7 1.4,8.1 9.1,0.5\" />\n\t\t\t\t\t\t\t<polygon points=\"8.1,16.1 0,8.1 8.1,0 8.1,1.4 1.4,8.1 8.1,14.7\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t{tooltipContent}\n\t\t\t\t\t\t{link}\n\t\t\t\t\t</div>\n\t\t\t\t</Portal>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div className=\"tooltip-container\">\n\t\t\t\t{triggerContent}\n\t\t\t\t{tooltip}\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nToolTip.propTypes = {\n\ttip: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired,\n\tlink: PropTypes.object,\n\ttooltipLinkHandler: PropTypes.func,\n\tdirection: PropTypes.oneOf([\"left\", \"right\", \"top\", \"bottom\"]),\n\tchildren: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n\ttargetObj: PropTypes.object,\n\tid: PropTypes.string.isRequired,\n\tclassName: PropTypes.string,\n\tmousePos: PropTypes.object,\n\tdisable: PropTypes.bool, // Tooltip will not show if disabled\n\tshowToolTipIfTruncated: PropTypes.bool, // Set to true to only display tooltip if full text does not fit in displayable width\n\tdelay: PropTypes.number,\n\tshowToolTipOnClick: PropTypes.bool\n};\n\nToolTip.defaultProps = {\n\tdelay: 200,\n\tdirection: \"bottom\",\n\tshowToolTipIfTruncated: false, // False will always show Tooltip even when whole word can be displayed\n\tshowToolTipOnClick: false\n};\n\nexport default ToolTip;\n"],"names":["ToolTip","props","_classCallCheck","_this","state","isTooltipVisible","pendingTooltip","hideTooltipOnScrollAndResize","bind","window","addEventListener","this","targetObj","setTooltipVisible","removeEventListener","clearTimeout","visible","showTooltip","setState","tooltip","document","querySelector","id","tooltipTrigger","updateTooltipLayout","getAttribute","value","currentDirection","newDirection","canDisplayFullText","triggerRef","disable","showToolTipIfTruncated","elem","firstChildWidth","firstChild","scrollWidth","displayWidth","offsetWidth","fullWidth","that","setTimeout","delay","direction","tooltipDirection","viewPortWidth","documentElement","clientWidth","viewPortHeight","clientHeight","triggerLayout","getBoundingClientRect","pointer","pointerLayout","style","left","getStyleValue","top","mousePos","updateLocationBasedOnMousePos","tooltipLeft","width","offsetLeft","Math","round","right","height","offsetHeight","bottom","tooltipTop","isOutOfBounds","getNewDirection","setAttribute","mouseX","x","mouseY","y","parseFloat","evt","stopPropagation","preventDefault","url","open","tooltipContent","triggerContent","children","React","className","onMouseOver","showToolTipOnClick","_this2","onMouseLeave","onMouseDown","onClick","toggleTooltipOnClick","onFocus","showTooltipWithDelay","onBlur","relatedTarget","tabIndex","ref","tip","_typeof","tipClass","link","tooltipLinkHandler","linkInformation","label","Link","tooltipLinkOnClick","Portal","viewBox","points","Component","defaultProps"],"mappings":"ypBAwBMA,gCACL,WAAYC,GAAO,MAAA,OAAAC,WAClBC,cAAMF,IACDG,MAAQ,CACZC,kBAAkB,GAGnBF,EAAKG,eAAiB,KACtBH,EAAKI,6BAA+BJ,EAAKI,6BAA6BC,wDAGvE,WACCC,OAAOC,iBAAiB,SAAUC,KAAKJ,8BAA8B,GACrEE,OAAOC,iBAAiB,SAAUC,KAAKJ,8BAA8B,GACjEI,KAAKV,MAAMW,WACdD,KAAKE,mBAAkB,uCAIzB,WACCJ,OAAOK,oBAAoB,SAAUH,KAAKJ,8BAA8B,GACxEE,OAAOK,oBAAoB,SAAUH,KAAKJ,8BAA8B,GACpEI,KAAKL,gBACRS,aAAaJ,KAAKL,iDAIpB,SAAkBU,GAWjB,KATKL,KAAKM,gBAAmBD,GAAWL,KAAKL,kBAC5CS,aAAaJ,KAAKL,gBAClBK,KAAKL,eAAiB,KACtBK,KAAKO,SAAS,CACbb,kBAAkB,KAKhBM,KAAKM,cAAe,CACvB,IAAME,EAAUC,SAASC,cAAc,aAAeV,KAAKV,MAAMqB,GAAK,MAMtE,GALAX,KAAKL,eAAiB,KACtBK,KAAKO,SAAS,CACbb,iBAAkBW,IAGfA,EAAS,CACZ,IAAIO,EAAiB,MAEpBA,EADGZ,KAAKV,MAAMW,UACGD,KAAKV,MAAMW,UAEXQ,SAASC,cAAc,aAAeV,KAAKV,MAAMqB,GAAK,gBAElDH,GACrBR,KAAKa,oBAAoBL,EAASI,EAAgBJ,EAAQM,aAAa,6CAM3E,SAAcC,GACb,OAAOA,EAAQ,oCAGhB,SAAgBC,GACf,IAAIC,EACJ,OAAQD,GACR,IAAK,MACJC,EAAe,SACf,MACD,IAA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MoG,KAGwB,mBAApB1F,KAAKV,MAAMoG,MAC7BlB,EAAiBxE,KAAKV,MAAMoG,OAG7B,IAAIE,EAAW,wBACX5F,KAAKV,MAAMsF,YACdgB,GAAY,IAAM5F,KAAKV,MAAMsF,WAG9B,IAAIiB,EAAO,KACX,GAAI7F,KAAKP,MAAMC,kBAAoBM,KAAKV,MAAMwG,oBAAsB9F,KAAKV,MAAMuG,KAAM,CACpF,IAAME,EAAkB/F,KAAKV,MAAMwG,mBAAmB9F,KAAKV,MAAMuG,MAElC,WAA3BF,EAAOI,IAAgCA,EAAgBC,OAASD,EAAgBzB,MACnFuB,EAAQlB,gBAACsB,GACRrB,UAAU,eACVjE,GAAIX,KAAKV,MAAMuG,KAAKlF,GACpBuE,QAASlF,KAAKkG,mBAAmBrG,KAAKG,KAAM+F,EAAgBzB,MAE3DyB,EAAgBC,QAKpB,IAAIxF,EAAU,KAgBd,OAfIgE,GAAkBqB,KACrBrF,EACCmE,gBAACwB,OACAxB,uBAAK,UAAS3E,KAAKV,MAAMqB,GAAIiE,UAAWgB,EAAU,eAAc5F,KAAKP,MAAMC,iBAAkBsC,UAAWhC,KAAKV,MAAM0C,WAClH2C,uBAAKhE,GAAG,WAAWoD,EAAE,MAAME,EAAE,MAAMmC,QAAQ,gBAC1CzB,4BAAU0B,OAAO,6BACjB1B,2BAAS0B,OAAO,mDAEhB7B,EACAqB,KAOJlB,uBAAKC,UAAU,qBACbH,EACAjE,UA/YiBmE,EAAM2B,WAqa5BjH,EAAQkH,aAAe,CACtBxE,MAAO,IACPC,UAAW,SACXX,wBAAwB,EACxByD,oBAAoB"}
|
package/dist/lib/tooltip.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("../getPrototypeOf-bf88242f.js"),e=require("../createClass-6db89a23.js"),i=require("react"),o=require("react-portal"),l=require("carbon-components-react");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=s(i);function r(e){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var o,l=t._getPrototypeOf(e);if(i){var s=t._getPrototypeOf(this).constructor;o=Reflect.construct(l,arguments,s)}else o=l.apply(this,arguments);return t._possibleConstructorReturn(this,o)}}var p=function(i){t._inherits(p,i);var s=r(p);function p(i){var o;return e._classCallCheck(this,p),(o=s.call(this,i)).state={isTooltipVisible:!1},o.pendingTooltip=null,o.hideTooltipOnScrollAndResize=o.hideTooltipOnScrollAndResize.bind(t._assertThisInitialized(o)),o}return e._createClass(p,[{key:"componentDidMount",value:function(){window.addEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.addEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.props.targetObj&&this.setTooltipVisible(!0)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.removeEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.pendingTooltip&&clearTimeout(this.pendingTooltip)}},{key:"setTooltipVisible",value:function(t){if((!this.showTooltip()||!t&&this.pendingTooltip)&&(clearTimeout(this.pendingTooltip),this.pendingTooltip=null,this.setState({isTooltipVisible:!1})),this.showTooltip()){var e=document.querySelector("[data-id='"+this.props.id+"']");if(this.pendingTooltip=null,this.setState({isTooltipVisible:t}),t){var i=null;(i=this.props.targetObj?this.props.targetObj:document.querySelector("[data-id='"+this.props.id+"-trigger']"))&&e&&this.updateTooltipLayout(e,i,e.getAttribute("direction"))}}}},{key:"getStyleValue",value:function(t){return t+"px"}},{key:"getNewDirection",value:function(t){var e;switch(t){case"top":e="bottom";break;case"bottom":e="top";break;case"left":e="right";break;default:e="left"}return e}},{key:"showTooltip",value:function(){var t=this.canDisplayFullText(this.triggerRef);return!this.props.disable&&!this.props.showToolTipIfTruncated||!this.props.disable&&this.props.showToolTipIfTruncated&&!t}},{key:"canDisplayFullText",value:function(t){if(t){var e=t.firstChild&&t.firstChild.scrollWidth?t.firstChild.scrollWidth:0,i=t.offsetWidth,o=e;0===e&&(o=t.scrollWidth);var l=o<=i;return l}return!1}},{key:"showTooltipWithDelay",value:function(){if(!this.pendingTooltip&&this.showTooltip()){var t=this;this.pendingTooltip=setTimeout((function(){t.setTooltipVisible(!0)}),this.props.delay)}}},{key:"updateTooltipLayout",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=e.getBoundingClientRect(),r=t.querySelector("svg"),p=r.getBoundingClientRect();if(t.style.left=this.getStyleValue(n.left),t.style.top=this.getStyleValue(n.top),this.props.mousePos)this.updateLocationBasedOnMousePos(t,this.props.mousePos,i);else{if("top"===o||"bottom"===o){var h=n.left;t.offsetWidth>n.width?(h-=(t.offsetWidth-n.width)/2)<0&&(h=2):t.offsetWidth<n.width&&(h+=(n.width-t.offsetWidth)/2),t.style.left=this.getStyleValue(h),h+t.offsetWidth>l&&(t.style.left=this.getStyleValue(l-t.offsetWidth))}else if("left"===o)for(;t.offsetLeft+t.offsetWidth+p.width>n.left;)t.style.left=this.getStyleValue(n.left-t.offsetWidth-p.width);else"right"===o&&(t.style.left=this.getStyleValue(n.right+p.width));if("top"===o)t.style.top=this.getStyleValue(n.top-p.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(n.bottom+p.height);else if("left"===o||"right"===o){var u=n.top;t.offsetHeight>n.height?(u-=(t.offsetHeight-n.height)/2)<0&&(u=n.top):t.offsetHeight<n.height&&(u+=(n.height-t.offsetHeight)/2),t.style.top=this.getStyleValue(u+1),s-t.offsetHeight<n.top&&(t.style.top=this.getStyleValue(s-t.offsetHeight))}"top"===o||"bottom"===o?r.style.left=this.getStyleValue(n.left-t.getBoundingClientRect().left+e.getBoundingClientRect().width/2-p.width/2+1):"left"===o?r.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(r.style.left=this.getStyleValue(2-p.width)),"top"===o?r.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?r.style.top="-11px":"left"!==o&&"right"!==o||(r.style.top=this.getStyleValue(n.top-t.getBoundingClientRect().top+e.offsetHeight/2-p.height/2))}if(this.isOutOfBounds(t)&&t.getAttribute("direction")===o){var a=this.getNewDirection(o);return this.updateTooltipLayout(t,e,a),void t.setAttribute("direction",a)}}},{key:"updateLocationBasedOnMousePos",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=t.querySelector("svg"),r=n.getBoundingClientRect(),p=this.props.mousePos.x,h=this.props.mousePos.y;if("top"===o||"bottom"===o){var u=p-t.offsetWidth/2;l-t.offsetWidth<u?u=l-t.offsetWidth:u<0&&(u=2),t.style.left=this.getStyleValue(u)}else"left"===o?t.style.left=this.getStyleValue(p-t.offsetWidth-r.width-5):"right"===o&&(t.style.left=this.getStyleValue(p+r.width+5));if("top"===o)t.style.top=this.getStyleValue(h-r.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(h+2*r.height);else if("left"===o||"right"===o){var a=h-t.offsetHeight/2;s-t.offsetHeight<a?a=s-t.offsetHeight:a<0&&(a=2),t.style.top=this.getStyleValue(a+1)}"top"===o||"bottom"===o?n.style.left=this.getStyleValue(p-t.getBoundingClientRect().left-r.width/2):"left"===o?n.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(n.style.left=this.getStyleValue(2-r.width)),"top"===o?n.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?n.style.top="-11px":"left"!==o&&"right"!==o||(n.style.top=this.getStyleValue(h-t.getBoundingClientRect().top-r.height/2))}},{key:"isOutOfBounds",value:function(t){var e=parseFloat(t.style.left),i=parseFloat(t.style.top);return e+t.offsetWidth>document.documentElement.clientWidth||e<0||i<0||i+t.offsetHeight>document.documentElement.clientHeight}},{key:"toggleTooltipOnClick",value:function(t){t.stopPropagation(),t.preventDefault(),this.state.isTooltipVisible?this.setTooltipVisible(!1):this.setTooltipVisible(!0)}},{key:"hideTooltipOnScrollAndResize",value:function(t){this.state.isTooltipVisible&&this.setTooltipVisible(!1)}},{key:"tooltipLinkOnClick",value:function(t){window.open(t,"_blank","noopener")}},{key:"render",value:function(){var e=this,i=null,s=null;if(this.props.children){s=n.default.createElement("div",{"data-id":this.props.id+"-trigger",className:"tooltip-trigger",onMouseOver:this.props.showToolTipOnClick?null:function(){return e.setTooltipVisible(!0)},onMouseLeave:this.props.showToolTipOnClick?null:function(){return e.setTooltipVisible(!1)},onMouseDown:this.props.showToolTipOnClick?null:function(){return e.setTooltipVisible(!1)},onClick:this.props.showToolTipOnClick?function(t){return e.toggleTooltipOnClick(t)}:null,onFocus:this.props.showToolTipOnClick?function(){return e.showTooltipWithDelay()}:null,onBlur:this.props.showToolTipOnClick?function(t){null!==t.relatedTarget&&e.setTooltipVisible(!1)}:null,tabIndex:this.props.showToolTipOnClick?0:null,ref:function(t){return e.triggerRef=t}},this.props.children)}"string"==typeof this.props.tip?i=n.default.createElement("span",{id:"tooltipContainer"},this.props.tip):"object"===t._typeof(this.props.tip)
|
|
1
|
+
"use strict";var t=require("../getPrototypeOf-bf88242f.js"),e=require("../createClass-6db89a23.js"),i=require("react"),o=require("react-portal"),l=require("carbon-components-react");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=s(i);function r(e){var i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var o,l=t._getPrototypeOf(e);if(i){var s=t._getPrototypeOf(this).constructor;o=Reflect.construct(l,arguments,s)}else o=l.apply(this,arguments);return t._possibleConstructorReturn(this,o)}}var p=function(i){t._inherits(p,i);var s=r(p);function p(i){var o;return e._classCallCheck(this,p),(o=s.call(this,i)).state={isTooltipVisible:!1},o.pendingTooltip=null,o.hideTooltipOnScrollAndResize=o.hideTooltipOnScrollAndResize.bind(t._assertThisInitialized(o)),o}return e._createClass(p,[{key:"componentDidMount",value:function(){window.addEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.addEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.props.targetObj&&this.setTooltipVisible(!0)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.hideTooltipOnScrollAndResize,!0),window.removeEventListener("resize",this.hideTooltipOnScrollAndResize,!0),this.pendingTooltip&&clearTimeout(this.pendingTooltip)}},{key:"setTooltipVisible",value:function(t){if((!this.showTooltip()||!t&&this.pendingTooltip)&&(clearTimeout(this.pendingTooltip),this.pendingTooltip=null,this.setState({isTooltipVisible:!1})),this.showTooltip()){var e=document.querySelector("[data-id='"+this.props.id+"']");if(this.pendingTooltip=null,this.setState({isTooltipVisible:t}),t){var i=null;(i=this.props.targetObj?this.props.targetObj:document.querySelector("[data-id='"+this.props.id+"-trigger']"))&&e&&this.updateTooltipLayout(e,i,e.getAttribute("direction"))}}}},{key:"getStyleValue",value:function(t){return t+"px"}},{key:"getNewDirection",value:function(t){var e;switch(t){case"top":e="bottom";break;case"bottom":e="top";break;case"left":e="right";break;default:e="left"}return e}},{key:"showTooltip",value:function(){var t=this.canDisplayFullText(this.triggerRef);return!this.props.disable&&!this.props.showToolTipIfTruncated||!this.props.disable&&this.props.showToolTipIfTruncated&&!t}},{key:"canDisplayFullText",value:function(t){if(t){var e=t.firstChild&&t.firstChild.scrollWidth?t.firstChild.scrollWidth:0,i=t.offsetWidth,o=e;0===e&&(o=t.scrollWidth);var l=o<=i;return l}return!1}},{key:"showTooltipWithDelay",value:function(){if(!this.pendingTooltip&&this.showTooltip()){var t=this;this.pendingTooltip=setTimeout((function(){t.setTooltipVisible(!0)}),this.props.delay)}}},{key:"updateTooltipLayout",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=e.getBoundingClientRect(),r=t.querySelector("svg"),p=r.getBoundingClientRect();if(t.style.left=this.getStyleValue(n.left),t.style.top=this.getStyleValue(n.top),this.props.mousePos)this.updateLocationBasedOnMousePos(t,this.props.mousePos,i);else{if("top"===o||"bottom"===o){var h=n.left;t.offsetWidth>n.width?(h-=(t.offsetWidth-n.width)/2)<0&&(h=2):t.offsetWidth<n.width&&(h+=(n.width-t.offsetWidth)/2),t.style.left=this.getStyleValue(h),h+t.offsetWidth>l&&(t.style.left=this.getStyleValue(l-t.offsetWidth))}else if("left"===o)for(;t.offsetLeft+t.offsetWidth+p.width>Math.round(n.left);)t.style.left=this.getStyleValue(n.left-t.offsetWidth-p.width);else"right"===o&&(t.style.left=this.getStyleValue(n.right+p.width));if("top"===o)t.style.top=this.getStyleValue(n.top-p.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(n.bottom+p.height);else if("left"===o||"right"===o){var u=n.top;t.offsetHeight>n.height?(u-=(t.offsetHeight-n.height)/2)<0&&(u=n.top):t.offsetHeight<n.height&&(u+=(n.height-t.offsetHeight)/2),t.style.top=this.getStyleValue(u+1),s-t.offsetHeight<n.top&&(t.style.top=this.getStyleValue(s-t.offsetHeight))}"top"===o||"bottom"===o?r.style.left=this.getStyleValue(n.left-t.getBoundingClientRect().left+e.getBoundingClientRect().width/2-p.width/2+1):"left"===o?r.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(r.style.left=this.getStyleValue(2-p.width)),"top"===o?r.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?r.style.top="-11px":"left"!==o&&"right"!==o||(r.style.top=this.getStyleValue(n.top-t.getBoundingClientRect().top+e.offsetHeight/2-p.height/2))}if(this.isOutOfBounds(t)&&t.getAttribute("direction")===o){var a=this.getNewDirection(o);return this.updateTooltipLayout(t,e,a),void t.setAttribute("direction",a)}}},{key:"updateLocationBasedOnMousePos",value:function(t,e,i){var o=i,l=document.documentElement.clientWidth,s=document.documentElement.clientHeight,n=t.querySelector("svg"),r=n.getBoundingClientRect(),p=this.props.mousePos.x,h=this.props.mousePos.y;if("top"===o||"bottom"===o){var u=p-t.offsetWidth/2;l-t.offsetWidth<u?u=l-t.offsetWidth:u<0&&(u=2),t.style.left=this.getStyleValue(u)}else"left"===o?t.style.left=this.getStyleValue(p-t.offsetWidth-r.width-5):"right"===o&&(t.style.left=this.getStyleValue(p+r.width+5));if("top"===o)t.style.top=this.getStyleValue(h-r.height-t.offsetHeight);else if("bottom"===o)t.style.top=this.getStyleValue(h+2*r.height);else if("left"===o||"right"===o){var a=h-t.offsetHeight/2;s-t.offsetHeight<a?a=s-t.offsetHeight:a<0&&(a=2),t.style.top=this.getStyleValue(a+1)}"top"===o||"bottom"===o?n.style.left=this.getStyleValue(p-t.getBoundingClientRect().left-r.width/2):"left"===o?n.style.left=this.getStyleValue(t.offsetWidth-3):"right"===o&&(n.style.left=this.getStyleValue(2-r.width)),"top"===o?n.style.top=this.getStyleValue(t.offsetHeight-5):"bottom"===o?n.style.top="-11px":"left"!==o&&"right"!==o||(n.style.top=this.getStyleValue(h-t.getBoundingClientRect().top-r.height/2))}},{key:"isOutOfBounds",value:function(t){var e=parseFloat(t.style.left),i=parseFloat(t.style.top);return e+t.offsetWidth>document.documentElement.clientWidth||e<0||i<0||i+t.offsetHeight>document.documentElement.clientHeight}},{key:"toggleTooltipOnClick",value:function(t){t.stopPropagation(),t.preventDefault(),this.state.isTooltipVisible?this.setTooltipVisible(!1):this.setTooltipVisible(!0)}},{key:"hideTooltipOnScrollAndResize",value:function(t){this.state.isTooltipVisible&&this.setTooltipVisible(!1)}},{key:"tooltipLinkOnClick",value:function(t){window.open(t,"_blank","noopener")}},{key:"render",value:function(){var e=this,i=null,s=null;if(this.props.children){s=n.default.createElement("div",{"data-id":this.props.id+"-trigger",className:"tooltip-trigger",onMouseOver:this.props.showToolTipOnClick?null:function(){return e.setTooltipVisible(!0)},onMouseLeave:this.props.showToolTipOnClick?null:function(){return e.setTooltipVisible(!1)},onMouseDown:this.props.showToolTipOnClick?null:function(){return e.setTooltipVisible(!1)},onClick:this.props.showToolTipOnClick?function(t){return e.toggleTooltipOnClick(t)}:null,onFocus:this.props.showToolTipOnClick?function(){return e.showTooltipWithDelay()}:null,onBlur:this.props.showToolTipOnClick?function(t){null!==t.relatedTarget&&e.setTooltipVisible(!1)}:null,tabIndex:this.props.showToolTipOnClick?0:null,ref:function(t){return e.triggerRef=t}},this.props.children)}"string"==typeof this.props.tip?i=n.default.createElement("span",{id:"tooltipContainer"},this.props.tip):"object"===t._typeof(this.props.tip)?i=n.default.createElement("div",{id:"tooltipContainer"},this.props.tip):"function"==typeof this.props.tip&&(i=this.props.tip());var r="common-canvas-tooltip";this.props.className&&(r+=" "+this.props.className);var p=null;if(this.state.isTooltipVisible&&this.props.tooltipLinkHandler&&this.props.link){var h=this.props.tooltipLinkHandler(this.props.link);"object"===t._typeof(h)&&h.label&&h.url&&(p=n.default.createElement(l.Link,{className:"tooltip-link",id:this.props.link.id,onClick:this.tooltipLinkOnClick.bind(this,h.url)},h.label))}var u=null;return(i||p)&&(u=n.default.createElement(o.Portal,null,n.default.createElement("div",{"data-id":this.props.id,className:r,"aria-hidden":!this.state.isTooltipVisible,direction:this.props.direction},n.default.createElement("svg",{id:"tipArrow",x:"0px",y:"0px",viewBox:"0 0 9.1 16.1"},n.default.createElement("polyline",{points:"9.1,15.7 1.4,8.1 9.1,0.5"}),n.default.createElement("polygon",{points:"8.1,16.1 0,8.1 8.1,0 8.1,1.4 1.4,8.1 8.1,14.7"})),i,p))),n.default.createElement("div",{className:"tooltip-container"},s,u)}}]),p}(n.default.Component);p.defaultProps={delay:200,direction:"bottom",showToolTipIfTruncated:!1,showToolTipOnClick:!1},module.exports=p;
|
|
2
2
|
//# sourceMappingURL=tooltip.js.map
|
package/dist/lib/tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.jsx"],"sourcesContent":["/*\n * Copyright 2017-2022 Elyra Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*\n\tThis code is a modified version from portal-common-api for the Elyra canvas tooltips\n*/\n\nimport React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Portal } from \"react-portal\";\nimport { Link } from \"carbon-components-react\";\n\nclass ToolTip extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\tisTooltipVisible: false\n\t\t};\n\n\t\tthis.pendingTooltip = null;\n\t\tthis.hideTooltipOnScrollAndResize = this.hideTooltipOnScrollAndResize.bind(this);\n\t}\n\n\tcomponentDidMount() {\n\t\twindow.addEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.addEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.props.targetObj) {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\twindow.removeEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.removeEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.pendingTooltip) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t}\n\t}\n\n\tsetTooltipVisible(visible) {\n\t\t// clear the display timer if set\n\t\tif (!this.showTooltip() || (!visible && this.pendingTooltip)) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: false\n\t\t\t});\n\t\t}\n\n\n\t\tif (this.showTooltip()) {\n\t\t\tconst tooltip = document.querySelector(\"[data-id='\" + this.props.id + \"']\");\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: visible\n\t\t\t});\n\t\t\t// updates the tooltip display\n\t\t\tif (visible) {\n\t\t\t\tlet tooltipTrigger = null;\n\t\t\t\tif (this.props.targetObj) {\n\t\t\t\t\ttooltipTrigger = this.props.targetObj;\n\t\t\t\t} else {\n\t\t\t\t\ttooltipTrigger = document.querySelector(\"[data-id='\" + this.props.id + \"-trigger']\");\n\t\t\t\t}\n\t\t\t\tif (tooltipTrigger && tooltip) {\n\t\t\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, tooltip.getAttribute(\"direction\"));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tgetStyleValue(value) {\n\t\treturn value + \"px\";\n\t}\n\n\tgetNewDirection(currentDirection) {\n\t\tlet newDirection;\n\t\tswitch (currentDirection) {\n\t\tcase \"top\":\n\t\t\tnewDirection = \"bottom\";\n\t\t\tbreak;\n\t\tcase \"bottom\":\n\t\t\tnewDirection = \"top\";\n\t\t\tbreak;\n\t\tcase \"left\":\n\t\t\tnewDirection = \"right\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tnewDirection = \"left\";\n\t\t}\n\t\treturn newDirection;\n\t}\n\n\tshowTooltip() {\n\t\tconst canDisplayFullText = this.canDisplayFullText(this.triggerRef);\n\t\tconst showToolTip = (\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is false\n\t\t\t(!this.props.disable && !this.props.showToolTipIfTruncated) ||\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is true and string is truncated\n\t\t\t(!this.props.disable && this.props.showToolTipIfTruncated && !canDisplayFullText));\n\t\treturn showToolTip;\n\t}\n\n\t// Return true if the string can be displayed in the available space\n\t// Return false if the string is truncated and ellipsis is shown on the UI\n\t// (offsetWidth) is a measurement in pixels of the element's CSS width, including any borders, padding, and vertical scrollbars\n\t// (scrollWidth) value is equal to the minimum width the element would require\n\t// in order to fit all the content in the viewport without using a horizontal scrollbar\n\tcanDisplayFullText(elem) {\n\t\tif (elem) {\n\t\t\tconst firstChildWidth = elem.firstChild && elem.firstChild.scrollWidth ? elem.firstChild.scrollWidth : 0;\n\t\t\tconst displayWidth = elem.offsetWidth;\n\t\t\tlet fullWidth = firstChildWidth;\n\t\t\tif (firstChildWidth === 0) {\n\t\t\t\tfullWidth = elem.scrollWidth;\n\t\t\t}\n\t\t\tconst canDisplayFullText = fullWidth <= displayWidth;\n\t\t\treturn canDisplayFullText;\n\t\t}\n\t\treturn false; // Show tooltip if we cannot read the width (Canvas objects)\n\t}\n\n\tshowTooltipWithDelay() {\n\n\t\t// set a delay on displaying the tooltip\n\t\tif (!this.pendingTooltip && this.showTooltip()) {\n\t\t\tconst that = this;\n\t\t\tthis.pendingTooltip = setTimeout(function() {\n\t\t\t\tthat.setTooltipVisible(true);\n\t\t\t}, this.props.delay);\n\t\t}\n\n\t}\n\n\tupdateTooltipLayout(tooltip, tooltipTrigger, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst triggerLayout = tooltipTrigger.getBoundingClientRect();\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\t// always initialize tooltip location so it's all visible to ensure adjustments are done on the right size\n\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left);\n\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top);\n\n\t\tif (this.props.mousePos) {\n\t\t\tthis.updateLocationBasedOnMousePos(tooltip, this.props.mousePos, direction);\n\t\t} else { // tooltip relativ to element\n\t\t\t// tooltip - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tlet tooltipLeft = triggerLayout.left;\n\t\t\t\tif (tooltip.offsetWidth > triggerLayout.width) {\n\t\t\t\t\ttooltipLeft -= (tooltip.offsetWidth - triggerLayout.width) / 2; // distribute overlap evenly left and right\n\t\t\t\t\tif (tooltipLeft < 0) {\n\t\t\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetWidth < triggerLayout.width) {\n\t\t\t\t\ttooltipLeft += (triggerLayout.width - tooltip.offsetWidth) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t\t\tif ((tooltipLeft + tooltip.offsetWidth) > viewPortWidth) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(viewPortWidth - tooltip.offsetWidth); // hitting right border\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\t// For long tooltips, tooltip.offsetWidth is updated after setting tooltip.style.left. Ensure tooltip doesn't overlap tooltipTrigger element.\n\t\t\t\twhile ((tooltip.offsetLeft + tooltip.offsetWidth + pointerLayout.width) > triggerLayout.left) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left - tooltip.offsetWidth - pointerLayout.width);\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.right + pointerLayout.width);\n\t\t\t}\n\n\t\t\t// tooltip - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top - pointerLayout.height - tooltip.offsetHeight);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.bottom + pointerLayout.height);\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tlet tooltipTop = triggerLayout.top;\n\t\t\t\tif (tooltip.offsetHeight > triggerLayout.height) {\n\t\t\t\t\ttooltipTop -= (tooltip.offsetHeight - triggerLayout.height) / 2; // distribute overlap evenly top and bottom\n\t\t\t\t\tif (tooltipTop < 0) {\n\t\t\t\t\t\ttooltipTop = triggerLayout.top; // hitting top border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetHeight < triggerLayout.height) {\n\t\t\t\t\ttooltipTop += (triggerLayout.height - tooltip.offsetHeight) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < triggerLayout.top) {\n\t\t\t\t\ttooltip.style.top = this.getStyleValue(viewPortHeight - tooltip.offsetHeight); // hitting bottom border\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// pointer - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(triggerLayout.left - tooltip.getBoundingClientRect().left +\n\t\t\t\t\ttooltipTrigger.getBoundingClientRect().width / 2 - pointerLayout.width / 2\t + pointerCorrection);\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t\t}\n\n\t\t\t// pointer - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.top = \"-11px\";\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(triggerLayout.top - tooltip.getBoundingClientRect().top +\n\t\t\t\t\ttooltipTrigger.offsetHeight / 2 - pointerLayout.height / 2);\n\t\t\t}\n\t\t}\n\n\t\t// check if out-of-bounds at the end and if so, trigger new layout on opposite site if not already re-rendered already\n\t\tif (this.isOutOfBounds(tooltip) && tooltip.getAttribute(\"direction\") === tooltipDirection) {\n\t\t\tconst newDirection = this.getNewDirection(tooltipDirection);\n\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, newDirection);\n\t\t\t// update class name directly, otherwise setState triggers re-render loop in canvas\n\t\t\t// also call after updateTooltipLayout, otherwise the newDirection and class of trigger are the same\n\t\t\ttooltip.setAttribute(\"direction\", newDirection);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tupdateLocationBasedOnMousePos(tooltip, mousePos, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\tconst mouseX = this.props.mousePos.x;\n\t\tconst mouseY = this.props.mousePos.y;\n\t\t// if mouse position is passed in, use the cursor as reference point\n\n\t\t// tooltip - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tlet tooltipLeft = mouseX - tooltip.offsetWidth / 2;\n\t\t\tif ((viewPortWidth - tooltip.offsetWidth) < tooltipLeft) {\n\t\t\t\ttooltipLeft = viewPortWidth - tooltip.offsetWidth; // hitting right border\n\t\t\t} else if (tooltipLeft < 0) {\n\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t}\n\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX - tooltip.offsetWidth - pointerLayout.width - 5);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX + pointerLayout.width + 5);\n\t\t}\n\n\t\t// tooltip - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY - pointerLayout.height - tooltip.offsetHeight);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY + 2 * pointerLayout.height);\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tlet tooltipTop = mouseY - tooltip.offsetHeight / 2;\n\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < tooltipTop) {\n\t\t\t\ttooltipTop = viewPortHeight - tooltip.offsetHeight; // hitting bottom border\n\t\t\t} else if (tooltipTop < 0) {\n\t\t\t\ttooltipTop = 2; // hitting top border\n\t\t\t}\n\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t}\n\n\t\t// pointer - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.left = this.getStyleValue(mouseX - tooltip.getBoundingClientRect().left - pointerLayout.width / 2);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t}\n\n\t\t// pointer - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.top = \"-11px\";\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tpointer.style.top = this.getStyleValue(mouseY - tooltip.getBoundingClientRect().top - pointerLayout.height / 2);\n\t\t}\n\t}\n\n\tisOutOfBounds(tooltip) {\n\t\tconst tooltipLeft = parseFloat(tooltip.style.left);\n\t\tconst tooltipTop = parseFloat(tooltip.style.top);\n\t\treturn (((tooltipLeft + tooltip.offsetWidth) > document.documentElement.clientWidth) || // to the right\n\t\t\t\t(tooltipLeft < 0) || // to the left\n\t\t\t\t(tooltipTop < 0) || // to the top\n\t\t\t\t((tooltipTop + tooltip.offsetHeight) > document.documentElement.clientHeight)); // to the bottom\n\t}\n\n\ttoggleTooltipOnClick(evt) {\n\t\t// 'blur' event occurs before 'click' event. Because of this, onBlur function is called which hides the tooltip.\n\t\t// To prevent this default behavior, stopPropagation and preventDefault is used.\n\t\tevt.stopPropagation();\n\t\tevt.preventDefault();\n\t\tif (this.state.isTooltipVisible) {\n\t\t\t// Tooltip is visible and user clicks on trigger element again, hide tooltip\n\t\t\tthis.setTooltipVisible(false);\n\t\t} else {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\thideTooltipOnScrollAndResize(evt) {\n\t\tif (this.state.isTooltipVisible) {\n\t\t\tthis.setTooltipVisible(false);\n\t\t}\n\t}\n\n\ttooltipLinkOnClick(url) {\n\t\twindow.open(url, \"_blank\", \"noopener\");\n\t}\n\n\trender() {\n\t\tlet tooltipContent = null;\n\t\tlet triggerContent = null;\n\t\tif (this.props.children) {\n\t\t\t// when children are passed in, tooltip will handle show/hide, otherwise consumer has to hide show/hide tooltip\n\t\t\tconst mouseover = () => this.setTooltipVisible(true);\n\t\t\tconst mouseleave = () => this.setTooltipVisible(false);\n\t\t\tconst mousedown = () => this.setTooltipVisible(false);\n\t\t\t// `focus` event occurs before `click`. Adding timeout in onFocus function to ensure click is executed first.\n\t\t\t// Ref - https://stackoverflow.com/a/49512400\n\t\t\tconst onFocus = () => this.showTooltipWithDelay();\n\t\t\tconst onBlur = (evt) => {\n\t\t\t\t// Keep tooltip visible when clicked on a link.\n\t\t\t\t// Since link is an anchor tag without \"href\" attribute, it has relatedTarget=null\n\t\t\t\tif (evt.relatedTarget !== null) {\n\t\t\t\t\tthis.setTooltipVisible(false);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst click = (evt) => this.toggleTooltipOnClick(evt);\n\n\t\t\ttriggerContent = (<div\n\t\t\t\tdata-id={this.props.id + \"-trigger\"}\n\t\t\t\tclassName=\"tooltip-trigger\"\n\t\t\t\tonMouseOver={!this.props.showToolTipOnClick ? mouseover : null}\n\t\t\t\tonMouseLeave={!this.props.showToolTipOnClick ? mouseleave : null}\n\t\t\t\tonMouseDown={!this.props.showToolTipOnClick ? mousedown : null}\n\t\t\t\tonClick={this.props.showToolTipOnClick ? click : null}\n\t\t\t\tonFocus={this.props.showToolTipOnClick ? onFocus : null} // When focused using keyboard\n\t\t\t\tonBlur={this.props.showToolTipOnClick ? onBlur : null}\n\t\t\t\ttabIndex={this.props.showToolTipOnClick ? 0 : null}\n\t\t\t\tref={(ref) => (this.triggerRef = ref)}\n\t\t\t>\n\t\t\t\t{this.props.children}\n\t\t\t</div>);\n\t\t}\n\n\t\tif ((typeof this.props.tip) === \"string\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<span id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</span>\n\t\t\t);\n\t\t} else if ((typeof this.props.tip) === \"object\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<div id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tlet tipClass = \"common-canvas-tooltip\";\n\t\tif (this.props.className) {\n\t\t\ttipClass += \" \" + this.props.className;\n\t\t}\n\n\t\tlet link = null;\n\t\tif (this.state.isTooltipVisible && this.props.tooltipLinkHandler && this.props.link) {\n\t\t\tconst linkInformation = this.props.tooltipLinkHandler(this.props.link);\n\t\t\t// Verify tooltipLinkHandler returns object in correct format\n\t\t\tif (typeof linkInformation === \"object\" && linkInformation.label && linkInformation.url) {\n\t\t\t\tlink = (<Link\n\t\t\t\t\tclassName=\"tooltip-link\"\n\t\t\t\t\tid={this.props.link.id}\n\t\t\t\t\tonClick={this.tooltipLinkOnClick.bind(this, linkInformation.url)}\n\t\t\t\t>\n\t\t\t\t\t{linkInformation.label}\n\t\t\t\t</Link>);\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<div className=\"tooltip-container\">\n\t\t\t\t{triggerContent}\n\t\t\t\t<Portal>\n\t\t\t\t\t<div data-id={this.props.id} className={tipClass} aria-hidden={!this.state.isTooltipVisible} direction={this.props.direction}>\n\t\t\t\t\t\t<svg id=\"tipArrow\" x=\"0px\" y=\"0px\" viewBox=\"0 0 9.1 16.1\">\n\t\t\t\t\t\t\t<polyline points=\"9.1,15.7 1.4,8.1 9.1,0.5\" />\n\t\t\t\t\t\t\t<polygon points=\"8.1,16.1 0,8.1 8.1,0 8.1,1.4 1.4,8.1 8.1,14.7\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t{tooltipContent}\n\t\t\t\t\t\t{link}\n\t\t\t\t\t</div>\n\t\t\t\t</Portal>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nToolTip.propTypes = {\n\ttip: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,\n\tlink: PropTypes.object,\n\ttooltipLinkHandler: PropTypes.func,\n\tdirection: PropTypes.oneOf([\"left\", \"right\", \"top\", \"bottom\"]),\n\tchildren: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n\ttargetObj: PropTypes.object,\n\tid: PropTypes.string.isRequired,\n\tclassName: PropTypes.string,\n\tmousePos: PropTypes.object,\n\tdisable: PropTypes.bool, // Tooltip will not show if disabled\n\tshowToolTipIfTruncated: PropTypes.bool, // Set to true to only display tooltip if full text does not fit in displayable width\n\tdelay: PropTypes.number,\n\tshowToolTipOnClick: PropTypes.bool\n};\n\nToolTip.defaultProps = {\n\tdelay: 200,\n\tdirection: \"bottom\",\n\tshowToolTipIfTruncated: false, // False will always show Tooltip even when whole word can be displayed\n\tshowToolTipOnClick: false\n};\n\nexport default ToolTip;\n"],"names":["ToolTip","props","_classCallCheck","_this","state","isTooltipVisible","pendingTooltip","hideTooltipOnScrollAndResize","bind","window","addEventListener","this","targetObj","setTooltipVisible","removeEventListener","clearTimeout","visible","showTooltip","setState","tooltip","document","querySelector","id","tooltipTrigger","updateTooltipLayout","getAttribute","value","currentDirection","newDirection","canDisplayFullText","triggerRef","disable","showToolTipIfTruncated","elem","firstChildWidth","firstChild","scrollWidth","displayWidth","offsetWidth","fullWidth","that","setTimeout","delay","direction","tooltipDirection","viewPortWidth","documentElement","clientWidth","viewPortHeight","clientHeight","triggerLayout","getBoundingClientRect","pointer","pointerLayout","style","left","getStyleValue","top","mousePos","updateLocationBasedOnMousePos","tooltipLeft","width","offsetLeft","right","height","offsetHeight","bottom","tooltipTop","isOutOfBounds","getNewDirection","setAttribute","mouseX","x","mouseY","y","parseFloat","evt","stopPropagation","preventDefault","url","open","tooltipContent","triggerContent","children","React","className","onMouseOver","showToolTipOnClick","_this2","onMouseLeave","onMouseDown","onClick","toggleTooltipOnClick","onFocus","showTooltipWithDelay","onBlur","relatedTarget","tabIndex","ref","tip","_typeof","tipClass","link","tooltipLinkHandler","linkInformation","label","Link","tooltipLinkOnClick","Portal","viewBox","points","Component","defaultProps"],"mappings":"+uBAwBMA,0CACL,WAAYC,GAAO,MAAA,OAAAC,2BAClBC,cAAMF,IACDG,MAAQ,CACZC,kBAAkB,GAGnBF,EAAKG,eAAiB,KACtBH,EAAKI,6BAA+BJ,EAAKI,6BAA6BC,4FAGvE,WACCC,OAAOC,iBAAiB,SAAUC,KAAKJ,8BAA8B,GACrEE,OAAOC,iBAAiB,SAAUC,KAAKJ,8BAA8B,GACjEI,KAAKV,MAAMW,WACdD,KAAKE,mBAAkB,uCAIzB,WACCJ,OAAOK,oBAAoB,SAAUH,KAAKJ,8BAA8B,GACxEE,OAAOK,oBAAoB,SAAUH,KAAKJ,8BAA8B,GACpEI,KAAKL,gBACRS,aAAaJ,KAAKL,iDAIpB,SAAkBU,GAWjB,KATKL,KAAKM,gBAAmBD,GAAWL,KAAKL,kBAC5CS,aAAaJ,KAAKL,gBAClBK,KAAKL,eAAiB,KACtBK,KAAKO,SAAS,CACbb,kBAAkB,KAKhBM,KAAKM,cAAe,CACvB,IAAME,EAAUC,SAASC,cAAc,aAAeV,KAAKV,MAAMqB,GAAK,MAMtE,GALAX,KAAKL,eAAiB,KACtBK,KAAKO,SAAS,CACbb,iBAAkBW,IAGfA,EAAS,CACZ,IAAIO,EAAiB,MAEpBA,EADGZ,KAAKV,MAAMW,UACGD,KAAKV,MAAMW,UAEXQ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,EAAK1D,WAAaoE,IAEhCvF,KAAKV,MAAMkF,UAIkB,iBAApBxE,KAAKV,MAAMkG,IACtBlB,EACCG,gCAAM9D,GAAG,oBACPX,KAAKV,MAAMkG,KAGwB,WAA5BC,UAAQzF,KAAKV,MAAMkG,OAC7BlB,EACCG,+BAAK9D,GAAG,oBACNX,KAAKV,MAAMkG,MAKf,IAAIE,EAAW,wBACX1F,KAAKV,MAAMoF,YACdgB,GAAY,IAAM1F,KAAKV,MAAMoF,WAG9B,IAAIiB,EAAO,KACX,GAAI3F,KAAKP,MAAMC,kBAAoBM,KAAKV,MAAMsG,oBAAsB5F,KAAKV,MAAMqG,KAAM,CACpF,IAAME,EAAkB7F,KAAKV,MAAMsG,mBAAmB5F,KAAKV,MAAMqG,MAElC,WAA3BF,UAAOI,IAAgCA,EAAgBC,OAASD,EAAgBzB,MACnFuB,EAAQlB,wBAACsB,QACRrB,UAAU,eACV/D,GAAIX,KAAKV,MAAMqG,KAAKhF,GACpBqE,QAAShF,KAAKgG,mBAAmBnG,KAAKG,KAAM6F,EAAgBzB,MAE3DyB,EAAgBC,QAKpB,OACCrB,+BAAKC,UAAU,qBACbH,EACDE,wBAACwB,cACAxB,+BAAK,UAASzE,KAAKV,MAAMqB,GAAI+D,UAAWgB,EAAU,eAAc1F,KAAKP,MAAMC,iBAAkBsC,UAAWhC,KAAKV,MAAM0C,WAClHyC,+BAAK9D,GAAG,WAAWkD,EAAE,MAAME,EAAE,MAAMmC,QAAQ,gBAC1CzB,oCAAU0B,OAAO,6BACjB1B,mCAAS0B,OAAO,mDAEhB7B,EACAqB,YApYelB,UAAM2B,WA4Z5B/G,EAAQgH,aAAe,CACtBtE,MAAO,IACPC,UAAW,SACXX,wBAAwB,EACxBuD,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.jsx"],"sourcesContent":["/*\n * Copyright 2017-2022 Elyra Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*\n\tThis code is a modified version from portal-common-api for the Elyra canvas tooltips\n*/\n\nimport React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Portal } from \"react-portal\";\nimport { Link } from \"carbon-components-react\";\n\nclass ToolTip extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\tisTooltipVisible: false\n\t\t};\n\n\t\tthis.pendingTooltip = null;\n\t\tthis.hideTooltipOnScrollAndResize = this.hideTooltipOnScrollAndResize.bind(this);\n\t}\n\n\tcomponentDidMount() {\n\t\twindow.addEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.addEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.props.targetObj) {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\twindow.removeEventListener(\"scroll\", this.hideTooltipOnScrollAndResize, true);\n\t\twindow.removeEventListener(\"resize\", this.hideTooltipOnScrollAndResize, true);\n\t\tif (this.pendingTooltip) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t}\n\t}\n\n\tsetTooltipVisible(visible) {\n\t\t// clear the display timer if set\n\t\tif (!this.showTooltip() || (!visible && this.pendingTooltip)) {\n\t\t\tclearTimeout(this.pendingTooltip);\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: false\n\t\t\t});\n\t\t}\n\n\n\t\tif (this.showTooltip()) {\n\t\t\tconst tooltip = document.querySelector(\"[data-id='\" + this.props.id + \"']\");\n\t\t\tthis.pendingTooltip = null;\n\t\t\tthis.setState({\n\t\t\t\tisTooltipVisible: visible\n\t\t\t});\n\t\t\t// updates the tooltip display\n\t\t\tif (visible) {\n\t\t\t\tlet tooltipTrigger = null;\n\t\t\t\tif (this.props.targetObj) {\n\t\t\t\t\ttooltipTrigger = this.props.targetObj;\n\t\t\t\t} else {\n\t\t\t\t\ttooltipTrigger = document.querySelector(\"[data-id='\" + this.props.id + \"-trigger']\");\n\t\t\t\t}\n\t\t\t\tif (tooltipTrigger && tooltip) {\n\t\t\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, tooltip.getAttribute(\"direction\"));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tgetStyleValue(value) {\n\t\treturn value + \"px\";\n\t}\n\n\tgetNewDirection(currentDirection) {\n\t\tlet newDirection;\n\t\tswitch (currentDirection) {\n\t\tcase \"top\":\n\t\t\tnewDirection = \"bottom\";\n\t\t\tbreak;\n\t\tcase \"bottom\":\n\t\t\tnewDirection = \"top\";\n\t\t\tbreak;\n\t\tcase \"left\":\n\t\t\tnewDirection = \"right\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tnewDirection = \"left\";\n\t\t}\n\t\treturn newDirection;\n\t}\n\n\tshowTooltip() {\n\t\tconst canDisplayFullText = this.canDisplayFullText(this.triggerRef);\n\t\tconst showToolTip = (\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is false\n\t\t\t(!this.props.disable && !this.props.showToolTipIfTruncated) ||\n\t\t\t// show tooltip if not disabled and showToolTipIfTruncated is true and string is truncated\n\t\t\t(!this.props.disable && this.props.showToolTipIfTruncated && !canDisplayFullText));\n\t\treturn showToolTip;\n\t}\n\n\t// Return true if the string can be displayed in the available space\n\t// Return false if the string is truncated and ellipsis is shown on the UI\n\t// (offsetWidth) is a measurement in pixels of the element's CSS width, including any borders, padding, and vertical scrollbars\n\t// (scrollWidth) value is equal to the minimum width the element would require\n\t// in order to fit all the content in the viewport without using a horizontal scrollbar\n\tcanDisplayFullText(elem) {\n\t\tif (elem) {\n\t\t\tconst firstChildWidth = elem.firstChild && elem.firstChild.scrollWidth ? elem.firstChild.scrollWidth : 0;\n\t\t\tconst displayWidth = elem.offsetWidth;\n\t\t\tlet fullWidth = firstChildWidth;\n\t\t\tif (firstChildWidth === 0) {\n\t\t\t\tfullWidth = elem.scrollWidth;\n\t\t\t}\n\t\t\tconst canDisplayFullText = fullWidth <= displayWidth;\n\t\t\treturn canDisplayFullText;\n\t\t}\n\t\treturn false; // Show tooltip if we cannot read the width (Canvas objects)\n\t}\n\n\tshowTooltipWithDelay() {\n\n\t\t// set a delay on displaying the tooltip\n\t\tif (!this.pendingTooltip && this.showTooltip()) {\n\t\t\tconst that = this;\n\t\t\tthis.pendingTooltip = setTimeout(function() {\n\t\t\t\tthat.setTooltipVisible(true);\n\t\t\t}, this.props.delay);\n\t\t}\n\n\t}\n\n\tupdateTooltipLayout(tooltip, tooltipTrigger, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst triggerLayout = tooltipTrigger.getBoundingClientRect();\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\t// always initialize tooltip location so it's all visible to ensure adjustments are done on the right size\n\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left);\n\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top);\n\n\t\tif (this.props.mousePos) {\n\t\t\tthis.updateLocationBasedOnMousePos(tooltip, this.props.mousePos, direction);\n\t\t} else { // tooltip relativ to element\n\t\t\t// tooltip - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tlet tooltipLeft = triggerLayout.left;\n\t\t\t\tif (tooltip.offsetWidth > triggerLayout.width) {\n\t\t\t\t\ttooltipLeft -= (tooltip.offsetWidth - triggerLayout.width) / 2; // distribute overlap evenly left and right\n\t\t\t\t\tif (tooltipLeft < 0) {\n\t\t\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetWidth < triggerLayout.width) {\n\t\t\t\t\ttooltipLeft += (triggerLayout.width - tooltip.offsetWidth) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t\t\tif ((tooltipLeft + tooltip.offsetWidth) > viewPortWidth) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(viewPortWidth - tooltip.offsetWidth); // hitting right border\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\t// For long tooltips, tooltip.offsetWidth is updated after setting tooltip.style.left. Ensure tooltip doesn't overlap tooltipTrigger element.\n\t\t\t\twhile ((tooltip.offsetLeft + tooltip.offsetWidth + pointerLayout.width) > Math.round(triggerLayout.left)) {\n\t\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.left - tooltip.offsetWidth - pointerLayout.width);\n\t\t\t\t}\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\ttooltip.style.left = this.getStyleValue(triggerLayout.right + pointerLayout.width);\n\t\t\t}\n\n\t\t\t// tooltip - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.top - pointerLayout.height - tooltip.offsetHeight);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\ttooltip.style.top = this.getStyleValue(triggerLayout.bottom + pointerLayout.height);\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tlet tooltipTop = triggerLayout.top;\n\t\t\t\tif (tooltip.offsetHeight > triggerLayout.height) {\n\t\t\t\t\ttooltipTop -= (tooltip.offsetHeight - triggerLayout.height) / 2; // distribute overlap evenly top and bottom\n\t\t\t\t\tif (tooltipTop < 0) {\n\t\t\t\t\t\ttooltipTop = triggerLayout.top; // hitting top border\n\t\t\t\t\t}\n\t\t\t\t} else if (tooltip.offsetHeight < triggerLayout.height) {\n\t\t\t\t\ttooltipTop += (triggerLayout.height - tooltip.offsetHeight) / 2; // center tip within triggerLayout\n\t\t\t\t}\n\t\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < triggerLayout.top) {\n\t\t\t\t\ttooltip.style.top = this.getStyleValue(viewPortHeight - tooltip.offsetHeight); // hitting bottom border\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// pointer - left correction\n\t\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(triggerLayout.left - tooltip.getBoundingClientRect().left +\n\t\t\t\t\ttooltipTrigger.getBoundingClientRect().width / 2 - pointerLayout.width / 2\t + pointerCorrection);\n\t\t\t} else if (tooltipDirection === \"left\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t\t} else if (tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t\t}\n\n\t\t\t// pointer - top correction\n\t\t\tif (tooltipDirection === \"top\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\t\tpointer.style.top = \"-11px\";\n\t\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\t\tpointer.style.top = this.getStyleValue(triggerLayout.top - tooltip.getBoundingClientRect().top +\n\t\t\t\t\ttooltipTrigger.offsetHeight / 2 - pointerLayout.height / 2);\n\t\t\t}\n\t\t}\n\n\t\t// check if out-of-bounds at the end and if so, trigger new layout on opposite site if not already re-rendered already\n\t\tif (this.isOutOfBounds(tooltip) && tooltip.getAttribute(\"direction\") === tooltipDirection) {\n\t\t\tconst newDirection = this.getNewDirection(tooltipDirection);\n\t\t\tthis.updateTooltipLayout(tooltip, tooltipTrigger, newDirection);\n\t\t\t// update class name directly, otherwise setState triggers re-render loop in canvas\n\t\t\t// also call after updateTooltipLayout, otherwise the newDirection and class of trigger are the same\n\t\t\ttooltip.setAttribute(\"direction\", newDirection);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tupdateLocationBasedOnMousePos(tooltip, mousePos, direction) {\n\t\tconst tooltipDirection = direction;\n\t\tconst viewPortWidth = document.documentElement.clientWidth;\n\t\tconst viewPortHeight = document.documentElement.clientHeight;\n\t\tconst pointer = tooltip.querySelector(\"svg\");\n\t\tconst pointerLayout = pointer.getBoundingClientRect();\n\t\tconst pointerCorrection = 1;\n\n\t\tconst mouseX = this.props.mousePos.x;\n\t\tconst mouseY = this.props.mousePos.y;\n\t\t// if mouse position is passed in, use the cursor as reference point\n\n\t\t// tooltip - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tlet tooltipLeft = mouseX - tooltip.offsetWidth / 2;\n\t\t\tif ((viewPortWidth - tooltip.offsetWidth) < tooltipLeft) {\n\t\t\t\ttooltipLeft = viewPortWidth - tooltip.offsetWidth; // hitting right border\n\t\t\t} else if (tooltipLeft < 0) {\n\t\t\t\ttooltipLeft = 2; // hitting left border\n\t\t\t}\n\t\t\ttooltip.style.left = this.getStyleValue(tooltipLeft);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX - tooltip.offsetWidth - pointerLayout.width - 5);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\ttooltip.style.left = this.getStyleValue(mouseX + pointerLayout.width + 5);\n\t\t}\n\n\t\t// tooltip - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY - pointerLayout.height - tooltip.offsetHeight);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\ttooltip.style.top = this.getStyleValue(mouseY + 2 * pointerLayout.height);\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tlet tooltipTop = mouseY - tooltip.offsetHeight / 2;\n\t\t\tif ((viewPortHeight - tooltip.offsetHeight) < tooltipTop) {\n\t\t\t\ttooltipTop = viewPortHeight - tooltip.offsetHeight; // hitting bottom border\n\t\t\t} else if (tooltipTop < 0) {\n\t\t\t\ttooltipTop = 2; // hitting top border\n\t\t\t}\n\t\t\ttooltip.style.top = this.getStyleValue(tooltipTop + pointerCorrection);\n\t\t}\n\n\t\t// pointer - left correction\n\t\tif (tooltipDirection === \"top\" || tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.left = this.getStyleValue(mouseX - tooltip.getBoundingClientRect().left - pointerLayout.width / 2);\n\t\t} else if (tooltipDirection === \"left\") {\n\t\t\tpointer.style.left = this.getStyleValue(tooltip.offsetWidth - 3);\n\t\t} else if (tooltipDirection === \"right\") {\n\t\t\tpointer.style.left = this.getStyleValue(-pointerLayout.width + 2);\n\t\t}\n\n\t\t// pointer - top correction\n\t\tif (tooltipDirection === \"top\") {\n\t\t\tpointer.style.top = this.getStyleValue(tooltip.offsetHeight - 5);\n\t\t} else if (tooltipDirection === \"bottom\") {\n\t\t\tpointer.style.top = \"-11px\";\n\t\t} else if (tooltipDirection === \"left\" || tooltipDirection === \"right\") {\n\t\t\tpointer.style.top = this.getStyleValue(mouseY - tooltip.getBoundingClientRect().top - pointerLayout.height / 2);\n\t\t}\n\t}\n\n\tisOutOfBounds(tooltip) {\n\t\tconst tooltipLeft = parseFloat(tooltip.style.left);\n\t\tconst tooltipTop = parseFloat(tooltip.style.top);\n\t\treturn (((tooltipLeft + tooltip.offsetWidth) > document.documentElement.clientWidth) || // to the right\n\t\t\t\t(tooltipLeft < 0) || // to the left\n\t\t\t\t(tooltipTop < 0) || // to the top\n\t\t\t\t((tooltipTop + tooltip.offsetHeight) > document.documentElement.clientHeight)); // to the bottom\n\t}\n\n\ttoggleTooltipOnClick(evt) {\n\t\t// 'blur' event occurs before 'click' event. Because of this, onBlur function is called which hides the tooltip.\n\t\t// To prevent this default behavior, stopPropagation and preventDefault is used.\n\t\tevt.stopPropagation();\n\t\tevt.preventDefault();\n\t\tif (this.state.isTooltipVisible) {\n\t\t\t// Tooltip is visible and user clicks on trigger element again, hide tooltip\n\t\t\tthis.setTooltipVisible(false);\n\t\t} else {\n\t\t\tthis.setTooltipVisible(true);\n\t\t}\n\t}\n\n\thideTooltipOnScrollAndResize(evt) {\n\t\tif (this.state.isTooltipVisible) {\n\t\t\tthis.setTooltipVisible(false);\n\t\t}\n\t}\n\n\ttooltipLinkOnClick(url) {\n\t\twindow.open(url, \"_blank\", \"noopener\");\n\t}\n\n\trender() {\n\t\tlet tooltipContent = null;\n\t\tlet triggerContent = null;\n\t\tif (this.props.children) {\n\t\t\t// when children are passed in, tooltip will handle show/hide, otherwise consumer has to hide show/hide tooltip\n\t\t\tconst mouseover = () => this.setTooltipVisible(true);\n\t\t\tconst mouseleave = () => this.setTooltipVisible(false);\n\t\t\tconst mousedown = () => this.setTooltipVisible(false);\n\t\t\t// `focus` event occurs before `click`. Adding timeout in onFocus function to ensure click is executed first.\n\t\t\t// Ref - https://stackoverflow.com/a/49512400\n\t\t\tconst onFocus = () => this.showTooltipWithDelay();\n\t\t\tconst onBlur = (evt) => {\n\t\t\t\t// Keep tooltip visible when clicked on a link.\n\t\t\t\t// Since link is an anchor tag without \"href\" attribute, it has relatedTarget=null\n\t\t\t\tif (evt.relatedTarget !== null) {\n\t\t\t\t\tthis.setTooltipVisible(false);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst click = (evt) => this.toggleTooltipOnClick(evt);\n\n\t\t\ttriggerContent = (<div\n\t\t\t\tdata-id={this.props.id + \"-trigger\"}\n\t\t\t\tclassName=\"tooltip-trigger\"\n\t\t\t\tonMouseOver={!this.props.showToolTipOnClick ? mouseover : null}\n\t\t\t\tonMouseLeave={!this.props.showToolTipOnClick ? mouseleave : null}\n\t\t\t\tonMouseDown={!this.props.showToolTipOnClick ? mousedown : null}\n\t\t\t\tonClick={this.props.showToolTipOnClick ? click : null}\n\t\t\t\tonFocus={this.props.showToolTipOnClick ? onFocus : null} // When focused using keyboard\n\t\t\t\tonBlur={this.props.showToolTipOnClick ? onBlur : null}\n\t\t\t\ttabIndex={this.props.showToolTipOnClick ? 0 : null}\n\t\t\t\tref={(ref) => (this.triggerRef = ref)}\n\t\t\t>\n\t\t\t\t{this.props.children}\n\t\t\t</div>);\n\t\t}\n\n\t\tif ((typeof this.props.tip) === \"string\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<span id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</span>\n\t\t\t);\n\t\t} else if ((typeof this.props.tip) === \"object\") {\n\t\t\ttooltipContent = (\n\t\t\t\t<div id=\"tooltipContainer\">\n\t\t\t\t\t{this.props.tip}\n\t\t\t\t</div>\n\t\t\t);\n\t\t} else if ((typeof this.props.tip) === \"function\") {\n\t\t\ttooltipContent = this.props.tip();\n\t\t}\n\n\t\tlet tipClass = \"common-canvas-tooltip\";\n\t\tif (this.props.className) {\n\t\t\ttipClass += \" \" + this.props.className;\n\t\t}\n\n\t\tlet link = null;\n\t\tif (this.state.isTooltipVisible && this.props.tooltipLinkHandler && this.props.link) {\n\t\t\tconst linkInformation = this.props.tooltipLinkHandler(this.props.link);\n\t\t\t// Verify tooltipLinkHandler returns object in correct format\n\t\t\tif (typeof linkInformation === \"object\" && linkInformation.label && linkInformation.url) {\n\t\t\t\tlink = (<Link\n\t\t\t\t\tclassName=\"tooltip-link\"\n\t\t\t\t\tid={this.props.link.id}\n\t\t\t\t\tonClick={this.tooltipLinkOnClick.bind(this, linkInformation.url)}\n\t\t\t\t>\n\t\t\t\t\t{linkInformation.label}\n\t\t\t\t</Link>);\n\t\t\t}\n\t\t}\n\n\t\tlet tooltip = null;\n\t\tif (tooltipContent || link) {\n\t\t\ttooltip = (\n\t\t\t\t<Portal>\n\t\t\t\t\t<div data-id={this.props.id} className={tipClass} aria-hidden={!this.state.isTooltipVisible} direction={this.props.direction}>\n\t\t\t\t\t\t<svg id=\"tipArrow\" x=\"0px\" y=\"0px\" viewBox=\"0 0 9.1 16.1\">\n\t\t\t\t\t\t\t<polyline points=\"9.1,15.7 1.4,8.1 9.1,0.5\" />\n\t\t\t\t\t\t\t<polygon points=\"8.1,16.1 0,8.1 8.1,0 8.1,1.4 1.4,8.1 8.1,14.7\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t{tooltipContent}\n\t\t\t\t\t\t{link}\n\t\t\t\t\t</div>\n\t\t\t\t</Portal>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div className=\"tooltip-container\">\n\t\t\t\t{triggerContent}\n\t\t\t\t{tooltip}\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nToolTip.propTypes = {\n\ttip: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired,\n\tlink: PropTypes.object,\n\ttooltipLinkHandler: PropTypes.func,\n\tdirection: PropTypes.oneOf([\"left\", \"right\", \"top\", \"bottom\"]),\n\tchildren: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n\ttargetObj: PropTypes.object,\n\tid: PropTypes.string.isRequired,\n\tclassName: PropTypes.string,\n\tmousePos: PropTypes.object,\n\tdisable: PropTypes.bool, // Tooltip will not show if disabled\n\tshowToolTipIfTruncated: PropTypes.bool, // Set to true to only display tooltip if full text does not fit in displayable width\n\tdelay: PropTypes.number,\n\tshowToolTipOnClick: PropTypes.bool\n};\n\nToolTip.defaultProps = {\n\tdelay: 200,\n\tdirection: \"bottom\",\n\tshowToolTipIfTruncated: false, // False will always show Tooltip even when whole word can be displayed\n\tshowToolTipOnClick: false\n};\n\nexport default ToolTip;\n"],"names":["ToolTip","props","_classCallCheck","_this","state","isTooltipVisible","pendingTooltip","hideTooltipOnScrollAndResize","bind","window","addEventListener","this","targetObj","setTooltipVisible","removeEventListener","clearTimeout","visible","showTooltip","setState","tooltip","document","querySelector","id","tooltipTrigger","updateTooltipLayout","getAttribute","value","currentDirection","newDirection","canDisplayFullText","triggerRef","disable","showToolTipIfTruncated","elem","firstChildWidth","firstChild","scrollWidth","displayWidth","offsetWidth","fullWidth","that","setTimeout","delay","direction","tooltipDirection","viewPortWidth","documentElement","clientWidth","viewPortHeight","clientHeight","triggerLayout","getBoundingClientRect","pointer","pointerLayout","style","left","getStyleValue","top","mousePos","updateLocationBasedOnMousePos","tooltipLeft","width","offsetLeft","Math","round","right","height","offsetHeight","bottom","tooltipTop","isOutOfBounds","getNewDirection","setAttribute","mouseX","x","mouseY","y","parseFloat","evt","stopPropagation","preventDefault","url","open","tooltipContent","triggerContent","children","React","className","onMouseOver","showToolTipOnClick","_this2","onMouseLeave","onMouseDown","onClick","toggleTooltipOnClick","onFocus","showTooltipWithDelay","onBlur","relatedTarget","tabIndex","ref","tip","_typeof","tipClass","link","tooltipLinkHandler","linkInformation","label","Link","tooltipLinkOnClick","Portal","viewBox","points","Component","defaultProps"],"mappings":"+uBAwBMA,0CACL,WAAYC,GAAO,MAAA,OAAAC,2BAClBC,cAAMF,IACDG,MAAQ,CACZC,kBAAkB,GAGnBF,EAAKG,eAAiB,KACtBH,EAAKI,6BAA+BJ,EAAKI,6BAA6BC,4FAGvE,WACCC,OAAOC,iBAAiB,SAAUC,KAAKJ,8BAA8B,GACrEE,OAAOC,iBAAiB,SAAUC,KAAKJ,8BAA8B,GACjEI,KAAKV,MAAMW,WACdD,KAAKE,mBAAkB,uCAIzB,WACCJ,OAAOK,oBAAoB,SAAUH,KAAKJ,8BAA8B,GACxEE,OAAOK,oBAAoB,SAAUH,KAAKJ,8BAA8B,GACpEI,KAAKL,gBACRS,aAAaJ,KAAKL,iDAIpB,SAAkBU,GAWjB,KATKL,KAAKM,gBAAmBD,GAAWL,KAAKL,kBAC5CS,aAAaJ,KAAKL,gBAClBK,KAAKL,eAAiB,KACtBK,KAAKO,SAAS,CACbb,kBAAkB,KAKhBM,KAAKM,cAAe,CACvB,IAAME,EAAUC,S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