@zohodesk/components 1.0.0-alpha-263 → 1.0.0-alpha-265
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/README.md +11 -0
- package/css_error.log +1 -0
- package/es/DateTime/DateTime.js +26 -65
- package/es/DateTime/dateFormatUtils/dateFormats.js +43 -0
- package/es/DateTime/dateFormatUtils/index.js +27 -0
- package/es/DateTime/props/propTypes.js +2 -1
- package/es/DropBox/DropBox.js +68 -244
- package/es/DropBox/DropBoxElement/DropBoxElement.js +118 -0
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +432 -0
- package/es/DropBox/DropBoxElement/css/cssJSLogic.js +89 -0
- package/es/DropBox/DropBoxElement/props/defaultProps.js +18 -0
- package/es/DropBox/DropBoxElement/props/propTypes.js +45 -0
- package/es/DropBox/DropBoxElement/useDropboxPosCalc.js +51 -0
- package/es/DropBox/css/DropBox.module.css +59 -0
- package/es/DropBox/css/cssJSLogic.js +14 -0
- package/es/DropBox/props/defaultProps.js +9 -17
- package/es/DropBox/props/propTypes.js +9 -43
- package/es/MultiSelect/AdvancedMultiSelect.js +0 -2
- package/es/MultiSelect/MultiSelect.js +0 -3
- package/es/Popup/Popup.js +2 -3
- package/es/Tab/Tab.js +1 -1
- package/es/Tab/Tabs.js +10 -5
- package/es/Tab/__tests__/Tab.spec.js +5 -11
- package/es/Tab/props/propTypes.js +1 -1
- package/es/css.js +2 -1
- package/es/utils/Common.js +4 -0
- package/es/utils/css/mergeStyle.js +25 -11
- package/lib/DateTime/DateTime.js +25 -61
- package/lib/DateTime/dateFormatUtils/dateFormats.js +51 -0
- package/lib/DateTime/dateFormatUtils/index.js +31 -3
- package/lib/DateTime/props/propTypes.js +8 -1
- package/lib/DropBox/DropBox.js +65 -276
- package/lib/DropBox/DropBoxElement/DropBoxElement.js +117 -0
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +432 -0
- package/lib/DropBox/DropBoxElement/css/cssJSLogic.js +72 -0
- package/lib/DropBox/DropBoxElement/props/defaultProps.js +25 -0
- package/lib/DropBox/DropBoxElement/props/propTypes.js +53 -0
- package/lib/DropBox/DropBoxElement/useDropboxPosCalc.js +55 -0
- package/lib/DropBox/css/DropBox.module.css +59 -0
- package/lib/DropBox/css/cssJSLogic.js +18 -0
- package/lib/DropBox/props/defaultProps.js +15 -19
- package/lib/DropBox/props/propTypes.js +15 -45
- package/lib/MultiSelect/AdvancedMultiSelect.js +0 -1
- package/lib/MultiSelect/MultiSelect.js +0 -2
- package/lib/Popup/Popup.js +1 -2
- package/lib/Tab/Tabs.js +7 -2
- package/lib/Tab/__tests__/Tab.spec.js +17 -22
- package/lib/Tab/props/propTypes.js +1 -1
- package/lib/css.js +2 -1
- package/lib/utils/Common.js +7 -1
- package/lib/utils/css/mergeStyle.js +25 -11
- package/package.json +1 -1
- package/docs/external/active-line.js +0 -72
- package/docs/external/autorefresh.js +0 -47
- package/docs/external/codemirror.js +0 -9681
- package/docs/external/css/hopscotch.css +0 -576
- package/docs/external/css/styleGuide.css +0 -1100
- package/docs/external/css.js +0 -466
- package/docs/external/designTokens.js +0 -1
- package/docs/external/foldcode.js +0 -152
- package/docs/external/format.js +0 -129
- package/docs/external/htmlmixed.js +0 -84
- package/docs/external/images/bottom.png +0 -0
- package/docs/external/images/bottombg.jpg +0 -0
- package/docs/external/images/desk.png +0 -0
- package/docs/external/images/desklogo.png +0 -0
- package/docs/external/images/menu.png +0 -0
- package/docs/external/index.html +0 -127
- package/docs/external/javascript.js +0 -422
- package/docs/external/jsx.js +0 -148
- package/docs/external/matchbrackets.js +0 -145
- package/docs/external/xml.js +0 -322
- package/docs/package.json +0 -41
- package/docs/src/index.js +0 -1311
- package/es/DropBox/DropBox.module.css +0 -405
- package/lib/DropBox/DropBox.module.css +0 -405
package/README.md
CHANGED
|
@@ -32,6 +32,17 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
32
32
|
- TextBoxIcon
|
|
33
33
|
- Tooltip
|
|
34
34
|
|
|
35
|
+
|
|
36
|
+
# 1.0.0-alpha-265
|
|
37
|
+
|
|
38
|
+
- **mergeStyle** - Logic Issue Fixed
|
|
39
|
+
- **Tab** - State Restricted Names Check added
|
|
40
|
+
- **cancelBubblingEffect** function added in utils/Common
|
|
41
|
+
|
|
42
|
+
# 1.0.0-alpha-264
|
|
43
|
+
|
|
44
|
+
- **DropBox** - customStyle renamed to customInlineStyle and migrarted to functional UCL component
|
|
45
|
+
|
|
35
46
|
# 1.0.0-alpha-263
|
|
36
47
|
|
|
37
48
|
- **ListItem, ListItemWithAvatar, ListItemWithCheckbox, ListItemWithIcon, ListItemWithRadio** - Line height changed 20px and Padding also changed.
|
package/css_error.log
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Component Package error log:
|
package/es/DateTime/DateTime.js
CHANGED
|
@@ -15,9 +15,8 @@ import { formatDate, getMonthEnd } from '../utils/datetime/common';
|
|
|
15
15
|
import { getIsEmptyValue } from '../utils/Common';
|
|
16
16
|
import { monthNamesDefault, monthNamesShortDefault, dayNamesDefault, dayNamesShortDefault, ampmTextDefault } from './constants';
|
|
17
17
|
import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
|
|
18
|
-
import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
|
|
19
18
|
import { Box } from '../Layout';
|
|
20
|
-
import {
|
|
19
|
+
import { getHourSuggestions, getMinuteSuggestions, addZeroIfNeeded } from './dateFormatUtils';
|
|
21
20
|
function title(date, year, month) {
|
|
22
21
|
let monthNames = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
23
22
|
const HeadingText = `${monthNames[month] || ''} ${year}`;
|
|
@@ -48,26 +47,6 @@ export default class DateTime extends React.PureComponent {
|
|
|
48
47
|
const {
|
|
49
48
|
ampmText = ampmTextDefault
|
|
50
49
|
} = props.i18nKeys;
|
|
51
|
-
const {
|
|
52
|
-
startPoint: hourStart,
|
|
53
|
-
endPoint: hourEnd
|
|
54
|
-
} = getHourDetails(props.is24Hour);
|
|
55
|
-
this.hourSuggestions = (() => {
|
|
56
|
-
const hourArr = [];
|
|
57
|
-
for (let hour = hourStart; hour <= hourEnd; hour++) {
|
|
58
|
-
const htxt = hour < 10 ? `0${hour}` : `${hour}`;
|
|
59
|
-
hourArr.push(htxt);
|
|
60
|
-
}
|
|
61
|
-
return hourArr;
|
|
62
|
-
})();
|
|
63
|
-
this.minSuggestions = (() => {
|
|
64
|
-
const minArr = [];
|
|
65
|
-
for (let minute = 0; minute <= 59; minute++) {
|
|
66
|
-
const mtxt = minute < 10 ? `0${minute}` : `${minute}`;
|
|
67
|
-
minArr.push(mtxt);
|
|
68
|
-
}
|
|
69
|
-
return minArr;
|
|
70
|
-
})();
|
|
71
50
|
this.ampmSuggestions = (() => {
|
|
72
51
|
const ampmSuggestions = [];
|
|
73
52
|
ampmText.forEach((text, index) => {
|
|
@@ -140,7 +119,7 @@ export default class DateTime extends React.PureComponent {
|
|
|
140
119
|
year = dateObj.getFullYear();
|
|
141
120
|
hours = defaultHour ? defaultHour : dateObj.getHours();
|
|
142
121
|
mins = !getIsEmptyValue(defaultMin) ? defaultMin : dateObj.getMinutes();
|
|
143
|
-
mins = mins
|
|
122
|
+
mins = addZeroIfNeeded(mins);
|
|
144
123
|
amPm = defaultAmPm ? defaultAmPm : hours < 12 ? 'AM' : 'PM';
|
|
145
124
|
hours = this.getHours(hours, is24Hour);
|
|
146
125
|
return {
|
|
@@ -164,7 +143,7 @@ export default class DateTime extends React.PureComponent {
|
|
|
164
143
|
hours -= 12;
|
|
165
144
|
}
|
|
166
145
|
}
|
|
167
|
-
hours = hours
|
|
146
|
+
hours = addZeroIfNeeded(hours);
|
|
168
147
|
return hours;
|
|
169
148
|
}
|
|
170
149
|
handleGetSelectedDate() {
|
|
@@ -563,16 +542,6 @@ export default class DateTime extends React.PureComponent {
|
|
|
563
542
|
isMonthOpen: false
|
|
564
543
|
});
|
|
565
544
|
}
|
|
566
|
-
responsiveFunc(_ref) {
|
|
567
|
-
let {
|
|
568
|
-
mediaQueryOR
|
|
569
|
-
} = _ref;
|
|
570
|
-
return {
|
|
571
|
-
tabletMode: mediaQueryOR([{
|
|
572
|
-
maxWidth: 700
|
|
573
|
-
}])
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
545
|
render() {
|
|
577
546
|
const {
|
|
578
547
|
date,
|
|
@@ -653,12 +622,12 @@ export default class DateTime extends React.PureComponent {
|
|
|
653
622
|
}), isDateTimeField ? /*#__PURE__*/React.createElement(Time, {
|
|
654
623
|
timeText: timeText,
|
|
655
624
|
dataId: dataId,
|
|
656
|
-
hourSuggestions:
|
|
625
|
+
hourSuggestions: getHourSuggestions(),
|
|
657
626
|
onHourSelect: this.hoursSelect,
|
|
658
627
|
hours: hours,
|
|
659
628
|
hourEmptyText: hourEmptyText,
|
|
660
629
|
needResponsive: needResponsive,
|
|
661
|
-
minSuggestions:
|
|
630
|
+
minSuggestions: getMinuteSuggestions(),
|
|
662
631
|
onMinutesSelect: this.minutesSelect,
|
|
663
632
|
mins: mins,
|
|
664
633
|
minuteEmptyText: minuteEmptyText,
|
|
@@ -686,35 +655,27 @@ export default class DateTime extends React.PureComponent {
|
|
|
686
655
|
return isDefaultPosition ? /*#__PURE__*/React.createElement("div", {
|
|
687
656
|
className: `${style.dropBox} ${className}`,
|
|
688
657
|
"data-id": `${dataId}_dateBoxContainer`
|
|
689
|
-
}, childEle) : isReady ? /*#__PURE__*/React.createElement(
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
},
|
|
711
|
-
isPadding: isPadding,
|
|
712
|
-
positionsOffset: positionsOffset,
|
|
713
|
-
targetOffset: targetOffset,
|
|
714
|
-
isRestrictScroll: isRestrictScroll,
|
|
715
|
-
portalId: dropBoxPortalId
|
|
716
|
-
}, /*#__PURE__*/React.createElement(Box, null, childEle));
|
|
717
|
-
}) : null;
|
|
658
|
+
}, childEle) : isReady ? /*#__PURE__*/React.createElement(ResponsiveDropBox, {
|
|
659
|
+
size: boxSize,
|
|
660
|
+
boxPosition: position,
|
|
661
|
+
isActive: isActive,
|
|
662
|
+
isArrow: false,
|
|
663
|
+
isAnimate: isAnimate,
|
|
664
|
+
animationStyle: "bounce",
|
|
665
|
+
getRef: getRef,
|
|
666
|
+
onClick: onClick,
|
|
667
|
+
dataId: `${dataId}_dateBoxContainer`,
|
|
668
|
+
needResponsive: needResponsive,
|
|
669
|
+
isAbsolutePositioningNeeded: isAbsolute,
|
|
670
|
+
customClass: {
|
|
671
|
+
customDropBoxWrap: className
|
|
672
|
+
},
|
|
673
|
+
isPadding: isPadding,
|
|
674
|
+
positionsOffset: positionsOffset,
|
|
675
|
+
targetOffset: targetOffset,
|
|
676
|
+
isRestrictScroll: isRestrictScroll,
|
|
677
|
+
portalId: dropBoxPortalId
|
|
678
|
+
}, /*#__PURE__*/React.createElement(Box, null, childEle)) : null;
|
|
718
679
|
}
|
|
719
680
|
}
|
|
720
681
|
DateTime.propTypes = DateTime_propTypes;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Date Pattern Letters And its Meanings :-
|
|
2
|
+
// 1. d/D: day without 0 prefix on single digit.
|
|
3
|
+
// 2. dd/DD: day with 0 prefix if single digit.
|
|
4
|
+
// 3. M: Month without 0 prefix on single digit.
|
|
5
|
+
// 4. MM: Month with 0 prefix if single digit.
|
|
6
|
+
// 5. yy/YY: Last two digit of year.
|
|
7
|
+
// 6. yyyy/YYYY: represents full year.
|
|
8
|
+
// 7. HH: 24 hour based hour. ie. 13:00. **H** will display hour without prefix 0 if single digit
|
|
9
|
+
// 8. hh: 12 hour based hour. ie. 01:00. **h** will display hour without prefix 0 if single digit
|
|
10
|
+
// 9. m: minute without 0 prefix on single digit.
|
|
11
|
+
// 10.mm: minute with 0 prefix if single digit.
|
|
12
|
+
// 11.s: second without 0 prefix on single digit.
|
|
13
|
+
// 12.ss: second with 0 prefix if single digit.
|
|
14
|
+
// 13.S: milliseconds with 0 prefix if single digit.
|
|
15
|
+
// 14.a: represent the AM or PM
|
|
16
|
+
// 15.A: represent the AM or PM
|
|
17
|
+
// 16.Z: represent the timezone (Asia/Kolkata)
|
|
18
|
+
// 17. (O) : Offset Of the timezone (GMT+00:00)
|
|
19
|
+
|
|
20
|
+
export const dateSymbols = {
|
|
21
|
+
d: 'date',
|
|
22
|
+
dd: 'date',
|
|
23
|
+
DD: 'date',
|
|
24
|
+
M: 'month',
|
|
25
|
+
MM: 'month',
|
|
26
|
+
yy: 'year',
|
|
27
|
+
YY: 'year',
|
|
28
|
+
YYYY: 'year',
|
|
29
|
+
yyyy: 'year',
|
|
30
|
+
h: 'hour',
|
|
31
|
+
hh: 'hour',
|
|
32
|
+
H: 'hour',
|
|
33
|
+
HH: 'hour',
|
|
34
|
+
m: 'minute',
|
|
35
|
+
mm: 'minute',
|
|
36
|
+
s: 'second',
|
|
37
|
+
ss: 'second',
|
|
38
|
+
S: 'millisecond',
|
|
39
|
+
a: 'AMPM',
|
|
40
|
+
Z: 'timezone',
|
|
41
|
+
O: 'offset'
|
|
42
|
+
};
|
|
43
|
+
export const dataFormatList = ['yyyy/MM/dd', 'yyyy-MM-dd', 'yyyy.MM.dd', 'yyyy MM dd', 'MM/dd/yyyy', 'MM-dd-yyyy', 'MM.dd.yyyy', 'MM dd yyyy', 'dd/MM/yyyy', 'dd-MM-yyyy', 'dd.MM.yyyy', 'dd MM yyyy', 'yyyy/MMM/dd', 'yyyy-MMM-dd', 'yyyy.MMM.dd', 'yyyy MMM dd', 'MMM/dd/yyyy', 'MMM-dd-yyyy', 'MMM.dd.yyyy', 'MMM dd yyyy', 'dd/MMM/yyyy', 'dd-MMM-yyyy', 'dd.MMM.yyyy', 'dd MMM yyyy', 'dd/MMMM/yyyy', 'dd-MMMM-yyyy', 'dd-MMMM-yyyy', 'dd MMMM yyyy', 'MMMM/dd/yyyy', 'MMMM-dd-yyyy', 'MMMM.dd.yyyy', 'MMMM dd yyyy', 'yyyy/MMMM/dd', 'yyyy-MMMM-dd', 'yyyy.MMMM.dd', 'yyyy MMMM dd', 'dd/MM/YY', 'dd-MM-YY', 'dd.MM.YY', 'dd MM YY', 'MM/dd/YY', 'MM-dd-YY', 'MM.dd.YY', 'MM dd YY', 'YY/MM/dd', 'YY-MM-dd', 'YY.MM.dd', 'YY MM dd', 'dd/MMM/YY', 'dd-MMM-YY', 'dd.MMM.YY', 'dd MMM YY', 'MMM/dd/YY', 'MMM-dd-YY', 'MMM.dd.YY', 'MMM dd YY', 'YY/MMM/dd', 'YY-MMM-dd', 'YY.MMM.dd', 'YY MMM dd', 'dd/MMMM/YY', 'dd-MMMM-YY', 'dd.MMMM.YY', 'dd MMMM YY', 'MMMM/dd/YY', 'MMMM-dd-YY', 'MMMM.dd.YY', 'MMMM dd YY', 'YY/MMMM/dd', 'YY-MMMM-dd', 'YY.MMMM.dd', 'YY MMMM dd'];
|
|
@@ -109,12 +109,39 @@ export function getHourDetails(is24Hour) {
|
|
|
109
109
|
endPoint: is24Hour ? 23 : 12
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
export function getHourSuggestions(is24Hour) {
|
|
113
|
+
const {
|
|
114
|
+
startPoint,
|
|
115
|
+
endPoint
|
|
116
|
+
} = getHourDetails(is24Hour);
|
|
117
|
+
const hourArr = [];
|
|
118
|
+
for (let hour = startPoint; hour <= endPoint; hour++) {
|
|
119
|
+
const htxt = addZeroIfNeeded(hour);
|
|
120
|
+
hourArr.push(htxt);
|
|
121
|
+
}
|
|
122
|
+
return hourArr;
|
|
123
|
+
}
|
|
112
124
|
export function getMinuteDetails() {
|
|
113
125
|
return {
|
|
114
126
|
startPoint: 0,
|
|
115
127
|
endPoint: 59
|
|
116
128
|
};
|
|
117
129
|
}
|
|
130
|
+
export function getMinuteSuggestions() {
|
|
131
|
+
const {
|
|
132
|
+
startPoint,
|
|
133
|
+
endPoint
|
|
134
|
+
} = getMinuteDetails();
|
|
135
|
+
const minArr = [];
|
|
136
|
+
for (let minute = startPoint; minute <= endPoint; minute++) {
|
|
137
|
+
const mtxt = addZeroIfNeeded(minute);
|
|
138
|
+
minArr.push(mtxt);
|
|
139
|
+
}
|
|
140
|
+
return minArr;
|
|
141
|
+
}
|
|
142
|
+
export function addZeroIfNeeded(value) {
|
|
143
|
+
return value < 10 ? `0${value}` : value;
|
|
144
|
+
}
|
|
118
145
|
export function getIsNoonValueTyped(event) {
|
|
119
146
|
const {
|
|
120
147
|
keyCode
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
import { dataFormatList } from '../dateFormatUtils/dateFormats';
|
|
2
3
|
export const CalendarView_propTypes = {
|
|
3
4
|
dataId: PropTypes.string,
|
|
4
5
|
date: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
@@ -71,7 +72,7 @@ export const DateWidget_propTypes = {
|
|
|
71
72
|
className: PropTypes.string,
|
|
72
73
|
closePopupOnly: PropTypes.func,
|
|
73
74
|
dataId: PropTypes.string,
|
|
74
|
-
dateFormat: PropTypes.oneOf([
|
|
75
|
+
dateFormat: PropTypes.oneOf([...dataFormatList]),
|
|
75
76
|
defaultPosition: PropTypes.oneOf(['top', 'bottom', 'right', 'left']),
|
|
76
77
|
defaultTime: PropTypes.string,
|
|
77
78
|
getContainerRef: PropTypes.func,
|
package/es/DropBox/DropBox.js
CHANGED
|
@@ -1,251 +1,75 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React, { Fragment } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import { propTypes } from './props/propTypes';
|
|
5
|
-
import { remConvert } from '../utils/Common';
|
|
2
|
+
import React, { useRef, Fragment, useContext } from 'react';
|
|
3
|
+
import FocusScope from '@zohodesk/a11y/es/FocusScope/FocusScope';
|
|
6
4
|
import Modal from '../Modal/Modal';
|
|
7
|
-
import style from './DropBox.module.css';
|
|
8
|
-
import { positionMapping } from './DropBoxPositionMapping.json';
|
|
9
|
-
import { getZIndex } from '../Provider/ZindexProvider';
|
|
10
5
|
import { getLibraryConfig } from '../Provider/Config';
|
|
11
6
|
import LibraryContext from '../Provider/LibraryContextInit';
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
arrowLeft,
|
|
41
|
-
arrowTop,
|
|
42
|
-
arrowBottom,
|
|
43
|
-
bottom,
|
|
44
|
-
onClick,
|
|
45
|
-
isRadius,
|
|
46
|
-
animationStyle,
|
|
47
|
-
isActive,
|
|
48
|
-
dataId,
|
|
49
|
-
dataSelectorId,
|
|
50
|
-
isModel,
|
|
51
|
-
isAbsolutePositioningNeeded,
|
|
52
|
-
tourId,
|
|
53
|
-
isBoxPaddingNeed,
|
|
54
|
-
isPadding,
|
|
55
|
-
customClass,
|
|
56
|
-
htmlId,
|
|
57
|
-
a11y,
|
|
58
|
-
direction,
|
|
59
|
-
tabIndex,
|
|
60
|
-
palette,
|
|
61
|
-
positionsOffset,
|
|
62
|
-
targetOffset,
|
|
63
|
-
zIndexStyle,
|
|
64
|
-
customStyle,
|
|
65
|
-
subContainerRef
|
|
66
|
-
} = this.props;
|
|
67
|
-
let {
|
|
68
|
-
isReducedMotion
|
|
69
|
-
} = this.context || {};
|
|
70
|
-
if (!isAbsolutePositioningNeeded && size === 'default' && !isActive) {
|
|
71
|
-
isAbsolutePositioningNeeded = true;
|
|
72
|
-
}
|
|
73
|
-
const {
|
|
74
|
-
role,
|
|
75
|
-
ariaMultiselectable,
|
|
76
|
-
ariaLabelledby
|
|
77
|
-
} = a11y;
|
|
78
|
-
const {
|
|
79
|
-
customDropBox = '',
|
|
80
|
-
customMobileDropBox = '',
|
|
81
|
-
customDropBoxWrap = '',
|
|
82
|
-
customMobileDropBoxWrap = ''
|
|
83
|
-
} = customClass;
|
|
84
|
-
const unit = 'rem';
|
|
85
|
-
let boxstyle = {};
|
|
86
|
-
let arrowstyle = {};
|
|
87
|
-
const needBoxStyle = right || left || top || bottom;
|
|
88
|
-
const needArrowStyle = arrowLeft || arrowRight || arrowTop || arrowBottom;
|
|
89
|
-
if (needBoxStyle) {
|
|
90
|
-
boxstyle = !isModel ? direction === 'rtl' ? {
|
|
91
|
-
right: [remConvert(left)] + unit,
|
|
92
|
-
left: [remConvert(right)] + unit,
|
|
93
|
-
top: [remConvert(top)] + unit,
|
|
94
|
-
bottom: [remConvert(bottom)] + unit
|
|
95
|
-
} : {
|
|
96
|
-
right: [remConvert(right)] + unit,
|
|
97
|
-
left: [remConvert(left)] + unit,
|
|
98
|
-
top: [remConvert(top)] + unit,
|
|
99
|
-
bottom: [remConvert(bottom)] + unit
|
|
100
|
-
} : {};
|
|
101
|
-
}
|
|
102
|
-
if (needArrowStyle) {
|
|
103
|
-
arrowstyle = !isModel ? direction === 'rtl' ? {
|
|
104
|
-
right: [remConvert(arrowLeft)] + unit,
|
|
105
|
-
left: [remConvert(arrowRight)] + unit,
|
|
106
|
-
top: [remConvert(arrowTop)] + unit,
|
|
107
|
-
bottom: [remConvert(arrowBottom)] + unit
|
|
108
|
-
} : {
|
|
109
|
-
right: [remConvert(arrowRight)] + unit,
|
|
110
|
-
left: [remConvert(arrowLeft)] + unit,
|
|
111
|
-
top: [remConvert(arrowTop)] + unit,
|
|
112
|
-
bottom: [remConvert(arrowBottom)] + unit
|
|
113
|
-
} : {};
|
|
114
|
-
}
|
|
115
|
-
boxPosition = boxPosition && boxPosition != 'undefined' ? boxPosition : 'bottomCenter';
|
|
116
|
-
const boxDirection = positionMapping[boxPosition].direction; /*getting box direction*/
|
|
117
|
-
if (isAbsolutePositioningNeeded) {
|
|
118
|
-
arrowPosition = arrowPosition ? arrowPosition : positionMapping[boxPosition].arrowPosition;
|
|
119
|
-
boxPosition = positionMapping[boxPosition].positionStyle;
|
|
120
|
-
} else {
|
|
121
|
-
arrowPosition = positionMapping[boxPosition].arrowPosition;
|
|
122
|
-
}
|
|
123
|
-
const boxClassName = `${style.main} ${!isActive ? style.hidden : ''} ${isModel ? `${style.responsive} ${customMobileDropBoxWrap}` : `${customDropBoxWrap} ${size ? style[size] : ''} ${isActive ? `${isArrow ? `${style[boxDirection]} ${isAbsolutePositioningNeeded ? style[`arrow${boxDirection}`] : ''}` : isPadding ? style[`paddingSpace_${boxDirection}`] : ''}` : ''} ${isAbsolutePositioningNeeded ? `${style.container} ${style[boxPosition]}` : style.fixedContainer}`}`;
|
|
124
|
-
const subContainerClass = `${style.subContainer} ${isModel ? ` ${customMobileDropBox} ${style.mobRadius} ${isActive ? style.slideUp : ''} ` : `${customDropBox} ${style[`${boxDirection}_shadow`]} ${isRadius ? style.radius : ''} ${isAnimate && !isReducedMotion && isActive ? animationStyle === 'default' ? style.fadeIn : style.bounce : ''} ${isBoxPaddingNeed ? style.boxPadding : ''}`}`;
|
|
125
|
-
|
|
126
|
-
// setting inlineStyle for dropbox
|
|
127
|
-
let inlineStyle = !isModel ? isAbsolutePositioningNeeded ? needBoxStyle && boxstyle : positionsOffset && positionsOffset[boxPosition] || {} : {};
|
|
128
|
-
if (zIndexStyle) {
|
|
129
|
-
inlineStyle = Object.assign({}, inlineStyle, zIndexStyle);
|
|
130
|
-
}
|
|
131
|
-
if (!isModel && !isAbsolutePositioningNeeded && size === 'default' && targetOffset && isActive) {
|
|
132
|
-
inlineStyle = Object.assign({}, inlineStyle, {
|
|
133
|
-
width: targetOffset.width
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
if (customStyle) {
|
|
137
|
-
inlineStyle = Object.assign({}, inlineStyle, customStyle);
|
|
138
|
-
}
|
|
139
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
140
|
-
className: boxClassName,
|
|
141
|
-
"data-id": `${dataId}`,
|
|
142
|
-
"data-selector-id": dataSelectorId,
|
|
143
|
-
ref: this.getRef,
|
|
144
|
-
style: inlineStyle,
|
|
145
|
-
"data-tour": tourId,
|
|
146
|
-
"data-position": boxPosition,
|
|
147
|
-
id: htmlId,
|
|
148
|
-
role: role,
|
|
149
|
-
"aria-multiselectable": ariaMultiselectable,
|
|
150
|
-
"aria-labelledby": ariaLabelledby,
|
|
151
|
-
tabIndex: tabIndex
|
|
152
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
153
|
-
tabIndex: "-1",
|
|
154
|
-
className: `${subContainerClass} ${style[`${palette}Palette`]}`,
|
|
155
|
-
onClick: onClick,
|
|
156
|
-
"data-id": `${dataId}_subcontainer`,
|
|
157
|
-
"data-selector-id": `${dataSelectorId}_subcontainer`,
|
|
158
|
-
ref: subContainerRef
|
|
159
|
-
}, isModel ? /*#__PURE__*/React.createElement("div", {
|
|
160
|
-
className: style.closeBar
|
|
161
|
-
}) : null, isArrow && !isModel && /*#__PURE__*/React.createElement("div", {
|
|
162
|
-
className: style[arrowPosition],
|
|
163
|
-
style: needArrowStyle && arrowstyle,
|
|
164
|
-
"data-id": `${dataId}_arrow`,
|
|
165
|
-
"data-selector-id": `${dataSelectorId}_arrow`
|
|
166
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
167
|
-
className: style.arrowShape
|
|
168
|
-
})), children));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
export default class DropBox extends React.Component {
|
|
172
|
-
constructor(props) {
|
|
173
|
-
super(props);
|
|
174
|
-
this.getNextIndex = getZIndex(this);
|
|
175
|
-
this.onFreezeClick = this.onFreezeClick.bind(this);
|
|
176
|
-
this.createRef = /*#__PURE__*/React.createRef();
|
|
177
|
-
}
|
|
178
|
-
onFreezeClick(e) {
|
|
179
|
-
e && e.stopPropagation();
|
|
180
|
-
}
|
|
181
|
-
render() {
|
|
182
|
-
const {
|
|
183
|
-
needResponsive,
|
|
184
|
-
portalId,
|
|
185
|
-
isActive,
|
|
186
|
-
isAbsolutePositioningNeeded,
|
|
187
|
-
needAutoZindex,
|
|
188
|
-
isRestrictScroll,
|
|
189
|
-
needFocusScope,
|
|
190
|
-
onClose
|
|
191
|
-
} = this.props;
|
|
192
|
-
let windowWidth,
|
|
193
|
-
mobileWidth = getLibraryConfig('mobileWidth'),
|
|
194
|
-
isModel = false;
|
|
195
|
-
if (needResponsive) {
|
|
196
|
-
windowWidth = window.innerWidth;
|
|
197
|
-
if (windowWidth <= mobileWidth) {
|
|
198
|
-
isModel = true;
|
|
199
|
-
}
|
|
7
|
+
import cssJSLogic from './css/cssJSLogic';
|
|
8
|
+
import DropBoxElement from './DropBoxElement/DropBoxElement';
|
|
9
|
+
import { DropBoxDefaultProps } from './props/defaultProps';
|
|
10
|
+
import { DropBoxPropTypes } from './props/propTypes';
|
|
11
|
+
import { cancelBubblingEffect } from './../utils/Common';
|
|
12
|
+
import style from './css/DropBox.module.css';
|
|
13
|
+
export default function DropBox(props) {
|
|
14
|
+
const focusRef = useRef(null);
|
|
15
|
+
const DropBoxContext = useContext(LibraryContext);
|
|
16
|
+
const {
|
|
17
|
+
needResponsive,
|
|
18
|
+
portalId,
|
|
19
|
+
isActive,
|
|
20
|
+
isAbsolutePositioningNeeded,
|
|
21
|
+
isRestrictScroll,
|
|
22
|
+
needFocusScope,
|
|
23
|
+
onClose
|
|
24
|
+
} = props;
|
|
25
|
+
const {
|
|
26
|
+
direction
|
|
27
|
+
} = DropBoxContext || {};
|
|
28
|
+
let windowWidth,
|
|
29
|
+
mobileWidth = getLibraryConfig('mobileWidth'),
|
|
30
|
+
isModel = false;
|
|
31
|
+
if (needResponsive) {
|
|
32
|
+
windowWidth = window.innerWidth;
|
|
33
|
+
if (windowWidth <= mobileWidth) {
|
|
34
|
+
isModel = true;
|
|
200
35
|
}
|
|
201
|
-
const zIndexStyle = isActive && needAutoZindex ? {
|
|
202
|
-
zIndex: this.getNextIndex()
|
|
203
|
-
} : {};
|
|
204
|
-
const {
|
|
205
|
-
direction
|
|
206
|
-
} = this.context || {};
|
|
207
|
-
const dropBoxEle = needFocusScope ? /*#__PURE__*/React.createElement(FocusScope, {
|
|
208
|
-
focusClose: onClose,
|
|
209
|
-
elementRef: this.createRef,
|
|
210
|
-
autoFocus: true,
|
|
211
|
-
restoreFocus: true,
|
|
212
|
-
focusArrowLoop: true,
|
|
213
|
-
enableEnterAction: true
|
|
214
|
-
}, /*#__PURE__*/React.createElement(DropBoxElement, _extends({
|
|
215
|
-
isModel: isModel,
|
|
216
|
-
direction: direction
|
|
217
|
-
}, this.props, {
|
|
218
|
-
zIndexStyle: zIndexStyle,
|
|
219
|
-
subContainerRef: this.createRef
|
|
220
|
-
}))) : /*#__PURE__*/React.createElement(DropBoxElement, _extends({
|
|
221
|
-
isModel: isModel,
|
|
222
|
-
direction: direction
|
|
223
|
-
}, this.props, {
|
|
224
|
-
zIndexStyle: zIndexStyle
|
|
225
|
-
}));
|
|
226
|
-
return isModel && isActive ? /*#__PURE__*/React.createElement(Modal, {
|
|
227
|
-
portalId: portalId
|
|
228
|
-
}, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
229
|
-
className: `${style.freezeLayer} ${style.freeze}`,
|
|
230
|
-
style: zIndexStyle,
|
|
231
|
-
onClick: this.onFreezeClick
|
|
232
|
-
}), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/React.createElement(Modal, {
|
|
233
|
-
portalId: portalId
|
|
234
|
-
}, /*#__PURE__*/React.createElement(Fragment, null, isRestrictScroll ? /*#__PURE__*/React.createElement("div", {
|
|
235
|
-
className: style.freezeLayer,
|
|
236
|
-
style: zIndexStyle,
|
|
237
|
-
onClick: this.onFreezeClick
|
|
238
|
-
}) : null, dropBoxEle)) : dropBoxEle;
|
|
239
36
|
}
|
|
37
|
+
const {
|
|
38
|
+
zIndexStyle
|
|
39
|
+
} = cssJSLogic(props);
|
|
40
|
+
const dropBoxEle = needFocusScope ? /*#__PURE__*/React.createElement(FocusScope, {
|
|
41
|
+
focusClose: onClose,
|
|
42
|
+
elementRef: focusRef,
|
|
43
|
+
autoFocus: true,
|
|
44
|
+
restoreFocus: true,
|
|
45
|
+
focusArrowLoop: true,
|
|
46
|
+
enableEnterAction: true
|
|
47
|
+
}, /*#__PURE__*/React.createElement(DropBoxElement, _extends({
|
|
48
|
+
isModel: isModel,
|
|
49
|
+
direction: direction
|
|
50
|
+
}, props, {
|
|
51
|
+
zIndexStyle: zIndexStyle,
|
|
52
|
+
subContainerRef: focusRef
|
|
53
|
+
}))) : /*#__PURE__*/React.createElement(DropBoxElement, _extends({
|
|
54
|
+
isModel: isModel,
|
|
55
|
+
subContainerRef: focusRef,
|
|
56
|
+
direction: direction
|
|
57
|
+
}, props, {
|
|
58
|
+
zIndexStyle: zIndexStyle
|
|
59
|
+
}));
|
|
60
|
+
return isModel && isActive ? /*#__PURE__*/React.createElement(Modal, {
|
|
61
|
+
portalId: portalId
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: `${style.freezeLayer} ${style.freeze}`,
|
|
64
|
+
style: zIndexStyle,
|
|
65
|
+
onClick: cancelBubblingEffect
|
|
66
|
+
}), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/React.createElement(Modal, {
|
|
67
|
+
portalId: portalId
|
|
68
|
+
}, /*#__PURE__*/React.createElement(Fragment, null, isRestrictScroll ? /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
className: style.freezeLayer,
|
|
70
|
+
style: zIndexStyle,
|
|
71
|
+
onClick: cancelBubblingEffect
|
|
72
|
+
}) : null, dropBoxEle)) : dropBoxEle;
|
|
240
73
|
}
|
|
241
|
-
DropBox.propTypes =
|
|
242
|
-
DropBox.
|
|
243
|
-
DropBox.defaultProps = defaultProps;
|
|
244
|
-
// if (__DOCS__) {
|
|
245
|
-
// DropBox.docs = {
|
|
246
|
-
// componentGroup: 'Atom',
|
|
247
|
-
// folderName: 'Style Guide',
|
|
248
|
-
// external: true,
|
|
249
|
-
// description: ' '
|
|
250
|
-
// };
|
|
251
|
-
// }
|
|
74
|
+
DropBox.propTypes = DropBoxPropTypes;
|
|
75
|
+
DropBox.defaultProps = DropBoxDefaultProps;
|