@zohodesk/components 1.0.0-temp-211.2 → 1.0.0-temp-217
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 +118 -31
- package/es/AvatarTeam/props/propTypes.js +2 -1
- package/es/CheckBox/CheckBox.js +6 -5
- package/es/CheckBox/CheckBox.module.css +5 -2
- package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +64 -64
- package/es/DateTime/CalendarView.js +17 -12
- package/es/DateTime/DateTime.js +26 -8
- package/es/DateTime/DateTime.module.css +5 -5
- package/es/DateTime/DateWidget.js +13 -2
- package/es/DateTime/DaysRow.js +3 -2
- package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +7 -7
- package/es/DateTime/props/defaultProps.js +9 -3
- package/es/DateTime/props/propTypes.js +16 -4
- package/es/DropBox/DropBoxElement/DropBoxElement.js +3 -1
- package/es/DropBox/DropBoxElement/__tests__/__snapshots__/DropBoxElement.spec.js.snap +1 -0
- package/es/DropBox/__tests__/__snapshots__/DropBox.spec.js.snap +1 -0
- package/es/DropDown/__tests__/__snapshots__/DropDown.spec.js.snap +1 -0
- package/es/ListItem/ListItemWithAvatar.js +7 -3
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2 -2
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +1 -1
- package/es/ListItem/props/propTypes.js +6 -1
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +4 -2
- package/es/MultiSelect/AdvancedMultiSelect.js +4 -2
- package/es/MultiSelect/MultiSelect.js +11 -3
- package/es/MultiSelect/props/propTypes.js +6 -3
- package/es/Popup/Popup.js +125 -7
- package/es/Popup/intersectionObserver.js +49 -0
- package/es/Popup/props/propTypes.js +30 -0
- package/es/Radio/Radio.js +9 -7
- package/es/Radio/Radio.module.css +1 -1
- package/es/Radio/__tests__/__snapshots__/Radio.spec.js.snap +77 -77
- package/es/Responsive/ResizeObserver.js +21 -85
- package/es/Responsive/ResizeObserverWithPolyfill.js +140 -0
- package/es/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1 -0
- package/es/Select/GroupSelect.js +15 -3
- package/es/Select/props/defaultProps.js +2 -1
- package/es/Select/props/propTypes.js +5 -1
- package/es/Tag/Tag.js +10 -3
- package/es/Tag/props/defaultProps.js +2 -1
- package/es/Tag/props/propTypes.js +7 -1
- package/es/TextBox/TextBox.js +1 -1
- package/es/Textarea/Textarea.js +4 -2
- package/es/Textarea/Textarea.module.css +1 -1
- package/es/Textarea/__tests__/__snapshots__/Textarea.spec.js.snap +41 -41
- package/es/Textarea/props/propTypes.js +2 -1
- package/es/Typography/Typography.js +38 -0
- package/es/Typography/css/Typography.module.css +489 -0
- package/es/Typography/css/cssJSLogic.js +56 -0
- package/es/Typography/props/defaultProps.js +8 -0
- package/es/Typography/props/propTypes.js +27 -0
- package/es/Typography/utils/index.js +50 -0
- package/es/index.js +1 -1
- package/es/v1/AppContainer/AppContainer.js +0 -6
- package/es/v1/DateTime/CalendarView.js +9 -6
- package/es/v1/DateTime/DateTime.js +18 -4
- package/es/v1/DateTime/DateWidget.js +5 -1
- package/es/v1/DateTime/DaysRow.js +3 -2
- package/es/v1/DateTime/props/defaultProps.js +9 -3
- package/es/v1/DateTime/props/propTypes.js +11 -4
- package/es/v1/MultiSelect/MultiSelect.js +7 -1
- package/es/v1/Select/GroupSelect.js +5 -0
- package/es/v1/Typography/Typography.js +1 -1
- package/lib/AvatarTeam/props/propTypes.js +3 -1
- package/lib/CheckBox/CheckBox.js +5 -4
- package/lib/CheckBox/CheckBox.module.css +5 -2
- package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +64 -64
- package/lib/DateTime/CalendarView.js +17 -12
- package/lib/DateTime/DateTime.js +38 -9
- package/lib/DateTime/DateTime.module.css +5 -5
- package/lib/DateTime/DateWidget.js +13 -2
- package/lib/DateTime/DaysRow.js +3 -2
- package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +7 -7
- package/lib/DateTime/props/defaultProps.js +9 -3
- package/lib/DateTime/props/propTypes.js +16 -4
- package/lib/DropBox/DropBoxElement/DropBoxElement.js +3 -1
- package/lib/DropBox/DropBoxElement/__tests__/__snapshots__/DropBoxElement.spec.js.snap +1 -0
- package/lib/DropBox/__tests__/__snapshots__/DropBox.spec.js.snap +1 -0
- package/lib/DropDown/__tests__/__snapshots__/DropDown.spec.js.snap +1 -0
- package/lib/ListItem/ListItemWithAvatar.js +8 -4
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2 -2
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +1 -1
- package/lib/ListItem/props/propTypes.js +8 -1
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +4 -2
- package/lib/MultiSelect/AdvancedMultiSelect.js +4 -2
- package/lib/MultiSelect/MultiSelect.js +11 -3
- package/lib/MultiSelect/props/propTypes.js +8 -6
- package/lib/Popup/Popup.js +135 -8
- package/lib/Popup/intersectionObserver.js +72 -0
- package/lib/Popup/props/propTypes.js +51 -0
- package/lib/Radio/Radio.js +10 -7
- package/lib/Radio/Radio.module.css +1 -1
- package/lib/Radio/__tests__/__snapshots__/Radio.spec.js.snap +77 -77
- package/lib/Responsive/ResizeObserver.js +20 -88
- package/lib/Responsive/ResizeObserverWithPolyfill.js +168 -0
- package/lib/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1 -0
- package/lib/Select/GroupSelect.js +17 -5
- package/lib/Select/props/defaultProps.js +2 -1
- package/lib/Select/props/propTypes.js +5 -1
- package/lib/Tag/Tag.js +10 -5
- package/lib/Tag/props/defaultProps.js +2 -1
- package/lib/Tag/props/propTypes.js +9 -1
- package/lib/TextBox/TextBox.js +1 -1
- package/lib/Textarea/Textarea.js +4 -2
- package/lib/Textarea/Textarea.module.css +1 -1
- package/lib/Textarea/__tests__/__snapshots__/Textarea.spec.js.snap +41 -41
- package/lib/Textarea/props/propTypes.js +2 -1
- package/lib/Typography/Typography.js +56 -0
- package/lib/Typography/css/Typography.module.css +489 -0
- package/lib/Typography/css/cssJSLogic.js +48 -0
- package/lib/Typography/props/defaultProps.js +15 -0
- package/lib/Typography/props/propTypes.js +38 -0
- package/lib/Typography/utils/index.js +59 -0
- package/lib/index.js +1 -1
- package/lib/v1/AppContainer/AppContainer.js +0 -12
- package/lib/v1/DateTime/CalendarView.js +9 -6
- package/lib/v1/DateTime/DateTime.js +27 -4
- package/lib/v1/DateTime/DateWidget.js +5 -1
- package/lib/v1/DateTime/DaysRow.js +3 -2
- package/lib/v1/DateTime/props/defaultProps.js +9 -3
- package/lib/v1/DateTime/props/propTypes.js +11 -4
- package/lib/v1/MultiSelect/MultiSelect.js +7 -1
- package/lib/v1/Select/GroupSelect.js +5 -0
- package/lib/v1/Typography/Typography.js +2 -2
- package/package.json +8 -8
- package/propValidationArg.json +1 -1
- /package/es/v1/Typography/css/{Typography.module.css → v1_Typography.module.css} +0 -0
- /package/lib/v1/Typography/css/{Typography.module.css → v1_Typography.module.css} +0 -0
package/es/Popup/Popup.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**** Libraries ****/
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import hoistStatics from 'hoist-non-react-statics';
|
|
4
|
+
import { PopupPropTypes, ContextTypes } from './props/propTypes';
|
|
5
5
|
/**** Methods ****/
|
|
6
6
|
|
|
7
7
|
import { debounce, isDescendant, isTextSelected, cancelBubblingEffect } from '../utils/Common.js';
|
|
8
8
|
import viewPort from './viewPort';
|
|
9
9
|
import { absolutePositionMapping, rtlAbsolutePositionMapping, rtlFixedPositionMapping } from './PositionMapping.js';
|
|
10
10
|
import ResizeObserver from '@zohodesk/virtualizer/lib/commons/ResizeObserver.js';
|
|
11
|
+
import { addIntersectionObserver, removeIntersectionObserver } from './intersectionObserver';
|
|
11
12
|
let lastOpenedGroup = [];
|
|
12
13
|
let popups = {};
|
|
13
14
|
|
|
@@ -89,6 +90,14 @@ const Popup = function (Component) {
|
|
|
89
90
|
this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
|
|
90
91
|
this.handleDocumentFocus = this.handleDocumentFocus.bind(this);
|
|
91
92
|
this.handleGetNeedPrevent = this.handleGetNeedPrevent.bind(this);
|
|
93
|
+
this.handleBlockScroll = this.handleBlockScroll.bind(this);
|
|
94
|
+
this.handlePositionChange = this.handlePositionChange.bind(this);
|
|
95
|
+
this.preventKeyboardScroll = this.preventKeyboardScroll.bind(this);
|
|
96
|
+
this.addScrollBlockListeners = this.addScrollBlockListeners.bind(this);
|
|
97
|
+
this.removeScrollBlockListeners = this.removeScrollBlockListeners.bind(this);
|
|
98
|
+
this.handleAddingScrollBlock = this.handleAddingScrollBlock.bind(this);
|
|
99
|
+
this.handleRemovingScrollBlock = this.handleRemovingScrollBlock.bind(this);
|
|
100
|
+
this.handleIntersectionObserver = this.handleIntersectionObserver.bind(this);
|
|
92
101
|
this.popupObserver = new ResizeObserver(this.handlePopupResize); //dropBoxSize
|
|
93
102
|
|
|
94
103
|
this.size = null;
|
|
@@ -101,6 +110,7 @@ const Popup = function (Component) {
|
|
|
101
110
|
scrollDebounceTime
|
|
102
111
|
} = this.getScrollDebounceTime(this);
|
|
103
112
|
this.handleScroll = debounce(this.handleScroll.bind(this), scrollDebounceTime);
|
|
113
|
+
this.handleDebouncedPositionChange = debounce(this.handlePositionChange.bind(this), 100);
|
|
104
114
|
}
|
|
105
115
|
|
|
106
116
|
componentDidMount() {
|
|
@@ -154,6 +164,12 @@ const Popup = function (Component) {
|
|
|
154
164
|
this.size = null;
|
|
155
165
|
this.popupObserver.disconnect();
|
|
156
166
|
}
|
|
167
|
+
|
|
168
|
+
if (isPopupReady) {
|
|
169
|
+
this.handleAddingScrollBlock();
|
|
170
|
+
} else {
|
|
171
|
+
this.handleRemovingScrollBlock();
|
|
172
|
+
}
|
|
157
173
|
}
|
|
158
174
|
}
|
|
159
175
|
|
|
@@ -169,6 +185,7 @@ const Popup = function (Component) {
|
|
|
169
185
|
|
|
170
186
|
return res;
|
|
171
187
|
}, popups);
|
|
188
|
+
this.handleRemovingScrollBlock();
|
|
172
189
|
let noPopups = true;
|
|
173
190
|
|
|
174
191
|
for (const i in popups) {
|
|
@@ -193,6 +210,106 @@ const Popup = function (Component) {
|
|
|
193
210
|
}
|
|
194
211
|
}
|
|
195
212
|
|
|
213
|
+
handleAddingScrollBlock() {
|
|
214
|
+
const {
|
|
215
|
+
isAbsolutePositioningNeeded,
|
|
216
|
+
isOutsideScrollBlocked
|
|
217
|
+
} = this.props;
|
|
218
|
+
|
|
219
|
+
if (isOutsideScrollBlocked && !isAbsolutePositioningNeeded) {
|
|
220
|
+
addIntersectionObserver(this.placeHolderElement, this.handleIntersectionObserver);
|
|
221
|
+
this.addScrollBlockListeners();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
handleRemovingScrollBlock() {
|
|
226
|
+
const {
|
|
227
|
+
isAbsolutePositioningNeeded,
|
|
228
|
+
isOutsideScrollBlocked
|
|
229
|
+
} = this.props;
|
|
230
|
+
|
|
231
|
+
if (isOutsideScrollBlocked && !isAbsolutePositioningNeeded) {
|
|
232
|
+
removeIntersectionObserver(this.placeHolderElement, this.handleIntersectionObserver);
|
|
233
|
+
this.removeScrollBlockListeners();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
addScrollBlockListeners() {
|
|
238
|
+
document.addEventListener('wheel', this.handleBlockScroll, {
|
|
239
|
+
capture: true,
|
|
240
|
+
passive: false
|
|
241
|
+
});
|
|
242
|
+
document.addEventListener('touchmove', this.handleBlockScroll, {
|
|
243
|
+
capture: true,
|
|
244
|
+
passive: false
|
|
245
|
+
});
|
|
246
|
+
document.addEventListener('scroll', this.handleDebouncedPositionChange, {
|
|
247
|
+
capture: true,
|
|
248
|
+
passive: false
|
|
249
|
+
});
|
|
250
|
+
document.addEventListener('keydown', this.preventKeyboardScroll, {
|
|
251
|
+
capture: true,
|
|
252
|
+
passive: false
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
removeScrollBlockListeners() {
|
|
257
|
+
document.removeEventListener('wheel', this.handleBlockScroll, {
|
|
258
|
+
capture: true,
|
|
259
|
+
passive: false
|
|
260
|
+
});
|
|
261
|
+
document.removeEventListener('touchmove', this.handleBlockScroll, {
|
|
262
|
+
capture: true,
|
|
263
|
+
passive: false
|
|
264
|
+
});
|
|
265
|
+
document.removeEventListener('scroll', this.handleDebouncedPositionChange, {
|
|
266
|
+
capture: true,
|
|
267
|
+
passive: false
|
|
268
|
+
});
|
|
269
|
+
document.removeEventListener('keydown', this.preventKeyboardScroll, {
|
|
270
|
+
capture: true,
|
|
271
|
+
passive: false
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
handleBlockScroll(event) {
|
|
276
|
+
// const targetElement = this.placeHolderElement;
|
|
277
|
+
const containerElement = this.dropElement;
|
|
278
|
+
|
|
279
|
+
if (containerElement && containerElement !== event.target && !containerElement.contains(event.target)) {
|
|
280
|
+
// --- Scroll exclude Target & Container elements --- For reference. Will adopt in future
|
|
281
|
+
// if(
|
|
282
|
+
// (containerElement && (containerElement !== event.target && !containerElement.contains(event.target)))
|
|
283
|
+
// && (targetElement && (targetElement !== event.target && !targetElement.contains(event.target)))
|
|
284
|
+
// ) {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
handlePositionChange(event) {
|
|
290
|
+
const targetElement = this.placeHolderElement;
|
|
291
|
+
const containerElement = this.dropElement;
|
|
292
|
+
|
|
293
|
+
if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && targetElement && targetElement !== event.target && !targetElement.contains(event.target) && event.target.contains(targetElement)) {
|
|
294
|
+
this.handlePopupPosition(this.state.position); // this.closePopupOnly(event);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
preventKeyboardScroll(event) {
|
|
299
|
+
const containerElement = this.dropElement;
|
|
300
|
+
const keys = [32, 37, 38, 39, 40]; // Space, Arrow keys
|
|
301
|
+
|
|
302
|
+
if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && keys.includes(event.keyCode)) {
|
|
303
|
+
event.preventDefault();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
handleIntersectionObserver(entry) {
|
|
308
|
+
if (entry.intersectionRatio === 0) {
|
|
309
|
+
this.closePopupOnly();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
196
313
|
getGroup() {
|
|
197
314
|
const {
|
|
198
315
|
popupGroup
|
|
@@ -523,13 +640,15 @@ const Popup = function (Component) {
|
|
|
523
640
|
} = betterPosition || {};
|
|
524
641
|
const {
|
|
525
642
|
left: oldLeft = '',
|
|
526
|
-
top: oldTop = ''
|
|
643
|
+
top: oldTop = '',
|
|
644
|
+
bottom: oldBottom = ''
|
|
527
645
|
} = positionsOffset[position] || {};
|
|
528
646
|
const {
|
|
529
647
|
left = '',
|
|
530
|
-
top = ''
|
|
648
|
+
top = '',
|
|
649
|
+
bottom = ''
|
|
531
650
|
} = viewsOffset[view] || {};
|
|
532
|
-
const changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top; // let isInViewPort = viewPort.isInViewPort(
|
|
651
|
+
const changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top || oldBottom !== bottom; // let isInViewPort = viewPort.isInViewPort(
|
|
533
652
|
// placeHolderElement,
|
|
534
653
|
// scrollContainer
|
|
535
654
|
// );
|
|
@@ -635,9 +754,8 @@ const Popup = function (Component) {
|
|
|
635
754
|
}
|
|
636
755
|
|
|
637
756
|
Popup.displayName = Component.displayName || Component.name || Popup.name;
|
|
638
|
-
Popup.contextTypes =
|
|
639
|
-
|
|
640
|
-
};
|
|
757
|
+
Popup.contextTypes = ContextTypes;
|
|
758
|
+
Popup.propTypes = PopupPropTypes;
|
|
641
759
|
return hoistStatics(Popup, Component);
|
|
642
760
|
};
|
|
643
761
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
let observerCallbacks = null;
|
|
2
|
+
let intersectionObserver = null;
|
|
3
|
+
|
|
4
|
+
function handleObserverCallbacks(entries) {
|
|
5
|
+
entries.forEach(entry => {
|
|
6
|
+
let oldCallbacks = observerCallbacks.get(entry.target);
|
|
7
|
+
|
|
8
|
+
if (Array.isArray(oldCallbacks) && oldCallbacks.length) {
|
|
9
|
+
oldCallbacks.forEach(callback => {
|
|
10
|
+
callback && callback(entry);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function addIntersectionObserver(element, callback, options) {
|
|
17
|
+
if (!!element && typeof callback == 'function') {
|
|
18
|
+
if (intersectionObserver === null && observerCallbacks === null) {
|
|
19
|
+
intersectionObserver = new IntersectionObserver(entries => {
|
|
20
|
+
handleObserverCallbacks(entries);
|
|
21
|
+
}, options);
|
|
22
|
+
observerCallbacks = new Map();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
intersectionObserver.observe(element);
|
|
26
|
+
let oldCallbacks = observerCallbacks.get(element) || [];
|
|
27
|
+
observerCallbacks.set(element, [...oldCallbacks, callback]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function removeIntersectionObserver(element, callback) {
|
|
31
|
+
if (!!element && typeof callback == 'function') {
|
|
32
|
+
let oldCallbacks = observerCallbacks ? observerCallbacks.get(element) : null;
|
|
33
|
+
|
|
34
|
+
if (Array.isArray(oldCallbacks)) {
|
|
35
|
+
let callbacks = oldCallbacks.filter(handler => handler !== callback);
|
|
36
|
+
|
|
37
|
+
if (intersectionObserver && callbacks.length === 0) {
|
|
38
|
+
observerCallbacks.delete(element);
|
|
39
|
+
intersectionObserver.unobserve(element);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (intersectionObserver && observerCallbacks && observerCallbacks.size === 0) {
|
|
44
|
+
intersectionObserver.disconnect();
|
|
45
|
+
intersectionObserver = null;
|
|
46
|
+
observerCallbacks = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
export const ContextTypes = {
|
|
3
|
+
direction: PropTypes.string
|
|
4
|
+
};
|
|
5
|
+
export const PopupPropTypes = {
|
|
6
|
+
popupGroup: PropTypes.string,
|
|
7
|
+
isArrow: PropTypes.bool,
|
|
8
|
+
isPopupOpen: PropTypes.bool,
|
|
9
|
+
closeOnScroll: PropTypes.bool,
|
|
10
|
+
isOutsideScrollBlocked: PropTypes.bool,
|
|
11
|
+
needResizeHandling: PropTypes.bool,
|
|
12
|
+
isAbsolutePositioningNeeded: PropTypes.bool,
|
|
13
|
+
scrollDebounceTime: PropTypes.number,
|
|
14
|
+
customOrder: PropTypes.arrayOf(PropTypes.string),
|
|
15
|
+
checkBeforeClose: PropTypes.func
|
|
16
|
+
};
|
|
17
|
+
export const PopupWrappersPropTypes = {
|
|
18
|
+
openPopupOnly: PropTypes.func,
|
|
19
|
+
closePopupOnly: PropTypes.func,
|
|
20
|
+
togglePopup: PropTypes.func,
|
|
21
|
+
removeClose: PropTypes.func,
|
|
22
|
+
isPopupReady: PropTypes.bool,
|
|
23
|
+
position: PropTypes.oneOf(['bottomRight', 'bottomLeft', 'bottomCenter', 'topRight', 'topLeft', 'topCenter', 'rightTop', 'rightBottom', 'rightCenter', 'leftTop', 'leftBottom', 'leftCenter']),
|
|
24
|
+
getTargetRef: PropTypes.func,
|
|
25
|
+
getContainerRef: PropTypes.func,
|
|
26
|
+
...PopupPropTypes,
|
|
27
|
+
isRestrictScroll: PropTypes.bool,
|
|
28
|
+
positionsOffset: PropTypes.object,
|
|
29
|
+
targetOffset: PropTypes.object
|
|
30
|
+
};
|
package/es/Radio/Radio.js
CHANGED
|
@@ -4,6 +4,7 @@ import { defaultProps } from './props/defaultProps';
|
|
|
4
4
|
import { propTypes } from './props/propTypes';
|
|
5
5
|
import Label from '../Label/Label';
|
|
6
6
|
import { Container, Box } from '../Layout';
|
|
7
|
+
import CssProvider from '../Provider/CssProvider';
|
|
7
8
|
import style from './Radio.module.css';
|
|
8
9
|
export default class Radio extends React.Component {
|
|
9
10
|
constructor(props) {
|
|
@@ -57,8 +58,9 @@ export default class Radio extends React.Component {
|
|
|
57
58
|
customRadio = '',
|
|
58
59
|
customLabel = ''
|
|
59
60
|
} = customClass;
|
|
60
|
-
let accessMode = isReadOnly ? style.readonly : disabled ?
|
|
61
|
+
let accessMode = isReadOnly ? style.readonly : disabled ? CssProvider('isDisabled') : style.pointer;
|
|
61
62
|
let toolTip = disabled ? disabledTitle : title ? title : null;
|
|
63
|
+
const isEditable = !(isReadOnly || disabled);
|
|
62
64
|
let {
|
|
63
65
|
ariaHidden,
|
|
64
66
|
role = 'radio',
|
|
@@ -66,7 +68,7 @@ export default class Radio extends React.Component {
|
|
|
66
68
|
ariaChecked = checked,
|
|
67
69
|
ariaLabel,
|
|
68
70
|
ariaLabelledby,
|
|
69
|
-
ariaReadonly =
|
|
71
|
+
ariaReadonly = !isEditable ? true : false
|
|
70
72
|
} = a11y;
|
|
71
73
|
let {
|
|
72
74
|
ContainerProps = {},
|
|
@@ -78,11 +80,11 @@ export default class Radio extends React.Component {
|
|
|
78
80
|
isInline: text ? false : true,
|
|
79
81
|
alignBox: "row",
|
|
80
82
|
align: "both",
|
|
81
|
-
className: `${style.container} ${active && !disabled ? style.active : ''} ${accessMode} ${
|
|
83
|
+
className: `${style.container} ${active && !disabled ? style.active : ''} ${accessMode} ${!isEditable ? '' : style.hoverEfffect} ${checked ? style.checked : ''} ${customRadioWrap}`,
|
|
82
84
|
"data-title": toolTip,
|
|
83
85
|
onClick: !isReadOnly && !disabled ? this.onChange : '',
|
|
84
86
|
"aria-checked": ariaChecked,
|
|
85
|
-
tabindex:
|
|
87
|
+
tabindex: !isEditable || ariaHidden ? '-1' : tabIndex || '0',
|
|
86
88
|
eleRef: this.handleGetRef,
|
|
87
89
|
role: role,
|
|
88
90
|
"aria-Hidden": ariaHidden,
|
|
@@ -92,7 +94,7 @@ export default class Radio extends React.Component {
|
|
|
92
94
|
...ContainerProps
|
|
93
95
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
94
96
|
className: `${style.radio} ${checked ? `${style[`rdBox${palette}`]}` : ''}
|
|
95
|
-
${
|
|
97
|
+
${!isEditable ? '' : `${style[`hover${palette}`]}`} ${style[size]} ${isFilled ? style.filled : ''} ${style[`centerPath${palette}`]} ${customRadio} ${!isEditable ? `${style.disabled}` : ''}`
|
|
96
98
|
}, /*#__PURE__*/React.createElement("input", {
|
|
97
99
|
type: "hidden",
|
|
98
100
|
id: id,
|
|
@@ -115,7 +117,7 @@ export default class Radio extends React.Component {
|
|
|
115
117
|
className: `${style.centerPath}`
|
|
116
118
|
}) : null))), text && /*#__PURE__*/React.createElement(Box, {
|
|
117
119
|
flexible: true,
|
|
118
|
-
className: style.text
|
|
120
|
+
className: `${style.text} ${disabled ? `${style.disabled}` : ''}`
|
|
119
121
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
120
122
|
text: text,
|
|
121
123
|
palette: labelPalette,
|
|
@@ -126,7 +128,7 @@ export default class Radio extends React.Component {
|
|
|
126
128
|
variant: variant,
|
|
127
129
|
title: toolTip ? toolTip : text,
|
|
128
130
|
customClass: `${checked && active ? `${style[`${palette}checkedActive`]}` : ''}
|
|
129
|
-
${style[`${palette}Label`]} ${
|
|
131
|
+
${style[`${palette}Label`]} ${isEditable ? style.pointer : ''} ${isReadOnly ? style.readonly : ''} ${customLabel}`,
|
|
130
132
|
...LabelProps
|
|
131
133
|
})), children, renderRightPlaceholderNode ? renderRightPlaceholderNode : null);
|
|
132
134
|
}
|