bi-open-menu-sdk
Advanced tools
Comparing version
@@ -28,3 +28,3 @@ /** | ||
disabled?: boolean; | ||
/** hover 提示 */ | ||
/** PC端鼠标 hover 提示 */ | ||
hoverTip?: string; | ||
@@ -31,0 +31,0 @@ /** 是否加载中 */ |
@@ -54,4 +54,3 @@ "use strict"; | ||
style = _ref.style, | ||
_ref$title = _ref.title, | ||
title = _ref$title === void 0 ? '' : _ref$title, | ||
title = _ref.title, | ||
_ref$disabled = _ref.disabled, | ||
@@ -61,4 +60,3 @@ disabled = _ref$disabled === void 0 ? false : _ref$disabled, | ||
loading = _ref$loading === void 0 ? false : _ref$loading, | ||
_ref$hoverTip = _ref.hoverTip, | ||
hoverTip = _ref$hoverTip === void 0 ? '' : _ref$hoverTip, | ||
hoverTip = _ref.hoverTip, | ||
onClick = _ref.onClick; | ||
@@ -71,7 +69,2 @@ | ||
var _React$useState3 = React.useState(false), | ||
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2), | ||
hoverTipVisible = _React$useState4[0], | ||
setHoverTipVisible = _React$useState4[1]; | ||
var ref = React.useRef(); | ||
@@ -91,11 +84,11 @@ React.useEffect(function () { | ||
}, []); | ||
React.useEffect(function () { | ||
var setTip = React.useCallback(function (visible) { | ||
if (ref.current) { | ||
var container = ref.current.closest('[data-custom-component-root]'); | ||
if (typeof hoverTip === 'string' && container) { | ||
if (hoverTip && typeof hoverTip === 'string' && container) { | ||
container.dispatchEvent(new CustomEvent(CUSTOM_MENU_TOOLTIP_EVENT, { | ||
detail: { | ||
title: hoverTip, | ||
visible: hoverTipVisible | ||
visible: visible | ||
} | ||
@@ -105,3 +98,3 @@ })); | ||
} | ||
}, [hoverTip, hoverTipVisible]); | ||
}, [hoverTip]); | ||
React.useEffect(function () { | ||
@@ -118,8 +111,2 @@ if (ref.current) { | ||
}, []); | ||
var handleMouseEnter = React.useCallback(function (e) { | ||
setHoverTipVisible(true); | ||
}, []); | ||
var handleMouseLeave = React.useCallback(function (e) { | ||
setHoverTipVisible(false); | ||
}, []); | ||
var iconContent = React.createElement(IconDefault, { | ||
@@ -146,7 +133,19 @@ className: "default-icon" | ||
}, [disabled, onClick]); | ||
var handleMouseEnter = React.useCallback(function (e) { | ||
setTip(true); | ||
}, [setTip]); | ||
var handleMouseLeave = React.useCallback(function (e) { | ||
setTip(false); | ||
}, [setTip]); | ||
var viewTitle = React.useMemo(function () { | ||
var _ref2, _ref2$componentInfo; | ||
var originConfigName = (_ref2 = window.globalConfig) === null || _ref2 === void 0 ? void 0 : (_ref2$componentInfo = _ref2.componentInfo) === null || _ref2$componentInfo === void 0 ? void 0 : _ref2$componentInfo.name; | ||
var configName = typeof originConfigName === 'string' ? originConfigName : ''; | ||
var propsTitle = typeof title === 'string' ? title : undefined; | ||
return propsTitle !== null && propsTitle !== void 0 ? propsTitle : configName; | ||
}, [title]); | ||
return React.createElement("div", { | ||
ref: ref, | ||
className: "custom-card-menu ".concat(disabled ? 'disabled' : '', " ").concat(className || ''), | ||
onMouseOver: handleMouseEnter, | ||
onMouseOut: handleMouseLeave, | ||
style: style, | ||
@@ -158,6 +157,8 @@ onClick: handleClick | ||
className: "custom-card-menu-text", | ||
title: typeof title === 'string' ? title : '' | ||
}, title)); | ||
title: viewTitle, | ||
onMouseOver: handleMouseEnter, | ||
onMouseOut: handleMouseLeave | ||
}, viewTitle)); | ||
}; | ||
exports.MenuItem = MenuItem; |
@@ -28,4 +28,3 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray.js"; | ||
style = _ref.style, | ||
_ref$title = _ref.title, | ||
title = _ref$title === void 0 ? '' : _ref$title, | ||
title = _ref.title, | ||
_ref$disabled = _ref.disabled, | ||
@@ -35,4 +34,3 @@ disabled = _ref$disabled === void 0 ? false : _ref$disabled, | ||
loading = _ref$loading === void 0 ? false : _ref$loading, | ||
_ref$hoverTip = _ref.hoverTip, | ||
hoverTip = _ref$hoverTip === void 0 ? '' : _ref$hoverTip, | ||
hoverTip = _ref.hoverTip, | ||
onClick = _ref.onClick; | ||
@@ -45,7 +43,2 @@ | ||
var _React$useState3 = React.useState(false), | ||
_React$useState4 = _slicedToArray(_React$useState3, 2), | ||
hoverTipVisible = _React$useState4[0], | ||
setHoverTipVisible = _React$useState4[1]; | ||
var ref = React.useRef(); | ||
@@ -65,11 +58,11 @@ React.useEffect(function () { | ||
}, []); | ||
React.useEffect(function () { | ||
var setTip = React.useCallback(function (visible) { | ||
if (ref.current) { | ||
var container = ref.current.closest('[data-custom-component-root]'); | ||
if (typeof hoverTip === 'string' && container) { | ||
if (hoverTip && typeof hoverTip === 'string' && container) { | ||
container.dispatchEvent(new CustomEvent(CUSTOM_MENU_TOOLTIP_EVENT, { | ||
detail: { | ||
title: hoverTip, | ||
visible: hoverTipVisible | ||
visible: visible | ||
} | ||
@@ -79,3 +72,3 @@ })); | ||
} | ||
}, [hoverTip, hoverTipVisible]); | ||
}, [hoverTip]); | ||
React.useEffect(function () { | ||
@@ -92,8 +85,2 @@ if (ref.current) { | ||
}, []); | ||
var handleMouseEnter = React.useCallback(function (e) { | ||
setHoverTipVisible(true); | ||
}, []); | ||
var handleMouseLeave = React.useCallback(function (e) { | ||
setHoverTipVisible(false); | ||
}, []); | ||
var iconContent = React.createElement(IconDefault, { | ||
@@ -120,7 +107,19 @@ className: "default-icon" | ||
}, [disabled, onClick]); | ||
var handleMouseEnter = React.useCallback(function (e) { | ||
setTip(true); | ||
}, [setTip]); | ||
var handleMouseLeave = React.useCallback(function (e) { | ||
setTip(false); | ||
}, [setTip]); | ||
var viewTitle = React.useMemo(function () { | ||
var _ref2, _ref2$componentInfo; | ||
var originConfigName = (_ref2 = window.globalConfig) === null || _ref2 === void 0 ? void 0 : (_ref2$componentInfo = _ref2.componentInfo) === null || _ref2$componentInfo === void 0 ? void 0 : _ref2$componentInfo.name; | ||
var configName = typeof originConfigName === 'string' ? originConfigName : ''; | ||
var propsTitle = typeof title === 'string' ? title : undefined; | ||
return propsTitle !== null && propsTitle !== void 0 ? propsTitle : configName; | ||
}, [title]); | ||
return React.createElement("div", { | ||
ref: ref, | ||
className: "custom-card-menu ".concat(disabled ? 'disabled' : '', " ").concat(className || ''), | ||
onMouseOver: handleMouseEnter, | ||
onMouseOut: handleMouseLeave, | ||
style: style, | ||
@@ -132,4 +131,6 @@ onClick: handleClick | ||
className: "custom-card-menu-text", | ||
title: typeof title === 'string' ? title : '' | ||
}, title)); | ||
title: viewTitle, | ||
onMouseOver: handleMouseEnter, | ||
onMouseOut: handleMouseLeave | ||
}, viewTitle)); | ||
}; |
{ | ||
"name": "bi-open-menu-sdk", | ||
"version": "0.0.7", | ||
"version": "0.0.8-beta.0", | ||
"main": "dist/main", | ||
"peerDependencies": { | ||
@@ -17,7 +18,6 @@ "react": "^16.12.0", | ||
"dependencies": { | ||
"bi-open-react-sdk": "^2.1.12" | ||
"bi-open-react-sdk": "2.1.13-beta.0" | ||
}, | ||
"main": "dist/main", | ||
"module": "dist/module", | ||
"types": "declaration/index.d.ts" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19048
-0.19%464
-1.28%1
Infinity%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed