@zohodesk/components 1.2.48 → 1.2.50
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 +24 -1
- package/es/DateTime/CalendarView.js +8 -5
- package/es/DateTime/DateTime.js +18 -4
- package/es/DateTime/DateTime.module.css +5 -5
- package/es/DateTime/DateWidget.js +5 -1
- 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 +11 -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/Popup/Popup.js +107 -8
- package/es/Popup/intersectionObserver.js +39 -0
- package/es/Popup/props/propTypes.js +30 -0
- package/es/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1 -0
- package/es/TextBox/TextBox.js +1 -1
- 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/lib/DateTime/CalendarView.js +8 -5
- package/lib/DateTime/DateTime.js +27 -4
- package/lib/DateTime/DateTime.module.css +5 -5
- package/lib/DateTime/DateWidget.js +5 -1
- 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 +11 -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/Popup/Popup.js +118 -9
- package/lib/Popup/intersectionObserver.js +62 -0
- package/lib/Popup/props/propTypes.js +51 -0
- package/lib/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1 -0
- package/lib/TextBox/TextBox.js +1 -1
- 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/package.json +4 -4
- package/result.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,29 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
32
32
|
- TextBoxIcon
|
|
33
33
|
- Tooltip
|
|
34
34
|
|
|
35
|
+
|
|
36
|
+
# 1.2.50
|
|
37
|
+
|
|
38
|
+
- **DateTime (v0&v1), CalendarView (v0&v1)**
|
|
39
|
+
|
|
40
|
+
- Week starting day customization support added with `weekStartDay` props and week holiday customization support with `holidays` prop
|
|
41
|
+
|
|
42
|
+
- **DateWidget (v0&v1)**
|
|
43
|
+
|
|
44
|
+
- Support has been added for `weekStartDay`, `holidays` props
|
|
45
|
+
|
|
46
|
+
- **DaysRow (v0&v1)**
|
|
47
|
+
|
|
48
|
+
- `holidays` prop added for holiday column indication
|
|
49
|
+
|
|
50
|
+
# 1.2.49
|
|
51
|
+
|
|
52
|
+
- **Popup**
|
|
53
|
+
- `isOutsideScrollBlocked` prop supported - Scroll blocking behaviours supported
|
|
54
|
+
- Fixed popup re-positioning on window resize not working properly - Issue fixed
|
|
55
|
+
- **DropBoxElement**
|
|
56
|
+
- The dot-ui-element attribute has been added to facilitate the use of component-level CSS selectors
|
|
57
|
+
|
|
35
58
|
# 1.2.48
|
|
36
59
|
|
|
37
60
|
- **ResizeObserver**
|
|
@@ -104,7 +127,7 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
104
127
|
|
|
105
128
|
- **LibraryContext** - coloredTagVariant, hasTagColorInheritedToText properties added
|
|
106
129
|
- **Tag** - customAttributes prop supported
|
|
107
|
-
- **TextBoxIcon** -
|
|
130
|
+
- **TextBoxIcon** - needInputFocusOnWrapperClick prop supported
|
|
108
131
|
|
|
109
132
|
# 1.2.38
|
|
110
133
|
|
|
@@ -31,10 +31,12 @@ export default class CalendarView extends React.PureComponent {
|
|
|
31
31
|
dayNamesShort,
|
|
32
32
|
todayMonth,
|
|
33
33
|
todayDate,
|
|
34
|
-
todayYear
|
|
34
|
+
todayYear,
|
|
35
|
+
weekStartDay,
|
|
36
|
+
holidays
|
|
35
37
|
} = this.props;
|
|
36
38
|
const userSeeDate = new Date(year, month, 1);
|
|
37
|
-
const userSeeDay = userSeeDate.getDay() + 1;
|
|
39
|
+
const userSeeDay = (userSeeDate.getDay() - weekStartDay + dayNames.length) % dayNames.length + 1;
|
|
38
40
|
const userSeeYear = userSeeDate.getFullYear();
|
|
39
41
|
const userSeeMonth = userSeeDate.getMonth();
|
|
40
42
|
const monthEnd = getMonthEnd(month, year);
|
|
@@ -65,8 +67,8 @@ export default class CalendarView extends React.PureComponent {
|
|
|
65
67
|
isSelectedDay = false;
|
|
66
68
|
let tdclass = `${style.datesStr} ${style.grid}`;
|
|
67
69
|
|
|
68
|
-
if (i
|
|
69
|
-
tdclass += ` ${style.
|
|
70
|
+
if (holidays.includes(i - 1)) {
|
|
71
|
+
tdclass += ` ${style.holiday}`;
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
if (incremleti >= userSeeDay && incremday <= monthEnd) {
|
|
@@ -170,7 +172,8 @@ export default class CalendarView extends React.PureComponent {
|
|
|
170
172
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DaysRow, {
|
|
171
173
|
dayNames: dayNames,
|
|
172
174
|
dayNamesShort: dayNamesShort,
|
|
173
|
-
ariaLabel: dayNamesShort
|
|
175
|
+
ariaLabel: dayNamesShort,
|
|
176
|
+
holidays: holidays
|
|
174
177
|
}), /*#__PURE__*/React.createElement("div", {
|
|
175
178
|
"data-id": `${dataId}_dateContainer`,
|
|
176
179
|
"data-test-id": `${dataId}_dateContainer`,
|
package/es/DateTime/DateTime.js
CHANGED
|
@@ -650,7 +650,9 @@ export default class DateTime extends React.PureComponent {
|
|
|
650
650
|
targetOffset,
|
|
651
651
|
isRestrictScroll,
|
|
652
652
|
dropBoxPortalId,
|
|
653
|
-
customProps = {}
|
|
653
|
+
customProps = {},
|
|
654
|
+
weekStartDay,
|
|
655
|
+
holidays
|
|
654
656
|
} = this.props;
|
|
655
657
|
const {
|
|
656
658
|
TimeProps = {}
|
|
@@ -669,6 +671,16 @@ export default class DateTime extends React.PureComponent {
|
|
|
669
671
|
dayNamesShort = dayNamesShortDefault
|
|
670
672
|
} = i18nKeys;
|
|
671
673
|
const showmonthtxt = title(date, year, month, monthNames);
|
|
674
|
+
let customDayNames = dayNames,
|
|
675
|
+
customDayNamesShort = dayNamesShort,
|
|
676
|
+
customizedHolidays = holidays;
|
|
677
|
+
|
|
678
|
+
if (weekStartDay !== 0) {
|
|
679
|
+
customDayNames = [...dayNames.slice(weekStartDay), ...dayNames.slice(0, weekStartDay)];
|
|
680
|
+
customDayNamesShort = [...dayNamesShort.slice(weekStartDay), ...dayNamesShort.slice(0, weekStartDay)];
|
|
681
|
+
customizedHolidays = holidays.map(dayIndex => customDayNames.indexOf(dayNames[dayIndex]));
|
|
682
|
+
}
|
|
683
|
+
|
|
672
684
|
const childEle = /*#__PURE__*/React.createElement("div", {
|
|
673
685
|
className: `${style.container} ${innerClass}`,
|
|
674
686
|
"data-id": `${dataId}_Calendar`,
|
|
@@ -690,11 +702,13 @@ export default class DateTime extends React.PureComponent {
|
|
|
690
702
|
year: year,
|
|
691
703
|
month: month,
|
|
692
704
|
onSelect: this.dateSelect,
|
|
693
|
-
dayNames:
|
|
694
|
-
dayNamesShort:
|
|
705
|
+
dayNames: customDayNames,
|
|
706
|
+
dayNamesShort: customDayNamesShort,
|
|
695
707
|
todayDate: todayDate,
|
|
696
708
|
todayMonth: todayMonth,
|
|
697
|
-
todayYear: todayYear
|
|
709
|
+
todayYear: todayYear,
|
|
710
|
+
weekStartDay: weekStartDay,
|
|
711
|
+
holidays: customizedHolidays
|
|
698
712
|
}), isDateTimeField ? /*#__PURE__*/React.createElement(Time, {
|
|
699
713
|
timeText: timeText,
|
|
700
714
|
dataId: dataId,
|
|
@@ -112,9 +112,9 @@
|
|
|
112
112
|
margin-bottom: 0 ;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
.
|
|
116
|
-
.
|
|
117
|
-
.invalidDate.
|
|
115
|
+
.holiday,
|
|
116
|
+
.holiday:hover,
|
|
117
|
+
.invalidDate.holiday:hover {
|
|
118
118
|
color: var(--zdt_datetime_invalid_hover_text);
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
color: var(--zdt_datetime_invalid_text);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
.invalidDate.
|
|
125
|
+
.invalidDate.holiday,.inActiveDate.holiday:hover {
|
|
126
126
|
color: var(--zdt_datetime_invaliddate_text);
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -155,7 +155,7 @@ cursor: no-drop;
|
|
|
155
155
|
{
|
|
156
156
|
color: var(--zdt_datetime_invalid_text);
|
|
157
157
|
}
|
|
158
|
-
.inActiveDate:hover, .inActiveDate.
|
|
158
|
+
.inActiveDate:hover, .inActiveDate.holiday:hover{
|
|
159
159
|
background-color: var(--zdt_datetime_inactivedate_hover_bg);
|
|
160
160
|
|
|
161
161
|
}
|
|
@@ -1004,6 +1004,8 @@ class DateWidgetComponent extends React.Component {
|
|
|
1004
1004
|
a11y,
|
|
1005
1005
|
boxSize,
|
|
1006
1006
|
onError,
|
|
1007
|
+
weekStartDay,
|
|
1008
|
+
holidays,
|
|
1007
1009
|
customProps = {}
|
|
1008
1010
|
} = this.props;
|
|
1009
1011
|
const {
|
|
@@ -1106,7 +1108,9 @@ class DateWidgetComponent extends React.Component {
|
|
|
1106
1108
|
dropBoxPortalId: dropBoxPortalId,
|
|
1107
1109
|
boxSize: boxSize,
|
|
1108
1110
|
onError: onError,
|
|
1109
|
-
customProps: DateTimeProps
|
|
1111
|
+
customProps: DateTimeProps,
|
|
1112
|
+
weekStartDay: weekStartDay,
|
|
1113
|
+
holidays: holidays
|
|
1110
1114
|
}));
|
|
1111
1115
|
}
|
|
1112
1116
|
|
package/es/DateTime/DaysRow.js
CHANGED
|
@@ -13,7 +13,8 @@ export default class DaysRow extends PureComponent {
|
|
|
13
13
|
render() {
|
|
14
14
|
const {
|
|
15
15
|
dayNames,
|
|
16
|
-
dayNamesShort
|
|
16
|
+
dayNamesShort,
|
|
17
|
+
holidays
|
|
17
18
|
} = this.props;
|
|
18
19
|
return /*#__PURE__*/React.createElement(Container, {
|
|
19
20
|
alignBox: "row",
|
|
@@ -21,7 +22,7 @@ export default class DaysRow extends PureComponent {
|
|
|
21
22
|
className: style.days
|
|
22
23
|
}, dayNames.map((dayName, index) => /*#__PURE__*/React.createElement(Box, {
|
|
23
24
|
key: dayName,
|
|
24
|
-
className: `${style.daysStr} ${style.grid} ${index
|
|
25
|
+
className: `${style.daysStr} ${style.grid} ${holidays.includes(index) ? style.holiday : ''}`,
|
|
25
26
|
"data-title": dayName,
|
|
26
27
|
"aria-label": dayName
|
|
27
28
|
}, dayNamesShort[index])));
|
|
@@ -96,7 +96,7 @@ exports[`DateTime rendering the isActive is true and isDefaultPosition is true 1
|
|
|
96
96
|
>
|
|
97
97
|
<div
|
|
98
98
|
aria-label="Sunday"
|
|
99
|
-
class="daysStr grid
|
|
99
|
+
class="daysStr grid holiday shrinkOff"
|
|
100
100
|
data-id="boxComponent"
|
|
101
101
|
data-selector-id="box"
|
|
102
102
|
data-test-id="boxComponent"
|
|
@@ -178,7 +178,7 @@ exports[`DateTime rendering the isActive is true and isDefaultPosition is true 1
|
|
|
178
178
|
>
|
|
179
179
|
<div
|
|
180
180
|
aria-label="25"
|
|
181
|
-
class="datesStr grid
|
|
181
|
+
class="datesStr grid holiday invalidDate shrinkOff"
|
|
182
182
|
data-id="dateTime_invalidDate"
|
|
183
183
|
data-selector-id="box"
|
|
184
184
|
data-test-id="dateTime_invalidDate"
|
|
@@ -248,7 +248,7 @@ exports[`DateTime rendering the isActive is true and isDefaultPosition is true 1
|
|
|
248
248
|
>
|
|
249
249
|
<div
|
|
250
250
|
aria-label="2"
|
|
251
|
-
class="datesStr grid
|
|
251
|
+
class="datesStr grid holiday shrinkOff"
|
|
252
252
|
data-id="dateTime_date"
|
|
253
253
|
data-selector-id="box"
|
|
254
254
|
data-test-id="dateTime_date"
|
|
@@ -318,7 +318,7 @@ exports[`DateTime rendering the isActive is true and isDefaultPosition is true 1
|
|
|
318
318
|
>
|
|
319
319
|
<div
|
|
320
320
|
aria-label="9"
|
|
321
|
-
class="datesStr grid
|
|
321
|
+
class="datesStr grid holiday shrinkOff"
|
|
322
322
|
data-id="dateTime_date"
|
|
323
323
|
data-selector-id="box"
|
|
324
324
|
data-test-id="dateTime_date"
|
|
@@ -388,7 +388,7 @@ exports[`DateTime rendering the isActive is true and isDefaultPosition is true 1
|
|
|
388
388
|
>
|
|
389
389
|
<div
|
|
390
390
|
aria-label="16"
|
|
391
|
-
class="datesStr grid
|
|
391
|
+
class="datesStr grid holiday shrinkOff"
|
|
392
392
|
data-id="dateTime_date"
|
|
393
393
|
data-selector-id="box"
|
|
394
394
|
data-test-id="dateTime_date"
|
|
@@ -458,7 +458,7 @@ exports[`DateTime rendering the isActive is true and isDefaultPosition is true 1
|
|
|
458
458
|
>
|
|
459
459
|
<div
|
|
460
460
|
aria-label="23"
|
|
461
|
-
class="datesStr grid
|
|
461
|
+
class="datesStr grid holiday shrinkOff"
|
|
462
462
|
data-id="dateTime_date"
|
|
463
463
|
data-selector-id="box"
|
|
464
464
|
data-test-id="dateTime_date"
|
|
@@ -528,7 +528,7 @@ exports[`DateTime rendering the isActive is true and isDefaultPosition is true 1
|
|
|
528
528
|
>
|
|
529
529
|
<div
|
|
530
530
|
aria-label="30"
|
|
531
|
-
class="datesStr grid
|
|
531
|
+
class="datesStr grid holiday shrinkOff"
|
|
532
532
|
data-id="dateTime_date"
|
|
533
533
|
data-selector-id="box"
|
|
534
534
|
data-test-id="dateTime_date"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export const CalendarView_defaultProps = {
|
|
2
2
|
dataId: 'dateContainer',
|
|
3
|
-
needBorder: true
|
|
3
|
+
needBorder: true,
|
|
4
|
+
weekStartDay: 0,
|
|
5
|
+
holidays: [0]
|
|
4
6
|
};
|
|
5
7
|
export const Span_defaultProps = {
|
|
6
8
|
dataId: 'calendar-view'
|
|
@@ -21,7 +23,9 @@ export const DateTime_defaultProps = {
|
|
|
21
23
|
is24Hour: false,
|
|
22
24
|
isDefaultPosition: false,
|
|
23
25
|
customDateFormat: null,
|
|
24
|
-
customProps: {}
|
|
26
|
+
customProps: {},
|
|
27
|
+
weekStartDay: 0,
|
|
28
|
+
holidays: [0]
|
|
25
29
|
};
|
|
26
30
|
export const DateWidget_defaultProps = {
|
|
27
31
|
borderColor: 'default',
|
|
@@ -44,7 +48,9 @@ export const DateWidget_defaultProps = {
|
|
|
44
48
|
needErrorOnBlur: false,
|
|
45
49
|
isEditable: false,
|
|
46
50
|
iconOnHover: false,
|
|
47
|
-
is24Hour: false
|
|
51
|
+
is24Hour: false,
|
|
52
|
+
weekStartDay: 0,
|
|
53
|
+
holidays: [0]
|
|
48
54
|
};
|
|
49
55
|
export const YearView_defaultProps = {
|
|
50
56
|
dataId: 'dateContainer',
|
|
@@ -11,7 +11,9 @@ export const CalendarView_propTypes = {
|
|
|
11
11
|
dayNamesShort: PropTypes.array,
|
|
12
12
|
todayMonth: PropTypes.string,
|
|
13
13
|
todayDate: PropTypes.string,
|
|
14
|
-
todayYear: PropTypes.string
|
|
14
|
+
todayYear: PropTypes.string,
|
|
15
|
+
weekStartDay: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
|
|
16
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
15
17
|
};
|
|
16
18
|
export const Span_propTypes = {
|
|
17
19
|
dataId: PropTypes.string,
|
|
@@ -73,7 +75,9 @@ export const DateTime_propTypes = {
|
|
|
73
75
|
targetOffset: PropTypes.string,
|
|
74
76
|
isRestrictScroll: PropTypes.bool,
|
|
75
77
|
dropBoxPortalId: PropTypes.string,
|
|
76
|
-
customProps: PropTypes.object
|
|
78
|
+
customProps: PropTypes.object,
|
|
79
|
+
weekStartDay: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
|
|
80
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
77
81
|
};
|
|
78
82
|
export const DateWidget_propTypes = {
|
|
79
83
|
borderColor: PropTypes.oneOf(['transparent', 'default']),
|
|
@@ -142,7 +146,9 @@ export const DateWidget_propTypes = {
|
|
|
142
146
|
dropBoxPortalId: PropTypes.string,
|
|
143
147
|
a11y: PropTypes.object,
|
|
144
148
|
getPopupProps: PropTypes.func,
|
|
145
|
-
customProps: PropTypes.object
|
|
149
|
+
customProps: PropTypes.object,
|
|
150
|
+
weekStartDay: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
|
|
151
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
146
152
|
};
|
|
147
153
|
export const YearView_propTypes = {
|
|
148
154
|
onSelectMonth: PropTypes.func,
|
|
@@ -169,7 +175,8 @@ export const DateTimePopupHeader_propTypes = {
|
|
|
169
175
|
};
|
|
170
176
|
export const DaysRow_propTypes = {
|
|
171
177
|
dayNames: PropTypes.array,
|
|
172
|
-
dayNamesShort: PropTypes.object
|
|
178
|
+
dayNamesShort: PropTypes.object,
|
|
179
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
173
180
|
};
|
|
174
181
|
export const Time_propTypes = {
|
|
175
182
|
timeText: PropTypes.string,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/no-unknown-property */
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import useDropboxPosCalc from "./useDropboxPosCalc";
|
|
3
4
|
import cssJSLogic from "./css/cssJSLogic";
|
|
@@ -108,7 +109,8 @@ export default function DropBoxElement(props) {
|
|
|
108
109
|
"aria-labelledby": ariaLabelledby,
|
|
109
110
|
tabIndex: tabIndex,
|
|
110
111
|
onAnimationEnd: isAnimate && FireOnAnimationEnd,
|
|
111
|
-
"data-a11y-focus-main-area": true
|
|
112
|
+
"data-a11y-focus-main-area": true,
|
|
113
|
+
"dot-ui-element": "dropbox"
|
|
112
114
|
}, /*#__PURE__*/React.createElement("div", {
|
|
113
115
|
tabIndex: "-1",
|
|
114
116
|
className: `${subContainerClass} ${style[`${palette}Palette`]}`,
|
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,12 @@ 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.handleIntersectionObserver = this.handleIntersectionObserver.bind(this);
|
|
92
99
|
this.popupObserver = new ResizeObserver(this.handlePopupResize); //dropBoxSize
|
|
93
100
|
|
|
94
101
|
this.size = null;
|
|
@@ -101,6 +108,7 @@ const Popup = function (Component) {
|
|
|
101
108
|
scrollDebounceTime
|
|
102
109
|
} = this.getScrollDebounceTime(this);
|
|
103
110
|
this.handleScroll = debounce(this.handleScroll.bind(this), scrollDebounceTime);
|
|
111
|
+
this.handleDebouncedPositionChange = debounce(this.handlePositionChange.bind(this), 100);
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
componentDidMount() {
|
|
@@ -144,7 +152,9 @@ const Popup = function (Component) {
|
|
|
144
152
|
dropElement
|
|
145
153
|
} = this;
|
|
146
154
|
const {
|
|
147
|
-
needResizeHandling: propResizeHandling
|
|
155
|
+
needResizeHandling: propResizeHandling,
|
|
156
|
+
isAbsolutePositioningNeeded,
|
|
157
|
+
isOutsideScrollBlocked
|
|
148
158
|
} = this.props;
|
|
149
159
|
|
|
150
160
|
if (oldStateOpen !== isPopupReady) {
|
|
@@ -154,6 +164,16 @@ const Popup = function (Component) {
|
|
|
154
164
|
this.size = null;
|
|
155
165
|
this.popupObserver.disconnect();
|
|
156
166
|
}
|
|
167
|
+
|
|
168
|
+
if (isOutsideScrollBlocked && !isAbsolutePositioningNeeded) {
|
|
169
|
+
if (isPopupReady) {
|
|
170
|
+
addIntersectionObserver(this.placeHolderElement, this.handleIntersectionObserver);
|
|
171
|
+
this.addScrollBlockListeners();
|
|
172
|
+
} else {
|
|
173
|
+
removeIntersectionObserver(this.placeHolderElement, this.handleIntersectionObserver);
|
|
174
|
+
this.removeScrollBlockListeners();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
157
177
|
}
|
|
158
178
|
}
|
|
159
179
|
|
|
@@ -169,6 +189,8 @@ const Popup = function (Component) {
|
|
|
169
189
|
|
|
170
190
|
return res;
|
|
171
191
|
}, popups);
|
|
192
|
+
removeIntersectionObserver(this.placeHolderElement, this.handleIntersectionObserver);
|
|
193
|
+
this.removeScrollBlockListeners();
|
|
172
194
|
let noPopups = true;
|
|
173
195
|
|
|
174
196
|
for (const i in popups) {
|
|
@@ -193,6 +215,82 @@ const Popup = function (Component) {
|
|
|
193
215
|
}
|
|
194
216
|
}
|
|
195
217
|
|
|
218
|
+
addScrollBlockListeners() {
|
|
219
|
+
document.addEventListener('wheel', this.handleBlockScroll, {
|
|
220
|
+
capture: true,
|
|
221
|
+
passive: false
|
|
222
|
+
});
|
|
223
|
+
document.addEventListener('touchmove', this.handleBlockScroll, {
|
|
224
|
+
capture: true,
|
|
225
|
+
passive: false
|
|
226
|
+
});
|
|
227
|
+
document.addEventListener('scroll', this.handleDebouncedPositionChange, {
|
|
228
|
+
capture: true,
|
|
229
|
+
passive: false
|
|
230
|
+
});
|
|
231
|
+
document.addEventListener('keydown', this.preventKeyboardScroll, {
|
|
232
|
+
capture: true,
|
|
233
|
+
passive: false
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
removeScrollBlockListeners() {
|
|
238
|
+
document.removeEventListener('wheel', this.handleBlockScroll, {
|
|
239
|
+
capture: true,
|
|
240
|
+
passive: false
|
|
241
|
+
});
|
|
242
|
+
document.removeEventListener('touchmove', this.handleBlockScroll, {
|
|
243
|
+
capture: true,
|
|
244
|
+
passive: false
|
|
245
|
+
});
|
|
246
|
+
document.removeEventListener('scroll', this.handleDebouncedPositionChange, {
|
|
247
|
+
capture: true,
|
|
248
|
+
passive: false
|
|
249
|
+
});
|
|
250
|
+
document.removeEventListener('keydown', this.preventKeyboardScroll, {
|
|
251
|
+
capture: true,
|
|
252
|
+
passive: false
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
handleBlockScroll(event) {
|
|
257
|
+
// const targetElement = this.placeHolderElement;
|
|
258
|
+
const containerElement = this.dropElement;
|
|
259
|
+
|
|
260
|
+
if (containerElement && containerElement !== event.target && !containerElement.contains(event.target)) {
|
|
261
|
+
// --- Scroll exclude Target & Container elements --- For reference. Will adopt in future
|
|
262
|
+
// if(
|
|
263
|
+
// (containerElement && (containerElement !== event.target && !containerElement.contains(event.target)))
|
|
264
|
+
// && (targetElement && (targetElement !== event.target && !targetElement.contains(event.target)))
|
|
265
|
+
// ) {
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
handlePositionChange(event) {
|
|
271
|
+
const targetElement = this.placeHolderElement;
|
|
272
|
+
const containerElement = this.dropElement;
|
|
273
|
+
|
|
274
|
+
if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && targetElement && targetElement !== event.target && !targetElement.contains(event.target) && event.target.contains(targetElement)) {
|
|
275
|
+
this.handlePopupPosition(this.state.position); // this.closePopupOnly(event);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
preventKeyboardScroll(event) {
|
|
280
|
+
const containerElement = this.dropElement;
|
|
281
|
+
const keys = [32, 37, 38, 39, 40]; // Space, Arrow keys
|
|
282
|
+
|
|
283
|
+
if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && keys.includes(event.keyCode)) {
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
handleIntersectionObserver(entry) {
|
|
289
|
+
if (entry.intersectionRatio === 0) {
|
|
290
|
+
this.closePopupOnly();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
196
294
|
getGroup() {
|
|
197
295
|
const {
|
|
198
296
|
popupGroup
|
|
@@ -523,13 +621,15 @@ const Popup = function (Component) {
|
|
|
523
621
|
} = betterPosition || {};
|
|
524
622
|
const {
|
|
525
623
|
left: oldLeft = '',
|
|
526
|
-
top: oldTop = ''
|
|
624
|
+
top: oldTop = '',
|
|
625
|
+
bottom: oldBottom = ''
|
|
527
626
|
} = positionsOffset[position] || {};
|
|
528
627
|
const {
|
|
529
628
|
left = '',
|
|
530
|
-
top = ''
|
|
629
|
+
top = '',
|
|
630
|
+
bottom = ''
|
|
531
631
|
} = viewsOffset[view] || {};
|
|
532
|
-
const changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top; // let isInViewPort = viewPort.isInViewPort(
|
|
632
|
+
const changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top || oldBottom !== bottom; // let isInViewPort = viewPort.isInViewPort(
|
|
533
633
|
// placeHolderElement,
|
|
534
634
|
// scrollContainer
|
|
535
635
|
// );
|
|
@@ -635,9 +735,8 @@ const Popup = function (Component) {
|
|
|
635
735
|
}
|
|
636
736
|
|
|
637
737
|
Popup.displayName = Component.displayName || Component.name || Popup.name;
|
|
638
|
-
Popup.contextTypes =
|
|
639
|
-
|
|
640
|
-
};
|
|
738
|
+
Popup.contextTypes = ContextTypes;
|
|
739
|
+
Popup.propTypes = PopupPropTypes;
|
|
641
740
|
return hoistStatics(Popup, Component);
|
|
642
741
|
};
|
|
643
742
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
let observerCallbacks = null;
|
|
2
|
+
let intersectionObserver = null;
|
|
3
|
+
|
|
4
|
+
function handleObserverCallbacks(entries) {
|
|
5
|
+
entries.map((entry, i) => {
|
|
6
|
+
let oldCallbacks = observerCallbacks.get(entry.target);
|
|
7
|
+
oldCallbacks.length && oldCallbacks.forEach(callback => {
|
|
8
|
+
callback && callback(entry);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function addIntersectionObserver(element, callback, options) {
|
|
14
|
+
if (intersectionObserver === null && observerCallbacks === null) {
|
|
15
|
+
intersectionObserver = new IntersectionObserver(entries => {
|
|
16
|
+
handleObserverCallbacks(entries);
|
|
17
|
+
}, options);
|
|
18
|
+
observerCallbacks = new Map();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
intersectionObserver.observe(element);
|
|
22
|
+
let oldCallbacks = observerCallbacks.get(element) || [];
|
|
23
|
+
observerCallbacks.set(element, [...oldCallbacks, callback]);
|
|
24
|
+
}
|
|
25
|
+
export function removeIntersectionObserver(element, callback) {
|
|
26
|
+
let oldCallbacks = observerCallbacks ? observerCallbacks.get(element) : [];
|
|
27
|
+
oldCallbacks = oldCallbacks.filter(handler => handler !== callback);
|
|
28
|
+
|
|
29
|
+
if (intersectionObserver && oldCallbacks.length === 0) {
|
|
30
|
+
observerCallbacks.delete(element);
|
|
31
|
+
intersectionObserver.unobserve(element);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (intersectionObserver && observerCallbacks && observerCallbacks.size === 0) {
|
|
35
|
+
intersectionObserver.disconnect();
|
|
36
|
+
intersectionObserver = null;
|
|
37
|
+
observerCallbacks = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -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/TextBox/TextBox.js
CHANGED
|
@@ -169,7 +169,7 @@ export default class TextBox extends React.PureComponent {
|
|
|
169
169
|
ref: this.inputRef,
|
|
170
170
|
type: type,
|
|
171
171
|
value: value,
|
|
172
|
-
onScroll: isScrollPrevent ? this.handlePreventTextBoxScroll :
|
|
172
|
+
onScroll: isScrollPrevent ? this.handlePreventTextBoxScroll : null,
|
|
173
173
|
onKeyPress: onKeyPress,
|
|
174
174
|
onMouseDown: onMouseDown,
|
|
175
175
|
...options,
|