@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.
Files changed (159) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +303 -0
  3. package/es/Children/toArray.d.ts +5 -0
  4. package/es/Children/toArray.js +19 -0
  5. package/es/Dom/canUseDom.d.ts +1 -0
  6. package/es/Dom/canUseDom.js +3 -0
  7. package/es/Dom/contains.d.ts +1 -0
  8. package/es/Dom/contains.js +20 -0
  9. package/es/Dom/dynamicCSS.d.ts +25 -0
  10. package/es/Dom/dynamicCSS.js +153 -0
  11. package/es/Dom/findDOMNode.d.ts +12 -0
  12. package/es/Dom/findDOMNode.js +36 -0
  13. package/es/Dom/focus.d.ts +8 -0
  14. package/es/Dom/focus.js +87 -0
  15. package/es/Dom/isVisible.d.ts +2 -0
  16. package/es/Dom/isVisible.js +27 -0
  17. package/es/Dom/scrollLocker.d.ts +12 -0
  18. package/es/Dom/scrollLocker.js +135 -0
  19. package/es/Dom/shadow.d.ts +8 -0
  20. package/es/Dom/shadow.js +18 -0
  21. package/es/Dom/styleChecker.d.ts +2 -0
  22. package/es/Dom/styleChecker.js +26 -0
  23. package/es/KeyCode.d.ts +436 -0
  24. package/es/KeyCode.js +538 -0
  25. package/es/Portal.d.ts +9 -0
  26. package/es/Portal.js +44 -0
  27. package/es/PortalWrapper.d.ts +51 -0
  28. package/es/PortalWrapper.js +217 -0
  29. package/es/React/isFragment.d.ts +4 -0
  30. package/es/React/isFragment.js +18 -0
  31. package/es/React/render.d.ts +13 -0
  32. package/es/React/render.js +114 -0
  33. package/es/composeProps.d.ts +2 -0
  34. package/es/composeProps.js +24 -0
  35. package/es/getScrollBarSize.d.ts +7 -0
  36. package/es/getScrollBarSize.js +76 -0
  37. package/es/hooks/useEffect.d.ts +2 -0
  38. package/es/hooks/useEffect.js +14 -0
  39. package/es/hooks/useEvent.d.ts +2 -0
  40. package/es/hooks/useEvent.js +16 -0
  41. package/es/hooks/useId.d.ts +4 -0
  42. package/es/hooks/useId.js +69 -0
  43. package/es/hooks/useLayoutEffect.d.ts +4 -0
  44. package/es/hooks/useLayoutEffect.js +30 -0
  45. package/es/hooks/useMemo.d.ts +1 -0
  46. package/es/hooks/useMemo.js +9 -0
  47. package/es/hooks/useMergedState.d.ts +12 -0
  48. package/es/hooks/useMergedState.js +68 -0
  49. package/es/hooks/useMobile.d.ts +6 -0
  50. package/es/hooks/useMobile.js +25 -0
  51. package/es/hooks/useState.d.ts +14 -0
  52. package/es/hooks/useState.js +32 -0
  53. package/es/hooks/useSyncState.d.ts +9 -0
  54. package/es/hooks/useSyncState.js +29 -0
  55. package/es/index.d.ts +6 -0
  56. package/es/index.js +6 -0
  57. package/es/isEqual.d.ts +9 -0
  58. package/es/isEqual.js +55 -0
  59. package/es/isMobile.d.ts +2 -0
  60. package/es/isMobile.js +7 -0
  61. package/es/omit.d.ts +1 -0
  62. package/es/omit.js +9 -0
  63. package/es/pickAttrs.d.ts +11 -0
  64. package/es/pickAttrs.js +51 -0
  65. package/es/proxyObject.d.ts +4 -0
  66. package/es/proxyObject.js +19 -0
  67. package/es/raf.d.ts +6 -0
  68. package/es/raf.js +54 -0
  69. package/es/ref.d.ts +19 -0
  70. package/es/ref.js +89 -0
  71. package/es/setStyle.d.ts +12 -0
  72. package/es/setStyle.js +26 -0
  73. package/es/test/domHook.d.ts +8 -0
  74. package/es/test/domHook.js +64 -0
  75. package/es/utils/get.d.ts +1 -0
  76. package/es/utils/get.js +10 -0
  77. package/es/utils/set.d.ts +6 -0
  78. package/es/utils/set.js +93 -0
  79. package/es/warning.d.ts +32 -0
  80. package/es/warning.js +68 -0
  81. package/lib/Children/toArray.d.ts +5 -0
  82. package/lib/Children/toArray.js +26 -0
  83. package/lib/Dom/canUseDom.d.ts +1 -0
  84. package/lib/Dom/canUseDom.js +9 -0
  85. package/lib/Dom/contains.d.ts +1 -0
  86. package/lib/Dom/contains.js +26 -0
  87. package/lib/Dom/dynamicCSS.d.ts +25 -0
  88. package/lib/Dom/dynamicCSS.js +163 -0
  89. package/lib/Dom/findDOMNode.d.ts +12 -0
  90. package/lib/Dom/findDOMNode.js +45 -0
  91. package/lib/Dom/focus.d.ts +8 -0
  92. package/lib/Dom/focus.js +98 -0
  93. package/lib/Dom/isVisible.d.ts +2 -0
  94. package/lib/Dom/isVisible.js +33 -0
  95. package/lib/Dom/scrollLocker.d.ts +12 -0
  96. package/lib/Dom/scrollLocker.js +141 -0
  97. package/lib/Dom/shadow.d.ts +8 -0
  98. package/lib/Dom/shadow.js +25 -0
  99. package/lib/Dom/styleChecker.d.ts +2 -0
  100. package/lib/Dom/styleChecker.js +33 -0
  101. package/lib/KeyCode.d.ts +436 -0
  102. package/lib/KeyCode.js +544 -0
  103. package/lib/Portal.d.ts +9 -0
  104. package/lib/Portal.js +51 -0
  105. package/lib/PortalWrapper.d.ts +51 -0
  106. package/lib/PortalWrapper.js +226 -0
  107. package/lib/React/isFragment.d.ts +4 -0
  108. package/lib/React/isFragment.js +24 -0
  109. package/lib/React/render.d.ts +13 -0
  110. package/lib/React/render.js +125 -0
  111. package/lib/composeProps.d.ts +2 -0
  112. package/lib/composeProps.js +30 -0
  113. package/lib/getScrollBarSize.d.ts +7 -0
  114. package/lib/getScrollBarSize.js +84 -0
  115. package/lib/hooks/useEffect.d.ts +2 -0
  116. package/lib/hooks/useEffect.js +22 -0
  117. package/lib/hooks/useEvent.d.ts +2 -0
  118. package/lib/hooks/useEvent.js +26 -0
  119. package/lib/hooks/useId.d.ts +4 -0
  120. package/lib/hooks/useId.js +78 -0
  121. package/lib/hooks/useLayoutEffect.d.ts +4 -0
  122. package/lib/hooks/useLayoutEffect.js +39 -0
  123. package/lib/hooks/useMemo.d.ts +1 -0
  124. package/lib/hooks/useMemo.js +18 -0
  125. package/lib/hooks/useMergedState.d.ts +12 -0
  126. package/lib/hooks/useMergedState.js +75 -0
  127. package/lib/hooks/useMobile.d.ts +6 -0
  128. package/lib/hooks/useMobile.js +31 -0
  129. package/lib/hooks/useState.d.ts +14 -0
  130. package/lib/hooks/useState.js +41 -0
  131. package/lib/hooks/useSyncState.d.ts +9 -0
  132. package/lib/hooks/useSyncState.js +39 -0
  133. package/lib/index.d.ts +6 -0
  134. package/lib/index.js +60 -0
  135. package/lib/isEqual.d.ts +9 -0
  136. package/lib/isEqual.js +61 -0
  137. package/lib/isMobile.d.ts +2 -0
  138. package/lib/isMobile.js +13 -0
  139. package/lib/omit.d.ts +1 -0
  140. package/lib/omit.js +15 -0
  141. package/lib/pickAttrs.d.ts +11 -0
  142. package/lib/pickAttrs.js +57 -0
  143. package/lib/proxyObject.d.ts +4 -0
  144. package/lib/proxyObject.js +25 -0
  145. package/lib/raf.d.ts +6 -0
  146. package/lib/raf.js +60 -0
  147. package/lib/ref.d.ts +19 -0
  148. package/lib/ref.js +96 -0
  149. package/lib/setStyle.d.ts +12 -0
  150. package/lib/setStyle.js +32 -0
  151. package/lib/test/domHook.d.ts +8 -0
  152. package/lib/test/domHook.js +71 -0
  153. package/lib/utils/get.d.ts +1 -0
  154. package/lib/utils/get.js +16 -0
  155. package/lib/utils/set.d.ts +6 -0
  156. package/lib/utils/set.js +101 -0
  157. package/lib/warning.d.ts +32 -0
  158. package/lib/warning.js +81 -0
  159. package/package.json +76 -0
@@ -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,2 @@
1
+ declare const _default: (element: Element) => boolean;
2
+ export default _default;
@@ -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,8 @@
1
+ /**
2
+ * Check if is in shadowRoot
3
+ */
4
+ export declare function inShadow(ele: Node): boolean;
5
+ /**
6
+ * Return shadowRoot if possible
7
+ */
8
+ export declare function getShadowRoot(ele: Node): ShadowRoot;
@@ -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,2 @@
1
+ export declare function isStyleSupport(styleName: string | string[]): boolean;
2
+ export declare function isStyleSupport(styleName: string, styleValue: any): boolean;
@@ -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
+ }