@zohodesk/components 1.0.0-temp-229.1 → 1.0.0-temp-220.11
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 +35 -0
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +15 -11
- package/assets/Appearance/dark/themes/blue/blue_ComponentTheme_DarkTheme.module.css +5 -0
- package/assets/Appearance/dark/themes/green/green_ComponentTheme_DarkTheme.module.css +5 -0
- package/assets/Appearance/dark/themes/orange/orange_ComponentTheme_DarkTheme.module.css +5 -0
- package/assets/Appearance/dark/themes/red/red_ComponentTheme_DarkTheme.module.css +5 -0
- package/assets/Appearance/dark/themes/yellow/yellow_ComponentTheme_DarkTheme.module.css +5 -0
- package/assets/Appearance/light/mode/Component_LightMode.module.css +13 -9
- package/assets/Appearance/light/themes/blue/blue_ComponentTheme_LightTheme.module.css +5 -0
- package/assets/Appearance/light/themes/green/green_ComponentTheme_LightTheme.module.css +5 -0
- package/assets/Appearance/light/themes/orange/orange_ComponentTheme_LightTheme.module.css +5 -0
- package/assets/Appearance/light/themes/red/red_ComponentTheme_LightTheme.module.css +5 -0
- package/assets/Appearance/light/themes/yellow/yellow_ComponentTheme_LightTheme.module.css +5 -0
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +15 -11
- package/assets/Appearance/pureDark/themes/blue/blue_ComponentTheme_PureDarkTheme.module.css +5 -0
- package/assets/Appearance/pureDark/themes/green/green_ComponentTheme_PureDarkTheme.module.css +5 -0
- package/assets/Appearance/pureDark/themes/orange/orange_ComponentTheme_PureDarkTheme.module.css +5 -0
- package/assets/Appearance/pureDark/themes/red/red_ComponentTheme_PureDarkTheme.module.css +5 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_ComponentTheme_PureDarkTheme.module.css +5 -0
- package/es/Button/Button.js +14 -7
- package/es/Button/css/Button.module.css +54 -16
- package/es/Button/css/cssJSLogic.js +6 -1
- package/es/Button/props/propTypes.js +1 -0
- package/es/Card/Card.js +10 -39
- package/es/Card/props/defaultProps.js +1 -2
- package/es/Card/props/propTypes.js +1 -2
- package/es/DropBox/DropBox.js +3 -3
- package/es/ListItem/ListItem.js +11 -2
- package/es/ListItem/ListItem.module.css +9 -0
- package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +15 -1
- package/es/ListItem/props/propTypes.js +2 -1
- package/es/Modal/Modal.js +35 -14
- package/es/Modal/Portal/Portal.js +33 -0
- package/es/Modal/Portal/__tests__/Portal.spec.js +28 -0
- package/es/Modal/Portal/__tests__/__snapshots__/Portal.spec.js.snap +30 -0
- package/es/Modal/Portal/props/defaultProps.js +3 -0
- package/es/Modal/Portal/props/propTypes.js +5 -0
- package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +80 -10
- package/es/Popup/Popup.js +239 -107
- package/es/Popup/Registry.js +36 -0
- package/es/Popup/viewPort.js +15 -16
- package/es/Provider/Config.js +4 -1
- package/es/Provider/LibraryContext.js +7 -3
- package/es/RippleEffect/RippleEffect.module.css +3 -2
- package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +512 -64
- package/es/v1/Button/props/propTypes.js +2 -1
- package/es/v1/Switch/useSwitch.js +1 -1
- package/lib/Button/Button.js +12 -5
- package/lib/Button/css/Button.module.css +54 -16
- package/lib/Button/css/cssJSLogic.js +6 -2
- package/lib/Button/props/propTypes.js +1 -0
- package/lib/Card/Card.js +25 -54
- package/lib/Card/props/defaultProps.js +1 -2
- package/lib/Card/props/propTypes.js +1 -2
- package/lib/DropBox/DropBox.js +3 -3
- package/lib/ListItem/ListItem.js +12 -3
- package/lib/ListItem/ListItem.module.css +9 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +15 -1
- package/lib/ListItem/props/propTypes.js +2 -1
- package/lib/Modal/Modal.js +40 -16
- package/lib/Modal/Portal/Portal.js +46 -0
- package/lib/Modal/Portal/__tests__/Portal.spec.js +37 -0
- package/lib/Modal/Portal/__tests__/__snapshots__/Portal.spec.js.snap +30 -0
- package/lib/Modal/Portal/props/defaultProps.js +10 -0
- package/lib/Modal/Portal/props/propTypes.js +16 -0
- package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +80 -10
- package/lib/Popup/Popup.js +316 -162
- package/lib/Popup/Registry.js +46 -0
- package/lib/Popup/viewPort.js +15 -16
- package/lib/Provider/Config.js +4 -1
- package/lib/Provider/LibraryContext.js +7 -3
- package/lib/RippleEffect/RippleEffect.module.css +3 -2
- package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +512 -64
- package/lib/v1/Button/props/propTypes.js +2 -1
- package/lib/v1/Switch/useSwitch.js +1 -1
- package/package.json +12 -12
- package/result.json +1 -1
package/es/Card/Card.js
CHANGED
|
@@ -96,9 +96,7 @@ 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);
|
|
100
|
-
this.setScrollRef = this.setScrollRef.bind(this);
|
|
101
|
-
this.childEleRef = null; //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
|
|
99
|
+
this.onScroll = this.onScroll.bind(this); //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
|
|
102
100
|
//this.onClearScroll = debounce(this.setScroll.bind(this, false), 500);
|
|
103
101
|
}
|
|
104
102
|
|
|
@@ -129,11 +127,8 @@ export default class Card extends Component {
|
|
|
129
127
|
scrollAt,
|
|
130
128
|
noNeedUpScroll,
|
|
131
129
|
// isScrollShadow,
|
|
132
|
-
isPercentageScroll
|
|
133
|
-
isRecentOnBottom
|
|
130
|
+
isPercentageScroll
|
|
134
131
|
} = this.props;
|
|
135
|
-
const scrollLimitHeight = scrollHeight - scrollAt;
|
|
136
|
-
const currentVisibleBottom = scrollTop + offsetHeight;
|
|
137
132
|
|
|
138
133
|
if (scrollTop > this.lastScrollTop) {
|
|
139
134
|
this.scrollDirection = 'down';
|
|
@@ -144,12 +139,9 @@ export default class Card extends Component {
|
|
|
144
139
|
this.lastScrollTop = scrollTop;
|
|
145
140
|
|
|
146
141
|
if (fetchData && !this.isFetching) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const scrollingPercentage = currentVisibleBottom / scrollLimitHeight * 100;
|
|
151
|
-
const scrolledUpPercentage = (scrollHeight - scrollTop) / scrollLimitHeight * 100;
|
|
152
|
-
const prefetch = isRecentOnBottom ? isPercentageScroll ? scrolledUpPercentage >= getLibraryConfig('scrollFetchLimit') : scrollTop <= scrollAt : isPercentageScroll ? scrollingPercentage >= getLibraryConfig('scrollFetchLimit') : scrollLimitHeight <= currentVisibleBottom;
|
|
142
|
+
if (this.scrollDirection === 'down' && !noMoreData) {
|
|
143
|
+
const scrollingPercentage = (scrollTop + offsetHeight) / (scrollHeight - scrollAt) * 100;
|
|
144
|
+
const prefetch = isPercentageScroll ? scrollingPercentage >= getLibraryConfig('scrollFetchLimit') : scrollHeight - scrollAt <= scrollTop + offsetHeight;
|
|
153
145
|
|
|
154
146
|
if (prefetch) {
|
|
155
147
|
this.isFetching = true;
|
|
@@ -161,9 +153,7 @@ export default class Card extends Component {
|
|
|
161
153
|
});
|
|
162
154
|
}
|
|
163
155
|
} else {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (prefetch && this.from !== 0 && !noNeedUpScroll) {
|
|
156
|
+
if (0 >= scrollTop - scrollAt && this.from !== 0 && !noNeedUpScroll) {
|
|
167
157
|
this.isFetching = true;
|
|
168
158
|
fetchData(this.from - this.limit, this.to - this.limit, this.scrollDirection).then(() => {
|
|
169
159
|
this.to = this.to - this.limit;
|
|
@@ -176,12 +166,9 @@ export default class Card extends Component {
|
|
|
176
166
|
}
|
|
177
167
|
|
|
178
168
|
if (fetchData && !noNeedUpScroll) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (this.from !== 0 && scrollTop === 0 && topFetch) {
|
|
183
|
-
scrollContainerObj.scrollTop = currentVisibleBottom / 3;
|
|
184
|
-
} else if (scrollHeight === currentVisibleBottom && bottomFetch) {
|
|
169
|
+
if (this.from !== 0 && scrollTop === 0 && !noNeedUpScroll) {
|
|
170
|
+
scrollContainerObj.scrollTop = scrollTop + offsetHeight / 3;
|
|
171
|
+
} else if (scrollHeight === scrollTop + offsetHeight && !noMoreData) {
|
|
185
172
|
scrollContainerObj.scrollTop = scrollTop - offsetHeight / 2;
|
|
186
173
|
}
|
|
187
174
|
} // if (isScrollShadow) {
|
|
@@ -200,21 +187,6 @@ export default class Card extends Component {
|
|
|
200
187
|
// }
|
|
201
188
|
|
|
202
189
|
|
|
203
|
-
setScrollRef(el) {
|
|
204
|
-
const {
|
|
205
|
-
scrollAt,
|
|
206
|
-
isRecentOnBottom
|
|
207
|
-
} = this.props;
|
|
208
|
-
|
|
209
|
-
if (el && isRecentOnBottom) {
|
|
210
|
-
requestAnimationFrame(() => {
|
|
211
|
-
el.scrollTop = el.scrollHeight + Number(scrollAt);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
this.childEleRef && this.childEleRef(el);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
190
|
render() {
|
|
219
191
|
let {
|
|
220
192
|
onClick,
|
|
@@ -248,7 +220,6 @@ export default class Card extends Component {
|
|
|
248
220
|
isScroll
|
|
249
221
|
});
|
|
250
222
|
} else if (child.type === CardContent || this.props.childTypes && child.type === this.props.childTypes.cardContent) {
|
|
251
|
-
this.childEleRef = child.props.eleRef;
|
|
252
223
|
return /*#__PURE__*/React.createElement(Box, {
|
|
253
224
|
id: htmlId,
|
|
254
225
|
role: role,
|
|
@@ -256,7 +227,7 @@ export default class Card extends Component {
|
|
|
256
227
|
scroll: child.props.scroll,
|
|
257
228
|
preventParentScroll: child.props.preventParentScroll,
|
|
258
229
|
onScroll: this.onScroll,
|
|
259
|
-
eleRef:
|
|
230
|
+
eleRef: child.props.eleRef,
|
|
260
231
|
isScrollAttribute: child.props.isScrollAttribute,
|
|
261
232
|
dataId: child.props.dataId,
|
|
262
233
|
shrink: child.props.shrink,
|
|
@@ -38,8 +38,7 @@ export const Card_propTypes = {
|
|
|
38
38
|
role: PropTypes.string
|
|
39
39
|
}),
|
|
40
40
|
isPercentageScroll: PropTypes.bool,
|
|
41
|
-
eleRef: PropTypes.func
|
|
42
|
-
isRecentOnBottom: PropTypes.bool
|
|
41
|
+
eleRef: PropTypes.func
|
|
43
42
|
};
|
|
44
43
|
export const CardFooter_propTypes = {
|
|
45
44
|
children: PropTypes.node,
|
package/es/DropBox/DropBox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useContext } from 'react';
|
|
2
2
|
import FocusScope from '@zohodesk/a11y/es/FocusScope/FocusScope';
|
|
3
|
-
import
|
|
3
|
+
import Portal from "../Modal/Portal/Portal"; // import { getLibraryConfig } from '../Provider/Config';
|
|
4
4
|
|
|
5
5
|
import LibraryContext from "../Provider/LibraryContextInit";
|
|
6
6
|
import cssJSLogic from "./css/cssJSLogic";
|
|
@@ -62,13 +62,13 @@ export default function DropBox(props) {
|
|
|
62
62
|
...props,
|
|
63
63
|
zIndexStyle: zIndexStyle
|
|
64
64
|
});
|
|
65
|
-
return isModel && isActive ? /*#__PURE__*/React.createElement(
|
|
65
|
+
return isModel && isActive ? /*#__PURE__*/React.createElement(Portal, {
|
|
66
66
|
portalId: portalId
|
|
67
67
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
68
68
|
className: `${style.freezeLayer} ${style.freeze}`,
|
|
69
69
|
style: zIndexStyle,
|
|
70
70
|
onClick: stopPropagation
|
|
71
|
-
}), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/React.createElement(
|
|
71
|
+
}), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/React.createElement(Portal, {
|
|
72
72
|
portalId: portalId
|
|
73
73
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, isRestrictScroll ? /*#__PURE__*/React.createElement("div", {
|
|
74
74
|
className: style.freezeLayer,
|
package/es/ListItem/ListItem.js
CHANGED
|
@@ -70,7 +70,8 @@ export default class ListItem extends React.Component {
|
|
|
70
70
|
a11y,
|
|
71
71
|
customClass,
|
|
72
72
|
customProps,
|
|
73
|
-
needMultiLineText
|
|
73
|
+
needMultiLineText,
|
|
74
|
+
secondaryValue
|
|
74
75
|
} = this.props;
|
|
75
76
|
let {
|
|
76
77
|
ListItemProps = {},
|
|
@@ -113,6 +114,11 @@ export default class ListItem extends React.Component {
|
|
|
113
114
|
eleRef: this.getRef,
|
|
114
115
|
customProps: ListItemProps,
|
|
115
116
|
...ContainerProps
|
|
117
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
118
|
+
flexible: true,
|
|
119
|
+
className: style.leftBox
|
|
120
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
121
|
+
className: style.titleBox
|
|
116
122
|
}, value ? /*#__PURE__*/React.createElement(Box, {
|
|
117
123
|
shrink: true,
|
|
118
124
|
adjust: true,
|
|
@@ -121,7 +127,10 @@ export default class ListItem extends React.Component {
|
|
|
121
127
|
shrink: true,
|
|
122
128
|
adjust: true,
|
|
123
129
|
className: style.children
|
|
124
|
-
}, children) : null,
|
|
130
|
+
}, children) : null), secondaryValue ? /*#__PURE__*/React.createElement(Box, {
|
|
131
|
+
"data-title": isDisabled ? null : secondaryValue,
|
|
132
|
+
className: `${style.secondaryField} ${needMultiLineText ? style.multiLine : style.secondaryValue}`
|
|
133
|
+
}, secondaryValue) : null), needTick && active ? /*#__PURE__*/React.createElement(Box, {
|
|
125
134
|
className: `${style.tickIcon} ${tickIconPalette} ${customTickIcon}`,
|
|
126
135
|
"aria-hidden": ariaHidden,
|
|
127
136
|
dataId: `${dataIdString}_tickIcon`,
|
|
@@ -250,3 +250,12 @@
|
|
|
250
250
|
padding-top: var(--zd_size10) ;
|
|
251
251
|
padding-bottom: var(--zd_size10) ;
|
|
252
252
|
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
.leftBox {
|
|
256
|
+
composes: dflex flexcolumn from '../common/common.module.css';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.titleBox {
|
|
260
|
+
composes: dflex alignVertical from '../common/common.module.css';
|
|
261
|
+
}
|
|
@@ -10,6 +10,20 @@ exports[`ListItem rendering the defult props 1`] = `
|
|
|
10
10
|
data-test-id="listItem"
|
|
11
11
|
role="option"
|
|
12
12
|
tabindex="0"
|
|
13
|
-
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
class="leftBox grow basis shrinkOff"
|
|
16
|
+
data-id="boxComponent"
|
|
17
|
+
data-selector-id="box"
|
|
18
|
+
data-test-id="boxComponent"
|
|
19
|
+
>
|
|
20
|
+
<div
|
|
21
|
+
class="titleBox shrinkOff"
|
|
22
|
+
data-id="boxComponent"
|
|
23
|
+
data-selector-id="box"
|
|
24
|
+
data-test-id="boxComponent"
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
</li>
|
|
14
28
|
</DocumentFragment>
|
|
15
29
|
`;
|
package/es/Modal/Modal.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**** Libraries ****/
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import ReactDOM from 'react-dom';
|
|
4
3
|
import { defaultProps } from "./props/defaultProps";
|
|
5
4
|
import { propTypes } from "./props/propTypes";
|
|
5
|
+
import Portal from "./Portal/Portal";
|
|
6
|
+
import { getLibraryConfig } from "../Provider/Config";
|
|
6
7
|
import style from "../AppContainer/AppContainer.module.css";
|
|
7
8
|
let createdPortalIds = [];
|
|
8
9
|
let newPortalPrefix = 'CPortal';
|
|
@@ -13,10 +14,13 @@ export default class Modal extends React.Component {
|
|
|
13
14
|
this.handleAddPortalId = this.handleAddPortalId.bind(this);
|
|
14
15
|
this.handleRemovePortalId = this.handleRemovePortalId.bind(this);
|
|
15
16
|
this.handleInsertPortalDiv = this.handleInsertPortalDiv.bind(this);
|
|
16
|
-
this.
|
|
17
|
+
this.setPortalDiv = this.setPortalDiv.bind(this);
|
|
18
|
+
this.getRootElement = this.getRootElement.bind(this);
|
|
19
|
+
this.getPortalPrefix = this.getPortalPrefix.bind(this);
|
|
17
20
|
this.state = {
|
|
18
21
|
isMounted: false
|
|
19
22
|
};
|
|
23
|
+
this.portalPrefix = this.getPortalPrefix();
|
|
20
24
|
this.portalId = props.portalId;
|
|
21
25
|
this.setRef = this.setRef.bind(this);
|
|
22
26
|
this.ref = null; // this.portalDiv = document.createDocumentFragment();
|
|
@@ -31,24 +35,40 @@ export default class Modal extends React.Component {
|
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
getRootElement() {
|
|
39
|
+
const getRootElement = getLibraryConfig('getRootElement');
|
|
36
40
|
|
|
37
|
-
if (
|
|
41
|
+
if (getRootElement && typeof getRootElement === 'function') {
|
|
42
|
+
const parent = getRootElement();
|
|
43
|
+
|
|
44
|
+
if (parent) {
|
|
45
|
+
return parent;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getPortalPrefix() {
|
|
53
|
+
const portalPrefix = getLibraryConfig('portalPrefix');
|
|
54
|
+
return portalPrefix !== '' ? portalPrefix : '';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setPortalDiv() {
|
|
58
|
+
const modalRoot = this.props.portalId ? document.querySelector(`[data-portal=${this.portalPrefix}${this.props.portalId}]`) : '';
|
|
59
|
+
|
|
60
|
+
if (!modalRoot) {
|
|
38
61
|
this.portalId = this.handleAddPortalId();
|
|
39
62
|
this.newModalRoot = document.createElement('div');
|
|
40
63
|
this.newModalRoot.className = style.container;
|
|
41
|
-
this.newModalRoot.setAttribute('data-portal', this.portalId);
|
|
64
|
+
this.newModalRoot.setAttribute('data-portal', `${this.portalPrefix}${this.portalId}`);
|
|
42
65
|
this.containerDiv && this.containerDiv.appendChild(this.newModalRoot);
|
|
43
|
-
this.modalRoot = this.newModalRoot;
|
|
44
66
|
}
|
|
45
|
-
|
|
46
|
-
return this.modalRoot;
|
|
47
67
|
}
|
|
48
68
|
|
|
49
69
|
componentDidMount() {
|
|
50
|
-
this.containerDiv =
|
|
51
|
-
this.
|
|
70
|
+
this.containerDiv = this.getRootElement() || document.getElementsByTagName('desk')[0] || document.getElementsByTagName('body')[0];
|
|
71
|
+
this.setPortalDiv();
|
|
52
72
|
this.setState({
|
|
53
73
|
isMounted: true
|
|
54
74
|
}, () => {
|
|
@@ -57,7 +77,6 @@ export default class Modal extends React.Component {
|
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
componentWillUnmount() {
|
|
60
|
-
//this.modalRoot && this.modalRoot.removeChild(this.portalDiv);
|
|
61
80
|
if (this.newModalRoot) {
|
|
62
81
|
this.containerDiv && this.containerDiv.removeChild(this.newModalRoot);
|
|
63
82
|
this.handleRemovePortalId();
|
|
@@ -129,10 +148,12 @@ export default class Modal extends React.Component {
|
|
|
129
148
|
|
|
130
149
|
if (isMounted) {
|
|
131
150
|
if (Element) {
|
|
132
|
-
return /*#__PURE__*/
|
|
151
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
152
|
+
portalId: `${this.portalPrefix}${this.portalId}`
|
|
153
|
+
}, /*#__PURE__*/React.createElement(Element, {
|
|
133
154
|
ref: this.setRef,
|
|
134
155
|
...elementProps
|
|
135
|
-
})
|
|
156
|
+
}));
|
|
136
157
|
}
|
|
137
158
|
|
|
138
159
|
return null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import BasePortal from '@zohodesk/dotkit/es/react/components/Portal/Portal';
|
|
3
|
+
import { getLibraryConfig } from "../../Provider/Config";
|
|
4
|
+
import { defaultProps } from "./props/defaultProps";
|
|
5
|
+
import { propTypes } from "./props/propTypes";
|
|
6
|
+
export default function Portal(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
portalId
|
|
10
|
+
} = _ref;
|
|
11
|
+
const portalPrefix = getLibraryConfig("portalPrefix");
|
|
12
|
+
|
|
13
|
+
const getPortalContainer = () => {
|
|
14
|
+
const getPortalContainer = getLibraryConfig('getPortalContainer');
|
|
15
|
+
|
|
16
|
+
if (getPortalContainer && typeof getPortalContainer === 'function') {
|
|
17
|
+
const portal = getPortalContainer();
|
|
18
|
+
|
|
19
|
+
if (portal) {
|
|
20
|
+
return portal;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return /*#__PURE__*/React.createElement(BasePortal, {
|
|
28
|
+
portalId: `${portalPrefix ? `${portalPrefix}` : ''}${portalId}`,
|
|
29
|
+
getFallbackElement: getPortalContainer
|
|
30
|
+
}, children);
|
|
31
|
+
}
|
|
32
|
+
Portal.propTypes = propTypes;
|
|
33
|
+
Portal.defaultProps = defaultProps;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, cleanup } from '@testing-library/react';
|
|
3
|
+
import Portal from "../Portal";
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cleanup();
|
|
6
|
+
});
|
|
7
|
+
describe('Portal', () => {
|
|
8
|
+
test('rendering the defult props', () => {
|
|
9
|
+
const customPortalContainer = document.createElement('div');
|
|
10
|
+
customPortalContainer.setAttribute('data-portal', 'portal1');
|
|
11
|
+
document.body.appendChild(customPortalContainer);
|
|
12
|
+
const {
|
|
13
|
+
baseElement
|
|
14
|
+
} = render( /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", null, "Portal Div Check")));
|
|
15
|
+
expect(baseElement).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
test('renders with portalId prop', () => {
|
|
18
|
+
const customPortalContainer = document.createElement('div');
|
|
19
|
+
customPortalContainer.setAttribute('data-portal', 'customPortal');
|
|
20
|
+
document.body.appendChild(customPortalContainer);
|
|
21
|
+
const {
|
|
22
|
+
baseElement
|
|
23
|
+
} = render( /*#__PURE__*/React.createElement(Portal, {
|
|
24
|
+
portalId: "customPortal"
|
|
25
|
+
}, /*#__PURE__*/React.createElement("div", null, "Portal Content Check")));
|
|
26
|
+
expect(baseElement).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Portal rendering the defult props 1`] = `
|
|
4
|
+
<body>
|
|
5
|
+
<div
|
|
6
|
+
data-portal="portal1"
|
|
7
|
+
>
|
|
8
|
+
<div>
|
|
9
|
+
Portal Div Check
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<div />
|
|
13
|
+
</body>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`Portal renders with portalId prop 1`] = `
|
|
17
|
+
<body>
|
|
18
|
+
<div
|
|
19
|
+
data-portal="portal1"
|
|
20
|
+
/>
|
|
21
|
+
<div
|
|
22
|
+
data-portal="customPortal"
|
|
23
|
+
>
|
|
24
|
+
<div>
|
|
25
|
+
Portal Content Check
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<div />
|
|
29
|
+
</body>
|
|
30
|
+
`;
|
|
@@ -215,12 +215,26 @@ exports[`AdvancedMultiSelect rendering the options array with objects and string
|
|
|
215
215
|
tabindex="0"
|
|
216
216
|
>
|
|
217
217
|
<div
|
|
218
|
-
class="
|
|
218
|
+
class="leftBox grow basis shrinkOff"
|
|
219
219
|
data-id="boxComponent"
|
|
220
220
|
data-selector-id="box"
|
|
221
221
|
data-test-id="boxComponent"
|
|
222
222
|
>
|
|
223
|
-
|
|
223
|
+
<div
|
|
224
|
+
class="titleBox shrinkOff"
|
|
225
|
+
data-id="boxComponent"
|
|
226
|
+
data-selector-id="box"
|
|
227
|
+
data-test-id="boxComponent"
|
|
228
|
+
>
|
|
229
|
+
<div
|
|
230
|
+
class="value basisAuto shrinkOn"
|
|
231
|
+
data-id="boxComponent"
|
|
232
|
+
data-selector-id="box"
|
|
233
|
+
data-test-id="boxComponent"
|
|
234
|
+
>
|
|
235
|
+
Apple
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
224
238
|
</div>
|
|
225
239
|
</li>
|
|
226
240
|
<li
|
|
@@ -237,12 +251,26 @@ exports[`AdvancedMultiSelect rendering the options array with objects and string
|
|
|
237
251
|
tabindex="0"
|
|
238
252
|
>
|
|
239
253
|
<div
|
|
240
|
-
class="
|
|
254
|
+
class="leftBox grow basis shrinkOff"
|
|
241
255
|
data-id="boxComponent"
|
|
242
256
|
data-selector-id="box"
|
|
243
257
|
data-test-id="boxComponent"
|
|
244
258
|
>
|
|
245
|
-
|
|
259
|
+
<div
|
|
260
|
+
class="titleBox shrinkOff"
|
|
261
|
+
data-id="boxComponent"
|
|
262
|
+
data-selector-id="box"
|
|
263
|
+
data-test-id="boxComponent"
|
|
264
|
+
>
|
|
265
|
+
<div
|
|
266
|
+
class="value basisAuto shrinkOn"
|
|
267
|
+
data-id="boxComponent"
|
|
268
|
+
data-selector-id="box"
|
|
269
|
+
data-test-id="boxComponent"
|
|
270
|
+
>
|
|
271
|
+
Orange
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
246
274
|
</div>
|
|
247
275
|
</li>
|
|
248
276
|
<li
|
|
@@ -259,12 +287,26 @@ exports[`AdvancedMultiSelect rendering the options array with objects and string
|
|
|
259
287
|
tabindex="0"
|
|
260
288
|
>
|
|
261
289
|
<div
|
|
262
|
-
class="
|
|
290
|
+
class="leftBox grow basis shrinkOff"
|
|
263
291
|
data-id="boxComponent"
|
|
264
292
|
data-selector-id="box"
|
|
265
293
|
data-test-id="boxComponent"
|
|
266
294
|
>
|
|
267
|
-
|
|
295
|
+
<div
|
|
296
|
+
class="titleBox shrinkOff"
|
|
297
|
+
data-id="boxComponent"
|
|
298
|
+
data-selector-id="box"
|
|
299
|
+
data-test-id="boxComponent"
|
|
300
|
+
>
|
|
301
|
+
<div
|
|
302
|
+
class="value basisAuto shrinkOn"
|
|
303
|
+
data-id="boxComponent"
|
|
304
|
+
data-selector-id="box"
|
|
305
|
+
data-test-id="boxComponent"
|
|
306
|
+
>
|
|
307
|
+
string test
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
268
310
|
</div>
|
|
269
311
|
</li>
|
|
270
312
|
</div>
|
|
@@ -421,12 +463,26 @@ exports[`AdvancedMultiSelect rendering the options array with only objects using
|
|
|
421
463
|
tabindex="0"
|
|
422
464
|
>
|
|
423
465
|
<div
|
|
424
|
-
class="
|
|
466
|
+
class="leftBox grow basis shrinkOff"
|
|
425
467
|
data-id="boxComponent"
|
|
426
468
|
data-selector-id="box"
|
|
427
469
|
data-test-id="boxComponent"
|
|
428
470
|
>
|
|
429
|
-
|
|
471
|
+
<div
|
|
472
|
+
class="titleBox shrinkOff"
|
|
473
|
+
data-id="boxComponent"
|
|
474
|
+
data-selector-id="box"
|
|
475
|
+
data-test-id="boxComponent"
|
|
476
|
+
>
|
|
477
|
+
<div
|
|
478
|
+
class="value basisAuto shrinkOn"
|
|
479
|
+
data-id="boxComponent"
|
|
480
|
+
data-selector-id="box"
|
|
481
|
+
data-test-id="boxComponent"
|
|
482
|
+
>
|
|
483
|
+
Apple
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
430
486
|
</div>
|
|
431
487
|
</li>
|
|
432
488
|
<li
|
|
@@ -443,12 +499,26 @@ exports[`AdvancedMultiSelect rendering the options array with only objects using
|
|
|
443
499
|
tabindex="0"
|
|
444
500
|
>
|
|
445
501
|
<div
|
|
446
|
-
class="
|
|
502
|
+
class="leftBox grow basis shrinkOff"
|
|
447
503
|
data-id="boxComponent"
|
|
448
504
|
data-selector-id="box"
|
|
449
505
|
data-test-id="boxComponent"
|
|
450
506
|
>
|
|
451
|
-
|
|
507
|
+
<div
|
|
508
|
+
class="titleBox shrinkOff"
|
|
509
|
+
data-id="boxComponent"
|
|
510
|
+
data-selector-id="box"
|
|
511
|
+
data-test-id="boxComponent"
|
|
512
|
+
>
|
|
513
|
+
<div
|
|
514
|
+
class="value basisAuto shrinkOn"
|
|
515
|
+
data-id="boxComponent"
|
|
516
|
+
data-selector-id="box"
|
|
517
|
+
data-test-id="boxComponent"
|
|
518
|
+
>
|
|
519
|
+
Orange
|
|
520
|
+
</div>
|
|
521
|
+
</div>
|
|
452
522
|
</div>
|
|
453
523
|
</li>
|
|
454
524
|
</div>
|