@rc-component/util 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +303 -0
- package/es/Children/toArray.d.ts +5 -0
- package/es/Children/toArray.js +19 -0
- package/es/Dom/canUseDom.d.ts +1 -0
- package/es/Dom/canUseDom.js +3 -0
- package/es/Dom/contains.d.ts +1 -0
- package/es/Dom/contains.js +20 -0
- package/es/Dom/dynamicCSS.d.ts +25 -0
- package/es/Dom/dynamicCSS.js +153 -0
- package/es/Dom/findDOMNode.d.ts +12 -0
- package/es/Dom/findDOMNode.js +36 -0
- package/es/Dom/focus.d.ts +8 -0
- package/es/Dom/focus.js +87 -0
- package/es/Dom/isVisible.d.ts +2 -0
- package/es/Dom/isVisible.js +27 -0
- package/es/Dom/scrollLocker.d.ts +12 -0
- package/es/Dom/scrollLocker.js +135 -0
- package/es/Dom/shadow.d.ts +8 -0
- package/es/Dom/shadow.js +18 -0
- package/es/Dom/styleChecker.d.ts +2 -0
- package/es/Dom/styleChecker.js +26 -0
- package/es/KeyCode.d.ts +436 -0
- package/es/KeyCode.js +538 -0
- package/es/Portal.d.ts +9 -0
- package/es/Portal.js +44 -0
- package/es/PortalWrapper.d.ts +51 -0
- package/es/PortalWrapper.js +217 -0
- package/es/React/isFragment.d.ts +4 -0
- package/es/React/isFragment.js +18 -0
- package/es/React/render.d.ts +13 -0
- package/es/React/render.js +114 -0
- package/es/composeProps.d.ts +2 -0
- package/es/composeProps.js +24 -0
- package/es/getScrollBarSize.d.ts +7 -0
- package/es/getScrollBarSize.js +76 -0
- package/es/hooks/useEffect.d.ts +2 -0
- package/es/hooks/useEffect.js +14 -0
- package/es/hooks/useEvent.d.ts +2 -0
- package/es/hooks/useEvent.js +16 -0
- package/es/hooks/useId.d.ts +4 -0
- package/es/hooks/useId.js +69 -0
- package/es/hooks/useLayoutEffect.d.ts +4 -0
- package/es/hooks/useLayoutEffect.js +30 -0
- package/es/hooks/useMemo.d.ts +1 -0
- package/es/hooks/useMemo.js +9 -0
- package/es/hooks/useMergedState.d.ts +12 -0
- package/es/hooks/useMergedState.js +68 -0
- package/es/hooks/useMobile.d.ts +6 -0
- package/es/hooks/useMobile.js +25 -0
- package/es/hooks/useState.d.ts +14 -0
- package/es/hooks/useState.js +32 -0
- package/es/hooks/useSyncState.d.ts +9 -0
- package/es/hooks/useSyncState.js +29 -0
- package/es/index.d.ts +6 -0
- package/es/index.js +6 -0
- package/es/isEqual.d.ts +9 -0
- package/es/isEqual.js +55 -0
- package/es/isMobile.d.ts +2 -0
- package/es/isMobile.js +7 -0
- package/es/omit.d.ts +1 -0
- package/es/omit.js +9 -0
- package/es/pickAttrs.d.ts +11 -0
- package/es/pickAttrs.js +51 -0
- package/es/proxyObject.d.ts +4 -0
- package/es/proxyObject.js +19 -0
- package/es/raf.d.ts +6 -0
- package/es/raf.js +54 -0
- package/es/ref.d.ts +19 -0
- package/es/ref.js +89 -0
- package/es/setStyle.d.ts +12 -0
- package/es/setStyle.js +26 -0
- package/es/test/domHook.d.ts +8 -0
- package/es/test/domHook.js +64 -0
- package/es/utils/get.d.ts +1 -0
- package/es/utils/get.js +10 -0
- package/es/utils/set.d.ts +6 -0
- package/es/utils/set.js +93 -0
- package/es/warning.d.ts +32 -0
- package/es/warning.js +68 -0
- package/lib/Children/toArray.d.ts +5 -0
- package/lib/Children/toArray.js +26 -0
- package/lib/Dom/canUseDom.d.ts +1 -0
- package/lib/Dom/canUseDom.js +9 -0
- package/lib/Dom/contains.d.ts +1 -0
- package/lib/Dom/contains.js +26 -0
- package/lib/Dom/dynamicCSS.d.ts +25 -0
- package/lib/Dom/dynamicCSS.js +163 -0
- package/lib/Dom/findDOMNode.d.ts +12 -0
- package/lib/Dom/findDOMNode.js +45 -0
- package/lib/Dom/focus.d.ts +8 -0
- package/lib/Dom/focus.js +98 -0
- package/lib/Dom/isVisible.d.ts +2 -0
- package/lib/Dom/isVisible.js +33 -0
- package/lib/Dom/scrollLocker.d.ts +12 -0
- package/lib/Dom/scrollLocker.js +141 -0
- package/lib/Dom/shadow.d.ts +8 -0
- package/lib/Dom/shadow.js +25 -0
- package/lib/Dom/styleChecker.d.ts +2 -0
- package/lib/Dom/styleChecker.js +33 -0
- package/lib/KeyCode.d.ts +436 -0
- package/lib/KeyCode.js +544 -0
- package/lib/Portal.d.ts +9 -0
- package/lib/Portal.js +51 -0
- package/lib/PortalWrapper.d.ts +51 -0
- package/lib/PortalWrapper.js +226 -0
- package/lib/React/isFragment.d.ts +4 -0
- package/lib/React/isFragment.js +24 -0
- package/lib/React/render.d.ts +13 -0
- package/lib/React/render.js +125 -0
- package/lib/composeProps.d.ts +2 -0
- package/lib/composeProps.js +30 -0
- package/lib/getScrollBarSize.d.ts +7 -0
- package/lib/getScrollBarSize.js +84 -0
- package/lib/hooks/useEffect.d.ts +2 -0
- package/lib/hooks/useEffect.js +22 -0
- package/lib/hooks/useEvent.d.ts +2 -0
- package/lib/hooks/useEvent.js +26 -0
- package/lib/hooks/useId.d.ts +4 -0
- package/lib/hooks/useId.js +78 -0
- package/lib/hooks/useLayoutEffect.d.ts +4 -0
- package/lib/hooks/useLayoutEffect.js +39 -0
- package/lib/hooks/useMemo.d.ts +1 -0
- package/lib/hooks/useMemo.js +18 -0
- package/lib/hooks/useMergedState.d.ts +12 -0
- package/lib/hooks/useMergedState.js +75 -0
- package/lib/hooks/useMobile.d.ts +6 -0
- package/lib/hooks/useMobile.js +31 -0
- package/lib/hooks/useState.d.ts +14 -0
- package/lib/hooks/useState.js +41 -0
- package/lib/hooks/useSyncState.d.ts +9 -0
- package/lib/hooks/useSyncState.js +39 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +60 -0
- package/lib/isEqual.d.ts +9 -0
- package/lib/isEqual.js +61 -0
- package/lib/isMobile.d.ts +2 -0
- package/lib/isMobile.js +13 -0
- package/lib/omit.d.ts +1 -0
- package/lib/omit.js +15 -0
- package/lib/pickAttrs.d.ts +11 -0
- package/lib/pickAttrs.js +57 -0
- package/lib/proxyObject.d.ts +4 -0
- package/lib/proxyObject.js +25 -0
- package/lib/raf.d.ts +6 -0
- package/lib/raf.js +60 -0
- package/lib/ref.d.ts +19 -0
- package/lib/ref.js +96 -0
- package/lib/setStyle.d.ts +12 -0
- package/lib/setStyle.js +32 -0
- package/lib/test/domHook.d.ts +8 -0
- package/lib/test/domHook.js +71 -0
- package/lib/utils/get.d.ts +1 -0
- package/lib/utils/get.js +16 -0
- package/lib/utils/set.d.ts +6 -0
- package/lib/utils/set.js +101 -0
- package/lib/warning.d.ts +32 -0
- package/lib/warning.js +81 -0
- package/package.json +76 -0
package/lib/Dom/focus.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.backLastFocusNode = backLastFocusNode;
|
|
7
|
+
exports.clearLastFocusNode = clearLastFocusNode;
|
|
8
|
+
exports.getFocusNodeList = getFocusNodeList;
|
|
9
|
+
exports.limitTabRange = limitTabRange;
|
|
10
|
+
exports.saveLastFocusNode = saveLastFocusNode;
|
|
11
|
+
var _isVisible = _interopRequireDefault(require("./isVisible"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
+
function focusable(node) {
|
|
20
|
+
var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
21
|
+
if ((0, _isVisible.default)(node)) {
|
|
22
|
+
var nodeName = node.nodeName.toLowerCase();
|
|
23
|
+
var isFocusableElement =
|
|
24
|
+
// Focusable element
|
|
25
|
+
['input', 'select', 'textarea', 'button'].includes(nodeName) ||
|
|
26
|
+
// Editable element
|
|
27
|
+
node.isContentEditable ||
|
|
28
|
+
// Anchor with href element
|
|
29
|
+
nodeName === 'a' && !!node.getAttribute('href');
|
|
30
|
+
|
|
31
|
+
// Get tabIndex
|
|
32
|
+
var tabIndexAttr = node.getAttribute('tabindex');
|
|
33
|
+
var tabIndexNum = Number(tabIndexAttr);
|
|
34
|
+
|
|
35
|
+
// Parse as number if validate
|
|
36
|
+
var tabIndex = null;
|
|
37
|
+
if (tabIndexAttr && !Number.isNaN(tabIndexNum)) {
|
|
38
|
+
tabIndex = tabIndexNum;
|
|
39
|
+
} else if (isFocusableElement && tabIndex === null) {
|
|
40
|
+
tabIndex = 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Block focusable if disabled
|
|
44
|
+
if (isFocusableElement && node.disabled) {
|
|
45
|
+
tabIndex = null;
|
|
46
|
+
}
|
|
47
|
+
return tabIndex !== null && (tabIndex >= 0 || includePositive && tabIndex < 0);
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
function getFocusNodeList(node) {
|
|
52
|
+
var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
53
|
+
var res = _toConsumableArray(node.querySelectorAll('*')).filter(function (child) {
|
|
54
|
+
return focusable(child, includePositive);
|
|
55
|
+
});
|
|
56
|
+
if (focusable(node, includePositive)) {
|
|
57
|
+
res.unshift(node);
|
|
58
|
+
}
|
|
59
|
+
return res;
|
|
60
|
+
}
|
|
61
|
+
var lastFocusElement = null;
|
|
62
|
+
|
|
63
|
+
/** @deprecated Do not use since this may failed when used in async */
|
|
64
|
+
function saveLastFocusNode() {
|
|
65
|
+
lastFocusElement = document.activeElement;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** @deprecated Do not use since this may failed when used in async */
|
|
69
|
+
function clearLastFocusNode() {
|
|
70
|
+
lastFocusElement = null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @deprecated Do not use since this may failed when used in async */
|
|
74
|
+
function backLastFocusNode() {
|
|
75
|
+
if (lastFocusElement) {
|
|
76
|
+
try {
|
|
77
|
+
// 元素可能已经被移动了
|
|
78
|
+
lastFocusElement.focus();
|
|
79
|
+
|
|
80
|
+
/* eslint-disable no-empty */
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// empty
|
|
83
|
+
}
|
|
84
|
+
/* eslint-enable no-empty */
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function limitTabRange(node, e) {
|
|
88
|
+
if (e.keyCode === 9) {
|
|
89
|
+
var tabNodeList = getFocusNodeList(node);
|
|
90
|
+
var lastTabNode = tabNodeList[e.shiftKey ? 0 : tabNodeList.length - 1];
|
|
91
|
+
var leavingTab = lastTabNode === document.activeElement || node === document.activeElement;
|
|
92
|
+
if (leavingTab) {
|
|
93
|
+
var target = tabNodeList[e.shiftKey ? tabNodeList.length - 1 : 0];
|
|
94
|
+
target.focus();
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = function _default(element) {
|
|
8
|
+
if (!element) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (element instanceof Element) {
|
|
12
|
+
if (element.offsetParent) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (element.getBBox) {
|
|
16
|
+
var _getBBox = element.getBBox(),
|
|
17
|
+
width = _getBBox.width,
|
|
18
|
+
height = _getBBox.height;
|
|
19
|
+
if (width || height) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (element.getBoundingClientRect) {
|
|
24
|
+
var _element$getBoundingC = element.getBoundingClientRect(),
|
|
25
|
+
_width = _element$getBoundingC.width,
|
|
26
|
+
_height = _element$getBoundingC.height;
|
|
27
|
+
if (_width || _height) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface scrollLockOptions {
|
|
2
|
+
container: HTMLElement;
|
|
3
|
+
}
|
|
4
|
+
export default class ScrollLocker {
|
|
5
|
+
private lockTarget;
|
|
6
|
+
private options;
|
|
7
|
+
constructor(options?: scrollLockOptions);
|
|
8
|
+
getContainer: () => HTMLElement | undefined;
|
|
9
|
+
reLock: (options?: scrollLockOptions) => void;
|
|
10
|
+
lock: () => void;
|
|
11
|
+
unLock: () => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _getScrollBarSize = _interopRequireDefault(require("../getScrollBarSize"));
|
|
8
|
+
var _setStyle = _interopRequireDefault(require("../setStyle"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
18
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
var uuid = 0;
|
|
24
|
+
var locks = [];
|
|
25
|
+
var scrollingEffectClassName = 'ant-scrolling-effect';
|
|
26
|
+
var scrollingEffectClassNameReg = new RegExp("".concat(scrollingEffectClassName), 'g');
|
|
27
|
+
|
|
28
|
+
// https://github.com/ant-design/ant-design/issues/19340
|
|
29
|
+
// https://github.com/ant-design/ant-design/issues/19332
|
|
30
|
+
var cacheStyle = new Map();
|
|
31
|
+
var ScrollLocker = exports.default = /*#__PURE__*/_createClass(function ScrollLocker(_options) {
|
|
32
|
+
var _this = this;
|
|
33
|
+
_classCallCheck(this, ScrollLocker);
|
|
34
|
+
_defineProperty(this, "lockTarget", void 0);
|
|
35
|
+
_defineProperty(this, "options", void 0);
|
|
36
|
+
_defineProperty(this, "getContainer", function () {
|
|
37
|
+
var _this$options;
|
|
38
|
+
return (_this$options = _this.options) === null || _this$options === void 0 ? void 0 : _this$options.container;
|
|
39
|
+
});
|
|
40
|
+
// if options change...
|
|
41
|
+
_defineProperty(this, "reLock", function (options) {
|
|
42
|
+
var findLock = locks.find(function (_ref) {
|
|
43
|
+
var target = _ref.target;
|
|
44
|
+
return target === _this.lockTarget;
|
|
45
|
+
});
|
|
46
|
+
if (findLock) {
|
|
47
|
+
_this.unLock();
|
|
48
|
+
}
|
|
49
|
+
_this.options = options;
|
|
50
|
+
if (findLock) {
|
|
51
|
+
findLock.options = options;
|
|
52
|
+
_this.lock();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
_defineProperty(this, "lock", function () {
|
|
56
|
+
var _this$options3;
|
|
57
|
+
// If lockTarget exist return
|
|
58
|
+
if (locks.some(function (_ref2) {
|
|
59
|
+
var target = _ref2.target;
|
|
60
|
+
return target === _this.lockTarget;
|
|
61
|
+
})) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// If same container effect, return
|
|
66
|
+
if (locks.some(function (_ref3) {
|
|
67
|
+
var _this$options2;
|
|
68
|
+
var options = _ref3.options;
|
|
69
|
+
return (options === null || options === void 0 ? void 0 : options.container) === ((_this$options2 = _this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.container);
|
|
70
|
+
})) {
|
|
71
|
+
locks = [].concat(_toConsumableArray(locks), [{
|
|
72
|
+
target: _this.lockTarget,
|
|
73
|
+
options: _this.options
|
|
74
|
+
}]);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
var scrollBarSize = 0;
|
|
78
|
+
var container = ((_this$options3 = _this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.container) || document.body;
|
|
79
|
+
if (container === document.body && window.innerWidth - document.documentElement.clientWidth > 0 || container.scrollHeight > container.clientHeight) {
|
|
80
|
+
if (getComputedStyle(container).overflow !== 'hidden') {
|
|
81
|
+
scrollBarSize = (0, _getScrollBarSize.default)();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var containerClassName = container.className;
|
|
85
|
+
if (locks.filter(function (_ref4) {
|
|
86
|
+
var _this$options4;
|
|
87
|
+
var options = _ref4.options;
|
|
88
|
+
return (options === null || options === void 0 ? void 0 : options.container) === ((_this$options4 = _this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.container);
|
|
89
|
+
}).length === 0) {
|
|
90
|
+
cacheStyle.set(container, (0, _setStyle.default)({
|
|
91
|
+
width: scrollBarSize !== 0 ? "calc(100% - ".concat(scrollBarSize, "px)") : undefined,
|
|
92
|
+
overflow: 'hidden',
|
|
93
|
+
overflowX: 'hidden',
|
|
94
|
+
overflowY: 'hidden'
|
|
95
|
+
}, {
|
|
96
|
+
element: container
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// https://github.com/ant-design/ant-design/issues/19729
|
|
101
|
+
if (!scrollingEffectClassNameReg.test(containerClassName)) {
|
|
102
|
+
var addClassName = "".concat(containerClassName, " ").concat(scrollingEffectClassName);
|
|
103
|
+
container.className = addClassName.trim();
|
|
104
|
+
}
|
|
105
|
+
locks = [].concat(_toConsumableArray(locks), [{
|
|
106
|
+
target: _this.lockTarget,
|
|
107
|
+
options: _this.options
|
|
108
|
+
}]);
|
|
109
|
+
});
|
|
110
|
+
_defineProperty(this, "unLock", function () {
|
|
111
|
+
var _this$options5;
|
|
112
|
+
var findLock = locks.find(function (_ref5) {
|
|
113
|
+
var target = _ref5.target;
|
|
114
|
+
return target === _this.lockTarget;
|
|
115
|
+
});
|
|
116
|
+
locks = locks.filter(function (_ref6) {
|
|
117
|
+
var target = _ref6.target;
|
|
118
|
+
return target !== _this.lockTarget;
|
|
119
|
+
});
|
|
120
|
+
if (!findLock || locks.some(function (_ref7) {
|
|
121
|
+
var _findLock$options;
|
|
122
|
+
var options = _ref7.options;
|
|
123
|
+
return (options === null || options === void 0 ? void 0 : options.container) === ((_findLock$options = findLock.options) === null || _findLock$options === void 0 ? void 0 : _findLock$options.container);
|
|
124
|
+
})) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Remove Effect
|
|
129
|
+
var container = ((_this$options5 = _this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.container) || document.body;
|
|
130
|
+
var containerClassName = container.className;
|
|
131
|
+
if (!scrollingEffectClassNameReg.test(containerClassName)) return;
|
|
132
|
+
(0, _setStyle.default)(cacheStyle.get(container), {
|
|
133
|
+
element: container
|
|
134
|
+
});
|
|
135
|
+
cacheStyle.delete(container);
|
|
136
|
+
container.className = container.className.replace(scrollingEffectClassNameReg, '').trim();
|
|
137
|
+
});
|
|
138
|
+
// eslint-disable-next-line no-plusplus
|
|
139
|
+
this.lockTarget = uuid++;
|
|
140
|
+
this.options = _options;
|
|
141
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getShadowRoot = getShadowRoot;
|
|
7
|
+
exports.inShadow = inShadow;
|
|
8
|
+
function getRoot(ele) {
|
|
9
|
+
var _ele$getRootNode;
|
|
10
|
+
return ele === null || ele === void 0 || (_ele$getRootNode = ele.getRootNode) === null || _ele$getRootNode === void 0 ? void 0 : _ele$getRootNode.call(ele);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if is in shadowRoot
|
|
15
|
+
*/
|
|
16
|
+
function inShadow(ele) {
|
|
17
|
+
return getRoot(ele) instanceof ShadowRoot;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Return shadowRoot if possible
|
|
22
|
+
*/
|
|
23
|
+
function getShadowRoot(ele) {
|
|
24
|
+
return inShadow(ele) ? getRoot(ele) : null;
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isStyleSupport = isStyleSupport;
|
|
7
|
+
var _canUseDom = _interopRequireDefault(require("./canUseDom"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var isStyleNameSupport = function isStyleNameSupport(styleName) {
|
|
10
|
+
if ((0, _canUseDom.default)() && window.document.documentElement) {
|
|
11
|
+
var styleNameList = Array.isArray(styleName) ? styleName : [styleName];
|
|
12
|
+
var documentElement = window.document.documentElement;
|
|
13
|
+
return styleNameList.some(function (name) {
|
|
14
|
+
return name in documentElement.style;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
var isStyleValueSupport = function isStyleValueSupport(styleName, value) {
|
|
20
|
+
if (!isStyleNameSupport(styleName)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
var ele = document.createElement('div');
|
|
24
|
+
var origin = ele.style[styleName];
|
|
25
|
+
ele.style[styleName] = value;
|
|
26
|
+
return ele.style[styleName] !== origin;
|
|
27
|
+
};
|
|
28
|
+
function isStyleSupport(styleName, styleValue) {
|
|
29
|
+
if (!Array.isArray(styleName) && styleValue !== undefined) {
|
|
30
|
+
return isStyleValueSupport(styleName, styleValue);
|
|
31
|
+
}
|
|
32
|
+
return isStyleNameSupport(styleName);
|
|
33
|
+
}
|