@zohodesk/components 1.0.0-temp-199.2 → 1.0.0-temp-210.3

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.
Files changed (41) hide show
  1. package/README.md +7 -1
  2. package/es/ListItem/ListItem.js +2 -2
  3. package/es/ListItem/ListItem.module.css +18 -85
  4. package/es/ListItem/ListItemWithAvatar.js +3 -3
  5. package/es/ListItem/ListItemWithIcon.js +2 -2
  6. package/es/MultiSelect/AdvancedGroupMultiSelect.js +2 -7
  7. package/es/MultiSelect/AdvancedMultiSelect.js +1 -2
  8. package/es/MultiSelect/MultiSelect.js +2 -7
  9. package/es/MultiSelect/Suggestions.js +4 -8
  10. package/es/MultiSelect/props/defaultProps.js +4 -6
  11. package/es/MultiSelect/props/propTypes.js +2 -4
  12. package/es/Popup/Popup.js +106 -8
  13. package/es/Popup/intersectionObserver.js +39 -0
  14. package/es/Popup/props/propTypes.js +31 -0
  15. package/es/Select/GroupSelect.js +2 -7
  16. package/es/Select/SelectWithAvatar.js +2 -7
  17. package/es/Select/SelectWithIcon.js +2 -4
  18. package/es/Select/props/defaultProps.js +2 -4
  19. package/es/Select/props/propTypes.js +2 -4
  20. package/es/v1/Popup/Popup.js +96 -8
  21. package/lib/ListItem/ListItem.js +2 -2
  22. package/lib/ListItem/ListItem.module.css +18 -85
  23. package/lib/ListItem/ListItemWithAvatar.js +3 -3
  24. package/lib/ListItem/ListItemWithIcon.js +2 -2
  25. package/lib/MultiSelect/AdvancedGroupMultiSelect.js +3 -7
  26. package/lib/MultiSelect/AdvancedMultiSelect.js +1 -3
  27. package/lib/MultiSelect/MultiSelect.js +3 -6
  28. package/lib/MultiSelect/Suggestions.js +4 -8
  29. package/lib/MultiSelect/props/defaultProps.js +4 -6
  30. package/lib/MultiSelect/props/propTypes.js +5 -6
  31. package/lib/Popup/Popup.js +117 -9
  32. package/lib/Popup/intersectionObserver.js +62 -0
  33. package/lib/Popup/props/propTypes.js +44 -0
  34. package/lib/Select/GroupSelect.js +3 -8
  35. package/lib/Select/SelectWithAvatar.js +3 -8
  36. package/lib/Select/SelectWithIcon.js +3 -5
  37. package/lib/Select/props/defaultProps.js +2 -4
  38. package/lib/Select/props/propTypes.js +2 -4
  39. package/lib/v1/Popup/Popup.js +105 -9
  40. package/package.json +2 -2
  41. package/result.json +1 -1
package/README.md CHANGED
@@ -32,6 +32,12 @@ In this Package, we Provide Some Basic Components to Build Web App
32
32
  - TextBoxIcon
33
33
  - Tooltip
34
34
 
35
+ # 1.2.48
36
+
37
+ - **Popup**
38
+ - `isOutsideScrollBlocked` prop supported - Scroll blocking behviours supported
39
+ - Fixed popup re-positioning on window resize not working properly - Issue fixed
40
+
35
41
  # 1.2.47
36
42
 
37
43
  - **DateTime**
@@ -97,7 +103,7 @@ In this Package, we Provide Some Basic Components to Build Web App
97
103
 
98
104
  - **LibraryContext** - coloredTagVariant, hasTagColorInheritedToText properties added
99
105
  - **Tag** - customAttributes prop supported
100
- - **TextBoxIcon** - needInputFocusOnParentClick prop supported
106
+ - **TextBoxIcon** - needInputFocusOnWrapperClick prop supported
101
107
 
102
108
  # 1.2.38
103
109
 
