q2-tecton-elements 1.23.0-alpha.0 → 1.24.0
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/dist/cjs/action-sheet-4b366e9a.js +84 -0
- package/dist/cjs/charting-d02cba1f.js +3127 -0
- package/dist/cjs/{index-3518c78c.js → index-e00b4210.js} +33 -7
- package/dist/cjs/{installCanvasRenderer-b4d10c92.js → installCanvasRenderer-6c4fbcc9.js} +230 -1130
- package/dist/cjs/installLabelLayout-d6b548fe.js +1048 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-action-sheet.cjs.entry.js +218 -0
- package/dist/cjs/q2-badge_2.cjs.entry.js +1 -1
- package/dist/cjs/q2-btn_2.cjs.entry.js +2 -2
- package/dist/cjs/q2-calendar.cjs.entry.js +1 -1
- package/dist/cjs/q2-card.cjs.entry.js +2 -2
- package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-area.cjs.entry.js +4569 -0
- package/dist/cjs/q2-chart-bar.cjs.entry.js +25 -3133
- package/dist/cjs/q2-chart-donut.cjs.entry.js +9 -8
- package/dist/cjs/q2-checkbox-group.cjs.entry.js +1 -1
- package/dist/cjs/q2-checkbox.cjs.entry.js +2 -2
- package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown.cjs.entry.js +1 -1
- package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
- package/dist/cjs/q2-icon.cjs.entry.js +1 -1
- package/dist/cjs/q2-loading-element.cjs.entry.js +1 -1
- package/dist/cjs/q2-loc.cjs.entry.js +1 -1
- package/dist/cjs/q2-message.cjs.entry.js +1 -1
- package/dist/cjs/q2-month-picker.cjs.entry.js +1 -1
- package/dist/cjs/q2-optgroup_2.cjs.entry.js +93 -0
- package/dist/cjs/q2-option-list_2.cjs.entry.js +230 -88
- package/dist/cjs/q2-pagination.cjs.entry.js +1 -1
- package/dist/cjs/q2-pill.cjs.entry.js +57 -18
- package/dist/cjs/q2-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/q2-radio.cjs.entry.js +1 -1
- package/dist/cjs/q2-section.cjs.entry.js +1 -1
- package/dist/cjs/q2-select.cjs.entry.js +149 -409
- package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper-vertical.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper.cjs.entry.js +1 -1
- package/dist/cjs/q2-tab-container.cjs.entry.js +1 -1
- package/dist/cjs/q2-tag.cjs.entry.js +21 -6
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/cjs/q2-textarea.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/q2-action-sheet/index.js +345 -0
- package/dist/collection/components/q2-action-sheet/styles.css +215 -0
- package/dist/collection/components/q2-card/index.js +1 -1
- package/dist/collection/components/q2-chart-area/index.js +622 -0
- package/dist/collection/components/q2-chart-area/styles.css +82 -0
- package/dist/collection/components/q2-chart-bar/index.js +4 -4
- package/dist/collection/components/q2-chart-bar/styles.css +3 -6
- package/dist/collection/components/q2-chart-donut/index.js +1 -1
- package/dist/collection/components/q2-checkbox/index.js +2 -2
- package/dist/collection/components/q2-checkbox/styles.css +1 -0
- package/dist/collection/components/q2-dropdown/index.js +1 -1
- package/dist/collection/components/q2-loading/index.js +1 -1
- package/dist/collection/components/q2-loading/skeleton/q2-loading-element/styles.css +4 -0
- package/dist/collection/components/q2-loading/styles.css +4 -0
- package/dist/collection/components/q2-optgroup/styles.css +2 -2
- package/dist/collection/components/q2-option/index.js +1 -56
- package/dist/collection/components/q2-option/styles.css +7 -0
- package/dist/collection/components/q2-option-list/index.js +290 -102
- package/dist/collection/components/q2-pill/index.js +79 -18
- package/dist/collection/components/q2-pill/styles.css +1 -2
- package/dist/collection/components/q2-popover/index.js +21 -5
- package/dist/collection/components/q2-popover/styles.css +10 -67
- package/dist/collection/components/q2-radio/index.js +2 -2
- package/dist/collection/components/q2-select/index.js +197 -427
- package/dist/collection/components/q2-select/styles.css +5 -11
- package/dist/collection/components/q2-tag/index.js +38 -5
- package/dist/collection/utils/action-sheet.js +79 -0
- package/dist/collection/utils/index.js +31 -7
- package/dist/components/action-sheet.js +81 -0
- package/dist/components/charting.js +3113 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index10.js +1 -1
- package/dist/components/index11.js +42 -353
- package/dist/components/index12.js +44 -97
- package/dist/components/index13.js +495 -580
- package/dist/components/index14.js +137 -0
- package/dist/components/index15.js +626 -0
- package/dist/components/index5.js +1 -1
- package/dist/components/index6.js +1 -1
- package/dist/components/index7.js +1 -1
- package/dist/components/index8.js +1 -1
- package/dist/components/index9.js +3 -3
- package/dist/components/installCanvasRenderer.js +188 -1123
- package/dist/components/installLabelLayout.js +1042 -0
- package/dist/components/q2-action-sheet.d.ts +11 -0
- package/dist/components/q2-action-sheet.js +282 -0
- package/dist/components/q2-calendar.js +1 -1
- package/dist/components/q2-card.js +2 -2
- package/dist/components/q2-carousel-pane.js +1 -1
- package/dist/components/q2-carousel.js +1 -1
- package/dist/components/q2-chart-area.d.ts +11 -0
- package/dist/components/q2-chart-area.js +4604 -0
- package/dist/components/q2-chart-bar.js +11 -3119
- package/dist/components/q2-chart-donut.js +4 -3
- package/dist/components/q2-checkbox-group.js +1 -1
- package/dist/components/q2-checkbox.js +2 -2
- package/dist/components/q2-dropdown.js +2 -2
- package/dist/components/q2-editable-field.js +1 -1
- package/dist/components/q2-loading-element.js +1 -1
- package/dist/components/q2-loc.js +1 -1
- package/dist/components/q2-month-picker.js +1 -1
- package/dist/components/q2-optgroup.js +1 -70
- package/dist/components/q2-option-list.js +1 -1
- package/dist/components/q2-option.js +1 -76
- package/dist/components/q2-pagination.js +1 -1
- package/dist/components/q2-pill.js +62 -21
- package/dist/components/q2-popover.js +1 -1
- package/dist/components/q2-radio-group.js +1 -1
- package/dist/components/q2-radio.js +3 -3
- package/dist/components/q2-section.js +1 -1
- package/dist/components/q2-select.js +181 -427
- package/dist/components/q2-stepper-pane.js +1 -1
- package/dist/components/q2-stepper-vertical.js +1 -1
- package/dist/components/q2-stepper.js +1 -1
- package/dist/components/q2-tab-container.js +1 -1
- package/dist/components/q2-tag.js +24 -8
- package/dist/components/q2-textarea.js +1 -1
- package/dist/esm/action-sheet-a9597b32.js +81 -0
- package/dist/esm/charting-2a73ba8e.js +3113 -0
- package/dist/esm/{index-9c591682.js → index-ca21e539.js} +32 -8
- package/dist/esm/{installCanvasRenderer-0143b52d.js → installCanvasRenderer-4a470516.js} +188 -1123
- package/dist/esm/installLabelLayout-d660eaad.js +1042 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-action-sheet.entry.js +214 -0
- package/dist/esm/q2-badge_2.entry.js +1 -1
- package/dist/esm/q2-btn_2.entry.js +2 -2
- package/dist/esm/q2-calendar.entry.js +1 -1
- package/dist/esm/q2-card.entry.js +2 -2
- package/dist/esm/q2-carousel-pane.entry.js +1 -1
- package/dist/esm/q2-carousel.entry.js +1 -1
- package/dist/esm/q2-chart-area.entry.js +4565 -0
- package/dist/esm/q2-chart-bar.entry.js +11 -3119
- package/dist/esm/q2-chart-donut.entry.js +4 -3
- package/dist/esm/q2-checkbox-group.entry.js +1 -1
- package/dist/esm/q2-checkbox.entry.js +2 -2
- package/dist/esm/q2-dropdown-item.entry.js +1 -1
- package/dist/esm/q2-dropdown.entry.js +1 -1
- package/dist/esm/q2-editable-field.entry.js +1 -1
- package/dist/esm/q2-icon.entry.js +1 -1
- package/dist/esm/q2-loading-element.entry.js +1 -1
- package/dist/esm/q2-loc.entry.js +1 -1
- package/dist/esm/q2-message.entry.js +1 -1
- package/dist/esm/q2-month-picker.entry.js +1 -1
- package/dist/esm/q2-optgroup_2.entry.js +88 -0
- package/dist/esm/q2-option-list_2.entry.js +230 -88
- package/dist/esm/q2-pagination.entry.js +1 -1
- package/dist/esm/q2-pill.entry.js +57 -18
- package/dist/esm/q2-radio-group.entry.js +1 -1
- package/dist/esm/q2-radio.entry.js +1 -1
- package/dist/esm/q2-section.entry.js +1 -1
- package/dist/esm/q2-select.entry.js +149 -409
- package/dist/esm/q2-stepper-pane.entry.js +1 -1
- package/dist/esm/q2-stepper-vertical.entry.js +1 -1
- package/dist/esm/q2-stepper.entry.js +1 -1
- package/dist/esm/q2-tab-container.entry.js +1 -1
- package/dist/esm/q2-tag.entry.js +21 -6
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/esm/q2-textarea.entry.js +1 -1
- package/dist/q2-tecton-elements/{p-db873db2.entry.js → p-0473f4f7.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-520c40f6.entry.js → p-13a1390b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-9ebb283a.entry.js → p-13deb3ed.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-0ba564b1.entry.js → p-1d854203.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-1f71774f.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-18cc4758.entry.js → p-256d3fe6.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-9281adaa.entry.js → p-282f0f8c.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-2d2c5af2.entry.js → p-30969629.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-30cd888b.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-fc134a5d.entry.js → p-37cf9c97.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-fb37e67e.entry.js → p-388349b5.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-458b1987.js +1 -0
- package/dist/q2-tecton-elements/p-52063431.js +39 -0
- package/dist/q2-tecton-elements/p-5589ae0f.entry.js +1 -0
- package/dist/q2-tecton-elements/p-619aed74.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-4625184b.entry.js → p-63b67260.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-e4dc9ac0.entry.js → p-63e363ad.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-cbd1289a.entry.js → p-6736df05.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-72fe10cc.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-c4640b55.entry.js → p-75b817c6.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-c3f27fe2.entry.js → p-7a116095.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-7c94119b.entry.js +1 -0
- package/dist/q2-tecton-elements/p-833398d1.js +1 -0
- package/dist/q2-tecton-elements/{p-ce015552.entry.js → p-90572e43.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-91153c61.entry.js +1 -0
- package/dist/q2-tecton-elements/p-9792de8a.entry.js +1 -0
- package/dist/q2-tecton-elements/p-9acfa94e.js +1 -0
- package/dist/q2-tecton-elements/p-a1926e65.js +1 -0
- package/dist/q2-tecton-elements/{p-ffb48ccc.entry.js → p-b3a8cdc5.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-ce3f203c.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-041b3a82.entry.js → p-ce91cd9b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-b8b00394.entry.js → p-cefc9d0b.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-d05beeb7.entry.js +1 -0
- package/dist/q2-tecton-elements/p-dc7c8371.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-16c11d74.entry.js → p-e58581fc.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-f800fd1e.entry.js → p-e886c55b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-6e6b5b80.entry.js → p-f0ec4d2c.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-97aa8423.entry.js → p-f94e7043.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-c444a60b.entry.js → p-fcb7d191.entry.js} +1 -1
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/test/helpers.js +3 -2
- package/dist/types/components/q2-action-sheet/index.d.ts +52 -0
- package/dist/types/components/q2-card/index.d.ts +1 -1
- package/dist/types/components/q2-chart-area/index.d.ts +40 -0
- package/dist/types/components/q2-chart-bar/index.d.ts +2 -2
- package/dist/types/components/q2-chart-donut/index.d.ts +1 -1
- package/dist/types/components/q2-checkbox/index.d.ts +4 -1
- package/dist/types/components/q2-option/index.d.ts +0 -3
- package/dist/types/components/q2-option-list/index.d.ts +16 -8
- package/dist/types/components/q2-pill/index.d.ts +10 -1
- package/dist/types/components/q2-popover/index.d.ts +2 -0
- package/dist/types/components/q2-select/index.d.ts +46 -47
- package/dist/types/components/q2-tag/index.d.ts +3 -2
- package/dist/types/components.d.ts +100 -13
- package/dist/types/global.d.ts +10 -1
- package/dist/types/utils/action-sheet.d.ts +12 -0
- package/dist/types/utils/index.d.ts +3 -1
- package/dist/types/workspace/workspace/{_production_release_1.22.x-alpha → Tecton_tecton-production_master}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +1 -1
- package/package.json +3 -2
- package/dist/cjs/q2-optgroup.cjs.entry.js +0 -56
- package/dist/cjs/q2-option.cjs.entry.js +0 -46
- package/dist/esm/q2-optgroup.entry.js +0 -52
- package/dist/esm/q2-option.entry.js +0 -42
- package/dist/q2-tecton-elements/p-0d8dd75a.entry.js +0 -1
- package/dist/q2-tecton-elements/p-0fad9c5a.entry.js +0 -1
- package/dist/q2-tecton-elements/p-1f85cced.js +0 -39
- package/dist/q2-tecton-elements/p-2c9b1308.entry.js +0 -1
- package/dist/q2-tecton-elements/p-5e374fbd.js +0 -1
- package/dist/q2-tecton-elements/p-6b52a262.entry.js +0 -1
- package/dist/q2-tecton-elements/p-aaf42539.entry.js +0 -1
- package/dist/q2-tecton-elements/p-cf41970f.entry.js +0 -1
- package/dist/q2-tecton-elements/p-de164483.entry.js +0 -1
- package/dist/q2-tecton-elements/p-e6d26f39.entry.js +0 -1
- package/dist/q2-tecton-elements/p-f1d06917.entry.js +0 -1
- package/dist/q2-tecton-elements/p-f35bf6a3.entry.js +0 -1
|
@@ -1,58 +1,136 @@
|
|
|
1
1
|
import { h, Host, } from '@stencil/core';
|
|
2
|
-
import { isEventFromElement, overrideFocus } from 'src/utils';
|
|
2
|
+
import { isEventFromElement, nextPaint, overrideFocus } from 'src/utils';
|
|
3
3
|
export class Q2OptionList {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.scheduledAfterRender = [];
|
|
6
6
|
/// Event Handlers ///
|
|
7
7
|
/* tslint:disable:cyclomatic-complexity */
|
|
8
|
-
this.
|
|
8
|
+
this.externalKeydownHandler = (event) => {
|
|
9
|
+
event.stopPropagation();
|
|
10
|
+
const { activeIndex, customSearch, allOptions } = this;
|
|
11
|
+
const { key } = event;
|
|
12
|
+
let nextIndex;
|
|
13
|
+
switch (key) {
|
|
14
|
+
case ' ':
|
|
15
|
+
if (this.searchString) {
|
|
16
|
+
if (customSearch)
|
|
17
|
+
break;
|
|
18
|
+
this.searchOptions(key, true);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
this.setDefaultActiveElement();
|
|
22
|
+
break;
|
|
23
|
+
case 'Enter':
|
|
24
|
+
this.setDefaultActiveElement();
|
|
25
|
+
break;
|
|
26
|
+
case 'ArrowUp':
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
this.activeIndex = 0;
|
|
29
|
+
nextIndex = !!this.selectedOptions.length ? this.getDefaultActiveIndex() : this.getNextVisibleIndex(-1);
|
|
30
|
+
if (nextIndex === -1)
|
|
31
|
+
break;
|
|
32
|
+
this.openDropdownWithActiveElement(nextIndex);
|
|
33
|
+
break;
|
|
34
|
+
case 'ArrowDown':
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
this.activeIndex = 0;
|
|
37
|
+
nextIndex = !!this.selectedOptions.length ? this.getDefaultActiveIndex() : this.getNextVisibleIndex(0);
|
|
38
|
+
if (nextIndex === -1)
|
|
39
|
+
break;
|
|
40
|
+
this.openDropdownWithActiveElement(nextIndex);
|
|
41
|
+
break;
|
|
42
|
+
case 'Home':
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
this.openDropdownWithActiveElement(0);
|
|
45
|
+
break;
|
|
46
|
+
case 'End':
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
this.openDropdownWithActiveElement(allOptions.length - 1);
|
|
49
|
+
break;
|
|
50
|
+
case 'PageUp':
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
this.openDropdownWithActiveElement(Math.max((activeIndex || 0) - 10, 0));
|
|
53
|
+
break;
|
|
54
|
+
case 'PageDown':
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
this.openDropdownWithActiveElement(Math.min((activeIndex || 0) + 10, allOptions.length - 1));
|
|
57
|
+
break;
|
|
58
|
+
case 'Tab':
|
|
59
|
+
this.popoverState.emit({ open: false, action: 'close' });
|
|
60
|
+
break;
|
|
61
|
+
case 'Esc':
|
|
62
|
+
case 'Escape':
|
|
63
|
+
if (this.noSelect)
|
|
64
|
+
this.setActiveElement(null);
|
|
65
|
+
this.popoverState.emit({ open: false, action: 'close' });
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
if (customSearch)
|
|
69
|
+
break;
|
|
70
|
+
if (!key.match(/^[\w]$/))
|
|
71
|
+
break;
|
|
72
|
+
this.searchOptions(key, true);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
this.internalKeydownHandler = (event) => {
|
|
9
77
|
event.stopPropagation();
|
|
10
78
|
const { activeIndex, customSearch, allOptions } = this;
|
|
11
79
|
const { key, shiftKey } = event;
|
|
12
80
|
let newOption;
|
|
13
81
|
switch (key) {
|
|
14
82
|
case ' ':
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
83
|
+
if (this.searchString) {
|
|
84
|
+
if (customSearch)
|
|
85
|
+
break;
|
|
86
|
+
this.searchOptions(key, false);
|
|
18
87
|
break;
|
|
19
88
|
}
|
|
20
89
|
event.preventDefault();
|
|
21
90
|
newOption = allOptions.find(element => element.active);
|
|
22
91
|
if (!newOption || newOption.disabled)
|
|
23
92
|
break;
|
|
24
|
-
this.selectOption(newOption
|
|
93
|
+
this.selectOption(newOption);
|
|
94
|
+
break;
|
|
95
|
+
case 'Enter':
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
newOption = allOptions.find(element => element.active);
|
|
98
|
+
if (!newOption || newOption.disabled)
|
|
99
|
+
break;
|
|
100
|
+
this.selectOption(newOption);
|
|
25
101
|
break;
|
|
26
102
|
case 'ArrowUp':
|
|
27
103
|
event.preventDefault();
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
104
|
+
const isFirstOptionActive = activeIndex === 0;
|
|
105
|
+
if (isFirstOptionActive)
|
|
30
106
|
break;
|
|
31
107
|
if (activeIndex === undefined) {
|
|
32
108
|
this.setDefaultActiveElement();
|
|
109
|
+
break;
|
|
33
110
|
}
|
|
34
111
|
else {
|
|
35
112
|
const nextIndex = this.getNextVisibleIndex(-1);
|
|
36
113
|
if (nextIndex === -1)
|
|
37
114
|
break;
|
|
38
115
|
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
116
|
+
break;
|
|
39
117
|
}
|
|
40
|
-
break;
|
|
41
118
|
case 'ArrowDown':
|
|
42
119
|
event.preventDefault();
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
120
|
+
const isLastOptionActive = activeIndex === allOptions.length - 1;
|
|
121
|
+
if (isLastOptionActive)
|
|
45
122
|
break;
|
|
46
123
|
if (activeIndex === undefined) {
|
|
47
124
|
this.setDefaultActiveElement();
|
|
125
|
+
break;
|
|
48
126
|
}
|
|
49
127
|
else {
|
|
50
128
|
const nextIndex = this.getNextVisibleIndex(1);
|
|
51
129
|
if (nextIndex === -1)
|
|
52
130
|
break;
|
|
53
131
|
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
132
|
+
break;
|
|
54
133
|
}
|
|
55
|
-
break;
|
|
56
134
|
case 'Home':
|
|
57
135
|
event.preventDefault();
|
|
58
136
|
this.openDropdownWithActiveElement(0);
|
|
@@ -70,28 +148,25 @@ export class Q2OptionList {
|
|
|
70
148
|
this.openDropdownWithActiveElement(Math.min(activeIndex + 10, allOptions.length - 1));
|
|
71
149
|
break;
|
|
72
150
|
case 'Tab':
|
|
73
|
-
if (ignoreSelectionEvents)
|
|
74
|
-
break;
|
|
75
151
|
if (shiftKey)
|
|
76
152
|
break;
|
|
77
153
|
newOption = allOptions.find(element => element.active);
|
|
78
154
|
if (!newOption || newOption.disabled)
|
|
79
155
|
return;
|
|
80
|
-
this.selectOption(newOption
|
|
156
|
+
this.selectOption(newOption);
|
|
81
157
|
break;
|
|
82
158
|
case 'Esc':
|
|
83
159
|
case 'Escape':
|
|
84
160
|
if (this.noSelect)
|
|
85
161
|
this.setActiveElement(null);
|
|
86
|
-
this.popoverState.emit({ open: false });
|
|
162
|
+
this.popoverState.emit({ open: false, action: 'close' });
|
|
87
163
|
break;
|
|
88
164
|
default:
|
|
89
165
|
if (customSearch)
|
|
90
166
|
break;
|
|
91
|
-
if (!key.match(/^[
|
|
167
|
+
if (!key.match(/^[\w]$/))
|
|
92
168
|
break;
|
|
93
|
-
|
|
94
|
-
this.searchAndFocus(key);
|
|
169
|
+
this.searchOptions(key, false);
|
|
95
170
|
break;
|
|
96
171
|
}
|
|
97
172
|
};
|
|
@@ -106,19 +181,17 @@ export class Q2OptionList {
|
|
|
106
181
|
};
|
|
107
182
|
this.clickHandler = (event) => {
|
|
108
183
|
const target = event.target;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
this.selectOption(target.value);
|
|
184
|
+
const option = target.closest('q2-option');
|
|
185
|
+
this.selectOption(option);
|
|
113
186
|
};
|
|
114
187
|
this.role = 'listbox';
|
|
115
|
-
this.direction = 'down';
|
|
116
188
|
this.customSearch = undefined;
|
|
117
189
|
this.noSelect = undefined;
|
|
118
190
|
this.align = undefined;
|
|
119
191
|
this.selectedOptions = [];
|
|
120
192
|
this.multiple = undefined;
|
|
121
193
|
this.disabled = undefined;
|
|
194
|
+
this.showSelected = undefined;
|
|
122
195
|
this.type = undefined;
|
|
123
196
|
this.hasOptions = undefined;
|
|
124
197
|
}
|
|
@@ -130,26 +203,47 @@ export class Q2OptionList {
|
|
|
130
203
|
overrideFocus(this.hostElement);
|
|
131
204
|
this.checkOptions();
|
|
132
205
|
this.selectedOptionsUpdated();
|
|
206
|
+
this.ready.emit();
|
|
133
207
|
}
|
|
134
208
|
componentDidRender() {
|
|
135
209
|
this.scheduledAfterRender.forEach(fn => fn());
|
|
136
210
|
this.scheduledAfterRender = [];
|
|
137
211
|
}
|
|
138
212
|
/// Getters ///
|
|
213
|
+
get allContents() {
|
|
214
|
+
const rootSlot = this.getRootSlot(this.hostElement);
|
|
215
|
+
const acceptedTags = ['Q2-OPTGROUP', 'Q2-OPTION'];
|
|
216
|
+
return rootSlot.filter(element => acceptedTags.includes(element.tagName));
|
|
217
|
+
}
|
|
139
218
|
get allOptions() {
|
|
140
|
-
|
|
219
|
+
const contents = this.allContents;
|
|
220
|
+
const extractOptions = (elements) => {
|
|
221
|
+
return elements.reduce((acc, element) => {
|
|
222
|
+
if (element.tagName === 'Q2-OPTGROUP') {
|
|
223
|
+
return [...acc, ...extractOptions(Array.from(element.children))];
|
|
224
|
+
}
|
|
225
|
+
else if (element.tagName === 'Q2-OPTION') {
|
|
226
|
+
return [...acc, element];
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return acc;
|
|
230
|
+
}
|
|
231
|
+
}, []);
|
|
232
|
+
};
|
|
233
|
+
return extractOptions(contents);
|
|
234
|
+
}
|
|
235
|
+
get allVisibleOptions() {
|
|
236
|
+
return this.allOptions.filter(option => !option.hidden && !option._multiSelectHidden && !option.disabled && !option.disabledGroup);
|
|
141
237
|
}
|
|
142
238
|
/// Helpers ///
|
|
143
|
-
checkOptions() {
|
|
144
|
-
const {
|
|
145
|
-
|
|
239
|
+
async checkOptions() {
|
|
240
|
+
const { type } = this;
|
|
241
|
+
const options = await this.getOptions();
|
|
242
|
+
if (!type)
|
|
146
243
|
return;
|
|
147
244
|
const optionRole = type === 'menu' ? 'menuitem' : 'option';
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
option.noSelect = true;
|
|
151
|
-
if (type)
|
|
152
|
-
option.role = optionRole;
|
|
245
|
+
options.forEach(option => {
|
|
246
|
+
option.role = optionRole;
|
|
153
247
|
});
|
|
154
248
|
}
|
|
155
249
|
getRootSlot(element) {
|
|
@@ -168,20 +262,15 @@ export class Q2OptionList {
|
|
|
168
262
|
const activeOption = this.allOptions[this.activeIndex];
|
|
169
263
|
activeOption === null || activeOption === void 0 ? void 0 : activeOption.scrollIntoView({ block: 'nearest' });
|
|
170
264
|
}
|
|
171
|
-
resizeIframe() {
|
|
172
|
-
var _a, _b;
|
|
173
|
-
return (_b = (_a = window.TectonElements) === null || _a === void 0 ? void 0 : _a.resizeIframe) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
174
|
-
}
|
|
175
265
|
openDropdownWithActiveElement(activeIndex) {
|
|
176
266
|
if (this.disabled)
|
|
177
267
|
return;
|
|
178
268
|
this.activeIndex = activeIndex;
|
|
179
|
-
this.popoverState.emit({ open: true });
|
|
269
|
+
this.popoverState.emit({ open: true, action: 'open' });
|
|
180
270
|
this.setActiveOption();
|
|
181
271
|
this.setFocusedOption();
|
|
182
|
-
|
|
272
|
+
nextPaint(() => {
|
|
183
273
|
this.scrollToActiveOption();
|
|
184
|
-
this.resizeIframe();
|
|
185
274
|
});
|
|
186
275
|
}
|
|
187
276
|
getDefaultActiveIndex() {
|
|
@@ -195,16 +284,16 @@ export class Q2OptionList {
|
|
|
195
284
|
return 0;
|
|
196
285
|
}
|
|
197
286
|
updateSingleOptionAttrs() {
|
|
198
|
-
var _a
|
|
287
|
+
var _a;
|
|
199
288
|
const { allOptions, selectedOptions } = this;
|
|
200
|
-
const
|
|
289
|
+
const selectedValue = ((_a = selectedOptions[0]) === null || _a === void 0 ? void 0 : _a.value) || undefined;
|
|
201
290
|
allOptions.forEach(element => {
|
|
202
|
-
element.selected = element.value ===
|
|
291
|
+
element.selected = element.value === selectedValue;
|
|
203
292
|
});
|
|
204
293
|
}
|
|
205
294
|
updateMultipleOptionAttrs() {
|
|
206
295
|
const { allOptions, selectedOptions } = this;
|
|
207
|
-
const selectedValues = selectedOptions.map(
|
|
296
|
+
const selectedValues = selectedOptions.map(({ value }) => value);
|
|
208
297
|
allOptions.forEach(element => {
|
|
209
298
|
element.selected = selectedValues.includes(element.value);
|
|
210
299
|
});
|
|
@@ -219,38 +308,66 @@ export class Q2OptionList {
|
|
|
219
308
|
const option = this.allOptions[this.activeIndex];
|
|
220
309
|
if (!option)
|
|
221
310
|
return;
|
|
222
|
-
|
|
311
|
+
const isHostElementVisible = !!this.hostElement.offsetParent;
|
|
312
|
+
if (isHostElementVisible)
|
|
223
313
|
option.focus();
|
|
224
|
-
|
|
314
|
+
else
|
|
315
|
+
nextPaint(() => option.focus());
|
|
225
316
|
}
|
|
226
317
|
getNextVisibleIndex(direction) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
index = index + direction;
|
|
318
|
+
const { allVisibleOptions, allOptions, activeIndex } = this;
|
|
319
|
+
const activeOption = allOptions[activeIndex];
|
|
320
|
+
const visibleActiveOptionIndex = allVisibleOptions.indexOf(activeOption);
|
|
321
|
+
let nextVisibleOptionIndex = visibleActiveOptionIndex + direction;
|
|
322
|
+
if (nextVisibleOptionIndex < 0) {
|
|
323
|
+
nextVisibleOptionIndex = allVisibleOptions.length - 1;
|
|
234
324
|
}
|
|
235
|
-
|
|
325
|
+
else if (nextVisibleOptionIndex > allVisibleOptions.length - 1) {
|
|
326
|
+
nextVisibleOptionIndex = 0;
|
|
327
|
+
}
|
|
328
|
+
const nextVisibleOption = allVisibleOptions[nextVisibleOptionIndex];
|
|
329
|
+
return allOptions.indexOf(nextVisibleOption);
|
|
330
|
+
}
|
|
331
|
+
focusSelectedSibling(option) {
|
|
332
|
+
const { allVisibleOptions, allOptions } = this;
|
|
333
|
+
const hasNoSiblings = allVisibleOptions.length < 2;
|
|
334
|
+
if (hasNoSiblings) {
|
|
335
|
+
this.showSelected = false;
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const selectedOptionVisibleIndex = allVisibleOptions.indexOf(option);
|
|
339
|
+
const nextVisibleSiblingIndex = selectedOptionVisibleIndex
|
|
340
|
+
? selectedOptionVisibleIndex - 1
|
|
341
|
+
: selectedOptionVisibleIndex + 1;
|
|
342
|
+
const nextVisibleSibling = allVisibleOptions[nextVisibleSiblingIndex];
|
|
343
|
+
const nextSiblingIndex = allOptions.indexOf(nextVisibleSibling);
|
|
344
|
+
this.activeIndex = nextSiblingIndex;
|
|
345
|
+
this.setFocusedOption();
|
|
346
|
+
this.scheduledAfterRender.push(() => {
|
|
347
|
+
option._multiSelectHidden = !option.selected;
|
|
348
|
+
});
|
|
236
349
|
}
|
|
237
|
-
selectOption(
|
|
238
|
-
const
|
|
350
|
+
selectOption(selectedOption) {
|
|
351
|
+
const { multiple, noSelect, showSelected } = this;
|
|
352
|
+
if (!selectedOption || selectedOption.disabled || selectedOption.disabledGroup)
|
|
353
|
+
return;
|
|
354
|
+
const selectedValue = selectedOption.value;
|
|
239
355
|
const valueObject = {
|
|
240
356
|
value: selectedValue,
|
|
241
|
-
display:
|
|
357
|
+
display: selectedOption.display || selectedOption.innerText.trim(),
|
|
242
358
|
};
|
|
243
|
-
|
|
244
|
-
let values;
|
|
359
|
+
let values = [];
|
|
245
360
|
if (multiple) {
|
|
246
|
-
const { selectedOptions
|
|
247
|
-
const isAlreadySelected =
|
|
361
|
+
const { selectedOptions } = this;
|
|
362
|
+
const isAlreadySelected = selectedOptions.find(option => option.value === selectedValue);
|
|
248
363
|
if (isAlreadySelected) {
|
|
249
364
|
values = selectedOptions.filter(({ value }) => value !== selectedValue);
|
|
250
365
|
}
|
|
251
366
|
else {
|
|
252
367
|
values = [...selectedOptions, valueObject];
|
|
253
368
|
}
|
|
369
|
+
if (showSelected)
|
|
370
|
+
this.focusSelectedSibling(selectedOption);
|
|
254
371
|
}
|
|
255
372
|
else {
|
|
256
373
|
values = [valueObject];
|
|
@@ -262,7 +379,7 @@ export class Q2OptionList {
|
|
|
262
379
|
this.change.emit({ value: selectedValue, values });
|
|
263
380
|
if (multiple)
|
|
264
381
|
return;
|
|
265
|
-
this.popoverState.emit({ open: false });
|
|
382
|
+
this.popoverState.emit({ open: false, action: 'select' });
|
|
266
383
|
}
|
|
267
384
|
adjustActiveOptionAndScroll(numToAdd) {
|
|
268
385
|
this.activeIndex += numToAdd;
|
|
@@ -278,18 +395,29 @@ export class Q2OptionList {
|
|
|
278
395
|
this.searchString = null;
|
|
279
396
|
}, 2000);
|
|
280
397
|
}
|
|
281
|
-
|
|
398
|
+
searchOptions(key, shouldSelect) {
|
|
282
399
|
this.resetTimer();
|
|
283
400
|
let searchString = this.searchString ? `${this.searchString}${key}` : key;
|
|
284
|
-
searchString = searchString.replace(/[
|
|
401
|
+
searchString = searchString.replace(/[^\w\s]/gi, '');
|
|
285
402
|
this.searchString = searchString;
|
|
286
|
-
const searchRegEx = new RegExp(searchString
|
|
287
|
-
const
|
|
403
|
+
const searchRegEx = new RegExp(`^${searchString}`, 'i');
|
|
404
|
+
const { allOptions } = this;
|
|
405
|
+
const foundIndex = allOptions.findIndex(option => option.value === searchString || option.textContent.trim().match(searchRegEx));
|
|
288
406
|
if (foundIndex === -1)
|
|
289
407
|
return;
|
|
290
|
-
|
|
408
|
+
if (shouldSelect)
|
|
409
|
+
this.selectOption(this.allOptions[foundIndex]);
|
|
410
|
+
else
|
|
411
|
+
this.setActiveElement(foundIndex);
|
|
291
412
|
}
|
|
292
413
|
/// Watchers ///
|
|
414
|
+
showSelectedUpdated(showSelected) {
|
|
415
|
+
if (showSelected && this.selectedOptions.length === 0) {
|
|
416
|
+
this.showSelected = false;
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
this.allOptions.forEach(option => (option._multiSelectHidden = showSelected ? !option.selected : false));
|
|
420
|
+
}
|
|
293
421
|
selectedOptionsUpdated() {
|
|
294
422
|
if (this.multiple) {
|
|
295
423
|
this.updateMultipleOptionAttrs();
|
|
@@ -302,8 +430,15 @@ export class Q2OptionList {
|
|
|
302
430
|
delegateFocus(event) {
|
|
303
431
|
if (!isEventFromElement(event, this.hostElement))
|
|
304
432
|
return;
|
|
305
|
-
this.popoverState.emit({ open: true });
|
|
306
|
-
this
|
|
433
|
+
this.popoverState.emit({ open: true, action: 'open' });
|
|
434
|
+
const { activeIndex } = this;
|
|
435
|
+
if (typeof activeIndex === 'number' && activeIndex > -1) {
|
|
436
|
+
this.setActiveOption();
|
|
437
|
+
this.setFocusedOption();
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
this.setDefaultActiveElement();
|
|
441
|
+
}
|
|
307
442
|
}
|
|
308
443
|
handleClick(event) {
|
|
309
444
|
event.stopPropagation();
|
|
@@ -320,22 +455,17 @@ export class Q2OptionList {
|
|
|
320
455
|
this.setFocusedOption();
|
|
321
456
|
}
|
|
322
457
|
async handleExternalKeydown(event) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
this.setDefaultActiveElement();
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
333
|
-
this.keydownHandler(event, true);
|
|
334
|
-
}
|
|
458
|
+
this.externalKeydownHandler(event);
|
|
459
|
+
}
|
|
460
|
+
async getContents() {
|
|
461
|
+
return this.allContents;
|
|
462
|
+
}
|
|
463
|
+
async getOptions() {
|
|
464
|
+
return this.allOptions;
|
|
335
465
|
}
|
|
336
466
|
/// DOM ///
|
|
337
467
|
render() {
|
|
338
|
-
return (h(Host, null, h("div", { class: "content", ref: el => (this.contentElement = el), onFocusout: this.focusoutHandler }, h("div", { class: "options", role: this.type || 'listbox', onKeyDown: this.
|
|
468
|
+
return (h(Host, null, h("div", { class: "content", ref: el => (this.contentElement = el), onFocusout: this.focusoutHandler }, h("div", { class: "options", role: this.type || 'listbox', onKeyDown: this.internalKeydownHandler, onClick: this.clickHandler }, h("slot", null)))));
|
|
339
469
|
}
|
|
340
470
|
static get is() { return "q2-option-list"; }
|
|
341
471
|
static get encapsulation() { return "shadow"; }
|
|
@@ -369,24 +499,6 @@ export class Q2OptionList {
|
|
|
369
499
|
"reflect": true,
|
|
370
500
|
"defaultValue": "'listbox'"
|
|
371
501
|
},
|
|
372
|
-
"direction": {
|
|
373
|
-
"type": "string",
|
|
374
|
-
"mutable": false,
|
|
375
|
-
"complexType": {
|
|
376
|
-
"original": "'up' | 'down'",
|
|
377
|
-
"resolved": "\"down\" | \"up\"",
|
|
378
|
-
"references": {}
|
|
379
|
-
},
|
|
380
|
-
"required": false,
|
|
381
|
-
"optional": false,
|
|
382
|
-
"docs": {
|
|
383
|
-
"tags": [],
|
|
384
|
-
"text": ""
|
|
385
|
-
},
|
|
386
|
-
"attribute": "direction",
|
|
387
|
-
"reflect": true,
|
|
388
|
-
"defaultValue": "'down'"
|
|
389
|
-
},
|
|
390
502
|
"customSearch": {
|
|
391
503
|
"type": "boolean",
|
|
392
504
|
"mutable": false,
|
|
@@ -492,6 +604,23 @@ export class Q2OptionList {
|
|
|
492
604
|
"attribute": "disabled",
|
|
493
605
|
"reflect": true
|
|
494
606
|
},
|
|
607
|
+
"showSelected": {
|
|
608
|
+
"type": "boolean",
|
|
609
|
+
"mutable": true,
|
|
610
|
+
"complexType": {
|
|
611
|
+
"original": "boolean",
|
|
612
|
+
"resolved": "boolean",
|
|
613
|
+
"references": {}
|
|
614
|
+
},
|
|
615
|
+
"required": false,
|
|
616
|
+
"optional": false,
|
|
617
|
+
"docs": {
|
|
618
|
+
"tags": [],
|
|
619
|
+
"text": ""
|
|
620
|
+
},
|
|
621
|
+
"attribute": "show-selected",
|
|
622
|
+
"reflect": true
|
|
623
|
+
},
|
|
495
624
|
"type": {
|
|
496
625
|
"type": "string",
|
|
497
626
|
"mutable": false,
|
|
@@ -547,8 +676,23 @@ export class Q2OptionList {
|
|
|
547
676
|
"text": ""
|
|
548
677
|
},
|
|
549
678
|
"complexType": {
|
|
550
|
-
"original": "{ open: boolean }",
|
|
551
|
-
"resolved": "{ open: boolean; }",
|
|
679
|
+
"original": "{ open: boolean; action: 'close' | 'select' | 'open' }",
|
|
680
|
+
"resolved": "{ open: boolean; action: \"select\" | \"open\" | \"close\"; }",
|
|
681
|
+
"references": {}
|
|
682
|
+
}
|
|
683
|
+
}, {
|
|
684
|
+
"method": "ready",
|
|
685
|
+
"name": "ready",
|
|
686
|
+
"bubbles": false,
|
|
687
|
+
"cancelable": true,
|
|
688
|
+
"composed": true,
|
|
689
|
+
"docs": {
|
|
690
|
+
"tags": [],
|
|
691
|
+
"text": ""
|
|
692
|
+
},
|
|
693
|
+
"complexType": {
|
|
694
|
+
"original": "any",
|
|
695
|
+
"resolved": "any",
|
|
552
696
|
"references": {}
|
|
553
697
|
}
|
|
554
698
|
}];
|
|
@@ -611,12 +755,56 @@ export class Q2OptionList {
|
|
|
611
755
|
"text": "",
|
|
612
756
|
"tags": []
|
|
613
757
|
}
|
|
758
|
+
},
|
|
759
|
+
"getContents": {
|
|
760
|
+
"complexType": {
|
|
761
|
+
"signature": "() => Promise<(HTMLQ2OptgroupElement | HTMLQ2OptionElement)[]>",
|
|
762
|
+
"parameters": [],
|
|
763
|
+
"references": {
|
|
764
|
+
"Promise": {
|
|
765
|
+
"location": "global"
|
|
766
|
+
},
|
|
767
|
+
"HTMLQ2OptgroupElement": {
|
|
768
|
+
"location": "global"
|
|
769
|
+
},
|
|
770
|
+
"HTMLQ2OptionElement": {
|
|
771
|
+
"location": "global"
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
"return": "Promise<(HTMLQ2OptgroupElement | HTMLQ2OptionElement)[]>"
|
|
775
|
+
},
|
|
776
|
+
"docs": {
|
|
777
|
+
"text": "",
|
|
778
|
+
"tags": []
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
"getOptions": {
|
|
782
|
+
"complexType": {
|
|
783
|
+
"signature": "() => Promise<HTMLQ2OptionElement[]>",
|
|
784
|
+
"parameters": [],
|
|
785
|
+
"references": {
|
|
786
|
+
"Promise": {
|
|
787
|
+
"location": "global"
|
|
788
|
+
},
|
|
789
|
+
"HTMLQ2OptionElement": {
|
|
790
|
+
"location": "global"
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
"return": "Promise<HTMLQ2OptionElement[]>"
|
|
794
|
+
},
|
|
795
|
+
"docs": {
|
|
796
|
+
"text": "",
|
|
797
|
+
"tags": []
|
|
798
|
+
}
|
|
614
799
|
}
|
|
615
800
|
};
|
|
616
801
|
}
|
|
617
802
|
static get elementRef() { return "hostElement"; }
|
|
618
803
|
static get watchers() {
|
|
619
804
|
return [{
|
|
805
|
+
"propName": "showSelected",
|
|
806
|
+
"methodName": "showSelectedUpdated"
|
|
807
|
+
}, {
|
|
620
808
|
"propName": "selectedOptions",
|
|
621
809
|
"methodName": "selectedOptionsUpdated"
|
|
622
810
|
}];
|