@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
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.getOpenCount = getOpenCount;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _raf = _interopRequireDefault(require("./raf"));
|
|
10
|
+
var _Portal = _interopRequireDefault(require("./Portal"));
|
|
11
|
+
var _canUseDom = _interopRequireDefault(require("./Dom/canUseDom"));
|
|
12
|
+
var _setStyle = _interopRequireDefault(require("./setStyle"));
|
|
13
|
+
var _scrollLocker = _interopRequireDefault(require("./Dom/scrollLocker"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
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); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
23
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
24
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
26
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
+
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; }
|
|
28
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
29
|
+
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); }
|
|
30
|
+
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); } /* eslint-disable no-underscore-dangle,react/require-default-props */
|
|
31
|
+
var openCount = 0;
|
|
32
|
+
var supportDom = (0, _canUseDom.default)();
|
|
33
|
+
|
|
34
|
+
/** @private Test usage only */
|
|
35
|
+
function getOpenCount() {
|
|
36
|
+
return process.env.NODE_ENV === 'test' ? openCount : 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// https://github.com/ant-design/ant-design/issues/19340
|
|
40
|
+
// https://github.com/ant-design/ant-design/issues/19332
|
|
41
|
+
var cacheOverflow = {};
|
|
42
|
+
var getParent = function getParent(getContainer) {
|
|
43
|
+
if (!supportDom) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (getContainer) {
|
|
47
|
+
if (typeof getContainer === 'string') {
|
|
48
|
+
return document.querySelectorAll(getContainer)[0];
|
|
49
|
+
}
|
|
50
|
+
if (typeof getContainer === 'function') {
|
|
51
|
+
return getContainer();
|
|
52
|
+
}
|
|
53
|
+
if (_typeof(getContainer) === 'object' && getContainer instanceof window.HTMLElement) {
|
|
54
|
+
return getContainer;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return document.body;
|
|
58
|
+
};
|
|
59
|
+
var PortalWrapper = /*#__PURE__*/function (_React$Component) {
|
|
60
|
+
_inherits(PortalWrapper, _React$Component);
|
|
61
|
+
var _super = _createSuper(PortalWrapper);
|
|
62
|
+
function PortalWrapper(props) {
|
|
63
|
+
var _this;
|
|
64
|
+
_classCallCheck(this, PortalWrapper);
|
|
65
|
+
_this = _super.call(this, props);
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "container", void 0);
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "componentRef", /*#__PURE__*/React.createRef());
|
|
68
|
+
_defineProperty(_assertThisInitialized(_this), "rafId", void 0);
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "scrollLocker", void 0);
|
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "renderComponent", void 0);
|
|
71
|
+
_defineProperty(_assertThisInitialized(_this), "updateScrollLocker", function (prevProps) {
|
|
72
|
+
var _ref = prevProps || {},
|
|
73
|
+
prevVisible = _ref.visible;
|
|
74
|
+
var _this$props = _this.props,
|
|
75
|
+
getContainer = _this$props.getContainer,
|
|
76
|
+
visible = _this$props.visible;
|
|
77
|
+
if (visible && visible !== prevVisible && supportDom && getParent(getContainer) !== _this.scrollLocker.getContainer()) {
|
|
78
|
+
_this.scrollLocker.reLock({
|
|
79
|
+
container: getParent(getContainer)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
_defineProperty(_assertThisInitialized(_this), "updateOpenCount", function (prevProps) {
|
|
84
|
+
var _ref2 = prevProps || {},
|
|
85
|
+
prevVisible = _ref2.visible,
|
|
86
|
+
prevGetContainer = _ref2.getContainer;
|
|
87
|
+
var _this$props2 = _this.props,
|
|
88
|
+
visible = _this$props2.visible,
|
|
89
|
+
getContainer = _this$props2.getContainer;
|
|
90
|
+
|
|
91
|
+
// Update count
|
|
92
|
+
if (visible !== prevVisible && supportDom && getParent(getContainer) === document.body) {
|
|
93
|
+
if (visible && !prevVisible) {
|
|
94
|
+
openCount += 1;
|
|
95
|
+
} else if (prevProps) {
|
|
96
|
+
openCount -= 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Clean up container if needed
|
|
101
|
+
var getContainerIsFunc = typeof getContainer === 'function' && typeof prevGetContainer === 'function';
|
|
102
|
+
if (getContainerIsFunc ? getContainer.toString() !== prevGetContainer.toString() : getContainer !== prevGetContainer) {
|
|
103
|
+
_this.removeCurrentContainer();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "attachToParent", function () {
|
|
107
|
+
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
108
|
+
if (force || _this.container && !_this.container.parentNode) {
|
|
109
|
+
var parent = getParent(_this.props.getContainer);
|
|
110
|
+
if (parent) {
|
|
111
|
+
parent.appendChild(_this.container);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
});
|
|
118
|
+
_defineProperty(_assertThisInitialized(_this), "getContainer", function () {
|
|
119
|
+
if (!supportDom) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
if (!_this.container) {
|
|
123
|
+
_this.container = document.createElement('div');
|
|
124
|
+
_this.attachToParent(true);
|
|
125
|
+
}
|
|
126
|
+
_this.setWrapperClassName();
|
|
127
|
+
return _this.container;
|
|
128
|
+
});
|
|
129
|
+
_defineProperty(_assertThisInitialized(_this), "setWrapperClassName", function () {
|
|
130
|
+
var wrapperClassName = _this.props.wrapperClassName;
|
|
131
|
+
if (_this.container && wrapperClassName && wrapperClassName !== _this.container.className) {
|
|
132
|
+
_this.container.className = wrapperClassName;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
_defineProperty(_assertThisInitialized(_this), "removeCurrentContainer", function () {
|
|
136
|
+
var _this$container;
|
|
137
|
+
// Portal will remove from `parentNode`.
|
|
138
|
+
// Let's handle this again to avoid refactor issue.
|
|
139
|
+
(_this$container = _this.container) === null || _this$container === void 0 || (_this$container = _this$container.parentNode) === null || _this$container === void 0 || _this$container.removeChild(_this.container);
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* Enhance ./switchScrollingEffect
|
|
143
|
+
* 1. Simulate document body scroll bar with
|
|
144
|
+
* 2. Record body has overflow style and recover when all of PortalWrapper invisible
|
|
145
|
+
* 3. Disable body scroll when PortalWrapper has open
|
|
146
|
+
*
|
|
147
|
+
* @memberof PortalWrapper
|
|
148
|
+
*/
|
|
149
|
+
_defineProperty(_assertThisInitialized(_this), "switchScrollingEffect", function () {
|
|
150
|
+
if (openCount === 1 && !Object.keys(cacheOverflow).length) {
|
|
151
|
+
// Must be set after switchScrollingEffect
|
|
152
|
+
cacheOverflow = (0, _setStyle.default)({
|
|
153
|
+
overflow: 'hidden',
|
|
154
|
+
overflowX: 'hidden',
|
|
155
|
+
overflowY: 'hidden'
|
|
156
|
+
});
|
|
157
|
+
} else if (!openCount) {
|
|
158
|
+
(0, _setStyle.default)(cacheOverflow);
|
|
159
|
+
cacheOverflow = {};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
_this.scrollLocker = new _scrollLocker.default({
|
|
163
|
+
container: getParent(props.getContainer)
|
|
164
|
+
});
|
|
165
|
+
return _this;
|
|
166
|
+
}
|
|
167
|
+
_createClass(PortalWrapper, [{
|
|
168
|
+
key: "componentDidMount",
|
|
169
|
+
value: function componentDidMount() {
|
|
170
|
+
var _this2 = this;
|
|
171
|
+
this.updateOpenCount();
|
|
172
|
+
if (!this.attachToParent()) {
|
|
173
|
+
this.rafId = (0, _raf.default)(function () {
|
|
174
|
+
_this2.forceUpdate();
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "componentDidUpdate",
|
|
180
|
+
value: function componentDidUpdate(prevProps) {
|
|
181
|
+
this.updateOpenCount(prevProps);
|
|
182
|
+
this.updateScrollLocker(prevProps);
|
|
183
|
+
this.setWrapperClassName();
|
|
184
|
+
this.attachToParent();
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "componentWillUnmount",
|
|
188
|
+
value: function componentWillUnmount() {
|
|
189
|
+
var _this$props3 = this.props,
|
|
190
|
+
visible = _this$props3.visible,
|
|
191
|
+
getContainer = _this$props3.getContainer;
|
|
192
|
+
if (supportDom && getParent(getContainer) === document.body) {
|
|
193
|
+
// 离开时不会 render, 导到离开时数值不变,改用 func 。。
|
|
194
|
+
openCount = visible && openCount ? openCount - 1 : openCount;
|
|
195
|
+
}
|
|
196
|
+
this.removeCurrentContainer();
|
|
197
|
+
_raf.default.cancel(this.rafId);
|
|
198
|
+
}
|
|
199
|
+
}, {
|
|
200
|
+
key: "render",
|
|
201
|
+
value: function render() {
|
|
202
|
+
var _this$props4 = this.props,
|
|
203
|
+
children = _this$props4.children,
|
|
204
|
+
forceRender = _this$props4.forceRender,
|
|
205
|
+
visible = _this$props4.visible;
|
|
206
|
+
var portal = null;
|
|
207
|
+
var childProps = {
|
|
208
|
+
getOpenCount: function getOpenCount() {
|
|
209
|
+
return openCount;
|
|
210
|
+
},
|
|
211
|
+
getContainer: this.getContainer,
|
|
212
|
+
switchScrollingEffect: this.switchScrollingEffect,
|
|
213
|
+
scrollLocker: this.scrollLocker
|
|
214
|
+
};
|
|
215
|
+
if (forceRender || visible || this.componentRef.current) {
|
|
216
|
+
portal = /*#__PURE__*/React.createElement(_Portal.default, {
|
|
217
|
+
getContainer: this.getContainer,
|
|
218
|
+
ref: this.componentRef
|
|
219
|
+
}, children(childProps));
|
|
220
|
+
}
|
|
221
|
+
return portal;
|
|
222
|
+
}
|
|
223
|
+
}]);
|
|
224
|
+
return PortalWrapper;
|
|
225
|
+
}(React.Component);
|
|
226
|
+
var _default = exports.default = PortalWrapper;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = isFragment;
|
|
7
|
+
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); }
|
|
8
|
+
var REACT_ELEMENT_TYPE_18 = Symbol.for('react.element');
|
|
9
|
+
var REACT_ELEMENT_TYPE_19 = Symbol.for('react.transitional.element');
|
|
10
|
+
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Compatible with React 18 or 19 to check if node is a Fragment.
|
|
14
|
+
*/
|
|
15
|
+
function isFragment(object) {
|
|
16
|
+
return (
|
|
17
|
+
// Base object type
|
|
18
|
+
object && _typeof(object) === 'object' && (
|
|
19
|
+
// React Element type
|
|
20
|
+
object.$$typeof === REACT_ELEMENT_TYPE_18 || object.$$typeof === REACT_ELEMENT_TYPE_19) &&
|
|
21
|
+
// React Fragment type
|
|
22
|
+
object.type === REACT_FRAGMENT_TYPE
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { Root } from 'react-dom/client';
|
|
3
|
+
declare const MARK = "__rc_react_root__";
|
|
4
|
+
type ContainerType = (Element | DocumentFragment) & {
|
|
5
|
+
[MARK]?: Root;
|
|
6
|
+
};
|
|
7
|
+
/** @private Test usage. Not work in prod */
|
|
8
|
+
export declare function _r(node: React.ReactElement, container: ContainerType): void;
|
|
9
|
+
export declare function render(node: React.ReactElement, container: ContainerType): void;
|
|
10
|
+
/** @private Test usage. Not work in prod */
|
|
11
|
+
export declare function _u(container: ContainerType): void;
|
|
12
|
+
export declare function unmount(container: ContainerType): Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports._r = _r;
|
|
7
|
+
exports._u = _u;
|
|
8
|
+
exports.render = render;
|
|
9
|
+
exports.unmount = unmount;
|
|
10
|
+
var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
14
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
16
|
+
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); }
|
|
17
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
|
+
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); }
|
|
22
|
+
// Let compiler not to search module usage
|
|
23
|
+
var fullClone = _objectSpread({}, ReactDOM);
|
|
24
|
+
var version = fullClone.version,
|
|
25
|
+
reactRender = fullClone.render,
|
|
26
|
+
unmountComponentAtNode = fullClone.unmountComponentAtNode;
|
|
27
|
+
var createRoot;
|
|
28
|
+
try {
|
|
29
|
+
var mainVersion = Number((version || '').split('.')[0]);
|
|
30
|
+
if (mainVersion >= 18) {
|
|
31
|
+
createRoot = fullClone.createRoot;
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// Do nothing;
|
|
35
|
+
}
|
|
36
|
+
function toggleWarning(skip) {
|
|
37
|
+
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = fullClone.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
38
|
+
if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && _typeof(__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === 'object') {
|
|
39
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var MARK = '__rc_react_root__';
|
|
43
|
+
|
|
44
|
+
// ========================== Render ==========================
|
|
45
|
+
|
|
46
|
+
function modernRender(node, container) {
|
|
47
|
+
toggleWarning(true);
|
|
48
|
+
var root = container[MARK] || createRoot(container);
|
|
49
|
+
toggleWarning(false);
|
|
50
|
+
root.render(node);
|
|
51
|
+
container[MARK] = root;
|
|
52
|
+
}
|
|
53
|
+
function legacyRender(node, container) {
|
|
54
|
+
reactRender === null || reactRender === void 0 || reactRender(node, container);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @private Test usage. Not work in prod */
|
|
58
|
+
function _r(node, container) {
|
|
59
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
60
|
+
return legacyRender(node, container);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function render(node, container) {
|
|
64
|
+
if (createRoot) {
|
|
65
|
+
modernRender(node, container);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
legacyRender(node, container);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ========================= Unmount ==========================
|
|
72
|
+
function modernUnmount(_x) {
|
|
73
|
+
return _modernUnmount.apply(this, arguments);
|
|
74
|
+
}
|
|
75
|
+
function _modernUnmount() {
|
|
76
|
+
_modernUnmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(container) {
|
|
77
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
78
|
+
while (1) switch (_context.prev = _context.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
return _context.abrupt("return", Promise.resolve().then(function () {
|
|
81
|
+
var _container$MARK;
|
|
82
|
+
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 || _container$MARK.unmount();
|
|
83
|
+
delete container[MARK];
|
|
84
|
+
}));
|
|
85
|
+
case 1:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee);
|
|
90
|
+
}));
|
|
91
|
+
return _modernUnmount.apply(this, arguments);
|
|
92
|
+
}
|
|
93
|
+
function legacyUnmount(container) {
|
|
94
|
+
unmountComponentAtNode(container);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** @private Test usage. Not work in prod */
|
|
98
|
+
function _u(container) {
|
|
99
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
100
|
+
return legacyUnmount(container);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function unmount(_x2) {
|
|
104
|
+
return _unmount.apply(this, arguments);
|
|
105
|
+
}
|
|
106
|
+
function _unmount() {
|
|
107
|
+
_unmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(container) {
|
|
108
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
109
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
if (!(createRoot !== undefined)) {
|
|
112
|
+
_context2.next = 2;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context2.abrupt("return", modernUnmount(container));
|
|
116
|
+
case 2:
|
|
117
|
+
legacyUnmount(container);
|
|
118
|
+
case 3:
|
|
119
|
+
case "end":
|
|
120
|
+
return _context2.stop();
|
|
121
|
+
}
|
|
122
|
+
}, _callee2);
|
|
123
|
+
}));
|
|
124
|
+
return _unmount.apply(this, arguments);
|
|
125
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
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); }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
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); }
|
|
13
|
+
function composeProps(originProps, patchProps, isAll) {
|
|
14
|
+
var composedProps = _objectSpread(_objectSpread({}, originProps), isAll ? patchProps : {});
|
|
15
|
+
Object.keys(patchProps).forEach(function (key) {
|
|
16
|
+
var func = patchProps[key];
|
|
17
|
+
if (typeof func === 'function') {
|
|
18
|
+
composedProps[key] = function () {
|
|
19
|
+
var _originProps$key;
|
|
20
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
+
args[_key] = arguments[_key];
|
|
22
|
+
}
|
|
23
|
+
func.apply(void 0, args);
|
|
24
|
+
return (_originProps$key = originProps[key]) === null || _originProps$key === void 0 ? void 0 : _originProps$key.call.apply(_originProps$key, [originProps].concat(args));
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return composedProps;
|
|
29
|
+
}
|
|
30
|
+
var _default = exports.default = composeProps;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getScrollBarSize;
|
|
7
|
+
exports.getTargetScrollBarSize = getTargetScrollBarSize;
|
|
8
|
+
var _dynamicCSS = require("./Dom/dynamicCSS");
|
|
9
|
+
/* eslint-disable no-param-reassign */
|
|
10
|
+
|
|
11
|
+
var cached;
|
|
12
|
+
function measureScrollbarSize(ele) {
|
|
13
|
+
var randomId = "rc-scrollbar-measure-".concat(Math.random().toString(36).substring(7));
|
|
14
|
+
var measureEle = document.createElement('div');
|
|
15
|
+
measureEle.id = randomId;
|
|
16
|
+
|
|
17
|
+
// Create Style
|
|
18
|
+
var measureStyle = measureEle.style;
|
|
19
|
+
measureStyle.position = 'absolute';
|
|
20
|
+
measureStyle.left = '0';
|
|
21
|
+
measureStyle.top = '0';
|
|
22
|
+
measureStyle.width = '100px';
|
|
23
|
+
measureStyle.height = '100px';
|
|
24
|
+
measureStyle.overflow = 'scroll';
|
|
25
|
+
|
|
26
|
+
// Clone Style if needed
|
|
27
|
+
var fallbackWidth;
|
|
28
|
+
var fallbackHeight;
|
|
29
|
+
if (ele) {
|
|
30
|
+
var targetStyle = getComputedStyle(ele);
|
|
31
|
+
measureStyle.scrollbarColor = targetStyle.scrollbarColor;
|
|
32
|
+
measureStyle.scrollbarWidth = targetStyle.scrollbarWidth;
|
|
33
|
+
|
|
34
|
+
// Set Webkit style
|
|
35
|
+
var webkitScrollbarStyle = getComputedStyle(ele, '::-webkit-scrollbar');
|
|
36
|
+
var width = parseInt(webkitScrollbarStyle.width, 10);
|
|
37
|
+
var height = parseInt(webkitScrollbarStyle.height, 10);
|
|
38
|
+
|
|
39
|
+
// Try wrap to handle CSP case
|
|
40
|
+
try {
|
|
41
|
+
var widthStyle = width ? "width: ".concat(webkitScrollbarStyle.width, ";") : '';
|
|
42
|
+
var heightStyle = height ? "height: ".concat(webkitScrollbarStyle.height, ";") : '';
|
|
43
|
+
(0, _dynamicCSS.updateCSS)("\n#".concat(randomId, "::-webkit-scrollbar {\n").concat(widthStyle, "\n").concat(heightStyle, "\n}"), randomId);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
// Can't wrap, just log error
|
|
46
|
+
console.error(e);
|
|
47
|
+
|
|
48
|
+
// Get from style directly
|
|
49
|
+
fallbackWidth = width;
|
|
50
|
+
fallbackHeight = height;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
document.body.appendChild(measureEle);
|
|
54
|
+
|
|
55
|
+
// Measure. Get fallback style if provided
|
|
56
|
+
var scrollWidth = ele && fallbackWidth && !isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth;
|
|
57
|
+
var scrollHeight = ele && fallbackHeight && !isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight;
|
|
58
|
+
|
|
59
|
+
// Clean up
|
|
60
|
+
document.body.removeChild(measureEle);
|
|
61
|
+
(0, _dynamicCSS.removeCSS)(randomId);
|
|
62
|
+
return {
|
|
63
|
+
width: scrollWidth,
|
|
64
|
+
height: scrollHeight
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function getScrollBarSize(fresh) {
|
|
68
|
+
if (typeof document === 'undefined') {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
if (fresh || cached === undefined) {
|
|
72
|
+
cached = measureScrollbarSize();
|
|
73
|
+
}
|
|
74
|
+
return cached.width;
|
|
75
|
+
}
|
|
76
|
+
function getTargetScrollBarSize(target) {
|
|
77
|
+
if (typeof document === 'undefined' || !target || !(target instanceof Element)) {
|
|
78
|
+
return {
|
|
79
|
+
width: 0,
|
|
80
|
+
height: 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return measureScrollbarSize(target);
|
|
84
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = useEffect;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
/** As `React.useEffect` but pass origin value in callback and not need care deps length change. */
|
|
12
|
+
function useEffect(callback, deps) {
|
|
13
|
+
var prevRef = React.useRef(deps);
|
|
14
|
+
React.useEffect(function () {
|
|
15
|
+
if (deps.length !== prevRef.current.length || deps.some(function (dep, index) {
|
|
16
|
+
return dep !== prevRef.current[index];
|
|
17
|
+
})) {
|
|
18
|
+
callback(prevRef.current);
|
|
19
|
+
}
|
|
20
|
+
prevRef.current = deps;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
12
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
13
|
+
|
|
14
|
+
function useEvent(callback) {
|
|
15
|
+
var fnRef = React.useRef();
|
|
16
|
+
fnRef.current = callback;
|
|
17
|
+
var memoFn = React.useCallback(function () {
|
|
18
|
+
var _fnRef$current;
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
|
|
23
|
+
}, []);
|
|
24
|
+
return memoFn;
|
|
25
|
+
}
|
|
26
|
+
var _default = exports.default = useEvent;
|