@zohodesk/components 1.2.49 → 1.2.51
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 +19 -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/Popup/Popup.js +32 -13
- package/es/Popup/intersectionObserver.js +33 -23
- 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/Popup/Popup.js +32 -14
- package/lib/Popup/intersectionObserver.js +35 -25
- 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 +3 -3
- package/result.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,25 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
32
32
|
- TextBoxIcon
|
|
33
33
|
- Tooltip
|
|
34
34
|
|
|
35
|
-
# 1.2.
|
|
35
|
+
# 1.2.51
|
|
36
|
+
|
|
37
|
+
- **Popup** - Fixed issue: Error on unmount when target ref is not available.
|
|
38
|
+
|
|
39
|
+
# 1.2.50
|
|
40
|
+
|
|
41
|
+
- **DateTime (v0&v1), CalendarView (v0&v1)**
|
|
42
|
+
|
|
43
|
+
- Week starting day customization support added with `weekStartDay` props and week holiday customization support with `holidays` prop
|
|
44
|
+
|
|
45
|
+
- **DateWidget (v0&v1)**
|
|
46
|
+
|
|
47
|
+
- Support has been added for `weekStartDay`, `holidays` props
|
|
48
|
+
|
|
49
|
+
- **DaysRow (v0&v1)**
|
|
50
|
+
|
|
51
|
+
- `holidays` prop added for holiday column indication
|
|
52
|
+
|
|
53
|
+
# 1.2.49
|
|
36
54
|
|
|
37
55
|
- **Popup**
|
|
38
56
|
- `isOutsideScrollBlocked` prop supported - Scroll blocking behaviours supported
|
|
@@ -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,
|
package/es/Popup/Popup.js
CHANGED
|
@@ -95,6 +95,8 @@ const Popup = function (Component) {
|
|
|
95
95
|
this.preventKeyboardScroll = this.preventKeyboardScroll.bind(this);
|
|
96
96
|
this.addScrollBlockListeners = this.addScrollBlockListeners.bind(this);
|
|
97
97
|
this.removeScrollBlockListeners = this.removeScrollBlockListeners.bind(this);
|
|
98
|
+
this.handleAddingScrollBlock = this.handleAddingScrollBlock.bind(this);
|
|
99
|
+
this.handleRemovingScrollBlock = this.handleRemovingScrollBlock.bind(this);
|
|
98
100
|
this.handleIntersectionObserver = this.handleIntersectionObserver.bind(this);
|
|
99
101
|
this.popupObserver = new ResizeObserver(this.handlePopupResize); //dropBoxSize
|
|
100
102
|
|
|
@@ -152,9 +154,7 @@ const Popup = function (Component) {
|
|
|
152
154
|
dropElement
|
|
153
155
|
} = this;
|
|
154
156
|
const {
|
|
155
|
-
needResizeHandling: propResizeHandling
|
|
156
|
-
isAbsolutePositioningNeeded,
|
|
157
|
-
isOutsideScrollBlocked
|
|
157
|
+
needResizeHandling: propResizeHandling
|
|
158
158
|
} = this.props;
|
|
159
159
|
|
|
160
160
|
if (oldStateOpen !== isPopupReady) {
|
|
@@ -165,14 +165,10 @@ const Popup = function (Component) {
|
|
|
165
165
|
this.popupObserver.disconnect();
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
} else {
|
|
173
|
-
removeIntersectionObserver(this.placeHolderElement, this.handleIntersectionObserver);
|
|
174
|
-
this.removeScrollBlockListeners();
|
|
175
|
-
}
|
|
168
|
+
if (isPopupReady) {
|
|
169
|
+
this.handleAddingScrollBlock();
|
|
170
|
+
} else {
|
|
171
|
+
this.handleRemovingScrollBlock();
|
|
176
172
|
}
|
|
177
173
|
}
|
|
178
174
|
}
|
|
@@ -189,8 +185,7 @@ const Popup = function (Component) {
|
|
|
189
185
|
|
|
190
186
|
return res;
|
|
191
187
|
}, popups);
|
|
192
|
-
|
|
193
|
-
this.removeScrollBlockListeners();
|
|
188
|
+
this.handleRemovingScrollBlock();
|
|
194
189
|
let noPopups = true;
|
|
195
190
|
|
|
196
191
|
for (const i in popups) {
|
|
@@ -215,6 +210,30 @@ const Popup = function (Component) {
|
|
|
215
210
|
}
|
|
216
211
|
}
|
|
217
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
|
+
|
|
218
237
|
addScrollBlockListeners() {
|
|
219
238
|
document.addEventListener('wheel', this.handleBlockScroll, {
|
|
220
239
|
capture: true,
|
|
@@ -2,38 +2,48 @@ let observerCallbacks = null;
|
|
|
2
2
|
let intersectionObserver = null;
|
|
3
3
|
|
|
4
4
|
function handleObserverCallbacks(entries) {
|
|
5
|
-
entries.
|
|
5
|
+
entries.forEach(entry => {
|
|
6
6
|
let oldCallbacks = observerCallbacks.get(entry.target);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
if (Array.isArray(oldCallbacks) && oldCallbacks.length) {
|
|
9
|
+
oldCallbacks.forEach(callback => {
|
|
10
|
+
callback && callback(entry);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
10
13
|
});
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export function addIntersectionObserver(element, callback, options) {
|
|
14
|
-
if (
|
|
15
|
-
intersectionObserver
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
}
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
intersectionObserver.observe(element);
|
|
26
|
+
let oldCallbacks = observerCallbacks.get(element) || [];
|
|
27
|
+
observerCallbacks.set(element, [...oldCallbacks, callback]);
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
export function removeIntersectionObserver(element, callback) {
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
if (!!element && typeof callback == 'function') {
|
|
32
|
+
let oldCallbacks = observerCallbacks ? observerCallbacks.get(element) : null;
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
}
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
if (intersectionObserver && observerCallbacks && observerCallbacks.size === 0) {
|
|
44
|
+
intersectionObserver.disconnect();
|
|
45
|
+
intersectionObserver = null;
|
|
46
|
+
observerCallbacks = null;
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
}
|
|
@@ -34,10 +34,12 @@ export default class CalendarView extends React.PureComponent {
|
|
|
34
34
|
todayDate,
|
|
35
35
|
todayYear,
|
|
36
36
|
startDate,
|
|
37
|
-
endDate
|
|
37
|
+
endDate,
|
|
38
|
+
weekStartDay,
|
|
39
|
+
holidays
|
|
38
40
|
} = this.props;
|
|
39
41
|
const userSeeDate = new Date(year, month, 1);
|
|
40
|
-
const userSeeDay = userSeeDate.getDay() + 1;
|
|
42
|
+
const userSeeDay = (userSeeDate.getDay() - weekStartDay + dayNames.length) % dayNames.length + 1;
|
|
41
43
|
const userSeeYear = userSeeDate.getFullYear();
|
|
42
44
|
const userSeeMonth = userSeeDate.getMonth();
|
|
43
45
|
const monthEnd = getMonthEnd(month, year);
|
|
@@ -65,10 +67,10 @@ export default class CalendarView extends React.PureComponent {
|
|
|
65
67
|
let output = null;
|
|
66
68
|
|
|
67
69
|
for (let i = 1; i <= 7; i++) {
|
|
68
|
-
let tdclass = `${style.datesStr} ${style.grid}`;
|
|
70
|
+
let tdclass = `${style.datesStr} ${style.grid}`; // if (i === 1) {
|
|
69
71
|
|
|
70
|
-
if (i
|
|
71
|
-
tdclass += ` ${style.
|
|
72
|
+
if (holidays.includes(i - 1)) {
|
|
73
|
+
tdclass += ` ${style.holiday}`;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
if (incremleti >= userSeeDay && incremday <= monthEnd) {
|
|
@@ -177,7 +179,8 @@ export default class CalendarView extends React.PureComponent {
|
|
|
177
179
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DaysRow, {
|
|
178
180
|
dayNames: dayNames,
|
|
179
181
|
dayNamesShort: dayNamesShort,
|
|
180
|
-
ariaLabel: dayNamesShort
|
|
182
|
+
ariaLabel: dayNamesShort,
|
|
183
|
+
holidays: holidays
|
|
181
184
|
}), /*#__PURE__*/React.createElement("div", {
|
|
182
185
|
"data-id": `${dataId}_dateContainer`,
|
|
183
186
|
"data-test-id": `${dataId}_dateContainer`,
|
|
@@ -652,7 +652,9 @@ export default class DateTime extends React.PureComponent {
|
|
|
652
652
|
dropBoxPortalId,
|
|
653
653
|
startDate,
|
|
654
654
|
endDate,
|
|
655
|
-
customProps = {}
|
|
655
|
+
customProps = {},
|
|
656
|
+
holidays,
|
|
657
|
+
weekStartDay
|
|
656
658
|
} = this.props;
|
|
657
659
|
const {
|
|
658
660
|
TimeProps = {}
|
|
@@ -671,6 +673,16 @@ export default class DateTime extends React.PureComponent {
|
|
|
671
673
|
dayNamesShort = dayNamesShortDefault
|
|
672
674
|
} = i18nKeys;
|
|
673
675
|
const showmonthtxt = title(date, year, month, monthNames);
|
|
676
|
+
let customDayNames = dayNames,
|
|
677
|
+
customDayNamesShort = dayNamesShort,
|
|
678
|
+
customizedHolidays = holidays;
|
|
679
|
+
|
|
680
|
+
if (weekStartDay !== 0) {
|
|
681
|
+
customDayNames = [...dayNames.slice(weekStartDay), ...dayNames.slice(0, weekStartDay)];
|
|
682
|
+
customDayNamesShort = [...dayNamesShort.slice(weekStartDay), ...dayNamesShort.slice(0, weekStartDay)];
|
|
683
|
+
customizedHolidays = holidays.map(dayIndex => customDayNames.indexOf(dayNames[dayIndex]));
|
|
684
|
+
}
|
|
685
|
+
|
|
674
686
|
const childEle = /*#__PURE__*/React.createElement("div", {
|
|
675
687
|
className: `${style.container} ${innerClass}`,
|
|
676
688
|
"data-id": `${dataId}_Calendar`,
|
|
@@ -692,13 +704,15 @@ export default class DateTime extends React.PureComponent {
|
|
|
692
704
|
year: year,
|
|
693
705
|
month: month,
|
|
694
706
|
onSelect: this.dateSelect,
|
|
695
|
-
dayNames:
|
|
696
|
-
dayNamesShort:
|
|
707
|
+
dayNames: customDayNames,
|
|
708
|
+
dayNamesShort: customDayNamesShort,
|
|
697
709
|
todayDate: todayDate,
|
|
698
710
|
todayMonth: todayMonth,
|
|
699
711
|
todayYear: todayYear,
|
|
700
712
|
startDate: startDate,
|
|
701
|
-
endDate: endDate
|
|
713
|
+
endDate: endDate,
|
|
714
|
+
weekStartDay: weekStartDay,
|
|
715
|
+
holidays: customizedHolidays
|
|
702
716
|
}), isDateTimeField ? /*#__PURE__*/React.createElement(Time, {
|
|
703
717
|
timeText: timeText,
|
|
704
718
|
dataId: dataId,
|
|
@@ -1006,6 +1006,8 @@ class DateWidgetComponent extends React.Component {
|
|
|
1006
1006
|
onError,
|
|
1007
1007
|
startDate,
|
|
1008
1008
|
endDate,
|
|
1009
|
+
weekStartDay,
|
|
1010
|
+
holidays,
|
|
1009
1011
|
customProps = {}
|
|
1010
1012
|
} = this.props;
|
|
1011
1013
|
const {
|
|
@@ -1105,7 +1107,9 @@ class DateWidgetComponent extends React.Component {
|
|
|
1105
1107
|
onError: onError,
|
|
1106
1108
|
startDate: startDate,
|
|
1107
1109
|
endDate: endDate,
|
|
1108
|
-
customProps: DateTimeProps
|
|
1110
|
+
customProps: DateTimeProps,
|
|
1111
|
+
weekStartDay: weekStartDay,
|
|
1112
|
+
holidays: holidays
|
|
1109
1113
|
}));
|
|
1110
1114
|
}
|
|
1111
1115
|
|
|
@@ -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])));
|
|
@@ -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'
|
|
@@ -20,7 +22,9 @@ export const DateTime_defaultProps = {
|
|
|
20
22
|
i18nKeys: {},
|
|
21
23
|
is24Hour: false,
|
|
22
24
|
isDefaultPosition: false,
|
|
23
|
-
customDateFormat: null
|
|
25
|
+
customDateFormat: null,
|
|
26
|
+
weekStartDay: 0,
|
|
27
|
+
holidays: [0]
|
|
24
28
|
};
|
|
25
29
|
export const DateWidget_defaultProps = {
|
|
26
30
|
borderColor: 'default',
|
|
@@ -43,7 +47,9 @@ export const DateWidget_defaultProps = {
|
|
|
43
47
|
needErrorOnBlur: false,
|
|
44
48
|
isEditable: false,
|
|
45
49
|
iconOnHover: false,
|
|
46
|
-
is24Hour: false
|
|
50
|
+
is24Hour: false,
|
|
51
|
+
weekStartDay: 0,
|
|
52
|
+
holidays: [0]
|
|
47
53
|
};
|
|
48
54
|
export const YearView_defaultProps = {
|
|
49
55
|
dataId: 'dateContainer',
|
|
@@ -13,7 +13,9 @@ export const CalendarView_propTypes = {
|
|
|
13
13
|
todayDate: PropTypes.string,
|
|
14
14
|
todayYear: PropTypes.string,
|
|
15
15
|
startDate: PropTypes.string,
|
|
16
|
-
endDate: PropTypes.string
|
|
16
|
+
endDate: PropTypes.string,
|
|
17
|
+
weekStartDay: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
|
|
18
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
17
19
|
};
|
|
18
20
|
export const Span_propTypes = {
|
|
19
21
|
dataId: PropTypes.string,
|
|
@@ -79,7 +81,9 @@ export const DateTime_propTypes = {
|
|
|
79
81
|
dropBoxPortalId: PropTypes.string,
|
|
80
82
|
startDate: PropTypes.string,
|
|
81
83
|
endDate: PropTypes.string,
|
|
82
|
-
customProps: PropTypes.object
|
|
84
|
+
customProps: PropTypes.object,
|
|
85
|
+
weekStartDay: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
|
|
86
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
83
87
|
};
|
|
84
88
|
export const DateWidget_propTypes = {
|
|
85
89
|
borderColor: PropTypes.oneOf(['transparent', 'default']),
|
|
@@ -150,7 +154,9 @@ export const DateWidget_propTypes = {
|
|
|
150
154
|
startDate: PropTypes.string,
|
|
151
155
|
endDate: PropTypes.string,
|
|
152
156
|
getPopupProps: PropTypes.func,
|
|
153
|
-
customProps: PropTypes.object
|
|
157
|
+
customProps: PropTypes.object,
|
|
158
|
+
weekStartDay: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
|
|
159
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
154
160
|
};
|
|
155
161
|
export const YearView_propTypes = {
|
|
156
162
|
onSelectMonth: PropTypes.func,
|
|
@@ -177,7 +183,8 @@ export const DateTimePopupHeader_propTypes = {
|
|
|
177
183
|
};
|
|
178
184
|
export const DaysRow_propTypes = {
|
|
179
185
|
dayNames: PropTypes.array,
|
|
180
|
-
dayNamesShort: PropTypes.object
|
|
186
|
+
dayNamesShort: PropTypes.object,
|
|
187
|
+
holidays: PropTypes.arrayOf(PropTypes.number)
|
|
181
188
|
};
|
|
182
189
|
export const Time_propTypes = {
|
|
183
190
|
timeText: PropTypes.string,
|