@zohodesk/components 1.4.4 → 1.4.6
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 +25 -0
- package/es/AppContainer/AppContainer.js +1 -1
- package/es/DropBox/DropBox.js +3 -3
- 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/Popup/Popup.js +196 -92
- package/es/Popup/Registry.js +35 -0
- package/es/Popup/viewPort.js +15 -16
- package/es/Provider/Config.js +4 -1
- package/es/RippleEffect/RippleEffect.module.css +3 -2
- package/es/css.js +4 -4
- package/lib/AppContainer/AppContainer.js +1 -1
- package/lib/DropBox/DropBox.js +3 -3
- 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/Popup/Popup.js +265 -147
- package/lib/Popup/Registry.js +45 -0
- package/lib/Popup/viewPort.js +15 -16
- package/lib/Provider/Config.js +4 -1
- package/lib/RippleEffect/RippleEffect.module.css +3 -2
- package/lib/css.js +4 -4
- package/package.json +11 -10
- package/result.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
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.6
|
|
6
|
+
|
|
7
|
+
- **Popup**
|
|
8
|
+
- Added fixed popup scroll block behavior support to iframe elements (same-origin only).
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# 1.4.5
|
|
12
|
+
|
|
13
|
+
- **Portal**
|
|
14
|
+
- Introduced the `Portal` component to act as a React portal.
|
|
15
|
+
- Supported `getPortalContainer`, `portalPrefix` from the library config.
|
|
16
|
+
|
|
17
|
+
- **Popup**
|
|
18
|
+
- Fixed the auto-repositioning issue during fixed popup resize and improved the position calculation logic.
|
|
19
|
+
|
|
20
|
+
- **Modal**
|
|
21
|
+
- Refactored to use the new `Portal` component for rendering, resolving unwanted rendering issues.
|
|
22
|
+
- Supported `getRootElement` & `portalPrefix` from the library config.
|
|
23
|
+
|
|
24
|
+
- **Dropbox**
|
|
25
|
+
- Updated to use the new `Portal` component for rendering, resolving unwanted rendering issues.
|
|
26
|
+
|
|
27
|
+
- **RippleEffect**
|
|
28
|
+
- Enhanced CSS specificity for `secondary` active background and border color variables.
|
|
29
|
+
|
|
5
30
|
# 1.4.4
|
|
6
31
|
|
|
7
32
|
- **Button** - Strikethrough effect on disabled buttons supported through `shouldStrikeThroughDisabled` prop.
|
|
@@ -8,7 +8,7 @@ import '@zohodesk/variables/assets/colorVariables.module.css';
|
|
|
8
8
|
import '@zohodesk/variables/assets/dotVariables.module.css';
|
|
9
9
|
import '@zohodesk/variables/assets/sizeVariables.module.css';
|
|
10
10
|
import '@zohodesk/variables/assets/fontsizeVariables.module.css';
|
|
11
|
-
import '@zohodesk/variables/
|
|
11
|
+
import '@zohodesk/variables/es/fontFamilyVariables.module.css';
|
|
12
12
|
import '@zohodesk/variables/assets/transitionVariables.module.css';
|
|
13
13
|
import '@zohodesk/variables/assets/no_transitionVariables.module.css';
|
|
14
14
|
import "../common/a11y.module.css";
|
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/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
|
+
`;
|