@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,294 @@
|
|
|
1
|
+
import { bindable, BindingMode, computed, 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 template from './ui-select.html?raw';
|
|
6
|
+
|
|
7
|
+
let nextSelectId = 0;
|
|
8
|
+
|
|
9
|
+
@customElement({ name: 'ui-select', template })
|
|
10
|
+
export class UiSelect {
|
|
11
|
+
constructor() {
|
|
12
|
+
defineUiSelectElementApis(this.element);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
readonly element = resolve(Element) as HTMLElement;
|
|
16
|
+
|
|
17
|
+
errors = new Map<IError, boolean>();
|
|
18
|
+
focus: boolean = false;
|
|
19
|
+
active: boolean = false;
|
|
20
|
+
open: boolean = false;
|
|
21
|
+
controlEl!: HTMLElement;
|
|
22
|
+
|
|
23
|
+
@bindable({ mode: BindingMode.twoWay })
|
|
24
|
+
value: unknown;
|
|
25
|
+
|
|
26
|
+
@bindable({ mode: BindingMode.twoWay })
|
|
27
|
+
selectedItem: unknown;
|
|
28
|
+
|
|
29
|
+
@bindable
|
|
30
|
+
label: string | undefined;
|
|
31
|
+
|
|
32
|
+
@bindable({ set: booleanAttr })
|
|
33
|
+
inset: boolean = false;
|
|
34
|
+
|
|
35
|
+
@bindable
|
|
36
|
+
helperText: string | undefined;
|
|
37
|
+
|
|
38
|
+
@bindable
|
|
39
|
+
id: string = `ui-select-${++nextSelectId}`;
|
|
40
|
+
|
|
41
|
+
@bindable
|
|
42
|
+
placeholder: string | undefined;
|
|
43
|
+
|
|
44
|
+
@bindable
|
|
45
|
+
valueField: string | undefined;
|
|
46
|
+
|
|
47
|
+
@bindable
|
|
48
|
+
labelField: string | undefined;
|
|
49
|
+
|
|
50
|
+
@bindable({ set: booleanAttr })
|
|
51
|
+
disabled: boolean = false;
|
|
52
|
+
|
|
53
|
+
@bindable({ set: booleanAttr })
|
|
54
|
+
readonly: boolean = false;
|
|
55
|
+
|
|
56
|
+
@bindable({ set: booleanAttr })
|
|
57
|
+
required: boolean = false;
|
|
58
|
+
|
|
59
|
+
@bindable({ set: booleanAttr })
|
|
60
|
+
invalid: boolean = false;
|
|
61
|
+
|
|
62
|
+
@slotted({ slotName: 'helper' })
|
|
63
|
+
helperNodes: readonly Node[] = [];
|
|
64
|
+
|
|
65
|
+
@slotted({ slotName: 'leading' })
|
|
66
|
+
leadingNodes: readonly Node[] = [];
|
|
67
|
+
|
|
68
|
+
@slotted({ slotName: 'trailing' })
|
|
69
|
+
trailingNodes: readonly Node[] = [];
|
|
70
|
+
|
|
71
|
+
get labelId(): string {
|
|
72
|
+
return `${this.id}-label`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get helperId(): string {
|
|
76
|
+
return `${this.id}-helper`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get errorsId(): string {
|
|
80
|
+
return `${this.id}-errors`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@computed({ flush: 'async' })
|
|
84
|
+
get displayText(): string | undefined {
|
|
85
|
+
if (this.selectedItem !== undefined) {
|
|
86
|
+
return this.getItemLabel(this.selectedItem);
|
|
87
|
+
}
|
|
88
|
+
if (this.value !== undefined) {
|
|
89
|
+
return String(this.value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@computed({ flush: 'async' })
|
|
96
|
+
get placeholderText(): string | undefined {
|
|
97
|
+
if (this.inset && !this.focus) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.placeholder;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get hasValue(): boolean {
|
|
105
|
+
return this.value !== undefined && this.value !== null && this.value !== '';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
addError(error: IError): void {
|
|
109
|
+
if (this.findError(error)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.errors.set(error, true);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
removeError(error: IError): void {
|
|
117
|
+
const existing = this.findError(error);
|
|
118
|
+
if (existing) {
|
|
119
|
+
this.errors.delete(existing);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.errors.delete(error);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
onClick(): void {
|
|
127
|
+
if (this.disabled || this.readonly) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this.open = !this.open;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
onKeyDown(event: KeyboardEvent): void {
|
|
135
|
+
if (this.disabled || this.readonly) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (event.key === Keys.Enter || event.key === Keys.Space || event.key === Keys.ArrowDown) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
this.open = true;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (event.key === Keys.Escape) {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
this.open = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
onMenuSelect(event: CustomEvent): void {
|
|
152
|
+
this.selectedItem = event.detail;
|
|
153
|
+
this.value = this.getItemValue(event.detail);
|
|
154
|
+
this.open = false;
|
|
155
|
+
this.dispatchValueEvent('input');
|
|
156
|
+
this.dispatchValueEvent('change');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
onMenuTabAway(): void {
|
|
160
|
+
this.open = false;
|
|
161
|
+
this.focus = false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
onFocusIn(): void {
|
|
165
|
+
if (!this.disabled) {
|
|
166
|
+
this.focus = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
onFocusOut(event: FocusEvent): void {
|
|
171
|
+
if (this.open) {
|
|
172
|
+
event.stopPropagation();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.focus = false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
onPointerDown(): void {
|
|
180
|
+
if (!this.disabled) {
|
|
181
|
+
this.active = true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
onPointerUp(): void {
|
|
186
|
+
this.active = false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
onPointerLeave(): void {
|
|
190
|
+
this.active = false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private getItemValue(item: unknown): unknown {
|
|
194
|
+
if (this.valueField && item && typeof item === 'object') {
|
|
195
|
+
return (item as Record<string, unknown>)[this.valueField];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return item;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private getItemLabel(item: unknown): string {
|
|
202
|
+
if (this.labelField && item && typeof item === 'object') {
|
|
203
|
+
const label = (item as Record<string, unknown>)[this.labelField];
|
|
204
|
+
return label === undefined || label === null ? '' : String(label);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return item === undefined || item === null ? '' : String(item);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private dispatchValueEvent(type: 'input' | 'change'): void {
|
|
211
|
+
this.element.dispatchEvent(new Event(type, { bubbles: true }));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private findError(error: IError): IError | undefined {
|
|
215
|
+
for (const existing of this.errors.keys()) {
|
|
216
|
+
if (existing === error || existing.message === error.message) {
|
|
217
|
+
return existing;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface IUiSelectElement extends IValidatedElement {
|
|
226
|
+
value: unknown;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function defineUiSelectElementApis(element: HTMLElement) {
|
|
230
|
+
Object.defineProperties(element, {
|
|
231
|
+
tagName: {
|
|
232
|
+
get() {
|
|
233
|
+
return 'UI-SELECT';
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
value: {
|
|
237
|
+
get(this: IUiSelectElement) {
|
|
238
|
+
return CustomElement.for<UiSelect>(this).viewModel.value;
|
|
239
|
+
},
|
|
240
|
+
set(this: IUiSelectElement, value: unknown) {
|
|
241
|
+
CustomElement.for<UiSelect>(this).viewModel.value = value;
|
|
242
|
+
},
|
|
243
|
+
configurable: true
|
|
244
|
+
},
|
|
245
|
+
disabled: {
|
|
246
|
+
get(this: IUiSelectElement) {
|
|
247
|
+
return CustomElement.for<UiSelect>(this).viewModel.disabled;
|
|
248
|
+
},
|
|
249
|
+
set(this: IUiSelectElement, value: boolean) {
|
|
250
|
+
CustomElement.for<UiSelect>(this).viewModel.disabled = value;
|
|
251
|
+
},
|
|
252
|
+
configurable: true
|
|
253
|
+
},
|
|
254
|
+
readOnly: {
|
|
255
|
+
get(this: IUiSelectElement) {
|
|
256
|
+
return CustomElement.for<UiSelect>(this).viewModel.readonly;
|
|
257
|
+
},
|
|
258
|
+
set(this: IUiSelectElement, value: boolean) {
|
|
259
|
+
CustomElement.for<UiSelect>(this).viewModel.readonly = value;
|
|
260
|
+
},
|
|
261
|
+
configurable: true
|
|
262
|
+
},
|
|
263
|
+
addError: {
|
|
264
|
+
value(this: IUiSelectElement, error: IError) {
|
|
265
|
+
CustomElement.for<UiSelect>(this).viewModel.addError(error);
|
|
266
|
+
},
|
|
267
|
+
configurable: true
|
|
268
|
+
},
|
|
269
|
+
removeError: {
|
|
270
|
+
value(this: IUiSelectElement, error: IError) {
|
|
271
|
+
CustomElement.for<UiSelect>(this).viewModel.removeError(error);
|
|
272
|
+
},
|
|
273
|
+
configurable: true
|
|
274
|
+
},
|
|
275
|
+
focus: {
|
|
276
|
+
value(this: IUiSelectElement) {
|
|
277
|
+
CustomElement.for<UiSelect>(this).viewModel.controlEl.focus();
|
|
278
|
+
},
|
|
279
|
+
configurable: true
|
|
280
|
+
},
|
|
281
|
+
blur: {
|
|
282
|
+
value(this: IUiSelectElement) {
|
|
283
|
+
CustomElement.for<UiSelect>(this).viewModel.controlEl.blur();
|
|
284
|
+
},
|
|
285
|
+
configurable: true
|
|
286
|
+
},
|
|
287
|
+
isFocused: {
|
|
288
|
+
get(this: IUiSelectElement) {
|
|
289
|
+
return document.activeElement === CustomElement.for<UiSelect>(this).viewModel.controlEl;
|
|
290
|
+
},
|
|
291
|
+
configurable: true
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template class="ui-slider"
|
|
2
|
+
data-disabled.attr="disabled ? '' : null"
|
|
3
|
+
data-readonly.attr="readonly ? '' : null"
|
|
4
|
+
data-invalid.attr="invalid || errors.size ? '' : null"
|
|
5
|
+
data-focus.attr="focus ? '' : null"
|
|
6
|
+
data-active.attr="active ? '' : null"
|
|
7
|
+
data-range.attr="range ? '' : null">
|
|
8
|
+
<label class="ui-slider__label" for.bind="id" id.bind="label ? labelId : null" show.bind="label">${label}</label>
|
|
9
|
+
|
|
10
|
+
<div class="ui-slider__control">
|
|
11
|
+
<span class="ui-slider__track" aria-hidden="true">
|
|
12
|
+
<span class="ui-slider__fill" style.bind="fillStyle"></span>
|
|
13
|
+
</span>
|
|
14
|
+
<input ref="inputEl"
|
|
15
|
+
class="ui-slider__native"
|
|
16
|
+
id.bind="id"
|
|
17
|
+
type="range"
|
|
18
|
+
name.attr="name || null"
|
|
19
|
+
min.bind="min"
|
|
20
|
+
max.bind="max"
|
|
21
|
+
step.bind="step"
|
|
22
|
+
value.bind="value"
|
|
23
|
+
disabled.bind="disabled"
|
|
24
|
+
required.bind="required"
|
|
25
|
+
aria-labelledby.bind="label ? labelId : null"
|
|
26
|
+
aria-invalid.bind="invalid || errors.size ? 'true' : 'false'"
|
|
27
|
+
aria-describedby.bind="errors.size ? errorsId : (helperNodes.length ? helperId : null)"
|
|
28
|
+
input.trigger="onInput($event)"
|
|
29
|
+
change.trigger="onChange($event)"
|
|
30
|
+
focusin.trigger="onFocusIn()"
|
|
31
|
+
focusout.trigger="onFocusOut()"
|
|
32
|
+
pointerdown.trigger="onPointerDown($event)"
|
|
33
|
+
pointerup.trigger="onPointerUp()"
|
|
34
|
+
pointerleave.trigger="onPointerLeave()"
|
|
35
|
+
keydown.trigger="onKeyDown($event)">
|
|
36
|
+
<input ref="endInputEl"
|
|
37
|
+
if.bind="range"
|
|
38
|
+
class="ui-slider__native ui-slider__native--end"
|
|
39
|
+
id.bind="endId"
|
|
40
|
+
type="range"
|
|
41
|
+
name.attr="name ? name + '-end' : null"
|
|
42
|
+
min.bind="min"
|
|
43
|
+
max.bind="max"
|
|
44
|
+
step.bind="step"
|
|
45
|
+
value.bind="endValue"
|
|
46
|
+
disabled.bind="disabled"
|
|
47
|
+
aria-label.attr="label ? label + ' end' : 'Range end'"
|
|
48
|
+
aria-invalid.bind="invalid || errors.size ? 'true' : 'false'"
|
|
49
|
+
aria-describedby.bind="errors.size ? errorsId : (helperNodes.length ? helperId : null)"
|
|
50
|
+
input.trigger="onInput($event)"
|
|
51
|
+
change.trigger="onChange($event)"
|
|
52
|
+
focusin.trigger="onFocusIn()"
|
|
53
|
+
focusout.trigger="onFocusOut()"
|
|
54
|
+
pointerdown.trigger="onPointerDown($event)"
|
|
55
|
+
pointerup.trigger="onPointerUp()"
|
|
56
|
+
pointerleave.trigger="onPointerLeave()"
|
|
57
|
+
keydown.trigger="onKeyDown($event)">
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div class="ui-slider__subscript" show.bind="errors.size || helperText || helperNodes.length">
|
|
61
|
+
<div class="ui-slider__helper" id.bind="helperId" show.bind="!errors.size && (helperText || helperNodes.length)">
|
|
62
|
+
<au-slot name="helper">${helperText}</au-slot>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<div class="ui-slider__errors" id.bind="errorsId" show.bind="errors.size">
|
|
66
|
+
<div class="ui-slider__error" repeat.for="[error, _] of errors" if.bind="error.message">${error.message}</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { bindable, BindingMode, CustomElement, customElement, INode, resolve, slotted } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import { IError, IValidatedElement } from '../base/i-validated-element';
|
|
4
|
+
import template from './ui-slider.html?raw';
|
|
5
|
+
|
|
6
|
+
let nextSliderId = 0;
|
|
7
|
+
|
|
8
|
+
@customElement({ name: 'ui-slider', template })
|
|
9
|
+
export class UiSlider {
|
|
10
|
+
constructor() {
|
|
11
|
+
defineUiSliderElementApis(this.element);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
readonly element = resolve(INode) as HTMLElement;
|
|
15
|
+
errors = new Map<IError, boolean>();
|
|
16
|
+
focus = false;
|
|
17
|
+
active = false;
|
|
18
|
+
inputEl!: HTMLInputElement;
|
|
19
|
+
endInputEl!: HTMLInputElement;
|
|
20
|
+
fillStyle = 'width: 0%';
|
|
21
|
+
normalizedValue = 0;
|
|
22
|
+
normalizedEndValue = 0;
|
|
23
|
+
labelId = '';
|
|
24
|
+
helperId = '';
|
|
25
|
+
errorsId = '';
|
|
26
|
+
endId = '';
|
|
27
|
+
|
|
28
|
+
@bindable({ mode: BindingMode.twoWay })
|
|
29
|
+
value: number = 0;
|
|
30
|
+
valueChanged(): void {
|
|
31
|
+
this.normalizeValues('start');
|
|
32
|
+
this.updateFillStyle();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@bindable({ mode: BindingMode.twoWay })
|
|
36
|
+
endValue: number = 100;
|
|
37
|
+
endValueChanged(): void {
|
|
38
|
+
this.normalizeValues('end');
|
|
39
|
+
this.updateFillStyle();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@bindable
|
|
43
|
+
min: number = 0;
|
|
44
|
+
minChanged(): void {
|
|
45
|
+
this.normalizeValues();
|
|
46
|
+
this.updateFillStyle();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@bindable
|
|
50
|
+
max: number = 100;
|
|
51
|
+
maxChanged(): void {
|
|
52
|
+
this.normalizeValues();
|
|
53
|
+
this.updateFillStyle();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@bindable
|
|
57
|
+
step: number = 1;
|
|
58
|
+
|
|
59
|
+
@bindable({ set: booleanAttr })
|
|
60
|
+
range = false;
|
|
61
|
+
rangeChanged(): void {
|
|
62
|
+
this.normalizeValues();
|
|
63
|
+
this.updateFillStyle();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@bindable
|
|
67
|
+
label: string | undefined;
|
|
68
|
+
|
|
69
|
+
@bindable
|
|
70
|
+
helperText: string | undefined;
|
|
71
|
+
|
|
72
|
+
@bindable
|
|
73
|
+
id: string = `ui-slider-${++nextSliderId}`;
|
|
74
|
+
idChanged(): void {
|
|
75
|
+
this.updateIds();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@bindable
|
|
79
|
+
name: string | undefined;
|
|
80
|
+
|
|
81
|
+
@bindable({ set: booleanAttr })
|
|
82
|
+
disabled = false;
|
|
83
|
+
|
|
84
|
+
@bindable({ set: booleanAttr })
|
|
85
|
+
readonly = false;
|
|
86
|
+
|
|
87
|
+
@bindable({ set: booleanAttr })
|
|
88
|
+
required = false;
|
|
89
|
+
|
|
90
|
+
@bindable({ set: booleanAttr })
|
|
91
|
+
invalid = false;
|
|
92
|
+
|
|
93
|
+
@slotted({ slotName: 'helper' })
|
|
94
|
+
helperNodes: readonly Node[] = [];
|
|
95
|
+
|
|
96
|
+
binding(): void {
|
|
97
|
+
this.updateIds();
|
|
98
|
+
this.normalizeValues();
|
|
99
|
+
this.updateFillStyle();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
addError(error: IError): void {
|
|
103
|
+
if (this.findError(error)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.errors.set(error, true);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
removeError(error: IError): void {
|
|
111
|
+
const existing = this.findError(error);
|
|
112
|
+
if (existing) {
|
|
113
|
+
this.errors.delete(existing);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.errors.delete(error);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
onInput(event: Event): void {
|
|
121
|
+
if (!(event.target instanceof HTMLInputElement) || this.disabled || this.readonly) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (event.target === this.endInputEl) {
|
|
126
|
+
this.endValue = Number(event.target.value);
|
|
127
|
+
this.normalizeValues('end');
|
|
128
|
+
} else {
|
|
129
|
+
this.value = Number(event.target.value);
|
|
130
|
+
this.normalizeValues('start');
|
|
131
|
+
}
|
|
132
|
+
this.updateFillStyle();
|
|
133
|
+
this.dispatchValueEvent('input');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
onChange(event: Event): void {
|
|
137
|
+
if (!(event.target instanceof HTMLInputElement) || this.disabled || this.readonly) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (event.target === this.endInputEl) {
|
|
142
|
+
this.endValue = Number(event.target.value);
|
|
143
|
+
this.normalizeValues('end');
|
|
144
|
+
} else {
|
|
145
|
+
this.value = Number(event.target.value);
|
|
146
|
+
this.normalizeValues('start');
|
|
147
|
+
}
|
|
148
|
+
this.updateFillStyle();
|
|
149
|
+
this.dispatchValueEvent('change');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
onFocusIn(): void {
|
|
153
|
+
if (!this.disabled) {
|
|
154
|
+
this.focus = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
onFocusOut(): void {
|
|
159
|
+
this.focus = false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
onPointerDown(event: PointerEvent): void {
|
|
163
|
+
if (this.readonly) {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!this.disabled) {
|
|
169
|
+
this.active = true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
onPointerUp(): void {
|
|
174
|
+
this.active = false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
onPointerLeave(): void {
|
|
178
|
+
this.active = false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
onKeyDown(event: KeyboardEvent): void {
|
|
182
|
+
if (this.readonly) {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private normalizeValues(changed?: 'start' | 'end'): void {
|
|
188
|
+
const min = Number(this.min);
|
|
189
|
+
const max = Number(this.max);
|
|
190
|
+
const low = Number.isFinite(min) ? min : 0;
|
|
191
|
+
const high = Number.isFinite(max) && max > low ? max : low + 100;
|
|
192
|
+
const next = Number(this.value);
|
|
193
|
+
const nextEnd = Number(this.endValue);
|
|
194
|
+
this.normalizedValue = Math.max(low, Math.min(high, Number.isFinite(next) ? next : low));
|
|
195
|
+
this.normalizedEndValue = Math.max(low, Math.min(high, Number.isFinite(nextEnd) ? nextEnd : high));
|
|
196
|
+
if (this.range && this.normalizedValue > this.normalizedEndValue) {
|
|
197
|
+
if (changed === 'end') {
|
|
198
|
+
this.normalizedEndValue = this.normalizedValue;
|
|
199
|
+
} else {
|
|
200
|
+
this.normalizedValue = this.normalizedEndValue;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (!this.range) {
|
|
204
|
+
this.normalizedEndValue = high;
|
|
205
|
+
}
|
|
206
|
+
if (this.value !== this.normalizedValue) {
|
|
207
|
+
this.value = this.normalizedValue;
|
|
208
|
+
}
|
|
209
|
+
if (this.endValue !== this.normalizedEndValue) {
|
|
210
|
+
this.endValue = this.normalizedEndValue;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private updateFillStyle(): void {
|
|
215
|
+
const min = Number(this.min) || 0;
|
|
216
|
+
const max = Number(this.max) || 100;
|
|
217
|
+
const range = Math.max(1, max - min);
|
|
218
|
+
const startPercent = Math.max(0, Math.min(100, (this.normalizedValue - min) / range * 100));
|
|
219
|
+
const endPercent = Math.max(0, Math.min(100, (this.normalizedEndValue - min) / range * 100));
|
|
220
|
+
if (this.range) {
|
|
221
|
+
this.fillStyle = `left: ${startPercent}%; width: ${Math.max(0, endPercent - startPercent)}%`;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
this.fillStyle = `left: 0%; width: ${startPercent}%`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private updateIds(): void {
|
|
229
|
+
this.labelId = `${this.id}-label`;
|
|
230
|
+
this.helperId = `${this.id}-helper`;
|
|
231
|
+
this.errorsId = `${this.id}-errors`;
|
|
232
|
+
this.endId = `${this.id}-end`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
private dispatchValueEvent(type: 'input' | 'change'): void {
|
|
236
|
+
this.element.dispatchEvent(new Event(type, { bubbles: true }));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private findError(error: IError): IError | undefined {
|
|
240
|
+
for (const existing of this.errors.keys()) {
|
|
241
|
+
if (existing === error || existing.message === error.message) {
|
|
242
|
+
return existing;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface IUiSliderElement extends IValidatedElement {
|
|
251
|
+
value: number;
|
|
252
|
+
endValue: number;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function defineUiSliderElementApis(element: HTMLElement) {
|
|
256
|
+
Object.defineProperties(element, {
|
|
257
|
+
tagName: {
|
|
258
|
+
get() {
|
|
259
|
+
return 'UI-SLIDER';
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
value: {
|
|
263
|
+
get(this: IUiSliderElement) {
|
|
264
|
+
return CustomElement.for<UiSlider>(this).viewModel.value;
|
|
265
|
+
},
|
|
266
|
+
set(this: IUiSliderElement, value: number) {
|
|
267
|
+
CustomElement.for<UiSlider>(this).viewModel.value = Number(value);
|
|
268
|
+
},
|
|
269
|
+
configurable: true
|
|
270
|
+
},
|
|
271
|
+
disabled: {
|
|
272
|
+
get(this: IUiSliderElement) {
|
|
273
|
+
return CustomElement.for<UiSlider>(this).viewModel.disabled;
|
|
274
|
+
},
|
|
275
|
+
set(this: IUiSliderElement, value: boolean) {
|
|
276
|
+
CustomElement.for<UiSlider>(this).viewModel.disabled = value;
|
|
277
|
+
},
|
|
278
|
+
configurable: true
|
|
279
|
+
},
|
|
280
|
+
endValue: {
|
|
281
|
+
get(this: IUiSliderElement) {
|
|
282
|
+
return CustomElement.for<UiSlider>(this).viewModel.endValue;
|
|
283
|
+
},
|
|
284
|
+
set(this: IUiSliderElement, value: number) {
|
|
285
|
+
CustomElement.for<UiSlider>(this).viewModel.endValue = Number(value);
|
|
286
|
+
},
|
|
287
|
+
configurable: true
|
|
288
|
+
},
|
|
289
|
+
readOnly: {
|
|
290
|
+
get(this: IUiSliderElement) {
|
|
291
|
+
return CustomElement.for<UiSlider>(this).viewModel.readonly;
|
|
292
|
+
},
|
|
293
|
+
set(this: IUiSliderElement, value: boolean) {
|
|
294
|
+
CustomElement.for<UiSlider>(this).viewModel.readonly = value;
|
|
295
|
+
},
|
|
296
|
+
configurable: true
|
|
297
|
+
},
|
|
298
|
+
addError: {
|
|
299
|
+
value(this: IUiSliderElement, error: IError) {
|
|
300
|
+
CustomElement.for<UiSlider>(this).viewModel.addError(error);
|
|
301
|
+
},
|
|
302
|
+
configurable: true
|
|
303
|
+
},
|
|
304
|
+
removeError: {
|
|
305
|
+
value(this: IUiSliderElement, error: IError) {
|
|
306
|
+
CustomElement.for<UiSlider>(this).viewModel.removeError(error);
|
|
307
|
+
},
|
|
308
|
+
configurable: true
|
|
309
|
+
},
|
|
310
|
+
focus: {
|
|
311
|
+
value(this: IUiSliderElement) {
|
|
312
|
+
CustomElement.for<UiSlider>(this).viewModel.inputEl.focus();
|
|
313
|
+
},
|
|
314
|
+
configurable: true
|
|
315
|
+
},
|
|
316
|
+
blur: {
|
|
317
|
+
value(this: IUiSliderElement) {
|
|
318
|
+
CustomElement.for<UiSlider>(this).viewModel.inputEl.blur();
|
|
319
|
+
},
|
|
320
|
+
configurable: true
|
|
321
|
+
},
|
|
322
|
+
isFocused: {
|
|
323
|
+
get(this: IUiSliderElement) {
|
|
324
|
+
return document.activeElement === CustomElement.for<UiSlider>(this).viewModel.inputEl;
|
|
325
|
+
},
|
|
326
|
+
configurable: true
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template class="ui-splitter"
|
|
2
|
+
role="separator"
|
|
3
|
+
tabindex.bind="disabled ? -1 : 0"
|
|
4
|
+
aria-orientation.attr="direction"
|
|
5
|
+
aria-valuemin.attr="min"
|
|
6
|
+
aria-valuemax.attr="max"
|
|
7
|
+
aria-valuenow.attr="valueNow"
|
|
8
|
+
aria-disabled.attr="disabled ? 'true' : null"
|
|
9
|
+
data-direction.attr="direction"
|
|
10
|
+
data-disabled.attr="disabled ? '' : null"
|
|
11
|
+
pointerdown.trigger="onPointerDown($event)"
|
|
12
|
+
keydown.trigger="onKeyDown($event)">
|
|
13
|
+
<span class="ui-splitter__handle" aria-hidden="true"></span>
|
|
14
|
+
</template>
|