@@ -100,7 +100,7 @@ export default class ListItem extends React.Component {
100
100
  autoHover: autoHover,
101
101
  needTick: needTick,
102
102
  needBorder: needBorder,
103
- customClass: `${needMultiLineText ? style.txtAlignBaseLine + ' ' + style.autoHeight : ''} ${customListItem}`,
103
+ customClass: customListItem,
104
104
  dataId: dataIdString,
105
105
  dataSelectorId: `${dataSelectorId}`,
106
106
  isLink: isLink,
@@ -122,7 +122,7 @@ export default class ListItem extends React.Component {
122
122
  adjust: true,
123
123
  className: style.children
124
124
  }, children) : null, needTick && active ? /*#__PURE__*/React.createElement(Box, {
125
- className: `${style.tickIcon} ${tickIconPalette} ${customTickIcon} ${needMultiLineText ? style.tickIconCenter : ''}`,
125
+ className: `${style.tickIcon} ${tickIconPalette} ${customTickIcon}`,
126
126
  "aria-hidden": ariaHidden,
127
127
  dataId: `${dataIdString}_tickIcon`,
128
128
  dataSelectorId: `${dataSelectorId}_tickIcon`
@@ -17,9 +17,8 @@
17
17
  }[dir=ltr] .varClass {
18
18
  --listitem_avatar_margin: 0 var(--zd_size15) 0 0;
19
19
  }[dir=rtl] .varClass {
20
- --listitem_avatar_margin: 0 var(--zd_size15) 0 0;
20
+ --listitem_avatar_margin: 0 0 0 var(--zd_size15);
21
21
  }
22
-
23
22
  .list {
24
23
  composes: varClass;
25
24
  position: relative;
@@ -35,84 +34,62 @@
35
34
  border-color: var(--listitem_border_color);
36
35
  cursor: pointer;
37
36
  }
38
-
39
37
  .list, .default, .secondary {
40
38
  background-color: var(--listitem_bg_color);
41
39
  }
42
-
43
40
  [dir=ltr] .withBorder {
44
- --listitem_border_width: 0 0 0 1px
45
- /*rtl: 0 1px 0 0*/
46
- ;
41
+ --listitem_border_width: 0 0 0 1px /*rtl: 0 1px 0 0*/;
47
42
  }
48
-
49
43
  [dir=rtl] .withBorder {
50
- --listitem_border_width: 0 0 0 1px ;
44
+ --listitem_border_width: 0 1px 0 0;
51
45
  }
52
-
53
46
  .active {
54
47
  --listitem_border_color: var(--zdt_listitem_active_border);
55
48
  }
56
-
57
49
  [dir=ltr] .small {
58
50
  --listitem_padding: var(--zd_size7) var(--zd_size3) var(--zd_size7) var(--zd_size5);
59
51
  }
60
-
61
52
  [dir=rtl] .small {
62
- --listitem_padding: var(--zd_size7) var(--zd_size3) var(--zd_size7) var(--zd_size5);
53
+ --listitem_padding: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size3);
63
54
  }
64
-
65
55
  .medium {
66
56
  --listitem_padding: var(--zd_size7) var(--zd_size20);
67
57
  --listitem_min_height: var(--zd_size35);
68
58
  }
69
-
70
59
  .large {
71
60
  --listitem_height: var(--zd_size48);
72
61
  }
73
-
74
62
  [dir=ltr] .large {
75
63
  --listitem_padding: var(--zd_size10) var(--zd_size3) var(--zd_size10) var(--zd_size25);
76
64
  }
77
-
78
65
  [dir=rtl] .large {
79
- --listitem_padding: var(--zd_size10) var(--zd_size3) var(--zd_size10) var(--zd_size25);
66
+ --listitem_padding: var(--zd_size10) var(--zd_size25) var(--zd_size10) var(--zd_size3);
80
67
  }
81
-
82
68
  .value,
83
69
  .children {
84
70
  composes: dotted from '../common/common.module.css';
85
71
  }
