@aurelia-ui-toolkits/headless 1.0.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/alert/ui-alert.html +19 -0
- package/dist/alert/ui-alert.js +67 -0
- package/dist/alert/ui-alert.js.map +1 -0
- package/dist/alert-service/alert-configuration.js +11 -0
- package/dist/alert-service/alert-configuration.js.map +1 -0
- package/dist/alert-service/alert-modal/alert-modal.html +12 -0
- package/dist/alert-service/alert-modal/alert-modal.js +31 -0
- package/dist/alert-service/alert-modal/alert-modal.js.map +1 -0
- package/dist/alert-service/alert-modal/i-alert-modal-payload.js +2 -0
- package/dist/alert-service/alert-modal/i-alert-modal-payload.js.map +1 -0
- package/dist/alert-service/alert-service.js +108 -0
- package/dist/alert-service/alert-service.js.map +1 -0
- package/dist/alert-service/decorators/confirm-action.js +14 -0
- package/dist/alert-service/decorators/confirm-action.js.map +1 -0
- package/dist/alert-service/decorators/using-progress.js +23 -0
- package/dist/alert-service/decorators/using-progress.js.map +1 -0
- package/dist/alert-service/exceptions-tracker.js +4 -0
- package/dist/alert-service/exceptions-tracker.js.map +1 -0
- package/dist/alert-service/prompt-dialog/prompt-dialog.html +13 -0
- package/dist/alert-service/prompt-dialog/prompt-dialog.js +39 -0
- package/dist/alert-service/prompt-dialog/prompt-dialog.js.map +1 -0
- package/dist/badge/ui-badge.html +6 -0
- package/dist/badge/ui-badge.js +44 -0
- package/dist/badge/ui-badge.js.map +1 -0
- package/dist/base/boolean-attr.js +4 -0
- package/dist/base/boolean-attr.js.map +1 -0
- package/dist/base/i-validated-element.js +2 -0
- package/dist/base/i-validated-element.js.map +1 -0
- package/dist/base/keys.js +14 -0
- package/dist/base/keys.js.map +1 -0
- package/dist/breadcrumbs/ui-breadcrumbs.html +10 -0
- package/dist/breadcrumbs/ui-breadcrumbs.js +31 -0
- package/dist/breadcrumbs/ui-breadcrumbs.js.map +1 -0
- package/dist/button/enhance-ui-button.js +25 -0
- package/dist/button/enhance-ui-button.js.map +1 -0
- package/dist/button/ui-button.html +20 -0
- package/dist/button/ui-button.js +77 -0
- package/dist/button/ui-button.js.map +1 -0
- package/dist/button/ui-icon-button.html +20 -0
- package/dist/button/ui-icon-button.js +77 -0
- package/dist/button/ui-icon-button.js.map +1 -0
- package/dist/checkbox/ui-checkbox.html +32 -0
- package/dist/checkbox/ui-checkbox.js +186 -0
- package/dist/checkbox/ui-checkbox.js.map +1 -0
- package/dist/chip/ui-chip.html +32 -0
- package/dist/chip/ui-chip.js +129 -0
- package/dist/chip/ui-chip.js.map +1 -0
- package/dist/combobox/enhance-ui-combobox.js +26 -0
- package/dist/combobox/enhance-ui-combobox.js.map +1 -0
- package/dist/combobox/ui-combobox.html +76 -0
- package/dist/combobox/ui-combobox.js +478 -0
- package/dist/combobox/ui-combobox.js.map +1 -0
- package/dist/disclosure/ui-disclosure.html +28 -0
- package/dist/disclosure/ui-disclosure.js +75 -0
- package/dist/disclosure/ui-disclosure.js.map +1 -0
- package/dist/drawer/ui-drawer.html +35 -0
- package/dist/drawer/ui-drawer.js +246 -0
- package/dist/drawer/ui-drawer.js.map +1 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/input/enhance-ui-input.js +26 -0
- package/dist/input/enhance-ui-input.js.map +1 -0
- package/dist/input/ui-input.html +56 -0
- package/dist/input/ui-input.js +259 -0
- package/dist/input/ui-input.js.map +1 -0
- package/dist/list/ui-list-item.html +22 -0
- package/dist/list/ui-list-item.js +59 -0
- package/dist/list/ui-list-item.js.map +1 -0
- package/dist/list/ui-list.html +10 -0
- package/dist/list/ui-list.js +316 -0
- package/dist/list/ui-list.js.map +1 -0
- package/dist/menu/ui-menu.html +20 -0
- package/dist/menu/ui-menu.js +154 -0
- package/dist/menu/ui-menu.js.map +1 -0
- package/dist/popup/ui-popup.html +16 -0
- package/dist/popup/ui-popup.js +397 -0
- package/dist/popup/ui-popup.js.map +1 -0
- package/dist/progress/ui-progress.html +17 -0
- package/dist/progress/ui-progress.js +76 -0
- package/dist/progress/ui-progress.js.map +1 -0
- package/dist/radio/ui-radio-group.html +27 -0
- package/dist/radio/ui-radio-group.js +259 -0
- package/dist/radio/ui-radio-group.js.map +1 -0
- package/dist/radio/ui-radio.html +11 -0
- package/dist/radio/ui-radio.js +55 -0
- package/dist/radio/ui-radio.js.map +1 -0
- package/dist/segmented-control/ui-segment.html +10 -0
- package/dist/segmented-control/ui-segment.js +44 -0
- package/dist/segmented-control/ui-segment.js.map +1 -0
- package/dist/segmented-control/ui-segmented-control.html +9 -0
- package/dist/segmented-control/ui-segmented-control.js +134 -0
- package/dist/segmented-control/ui-segmented-control.js.map +1 -0
- package/dist/select/enhance-ui-select.js +26 -0
- package/dist/select/enhance-ui-select.js.map +1 -0
- package/dist/select/ui-select.html +70 -0
- package/dist/select/ui-select.js +323 -0
- package/dist/select/ui-select.js.map +1 -0
- package/dist/slider/ui-slider.html +69 -0
- package/dist/slider/ui-slider.js +362 -0
- package/dist/slider/ui-slider.js.map +1 -0
- package/dist/splitter/ui-splitter.html +14 -0
- package/dist/splitter/ui-splitter.js +257 -0
- package/dist/splitter/ui-splitter.js.map +1 -0
- package/dist/switch/ui-switch.html +23 -0
- package/dist/switch/ui-switch.js +121 -0
- package/dist/switch/ui-switch.js.map +1 -0
- package/dist/table/enhance-ui-table.js +25 -0
- package/dist/table/enhance-ui-table.js.map +1 -0
- package/dist/table/ui-table-column.html +17 -0
- package/dist/table/ui-table-column.js +127 -0
- package/dist/table/ui-table-column.js.map +1 -0
- package/dist/table/ui-table.html +56 -0
- package/dist/table/ui-table.js +225 -0
- package/dist/table/ui-table.js.map +1 -0
- package/dist/tabs/ui-tab.html +10 -0
- package/dist/tabs/ui-tab.js +52 -0
- package/dist/tabs/ui-tab.js.map +1 -0
- package/dist/tabs/ui-tabs.html +3 -0
- package/dist/tabs/ui-tabs.js +112 -0
- package/dist/tabs/ui-tabs.js.map +1 -0
- package/dist/toast/ui-toast-region.html +11 -0
- package/dist/toast/ui-toast-region.js +38 -0
- package/dist/toast/ui-toast-region.js.map +1 -0
- package/dist/toast/ui-toast-service.js +70 -0
- package/dist/toast/ui-toast-service.js.map +1 -0
- package/dist/tooltip/ui-tooltip-service.js +63 -0
- package/dist/tooltip/ui-tooltip-service.js.map +1 -0
- package/dist/tooltip/ui-tooltip.js +221 -0
- package/dist/tooltip/ui-tooltip.js.map +1 -0
- package/dist/top-app-bar/ui-top-app-bar.html +24 -0
- package/dist/top-app-bar/ui-top-app-bar.js +68 -0
- package/dist/top-app-bar/ui-top-app-bar.js.map +1 -0
- package/dist/tree/ui-tree.html +38 -0
- package/dist/tree/ui-tree.js +340 -0
- package/dist/tree/ui-tree.js.map +1 -0
- package/dist/types/alert/ui-alert.d.ts +11 -0
- package/dist/types/alert-service/alert-configuration.d.ts +8 -0
- package/dist/types/alert-service/alert-modal/alert-modal.d.ts +7 -0
- package/dist/types/alert-service/alert-modal/i-alert-modal-payload.d.ts +14 -0
- package/dist/types/alert-service/alert-service.d.ts +17 -0
- package/dist/types/alert-service/decorators/confirm-action.d.ts +3 -0
- package/dist/types/alert-service/decorators/using-progress.d.ts +6 -0
- package/dist/types/alert-service/exceptions-tracker.d.ts +3 -0
- package/dist/types/alert-service/prompt-dialog/prompt-dialog.d.ts +17 -0
- package/dist/types/badge/ui-badge.d.ts +7 -0
- package/dist/types/base/boolean-attr.d.ts +1 -0
- package/dist/types/base/i-validated-element.d.ts +10 -0
- package/dist/types/base/keys.d.ts +12 -0
- package/dist/types/breadcrumbs/ui-breadcrumbs.d.ts +8 -0
- package/dist/types/button/enhance-ui-button.d.ts +3 -0
- package/dist/types/button/ui-button.d.ts +16 -0
- package/dist/types/button/ui-icon-button.d.ts +18 -0
- package/dist/types/checkbox/ui-checkbox.d.ts +32 -0
- package/dist/types/chip/ui-chip.d.ts +26 -0
- package/dist/types/combobox/enhance-ui-combobox.d.ts +3 -0
- package/dist/types/combobox/ui-combobox.d.ts +79 -0
- package/dist/types/disclosure/ui-disclosure.d.ts +18 -0
- package/dist/types/drawer/ui-drawer.d.ts +38 -0
- package/dist/types/index.d.ts +91 -0
- package/dist/types/input/enhance-ui-input.d.ts +3 -0
- package/dist/types/input/ui-input.d.ts +44 -0
- package/dist/types/list/ui-list-item.d.ts +10 -0
- package/dist/types/list/ui-list.d.ts +45 -0
- package/dist/types/menu/ui-menu.d.ts +29 -0
- package/dist/types/popup/ui-popup.d.ts +61 -0
- package/dist/types/progress/ui-progress.d.ts +15 -0
- package/dist/types/radio/ui-radio-group.d.ts +37 -0
- package/dist/types/radio/ui-radio.d.ts +11 -0
- package/dist/types/segmented-control/ui-segment.d.ts +8 -0
- package/dist/types/segmented-control/ui-segmented-control.d.ts +17 -0
- package/dist/types/select/enhance-ui-select.d.ts +3 -0
- package/dist/types/select/ui-select.d.ts +50 -0
- package/dist/types/slider/ui-slider.d.ts +58 -0
- package/dist/types/splitter/ui-splitter.d.ts +39 -0
- package/dist/types/switch/ui-switch.d.ts +23 -0
- package/dist/types/table/enhance-ui-table.d.ts +3 -0
- package/dist/types/table/ui-table-column.d.ts +22 -0
- package/dist/types/table/ui-table.d.ts +51 -0
- package/dist/types/tabs/ui-tab.d.ts +10 -0
- package/dist/types/tabs/ui-tabs.d.ts +16 -0
- package/dist/types/toast/ui-toast-region.d.ts +6 -0
- package/dist/types/toast/ui-toast-service.d.ts +28 -0
- package/dist/types/tooltip/ui-tooltip-service.d.ts +23 -0
- package/dist/types/tooltip/ui-tooltip.d.ts +35 -0
- package/dist/types/top-app-bar/ui-top-app-bar.d.ts +9 -0
- package/dist/types/tree/ui-tree.d.ts +70 -0
- package/dist/types/validation/ui-validation-controller-factory.d.ts +7 -0
- package/dist/types/validation/ui-validation-result-presenter.d.ts +4 -0
- package/dist/types/validation/validate.d.ts +13 -0
- package/dist/validation/ui-validation-controller-factory.js +17 -0
- package/dist/validation/ui-validation-controller-factory.js.map +1 -0
- package/dist/validation/ui-validation-result-presenter.js +23 -0
- package/dist/validation/ui-validation-result-presenter.js.map +1 -0
- package/dist/validation/validate.js +24 -0
- package/dist/validation/validate.js.map +1 -0
- package/package.json +50 -0
- package/src/alert/ui-alert.html +19 -0
- package/src/alert/ui-alert.ts +33 -0
- package/src/alert-service/alert-configuration.ts +11 -0
- package/src/alert-service/alert-modal/alert-modal.html +12 -0
- package/src/alert-service/alert-modal/alert-modal.ts +19 -0
- package/src/alert-service/alert-modal/i-alert-modal-payload.ts +14 -0
- package/src/alert-service/alert-service.ts +116 -0
- package/src/alert-service/decorators/confirm-action.ts +18 -0
- package/src/alert-service/decorators/using-progress.ts +32 -0
- package/src/alert-service/exceptions-tracker.ts +3 -0
- package/src/alert-service/prompt-dialog/prompt-dialog.html +13 -0
- package/src/alert-service/prompt-dialog/prompt-dialog.ts +37 -0
- package/src/badge/ui-badge.html +6 -0
- package/src/badge/ui-badge.ts +17 -0
- package/src/base/boolean-attr.ts +3 -0
- package/src/base/i-validated-element.ts +11 -0
- package/src/base/keys.ts +12 -0
- package/src/breadcrumbs/ui-breadcrumbs.html +10 -0
- package/src/breadcrumbs/ui-breadcrumbs.ts +14 -0
- package/src/button/enhance-ui-button.ts +9 -0
- package/src/button/ui-button.html +20 -0
- package/src/button/ui-button.ts +60 -0
- package/src/button/ui-icon-button.html +20 -0
- package/src/button/ui-icon-button.ts +62 -0
- package/src/checkbox/ui-checkbox.html +32 -0
- package/src/checkbox/ui-checkbox.ts +188 -0
- package/src/chip/ui-chip.html +32 -0
- package/src/chip/ui-chip.ts +118 -0
- package/src/combobox/enhance-ui-combobox.ts +10 -0
- package/src/combobox/ui-combobox.html +76 -0
- package/src/combobox/ui-combobox.ts +450 -0
- package/src/disclosure/ui-disclosure.html +28 -0
- package/src/disclosure/ui-disclosure.ts +68 -0
- package/src/drawer/ui-drawer.html +35 -0
- package/src/drawer/ui-drawer.ts +219 -0
- package/src/index.ts +152 -0
- package/src/input/enhance-ui-input.ts +10 -0
- package/src/input/ui-input.html +56 -0
- package/src/input/ui-input.ts +225 -0
- package/src/list/ui-list-item.html +22 -0
- package/src/list/ui-list-item.ts +25 -0
- package/src/list/ui-list.html +10 -0
- package/src/list/ui-list.ts +330 -0
- package/src/menu/ui-menu.html +20 -0
- package/src/menu/ui-menu.ts +103 -0
- package/src/popup/ui-popup.html +16 -0
- package/src/popup/ui-popup.ts +391 -0
- package/src/progress/ui-progress.html +17 -0
- package/src/progress/ui-progress.ts +51 -0
- package/src/radio/ui-radio-group.html +27 -0
- package/src/radio/ui-radio-group.ts +250 -0
- package/src/radio/ui-radio.html +11 -0
- package/src/radio/ui-radio.ts +35 -0
- package/src/resource.d.ts +4 -0
- package/src/segmented-control/ui-segment.html +10 -0
- package/src/segmented-control/ui-segment.ts +20 -0
- package/src/segmented-control/ui-segmented-control.html +9 -0
- package/src/segmented-control/ui-segmented-control.ts +119 -0
- package/src/select/enhance-ui-select.ts +10 -0
- package/src/select/ui-select.html +70 -0
- package/src/select/ui-select.ts +294 -0
- package/src/slider/ui-slider.html +69 -0
- package/src/slider/ui-slider.ts +329 -0
- package/src/splitter/ui-splitter.html +14 -0
- package/src/splitter/ui-splitter.ts +249 -0
- package/src/switch/ui-switch.html +23 -0
- package/src/switch/ui-switch.ts +121 -0
- package/src/table/enhance-ui-table.ts +9 -0
- package/src/table/ui-table-column.html +17 -0
- package/src/table/ui-table-column.ts +108 -0
- package/src/table/ui-table.html +56 -0
- package/src/table/ui-table.ts +209 -0
- package/src/tabs/ui-tab.html +10 -0
- package/src/tabs/ui-tab.ts +30 -0
- package/src/tabs/ui-tabs.html +3 -0
- package/src/tabs/ui-tabs.ts +105 -0
- package/src/toast/ui-toast-region.html +11 -0
- package/src/toast/ui-toast-region.ts +18 -0
- package/src/toast/ui-toast-service.ts +100 -0
- package/src/tooltip/ui-tooltip-service.ts +84 -0
- package/src/tooltip/ui-tooltip.ts +200 -0
- package/src/top-app-bar/ui-top-app-bar.html +24 -0
- package/src/top-app-bar/ui-top-app-bar.ts +27 -0
- package/src/tree/ui-tree.html +38 -0
- package/src/tree/ui-tree.ts +363 -0
- package/src/validation/ui-validation-controller-factory.ts +20 -0
- package/src/validation/ui-validation-result-presenter.ts +26 -0
- package/src/validation/validate.ts +35 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { bindable, BindingMode, CustomElement, customElement, resolve, slotted } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import { IError, IValidatedElement } from '../base/i-validated-element';
|
|
4
|
+
import { Keys } from '../base/keys';
|
|
5
|
+
import { UiMenu } from '../menu/ui-menu';
|
|
6
|
+
import template from './ui-combobox.html?raw';
|
|
7
|
+
|
|
8
|
+
let nextComboboxId = 0;
|
|
9
|
+
type ComboboxOptions = unknown[] | ((filter: string | undefined, value: unknown) => unknown[] | Promise<unknown[]>);
|
|
10
|
+
|
|
11
|
+
@customElement({ name: 'ui-combobox', template })
|
|
12
|
+
export class UiCombobox {
|
|
13
|
+
constructor() {
|
|
14
|
+
defineUiComboboxElementApis(this.element);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
readonly element = resolve(Element) as HTMLElement;
|
|
18
|
+
readonly slotHost = this;
|
|
19
|
+
|
|
20
|
+
errors = new Map<IError, boolean>();
|
|
21
|
+
focus: boolean = false;
|
|
22
|
+
active: boolean = false;
|
|
23
|
+
controlEl!: HTMLElement;
|
|
24
|
+
inputEl!: HTMLInputElement;
|
|
25
|
+
menu!: UiMenu;
|
|
26
|
+
|
|
27
|
+
@bindable({ mode: BindingMode.twoWay })
|
|
28
|
+
value: unknown;
|
|
29
|
+
async valueChanged(): Promise<void> {
|
|
30
|
+
if (this.suppressValueChanged) {
|
|
31
|
+
this.suppressValueChanged = false;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await this.updateFilterBasedOnValue();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@bindable({ mode: BindingMode.twoWay })
|
|
39
|
+
text: string | undefined;
|
|
40
|
+
textChanged(): void {
|
|
41
|
+
if (this.inputEl && this.inputEl.value !== (this.text ?? '')) {
|
|
42
|
+
this.inputEl.value = this.text ?? '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@bindable
|
|
47
|
+
items: ComboboxOptions = [];
|
|
48
|
+
async itemsChanged(): Promise<void> {
|
|
49
|
+
this.setGetOptions();
|
|
50
|
+
await this.updateFilterBasedOnValue();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@bindable({ mode: BindingMode.twoWay })
|
|
54
|
+
filteredItems: unknown[] = [];
|
|
55
|
+
|
|
56
|
+
selectedOption: unknown;
|
|
57
|
+
|
|
58
|
+
@bindable
|
|
59
|
+
filterField: string | undefined;
|
|
60
|
+
filterFieldChanged(): void {}
|
|
61
|
+
|
|
62
|
+
@bindable({ mode: BindingMode.twoWay, set: booleanAttr })
|
|
63
|
+
open: boolean = false;
|
|
64
|
+
|
|
65
|
+
@bindable
|
|
66
|
+
label: string | undefined;
|
|
67
|
+
|
|
68
|
+
@bindable({ set: booleanAttr })
|
|
69
|
+
inset: boolean = false;
|
|
70
|
+
|
|
71
|
+
@bindable
|
|
72
|
+
helperText: string | undefined;
|
|
73
|
+
|
|
74
|
+
@bindable
|
|
75
|
+
id: string = `ui-combobox-${++nextComboboxId}`;
|
|
76
|
+
|
|
77
|
+
@bindable
|
|
78
|
+
name: string | undefined;
|
|
79
|
+
|
|
80
|
+
@bindable
|
|
81
|
+
placeholder: string | undefined;
|
|
82
|
+
|
|
83
|
+
@bindable
|
|
84
|
+
autocomplete: AutoFill | undefined;
|
|
85
|
+
|
|
86
|
+
@bindable
|
|
87
|
+
valueField: string | undefined;
|
|
88
|
+
|
|
89
|
+
@bindable
|
|
90
|
+
labelField: string | undefined;
|
|
91
|
+
|
|
92
|
+
@bindable({ set: booleanAttr })
|
|
93
|
+
disabled: boolean = false;
|
|
94
|
+
|
|
95
|
+
@bindable({ set: booleanAttr })
|
|
96
|
+
readonly: boolean = false;
|
|
97
|
+
|
|
98
|
+
@bindable({ set: booleanAttr })
|
|
99
|
+
required: boolean = false;
|
|
100
|
+
|
|
101
|
+
@bindable({ set: booleanAttr })
|
|
102
|
+
invalid: boolean = false;
|
|
103
|
+
|
|
104
|
+
@slotted({ slotName: 'helper' })
|
|
105
|
+
helperNodes: readonly Node[] = [];
|
|
106
|
+
|
|
107
|
+
@slotted({ slotName: 'leading' })
|
|
108
|
+
leadingNodes: readonly Node[] = [];
|
|
109
|
+
|
|
110
|
+
@slotted({ slotName: 'trailing' })
|
|
111
|
+
trailingNodes: readonly Node[] = [];
|
|
112
|
+
|
|
113
|
+
private initialText: string | undefined;
|
|
114
|
+
private getOptions: ((filter: string | undefined, value: unknown) => unknown[] | Promise<unknown[]>) | undefined;
|
|
115
|
+
private optionsRequest = 0;
|
|
116
|
+
private suppressValueChanged = false;
|
|
117
|
+
private suppressFocusOpen = false;
|
|
118
|
+
get textValue(): string | undefined {
|
|
119
|
+
if (this.inputEl) {
|
|
120
|
+
return this.inputEl.value;
|
|
121
|
+
}
|
|
122
|
+
return this.initialText;
|
|
123
|
+
}
|
|
124
|
+
set textValue(value: string | undefined) {
|
|
125
|
+
this.text = value;
|
|
126
|
+
if (this.inputEl) {
|
|
127
|
+
this.inputEl.value = value ?? '';
|
|
128
|
+
} else {
|
|
129
|
+
this.initialText = value;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get labelId(): string {
|
|
134
|
+
return `${this.id}-label`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get helperId(): string {
|
|
138
|
+
return `${this.id}-helper`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get errorsId(): string {
|
|
142
|
+
return `${this.id}-errors`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
get hasValue(): boolean {
|
|
146
|
+
return !!this.textValue;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get placeholderText(): string | undefined {
|
|
150
|
+
if (this.inset && !this.focus) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
return this.placeholder;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async attached(): Promise<void> {
|
|
157
|
+
this.setGetOptions();
|
|
158
|
+
if (this.text !== undefined) {
|
|
159
|
+
this.textValue = this.text;
|
|
160
|
+
}
|
|
161
|
+
await this.updateFilterBasedOnValue();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
addError(error: IError): void {
|
|
165
|
+
if (this.findError(error)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.errors.set(error, true);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
removeError(error: IError): void {
|
|
173
|
+
const existing = this.findError(error);
|
|
174
|
+
if (existing) {
|
|
175
|
+
this.errors.delete(existing);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this.errors.delete(error);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async onInput(): Promise<void> {
|
|
183
|
+
this.text = this.inputEl.value;
|
|
184
|
+
this.selectedOption = undefined;
|
|
185
|
+
this.setValue(undefined);
|
|
186
|
+
this.open = true;
|
|
187
|
+
await this.loadOptions(true, undefined);
|
|
188
|
+
this.dispatchValueEvent('input');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async onKeyDown(event: KeyboardEvent): Promise<void> {
|
|
192
|
+
if (this.disabled || this.readonly) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (event.key === Keys.Tab) {
|
|
197
|
+
this.open = false;
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (event.ctrlKey && event.key === Keys.Space) {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
await this.loadOptions(true, this.value);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (event.key === Keys.ArrowDown || event.key === Keys.ArrowUp) {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
await this.loadOptions(true, this.value);
|
|
210
|
+
this.menu.focus(event.key === Keys.ArrowDown ? Keys.Home : Keys.End);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (event.key === Keys.Escape) {
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
this.open = false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
onMenuSelect(event: CustomEvent): void {
|
|
221
|
+
this.selectedOption = event.detail;
|
|
222
|
+
this.value = this.getItemValue(event.detail);
|
|
223
|
+
this.open = false;
|
|
224
|
+
this.suppressFocusOpen = true;
|
|
225
|
+
this.inputEl.focus();
|
|
226
|
+
this.dispatchValueEvent('input');
|
|
227
|
+
this.dispatchValueEvent('change');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
onMenuTabAway(): void {
|
|
231
|
+
this.open = false;
|
|
232
|
+
this.focus = false;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async onFocusIn(): Promise<void> {
|
|
236
|
+
if (this.suppressFocusOpen) {
|
|
237
|
+
this.suppressFocusOpen = false;
|
|
238
|
+
this.focus = true;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (!this.disabled) {
|
|
243
|
+
this.focus = true;
|
|
244
|
+
await this.loadOptions(true, this.value);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
onFocusOut(event: FocusEvent): void {
|
|
249
|
+
const next = event.relatedTarget as Node | null;
|
|
250
|
+
if (next && this.menu.contains(next)) {
|
|
251
|
+
event.stopPropagation();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
this.open = false;
|
|
256
|
+
this.focus = false;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
onPointerDown(): void {
|
|
260
|
+
if (!this.disabled) {
|
|
261
|
+
this.active = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
onPointerUp(): void {
|
|
266
|
+
this.active = false;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
onPointerLeave(): void {
|
|
270
|
+
this.active = false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private getItemValue(item: unknown): unknown {
|
|
274
|
+
if (this.valueField && item && typeof item === 'object') {
|
|
275
|
+
return (item as Record<string, unknown>)[this.valueField];
|
|
276
|
+
}
|
|
277
|
+
return item;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private getItemLabel(item: unknown): string {
|
|
281
|
+
const labelField = this.labelField ?? this.filterField;
|
|
282
|
+
if (labelField && item && typeof item === 'object') {
|
|
283
|
+
const label = (item as Record<string, unknown>)[labelField];
|
|
284
|
+
return label === undefined || label === null ? '' : String(label);
|
|
285
|
+
}
|
|
286
|
+
return item === undefined || item === null ? '' : String(item);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private setValue(value: unknown): void {
|
|
290
|
+
if (this.value === value) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
this.suppressValueChanged = true;
|
|
295
|
+
this.value = value;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private setGetOptions(): void {
|
|
299
|
+
if (this.items instanceof Function) {
|
|
300
|
+
this.getOptions = this.items;
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
this.getOptions = this.getOptionsDefault;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private getOptionsDefault = (filter: string | undefined, value: unknown): unknown[] => {
|
|
308
|
+
const options = Array.isArray(this.items) ? this.items : [];
|
|
309
|
+
if (value !== undefined) {
|
|
310
|
+
const option = options.find(item => this.getItemValue(item) === value);
|
|
311
|
+
return option === undefined ? [] : [option];
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const text = filter?.trim().toLowerCase();
|
|
315
|
+
if (!text) {
|
|
316
|
+
return options;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return options.filter(item => this.getItemFilterText(item).toLowerCase().includes(text));
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
private async loadOptions(open: boolean, value: unknown): Promise<void> {
|
|
323
|
+
if (!this.getOptions) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const request = ++this.optionsRequest;
|
|
328
|
+
const options = await this.getOptions(this.textValue, value);
|
|
329
|
+
if (request !== this.optionsRequest) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
this.filteredItems = options;
|
|
334
|
+
if (open) {
|
|
335
|
+
this.open = true;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private async updateFilterBasedOnValue(): Promise<void> {
|
|
340
|
+
if (this.value !== undefined) {
|
|
341
|
+
await this.loadOptions(false, this.value);
|
|
342
|
+
} else {
|
|
343
|
+
this.filteredItems = [];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (this.filteredItems.length) {
|
|
347
|
+
this.selectedOption = this.filteredItems[0];
|
|
348
|
+
this.textValue = this.getItemLabel(this.filteredItems[0]);
|
|
349
|
+
} else if (this.value !== undefined) {
|
|
350
|
+
this.selectedOption = undefined;
|
|
351
|
+
this.textValue = undefined;
|
|
352
|
+
} else {
|
|
353
|
+
this.selectedOption = undefined;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
private getItemFilterText(item: unknown): string {
|
|
358
|
+
if (this.filterField && item && typeof item === 'object') {
|
|
359
|
+
const filterValue = (item as Record<string, unknown>)[this.filterField];
|
|
360
|
+
return filterValue === undefined || filterValue === null ? '' : String(filterValue);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return this.getItemLabel(item);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private dispatchValueEvent(type: 'input' | 'change'): void {
|
|
367
|
+
this.element.dispatchEvent(new Event(type, { bubbles: true }));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
private findError(error: IError): IError | undefined {
|
|
371
|
+
for (const existing of this.errors.keys()) {
|
|
372
|
+
if (existing === error || existing.message === error.message) {
|
|
373
|
+
return existing;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export interface IUiComboboxElement extends IValidatedElement {
|
|
382
|
+
value: unknown;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function defineUiComboboxElementApis(element: HTMLElement) {
|
|
386
|
+
Object.defineProperties(element, {
|
|
387
|
+
tagName: {
|
|
388
|
+
get() {
|
|
389
|
+
return 'UI-COMBOBOX';
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
value: {
|
|
393
|
+
get(this: IUiComboboxElement) {
|
|
394
|
+
return CustomElement.for<UiCombobox>(this).viewModel.value;
|
|
395
|
+
},
|
|
396
|
+
set(this: IUiComboboxElement, value: unknown) {
|
|
397
|
+
CustomElement.for<UiCombobox>(this).viewModel.value = value;
|
|
398
|
+
},
|
|
399
|
+
configurable: true
|
|
400
|
+
},
|
|
401
|
+
disabled: {
|
|
402
|
+
get(this: IUiComboboxElement) {
|
|
403
|
+
return CustomElement.for<UiCombobox>(this).viewModel.disabled;
|
|
404
|
+
},
|
|
405
|
+
set(this: IUiComboboxElement, value: boolean) {
|
|
406
|
+
CustomElement.for<UiCombobox>(this).viewModel.disabled = value;
|
|
407
|
+
},
|
|
408
|
+
configurable: true
|
|
409
|
+
},
|
|
410
|
+
readOnly: {
|
|
411
|
+
get(this: IUiComboboxElement) {
|
|
412
|
+
return CustomElement.for<UiCombobox>(this).viewModel.readonly;
|
|
413
|
+
},
|
|
414
|
+
set(this: IUiComboboxElement, value: boolean) {
|
|
415
|
+
CustomElement.for<UiCombobox>(this).viewModel.readonly = value;
|
|
416
|
+
},
|
|
417
|
+
configurable: true
|
|
418
|
+
},
|
|
419
|
+
addError: {
|
|
420
|
+
value(this: IUiComboboxElement, error: IError) {
|
|
421
|
+
CustomElement.for<UiCombobox>(this).viewModel.addError(error);
|
|
422
|
+
},
|
|
423
|
+
configurable: true
|
|
424
|
+
},
|
|
425
|
+
removeError: {
|
|
426
|
+
value(this: IUiComboboxElement, error: IError) {
|
|
427
|
+
CustomElement.for<UiCombobox>(this).viewModel.removeError(error);
|
|
428
|
+
},
|
|
429
|
+
configurable: true
|
|
430
|
+
},
|
|
431
|
+
focus: {
|
|
432
|
+
value(this: IUiComboboxElement) {
|
|
433
|
+
CustomElement.for<UiCombobox>(this).viewModel.inputEl.focus();
|
|
434
|
+
},
|
|
435
|
+
configurable: true
|
|
436
|
+
},
|
|
437
|
+
blur: {
|
|
438
|
+
value(this: IUiComboboxElement) {
|
|
439
|
+
CustomElement.for<UiCombobox>(this).viewModel.inputEl.blur();
|
|
440
|
+
},
|
|
441
|
+
configurable: true
|
|
442
|
+
},
|
|
443
|
+
isFocused: {
|
|
444
|
+
get(this: IUiComboboxElement) {
|
|
445
|
+
return document.activeElement === CustomElement.for<UiCombobox>(this).viewModel.inputEl;
|
|
446
|
+
},
|
|
447
|
+
configurable: true
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template class="ui-disclosure" data-open.attr="open ? '' : null">
|
|
2
|
+
<div class="ui-disclosure__header"
|
|
3
|
+
role="button"
|
|
4
|
+
tabindex="0"
|
|
5
|
+
aria-expanded.attr="open ? 'true' : 'false'"
|
|
6
|
+
aria-controls.bind="panelId"
|
|
7
|
+
data-open.attr="open ? '' : null"
|
|
8
|
+
data-hover.attr="hover ? '' : null"
|
|
9
|
+
data-focus.attr="focus ? '' : null"
|
|
10
|
+
data-active.attr="active ? '' : null"
|
|
11
|
+
click.trigger="onClick($event)"
|
|
12
|
+
keydown.trigger="onKeyDown($event)"
|
|
13
|
+
keyup.trigger="onKeyUp($event)"
|
|
14
|
+
mouseenter.trigger="onMouseEnter()"
|
|
15
|
+
mouseleave.trigger="onMouseLeave()"
|
|
16
|
+
focusin.trigger="onFocusIn()"
|
|
17
|
+
focusout.trigger="onFocusOut()"
|
|
18
|
+
pointerdown.trigger="onPointerDown()"
|
|
19
|
+
pointerup.trigger="onPointerUp()"
|
|
20
|
+
pointerleave.trigger="onPointerLeave()">
|
|
21
|
+
<au-slot name="header"></au-slot>
|
|
22
|
+
<span class="ui-disclosure__chevron" aria-hidden="true">▾</span>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div class="ui-disclosure__content" id.bind="panelId" data-open.attr="open ? '' : null" hidden.bind="!open">
|
|
26
|
+
<au-slot name="content"></au-slot>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { bindable, customElement } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import { Keys } from '../base/keys';
|
|
4
|
+
import template from './ui-disclosure.html?raw';
|
|
5
|
+
|
|
6
|
+
let nextPanelId = 0;
|
|
7
|
+
|
|
8
|
+
@customElement({ name: 'ui-disclosure', template })
|
|
9
|
+
export class UiDisclosure {
|
|
10
|
+
@bindable({ set: booleanAttr })
|
|
11
|
+
open: boolean = false;
|
|
12
|
+
|
|
13
|
+
panelId: string = `ui-disclosure-panel-${++nextPanelId}`;
|
|
14
|
+
hover: boolean = false;
|
|
15
|
+
focus: boolean = false;
|
|
16
|
+
active: boolean = false;
|
|
17
|
+
|
|
18
|
+
onClick(event: MouseEvent): void {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
this.toggle();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
onKeyDown(event: KeyboardEvent): void {
|
|
24
|
+
if (event.key === Keys.Space || event.key === Keys.Enter) {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
event.stopPropagation();
|
|
27
|
+
this.toggle();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
onKeyUp(event: KeyboardEvent): void {
|
|
32
|
+
if (event.key === Keys.Space) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onMouseEnter(): void {
|
|
38
|
+
this.hover = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onMouseLeave(): void {
|
|
42
|
+
this.hover = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
onFocusIn(): void {
|
|
46
|
+
this.focus = true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onFocusOut(): void {
|
|
50
|
+
this.focus = false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onPointerDown(): void {
|
|
54
|
+
this.active = true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
onPointerUp(): void {
|
|
58
|
+
this.active = false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
onPointerLeave(): void {
|
|
62
|
+
this.active = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private toggle(): void {
|
|
66
|
+
this.open = !this.open;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template class="ui-drawer" data-open.attr="open ? '' : null">
|
|
2
|
+
<aside if.bind="persistent"
|
|
3
|
+
class="ui-drawer__panel"
|
|
4
|
+
ref="panelElement"
|
|
5
|
+
role="dialog"
|
|
6
|
+
tabindex="-1"
|
|
7
|
+
aria-label.attr="label || null"
|
|
8
|
+
aria-labelledby.attr="labelledBy || null"
|
|
9
|
+
aria-describedby.attr="describedBy || null"
|
|
10
|
+
aria-hidden.attr="open ? null : 'true'"
|
|
11
|
+
data-side.attr="side"
|
|
12
|
+
data-open.attr="open ? '' : null"
|
|
13
|
+
data-persistent>
|
|
14
|
+
<au-slot></au-slot>
|
|
15
|
+
</aside>
|
|
16
|
+
|
|
17
|
+
<div else portal="target.bind: portalTarget; position.bind: portalPosition">
|
|
18
|
+
<div class="ui-drawer__backdrop"
|
|
19
|
+
if.bind="modal"
|
|
20
|
+
data-open.attr="open ? '' : null"></div>
|
|
21
|
+
<aside class="ui-drawer__panel"
|
|
22
|
+
ref="panelElement"
|
|
23
|
+
role="dialog"
|
|
24
|
+
tabindex="-1"
|
|
25
|
+
aria-modal.attr="modal ? 'true' : null"
|
|
26
|
+
aria-label.attr="label || null"
|
|
27
|
+
aria-labelledby.attr="labelledBy || null"
|
|
28
|
+
aria-describedby.attr="describedBy || null"
|
|
29
|
+
aria-hidden.attr="open ? null : 'true'"
|
|
30
|
+
data-side.attr="side"
|
|
31
|
+
data-open.attr="open ? '' : null">
|
|
32
|
+
<au-slot></au-slot>
|
|
33
|
+
</aside>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|