@zohodesk/components 1.4.6 → 1.4.8
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/.cli/propValidation_report.html +1 -1
- package/README.md +13 -2
- package/es/Accordion/Accordion.js +1 -1
- package/es/Card/Card.js +48 -14
- package/es/Card/__tests__/Card.spec.js +81 -2
- package/es/Card/__tests__/__snapshots__/Card.spec.js.snap +44 -0
- package/es/Card/props/defaultProps.js +2 -1
- package/es/Card/props/propTypes.js +2 -1
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +7 -0
- package/es/MultiSelect/MultiSelect.js +1 -1
- package/es/Popup/Popup.js +45 -17
- package/es/Popup/Registry.js +1 -0
- package/es/Select/Select.js +1 -1
- package/es/Select/__tests__/Select.spec.js +8 -1
- package/es/common/basic.module.css +0 -2
- package/es/components_layer.module.css +1 -0
- package/es/css.js +4 -4
- package/es/v1/Popup/Popup.js +1 -1
- package/es/v1/Select/Select.js +1 -1
- package/lib/Accordion/Accordion.js +2 -2
- package/lib/Card/Card.js +64 -30
- package/lib/Card/__tests__/Card.spec.js +118 -1
- package/lib/Card/__tests__/__snapshots__/Card.spec.js.snap +44 -0
- package/lib/Card/props/defaultProps.js +2 -1
- package/lib/Card/props/propTypes.js +2 -1
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +7 -0
- package/lib/MultiSelect/MultiSelect.js +2 -2
- package/lib/Popup/Popup.js +54 -18
- package/lib/Popup/Registry.js +1 -0
- package/lib/Select/Select.js +2 -2
- package/lib/Select/__tests__/Select.spec.js +8 -1
- package/lib/common/basic.module.css +0 -2
- package/lib/components_layer.module.css +1 -0
- package/lib/css.js +4 -4
- package/lib/v1/Popup/Popup.js +2 -2
- package/lib/v1/Select/Select.js +2 -2
- package/package.json +21 -13
- package/css_error.log +0 -1
- package/install.md +0 -10
- package/postPublish.js +0 -8
- package/prePublish.js +0 -70
- package/react-cli.config.js +0 -24
- package/result.json +0 -1
- /package/.cli/{stringContains.js → themeValidate/stringContains.js} +0 -0
package/README.md
CHANGED
|
@@ -2,11 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
|
|
4
4
|
|
|
5
|
-
# 1.4.
|
|
5
|
+
# 1.4.8
|
|
6
|
+
|
|
7
|
+
- Added UNSAFE_ prefix to deprecated lifecycle methods: componentWillMount, componentWillReceiveProps, and componentWillUpdate.
|
|
6
8
|
|
|
7
9
|
- **Popup**
|
|
8
|
-
-
|
|
10
|
+
- Handled potential memory leaks by `event listeners`.
|
|
11
|
+
- Added unmount handling for `requestAnimationFrame` to ensure proper cleanup.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 1.4.7
|
|
15
|
+
|
|
16
|
+
- **Card** - Added support for reverse infinite scroll with `isRecentOnBottom`.
|
|
17
|
+
|
|
18
|
+
# 1.4.6
|
|
9
19
|
|
|
20
|
+
- **Popup** - Added fixed popup scroll block behavior support to iframe elements (same-origin only).
|
|
10
21
|
|
|
11
22
|
# 1.4.5
|
|
12
23
|
|
|
@@ -25,7 +25,7 @@ export default class Accordion extends React.Component {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
29
29
|
if (this.props.selectedItem !== nextProps.selectedItem && !this.props.disableInternalState) {
|
|
30
30
|
this.setState({
|
|
31
31
|
selectedItem: nextProps.selectedItem
|
package/es/Card/Card.js
CHANGED
|
@@ -96,11 +96,13 @@ export default class Card extends Component {
|
|
|
96
96
|
this.to = from + 3 * limit;
|
|
97
97
|
this.isFetching = false;
|
|
98
98
|
this.lastScrollTop = 0;
|
|
99
|
-
this.onScroll = this.onScroll.bind(this);
|
|
99
|
+
this.onScroll = this.onScroll.bind(this);
|
|
100
|
+
this.setScrollRef = this.setScrollRef.bind(this);
|
|
101
|
+
this.childEleRef = null; //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
|
|
100
102
|
//this.onClearScroll = debounce(this.setScroll.bind(this, false), 500);
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
104
106
|
if (this.from !== nextProps.from) {
|
|
105
107
|
this.from = nextProps.from;
|
|
106
108
|
}
|
|
@@ -127,25 +129,36 @@ export default class Card extends Component {
|
|
|
127
129
|
scrollAt,
|
|
128
130
|
noNeedUpScroll,
|
|
129
131
|
// isScrollShadow,
|
|
130
|
-
isPercentageScroll
|
|
132
|
+
isPercentageScroll,
|
|
133
|
+
scrollDirection
|
|
131
134
|
} = this.props;
|
|
135
|
+
const scrollLimitHeight = scrollHeight - scrollAt;
|
|
136
|
+
const currentVisibleBottom = scrollTop + offsetHeight;
|
|
132
137
|
|
|
133
138
|
if (scrollTop > this.lastScrollTop) {
|
|
134
|
-
this.
|
|
139
|
+
this.scrollingDirection = 'down';
|
|
135
140
|
} else {
|
|
136
|
-
this.
|
|
141
|
+
this.scrollingDirection = 'up';
|
|
137
142
|
}
|
|
138
143
|
|
|
139
144
|
this.lastScrollTop = scrollTop;
|
|
140
145
|
|
|
141
146
|
if (fetchData && !this.isFetching) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
const fetchDirection = scrollDirection === 'bottomToTop' ? 'up' : 'down';
|
|
148
|
+
|
|
149
|
+
if (this.scrollingDirection === fetchDirection && !noMoreData) {
|
|
150
|
+
let prefetch = false;
|
|
151
|
+
|
|
152
|
+
if (isPercentageScroll) {
|
|
153
|
+
const scrollingPercentage = scrollDirection === 'bottomToTop' ? (scrollHeight - scrollTop) / scrollLimitHeight * 100 : currentVisibleBottom / scrollLimitHeight * 100;
|
|
154
|
+
prefetch = scrollingPercentage >= getLibraryConfig('scrollFetchLimit');
|
|
155
|
+
} else {
|
|
156
|
+
prefetch = scrollDirection === 'bottomToTop' ? scrollTop <= scrollAt : scrollLimitHeight <= currentVisibleBottom;
|
|
157
|
+
}
|
|
145
158
|
|
|
146
159
|
if (prefetch) {
|
|
147
160
|
this.isFetching = true;
|
|
148
|
-
fetchData(this.from + this.limit, this.limit + this.to, this.
|
|
161
|
+
fetchData(this.from + this.limit, this.limit + this.to, this.scrollingDirection).then(() => {
|
|
149
162
|
this.to = this.limit + this.to;
|
|
150
163
|
this.isFetching = false;
|
|
151
164
|
}, () => {
|
|
@@ -153,9 +166,11 @@ export default class Card extends Component {
|
|
|
153
166
|
});
|
|
154
167
|
}
|
|
155
168
|
} else {
|
|
156
|
-
|
|
169
|
+
const prefetch = scrollDirection === 'bottomToTop' ? scrollLimitHeight <= currentVisibleBottom : 0 >= scrollTop - scrollAt;
|
|
170
|
+
|
|
171
|
+
if (prefetch && this.from !== 0 && !noNeedUpScroll) {
|
|
157
172
|
this.isFetching = true;
|
|
158
|
-
fetchData(this.from - this.limit, this.to - this.limit, this.
|
|
173
|
+
fetchData(this.from - this.limit, this.to - this.limit, this.scrollingDirection).then(() => {
|
|
159
174
|
this.to = this.to - this.limit;
|
|
160
175
|
this.isFetching = false;
|
|
161
176
|
}, () => {
|
|
@@ -166,9 +181,12 @@ export default class Card extends Component {
|
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
if (fetchData && !noNeedUpScroll) {
|
|
169
|
-
|
|
184
|
+
const topFetch = scrollDirection === 'bottomToTop' ? !noMoreData : !noNeedUpScroll && this.from !== 0;
|
|
185
|
+
const bottomFetch = scrollDirection === 'bottomToTop' ? !noNeedUpScroll && this.from !== 0 : !noMoreData;
|
|
186
|
+
|
|
187
|
+
if (scrollTop === 0 && topFetch) {
|
|
170
188
|
scrollContainerObj.scrollTop = scrollTop + offsetHeight / 3;
|
|
171
|
-
} else if (scrollHeight ===
|
|
189
|
+
} else if (scrollHeight === currentVisibleBottom && bottomFetch) {
|
|
172
190
|
scrollContainerObj.scrollTop = scrollTop - offsetHeight / 2;
|
|
173
191
|
}
|
|
174
192
|
} // if (isScrollShadow) {
|
|
@@ -187,6 +205,21 @@ export default class Card extends Component {
|
|
|
187
205
|
// }
|
|
188
206
|
|
|
189
207
|
|
|
208
|
+
setScrollRef(el) {
|
|
209
|
+
const {
|
|
210
|
+
scrollAt,
|
|
211
|
+
scrollDirection
|
|
212
|
+
} = this.props;
|
|
213
|
+
|
|
214
|
+
if (el && scrollDirection === 'bottomToTop') {
|
|
215
|
+
requestAnimationFrame(() => {
|
|
216
|
+
el.scrollTop = el.scrollHeight + Number(scrollAt);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.childEleRef && this.childEleRef(el);
|
|
221
|
+
}
|
|
222
|
+
|
|
190
223
|
render() {
|
|
191
224
|
let {
|
|
192
225
|
onClick,
|
|
@@ -220,6 +253,7 @@ export default class Card extends Component {
|
|
|
220
253
|
isScroll
|
|
221
254
|
});
|
|
222
255
|
} else if (child.type === CardContent || this.props.childTypes && child.type === this.props.childTypes.cardContent) {
|
|
256
|
+
this.childEleRef = child.props.eleRef;
|
|
223
257
|
return /*#__PURE__*/React.createElement(Box, {
|
|
224
258
|
id: htmlId,
|
|
225
259
|
role: role,
|
|
@@ -227,7 +261,7 @@ export default class Card extends Component {
|
|
|
227
261
|
scroll: child.props.scroll,
|
|
228
262
|
preventParentScroll: child.props.preventParentScroll,
|
|
229
263
|
onScroll: this.onScroll,
|
|
230
|
-
eleRef:
|
|
264
|
+
eleRef: this.setScrollRef,
|
|
231
265
|
isScrollAttribute: child.props.isScrollAttribute,
|
|
232
266
|
dataId: child.props.dataId,
|
|
233
267
|
shrink: child.props.shrink,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import Card from "../Card";
|
|
2
|
+
import { render, fireEvent, within, waitFor } from '@testing-library/react';
|
|
3
|
+
import Card, { CardContent } from "../Card";
|
|
4
4
|
describe('Card', () => {
|
|
5
5
|
test('rendering the defult props', () => {
|
|
6
6
|
const {
|
|
@@ -8,4 +8,83 @@ describe('Card', () => {
|
|
|
8
8
|
} = render( /*#__PURE__*/React.createElement(Card, null));
|
|
9
9
|
expect(asFragment()).toMatchSnapshot();
|
|
10
10
|
});
|
|
11
|
+
test('should trigger fetch, when scroll to the bottom of the card while isRecentOnBottom = false', async () => {
|
|
12
|
+
const mockGetNextOptions = jest.fn(() => {
|
|
13
|
+
return new Promise(resolve => {
|
|
14
|
+
resolve();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
const {
|
|
18
|
+
getByTestId,
|
|
19
|
+
asFragment
|
|
20
|
+
} = render( /*#__PURE__*/React.createElement(Card, {
|
|
21
|
+
from: 0,
|
|
22
|
+
limit: 10,
|
|
23
|
+
fetchData: mockGetNextOptions
|
|
24
|
+
}, /*#__PURE__*/React.createElement(CardContent, {
|
|
25
|
+
dataId: "scrollToBottomCardContent"
|
|
26
|
+
}, /*#__PURE__*/React.createElement("div", null, "Hello Zam"))));
|
|
27
|
+
const cardContent = getByTestId('scrollToBottomCardContent');
|
|
28
|
+
Object.defineProperty(cardContent, 'scrollHeight', {
|
|
29
|
+
value: 1000,
|
|
30
|
+
writable: true
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(cardContent, 'clientHeight', {
|
|
33
|
+
value: 600,
|
|
34
|
+
writable: true
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(cardContent, 'offsetHeight', {
|
|
37
|
+
value: 600,
|
|
38
|
+
writable: true
|
|
39
|
+
});
|
|
40
|
+
fireEvent.scroll(cardContent, {
|
|
41
|
+
target: {
|
|
42
|
+
scrollTop: 401
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
await waitFor(() => {
|
|
46
|
+
expect(asFragment()).toMatchSnapshot();
|
|
47
|
+
expect(mockGetNextOptions).toHaveBeenCalledWith(10, 40, 'down');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
test('should trigger fetch, when scroll to the top of the card while scrollDirection = bottomToTop', async () => {
|
|
51
|
+
const mockGetNextOptions = jest.fn(() => {
|
|
52
|
+
return new Promise(resolve => {
|
|
53
|
+
resolve();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
const {
|
|
57
|
+
getByTestId,
|
|
58
|
+
asFragment
|
|
59
|
+
} = render( /*#__PURE__*/React.createElement(Card, {
|
|
60
|
+
from: 0,
|
|
61
|
+
limit: 10,
|
|
62
|
+
scrollDirection: "bottomToTop",
|
|
63
|
+
fetchData: mockGetNextOptions
|
|
64
|
+
}, /*#__PURE__*/React.createElement(CardContent, {
|
|
65
|
+
dataId: "scrollToTopCardContent"
|
|
66
|
+
}, /*#__PURE__*/React.createElement("div", null, "Hello Zam"))));
|
|
67
|
+
const cardContent = getByTestId('scrollToTopCardContent');
|
|
68
|
+
Object.defineProperty(cardContent, 'scrollHeight', {
|
|
69
|
+
value: 1000,
|
|
70
|
+
writable: true
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(cardContent, 'clientHeight', {
|
|
73
|
+
value: 600,
|
|
74
|
+
writable: true
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(cardContent, 'offsetHeight', {
|
|
77
|
+
value: 600,
|
|
78
|
+
writable: true
|
|
79
|
+
});
|
|
80
|
+
fireEvent.scroll(cardContent, {
|
|
81
|
+
target: {
|
|
82
|
+
scrollTop: 0
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
await waitFor(() => {
|
|
86
|
+
expect(asFragment()).toMatchSnapshot();
|
|
87
|
+
expect(mockGetNextOptions).toHaveBeenCalledWith(10, 40, 'up');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
11
90
|
});
|
|
@@ -10,3 +10,47 @@ exports[`Card rendering the defult props 1`] = `
|
|
|
10
10
|
/>
|
|
11
11
|
</DocumentFragment>
|
|
12
12
|
`;
|
|
13
|
+
|
|
14
|
+
exports[`Card should trigger fetch, when scroll to the bottom of the card while isRecentOnBottom = false 1`] = `
|
|
15
|
+
<DocumentFragment>
|
|
16
|
+
<div
|
|
17
|
+
class="flex cover coldir"
|
|
18
|
+
data-id="containerComponent"
|
|
19
|
+
data-selector-id="container"
|
|
20
|
+
data-test-id="containerComponent"
|
|
21
|
+
>
|
|
22
|
+
<div
|
|
23
|
+
class="grow basis shrinkOff scrolly"
|
|
24
|
+
data-id="scrollToBottomCardContent"
|
|
25
|
+
data-selector-id="cardContent"
|
|
26
|
+
data-test-id="scrollToBottomCardContent"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Hello Zam
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
exports[`Card should trigger fetch, when scroll to the top of the card while scrollDirection = bottomToTop 1`] = `
|
|
37
|
+
<DocumentFragment>
|
|
38
|
+
<div
|
|
39
|
+
class="flex cover coldir"
|
|
40
|
+
data-id="containerComponent"
|
|
41
|
+
data-selector-id="container"
|
|
42
|
+
data-test-id="containerComponent"
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
class="grow basis shrinkOff scrolly"
|
|
46
|
+
data-id="scrollToTopCardContent"
|
|
47
|
+
data-selector-id="cardContent"
|
|
48
|
+
data-test-id="scrollToTopCardContent"
|
|
49
|
+
>
|
|
50
|
+
<div>
|
|
51
|
+
Hello Zam
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</DocumentFragment>
|
|
56
|
+
`;
|
|
@@ -38,7 +38,8 @@ export const Card_propTypes = {
|
|
|
38
38
|
role: PropTypes.string
|
|
39
39
|
}),
|
|
40
40
|
isPercentageScroll: PropTypes.bool,
|
|
41
|
-
eleRef: PropTypes.func
|
|
41
|
+
eleRef: PropTypes.func,
|
|
42
|
+
scrollDirection: PropTypes.oneOf(['topToBottom', 'bottomToTop'])
|
|
42
43
|
};
|
|
43
44
|
export const CardFooter_propTypes = {
|
|
44
45
|
children: PropTypes.node,
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
box-shadow: var(--dropbox_box_shadow);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
.defaultPalette,
|
|
22
|
+
.darkPalette {
|
|
23
|
+
/*css:theme-validation:ignore*/
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
.defaultPalette, .darkPalette {
|
|
22
27
|
background-color: var(--dropbox_bg_color);
|
|
23
28
|
}
|
|
@@ -207,6 +212,7 @@
|
|
|
207
212
|
height: var(--zd_size10) ;
|
|
208
213
|
width: var(--zd_size10) ;
|
|
209
214
|
box-shadow: 1px -1px 2px 0 var(--dropbox_arrow_box_shadow_color);
|
|
215
|
+
/*css:theme-validation:ignore*/
|
|
210
216
|
background-color: var(--dropbox_bg_color);
|
|
211
217
|
-webkit-transform: rotateZ(-45deg);
|
|
212
218
|
transform: rotateZ(-45deg);
|
|
@@ -419,6 +425,7 @@
|
|
|
419
425
|
.closeBar {
|
|
420
426
|
/* Variable:Ignore */
|
|
421
427
|
height: 6px;
|
|
428
|
+
/*css:theme-validation:ignore*/
|
|
422
429
|
width: 20% ;
|
|
423
430
|
border-radius: 5px;
|
|
424
431
|
background-color: var(--dropbox_mob_close_bg_color);
|
|
@@ -89,7 +89,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
89
89
|
// suggestionContainer.addEventListener('scroll', this.handleScroll);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
93
93
|
const {
|
|
94
94
|
selectedOptions,
|
|
95
95
|
options,
|
package/es/Popup/Popup.js
CHANGED
|
@@ -161,7 +161,11 @@ const Popup = function (Component) {
|
|
|
161
161
|
this.handleDropElementStyleUpdate = this.handleDropElementStyleUpdate.bind(this);
|
|
162
162
|
this.positionRef = /*#__PURE__*/React.createRef();
|
|
163
163
|
this.rootElement = Registry.getRootElement();
|
|
164
|
-
this.popupObserver = new ResizeObserver(this.handlePopupResize);
|
|
164
|
+
this.popupObserver = new ResizeObserver(this.handlePopupResize);
|
|
165
|
+
this.cancelRaf = this.cancelRaf.bind(this);
|
|
166
|
+
this.cancelPendingAnimationFrames = this.cancelPendingAnimationFrames.bind(this);
|
|
167
|
+
this.setPositionRafId = null;
|
|
168
|
+
this.resizePositionRafId = null; //dropBoxSize
|
|
165
169
|
|
|
166
170
|
this.size = null;
|
|
167
171
|
this.isTargetElementVisible = false;
|
|
@@ -181,17 +185,18 @@ const Popup = function (Component) {
|
|
|
181
185
|
groupPopups.push(this);
|
|
182
186
|
Registry.popups[group] = groupPopups;
|
|
183
187
|
|
|
184
|
-
if (Object.keys(Registry.popups).length === 1 && groupPopups.length === 1) {
|
|
185
|
-
|
|
186
|
-
|
|
188
|
+
if (Object.keys(Registry.popups).length === 1 && groupPopups.length === 1 && Registry.listenerPopupRef === undefined) {
|
|
189
|
+
Registry.listenerPopupRef = this;
|
|
190
|
+
Registry.listenerPopupRef.updateListeners(true, CLICK_EVENTS, document);
|
|
191
|
+
document.addEventListener('keyup', Registry.listenerPopupRef.documentKeyupHandler, false); // document.addEventListener('scroll', Registry.listenerPopupRef.handleScroll, true);
|
|
187
192
|
|
|
188
|
-
window.addEventListener('resize',
|
|
189
|
-
document.addEventListener('mousedown',
|
|
190
|
-
document.addEventListener('focus',
|
|
193
|
+
window.addEventListener('resize', Registry.listenerPopupRef.handleResize);
|
|
194
|
+
document.addEventListener('mousedown', Registry.listenerPopupRef.handleDocumentMouseDown, true);
|
|
195
|
+
document.addEventListener('focus', Registry.listenerPopupRef.handleDocumentFocus, true);
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
198
|
|
|
194
|
-
|
|
199
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
195
200
|
const {
|
|
196
201
|
isPopupOpen
|
|
197
202
|
} = this.state;
|
|
@@ -256,6 +261,20 @@ const Popup = function (Component) {
|
|
|
256
261
|
}
|
|
257
262
|
}
|
|
258
263
|
|
|
264
|
+
cancelRaf(refName) {
|
|
265
|
+
const id = this[refName];
|
|
266
|
+
|
|
267
|
+
if (id) {
|
|
268
|
+
cancelAnimationFrame(id);
|
|
269
|
+
this[refName] = null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
cancelPendingAnimationFrames() {
|
|
274
|
+
this.cancelRaf('setPositionRafId');
|
|
275
|
+
this.cancelRaf('resizePositionRafId');
|
|
276
|
+
}
|
|
277
|
+
|
|
259
278
|
componentWillUnmount() {
|
|
260
279
|
const group = this.getGroup();
|
|
261
280
|
Registry.popups = Object.keys(Registry.popups).reduce((res, groupName) => {
|
|
@@ -284,14 +303,17 @@ const Popup = function (Component) {
|
|
|
284
303
|
this.popupObserver.disconnect();
|
|
285
304
|
}
|
|
286
305
|
|
|
287
|
-
if (noPopups) {
|
|
288
|
-
|
|
289
|
-
document.removeEventListener('keyup',
|
|
306
|
+
if (noPopups && Registry.listenerPopupRef !== undefined) {
|
|
307
|
+
Registry.listenerPopupRef.updateListeners(false, CLICK_EVENTS, document);
|
|
308
|
+
document.removeEventListener('keyup', Registry.listenerPopupRef.documentKeyupHandler); // document.removeEventListener('scroll', Registry.listenerPopupRef.handleScroll);
|
|
290
309
|
|
|
291
|
-
window.removeEventListener('resize',
|
|
292
|
-
document.removeEventListener('mousedown',
|
|
293
|
-
document.removeEventListener('focus',
|
|
310
|
+
window.removeEventListener('resize', Registry.listenerPopupRef.handleResize);
|
|
311
|
+
document.removeEventListener('mousedown', Registry.listenerPopupRef.handleDocumentMouseDown, true);
|
|
312
|
+
document.removeEventListener('focus', Registry.listenerPopupRef.handleDocumentFocus, true);
|
|
313
|
+
Registry.listenerPopupRef = undefined;
|
|
294
314
|
}
|
|
315
|
+
|
|
316
|
+
this.cancelPendingAnimationFrames();
|
|
295
317
|
}
|
|
296
318
|
|
|
297
319
|
handleAddingScrollBlock() {
|
|
@@ -814,7 +836,8 @@ const Popup = function (Component) {
|
|
|
814
836
|
}
|
|
815
837
|
|
|
816
838
|
const setPosition = () => {
|
|
817
|
-
|
|
839
|
+
this.cancelRaf('setPositionRafId');
|
|
840
|
+
this.setPositionRafId = requestAnimationFrame(() => {
|
|
818
841
|
const {
|
|
819
842
|
placeHolderElement,
|
|
820
843
|
dropElement
|
|
@@ -823,7 +846,7 @@ const Popup = function (Component) {
|
|
|
823
846
|
position,
|
|
824
847
|
isPopupReady
|
|
825
848
|
} = this.state;
|
|
826
|
-
const scrollContainer = placeHolderElement.closest('[data-scroll=true]') || document.body;
|
|
849
|
+
const scrollContainer = placeHolderElement ? placeHolderElement.closest('[data-scroll=true]') || document.body : document.body;
|
|
827
850
|
const betterPosition = viewPort.betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
|
|
828
851
|
needArrow,
|
|
829
852
|
isAbsolute,
|
|
@@ -852,6 +875,8 @@ const Popup = function (Component) {
|
|
|
852
875
|
this.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
|
|
853
876
|
}
|
|
854
877
|
}
|
|
878
|
+
|
|
879
|
+
this.setPositionRafId = null;
|
|
855
880
|
});
|
|
856
881
|
};
|
|
857
882
|
|
|
@@ -883,7 +908,8 @@ const Popup = function (Component) {
|
|
|
883
908
|
|
|
884
909
|
if (placeHolderElement && dropElement) {
|
|
885
910
|
const scrollContainer = placeHolderElement.closest('[data-scroll=true]') || document.body;
|
|
886
|
-
|
|
911
|
+
this.cancelRaf('resizePositionRafId');
|
|
912
|
+
this.resizePositionRafId = requestAnimationFrame(() => {
|
|
887
913
|
const needArrow = this.getNeedArrow(popup);
|
|
888
914
|
const isAbsolute = this.getIsAbsolutePopup(popup);
|
|
889
915
|
const customOrder = this.getCustomPositionOrder(popup);
|
|
@@ -940,6 +966,8 @@ const Popup = function (Component) {
|
|
|
940
966
|
// });
|
|
941
967
|
// }
|
|
942
968
|
|
|
969
|
+
|
|
970
|
+
this.resizePositionRafId = null;
|
|
943
971
|
});
|
|
944
972
|
}
|
|
945
973
|
}
|
package/es/Popup/Registry.js
CHANGED
package/es/Select/Select.js
CHANGED
|
@@ -119,7 +119,7 @@ export class SelectComponent extends Component {
|
|
|
119
119
|
// suggestionContainer.addEventListener('scroll', this.handleScroll);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
123
123
|
let {
|
|
124
124
|
selectedValue,
|
|
125
125
|
isDefaultSelectValue,
|
|
@@ -246,7 +246,14 @@ describe('Select -', () => {
|
|
|
246
246
|
userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '2');
|
|
247
247
|
expect(getAllByRole(listItemRole)).toHaveLength(1);
|
|
248
248
|
expect(asFragment()).toMatchSnapshot();
|
|
249
|
-
});
|
|
249
|
+
}); // test('Should render the only options matching search value even with additional spaces before and after', () => {
|
|
250
|
+
// const { getByRole, getAllByRole, asFragment, getByTestId } = render(<Select needSearch options={options} />);
|
|
251
|
+
// userEvent.click(getByRole(selectInputRole));
|
|
252
|
+
// userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), ' 2 ');
|
|
253
|
+
// expect(getAllByRole(listItemRole)).toHaveLength(1);
|
|
254
|
+
// expect(asFragment()).toMatchSnapshot();
|
|
255
|
+
// });
|
|
256
|
+
|
|
250
257
|
test('Should trigger given onSearch, when type on the search input', async () => {
|
|
251
258
|
const mockOnSearch = jest.fn();
|
|
252
259
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer dot-components, dot-components.theme, dot-components.core, dot-components.reset, dot-components.base, dot-components.animation, dot-components.transition, dot-components.utility, dot-components.layout, dot-components.semantic, dot-components.atom, dot-components.molecule, dot-components.organism, dot-components.page, dot-components.effect;
|
package/es/css.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./common/reset.module.css";
|
|
2
2
|
import "./common/basic.module.css";
|
|
3
|
-
import '@zohodesk/variables/
|
|
4
|
-
import '@zohodesk/variables/
|
|
5
|
-
import '@zohodesk/variables/
|
|
6
|
-
import '@zohodesk/icons/
|
|
3
|
+
import '@zohodesk/variables/lib/colorVariables.module.css';
|
|
4
|
+
import '@zohodesk/variables/lib/sizeVariables.module.css';
|
|
5
|
+
import '@zohodesk/variables/lib/fontFamilyVariables.module.css';
|
|
6
|
+
import '@zohodesk/icons/lib/Icon/Icon.module.css';
|
|
7
7
|
import "./common/animation.module.css";
|
|
8
8
|
import "./common/transition.module.css";
|
|
9
9
|
import "./common/common.module.css";
|
package/es/v1/Popup/Popup.js
CHANGED
package/es/v1/Select/Select.js
CHANGED
|
@@ -119,7 +119,7 @@ export class SelectComponent extends Component {
|
|
|
119
119
|
// suggestionContainer.addEventListener('scroll', this.handleScroll);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
123
123
|
let {
|
|
124
124
|
selectedValue,
|
|
125
125
|
isDefaultSelectValue,
|
|
@@ -69,8 +69,8 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}, {
|
|
72
|
-
key: "
|
|
73
|
-
value: function
|
|
72
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
73
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
74
74
|
if (this.props.selectedItem !== nextProps.selectedItem && !this.props.disableInternalState) {
|
|
75
75
|
this.setState({
|
|
76
76
|
selectedItem: nextProps.selectedItem
|