86
-
87
- .value {
72
+ .value, .multiLineValue {
88
73
  line-height: 1.5385;
89
74
  }
90
-
91
- .multiLineValue {
92
- line-height: 1.5385;
75
+ .multiLineValue{
93
76
  word-break: break-word;
94
- -webkit-line-clamp: 3;
95
- composes: clamp from '../common/common.module.css';
77
+ composes: clamp from '../common/common.module.css'
96
78
  }
97
-
98
79
  .iconBox {
99
80
  width: var(--zd_size20) ;
100
81
  text-align: center;
101
82
  }
102
-
103
83
  [dir=ltr] .iconBox {
104
84
  margin-right: var(--zd_size10) ;
105
85
  }
106
-
107
86
  [dir=rtl] .iconBox {
108
87
  margin-left: var(--zd_size10) ;
109
88
  }
110
-
111
89
  .iconBox,
112
90
  .leftAvatar {
113
91
  font-size: 0 ;
114
92
  }
115
-
116
93
  .leftAvatar {
117
94
  margin: var(--listitem_avatar_margin);
118
95
  }
@@ -120,78 +97,61 @@
120
97
  .defaultHover, .primaryHover, .secondaryHover, .darkHover {
121
98
  background-color: var(--listitem_highlight_bg_color);
122
99
  }
123
-
124
100
  .activewithBorder {
125
101
  --listitem_border_color: var(--zdt_listitem_active_border);
126
102
  }
127
-
128
103
  [dir=ltr] .activewithBorder {
129
- --listitem_border_width: 0 0 0 1px
130
- /*rtl: 0 1px 0 0*/
131
- ;
104
+ --listitem_border_width: 0 0 0 1px /*rtl: 0 1px 0 0*/;
132
105
  }
133
-
134
106
  [dir=rtl] .activewithBorder {
135
- --listitem_border_width: 0 0 0 1px ;
107
+ --listitem_border_width: 0 1px 0 0;
136
108
  }
137
109
 
138
110
  .defaultHover,
139
111
  .defaultEffect:hover
140
-
141
112
  /* .defaultEffect:focus */
142
- {
113
+ {
143
114
  --listitem_bg_color: var(--zdt_listitem_highlight_bg);
144
115
  }
145
-
146
116
  .primaryHover,
147
117
  .primaryEffect:hover
148
-
149
118
  /* .primaryEffect:focus */
150
- {
119
+ {
151
120
  --listitem_bg_color: var(--zdt_listitem_primary_bg);
152
121
  --listitem_highlight_bg_color: var(--zdt_listitem_primary_bg);
153
122
  }
154
-
155
123
  .secondaryHover,
156
124
  .secondaryEffect:hover
157
-
158
125
  /* .secondaryEffect:focus */
159
- {
126
+ {
160
127
  --listitem_bg_color: var(--zdt_listitem_secondary_bg);
161
128
  --listitem_highlight_bg_color: var(--zdt_listitem_secondary_bg);
162
129
  --listitem_text_color: var(--zdt_listitem_secondary_text);
163
130
  }
164
-
165
131
  .darkHover,
166
132
  .darkEffect:hover
167
-
168
133
  /* .darkEffect:focus */
169
- {
134
+ {
170
135
  --listitem_bg_color: var(--zdt_listitem_dark_effect_bg);
171
136
  --listitem_highlight_bg_color: var(--zdt_listitem_dark_effect_bg);
172
137
  }
173
-
174
138
  .activedefault, .activeprimary, .activesecondary, .activedark {
175
139
  background-color: var(--listitem_active_bg_color);
176
140
  }
177
-
178
141
  .activedefault,
179
142
  .activedefault:hover,
180
143
  .activeprimary,
181
144
  .activeprimary:hover {
182
145
  --listitem_active_bg_color: var(--zdt_listitem_primary_bg);
183
146
  }
184
-
185
147
  .activesecondary {
186
148
  --listitem_active_bg_color: var(--zdt_listitem_secondary_bg);
187
149
  --listitem_text_color: var(--zdt_listitem_secondary_text);
188
150
  }
189
-
190
151
  .dark {
191
152
  --listitem_bg_color: var(--zdt_listitem_dark_bg);
192
153
  --listitem_text_color: var(--zdt_listitem_dark_text);
193
154
  }
194
-
195
155
  .activedark {
196
156
  --listitem_active_bg_color: var(--zdt_listitem_dark_active_bg);
197
157
  }
@@ -210,63 +170,36 @@
210
170
  [dir=rtl] .tickIcon, [dir=rtl] .defaultTick, [dir=rtl] .darkTick {
211
171
  left: var(--zd_size20) ;
212
172
  }
213
-
214
173
  .defaultTick {
215
174
  --listitem_tickicon_color: var(--zdt_listitem_default_tickicon);
216
175
  }
217
-
218
176
  .darkTick {
219
177
  --listitem_tickicon_color: var(--zdt_listitem_dark_tickicon);
220
178
  }
221
-
222
- .defaultTick>i {
179
+ .defaultTick > i {
223
180
  display: block;
224
181
  }
225
-
226
182
  [dir=ltr] .smallwithTick {
227
183
  --listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7) var(--zd_size5);
228
184
  }
229
-
230
185
  [dir=rtl] .smallwithTick {
231
- --listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7) var(--zd_size5);
186
+ --listitem_padding: var(--zd_size7) var(--zd_size5) var(--zd_size7) var(--zd_size39);
232
187
  }
233
-
234
188
  [dir=ltr] .mediumwithTick {
235
189
  --listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7) var(--zd_size20);
236
190
  }
237
-
238
191
  [dir=rtl] .mediumwithTick {
239
- --listitem_padding: var(--zd_size7) var(--zd_size39) var(--zd_size7) var(--zd_size20);
192
+ --listitem_padding: var(--zd_size7) var(--zd_size20) var(--zd_size7) var(--zd_size39);
240
193
  }
241
-
242
194
  [dir=ltr] .largewithTick {
243
195
  --listitem_padding: var(--zd_size10) var(--zd_size39) var(--zd_size10) var(--zd_size25);
244
196
  }
245
-
246
197
  [dir=rtl] .largewithTick {
247
- --listitem_padding: var(--zd_size10) var(--zd_size39) var(--zd_size10) var(--zd_size25);
198
+ --listitem_padding: var(--zd_size10) var(--zd_size25) var(--zd_size10) var(--zd_size39);
248
199
  }
249
-
250
200
  .responsiveHeight {
251
201
  --listitem_min_height: var(--zd_size45);
252
202
  font-size: var(--zd_font_size15) ;
253
203
  padding-top: var(--zd_size10) ;
254
204
  padding-bottom: var(--zd_size10) ;
255
205
  }
256
-
257
- .autoHeight {
258
- height: auto ;
259
- }
260
-
261
- .tickIconCenter {
262
- top: 50% ;
263
- transform: translateY(-50%);
264
- }
265
-
266
- .txtAlignBaseLine {
267
- align-items: baseline;
268
- }
269
-
270
- .alignSelfTop {
271
- align-self: start;
272
- }
@@ -105,7 +105,7 @@ export default class ListItemWithAvatar extends React.PureComponent {
105
105
  autoHover: autoHover,
106
106
  needTick: needTick,
107
107
  needBorder: needBorder,
108
- customClass: `${needMultiLineText ? style.autoHeight : ''} ${customListItem}`,
108
+ customClass: customListItem,
109
109
  dataId: `${dataIdString}_ListItemWithAvatar`,
110
110
  dataSelectorId: `${dataSelectorId}`,
111
111
  onClick: this.handleClick,
@@ -116,7 +116,7 @@ export default class ListItemWithAvatar extends React.PureComponent {
116
116
  customProps: ListItemProps,
117
117
  ...ContainerProps
118
118
  }, name || imgSrc ? /*#__PURE__*/React.createElement(Box, {
119
- className: `${needMultiLineText ? style.alignSelfTop : ''} ${style.leftAvatar}`
119
+ className: style.leftAvatar
120
120
  }, isTeam ? /*#__PURE__*/React.createElement(AvatarTeam, {
121
121
  name: name,
122
122
  size: "small",
@@ -143,7 +143,7 @@ export default class ListItemWithAvatar extends React.PureComponent {
143
143
  "data-title": isDisabled ? null : title,
144
144
  className: needMultiLineText ? style.multiLineValue : style.value
145
145
  }, value) : null, needTick && active ? /*#__PURE__*/React.createElement(Box, {
146
- className: `${style.tickIcon} ${needMultiLineText ? style.tickIconCenter : ''}`,
146
+ className: style.tickIcon,
147
147
  "aria-hidden": ariaHidden,
148
148
  dataId: `${dataIdString}_tickIcon`,
149
149
  dataSelectorId: `${dataSelectorId}_tickIcon`
@@ -95,7 +95,7 @@ export default class ListItemWithIcon extends React.Component {
95
95
  autoHover: autoHover,
96
96
  needTick: needTick,
97
97
  needBorder: needBorder,
98
- customClass: `${needMultiLineText ? style.autoHeight : ''} ${needMultiLineText && iconClass && !iconName ? style.txtAlignBaseLine : ''} ${customClass}`,
98
+ customClass: customClass,
99
99
  dataId: dataIdString,
100
100
  dataSelectorId: dataSelectorId,
101
101
  isLink: isLink,
@@ -125,7 +125,7 @@ export default class ListItemWithIcon extends React.Component {
125
125
  "data-title": isDisabled ? null : title,
126
126
  dataId: `${dataIdString}_Text`
127
127
  }, value), needTick && active ? /*#__PURE__*/React.createElement(Box, {
128
- className: `${style.tickIcon} ${needMultiLineText ? style.tickIconCenter : ''}`,
128
+ className: style.tickIcon,
129
129
  "aria-hidden": ariaHidden,
130
130
  dataId: `${dataIdString}_tickIcon`,
131
131
  dataSelectorId: `${dataSelectorId}_tickIcon`
@@ -875,12 +875,8 @@ class AdvancedGroupMultiSelect extends React.Component {
875
875
  palette,
876
876
  needEffect,
877
877
  autoComplete,
878
- getTargetRef,
879
- customProps
878
+ getTargetRef
880
879
  } = this.props;
881
- const {
882
- suggestionsProps
883
- } = customProps;
884
880
  let {
885
881
  clearText = 'Clear all'
886
882
  } = i18nKeys;
@@ -1059,8 +1055,7 @@ class AdvancedGroupMultiSelect extends React.Component {
1059
1055
  a11y: {
1060
1056
  role: 'option'
1061
1057
  },
1062
- dataId: `${dataId}_Options`,
1063
- ...suggestionsProps
1058
+ dataId: `${dataId}_Options`
1064
1059
  }));
1065
1060
  }) : /*#__PURE__*/React.createElement(EmptyState, {
1066
1061
  options: revampedGroups,
@@ -549,8 +549,7 @@ export class AdvancedMultiSelectComponent extends MultiSelectComponent {
549
549
  role: 'option'
550
550
  },
551
551
  dataId: `${dataIdMultiSelectComp}_Options`,
552
- ...SuggestionsProps,
553
- needMultiLineText: true
552
+ ...SuggestionsProps
554
553
  }) : /*#__PURE__*/React.createElement(EmptyState, {
555
554
  isLoading: isFetchingOptions,
556
555
  options: options,
@@ -1015,12 +1015,8 @@ export class MultiSelectComponent extends React.Component {
1015
1015
  boxSize,
1016
1016
  isLoading,
1017
1017
  selectAllText,
1018
- needSelectAll,
1019
- customProps
1018
+ needSelectAll
1020
1019
  } = this.props;
1021
- const {
1022
- suggestionsProps = {}
1023
- } = customProps;
1024
1020
  const {
1025
1021
  selectedOptions,
1026
1022
  searchStr,
@@ -1110,8 +1106,7 @@ export class MultiSelectComponent extends React.Component {
1110
1106
  selectedOptions: selectedOptionIds,
1111
1107
  a11y: {
1112
1108
  role: 'option'
1113
- },
1114
- ...suggestionsProps
1109
+ }
1115
1110
  }) : /*#__PURE__*/React.createElement(EmptyState, {
1116
1111
  isLoading: isFetchingOptions,
1117
1112
  options: options,
@@ -27,8 +27,7 @@ export default class Suggestions extends React.PureComponent {
27
27
  avatarPalette,
28
28
  palette,
29
29
  htmlId,
30
- a11y,
31
- needMultiLineText
30
+ a11y
32
31
  } = this.props;
33
32
  const {
34
33
  ariaParentRole,
@@ -93,8 +92,7 @@ export default class Suggestions extends React.PureComponent {
93
92
  size: listItemSize,
94
93
  avatarPalette: avatarPalette,
95
94
  palette: palette,
96
- a11y: list_a11y,
97
- needMultiLineText: needMultiLineText
95
+ a11y: list_a11y
98
96
  });
99
97
  } else if (optionType === 'icon') {
100
98
  return /*#__PURE__*/React.createElement(ListItemWithIcon, { ...commonProps,
@@ -114,8 +112,7 @@ export default class Suggestions extends React.PureComponent {
114
112
  iconSize: iconSize,
115
113
  size: listItemSize,
116
114
  palette: palette,
117
- a11y: list_a11y,
118
- needMultiLineText: needMultiLineText
115
+ a11y: list_a11y
119
116
  });
120
117
  }
121
118
 
@@ -134,8 +131,7 @@ export default class Suggestions extends React.PureComponent {
134
131
  active: isActive,
135
132
  size: listItemSize,
136
133
  palette: palette,
137
- a11y: list_a11y,
138
- needMultiLineText: needMultiLineText
134
+ a11y: list_a11y
139
135
  });
140
136
  })));
141
137
  }
@@ -37,8 +37,7 @@ export const AdvancedGroupMultiSelect_defaultProps = {
37
37
  needEffect: true,
38
38
  palette: 'default',
39
39
  isLoading: false,
40
- dataSelectorId: 'advancedGroupMultiSelect',
41
- customProps: {}
40
+ dataSelectorId: 'advancedGroupMultiSelect'
42
41
  };
43
42
  export const AdvancedMultiSelect_defaultProps = {
44
43
  animationStyle: 'bounce',
@@ -155,14 +154,13 @@ export const MultiSelectWithAvatar_defaultProps = {
155
154
  isLoading: false,
156
155
  dataSelectorId: 'multiSelectWithAvatar',
157
156
  keepSelectedOptions: false,
158
- needResponsive: true,
159
- customProps: {}
157
+ customProps: {},
158
+ needResponsive: true
160
159
  };
161
160
  export const SelectedOptions_defaultProps = {
162
161
  size: 'medium',
163
162
  dataId: 'selectedOptions'
164
163
  };
165
164
  export const Suggestions_defaultProps = {
166
- a11y: {},
167
- needMultiLineText: false
165
+ a11y: {}
168
166
  };
@@ -176,8 +176,7 @@ export const Suggestions_propTypes = {
176
176
  logo: PropTypes.string,
177
177
  optionType: PropTypes.string,
178
178
  listItemProps: PropTypes.object
179
- })),
180
- needMultiLineText: PropTypes.bool
179
+ }))
181
180
  };
