first commit
This commit is contained in:
30
frontend/node_modules/@rc-component/trigger/lib/hooks/useAction.js
generated
vendored
Normal file
30
frontend/node_modules/@rc-component/trigger/lib/hooks/useAction.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = useAction;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
function toArray(val) {
|
||||
return val ? Array.isArray(val) ? val : [val] : [];
|
||||
}
|
||||
function useAction(mobile, action, showAction, hideAction) {
|
||||
return React.useMemo(function () {
|
||||
var mergedShowAction = toArray(showAction !== null && showAction !== void 0 ? showAction : action);
|
||||
var mergedHideAction = toArray(hideAction !== null && hideAction !== void 0 ? hideAction : action);
|
||||
var showActionSet = new Set(mergedShowAction);
|
||||
var hideActionSet = new Set(mergedHideAction);
|
||||
if (mobile) {
|
||||
if (showActionSet.has('hover')) {
|
||||
showActionSet.delete('hover');
|
||||
showActionSet.add('click');
|
||||
}
|
||||
if (hideActionSet.has('hover')) {
|
||||
hideActionSet.delete('hover');
|
||||
hideActionSet.add('click');
|
||||
}
|
||||
}
|
||||
return [showActionSet, hideActionSet];
|
||||
}, [mobile, action, showAction, hideAction]);
|
||||
}
|
||||
Reference in New Issue
Block a user