@instructure/ui-drilldown 8.25.1-snapshot-10 → 8.25.1-snapshot-13

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.
@@ -3,7 +3,7 @@ const _excluded = ["groupProps"],
3
3
  _excluded2 = ["groupProps"],
4
4
  _excluded3 = ["id", "themeOverride"];
5
5
 
6
- var _dec, _dec2, _dec3, _class, _IconArrowOpenEndSoli, _IconArrowOpenStartSo, _Options$Separator, _Options$Separator2;
6
+ var _dec, _dec2, _dec3, _class, _class2, _IconArrowOpenEndSoli, _IconArrowOpenStartSo, _Options$Separator, _Options$Separator2;
7
7
 
8
8
  /*
9
9
  * The MIT License (MIT)
@@ -58,74 +58,313 @@ experimental: true
58
58
  ---
59
59
  @tsProps
60
60
  **/
61
- let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = class Drilldown extends Component {
62
- static displayName = "Drilldown";
63
- static componentId = 'Drilldown';
64
- static propTypes = propTypes;
65
- static allowedProps = allowedProps;
66
- static defaultProps = {
67
- disabled: false,
68
- rotateFocus: true,
69
- as: 'ul',
70
- role: 'menu',
71
- overflowX: 'auto',
72
- overflowY: 'auto',
73
- placement: 'bottom center',
74
- defaultShow: false,
75
- shouldHideOnSelect: true,
76
- shouldContainFocus: false,
77
- shouldReturnFocus: true,
78
- withArrow: true,
79
- offsetX: 0,
80
- offsetY: 0
81
- };
82
- static Group = DrilldownGroup;
83
- static Option = DrilldownOption;
84
- static Page = DrilldownPage;
85
- static Separator = DrilldownSeparator;
86
- _drilldownRef = null;
87
- _popover = null;
88
- _trigger = null;
89
- _containerElement = null;
90
- _id;
91
- _triggerId;
92
- _headerBackId;
93
- _headerTitleId;
94
- _headerTitleLabelId;
95
- _headerActionId; // Array of visited page ids in "breadcrumbs" fashion
96
-
97
- _pageHistory; // Map of the active options on the page (includes header options too)
98
-
99
- _activeOptionsMap = {}; // Map of the selected options in groups (grouped by group id)
100
-
101
- _selectedGroupOptionsMap = {};
102
- ref = null;
103
- handleRef = el => {
104
- // ref and elementRef have to be set together for the same element
105
- const elementRef = this.props.elementRef;
106
- this.ref = el;
107
-
108
- if (typeof elementRef === 'function') {
109
- elementRef(el);
110
- }
111
- };
112
- handleDrilldownRef = el => {
113
- const drilldownRef = this.props.drilldownRef;
114
- this._drilldownRef = el;
61
+ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Drilldown extends Component {
62
+ // Array of visited page ids in "breadcrumbs" fashion
63
+ // Map of the active options on the page (includes header options too)
64
+ // Map of the selected options in groups (grouped by group id)
65
+ constructor(props) {
66
+ super(props);
67
+ this._drilldownRef = null;
68
+ this._popover = null;
69
+ this._trigger = null;
70
+ this._containerElement = null;
71
+ this._id = void 0;
72
+ this._triggerId = void 0;
73
+ this._headerBackId = void 0;
74
+ this._headerTitleId = void 0;
75
+ this._headerTitleLabelId = void 0;
76
+ this._headerActionId = void 0;
77
+ this._pageHistory = void 0;
78
+ this._activeOptionsMap = {};
79
+ this._selectedGroupOptionsMap = {};
80
+ this.ref = null;
115
81
 
116
- if (typeof drilldownRef === 'function') {
117
- drilldownRef(el);
118
- } // setting ref for "non-popover" version, the drilldown itself
119
- // (if a trigger is provided, the Popover sets the ref)
82
+ this.handleRef = el => {
83
+ // ref and elementRef have to be set together for the same element
84
+ const elementRef = this.props.elementRef;
85
+ this.ref = el;
120
86
 
87
+ if (typeof elementRef === 'function') {
88
+ elementRef(el);
89
+ }
90
+ };
121
91
 
122
- if (!this.props.trigger) {
123
- this.handleRef(el);
124
- }
125
- };
92
+ this.handleDrilldownRef = el => {
93
+ const drilldownRef = this.props.drilldownRef;
94
+ this._drilldownRef = el;
95
+
96
+ if (typeof drilldownRef === 'function') {
97
+ drilldownRef(el);
98
+ } // setting ref for "non-popover" version, the drilldown itself
99
+ // (if a trigger is provided, the Popover sets the ref)
100
+
101
+
102
+ if (!this.props.trigger) {
103
+ this.handleRef(el);
104
+ }
105
+ };
106
+
107
+ this.show = event => {
108
+ if (this._popover) {
109
+ this._popover.show(event);
110
+
111
+ this.setState({
112
+ isShowingPopover: true
113
+ });
114
+ }
115
+ };
116
+
117
+ this.hide = event => {
118
+ if (this._popover) {
119
+ this._popover.hide(event);
120
+
121
+ this.setState({
122
+ isShowingPopover: false
123
+ });
124
+ this.reset();
125
+ }
126
+ };
127
+
128
+ this.handleOptionHighlight = (_event, _ref) => {
129
+ let id = _ref.id,
130
+ direction = _ref.direction;
131
+ const rotateFocus = this.props.rotateFocus;
132
+ const highlightedOptionId = this.state.highlightedOptionId; // if id exists, use that, or calculate from direction
133
+
134
+ let highlightId = this.getPageChildById(id) ? id : void 0;
135
+
136
+ if (!highlightId) {
137
+ if (!highlightedOptionId) {
138
+ // nothing highlighted yet, highlight first option
139
+ highlightId = this.activeOptionIds[0];
140
+ } else if (direction) {
141
+ // if it has direction, find next id based on it
142
+ const index = this.activeOptionIds.indexOf(highlightedOptionId);
143
+ const newIndex = index + direction;
144
+ highlightId = index > -1 ? this.activeOptionIds[newIndex] : void 0;
145
+
146
+ if (rotateFocus) {
147
+ const lastOptionsIndex = this.activeOptionIds.length - 1;
148
+
149
+ if (newIndex < 0) {
150
+ highlightId = this.activeOptionIds[lastOptionsIndex];
151
+ }
152
+
153
+ if (newIndex > lastOptionsIndex) {
154
+ highlightId = this.activeOptionIds[0];
155
+ }
156
+ }
157
+ }
158
+ }
159
+
160
+ if (highlightId) {
161
+ // only highlight if id exists as a valid option
162
+ this.setState({
163
+ highlightedOptionId: highlightId
164
+ }, () => {
165
+ this.focusOption(highlightId);
166
+ });
167
+ }
168
+ };
169
+
170
+ this.goToPage = newPageId => {
171
+ var _this$pageMap;
172
+
173
+ if (!newPageId) {
174
+ warn(false, `Cannot go to page because there was no page id provided.`);
175
+ return void 0;
176
+ } // TS complains that it cannot be true, but since it is an exposed method,
177
+ // it is better if we provide a warning for this case too
178
+
179
+
180
+ if (typeof newPageId !== 'string') {
181
+ warn(false, `Cannot go to page because parameter newPageId has to be string (valid page id). Current newPageId is "${typeof newPageId}".`);
182
+ return void 0;
183
+ }
184
+
185
+ if (!((_this$pageMap = this.pageMap) !== null && _this$pageMap !== void 0 && _this$pageMap[newPageId])) {
186
+ warn(false, `Cannot go to page because page with id: "${newPageId}" doesn't exist.`);
187
+ return void 0;
188
+ } // the last page id in the history is the current one,
189
+ // it will become the "prevPage"
190
+
191
+
192
+ const prevPageId = this._pageHistory[this._pageHistory.length - 1];
193
+
194
+ const idxInHistory = this._pageHistory.indexOf(newPageId);
195
+
196
+ if (idxInHistory < 0) {
197
+ // if it is not in the page history, we have to add it
198
+ this._pageHistory.push(newPageId);
199
+ } else {
200
+ // if it was already in the history, we go back to that page,
201
+ // and clear the rest from the history
202
+ this._pageHistory.splice(idxInHistory + 1, this._pageHistory.length - 1);
203
+ }
204
+
205
+ this.setState({
206
+ activePageId: newPageId,
207
+ highlightedOptionId: void 0
208
+ });
209
+ return {
210
+ prevPageId,
211
+ newPageId
212
+ };
213
+ };
214
+
215
+ this.goToPreviousPage = () => {
216
+ if (!this.previousPage) {
217
+ warn(false, `There is no previous page to go to. The current page history is: [${this._pageHistory.join(', ')}].`);
218
+ return void 0;
219
+ } // If there is a previous page, goToPage will succeed and return the data
220
+
221
+
222
+ const _ref2 = this.goToPage(this.previousPage.id),
223
+ newPageId = _ref2.newPageId,
224
+ prevPageId = _ref2.prevPageId;
225
+
226
+ return {
227
+ newPageId,
228
+ prevPageId
229
+ };
230
+ };
231
+
232
+ this.handleBackButtonClick = () => {
233
+ const _ref3 = this.currentPage,
234
+ onBackButtonClicked = _ref3.onBackButtonClicked; // we only display the back button when there is a page to go back to
235
+
236
+ const _ref4 = this.goToPreviousPage(),
237
+ newPageId = _ref4.newPageId,
238
+ prevPageId = _ref4.prevPageId;
239
+
240
+ if (typeof onBackButtonClicked === 'function') {
241
+ onBackButtonClicked(newPageId, prevPageId);
242
+ }
243
+ };
244
+
245
+ this.handleOptionSelect = (event, _ref5) => {
246
+ let id = _ref5.id;
247
+ const selectedOption = this.getPageChildById(id);
248
+
249
+ if (!id || !selectedOption || selectedOption.props.disabled || event.target.getAttribute('disabled') || event.target.getAttribute('aria-disabled')) {
250
+ event.preventDefault();
251
+ event.stopPropagation();
252
+ return;
253
+ }
254
+
255
+ const _this$props = this.props,
256
+ shouldHideOnSelect = _this$props.shouldHideOnSelect,
257
+ onSelect = _this$props.onSelect;
258
+
259
+ const groupProps = selectedOption.groupProps,
260
+ selectedOptionChild = _objectWithoutProperties(selectedOption, _excluded);
261
+
262
+ const _selectedOptionChild$ = selectedOptionChild.props,
263
+ subPageId = _selectedOptionChild$.subPageId,
264
+ href = _selectedOptionChild$.href,
265
+ value = _selectedOptionChild$.value,
266
+ onOptionClick = _selectedOptionChild$.onOptionClick;
267
+
268
+ if (typeof onOptionClick === 'function') {
269
+ onOptionClick(event, {
270
+ optionId: id,
271
+ drilldown: this,
272
+ ...this.exposedNavigationProps
273
+ });
274
+ }
275
+
276
+ if (subPageId) {
277
+ this.goToPage(subPageId);
278
+ }
279
+
280
+ if (href) {
281
+ var _this$_drilldownRef;
282
+
283
+ const optionEl = (_this$_drilldownRef = this._drilldownRef) === null || _this$_drilldownRef === void 0 ? void 0 : _this$_drilldownRef.querySelector(`#${id}`);
284
+ const isLink = optionEl.tagName.toLowerCase() === 'a'; // we need this check because in some cases
285
+ // we ignore href prop in renderOption()
286
+
287
+ if (isLink && optionEl !== null && optionEl !== void 0 && optionEl.href) {
288
+ optionEl.click();
289
+ }
290
+ }
291
+
292
+ if (groupProps !== null && groupProps !== void 0 && groupProps.selectableType) {
293
+ this.handleGroupOptionSelected(event, selectedOption);
294
+ } else {
295
+ if (typeof onSelect === 'function') {
296
+ onSelect(event, {
297
+ value,
298
+ isSelected: true,
299
+ selectedOption: selectedOptionChild,
300
+ drilldown: this
301
+ });
302
+ }
303
+ } // should prevent closing on page navigation
304
+
305
+
306
+ if (shouldHideOnSelect && !subPageId && id !== this._headerBackId) {
307
+ this.hide(event);
308
+ }
309
+ };
310
+
311
+ this.handleKeyDown = event => {
312
+ const id = event.target.id;
313
+ const option = this.getPageChildById(id); // On Space...
314
+
315
+ if ([' ', 'space', 'Space'].includes(event.key)) {
316
+ // we need to preventDefault so the page doesn't scroll on Space
317
+ event.preventDefault();
318
+ event.stopPropagation(); // for options, Space it has to work as Enter (get selected)
319
+
320
+ if (option) {
321
+ this.handleOptionSelect(event, {
322
+ id
323
+ });
324
+ }
325
+ } // On Right arrow...
326
+
327
+
328
+ if (event.key === 'ArrowRight') {
329
+ // if the option has subpage, we open it
330
+ if (option !== null && option !== void 0 && option.props.subPageId) {
331
+ this.handleOptionSelect(event, {
332
+ id
333
+ });
334
+ }
335
+ } // On Left arrow...
336
+
337
+
338
+ if (event.key === 'ArrowLeft') {
339
+ var _this$_popover;
340
+
341
+ // if it is possible, we go a level up in the history
342
+ if (this._pageHistory.length > 1) {
343
+ this.goToPreviousPage();
344
+ } // if on root page and popover is open, we close it
345
+
346
+
347
+ if (this.isOnRootPage && (_this$_popover = this._popover) !== null && _this$_popover !== void 0 && _this$_popover.shown) {
348
+ this._popover.hide(event);
349
+ }
350
+ }
351
+ };
352
+
353
+ this.handleToggle = (event, shown) => {
354
+ const onToggle = this.props.onToggle;
355
+ this.setState({
356
+ isShowingPopover: shown
357
+ });
358
+
359
+ if (typeof onToggle === 'function') {
360
+ onToggle(event, {
361
+ shown,
362
+ drilldown: this,
363
+ ...this.exposedNavigationProps
364
+ });
365
+ }
366
+ };
126
367
 
127
- constructor(props) {
128
- super(props);
129
368
  this.state = {
130
369
  isShowingPopover: props.trigger ? !!props.show : false,
131
370
  activePageId: props.rootPageId,
@@ -143,15 +382,15 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
143
382
  }
144
383
 
145
384
  componentDidMount() {
146
- var _this$props$makeStyle, _this$props;
385
+ var _this$props$makeStyle, _this$props2;
147
386
 
148
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStylesVariables);
387
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStylesVariables);
149
388
  }
150
389
 
151
390
  componentDidUpdate(_prevProps, prevState) {
152
- var _this$props$makeStyle2, _this$props2;
391
+ var _this$props$makeStyle2, _this$props3;
153
392
 
154
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStylesVariables);
393
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStylesVariables);
155
394
 
156
395
  if (prevState.activePageId !== this.state.activePageId) {
157
396
  // on page change with mouse navigation, some option can get rendered
@@ -335,9 +574,9 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
335
574
 
336
575
  get headerChildren() {
337
576
  const currentPage = this.currentPage;
338
- const _this$props3 = this.props,
339
- styles = _this$props3.styles,
340
- deterministicId = _this$props3.deterministicId;
577
+ const _this$props4 = this.props,
578
+ styles = _this$props4.styles,
579
+ deterministicId = _this$props4.deterministicId;
341
580
  const headerChildren = [];
342
581
 
343
582
  if (!currentPage) {
@@ -412,26 +651,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
412
651
  return this.props.trigger ? this.state.isShowingPopover : true;
413
652
  }
414
653
 
415
- show = event => {
416
- if (this._popover) {
417
- this._popover.show(event);
418
-
419
- this.setState({
420
- isShowingPopover: true
421
- });
422
- }
423
- };
424
- hide = event => {
425
- if (this._popover) {
426
- this._popover.hide(event);
427
-
428
- this.setState({
429
- isShowingPopover: false
430
- });
431
- this.reset();
432
- }
433
- };
434
-
435
654
  reset() {
436
655
  this._activeOptionsMap = {};
437
656
  this.setState({
@@ -441,10 +660,10 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
441
660
 
442
661
  focus() {
443
662
  if (this.shown) {
444
- var _this$_drilldownRef, _this$_drilldownRef2;
663
+ var _this$_drilldownRef2, _this$_drilldownRef3;
445
664
 
446
- error(!!((_this$_drilldownRef = this._drilldownRef) !== null && _this$_drilldownRef !== void 0 && _this$_drilldownRef.focus), '[Drilldown] Could not focus the drilldown.');
447
- (_this$_drilldownRef2 = this._drilldownRef) === null || _this$_drilldownRef2 === void 0 ? void 0 : _this$_drilldownRef2.focus();
665
+ error(!!((_this$_drilldownRef2 = this._drilldownRef) !== null && _this$_drilldownRef2 !== void 0 && _this$_drilldownRef2.focus), '[Drilldown] Could not focus the drilldown.');
666
+ (_this$_drilldownRef3 = this._drilldownRef) === null || _this$_drilldownRef3 === void 0 ? void 0 : _this$_drilldownRef3.focus();
448
667
  } else {
449
668
  var _this$_trigger;
450
669
 
@@ -468,129 +687,14 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
468
687
  optionElement === null || optionElement === void 0 ? void 0 : optionElement.focus();
469
688
  }
470
689
 
471
- handleOptionHighlight = (_event, _ref) => {
472
- let id = _ref.id,
473
- direction = _ref.direction;
474
- const rotateFocus = this.props.rotateFocus;
475
- const highlightedOptionId = this.state.highlightedOptionId; // if id exists, use that, or calculate from direction
476
-
477
- let highlightId = this.getPageChildById(id) ? id : void 0;
478
-
479
- if (!highlightId) {
480
- if (!highlightedOptionId) {
481
- // nothing highlighted yet, highlight first option
482
- highlightId = this.activeOptionIds[0];
483
- } else if (direction) {
484
- // if it has direction, find next id based on it
485
- const index = this.activeOptionIds.indexOf(highlightedOptionId);
486
- const newIndex = index + direction;
487
- highlightId = index > -1 ? this.activeOptionIds[newIndex] : void 0;
488
-
489
- if (rotateFocus) {
490
- const lastOptionsIndex = this.activeOptionIds.length - 1;
491
-
492
- if (newIndex < 0) {
493
- highlightId = this.activeOptionIds[lastOptionsIndex];
494
- }
495
-
496
- if (newIndex > lastOptionsIndex) {
497
- highlightId = this.activeOptionIds[0];
498
- }
499
- }
500
- }
501
- }
502
-
503
- if (highlightId) {
504
- // only highlight if id exists as a valid option
505
- this.setState({
506
- highlightedOptionId: highlightId
507
- }, () => {
508
- this.focusOption(highlightId);
509
- });
510
- }
511
- }; // Navigates to the page and also returns the new and old pageIds
512
-
513
- goToPage = newPageId => {
514
- var _this$pageMap;
515
-
516
- if (!newPageId) {
517
- warn(false, `Cannot go to page because there was no page id provided.`);
518
- return void 0;
519
- } // TS complains that it cannot be true, but since it is an exposed method,
520
- // it is better if we provide a warning for this case too
521
-
522
-
523
- if (typeof newPageId !== 'string') {
524
- warn(false, `Cannot go to page because parameter newPageId has to be string (valid page id). Current newPageId is "${typeof newPageId}".`);
525
- return void 0;
526
- }
527
-
528
- if (!((_this$pageMap = this.pageMap) !== null && _this$pageMap !== void 0 && _this$pageMap[newPageId])) {
529
- warn(false, `Cannot go to page because page with id: "${newPageId}" doesn't exist.`);
530
- return void 0;
531
- } // the last page id in the history is the current one,
532
- // it will become the "prevPage"
533
-
534
-
535
- const prevPageId = this._pageHistory[this._pageHistory.length - 1];
536
-
537
- const idxInHistory = this._pageHistory.indexOf(newPageId);
538
-
539
- if (idxInHistory < 0) {
540
- // if it is not in the page history, we have to add it
541
- this._pageHistory.push(newPageId);
542
- } else {
543
- // if it was already in the history, we go back to that page,
544
- // and clear the rest from the history
545
- this._pageHistory.splice(idxInHistory + 1, this._pageHistory.length - 1);
546
- }
547
-
548
- this.setState({
549
- activePageId: newPageId,
550
- highlightedOptionId: void 0
551
- });
552
- return {
553
- prevPageId,
554
- newPageId
555
- };
556
- };
557
- goToPreviousPage = () => {
558
- if (!this.previousPage) {
559
- warn(false, `There is no previous page to go to. The current page history is: [${this._pageHistory.join(', ')}].`);
560
- return void 0;
561
- } // If there is a previous page, goToPage will succeed and return the data
562
-
563
-
564
- const _ref2 = this.goToPage(this.previousPage.id),
565
- newPageId = _ref2.newPageId,
566
- prevPageId = _ref2.prevPageId;
567
-
568
- return {
569
- newPageId,
570
- prevPageId
571
- };
572
- };
573
- handleBackButtonClick = () => {
574
- const _ref3 = this.currentPage,
575
- onBackButtonClicked = _ref3.onBackButtonClicked; // we only display the back button when there is a page to go back to
576
-
577
- const _ref4 = this.goToPreviousPage(),
578
- newPageId = _ref4.newPageId,
579
- prevPageId = _ref4.prevPageId;
580
-
581
- if (typeof onBackButtonClicked === 'function') {
582
- onBackButtonClicked(newPageId, prevPageId);
583
- }
584
- };
585
-
586
690
  handleGroupOptionSelected(event, selectedOption) {
587
691
  const _selectedOption$props = selectedOption.props,
588
692
  optionId = _selectedOption$props.id,
589
693
  value = _selectedOption$props.value;
590
- const _ref5 = selectedOption.groupProps,
591
- groupId = _ref5.id,
592
- selectableType = _ref5.selectableType,
593
- groupOnSelect = _ref5.onSelect;
694
+ const _ref6 = selectedOption.groupProps,
695
+ groupId = _ref6.id,
696
+ selectableType = _ref6.selectableType,
697
+ groupOnSelect = _ref6.onSelect;
594
698
  const onSelect = this.props.onSelect;
595
699
 
596
700
  if (this._selectedGroupOptionsMap[groupId].has(optionId)) {
@@ -614,7 +718,7 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
614
718
  });
615
719
 
616
720
  const groupProps = selectedOption.groupProps,
617
- option = _objectWithoutProperties(selectedOption, _excluded);
721
+ option = _objectWithoutProperties(selectedOption, _excluded2);
618
722
 
619
723
  const selectedOptionValuesInGroup = Array.from(this._selectedGroupOptionsMap[groupId].values());
620
724
 
@@ -637,129 +741,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
637
741
  }
638
742
  }
639
743
 
640
- handleOptionSelect = (event, _ref6) => {
641
- let id = _ref6.id;
642
- const selectedOption = this.getPageChildById(id);
643
-
644
- if (!id || !selectedOption || selectedOption.props.disabled || event.target.getAttribute('disabled') || event.target.getAttribute('aria-disabled')) {
645
- event.preventDefault();
646
- event.stopPropagation();
647
- return;
648
- }
649
-
650
- const _this$props4 = this.props,
651
- shouldHideOnSelect = _this$props4.shouldHideOnSelect,
652
- onSelect = _this$props4.onSelect;
653
-
654
- const groupProps = selectedOption.groupProps,
655
- selectedOptionChild = _objectWithoutProperties(selectedOption, _excluded2);
656
-
657
- const _selectedOptionChild$ = selectedOptionChild.props,
658
- subPageId = _selectedOptionChild$.subPageId,
659
- href = _selectedOptionChild$.href,
660
- value = _selectedOptionChild$.value,
661
- onOptionClick = _selectedOptionChild$.onOptionClick;
662
-
663
- if (typeof onOptionClick === 'function') {
664
- onOptionClick(event, {
665
- optionId: id,
666
- drilldown: this,
667
- ...this.exposedNavigationProps
668
- });
669
- }
670
-
671
- if (subPageId) {
672
- this.goToPage(subPageId);
673
- }
674
-
675
- if (href) {
676
- var _this$_drilldownRef3;
677
-
678
- const optionEl = (_this$_drilldownRef3 = this._drilldownRef) === null || _this$_drilldownRef3 === void 0 ? void 0 : _this$_drilldownRef3.querySelector(`#${id}`);
679
- const isLink = optionEl.tagName.toLowerCase() === 'a'; // we need this check because in some cases
680
- // we ignore href prop in renderOption()
681
-
682
- if (isLink && optionEl !== null && optionEl !== void 0 && optionEl.href) {
683
- optionEl.click();
684
- }
685
- }
686
-
687
- if (groupProps !== null && groupProps !== void 0 && groupProps.selectableType) {
688
- this.handleGroupOptionSelected(event, selectedOption);
689
- } else {
690
- if (typeof onSelect === 'function') {
691
- onSelect(event, {
692
- value,
693
- isSelected: true,
694
- selectedOption: selectedOptionChild,
695
- drilldown: this
696
- });
697
- }
698
- } // should prevent closing on page navigation
699
-
700
-
701
- if (shouldHideOnSelect && !subPageId && id !== this._headerBackId) {
702
- this.hide(event);
703
- }
704
- }; // Setting extra logic for keyboard navigation.
705
- // Enter, Esc and up/down/home/end keys are handled by Selectable.
706
-
707
- handleKeyDown = event => {
708
- const id = event.target.id;
709
- const option = this.getPageChildById(id); // On Space...
710
-
711
- if ([' ', 'space', 'Space'].includes(event.key)) {
712
- // we need to preventDefault so the page doesn't scroll on Space
713
- event.preventDefault();
714
- event.stopPropagation(); // for options, Space it has to work as Enter (get selected)
715
-
716
- if (option) {
717
- this.handleOptionSelect(event, {
718
- id
719
- });
720
- }
721
- } // On Right arrow...
722
-
723
-
724
- if (event.key === 'ArrowRight') {
725
- // if the option has subpage, we open it
726
- if (option !== null && option !== void 0 && option.props.subPageId) {
727
- this.handleOptionSelect(event, {
728
- id
729
- });
730
- }
731
- } // On Left arrow...
732
-
733
-
734
- if (event.key === 'ArrowLeft') {
735
- var _this$_popover;
736
-
737
- // if it is possible, we go a level up in the history
738
- if (this._pageHistory.length > 1) {
739
- this.goToPreviousPage();
740
- } // if on root page and popover is open, we close it
741
-
742
-
743
- if (this.isOnRootPage && (_this$_popover = this._popover) !== null && _this$_popover !== void 0 && _this$_popover.shown) {
744
- this._popover.hide(event);
745
- }
746
- }
747
- };
748
- handleToggle = (event, shown) => {
749
- const onToggle = this.props.onToggle;
750
- this.setState({
751
- isShowingPopover: shown
752
- });
753
-
754
- if (typeof onToggle === 'function') {
755
- onToggle(event, {
756
- shown,
757
- drilldown: this,
758
- ...this.exposedNavigationProps
759
- });
760
- }
761
- };
762
-
763
744
  renderList(getOptionProps, getDisabledOptionProps) {
764
745
  const currentPage = this.currentPage,
765
746
  headerChildren = this.headerChildren;
@@ -1239,6 +1220,21 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
1239
1220
  }, this.renderPage()) : this.renderPage();
1240
1221
  }
1241
1222
 
1242
- }) || _class) || _class) || _class);
1223
+ }, _class2.displayName = "Drilldown", _class2.componentId = 'Drilldown', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
1224
+ disabled: false,
1225
+ rotateFocus: true,
1226
+ as: 'ul',
1227
+ role: 'menu',
1228
+ overflowX: 'auto',
1229
+ overflowY: 'auto',
1230
+ placement: 'bottom center',
1231
+ defaultShow: false,
1232
+ shouldHideOnSelect: true,
1233
+ shouldContainFocus: false,
1234
+ shouldReturnFocus: true,
1235
+ withArrow: true,
1236
+ offsetX: 0,
1237
+ offsetY: 0
1238
+ }, _class2.Group = DrilldownGroup, _class2.Option = DrilldownOption, _class2.Page = DrilldownPage, _class2.Separator = DrilldownSeparator, _class2)) || _class) || _class) || _class);
1243
1239
  export default Drilldown;
1244
1240
  export { Drilldown };