@zohodesk/components 1.2.47 → 1.2.48
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/README.md
CHANGED
|
@@ -32,6 +32,13 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
32
32
|
- TextBoxIcon
|
|
33
33
|
- Tooltip
|
|
34
34
|
|
|
35
|
+
# 1.2.48
|
|
36
|
+
|
|
37
|
+
- **ResizeObserver**
|
|
38
|
+
|
|
39
|
+
- The ResizeObserver PolyFill code has been removed, and a separate copy with the PolyFill included is saved under the filename ResizeObserverWithPolyfill.js
|
|
40
|
+
|
|
41
|
+
|
|
35
42
|
# 1.2.47
|
|
36
43
|
|
|
37
44
|
- **DateTime**
|
|
@@ -1,68 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function getSize(element) {
|
|
9
|
-
let {
|
|
10
|
-
offsetHeight,
|
|
11
|
-
offsetWidth
|
|
12
|
-
} = element; // const { height, width } = element.getBoundingClientRect();
|
|
1
|
+
function getBorderBoxSizeFromEntry(entry) {
|
|
2
|
+
const {
|
|
3
|
+
borderBoxSize
|
|
4
|
+
} = entry;
|
|
5
|
+
return borderBoxSize[0];
|
|
6
|
+
}
|
|
13
7
|
|
|
8
|
+
function getSize(entry) {
|
|
9
|
+
const borderBoxSize = getBorderBoxSizeFromEntry(entry);
|
|
14
10
|
return {
|
|
15
|
-
height:
|
|
16
|
-
width:
|
|
11
|
+
height: borderBoxSize.blockSize,
|
|
12
|
+
width: borderBoxSize.inlineSize
|
|
17
13
|
};
|
|
18
14
|
}
|
|
19
15
|
|
|
20
|
-
function dispatch() {
|
|
21
|
-
let resizeResponsive = new Event('resizeResponsive');
|
|
22
|
-
window.dispatchEvent(resizeResponsive);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!hasResizeObserver) {
|
|
26
|
-
let interval = null;
|
|
27
|
-
window.addEventListener('resize', () => {
|
|
28
|
-
clearTimeout(interval);
|
|
29
|
-
interval = setTimeout(dispatch, 100);
|
|
30
|
-
});
|
|
31
|
-
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
32
|
-
|
|
33
|
-
|
|
34
16
|
export default class ResizeObserverPolyfill {
|
|
35
17
|
constructor(onResize) {
|
|
36
|
-
// method finding
|
|
37
|
-
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
38
|
-
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
39
18
|
this.resizeHandler = this.resizeHandler.bind(this);
|
|
40
|
-
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
41
|
-
this.debounce = this.debounce.bind(this);
|
|
42
19
|
this.onResize = onResize;
|
|
43
20
|
this.targetNode = null;
|
|
44
21
|
this.size = {
|
|
45
22
|
height: 0,
|
|
46
23
|
width: 0
|
|
47
24
|
};
|
|
48
|
-
|
|
49
|
-
if (hasResizeObserver) {
|
|
50
|
-
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
51
|
-
} else {
|
|
52
|
-
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
53
|
-
}
|
|
25
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandler);
|
|
54
26
|
}
|
|
55
27
|
|
|
56
28
|
replaceResizeHandler(onResize) {
|
|
57
29
|
this.onResize = onResize;
|
|
58
30
|
}
|
|
59
31
|
|
|
60
|
-
|
|
61
|
-
|
|
32
|
+
getEntry(entries) {
|
|
33
|
+
return entries[0];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
resizeHandler(entries) {
|
|
37
|
+
if (!this.targetNode || !entries.length) {
|
|
62
38
|
return;
|
|
63
39
|
}
|
|
64
40
|
|
|
65
|
-
const
|
|
41
|
+
const entry = this.getEntry(entries);
|
|
42
|
+
const currentSize = getSize(entry);
|
|
66
43
|
|
|
67
44
|
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
68
45
|
return;
|
|
@@ -73,48 +50,9 @@ export default class ResizeObserverPolyfill {
|
|
|
73
50
|
return true;
|
|
74
51
|
}
|
|
75
52
|
|
|
76
|
-
resizeHandlerDispatch() {
|
|
77
|
-
if (!this.resizeHandler() || hasResizeObserver) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
dispatch();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
debounce() {
|
|
85
|
-
clearTimeout(this.interval);
|
|
86
|
-
this.interval = setTimeout(this.resizeHandler, 100);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
transitionEndHandler(event) {
|
|
90
|
-
if (event.propertyName.indexOf('color') === -1) {
|
|
91
|
-
this.resizeHandlerDispatch();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
addEventListeners(targetNode) {
|
|
96
|
-
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
97
|
-
window.addEventListener('resizeResponsive', this.debounce);
|
|
98
|
-
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
99
|
-
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
removeEventListeners(targetNode) {
|
|
103
|
-
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
104
|
-
window.removeEventListener('resizeResponsive', this.debounce);
|
|
105
|
-
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
106
|
-
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
53
|
observe(targetNode) {
|
|
110
54
|
this.targetNode = targetNode;
|
|
111
|
-
|
|
112
|
-
if (hasResizeObserver) {
|
|
113
|
-
this.resizeObserverInstance.observe(targetNode);
|
|
114
|
-
} else {
|
|
115
|
-
this.addEventListeners(targetNode);
|
|
116
|
-
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
117
|
-
}
|
|
55
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
118
56
|
}
|
|
119
57
|
|
|
120
58
|
replaceObservationElement(targetNode) {
|
|
@@ -124,12 +62,10 @@ export default class ResizeObserverPolyfill {
|
|
|
124
62
|
|
|
125
63
|
this.targetNode && this.disconnect();
|
|
126
64
|
targetNode && this.observe(targetNode);
|
|
127
|
-
targetNode && this.resizeHandlerDispatch();
|
|
128
65
|
}
|
|
129
66
|
|
|
130
67
|
disconnect() {
|
|
131
|
-
this.
|
|
132
|
-
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
68
|
+
this.resizeObserverInstance.disconnect();
|
|
133
69
|
this.targetNode = null;
|
|
134
70
|
this.size = {
|
|
135
71
|
height: 0,
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const hasResizeObserver = !!window.ResizeObserver;
|
|
2
|
+
const mutationObserverOptions = {
|
|
3
|
+
//NOTE: we donot consider child Count
|
|
4
|
+
// childList: true,
|
|
5
|
+
attributes: true
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function getSize(element) {
|
|
9
|
+
let {
|
|
10
|
+
offsetHeight,
|
|
11
|
+
offsetWidth
|
|
12
|
+
} = element; // const { height, width } = element.getBoundingClientRect();
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
height: offsetHeight,
|
|
16
|
+
width: offsetWidth
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function dispatch() {
|
|
21
|
+
let resizeResponsive = new Event('resizeResponsive');
|
|
22
|
+
window.dispatchEvent(resizeResponsive);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!hasResizeObserver) {
|
|
26
|
+
let interval = null;
|
|
27
|
+
window.addEventListener('resize', () => {
|
|
28
|
+
clearTimeout(interval);
|
|
29
|
+
interval = setTimeout(dispatch, 100);
|
|
30
|
+
});
|
|
31
|
+
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export default class ResizeObserverPolyfill {
|
|
35
|
+
constructor(onResize) {
|
|
36
|
+
// method finding
|
|
37
|
+
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
38
|
+
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
39
|
+
this.resizeHandler = this.resizeHandler.bind(this);
|
|
40
|
+
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
41
|
+
this.debounce = this.debounce.bind(this);
|
|
42
|
+
this.onResize = onResize;
|
|
43
|
+
this.targetNode = null;
|
|
44
|
+
this.size = {
|
|
45
|
+
height: 0,
|
|
46
|
+
width: 0
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (hasResizeObserver) {
|
|
50
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
51
|
+
} else {
|
|
52
|
+
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
replaceResizeHandler(onResize) {
|
|
57
|
+
this.onResize = onResize;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
resizeHandler() {
|
|
61
|
+
if (!this.targetNode) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const currentSize = getSize(this.targetNode); // if (this.size && shallowCompare(currentSize, this.size)) {
|
|
66
|
+
|
|
67
|
+
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.size = currentSize;
|
|
72
|
+
this.onResize(this.size, this.targetNode);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
resizeHandlerDispatch() {
|
|
77
|
+
if (!this.resizeHandler() || hasResizeObserver) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
dispatch();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
debounce() {
|
|
85
|
+
clearTimeout(this.interval);
|
|
86
|
+
this.interval = setTimeout(this.resizeHandler, 100);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
transitionEndHandler(event) {
|
|
90
|
+
if (event.propertyName.indexOf('color') === -1) {
|
|
91
|
+
this.resizeHandlerDispatch();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
addEventListeners(targetNode) {
|
|
96
|
+
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
97
|
+
window.addEventListener('resizeResponsive', this.debounce);
|
|
98
|
+
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
99
|
+
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
removeEventListeners(targetNode) {
|
|
103
|
+
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
104
|
+
window.removeEventListener('resizeResponsive', this.debounce);
|
|
105
|
+
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
106
|
+
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
observe(targetNode) {
|
|
110
|
+
this.targetNode = targetNode;
|
|
111
|
+
|
|
112
|
+
if (hasResizeObserver) {
|
|
113
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
114
|
+
} else {
|
|
115
|
+
this.addEventListeners(targetNode);
|
|
116
|
+
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
replaceObservationElement(targetNode) {
|
|
121
|
+
if (this.targetNode === targetNode) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.targetNode && this.disconnect();
|
|
126
|
+
targetNode && this.observe(targetNode);
|
|
127
|
+
targetNode && this.resizeHandlerDispatch();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
disconnect() {
|
|
131
|
+
this.targetNode && this.removeEventListeners(this.targetNode);
|
|
132
|
+
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
133
|
+
this.targetNode = null;
|
|
134
|
+
this.size = {
|
|
135
|
+
height: 0,
|
|
136
|
+
width: 0
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
@@ -11,59 +11,31 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
11
11
|
|
|
12
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
attributes: true
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function getSize(element) {
|
|
22
|
-
var offsetHeight = element.offsetHeight,
|
|
23
|
-
offsetWidth = element.offsetWidth; // const { height, width } = element.getBoundingClientRect();
|
|
14
|
+
function getBorderBoxSizeFromEntry(entry) {
|
|
15
|
+
var borderBoxSize = entry.borderBoxSize;
|
|
16
|
+
return borderBoxSize[0];
|
|
17
|
+
}
|
|
24
18
|
|
|
19
|
+
function getSize(entry) {
|
|
20
|
+
var borderBoxSize = getBorderBoxSizeFromEntry(entry);
|
|
25
21
|
return {
|
|
26
|
-
height:
|
|
27
|
-
width:
|
|
22
|
+
height: borderBoxSize.blockSize,
|
|
23
|
+
width: borderBoxSize.inlineSize
|
|
28
24
|
};
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
function dispatch() {
|
|
32
|
-
var resizeResponsive = new Event('resizeResponsive');
|
|
33
|
-
window.dispatchEvent(resizeResponsive);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!hasResizeObserver) {
|
|
37
|
-
var interval = null;
|
|
38
|
-
window.addEventListener('resize', function () {
|
|
39
|
-
clearTimeout(interval);
|
|
40
|
-
interval = setTimeout(dispatch, 100);
|
|
41
|
-
});
|
|
42
|
-
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
43
|
-
|
|
44
|
-
|
|
45
27
|
var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
46
28
|
function ResizeObserverPolyfill(onResize) {
|
|
47
29
|
_classCallCheck(this, ResizeObserverPolyfill);
|
|
48
30
|
|
|
49
|
-
// method finding
|
|
50
|
-
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
51
|
-
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
52
31
|
this.resizeHandler = this.resizeHandler.bind(this);
|
|
53
|
-
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
54
|
-
this.debounce = this.debounce.bind(this);
|
|
55
32
|
this.onResize = onResize;
|
|
56
33
|
this.targetNode = null;
|
|
57
34
|
this.size = {
|
|
58
35
|
height: 0,
|
|
59
36
|
width: 0
|
|
60
37
|
};
|
|
61
|
-
|
|
62
|
-
if (hasResizeObserver) {
|
|
63
|
-
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
64
|
-
} else {
|
|
65
|
-
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
66
|
-
}
|
|
38
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandler);
|
|
67
39
|
}
|
|
68
40
|
|
|
69
41
|
_createClass(ResizeObserverPolyfill, [{
|
|
@@ -71,14 +43,20 @@ var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
|
71
43
|
value: function replaceResizeHandler(onResize) {
|
|
72
44
|
this.onResize = onResize;
|
|
73
45
|
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "getEntry",
|
|
48
|
+
value: function getEntry(entries) {
|
|
49
|
+
return entries[0];
|
|
50
|
+
}
|
|
74
51
|
}, {
|
|
75
52
|
key: "resizeHandler",
|
|
76
|
-
value: function resizeHandler() {
|
|
77
|
-
if (!this.targetNode) {
|
|
53
|
+
value: function resizeHandler(entries) {
|
|
54
|
+
if (!this.targetNode || !entries.length) {
|
|
78
55
|
return;
|
|
79
56
|
}
|
|
80
57
|
|
|
81
|
-
var
|
|
58
|
+
var entry = this.getEntry(entries);
|
|
59
|
+
var currentSize = getSize(entry);
|
|
82
60
|
|
|
83
61
|
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
84
62
|
return;
|
|
@@ -88,55 +66,11 @@ var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
|
88
66
|
this.onResize(this.size, this.targetNode);
|
|
89
67
|
return true;
|
|
90
68
|
}
|
|
91
|
-
}, {
|
|
92
|
-
key: "resizeHandlerDispatch",
|
|
93
|
-
value: function resizeHandlerDispatch() {
|
|
94
|
-
if (!this.resizeHandler() || hasResizeObserver) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
dispatch();
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "debounce",
|
|
102
|
-
value: function debounce() {
|
|
103
|
-
clearTimeout(this.interval);
|
|
104
|
-
this.interval = setTimeout(this.resizeHandler, 100);
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "transitionEndHandler",
|
|
108
|
-
value: function transitionEndHandler(event) {
|
|
109
|
-
if (event.propertyName.indexOf('color') === -1) {
|
|
110
|
-
this.resizeHandlerDispatch();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "addEventListeners",
|
|
115
|
-
value: function addEventListeners(targetNode) {
|
|
116
|
-
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
117
|
-
window.addEventListener('resizeResponsive', this.debounce);
|
|
118
|
-
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
119
|
-
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: "removeEventListeners",
|
|
123
|
-
value: function removeEventListeners(targetNode) {
|
|
124
|
-
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
125
|
-
window.removeEventListener('resizeResponsive', this.debounce);
|
|
126
|
-
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
127
|
-
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
128
|
-
}
|
|
129
69
|
}, {
|
|
130
70
|
key: "observe",
|
|
131
71
|
value: function observe(targetNode) {
|
|
132
72
|
this.targetNode = targetNode;
|
|
133
|
-
|
|
134
|
-
if (hasResizeObserver) {
|
|
135
|
-
this.resizeObserverInstance.observe(targetNode);
|
|
136
|
-
} else {
|
|
137
|
-
this.addEventListeners(targetNode);
|
|
138
|
-
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
139
|
-
}
|
|
73
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
140
74
|
}
|
|
141
75
|
}, {
|
|
142
76
|
key: "replaceObservationElement",
|
|
@@ -147,13 +81,11 @@ var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
|
147
81
|
|
|
148
82
|
this.targetNode && this.disconnect();
|
|
149
83
|
targetNode && this.observe(targetNode);
|
|
150
|
-
targetNode && this.resizeHandlerDispatch();
|
|
151
84
|
}
|
|
152
85
|
}, {
|
|
153
86
|
key: "disconnect",
|
|
154
87
|
value: function disconnect() {
|
|
155
|
-
this.
|
|
156
|
-
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
88
|
+
this.resizeObserverInstance.disconnect();
|
|
157
89
|
this.targetNode = null;
|
|
158
90
|
this.size = {
|
|
159
91
|
height: 0,
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
|
|
10
|
+
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, descriptor.key, descriptor); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
|
|
14
|
+
var hasResizeObserver = !!window.ResizeObserver;
|
|
15
|
+
var mutationObserverOptions = {
|
|
16
|
+
//NOTE: we donot consider child Count
|
|
17
|
+
// childList: true,
|
|
18
|
+
attributes: true
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function getSize(element) {
|
|
22
|
+
var offsetHeight = element.offsetHeight,
|
|
23
|
+
offsetWidth = element.offsetWidth; // const { height, width } = element.getBoundingClientRect();
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
height: offsetHeight,
|
|
27
|
+
width: offsetWidth
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function dispatch() {
|
|
32
|
+
var resizeResponsive = new Event('resizeResponsive');
|
|
33
|
+
window.dispatchEvent(resizeResponsive);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!hasResizeObserver) {
|
|
37
|
+
var interval = null;
|
|
38
|
+
window.addEventListener('resize', function () {
|
|
39
|
+
clearTimeout(interval);
|
|
40
|
+
interval = setTimeout(dispatch, 100);
|
|
41
|
+
});
|
|
42
|
+
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
46
|
+
function ResizeObserverPolyfill(onResize) {
|
|
47
|
+
_classCallCheck(this, ResizeObserverPolyfill);
|
|
48
|
+
|
|
49
|
+
// method finding
|
|
50
|
+
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
51
|
+
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
52
|
+
this.resizeHandler = this.resizeHandler.bind(this);
|
|
53
|
+
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
54
|
+
this.debounce = this.debounce.bind(this);
|
|
55
|
+
this.onResize = onResize;
|
|
56
|
+
this.targetNode = null;
|
|
57
|
+
this.size = {
|
|
58
|
+
height: 0,
|
|
59
|
+
width: 0
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (hasResizeObserver) {
|
|
63
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
64
|
+
} else {
|
|
65
|
+
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_createClass(ResizeObserverPolyfill, [{
|
|
70
|
+
key: "replaceResizeHandler",
|
|
71
|
+
value: function replaceResizeHandler(onResize) {
|
|
72
|
+
this.onResize = onResize;
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "resizeHandler",
|
|
76
|
+
value: function resizeHandler() {
|
|
77
|
+
if (!this.targetNode) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var currentSize = getSize(this.targetNode); // if (this.size && shallowCompare(currentSize, this.size)) {
|
|
82
|
+
|
|
83
|
+
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.size = currentSize;
|
|
88
|
+
this.onResize(this.size, this.targetNode);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "resizeHandlerDispatch",
|
|
93
|
+
value: function resizeHandlerDispatch() {
|
|
94
|
+
if (!this.resizeHandler() || hasResizeObserver) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
dispatch();
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "debounce",
|
|
102
|
+
value: function debounce() {
|
|
103
|
+
clearTimeout(this.interval);
|
|
104
|
+
this.interval = setTimeout(this.resizeHandler, 100);
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "transitionEndHandler",
|
|
108
|
+
value: function transitionEndHandler(event) {
|
|
109
|
+
if (event.propertyName.indexOf('color') === -1) {
|
|
110
|
+
this.resizeHandlerDispatch();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "addEventListeners",
|
|
115
|
+
value: function addEventListeners(targetNode) {
|
|
116
|
+
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
117
|
+
window.addEventListener('resizeResponsive', this.debounce);
|
|
118
|
+
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
119
|
+
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "removeEventListeners",
|
|
123
|
+
value: function removeEventListeners(targetNode) {
|
|
124
|
+
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
125
|
+
window.removeEventListener('resizeResponsive', this.debounce);
|
|
126
|
+
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
127
|
+
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "observe",
|
|
131
|
+
value: function observe(targetNode) {
|
|
132
|
+
this.targetNode = targetNode;
|
|
133
|
+
|
|
134
|
+
if (hasResizeObserver) {
|
|
135
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
136
|
+
} else {
|
|
137
|
+
this.addEventListeners(targetNode);
|
|
138
|
+
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "replaceObservationElement",
|
|
143
|
+
value: function replaceObservationElement(targetNode) {
|
|
144
|
+
if (this.targetNode === targetNode) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.targetNode && this.disconnect();
|
|
149
|
+
targetNode && this.observe(targetNode);
|
|
150
|
+
targetNode && this.resizeHandlerDispatch();
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "disconnect",
|
|
154
|
+
value: function disconnect() {
|
|
155
|
+
this.targetNode && this.removeEventListeners(this.targetNode);
|
|
156
|
+
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
157
|
+
this.targetNode = null;
|
|
158
|
+
this.size = {
|
|
159
|
+
height: 0,
|
|
160
|
+
width: 0
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}]);
|
|
164
|
+
|
|
165
|
+
return ResizeObserverPolyfill;
|
|
166
|
+
}();
|
|
167
|
+
|
|
168
|
+
exports["default"] = ResizeObserverPolyfill;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.48",
|
|
4
4
|
"main": "es/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"@zohodesk/a11y": "2.2.6",
|
|
72
72
|
"@zohodesk/docstool": "1.0.0-alpha-2",
|
|
73
73
|
"@zohodesk/hooks": "2.0.5",
|
|
74
|
-
"@zohodesk/icons": "1.0.
|
|
75
|
-
"@zohodesk/svg": "1.1.
|
|
74
|
+
"@zohodesk/icons": "1.0.63",
|
|
75
|
+
"@zohodesk/svg": "1.1.22",
|
|
76
76
|
"@zohodesk/utils": "1.3.14",
|
|
77
77
|
"@zohodesk/variables": "1.0.0",
|
|
78
78
|
"@zohodesk/virtualizer": "1.0.3",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"selectn": "1.1.2"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"@zohodesk/icons": "1.0.
|
|
89
|
+
"@zohodesk/icons": "1.0.63",
|
|
90
90
|
"@zohodesk/variables": "1.0.0",
|
|
91
|
-
"@zohodesk/svg": "1.1.
|
|
91
|
+
"@zohodesk/svg": "1.1.22",
|
|
92
92
|
"@zohodesk/virtualizer": "1.0.3",
|
|
93
93
|
"velocity-react": "1.4.3",
|
|
94
94
|
"react-sortable-hoc": "^0.8.3",
|