182
181
  export const AdvancedGroupMultiSelect_propTypes = {
183
182
  animationStyle: PropTypes.string,
@@ -247,8 +246,7 @@ export const AdvancedGroupMultiSelect_propTypes = {
247
246
  needToCloseOnSelect: PropTypes.func,
248
247
  searchStr: PropTypes.string,
249
248
  children: PropTypes.node,
250
- dataSelectorId: PropTypes.string,
251
- customProps: PropTypes.string
249
+ dataSelectorId: PropTypes.string
252
250
  };
253
251
  export const AdvancedMultiSelect_propTypes = { ...MultiSelect_propTypes,
254
252
  selectedOptionDetails: PropTypes.string,
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,7 @@ const Popup = function (Component) {
169
189
 
170
190
  return res;
171
191
  }, popups);
192
+ this.removeScrollBlockListeners();
172
193
  let noPopups = true;
173
194
 
174
195
  for (const i in popups) {
@@ -193,6 +214,82 @@ const Popup = function (Component) {
193
214
  }
194
215
  }
195
216
 
217
+ addScrollBlockListeners() {
218
+ document.addEventListener('wheel', this.handleBlockScroll, {
219
+ capture: true,
220
+ passive: false
221
+ });
222
+ document.addEventListener('touchmove', this.handleBlockScroll, {
223
+ capture: true,
224
+ passive: false
225
+ });
226
+ document.addEventListener('scroll', this.handleDebouncedPositionChange, {
227
+ capture: true,
228
+ passive: false
229
+ });
230
+ document.addEventListener('keydown', this.preventKeyboardScroll, {
231
+ capture: true,
232
+ passive: false
233
+ });
234
+ }
235
+
236
+ removeScrollBlockListeners() {
237
+ document.removeEventListener('wheel', this.handleBlockScroll, {
238
+ capture: true,
239
+ passive: false
240
+ });
241
+ document.removeEventListener('touchmove', this.handleBlockScroll, {
242
+ capture: true,
243
+ passive: false
244
+ });
245
+ document.removeEventListener('scroll', this.handleDebouncedPositionChange, {
246
+ capture: true,
247
+ passive: false
248
+ });
249
+ document.removeEventListener('keydown', this.preventKeyboardScroll, {
250
+ capture: true,
251
+ passive: false
252
+ });
253
+ }
254
+
255
+ handleBlockScroll(event) {
256
+ // const targetElement = this.placeHolderElement;
257
+ const containerElement = this.dropElement;
258
+
259
+ if (containerElement && containerElement !== event.target && !containerElement.contains(event.target)) {
260
+ // --- Scroll exclude Target & Container elements --- For reference. Will adopt in future
261
+ // if(
262
+ // (containerElement && (containerElement !== event.target && !containerElement.contains(event.target)))
263
+ // && (targetElement && (targetElement !== event.target && !targetElement.contains(event.target)))
264
+ // ) {
265
+ event.preventDefault();
266
+ }
267
+ }
268
+
269
+ handlePositionChange(event) {
270
+ const targetElement = this.placeHolderElement;
271
+ const containerElement = this.dropElement;
272
+
273
+ if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && targetElement && targetElement !== event.target && !targetElement.contains(event.target) && event.target.contains(targetElement)) {
274
+ this.handlePopupPosition(this.state.position); // this.closePopupOnly(event);
275
+ }
276
+ }
277
+
278
+ preventKeyboardScroll(event) {
279
+ const containerElement = this.dropElement;
280
+ const keys = [32, 37, 38, 39, 40]; // Space, Arrow keys
281
+
282
+ if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && keys.includes(event.keyCode)) {
283
+ event.preventDefault();
284
+ }
285
+ }
286
+
287
+ handleIntersectionObserver(entry) {
288
+ if (entry.intersectionRatio === 0) {
289
+ this.closePopupOnly();
290
+ }
291
+ }
292
+
196
293
  getGroup() {
197
294
  const {
198
295
  popupGroup
@@ -523,13 +620,15 @@ const Popup = function (Component) {
523
620
  } = betterPosition || {};
524
621
  const {
525
622
  left: oldLeft = '',
526
- top: oldTop = ''
623
+ top: oldTop = '',
624
+ bottom: oldBottom = ''
527
625
  } = positionsOffset[position] || {};
528
626
  const {
529
627
  left = '',
530
- top = ''
628
+ top = '',
629
+ bottom = ''
531
630
  } = viewsOffset[view] || {};
532
- const changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top; // let isInViewPort = viewPort.isInViewPort(
631
+ const changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top || oldBottom !== bottom; // let isInViewPort = viewPort.isInViewPort(
533
632
  // placeHolderElement,
534
633
  // scrollContainer
535
634
  // );
@@ -635,9 +734,8 @@ const Popup = function (Component) {
635
734
  }
636
735
 
637
736
  Popup.displayName = Component.displayName || Component.name || Popup.name;
638
- Popup.contextTypes = {
639
- direction: PropTypes.string
640
- };
737
+ Popup.contextTypes = ContextTypes;
738
+ Popup.propTypes = PopupPropTypes;
641
739
  return hoistStatics(Popup, Component);
642
740
  };
643
741