@zohodesk/components 1.4.3 → 1.4.5
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/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/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/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/v1/Button/props/propTypes.js +2 -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/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/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/v1/Button/props/propTypes.js +2 -1
- package/package.json +7 -7
- package/result.json +1 -1
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
|
+
`;
|
package/es/Popup/viewPort.js
CHANGED
|
@@ -108,24 +108,23 @@ let viewPort = {
|
|
|
108
108
|
let paddingSpace = 5; // space between target and relative element
|
|
109
109
|
|
|
110
110
|
let arrowSize = needArrow ? 10 : 0;
|
|
111
|
-
|
|
112
|
-
rect.width = rect.width + (needArrow ? arrowSize : paddingSpace);
|
|
111
|
+
let padding = needArrow ? arrowSize : paddingSpace;
|
|
113
112
|
let arrowHorizontalBalancePx = !isAbsolute && needArrow ? 30 : 0;
|
|
114
113
|
let arrowVerticalBalancePx = !isAbsolute && needArrow ? 27 : 0;
|
|
115
|
-
let bottomOverFlow = rect.height > relativeBoxGap.bottom;
|
|
116
|
-
let topOverFlow = rect.height > relativeBoxGap.top;
|
|
117
|
-
let rightOverFlow = rect.width > relativeBoxGap.right;
|
|
118
|
-
let leftOverFlow = rect.width > relativeBoxGap.left;
|
|
119
|
-
let horizontalCenterOverFlow = rect.width / 2 > relativeBoxGap.center.right || rect.width / 2 > relativeBoxGap.center.left;
|
|
120
|
-
let verticalCenterOverFlow = rect.height / 2 > relativeBoxGap.center.top || rect.height / 2 > relativeBoxGap.center.bottom;
|
|
121
|
-
let horizontalLeftToRightOverFlow = rect.width > relativeBoxRect.width + relativeBoxGap.right;
|
|
122
|
-
let horizontalCenterToRightOverFlow = rect.width > relativeBoxGap.center.right || arrowHorizontalBalancePx > relativeBoxGap.center.left;
|
|
123
|
-
let horizontalRightToLeft = rect.width > relativeBoxRect.width + relativeBoxGap.left;
|
|
124
|
-
let horizontalCenterToLeft = rect.width > relativeBoxGap.center.left || arrowHorizontalBalancePx > relativeBoxGap.center.right;
|
|
125
|
-
let verticalTopToBottomOverFlow = rect.height > relativeBoxRect.height + relativeBoxGap.bottom;
|
|
126
|
-
let verticalCenterToBottomOverFlow = rect.height > relativeBoxGap.center.bottom || arrowVerticalBalancePx > relativeBoxGap.center.top;
|
|
127
|
-
let verticalBottomToTopOverFlow = rect.height > relativeBoxRect.height + relativeBoxGap.top;
|
|
128
|
-
let verticalCenterToTopOverFlow = rect.height > relativeBoxGap.center.top || arrowVerticalBalancePx > relativeBoxGap.center.bottom;
|
|
114
|
+
let bottomOverFlow = rect.height + padding > relativeBoxGap.bottom;
|
|
115
|
+
let topOverFlow = rect.height + padding > relativeBoxGap.top;
|
|
116
|
+
let rightOverFlow = rect.width + padding > relativeBoxGap.right;
|
|
117
|
+
let leftOverFlow = rect.width + padding > relativeBoxGap.left;
|
|
118
|
+
let horizontalCenterOverFlow = rect.width / 2 + padding > relativeBoxGap.center.right || rect.width / 2 + padding > relativeBoxGap.center.left;
|
|
119
|
+
let verticalCenterOverFlow = rect.height / 2 + padding > relativeBoxGap.center.top || rect.height / 2 + padding > relativeBoxGap.center.bottom;
|
|
120
|
+
let horizontalLeftToRightOverFlow = rect.width + padding > relativeBoxRect.width + relativeBoxGap.right;
|
|
121
|
+
let horizontalCenterToRightOverFlow = rect.width + padding > relativeBoxGap.center.right || arrowHorizontalBalancePx > relativeBoxGap.center.left;
|
|
122
|
+
let horizontalRightToLeft = rect.width + padding > relativeBoxRect.width + relativeBoxGap.left;
|
|
123
|
+
let horizontalCenterToLeft = rect.width + padding > relativeBoxGap.center.left || arrowHorizontalBalancePx > relativeBoxGap.center.right;
|
|
124
|
+
let verticalTopToBottomOverFlow = rect.height + padding > relativeBoxRect.height + relativeBoxGap.bottom;
|
|
125
|
+
let verticalCenterToBottomOverFlow = rect.height + padding > relativeBoxGap.center.bottom || arrowVerticalBalancePx > relativeBoxGap.center.top;
|
|
126
|
+
let verticalBottomToTopOverFlow = rect.height + padding > relativeBoxRect.height + relativeBoxGap.top;
|
|
127
|
+
let verticalCenterToTopOverFlow = rect.height + padding > relativeBoxGap.center.top || arrowVerticalBalancePx > relativeBoxGap.center.bottom;
|
|
129
128
|
let views = {
|
|
130
129
|
bottomCenter: !(bottomOverFlow || horizontalCenterOverFlow),
|
|
131
130
|
bottomLeftToRight: !(bottomOverFlow || horizontalLeftToRightOverFlow),
|
package/es/Provider/Config.js
CHANGED
|
@@ -8,7 +8,10 @@ let id = {
|
|
|
8
8
|
direction: 'ltr',
|
|
9
9
|
tooltipDebounce: 175,
|
|
10
10
|
getTooltipContainer: () => {},
|
|
11
|
-
autoComplete: false
|
|
11
|
+
autoComplete: false,
|
|
12
|
+
portalPrefix: '',
|
|
13
|
+
getRootElement: () => {},
|
|
14
|
+
getPortalContainer: () => {}
|
|
12
15
|
};
|
|
13
16
|
export function getLibraryConfig(key) {
|
|
14
17
|
return id[key];
|
|
@@ -10,6 +10,7 @@ const LibraryContextProvider = _ref => {
|
|
|
10
10
|
coloredTagVariant,
|
|
11
11
|
hasTagColorInheritedToText,
|
|
12
12
|
shouldIndicateSwitchState,
|
|
13
|
+
shouldStrikeThroughDisabledButton,
|
|
13
14
|
children
|
|
14
15
|
} = _ref;
|
|
15
16
|
const [value, setValue] = useState({
|
|
@@ -17,7 +18,8 @@ const LibraryContextProvider = _ref => {
|
|
|
17
18
|
direction,
|
|
18
19
|
coloredTagVariant,
|
|
19
20
|
hasTagColorInheritedToText,
|
|
20
|
-
shouldIndicateSwitchState
|
|
21
|
+
shouldIndicateSwitchState,
|
|
22
|
+
shouldStrikeThroughDisabledButton
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
function setGlobalContext(key, data) {
|
|
@@ -41,13 +43,15 @@ LibraryContextProvider.propTypes = {
|
|
|
41
43
|
coloredTagVariant: PropTypes.oneOf(['bold', 'subtle', 'minimal']),
|
|
42
44
|
hasTagColorInheritedToText: PropTypes.bool,
|
|
43
45
|
direction: PropTypes.string,
|
|
44
|
-
shouldIndicateSwitchState: PropTypes.bool
|
|
46
|
+
shouldIndicateSwitchState: PropTypes.bool,
|
|
47
|
+
shouldStrikeThroughDisabledButton: PropTypes.bool
|
|
45
48
|
};
|
|
46
49
|
LibraryContextProvider.defaultProps = {
|
|
47
50
|
isReducedMotion: getLibraryConfig('isReducedMotion'),
|
|
48
51
|
direction: getLibraryConfig('direction'),
|
|
49
52
|
coloredTagVariant: 'bold',
|
|
50
53
|
hasTagColorInheritedToText: true,
|
|
51
|
-
shouldIndicateSwitchState: false
|
|
54
|
+
shouldIndicateSwitchState: false,
|
|
55
|
+
shouldStrikeThroughDisabledButton: false
|
|
52
56
|
};
|
|
53
57
|
export default LibraryContextProvider;
|
|
@@ -100,9 +100,10 @@
|
|
|
100
100
|
{
|
|
101
101
|
background-color: var(--zdt_rippleeffect_secondary_bg);
|
|
102
102
|
}
|
|
103
|
-
.secondary.active {
|
|
103
|
+
.secondary.active, .hoverEffect:hover.secondary.active.bgHover {
|
|
104
104
|
background-color: var(--zdt_rippleeffect_secondary_active_bg);
|
|
105
105
|
}
|
|
106
|
-
.secondary.active.border
|
|
106
|
+
.secondary.active.border
|
|
107
|
+
.hoverEffect:hover.secondary.active.border {
|
|
107
108
|
border-color: var(--zdt_rippleeffect_secondary_active_border);
|
|
108
109
|
}
|
package/lib/Button/Button.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] =
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -15,6 +15,8 @@ var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("@zohodesk/utils");
|
|
17
17
|
|
|
18
|
+
var _ComponentRegistry = require("@zohodesk/dotkit/es/react/ComponentRegistry");
|
|
19
|
+
|
|
18
20
|
var _ButtonModule = _interopRequireDefault(require("./css/Button.module.css"));
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -26,8 +28,6 @@ Button text and children props?
|
|
|
26
28
|
use children for both cases
|
|
27
29
|
toLowerCase check needed?
|
|
28
30
|
*/
|
|
29
|
-
|
|
30
|
-
/* eslint css-modules/no-unused-class: [2, { markAsUsed: ['small','medium','large','xlarge','button_medium','button_small','primary','primaryfilled','danger','dangerfilled','plainprimary', 'plainsecondary', 'secondary', 'secondaryfilled', 'successFilled','tertiaryFilled'] }] */
|
|
31
31
|
function Button(props) {
|
|
32
32
|
var text = props.text,
|
|
33
33
|
disabled = props.disabled,
|
|
@@ -76,9 +76,16 @@ function Button(props) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
Button.defaultProps = _defaultProps.defaultProps;
|
|
79
|
-
Button.propTypes = _propTypes.propTypes;
|
|
79
|
+
Button.propTypes = _propTypes.propTypes;
|
|
80
|
+
|
|
81
|
+
var _default = (0, _ComponentRegistry.withComponentRegistrar)(Button, {
|
|
82
|
+
name: 'ZDC_Button'
|
|
83
|
+
}); // if (__DOCS__) {
|
|
80
84
|
// Button.docs = {
|
|
81
85
|
// componentGroup: 'Form Elements',
|
|
82
86
|
// folderName: 'Style Guide'
|
|
83
87
|
// };
|
|
84
|
-
// }
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
exports["default"] = _default;
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
.native:disabled {
|
|
42
|
-
pointer-events: none;
|
|
43
42
|
--button_cursor: not-allowed;
|
|
44
43
|
--button_opacity: 0.4;
|
|
45
44
|
}
|
|
@@ -144,7 +143,7 @@
|
|
|
144
143
|
--button_text_color: var(--zdt_button_default_text);
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
.plainprimary:hover {
|
|
146
|
+
.plainprimary:not(:disabled):hover {
|
|
148
147
|
--button_text_color: var(--zdt_button_plainprimary_hover_text);
|
|
149
148
|
}
|
|
150
149
|
|
|
@@ -152,7 +151,7 @@
|
|
|
152
151
|
--button_text_color: var(--zdt_button_danger_text);
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
.plaindanger:hover {
|
|
154
|
+
.plaindanger:not(:disabled):hover {
|
|
156
155
|
--button_text_color: var(--zdt_button_danger_hover_text);
|
|
157
156
|
}
|
|
158
157
|
|
|
@@ -160,7 +159,7 @@
|
|
|
160
159
|
--button_text_color: var(--zdt_button_success_text);
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
.plainsuccess:hover {
|
|
162
|
+
.plainsuccess:not(:disabled):hover {
|
|
164
163
|
--button_text_color: var(--zdt_button_success_hover_text);
|
|
165
164
|
}
|
|
166
165
|
|
|
@@ -168,7 +167,7 @@
|
|
|
168
167
|
--button_text_color: var(--zdt_button_secondary_text);
|
|
169
168
|
}
|
|
170
169
|
|
|
171
|
-
.plainsecondary:hover {
|
|
170
|
+
.plainsecondary:not(:disabled):hover {
|
|
172
171
|
--button_text_color: var(--zdt_button_secondary_hover_text);
|
|
173
172
|
}
|
|
174
173
|
|
|
@@ -184,7 +183,7 @@
|
|
|
184
183
|
--button_border_width: 1px;
|
|
185
184
|
}
|
|
186
185
|
|
|
187
|
-
.primary:hover {
|
|
186
|
+
.primary:not(:disabled):hover {
|
|
188
187
|
--button_border_color: var(--zdt_button_primary_hover_border);
|
|
189
188
|
--button_text_color: var(--zdt_button_primary_hover_text);
|
|
190
189
|
}
|
|
@@ -195,7 +194,7 @@
|
|
|
195
194
|
--button_text_color: var(--zdt_button_primaryfill_text);
|
|
196
195
|
}
|
|
197
196
|
|
|
198
|
-
.primaryfilled:hover {
|
|
197
|
+
.primaryfilled:not(:disabled):hover {
|
|
199
198
|
--button_bg_color: var(--zdt_button_primaryfill_hover_bg);
|
|
200
199
|
}
|
|
201
200
|
|
|
@@ -205,7 +204,7 @@
|
|
|
205
204
|
--button_text_color: var(--zdt_button_danger_text);
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
.danger:hover {
|
|
207
|
+
.danger:not(:disabled):hover {
|
|
209
208
|
--button_border_color: var(--zdt_button_danger_hover_border);
|
|
210
209
|
--button_text_color: var(--zdt_button_danger_hover_text);
|
|
211
210
|
}
|
|
@@ -216,7 +215,7 @@
|
|
|
216
215
|
--button_text_color: var(--zdt_button_success_text);
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
.success:hover {
|
|
218
|
+
.success:not(:disabled):hover {
|
|
220
219
|
--button_border_color: var(--zdt_button_success_hover_border);
|
|
221
220
|
--button_text_color: var(--zdt_button_success_hover_text);
|
|
222
221
|
}
|
|
@@ -227,7 +226,7 @@
|
|
|
227
226
|
--button_text_color: var(--zdt_button_dangerfill_text);
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
.dangerfilled:hover {
|
|
229
|
+
.dangerfilled:not(:disabled):hover {
|
|
231
230
|
--button_bg_color: var(--zdt_button_dangerfill_hover_bg);
|
|
232
231
|
}
|
|
233
232
|
|
|
@@ -237,7 +236,7 @@
|
|
|
237
236
|
--button_text_color: var(--zdt_button_secondary_text);
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
.secondary:hover {
|
|
239
|
+
.secondary:not(:disabled):hover {
|
|
241
240
|
--button_border_color: var(--zdt_button_secondary_hover_border);
|
|
242
241
|
--button_text_color: var(--zdt_button_secondary_hover_text);
|
|
243
242
|
}
|
|
@@ -248,18 +247,17 @@
|
|
|
248
247
|
--button_text_color: var(--zdt_button_secondary_text);
|
|
249
248
|
}
|
|
250
249
|
|
|
251
|
-
.secondaryfilled:hover {
|
|
250
|
+
.secondaryfilled:not(:disabled):hover {
|
|
252
251
|
--button_text_color: var(--zdt_button_secondary_hover_text);
|
|
253
252
|
}
|
|
254
253
|
|
|
255
254
|
.successfilled {
|
|
256
|
-
--button_border_color: var(--
|
|
255
|
+
--button_border_color: var(--zdt_button_primaryfill_border);
|
|
257
256
|
--button_bg_color: var(--zdt_button_successfill_bg);
|
|
258
257
|
--button_text_color: var(--zdt_button_dangerfill_text);
|
|
259
258
|
}
|
|
260
259
|
|
|
261
|
-
.successfilled:hover {
|
|
262
|
-
--button_border_color: var(--zdt_button_successfill_hover_border);
|
|
260
|
+
.successfilled:not(:disabled):hover {
|
|
263
261
|
--button_bg_color: var(--zdt_button_successfill_hover_bg);
|
|
264
262
|
}
|
|
265
263
|
|
|
@@ -269,7 +267,7 @@
|
|
|
269
267
|
--button_text_color: var(--zdt_button_dangerfill_text);
|
|
270
268
|
}
|
|
271
269
|
|
|
272
|
-
.tertiaryfilled:hover {
|
|
270
|
+
.tertiaryfilled:not(:disabled):hover {
|
|
273
271
|
--button_bg_color: var(--zdt_button_tertiaryfill_hover_bg);
|
|
274
272
|
}
|
|
275
273
|
|
|
@@ -572,4 +570,44 @@
|
|
|
572
570
|
|
|
573
571
|
.loader {
|
|
574
572
|
color: var(--dot_mirror)
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
[dir=ltr] .strike {
|
|
576
|
+
background-image: repeating-linear-gradient(120deg, var(--button_strike_color) 0 1px, transparent 1px 8px);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
[dir=rtl] .strike {
|
|
580
|
+
background-image: repeating-linear-gradient(-120deg, var(--button_strike_color) 0 1px, transparent 1px 8px);
|
|
581
|
+
}
|
|
582
|
+
.primaryStrike {
|
|
583
|
+
--button_strike_color: var(--zdt_button_primary_strike);
|
|
584
|
+
}
|
|
585
|
+
.primaryfilledStrike {
|
|
586
|
+
--button_strike_color: var(--zdt_button_primaryFilled_strike);
|
|
587
|
+
--button_border_color: var(--zdt_button_primaryfill_bg);
|
|
588
|
+
}
|
|
589
|
+
.dangerStrike {
|
|
590
|
+
--button_strike_color: var(--zdt_button_danger_strike);
|
|
591
|
+
}
|
|
592
|
+
.dangerfilledStrike {
|
|
593
|
+
--button_strike_color: var(--zdt_button_dangerFilled_strike);
|
|
594
|
+
--button_border_color: var(--zdt_button_dangerfill_bg);
|
|
595
|
+
}
|
|
596
|
+
.secondaryStrike {
|
|
597
|
+
--button_strike_color: var(--zdt_button_secondary_border);
|
|
598
|
+
}
|
|
599
|
+
.secondaryfilledStrike {
|
|
600
|
+
--button_strike_color: var(--zdt_button_secondaryFilled_strike);
|
|
601
|
+
--button_border_color: var(--zdt_button_secondaryfill_bg);
|
|
602
|
+
}
|
|
603
|
+
.tertiaryfilledStrike {
|
|
604
|
+
--button_strike_color: var(--zdt_button_tertiaryFilled_strike);
|
|
605
|
+
--button_border_color: var(--zdt_button_tertiaryfill_bg);
|
|
606
|
+
}
|
|
607
|
+
.successStrike {
|
|
608
|
+
--button_strike_color: var(--zdt_button_success_strike);
|
|
609
|
+
}
|
|
610
|
+
.successfilledStrike {
|
|
611
|
+
--button_strike_color: var(--zdt_button_successFilled_strike);
|
|
612
|
+
--button_border_color: var(--zdt_button_successfill_bg);
|
|
575
613
|
}
|
|
@@ -21,16 +21,20 @@ function cssJSLogic(_ref) {
|
|
|
21
21
|
size = props.size,
|
|
22
22
|
children = props.children,
|
|
23
23
|
palette = props.palette,
|
|
24
|
-
status = props.status
|
|
24
|
+
status = props.status,
|
|
25
|
+
disabled = props.disabled,
|
|
26
|
+
shouldStrikeThroughDisabled = props.shouldStrikeThroughDisabled;
|
|
25
27
|
var _customClass$customBu = customClass.customButton,
|
|
26
28
|
customButton = _customClass$customBu === void 0 ? '' : _customClass$customBu,
|
|
27
29
|
_customClass$customSt = customClass.customStatus,
|
|
28
30
|
customStatus = _customClass$customSt === void 0 ? '' : _customClass$customSt,
|
|
29
31
|
_customClass$customSt2 = customClass.customStatusSize,
|
|
30
32
|
customStatusSize = _customClass$customSt2 === void 0 ? '' : _customClass$customSt2;
|
|
33
|
+
var strikeExcludedPalettes = ['plainprimary', 'plainsecondary', 'plainDanger', 'plainSuccess'];
|
|
31
34
|
var paletteLower = palette.toLowerCase();
|
|
32
35
|
var statusLower = status.toLowerCase();
|
|
33
|
-
var
|
|
36
|
+
var canStrikeThrough = !strikeExcludedPalettes.includes(paletteLower);
|
|
37
|
+
var buttonClass = (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, customButton, !!customButton), _defineProperty(_compileClassNames, style.bold, isBold), _defineProperty(_compileClassNames, style["default"], !needAppearance), _defineProperty(_compileClassNames, style[paletteLower], needAppearance), _defineProperty(_compileClassNames, style.rounded, needAppearance && rounded), _defineProperty(_compileClassNames, style[size.toLowerCase()], needAppearance && !children), _defineProperty(_compileClassNames, style["".concat(size, "Btn")], needAppearance && children), _defineProperty(_compileClassNames, style["".concat(size, "Btn").concat(paletteLower)], needAppearance && children && rounded), _defineProperty(_compileClassNames, "".concat(style["".concat(paletteLower, "Strike")], " ").concat(style.strike), disabled && canStrikeThrough && shouldStrikeThroughDisabled), _defineProperty(_compileClassNames, style.loader, !!needAppearance && statusLower !== 'none'), _compileClassNames));
|
|
34
38
|
var loaderParentClass = (0, _utils.compileClassNames)((_compileClassNames2 = {}, _defineProperty(_compileClassNames2, customStatusSize, !!customStatusSize), _defineProperty(_compileClassNames2, style.loading, statusLower === 'loading'), _defineProperty(_compileClassNames2, style["".concat(size, "loading")], statusLower === 'loading'), _defineProperty(_compileClassNames2, style.successstate, statusLower != 'loading'), _compileClassNames2));
|
|
35
39
|
var loaderChildClass = (0, _utils.compileClassNames)((_compileClassNames3 = {}, _defineProperty(_compileClassNames3, customStatus, !!customStatus), _defineProperty(_compileClassNames3, style.loadingelement, statusLower === 'loading'), _defineProperty(_compileClassNames3, style["".concat(paletteLower, "element")], statusLower === 'loading'), _defineProperty(_compileClassNames3, style.successelement, statusLower != 'loading'), _defineProperty(_compileClassNames3, style["".concat(paletteLower, "success")], statusLower != 'loading'), _compileClassNames3));
|
|
36
40
|
return {
|
|
@@ -24,6 +24,7 @@ var propTypes = {
|
|
|
24
24
|
status: _propTypes["default"].oneOf(['loading', 'success', 'none']),
|
|
25
25
|
text: _propTypes["default"].string,
|
|
26
26
|
title: _propTypes["default"].string,
|
|
27
|
+
shouldStrikeThroughDisabled: _propTypes["default"].bool,
|
|
27
28
|
customClass: _propTypes["default"].shape({
|
|
28
29
|
customButton: _propTypes["default"].string,
|
|
29
30
|
customStatus: _propTypes["default"].string,
|
package/lib/DropBox/DropBox.js
CHANGED
|
@@ -11,7 +11,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _FocusScope = _interopRequireDefault(require("@zohodesk/a11y/es/FocusScope/FocusScope"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _Portal = _interopRequireDefault(require("../Modal/Portal/Portal"));
|
|
15
15
|
|
|
16
16
|
var _LibraryContextInit = _interopRequireDefault(require("../Provider/LibraryContextInit"));
|
|
17
17
|
|
|
@@ -90,13 +90,13 @@ function DropBox(props) {
|
|
|
90
90
|
}, props, {
|
|
91
91
|
zIndexStyle: zIndexStyle
|
|
92
92
|
}));
|
|
93
|
-
return isModel && isActive ? /*#__PURE__*/_react["default"].createElement(
|
|
93
|
+
return isModel && isActive ? /*#__PURE__*/_react["default"].createElement(_Portal["default"], {
|
|
94
94
|
portalId: portalId
|
|
95
95
|
}, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
96
96
|
className: "".concat(_DropBoxModule["default"].freezeLayer, " ").concat(_DropBoxModule["default"].freeze),
|
|
97
97
|
style: zIndexStyle,
|
|
98
98
|
onClick: _Common.stopPropagation
|
|
99
|
-
}), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/_react["default"].createElement(
|
|
99
|
+
}), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/_react["default"].createElement(_Portal["default"], {
|
|
100
100
|
portalId: portalId
|
|
101
101
|
}, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isRestrictScroll ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
102
102
|
className: _DropBoxModule["default"].freezeLayer,
|