@instructure/ui-drilldown 8.33.2-snapshot-0 → 8.33.2
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/CHANGELOG.md +1 -5
- package/es/Drilldown/DrilldownGroup/index.js +0 -3
- package/es/Drilldown/DrilldownGroup/props.js +1 -0
- package/es/Drilldown/DrilldownLocator.js +13 -22
- package/es/Drilldown/DrilldownOption/index.js +0 -3
- package/es/Drilldown/DrilldownOption/props.js +1 -0
- package/es/Drilldown/DrilldownPage/index.js +0 -3
- package/es/Drilldown/DrilldownPage/props.js +1 -0
- package/es/Drilldown/DrilldownSeparator/index.js +0 -3
- package/es/Drilldown/DrilldownSeparator/props.js +1 -0
- package/es/Drilldown/__examples__/Drilldown.examples.js +9 -9
- package/es/Drilldown/index.js +199 -304
- package/es/Drilldown/locator.js +1 -0
- package/es/Drilldown/props.js +3 -1
- package/es/Drilldown/styles.js +1 -1
- package/es/Drilldown/theme.js +4 -4
- package/es/index.js +1 -0
- package/lib/Drilldown/DrilldownGroup/index.js +0 -7
- package/lib/Drilldown/DrilldownGroup/props.js +1 -6
- package/lib/Drilldown/DrilldownLocator.js +11 -25
- package/lib/Drilldown/DrilldownOption/index.js +0 -7
- package/lib/Drilldown/DrilldownOption/props.js +1 -3
- package/lib/Drilldown/DrilldownPage/index.js +0 -5
- package/lib/Drilldown/DrilldownPage/props.js +1 -7
- package/lib/Drilldown/DrilldownSeparator/index.js +0 -7
- package/lib/Drilldown/DrilldownSeparator/props.js +1 -3
- package/lib/Drilldown/__examples__/Drilldown.examples.js +8 -14
- package/lib/Drilldown/index.js +199 -326
- package/lib/Drilldown/locator.js +0 -2
- package/lib/Drilldown/props.js +3 -8
- package/lib/Drilldown/styles.js +1 -2
- package/lib/Drilldown/theme.js +4 -5
- package/lib/index.js +0 -1
- package/package.json +20 -20
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Drilldown/DrilldownOption/index.d.ts +6 -6
package/es/Drilldown/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["groupProps"],
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
_excluded2 = ["groupProps"],
|
|
4
|
+
_excluded3 = ["id", "themeOverride"];
|
|
6
5
|
var _dec, _dec2, _dec3, _class, _class2, _IconArrowOpenEndSoli, _IconArrowOpenStartSo, _Options$Separator, _Options$Separator2;
|
|
7
|
-
|
|
8
6
|
/*
|
|
9
7
|
* The MIT License (MIT)
|
|
10
8
|
*
|
|
@@ -30,7 +28,6 @@ var _dec, _dec2, _dec3, _class, _class2, _IconArrowOpenEndSoli, _IconArrowOpenSt
|
|
|
30
28
|
*/
|
|
31
29
|
|
|
32
30
|
/** @jsx jsx */
|
|
33
|
-
|
|
34
31
|
/** @jsxFrag React.Fragment */
|
|
35
32
|
import React, { Component } from 'react';
|
|
36
33
|
import { warn, error } from '@instructure/console';
|
|
@@ -50,7 +47,6 @@ import { DrilldownPage } from './DrilldownPage';
|
|
|
50
47
|
import generateStyle from './styles';
|
|
51
48
|
import generateComponentTheme from './theme';
|
|
52
49
|
import { propTypes, allowedProps } from './props';
|
|
53
|
-
|
|
54
50
|
/**
|
|
55
51
|
---
|
|
56
52
|
category: components
|
|
@@ -59,8 +55,11 @@ category: components
|
|
|
59
55
|
**/
|
|
60
56
|
let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Drilldown extends Component {
|
|
61
57
|
// Array of visited page ids in "breadcrumbs" fashion
|
|
58
|
+
|
|
62
59
|
// Map of the active options on the page (includes header options too)
|
|
60
|
+
|
|
63
61
|
// Map of the selected options in groups (grouped by group id)
|
|
62
|
+
|
|
64
63
|
constructor(props) {
|
|
65
64
|
super(props);
|
|
66
65
|
this._drilldownRef = null;
|
|
@@ -76,61 +75,52 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
76
75
|
this._pageHistory = void 0;
|
|
77
76
|
this._activeOptionsMap = {};
|
|
78
77
|
this.ref = null;
|
|
79
|
-
|
|
80
78
|
this.handleRef = el => {
|
|
81
79
|
// ref and elementRef have to be set together for the same element
|
|
82
80
|
const elementRef = this.props.elementRef;
|
|
83
81
|
this.ref = el;
|
|
84
|
-
|
|
85
82
|
if (typeof elementRef === 'function') {
|
|
86
83
|
elementRef(el);
|
|
87
84
|
}
|
|
88
85
|
};
|
|
89
|
-
|
|
90
86
|
this.handleDrilldownRef = el => {
|
|
91
87
|
const drilldownRef = this.props.drilldownRef;
|
|
92
88
|
this._drilldownRef = el;
|
|
93
|
-
|
|
94
89
|
if (typeof drilldownRef === 'function') {
|
|
95
90
|
drilldownRef(el);
|
|
96
|
-
}
|
|
97
|
-
// (if a trigger is provided, the Popover sets the ref)
|
|
98
|
-
|
|
91
|
+
}
|
|
99
92
|
|
|
93
|
+
// setting ref for "non-popover" version, the drilldown itself
|
|
94
|
+
// (if a trigger is provided, the Popover sets the ref)
|
|
100
95
|
if (!this.props.trigger) {
|
|
101
96
|
this.handleRef(el);
|
|
102
97
|
}
|
|
103
98
|
};
|
|
104
|
-
|
|
105
99
|
this.show = event => {
|
|
106
100
|
if (this._popover) {
|
|
107
101
|
this._popover.show(event);
|
|
108
|
-
|
|
109
102
|
this.setState({
|
|
110
103
|
isShowingPopover: true
|
|
111
104
|
});
|
|
112
105
|
}
|
|
113
106
|
};
|
|
114
|
-
|
|
115
107
|
this.hide = event => {
|
|
116
108
|
if (this._popover) {
|
|
117
109
|
this._popover.hide(event);
|
|
118
|
-
|
|
119
110
|
this.setState({
|
|
120
111
|
isShowingPopover: false
|
|
121
112
|
});
|
|
122
113
|
this.reset();
|
|
123
114
|
}
|
|
124
115
|
};
|
|
125
|
-
|
|
126
116
|
this.handleOptionHighlight = (_event, _ref) => {
|
|
127
117
|
let id = _ref.id,
|
|
128
|
-
|
|
118
|
+
direction = _ref.direction;
|
|
129
119
|
const rotateFocus = this.props.rotateFocus;
|
|
130
|
-
const highlightedOptionId = this.state.highlightedOptionId;
|
|
120
|
+
const highlightedOptionId = this.state.highlightedOptionId;
|
|
131
121
|
|
|
122
|
+
// if id exists, use that, or calculate from direction
|
|
132
123
|
let highlightId = this.getPageChildById(id) ? id : void 0;
|
|
133
|
-
|
|
134
124
|
if (!highlightId) {
|
|
135
125
|
if (!highlightedOptionId) {
|
|
136
126
|
// nothing highlighted yet, highlight first option
|
|
@@ -140,21 +130,17 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
140
130
|
const index = this.activeOptionIds.indexOf(highlightedOptionId);
|
|
141
131
|
const newIndex = index + direction;
|
|
142
132
|
highlightId = index > -1 ? this.activeOptionIds[newIndex] : void 0;
|
|
143
|
-
|
|
144
133
|
if (rotateFocus) {
|
|
145
134
|
const lastOptionsIndex = this.activeOptionIds.length - 1;
|
|
146
|
-
|
|
147
135
|
if (newIndex < 0) {
|
|
148
136
|
highlightId = this.activeOptionIds[lastOptionsIndex];
|
|
149
137
|
}
|
|
150
|
-
|
|
151
138
|
if (newIndex > lastOptionsIndex) {
|
|
152
139
|
highlightId = this.activeOptionIds[0];
|
|
153
140
|
}
|
|
154
141
|
}
|
|
155
142
|
}
|
|
156
143
|
}
|
|
157
|
-
|
|
158
144
|
if (highlightId) {
|
|
159
145
|
// only highlight if id exists as a valid option
|
|
160
146
|
this.setState({
|
|
@@ -164,33 +150,28 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
164
150
|
});
|
|
165
151
|
}
|
|
166
152
|
};
|
|
167
|
-
|
|
168
153
|
this.goToPage = newPageId => {
|
|
169
154
|
var _this$pageMap;
|
|
170
|
-
|
|
171
155
|
if (!newPageId) {
|
|
172
156
|
warn(false, `Cannot go to page because there was no page id provided.`);
|
|
173
157
|
return void 0;
|
|
174
|
-
}
|
|
175
|
-
// it is better if we provide a warning for this case too
|
|
176
|
-
|
|
158
|
+
}
|
|
177
159
|
|
|
160
|
+
// TS complains that it cannot be true, but since it is an exposed method,
|
|
161
|
+
// it is better if we provide a warning for this case too
|
|
178
162
|
if (typeof newPageId !== 'string') {
|
|
179
163
|
warn(false, `Cannot go to page because parameter newPageId has to be string (valid page id). Current newPageId is "${typeof newPageId}".`);
|
|
180
164
|
return void 0;
|
|
181
165
|
}
|
|
182
|
-
|
|
183
166
|
if (!((_this$pageMap = this.pageMap) !== null && _this$pageMap !== void 0 && _this$pageMap[newPageId])) {
|
|
184
167
|
warn(false, `Cannot go to page because page with id: "${newPageId}" doesn't exist.`);
|
|
185
168
|
return void 0;
|
|
186
|
-
}
|
|
187
|
-
// it will become the "prevPage"
|
|
188
|
-
|
|
169
|
+
}
|
|
189
170
|
|
|
171
|
+
// the last page id in the history is the current one,
|
|
172
|
+
// it will become the "prevPage"
|
|
190
173
|
const prevPageId = this._pageHistory[this._pageHistory.length - 1];
|
|
191
|
-
|
|
192
174
|
const idxInHistory = this._pageHistory.indexOf(newPageId);
|
|
193
|
-
|
|
194
175
|
if (idxInHistory < 0) {
|
|
195
176
|
// if it is not in the page history, we have to add it
|
|
196
177
|
this._pageHistory.push(newPageId);
|
|
@@ -199,7 +180,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
199
180
|
// and clear the rest from the history
|
|
200
181
|
this._pageHistory.splice(idxInHistory + 1, this._pageHistory.length - 1);
|
|
201
182
|
}
|
|
202
|
-
|
|
203
183
|
this.setState({
|
|
204
184
|
activePageId: newPageId,
|
|
205
185
|
highlightedOptionId: void 0
|
|
@@ -209,62 +189,54 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
209
189
|
newPageId
|
|
210
190
|
};
|
|
211
191
|
};
|
|
212
|
-
|
|
213
192
|
this.goToPreviousPage = () => {
|
|
214
193
|
if (!this.previousPage) {
|
|
215
194
|
warn(false, `There is no previous page to go to. The current page history is: [${this._pageHistory.join(', ')}].`);
|
|
216
195
|
return void 0;
|
|
217
|
-
}
|
|
218
|
-
|
|
196
|
+
}
|
|
219
197
|
|
|
198
|
+
// If there is a previous page, goToPage will succeed and return the data
|
|
220
199
|
const _ref2 = this.goToPage(this.previousPage.id),
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
200
|
+
newPageId = _ref2.newPageId,
|
|
201
|
+
prevPageId = _ref2.prevPageId;
|
|
224
202
|
return {
|
|
225
203
|
newPageId,
|
|
226
204
|
prevPageId
|
|
227
205
|
};
|
|
228
206
|
};
|
|
229
|
-
|
|
230
207
|
this.handleBackButtonClick = () => {
|
|
231
208
|
const _ref3 = this.currentPage,
|
|
232
|
-
|
|
209
|
+
onBackButtonClicked = _ref3.onBackButtonClicked;
|
|
233
210
|
|
|
211
|
+
// we only display the back button when there is a page to go back to
|
|
234
212
|
const _ref4 = this.goToPreviousPage(),
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
213
|
+
newPageId = _ref4.newPageId,
|
|
214
|
+
prevPageId = _ref4.prevPageId;
|
|
238
215
|
if (typeof onBackButtonClicked === 'function') {
|
|
239
216
|
onBackButtonClicked(newPageId, prevPageId);
|
|
240
217
|
}
|
|
241
218
|
};
|
|
242
|
-
|
|
243
219
|
this.handleOptionSelect = (event, _ref5) => {
|
|
244
220
|
let id = _ref5.id;
|
|
245
|
-
const selectedOption = this.getPageChildById(id);
|
|
221
|
+
const selectedOption = this.getPageChildById(id);
|
|
246
222
|
|
|
223
|
+
// TODO: this line can be removed when React 16 is no longer supported
|
|
247
224
|
event.persist();
|
|
248
|
-
|
|
249
225
|
if (!id || !selectedOption || selectedOption.props.disabled || event.target.getAttribute('disabled') || event.target.getAttribute('aria-disabled')) {
|
|
250
226
|
event.preventDefault();
|
|
251
227
|
event.stopPropagation();
|
|
252
228
|
return;
|
|
253
229
|
}
|
|
254
|
-
|
|
255
230
|
const _this$props = this.props,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
231
|
+
shouldHideOnSelect = _this$props.shouldHideOnSelect,
|
|
232
|
+
onSelect = _this$props.onSelect;
|
|
259
233
|
const groupProps = selectedOption.groupProps,
|
|
260
|
-
|
|
261
|
-
|
|
234
|
+
selectedOptionChild = _objectWithoutProperties(selectedOption, _excluded);
|
|
262
235
|
const _selectedOptionChild$ = selectedOptionChild.props,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
236
|
+
subPageId = _selectedOptionChild$.subPageId,
|
|
237
|
+
href = _selectedOptionChild$.href,
|
|
238
|
+
value = _selectedOptionChild$.value,
|
|
239
|
+
onOptionClick = _selectedOptionChild$.onOptionClick;
|
|
268
240
|
if (typeof onOptionClick === 'function') {
|
|
269
241
|
onOptionClick(event, {
|
|
270
242
|
optionId: id,
|
|
@@ -272,23 +244,20 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
272
244
|
...this.exposedNavigationProps
|
|
273
245
|
});
|
|
274
246
|
}
|
|
275
|
-
|
|
276
247
|
if (subPageId) {
|
|
277
248
|
this.goToPage(subPageId);
|
|
278
249
|
}
|
|
279
|
-
|
|
280
250
|
if (href) {
|
|
281
251
|
var _this$_drilldownRef;
|
|
282
|
-
|
|
283
252
|
const optionEl = (_this$_drilldownRef = this._drilldownRef) === null || _this$_drilldownRef === void 0 ? void 0 : _this$_drilldownRef.querySelector(`#${id}`);
|
|
284
|
-
const isLink = optionEl.tagName.toLowerCase() === 'a';
|
|
285
|
-
// we ignore href prop in renderOption()
|
|
253
|
+
const isLink = optionEl.tagName.toLowerCase() === 'a';
|
|
286
254
|
|
|
255
|
+
// we need this check because in some cases
|
|
256
|
+
// we ignore href prop in renderOption()
|
|
287
257
|
if (isLink && optionEl !== null && optionEl !== void 0 && optionEl.href) {
|
|
288
258
|
optionEl.click();
|
|
289
259
|
}
|
|
290
260
|
}
|
|
291
|
-
|
|
292
261
|
if (groupProps !== null && groupProps !== void 0 && groupProps.selectableType) {
|
|
293
262
|
this.handleGroupOptionSelected(event, selectedOption);
|
|
294
263
|
} else {
|
|
@@ -300,31 +269,32 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
300
269
|
drilldown: this
|
|
301
270
|
});
|
|
302
271
|
}
|
|
303
|
-
}
|
|
304
|
-
|
|
272
|
+
}
|
|
305
273
|
|
|
274
|
+
// should prevent closing on page navigation
|
|
306
275
|
if (shouldHideOnSelect && !subPageId && id !== this._headerBackId) {
|
|
307
276
|
this.hide(event);
|
|
308
277
|
}
|
|
309
278
|
};
|
|
310
|
-
|
|
311
279
|
this.handleKeyDown = event => {
|
|
312
280
|
const id = event.target.id;
|
|
313
|
-
const option = this.getPageChildById(id);
|
|
281
|
+
const option = this.getPageChildById(id);
|
|
314
282
|
|
|
283
|
+
// On Space...
|
|
315
284
|
if ([' ', 'space', 'Space'].includes(event.key)) {
|
|
316
285
|
// we need to preventDefault so the page doesn't scroll on Space
|
|
317
286
|
event.preventDefault();
|
|
318
|
-
event.stopPropagation();
|
|
287
|
+
event.stopPropagation();
|
|
319
288
|
|
|
289
|
+
// for options, Space it has to work as Enter (get selected)
|
|
320
290
|
if (option) {
|
|
321
291
|
this.handleOptionSelect(event, {
|
|
322
292
|
id
|
|
323
293
|
});
|
|
324
294
|
}
|
|
325
|
-
}
|
|
326
|
-
|
|
295
|
+
}
|
|
327
296
|
|
|
297
|
+
// On Right arrow...
|
|
328
298
|
if (event.key === 'ArrowRight') {
|
|
329
299
|
// if the option has subpage, we open it
|
|
330
300
|
if (option !== null && option !== void 0 && option.props.subPageId) {
|
|
@@ -332,30 +302,27 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
332
302
|
id
|
|
333
303
|
});
|
|
334
304
|
}
|
|
335
|
-
}
|
|
336
|
-
|
|
305
|
+
}
|
|
337
306
|
|
|
307
|
+
// On Left arrow...
|
|
338
308
|
if (event.key === 'ArrowLeft') {
|
|
339
309
|
var _this$_popover;
|
|
340
|
-
|
|
341
310
|
// if it is possible, we go a level up in the history
|
|
342
311
|
if (this._pageHistory.length > 1) {
|
|
343
312
|
this.goToPreviousPage();
|
|
344
|
-
}
|
|
345
|
-
|
|
313
|
+
}
|
|
346
314
|
|
|
315
|
+
// if on root page and popover is open, we close it
|
|
347
316
|
if (this.isOnRootPage && (_this$_popover = this._popover) !== null && _this$_popover !== void 0 && _this$_popover.shown) {
|
|
348
317
|
this._popover.hide(event);
|
|
349
318
|
}
|
|
350
319
|
}
|
|
351
320
|
};
|
|
352
|
-
|
|
353
321
|
this.handleToggle = (event, shown) => {
|
|
354
322
|
const onToggle = this.props.onToggle;
|
|
355
323
|
this.setState({
|
|
356
324
|
isShowingPopover: shown
|
|
357
325
|
});
|
|
358
|
-
|
|
359
326
|
if (typeof onToggle === 'function') {
|
|
360
327
|
onToggle(event, {
|
|
361
328
|
shown,
|
|
@@ -364,7 +331,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
364
331
|
});
|
|
365
332
|
}
|
|
366
333
|
};
|
|
367
|
-
|
|
368
334
|
this.state = {
|
|
369
335
|
isShowingPopover: props.trigger ? !!props.show : false,
|
|
370
336
|
activePageId: props.rootPageId,
|
|
@@ -380,18 +346,13 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
380
346
|
this._headerTitleLabelId = props.deterministicId('DrilldownHeader-Title-Label');
|
|
381
347
|
this._headerActionId = props.deterministicId('DrilldownHeader-Action');
|
|
382
348
|
}
|
|
383
|
-
|
|
384
349
|
componentDidMount() {
|
|
385
350
|
var _this$props$makeStyle, _this$props2;
|
|
386
|
-
|
|
387
351
|
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStylesVariables);
|
|
388
352
|
}
|
|
389
|
-
|
|
390
353
|
componentDidUpdate(_prevProps, prevState) {
|
|
391
354
|
var _this$props$makeStyle2, _this$props3;
|
|
392
|
-
|
|
393
355
|
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStylesVariables);
|
|
394
|
-
|
|
395
356
|
if (prevState.activePageId !== this.state.activePageId) {
|
|
396
357
|
// on page change with mouse navigation, some option can get rendered
|
|
397
358
|
// under the cursor and get focused, so we need to wait a tick to see
|
|
@@ -401,9 +362,9 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
401
362
|
this.focus();
|
|
402
363
|
}
|
|
403
364
|
}, 0);
|
|
404
|
-
}
|
|
405
|
-
|
|
365
|
+
}
|
|
406
366
|
|
|
367
|
+
// if the current page was removed
|
|
407
368
|
if (!this.currentPage) {
|
|
408
369
|
if (this.previousPage) {
|
|
409
370
|
this.goToPreviousPage();
|
|
@@ -411,71 +372,62 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
411
372
|
this.goToPage(this.props.rootPageId);
|
|
412
373
|
}
|
|
413
374
|
}
|
|
414
|
-
|
|
415
375
|
if (this.state.highlightedOptionId && !this.getPageChildById(this.state.highlightedOptionId)) {
|
|
416
376
|
this.setState({
|
|
417
377
|
highlightedOptionId: void 0
|
|
418
378
|
});
|
|
419
379
|
}
|
|
420
380
|
}
|
|
421
|
-
|
|
422
381
|
get makeStylesVariables() {
|
|
423
382
|
return {
|
|
424
383
|
hasHighlightedOption: !!this.state.highlightedOptionId
|
|
425
384
|
};
|
|
426
385
|
}
|
|
427
|
-
|
|
428
386
|
get activeOptionIds() {
|
|
429
387
|
return Object.keys(this._activeOptionsMap);
|
|
430
388
|
}
|
|
431
|
-
|
|
432
389
|
get activeOptions() {
|
|
433
390
|
return Object.values(this._activeOptionsMap);
|
|
434
391
|
}
|
|
435
|
-
|
|
436
392
|
get pages() {
|
|
437
393
|
const children = this.props.children;
|
|
438
394
|
return React.Children.toArray(children || []);
|
|
439
395
|
}
|
|
440
|
-
|
|
441
396
|
get pageMap() {
|
|
442
397
|
const children = this.props.children;
|
|
443
|
-
|
|
444
398
|
if (!children) {
|
|
445
399
|
return void 0;
|
|
446
400
|
}
|
|
447
|
-
|
|
448
401
|
const map = {};
|
|
449
402
|
this.pages.forEach(page => {
|
|
450
403
|
const props = page.props;
|
|
451
404
|
const children = props.children;
|
|
452
|
-
map[props.id] = {
|
|
405
|
+
map[props.id] = {
|
|
406
|
+
...props,
|
|
453
407
|
children: React.Children.toArray(children || [])
|
|
454
408
|
};
|
|
455
409
|
});
|
|
456
410
|
return map;
|
|
457
411
|
}
|
|
458
|
-
|
|
459
412
|
get isOnRootPage() {
|
|
460
413
|
return this.state.activePageId === this.props.rootPageId;
|
|
461
414
|
}
|
|
462
|
-
|
|
463
415
|
get currentPage() {
|
|
464
416
|
return this.getPageById(this.state.activePageId);
|
|
465
417
|
}
|
|
466
|
-
|
|
467
418
|
get previousPage() {
|
|
468
419
|
const previousPageId = this._pageHistory[this._pageHistory.length - 2];
|
|
469
420
|
return this.getPageById(previousPageId);
|
|
470
|
-
}
|
|
471
|
-
// These are used in some callbacks to expose the navigation logic.
|
|
472
|
-
|
|
421
|
+
}
|
|
473
422
|
|
|
423
|
+
// Returns the navigation methods and the page history.
|
|
424
|
+
// These are used in some callbacks to expose the navigation logic.
|
|
474
425
|
get exposedNavigationProps() {
|
|
475
426
|
const goToPage = this.goToPage,
|
|
476
|
-
|
|
477
|
-
// cannot be modified from the outside
|
|
427
|
+
goToPreviousPage = this.goToPreviousPage;
|
|
478
428
|
|
|
429
|
+
// we make a copy of the array so the original history
|
|
430
|
+
// cannot be modified from the outside
|
|
479
431
|
const pageHistory = [...this._pageHistory];
|
|
480
432
|
return {
|
|
481
433
|
pageHistory,
|
|
@@ -483,44 +435,36 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
483
435
|
goToPreviousPage
|
|
484
436
|
};
|
|
485
437
|
}
|
|
486
|
-
|
|
487
438
|
get currentPageAriaLabel() {
|
|
488
439
|
var _this$currentPage;
|
|
489
|
-
|
|
490
440
|
// return, if explicitly set
|
|
491
441
|
if (this.props['aria-labelledby']) {
|
|
492
442
|
return this.props['aria-labelledby'];
|
|
493
|
-
}
|
|
494
|
-
|
|
443
|
+
}
|
|
495
444
|
|
|
445
|
+
// if it has title, point to the title label content
|
|
496
446
|
if ((_this$currentPage = this.currentPage) !== null && _this$currentPage !== void 0 && _this$currentPage.renderTitle) {
|
|
497
447
|
return this._headerTitleLabelId;
|
|
498
|
-
}
|
|
499
|
-
|
|
448
|
+
}
|
|
500
449
|
|
|
450
|
+
// if root page has no title, try the trigger, if exists
|
|
501
451
|
if (this.isOnRootPage && this.props.trigger) {
|
|
502
452
|
return this._triggerId;
|
|
503
453
|
}
|
|
504
|
-
|
|
505
454
|
return void 0;
|
|
506
455
|
}
|
|
507
|
-
|
|
508
456
|
getChildrenArray(children) {
|
|
509
457
|
if (!children) {
|
|
510
458
|
return [];
|
|
511
459
|
}
|
|
512
|
-
|
|
513
460
|
return Array.isArray(children) ? children : [children];
|
|
514
461
|
}
|
|
515
|
-
|
|
516
462
|
getPageById(id) {
|
|
517
463
|
return this.pageMap && id ? this.pageMap[id] : void 0;
|
|
518
464
|
}
|
|
519
|
-
|
|
520
465
|
getPageChildById(id) {
|
|
521
466
|
return id ? this._activeOptionsMap[id] : void 0;
|
|
522
467
|
}
|
|
523
|
-
|
|
524
468
|
setDefaultSelected() {
|
|
525
469
|
const selectedGroupOptionsMap = {};
|
|
526
470
|
this.pages.forEach(page => {
|
|
@@ -528,41 +472,35 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
528
472
|
this.getChildrenArray(children).forEach(child => {
|
|
529
473
|
if (matchComponentTypes(child, [DrilldownGroup])) {
|
|
530
474
|
var _this$getChildrenArra;
|
|
531
|
-
|
|
532
475
|
const _child$props = child.props,
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
476
|
+
groupId = _child$props.id,
|
|
477
|
+
selectableType = _child$props.selectableType,
|
|
478
|
+
_child$props$defaultS = _child$props.defaultSelected,
|
|
479
|
+
groupDefaultSelected = _child$props$defaultS === void 0 ? [] : _child$props$defaultS,
|
|
480
|
+
groupChildren = _child$props.children;
|
|
539
481
|
if (!selectableType) {
|
|
540
482
|
return;
|
|
541
483
|
}
|
|
542
|
-
|
|
543
484
|
if (selectableType && !selectedGroupOptionsMap[groupId]) {
|
|
544
485
|
selectedGroupOptionsMap[groupId] = new Map();
|
|
545
486
|
}
|
|
546
|
-
|
|
547
487
|
if (selectableType === 'single' && groupDefaultSelected.length > 1) {
|
|
548
488
|
error(false, `Radio type selectable groups can have only one item selected! Group with id "${groupId}" cannot select multiple items: [${groupDefaultSelected.join(', ')}]!`);
|
|
549
489
|
return;
|
|
550
490
|
}
|
|
551
|
-
|
|
552
491
|
selectedGroupOptionsMap[groupId] = new Map();
|
|
553
492
|
(_this$getChildrenArra = this.getChildrenArray(groupChildren)) === null || _this$getChildrenArra === void 0 ? void 0 : _this$getChildrenArra.forEach(groupChild => {
|
|
554
493
|
if (matchComponentTypes(groupChild, [DrilldownOption])) {
|
|
555
494
|
const _groupChild$props = groupChild.props,
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
495
|
+
optionId = _groupChild$props.id,
|
|
496
|
+
optionValue = _groupChild$props.value,
|
|
497
|
+
optionDefaultSelected = _groupChild$props.defaultSelected;
|
|
559
498
|
|
|
499
|
+
// if explicitly set to false, it should override the group's
|
|
560
500
|
if (optionDefaultSelected === false) {
|
|
561
501
|
return;
|
|
562
502
|
}
|
|
563
|
-
|
|
564
503
|
const isGroupDefaultSelected = typeof optionValue !== 'undefined' && groupDefaultSelected.filter(value => typeof value !== 'undefined').includes(optionValue);
|
|
565
|
-
|
|
566
504
|
if (optionDefaultSelected || isGroupDefaultSelected) {
|
|
567
505
|
selectedGroupOptionsMap[groupId].set(optionId, optionValue);
|
|
568
506
|
}
|
|
@@ -573,29 +511,26 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
573
511
|
});
|
|
574
512
|
return selectedGroupOptionsMap;
|
|
575
513
|
}
|
|
576
|
-
|
|
577
514
|
get selectedGroupOptionIdsArray() {
|
|
578
515
|
return Object.values(this.state.selectedGroupOptionsMap).map(groupIdMap => Array.from(groupIdMap.keys())).flat();
|
|
579
516
|
}
|
|
580
|
-
|
|
581
517
|
get headerChildren() {
|
|
582
518
|
const currentPage = this.currentPage;
|
|
583
519
|
const _this$props4 = this.props,
|
|
584
|
-
|
|
585
|
-
|
|
520
|
+
styles = _this$props4.styles,
|
|
521
|
+
deterministicId = _this$props4.deterministicId;
|
|
586
522
|
const headerChildren = [];
|
|
587
|
-
|
|
588
523
|
if (!currentPage) {
|
|
589
524
|
return headerChildren;
|
|
590
525
|
}
|
|
591
|
-
|
|
592
526
|
const children = currentPage.children,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
527
|
+
renderBackButtonLabel = currentPage.renderBackButtonLabel,
|
|
528
|
+
renderTitle = currentPage.renderTitle,
|
|
529
|
+
renderActionLabel = currentPage.renderActionLabel,
|
|
530
|
+
onHeaderActionClicked = currentPage.onHeaderActionClicked,
|
|
531
|
+
withoutHeaderSeparator = currentPage.withoutHeaderSeparator;
|
|
598
532
|
|
|
533
|
+
// Back navigation option
|
|
599
534
|
if (this.previousPage) {
|
|
600
535
|
const prevPageTitle = callRenderProp(this.previousPage.renderTitle);
|
|
601
536
|
const backButtonLabel = callRenderProp(renderBackButtonLabel, prevPageTitle);
|
|
@@ -606,12 +541,11 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
606
541
|
css: styles === null || styles === void 0 ? void 0 : styles.headerBack,
|
|
607
542
|
role: "presentation"
|
|
608
543
|
}, backButtonLabel)));
|
|
609
|
-
}
|
|
610
|
-
|
|
544
|
+
}
|
|
611
545
|
|
|
546
|
+
// Header title
|
|
612
547
|
if (renderTitle) {
|
|
613
548
|
const title = callRenderProp(renderTitle);
|
|
614
|
-
|
|
615
549
|
if (title) {
|
|
616
550
|
headerChildren.push(jsx(DrilldownOption, {
|
|
617
551
|
id: this._headerTitleId,
|
|
@@ -622,12 +556,11 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
622
556
|
id: this._headerTitleLabelId
|
|
623
557
|
}, title)));
|
|
624
558
|
}
|
|
625
|
-
}
|
|
626
|
-
|
|
559
|
+
}
|
|
627
560
|
|
|
561
|
+
// Action label
|
|
628
562
|
if (renderActionLabel) {
|
|
629
563
|
const actionLabel = callRenderProp(renderActionLabel);
|
|
630
|
-
|
|
631
564
|
if (actionLabel) {
|
|
632
565
|
headerChildren.push(jsx(DrilldownOption, {
|
|
633
566
|
id: this._headerActionId,
|
|
@@ -641,26 +574,22 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
641
574
|
}
|
|
642
575
|
}, actionLabel));
|
|
643
576
|
}
|
|
644
|
-
}
|
|
645
|
-
|
|
577
|
+
}
|
|
646
578
|
|
|
579
|
+
// header separator
|
|
647
580
|
if (headerChildren.length > 0 && children.length > 0 && !withoutHeaderSeparator) {
|
|
648
581
|
headerChildren.push(jsx(DrilldownSeparator, {
|
|
649
582
|
id: deterministicId('DrilldownHeader-Separator')
|
|
650
583
|
}));
|
|
651
584
|
}
|
|
652
|
-
|
|
653
585
|
return headerChildren;
|
|
654
586
|
}
|
|
655
|
-
|
|
656
587
|
get shown() {
|
|
657
588
|
return this.props.trigger ? this.state.isShowingPopover : true;
|
|
658
589
|
}
|
|
659
|
-
|
|
660
590
|
containsDuplicateChild(children) {
|
|
661
591
|
let containsDuplicate = false;
|
|
662
592
|
const childMap = new Map();
|
|
663
|
-
|
|
664
593
|
for (const child of children) {
|
|
665
594
|
if (!childMap.has(child.props.id)) {
|
|
666
595
|
childMap.set(child.props.id, true);
|
|
@@ -669,32 +598,25 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
669
598
|
return containsDuplicate = true;
|
|
670
599
|
}
|
|
671
600
|
}
|
|
672
|
-
|
|
673
601
|
return containsDuplicate;
|
|
674
602
|
}
|
|
675
|
-
|
|
676
603
|
reset() {
|
|
677
604
|
this._activeOptionsMap = {};
|
|
678
605
|
this.setState({
|
|
679
606
|
highlightedOptionId: void 0
|
|
680
607
|
});
|
|
681
608
|
}
|
|
682
|
-
|
|
683
609
|
focus() {
|
|
684
610
|
if (this.shown) {
|
|
685
611
|
var _this$_drilldownRef2, _this$_drilldownRef3;
|
|
686
|
-
|
|
687
612
|
error(!!((_this$_drilldownRef2 = this._drilldownRef) !== null && _this$_drilldownRef2 !== void 0 && _this$_drilldownRef2.focus), '[Drilldown] Could not focus the drilldown.');
|
|
688
613
|
(_this$_drilldownRef3 = this._drilldownRef) === null || _this$_drilldownRef3 === void 0 ? void 0 : _this$_drilldownRef3.focus();
|
|
689
614
|
} else {
|
|
690
615
|
var _this$_trigger;
|
|
691
|
-
|
|
692
616
|
error(!!((_this$_trigger = this._trigger) !== null && _this$_trigger !== void 0 && _this$_trigger.focus), '[Drilldown] Could not focus the trigger.');
|
|
693
|
-
|
|
694
617
|
this._trigger.focus();
|
|
695
618
|
}
|
|
696
619
|
}
|
|
697
|
-
|
|
698
620
|
focused() {
|
|
699
621
|
if (this.shown) {
|
|
700
622
|
return containsActiveElement(this._drilldownRef);
|
|
@@ -702,25 +624,21 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
702
624
|
return containsActiveElement(this._trigger);
|
|
703
625
|
}
|
|
704
626
|
}
|
|
705
|
-
|
|
706
627
|
focusOption(id) {
|
|
707
628
|
const container = this._containerElement;
|
|
708
629
|
const optionElement = container === null || container === void 0 ? void 0 : container.querySelector(`[id="${id}"]`);
|
|
709
630
|
optionElement === null || optionElement === void 0 ? void 0 : optionElement.focus();
|
|
710
631
|
}
|
|
711
|
-
|
|
712
632
|
handleGroupOptionSelected(event, selectedOption) {
|
|
713
633
|
this.setState(oldState => {
|
|
714
634
|
var _oldState$selectedGro;
|
|
715
|
-
|
|
716
635
|
const _selectedOption$props = selectedOption.props,
|
|
717
|
-
|
|
718
|
-
|
|
636
|
+
optionId = _selectedOption$props.id,
|
|
637
|
+
value = _selectedOption$props.value;
|
|
719
638
|
const _ref6 = selectedOption.groupProps,
|
|
720
|
-
|
|
721
|
-
|
|
639
|
+
groupId = _ref6.id,
|
|
640
|
+
selectableType = _ref6.selectableType;
|
|
722
641
|
let newState = new Map(oldState.selectedGroupOptionsMap[groupId]);
|
|
723
|
-
|
|
724
642
|
if (selectableType === 'multiple' && Boolean((_oldState$selectedGro = oldState.selectedGroupOptionsMap[groupId]) === null || _oldState$selectedGro === void 0 ? void 0 : _oldState$selectedGro.has(optionId))) {
|
|
725
643
|
// toggle off, if already selected
|
|
726
644
|
newState.delete(optionId);
|
|
@@ -734,24 +652,22 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
734
652
|
newState.set(optionId, value);
|
|
735
653
|
}
|
|
736
654
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
selectedGroupOptionsMap: {
|
|
655
|
+
return {
|
|
656
|
+
...oldState,
|
|
657
|
+
selectedGroupOptionsMap: {
|
|
658
|
+
...oldState.selectedGroupOptionsMap,
|
|
740
659
|
[groupId]: newState
|
|
741
660
|
}
|
|
742
661
|
};
|
|
743
662
|
}, () => {
|
|
744
663
|
const value = selectedOption.props.value;
|
|
745
664
|
const _ref7 = selectedOption.groupProps,
|
|
746
|
-
|
|
747
|
-
|
|
665
|
+
groupId = _ref7.id,
|
|
666
|
+
groupOnSelect = _ref7.onSelect;
|
|
748
667
|
const onSelect = this.props.onSelect;
|
|
749
|
-
|
|
750
668
|
const groupProps = selectedOption.groupProps,
|
|
751
|
-
|
|
752
|
-
|
|
669
|
+
option = _objectWithoutProperties(selectedOption, _excluded2);
|
|
753
670
|
const selectedOptionValuesInGroup = [...this.state.selectedGroupOptionsMap[groupId].values()];
|
|
754
|
-
|
|
755
671
|
if (typeof groupOnSelect === 'function') {
|
|
756
672
|
groupOnSelect(event, {
|
|
757
673
|
value: selectedOptionValuesInGroup,
|
|
@@ -760,7 +676,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
760
676
|
drilldown: this
|
|
761
677
|
});
|
|
762
678
|
}
|
|
763
|
-
|
|
764
679
|
if (typeof onSelect === 'function') {
|
|
765
680
|
onSelect(event, {
|
|
766
681
|
value: selectedOptionValuesInGroup,
|
|
@@ -771,17 +686,15 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
771
686
|
}
|
|
772
687
|
});
|
|
773
688
|
}
|
|
774
|
-
|
|
775
689
|
renderList(getOptionProps, getDisabledOptionProps) {
|
|
776
690
|
const currentPage = this.currentPage,
|
|
777
|
-
|
|
778
|
-
|
|
691
|
+
headerChildren = this.headerChildren;
|
|
779
692
|
if (!currentPage || this.containsDuplicateChild(currentPage.children)) {
|
|
780
693
|
return null;
|
|
781
694
|
}
|
|
695
|
+
const pageChildren = [...headerChildren, ...currentPage.children];
|
|
782
696
|
|
|
783
|
-
|
|
784
|
-
|
|
697
|
+
// for tracking if the last item was a Separator or not
|
|
785
698
|
let lastItemWasSeparator = false;
|
|
786
699
|
return pageChildren.map((child, index) => {
|
|
787
700
|
/**
|
|
@@ -794,8 +707,10 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
794
707
|
const needsFirstSeparator = !child.props.withoutSeparators && !isFirstChild && !afterSeparator;
|
|
795
708
|
const needsLastSeparator = !child.props.withoutSeparators && !isLastChild;
|
|
796
709
|
lastItemWasSeparator = needsLastSeparator;
|
|
797
|
-
return this.renderGroup(child, getOptionProps, getDisabledOptionProps,
|
|
710
|
+
return this.renderGroup(child, getOptionProps, getDisabledOptionProps,
|
|
711
|
+
// for rendering separators appropriately
|
|
798
712
|
needsFirstSeparator, needsLastSeparator);
|
|
713
|
+
|
|
799
714
|
/**
|
|
800
715
|
* --- RENDER SEPARATOR ---
|
|
801
716
|
*/
|
|
@@ -804,9 +719,9 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
804
719
|
if (lastItemWasSeparator) {
|
|
805
720
|
return null;
|
|
806
721
|
}
|
|
807
|
-
|
|
808
722
|
lastItemWasSeparator = true;
|
|
809
723
|
return this.renderSeparator(child);
|
|
724
|
+
|
|
810
725
|
/**
|
|
811
726
|
* --- RENDER OPTION ---
|
|
812
727
|
*/
|
|
@@ -818,52 +733,49 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
818
733
|
}
|
|
819
734
|
});
|
|
820
735
|
}
|
|
821
|
-
|
|
822
736
|
renderSeparator(separator) {
|
|
823
737
|
const _separator$props = separator.props,
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
738
|
+
id = _separator$props.id,
|
|
739
|
+
themeOverride = _separator$props.themeOverride,
|
|
740
|
+
props = _objectWithoutProperties(_separator$props, _excluded3);
|
|
828
741
|
return jsx(Options.Separator, Object.assign({}, props, {
|
|
829
742
|
id: id,
|
|
830
743
|
key: id,
|
|
831
|
-
role: "separator"
|
|
744
|
+
role: "separator"
|
|
745
|
+
// we pass the themeOverride to Options.Separator
|
|
832
746
|
,
|
|
833
747
|
themeOverride: themeOverride
|
|
834
748
|
}));
|
|
835
749
|
}
|
|
836
|
-
|
|
837
750
|
renderOption(option, getOptionProps, getDisabledOptionProps, groupProps) {
|
|
838
751
|
var _this$currentPage2, _optionProps$renderBe, _optionProps$renderBe2, _optionProps$renderAf, _optionProps$renderAf2;
|
|
839
|
-
|
|
840
752
|
const styles = this.props.styles;
|
|
841
753
|
let isSelected = false;
|
|
842
754
|
const _option$props = option.props,
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
755
|
+
id = _option$props.id,
|
|
756
|
+
children = _option$props.children,
|
|
757
|
+
href = _option$props.href,
|
|
758
|
+
as = _option$props.as,
|
|
759
|
+
role = _option$props.role,
|
|
760
|
+
subPageId = _option$props.subPageId,
|
|
761
|
+
disabled = _option$props.disabled,
|
|
762
|
+
renderLabelInfo = _option$props.renderLabelInfo,
|
|
763
|
+
renderBeforeLabel = _option$props.renderBeforeLabel,
|
|
764
|
+
renderAfterLabel = _option$props.renderAfterLabel,
|
|
765
|
+
beforeLabelContentVAlign = _option$props.beforeLabelContentVAlign,
|
|
766
|
+
afterLabelContentVAlign = _option$props.afterLabelContentVAlign,
|
|
767
|
+
description = _option$props.description,
|
|
768
|
+
descriptionRole = _option$props.descriptionRole,
|
|
769
|
+
elementRef = _option$props.elementRef,
|
|
770
|
+
themeOverride = _option$props.themeOverride;
|
|
860
771
|
if (!id) {
|
|
861
772
|
warn(false, `Drilldown.Option without id won't be rendered. It is needed to internally track the options.`);
|
|
862
773
|
return null;
|
|
863
|
-
}
|
|
864
|
-
|
|
774
|
+
}
|
|
865
775
|
|
|
866
|
-
|
|
776
|
+
// Props passed to the Option.Item
|
|
777
|
+
let optionProps = {
|
|
778
|
+
// passthrough props
|
|
867
779
|
...omitProps(option.props, [...DrilldownOption.allowedProps, ...Options.Item.allowedProps]),
|
|
868
780
|
// props from selectable
|
|
869
781
|
...getOptionProps({
|
|
@@ -887,81 +799,78 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
887
799
|
elementRef,
|
|
888
800
|
variant: 'default',
|
|
889
801
|
tabIndex: -1
|
|
890
|
-
};
|
|
891
|
-
// but don't want to expose as props
|
|
802
|
+
};
|
|
892
803
|
|
|
804
|
+
// extra data we need track on the option,
|
|
805
|
+
// but don't want to expose as props
|
|
893
806
|
const optionData = {
|
|
894
807
|
groupProps: groupProps
|
|
895
808
|
};
|
|
896
|
-
const isOptionDisabled = id !== this._headerBackId && (
|
|
897
|
-
|
|
809
|
+
const isOptionDisabled = id !== this._headerBackId && (
|
|
810
|
+
// Back nav is never disabled
|
|
811
|
+
this.props.disabled || ((_this$currentPage2 = this.currentPage) === null || _this$currentPage2 === void 0 ? void 0 : _this$currentPage2.disabled) || (groupProps === null || groupProps === void 0 ? void 0 : groupProps.disabled) || disabled);
|
|
898
812
|
|
|
813
|
+
// display option as disabled
|
|
899
814
|
if (isOptionDisabled) {
|
|
900
815
|
optionProps.variant = 'disabled';
|
|
901
|
-
optionProps = {
|
|
816
|
+
optionProps = {
|
|
817
|
+
...optionProps,
|
|
902
818
|
...getDisabledOptionProps()
|
|
903
819
|
};
|
|
904
|
-
}
|
|
905
|
-
|
|
820
|
+
}
|
|
906
821
|
|
|
822
|
+
// track as valid active option if not the title
|
|
907
823
|
if (id !== this._headerTitleId) {
|
|
908
|
-
this._activeOptionsMap[id] = {
|
|
824
|
+
this._activeOptionsMap[id] = {
|
|
825
|
+
...option,
|
|
909
826
|
...optionData
|
|
910
827
|
};
|
|
911
828
|
}
|
|
829
|
+
const customRole = role !== DrilldownOption.defaultProps.role ? role : void 0;
|
|
912
830
|
|
|
913
|
-
|
|
831
|
+
// BEFORE/AFTER elements:
|
|
914
832
|
// we set a few manually on Options.Item,
|
|
915
833
|
// the rest are passed directly
|
|
916
|
-
|
|
917
834
|
if (subPageId) {
|
|
918
835
|
optionProps.renderAfterLabel = _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = jsx(IconArrowOpenEndSolid, null));
|
|
919
836
|
optionProps['aria-haspopup'] = true;
|
|
920
837
|
optionProps.role = customRole || 'button';
|
|
921
838
|
warn(!renderAfterLabel, `The prop "renderAfterLabel" is reserved on item with id: "${id}". When it has "subPageId" provided, a navigation arrow will render after the label.`);
|
|
922
839
|
}
|
|
923
|
-
|
|
924
840
|
if (id === this._headerBackId) {
|
|
925
841
|
optionProps.renderBeforeLabel = _IconArrowOpenStartSo || (_IconArrowOpenStartSo = jsx(IconArrowOpenStartSolid, null));
|
|
926
842
|
}
|
|
927
|
-
|
|
928
843
|
const isOptionControlled = typeof option.props.selected === 'boolean';
|
|
929
|
-
|
|
930
844
|
if ((groupProps !== null && groupProps !== void 0 && groupProps.selectableType || isOptionControlled) && groupProps) {
|
|
931
845
|
if (!isOptionControlled) {
|
|
932
846
|
var _this$state$selectedG;
|
|
933
|
-
|
|
934
847
|
isSelected = Boolean((_this$state$selectedG = this.state.selectedGroupOptionsMap[groupProps.id]) === null || _this$state$selectedG === void 0 ? void 0 : _this$state$selectedG.has(id));
|
|
935
848
|
} else {
|
|
936
849
|
isSelected = Boolean(option.props.selected);
|
|
937
850
|
}
|
|
938
|
-
|
|
939
851
|
optionProps['aria-checked'] = isSelected;
|
|
940
852
|
optionProps.renderBeforeLabel = jsx(IconCheckSolid, {
|
|
941
853
|
style: {
|
|
942
854
|
opacity: isSelected ? 1 : 0
|
|
943
855
|
}
|
|
944
856
|
});
|
|
945
|
-
warn(!renderBeforeLabel, `The prop "renderBeforeLabel" is reserved on item with id: "${id}". When this option is a selectable member of a Drilldown.Group, selection indicator will render before the label.`);
|
|
857
|
+
warn(!renderBeforeLabel, `The prop "renderBeforeLabel" is reserved on item with id: "${id}". When this option is a selectable member of a Drilldown.Group, selection indicator will render before the label.`);
|
|
946
858
|
|
|
859
|
+
// setting aria roles and attributes for selectable group items
|
|
947
860
|
if (groupProps.selectableType === 'single') {
|
|
948
861
|
optionProps.role = customRole || 'menuitemradio';
|
|
949
862
|
}
|
|
950
|
-
|
|
951
863
|
if (groupProps.selectableType === 'multiple') {
|
|
952
864
|
optionProps.role = customRole || 'menuitemcheckbox';
|
|
953
865
|
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
866
|
+
}
|
|
867
|
+
// display option as highlighted
|
|
957
868
|
if (id === this.state.highlightedOptionId) {
|
|
958
869
|
optionProps.variant = 'highlighted';
|
|
959
|
-
|
|
960
870
|
if (isOptionDisabled) {
|
|
961
871
|
optionProps.variant = 'highlighted-disabled';
|
|
962
872
|
}
|
|
963
873
|
}
|
|
964
|
-
|
|
965
874
|
if (href) {
|
|
966
875
|
if (subPageId) {
|
|
967
876
|
warn(false, `Drilldown.Option with id "${id}" has subPageId, so it will ignore the "href" property.`);
|
|
@@ -971,34 +880,30 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
971
880
|
optionProps.href = href;
|
|
972
881
|
}
|
|
973
882
|
}
|
|
974
|
-
|
|
975
883
|
const optionLabel = callRenderProp(children, {
|
|
976
884
|
id,
|
|
977
885
|
variant: optionProps.variant,
|
|
978
886
|
isSelected
|
|
979
887
|
});
|
|
980
|
-
|
|
981
888
|
if (!optionLabel) {
|
|
982
889
|
warn(false, `There are no "children" prop provided for option with id: "${id}", so it won't be rendered.`);
|
|
983
890
|
return null;
|
|
984
891
|
}
|
|
985
|
-
|
|
986
892
|
const renderLabelProps = {
|
|
987
893
|
variant: optionProps.variant,
|
|
988
894
|
vAlign: afterLabelContentVAlign,
|
|
989
895
|
as,
|
|
990
896
|
role: optionProps.role,
|
|
991
897
|
isSelected
|
|
992
|
-
};
|
|
898
|
+
};
|
|
993
899
|
|
|
900
|
+
// we need to bind our own option props the render functions
|
|
994
901
|
if (typeof optionProps.renderBeforeLabel === 'function' && !((_optionProps$renderBe = optionProps.renderBeforeLabel) !== null && _optionProps$renderBe !== void 0 && (_optionProps$renderBe2 = _optionProps$renderBe.prototype) !== null && _optionProps$renderBe2 !== void 0 && _optionProps$renderBe2.isReactComponent)) {
|
|
995
902
|
optionProps.renderBeforeLabel = optionProps.renderBeforeLabel.bind(null, renderLabelProps);
|
|
996
903
|
}
|
|
997
|
-
|
|
998
904
|
if (typeof optionProps.renderAfterLabel === 'function' && !((_optionProps$renderAf = optionProps.renderAfterLabel) !== null && _optionProps$renderAf !== void 0 && (_optionProps$renderAf2 = _optionProps$renderAf.prototype) !== null && _optionProps$renderAf2 !== void 0 && _optionProps$renderAf2.isReactComponent)) {
|
|
999
905
|
optionProps.renderAfterLabel = optionProps.renderAfterLabel.bind(null, renderLabelProps);
|
|
1000
906
|
}
|
|
1001
|
-
|
|
1002
907
|
const labelInfo = renderLabelInfo && callRenderProp(renderLabelInfo, renderLabelProps);
|
|
1003
908
|
const vAlignMap = {
|
|
1004
909
|
start: 'flex-start',
|
|
@@ -1030,36 +935,35 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1030
935
|
id: infoAriaId
|
|
1031
936
|
}, labelInfo)) : null));
|
|
1032
937
|
}
|
|
1033
|
-
|
|
1034
938
|
renderGroup(group, getOptionProps, getDisabledOptionProps, needsFirstSeparator, needsLastSeparator) {
|
|
1035
939
|
const _group$props = group.props,
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
940
|
+
id = _group$props.id,
|
|
941
|
+
children = _group$props.children,
|
|
942
|
+
renderGroupTitle = _group$props.renderGroupTitle,
|
|
943
|
+
themeOverride = _group$props.themeOverride,
|
|
944
|
+
role = _group$props.role,
|
|
945
|
+
as = _group$props.as,
|
|
946
|
+
elementRef = _group$props.elementRef;
|
|
1044
947
|
if (!children) {
|
|
1045
948
|
return null;
|
|
1046
949
|
}
|
|
950
|
+
const groupChildren = [];
|
|
1047
951
|
|
|
1048
|
-
|
|
1049
|
-
|
|
952
|
+
// add a separator above
|
|
1050
953
|
if (needsFirstSeparator) {
|
|
1051
954
|
groupChildren.push(_Options$Separator || (_Options$Separator = jsx(Options.Separator, null)));
|
|
1052
|
-
}
|
|
1053
|
-
// (a wrapping list item will be created by Options)
|
|
1054
|
-
|
|
955
|
+
}
|
|
1055
956
|
|
|
957
|
+
// create a sublist as a group
|
|
958
|
+
// (a wrapping list item will be created by Options)
|
|
1056
959
|
groupChildren.push(jsx(Options, {
|
|
1057
960
|
id: id,
|
|
1058
961
|
key: id,
|
|
1059
962
|
role: role,
|
|
1060
963
|
as: as || this.props.as,
|
|
1061
964
|
renderLabel: renderGroupTitle,
|
|
1062
|
-
elementRef: elementRef
|
|
965
|
+
elementRef: elementRef
|
|
966
|
+
// we pass the themeOverride to Options
|
|
1063
967
|
,
|
|
1064
968
|
themeOverride: themeOverride
|
|
1065
969
|
}, this.getChildrenArray(children).map(child => {
|
|
@@ -1070,34 +974,31 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1070
974
|
} else {
|
|
1071
975
|
return null;
|
|
1072
976
|
}
|
|
1073
|
-
})));
|
|
977
|
+
})));
|
|
1074
978
|
|
|
979
|
+
// add a separator below
|
|
1075
980
|
if (needsLastSeparator) {
|
|
1076
981
|
groupChildren.push(_Options$Separator2 || (_Options$Separator2 = jsx(Options.Separator, null)));
|
|
1077
982
|
}
|
|
1078
|
-
|
|
1079
983
|
return groupChildren;
|
|
1080
984
|
}
|
|
1081
|
-
|
|
1082
985
|
renderPage() {
|
|
1083
986
|
const _this$props5 = this.props,
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
987
|
+
styles = _this$props5.styles,
|
|
988
|
+
overflowY = _this$props5.overflowY,
|
|
989
|
+
overflowX = _this$props5.overflowX,
|
|
990
|
+
height = _this$props5.height,
|
|
991
|
+
width = _this$props5.width,
|
|
992
|
+
minHeight = _this$props5.minHeight,
|
|
993
|
+
minWidth = _this$props5.minWidth,
|
|
994
|
+
maxHeight = _this$props5.maxHeight,
|
|
995
|
+
maxWidth = _this$props5.maxWidth,
|
|
996
|
+
role = _this$props5.role,
|
|
997
|
+
as = _this$props5.as,
|
|
998
|
+
label = _this$props5.label;
|
|
1097
999
|
if (!this.currentPage) {
|
|
1098
1000
|
return null;
|
|
1099
1001
|
}
|
|
1100
|
-
|
|
1101
1002
|
return jsx(Selectable, {
|
|
1102
1003
|
isShowingOptions: this.shown,
|
|
1103
1004
|
highlightedOptionId: this.state.highlightedOptionId,
|
|
@@ -1120,9 +1021,9 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1120
1021
|
}
|
|
1121
1022
|
}, _ref8 => {
|
|
1122
1023
|
let getTriggerProps = _ref8.getTriggerProps,
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1024
|
+
getListProps = _ref8.getListProps,
|
|
1025
|
+
getOptionProps = _ref8.getOptionProps,
|
|
1026
|
+
getDisabledOptionProps = _ref8.getDisabledOptionProps;
|
|
1126
1027
|
return jsx(View, Object.assign({
|
|
1127
1028
|
as: "div",
|
|
1128
1029
|
elementRef: this.handleDrilldownRef,
|
|
@@ -1147,7 +1048,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1147
1048
|
const target = event.currentTarget;
|
|
1148
1049
|
const related = event.relatedTarget;
|
|
1149
1050
|
const containsRelated = contains(target, related);
|
|
1150
|
-
|
|
1151
1051
|
if (!related || related === this._drilldownRef || related !== target && !containsRelated) {
|
|
1152
1052
|
this.setState({
|
|
1153
1053
|
highlightedOptionId: void 0
|
|
@@ -1181,40 +1081,37 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1181
1081
|
}), this.renderList(getOptionProps, getDisabledOptionProps))));
|
|
1182
1082
|
});
|
|
1183
1083
|
}
|
|
1184
|
-
|
|
1185
1084
|
render() {
|
|
1186
1085
|
// clear temporary option store
|
|
1187
1086
|
this._activeOptionsMap = {};
|
|
1188
1087
|
const _this$props6 = this.props,
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1088
|
+
show = _this$props6.show,
|
|
1089
|
+
defaultShow = _this$props6.defaultShow,
|
|
1090
|
+
placement = _this$props6.placement,
|
|
1091
|
+
withArrow = _this$props6.withArrow,
|
|
1092
|
+
shouldContainFocus = _this$props6.shouldContainFocus,
|
|
1093
|
+
shouldReturnFocus = _this$props6.shouldReturnFocus,
|
|
1094
|
+
trigger = _this$props6.trigger,
|
|
1095
|
+
mountNode = _this$props6.mountNode,
|
|
1096
|
+
constrain = _this$props6.constrain,
|
|
1097
|
+
positionTarget = _this$props6.positionTarget,
|
|
1098
|
+
positionContainerDisplay = _this$props6.positionContainerDisplay,
|
|
1099
|
+
popoverRef = _this$props6.popoverRef,
|
|
1100
|
+
disabled = _this$props6.disabled,
|
|
1101
|
+
onDismiss = _this$props6.onDismiss,
|
|
1102
|
+
onFocus = _this$props6.onFocus,
|
|
1103
|
+
onMouseOver = _this$props6.onMouseOver,
|
|
1104
|
+
offsetX = _this$props6.offsetX,
|
|
1105
|
+
offsetY = _this$props6.offsetY;
|
|
1207
1106
|
return trigger ? jsx(Popover, {
|
|
1208
1107
|
isShowingContent: show,
|
|
1209
1108
|
defaultIsShowingContent: defaultShow,
|
|
1210
1109
|
shouldCloseOnDocumentClick: true,
|
|
1211
1110
|
onHideContent: (event, _ref9) => {
|
|
1212
1111
|
let documentClick = _ref9.documentClick;
|
|
1213
|
-
|
|
1214
1112
|
if (typeof onDismiss === 'function') {
|
|
1215
1113
|
onDismiss(event, documentClick);
|
|
1216
1114
|
}
|
|
1217
|
-
|
|
1218
1115
|
this.reset();
|
|
1219
1116
|
this.handleToggle(event, false);
|
|
1220
1117
|
},
|
|
@@ -1240,7 +1137,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1240
1137
|
},
|
|
1241
1138
|
ref: el => {
|
|
1242
1139
|
this._popover = el;
|
|
1243
|
-
|
|
1244
1140
|
if (typeof popoverRef === 'function') {
|
|
1245
1141
|
popoverRef(el);
|
|
1246
1142
|
}
|
|
@@ -1256,7 +1152,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1256
1152
|
})
|
|
1257
1153
|
}, this.renderPage()) : this.renderPage();
|
|
1258
1154
|
}
|
|
1259
|
-
|
|
1260
1155
|
}, _class2.displayName = "Drilldown", _class2.componentId = 'Drilldown', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
1261
1156
|
disabled: false,
|
|
1262
1157
|
rotateFocus: true,
|