@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,188 @@
|
|
|
1
|
+
import { bindable, BindingMode, customElement } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import { Keys } from '../base/keys';
|
|
4
|
+
import template from './ui-checkbox.html?raw';
|
|
5
|
+
|
|
6
|
+
@customElement({ name: 'ui-checkbox', template })
|
|
7
|
+
export class UiCheckbox {
|
|
8
|
+
@bindable({ mode: BindingMode.twoWay, set: booleanAttr })
|
|
9
|
+
checked: boolean = false;
|
|
10
|
+
|
|
11
|
+
@bindable({ set: booleanAttr })
|
|
12
|
+
disabled: boolean = false;
|
|
13
|
+
|
|
14
|
+
@bindable({ mode: BindingMode.twoWay, set: booleanAttr })
|
|
15
|
+
indeterminate: boolean = false;
|
|
16
|
+
|
|
17
|
+
@bindable
|
|
18
|
+
id: string = '';
|
|
19
|
+
|
|
20
|
+
@bindable
|
|
21
|
+
tabIndex: number = 0;
|
|
22
|
+
|
|
23
|
+
hover: boolean = false;
|
|
24
|
+
focus: boolean = false;
|
|
25
|
+
active: boolean = false;
|
|
26
|
+
changing: boolean = false;
|
|
27
|
+
|
|
28
|
+
controlEl!: HTMLInputElement;
|
|
29
|
+
|
|
30
|
+
private changingFrame: number | undefined;
|
|
31
|
+
|
|
32
|
+
onClick(event: MouseEvent): void {
|
|
33
|
+
if (event.target instanceof HTMLInputElement) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
this.toggle();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onInputClick(event: MouseEvent): void {
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
onInputChange(event: Event): void {
|
|
46
|
+
if (!(event.target instanceof HTMLInputElement) || this.disabled) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.changing = true;
|
|
51
|
+
this.checked = event.target.checked;
|
|
52
|
+
this.indeterminate = false;
|
|
53
|
+
|
|
54
|
+
if (this.changingFrame) {
|
|
55
|
+
cancelAnimationFrame(this.changingFrame);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.changingFrame = requestAnimationFrame(() => {
|
|
59
|
+
this.changing = false;
|
|
60
|
+
this.changingFrame = undefined;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onKeyUp(event: KeyboardEvent): void {
|
|
65
|
+
if (this.disabled) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (event.key === Keys.Space) {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
this.toggle();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (event.key === Keys.Enter) {
|
|
76
|
+
this.submitClosestForm(event.currentTarget);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onKeyPress(event: KeyboardEvent): void {
|
|
81
|
+
if (event.key === Keys.Space || event.key === Keys.Enter) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
onMouseEnter(): void {
|
|
87
|
+
if (!this.disabled) {
|
|
88
|
+
this.hover = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onMouseLeave(): void {
|
|
93
|
+
this.hover = false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onFocusIn(): void {
|
|
97
|
+
if (!this.disabled) {
|
|
98
|
+
this.focus = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
onFocusOut(): void {
|
|
103
|
+
this.focus = false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onPointerDown(): void {
|
|
107
|
+
if (!this.disabled) {
|
|
108
|
+
this.active = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
onPointerUp(): void {
|
|
113
|
+
this.active = false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
onPointerLeave(): void {
|
|
117
|
+
this.active = false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
detaching(): void {
|
|
121
|
+
if (this.changingFrame) {
|
|
122
|
+
cancelAnimationFrame(this.changingFrame);
|
|
123
|
+
this.changingFrame = undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
attached(): void {
|
|
128
|
+
this.syncControlIndeterminate();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
indeterminateChanged(): void {
|
|
132
|
+
this.syncControlIndeterminate();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private toggle(): void {
|
|
136
|
+
if (this.disabled) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.changing = true;
|
|
141
|
+
if (this.indeterminate) {
|
|
142
|
+
this.indeterminate = false;
|
|
143
|
+
this.checked = true;
|
|
144
|
+
} else {
|
|
145
|
+
this.checked = !this.checked;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.dispatchValueEvent('input');
|
|
149
|
+
this.dispatchValueEvent('change');
|
|
150
|
+
|
|
151
|
+
if (this.changingFrame) {
|
|
152
|
+
cancelAnimationFrame(this.changingFrame);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
this.changingFrame = requestAnimationFrame(() => {
|
|
156
|
+
this.changing = false;
|
|
157
|
+
this.changingFrame = undefined;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private submitClosestForm(target: EventTarget | null): void {
|
|
162
|
+
const element = target instanceof HTMLElement ? target : null;
|
|
163
|
+
const form = element?.closest('form');
|
|
164
|
+
|
|
165
|
+
if (!form || this.disabled) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (typeof form.requestSubmit === 'function') {
|
|
170
|
+
form.requestSubmit();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
form.submit();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private syncControlIndeterminate(): void {
|
|
178
|
+
if (this.controlEl) {
|
|
179
|
+
this.controlEl.indeterminate = this.indeterminate;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private dispatchValueEvent(type: 'input' | 'change'): void {
|
|
184
|
+
this.controlEl.checked = this.checked;
|
|
185
|
+
this.controlEl.indeterminate = this.indeterminate;
|
|
186
|
+
this.controlEl.dispatchEvent(new Event(type, { bubbles: true }));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template class="ui-chip"
|
|
2
|
+
role="button"
|
|
3
|
+
tabindex.bind="disabled ? -1 : 0"
|
|
4
|
+
aria-pressed.attr="selected ? 'true' : 'false'"
|
|
5
|
+
aria-disabled.attr="disabled ? 'true' : null"
|
|
6
|
+
data-tone.attr="tone"
|
|
7
|
+
data-selected.attr="selected ? '' : null"
|
|
8
|
+
data-disabled.attr="disabled ? '' : null"
|
|
9
|
+
data-removable.attr="removable ? '' : null"
|
|
10
|
+
data-hover.attr="hover ? '' : null"
|
|
11
|
+
data-focus.attr="focus ? '' : null"
|
|
12
|
+
data-active.attr="active ? '' : null"
|
|
13
|
+
click.trigger="onClick($event)"
|
|
14
|
+
keydown.trigger="onKeyDown($event)"
|
|
15
|
+
mouseenter.trigger="onMouseEnter()"
|
|
16
|
+
mouseleave.trigger="onMouseLeave()"
|
|
17
|
+
focusin.trigger="onFocusIn()"
|
|
18
|
+
focusout.trigger="onFocusOut()"
|
|
19
|
+
pointerdown.trigger="onPointerDown()"
|
|
20
|
+
pointerup.trigger="onPointerUp()"
|
|
21
|
+
pointerleave.trigger="onPointerLeave()">
|
|
22
|
+
<span class="ui-chip__content"><au-slot></au-slot></span>
|
|
23
|
+
<button class="ui-chip__remove"
|
|
24
|
+
if.bind="removable"
|
|
25
|
+
type="button"
|
|
26
|
+
tabindex="-1"
|
|
27
|
+
aria-label="Remove"
|
|
28
|
+
disabled.bind="disabled"
|
|
29
|
+
click.trigger="onRemoveClick($event)">
|
|
30
|
+
<span class="ui-chip__remove-icon" aria-hidden="true"></span>
|
|
31
|
+
</button>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { bindable, BindingMode, customElement, INode, resolve } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import { Keys } from '../base/keys';
|
|
4
|
+
import template from './ui-chip.html?raw';
|
|
5
|
+
|
|
6
|
+
type ChipTone = 'neutral' | 'primary' | 'success' | 'warning' | 'danger';
|
|
7
|
+
|
|
8
|
+
@customElement({ name: 'ui-chip', template })
|
|
9
|
+
export class UiChip {
|
|
10
|
+
private readonly host = resolve(INode) as HTMLElement;
|
|
11
|
+
|
|
12
|
+
@bindable({ mode: BindingMode.twoWay, set: booleanAttr })
|
|
13
|
+
selected = false;
|
|
14
|
+
|
|
15
|
+
@bindable({ set: booleanAttr })
|
|
16
|
+
disabled = false;
|
|
17
|
+
|
|
18
|
+
@bindable({ set: booleanAttr })
|
|
19
|
+
removable = false;
|
|
20
|
+
|
|
21
|
+
@bindable
|
|
22
|
+
value: unknown;
|
|
23
|
+
|
|
24
|
+
@bindable
|
|
25
|
+
tone: ChipTone = 'neutral';
|
|
26
|
+
|
|
27
|
+
hover = false;
|
|
28
|
+
focus = false;
|
|
29
|
+
active = false;
|
|
30
|
+
|
|
31
|
+
onClick(event: MouseEvent): void {
|
|
32
|
+
if (this.disabled || this.isRemoveTarget(event.target)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.toggleSelected();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onKeyDown(event: KeyboardEvent): void {
|
|
40
|
+
if (this.disabled) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (event.key === Keys.Space || event.key === Keys.Enter) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
this.toggleSelected();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (this.removable && (event.key === 'Backspace' || event.key === 'Delete')) {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
this.remove();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onRemoveClick(event: MouseEvent): void {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
this.remove();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onMouseEnter(): void {
|
|
63
|
+
if (!this.disabled) {
|
|
64
|
+
this.hover = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onMouseLeave(): void {
|
|
69
|
+
this.hover = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
onFocusIn(): void {
|
|
73
|
+
if (!this.disabled) {
|
|
74
|
+
this.focus = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
onFocusOut(): void {
|
|
79
|
+
this.focus = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onPointerDown(): void {
|
|
83
|
+
if (!this.disabled) {
|
|
84
|
+
this.active = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
onPointerUp(): void {
|
|
89
|
+
this.active = false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onPointerLeave(): void {
|
|
93
|
+
this.active = false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private toggleSelected(): void {
|
|
97
|
+
this.selected = !this.selected;
|
|
98
|
+
this.host.dispatchEvent(new CustomEvent('chip-select', {
|
|
99
|
+
bubbles: true,
|
|
100
|
+
detail: { selected: this.selected, value: this.value }
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private remove(): void {
|
|
105
|
+
if (this.disabled || !this.removable) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.host.dispatchEvent(new CustomEvent('chip-remove', {
|
|
110
|
+
bubbles: true,
|
|
111
|
+
detail: { value: this.value }
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private isRemoveTarget(target: EventTarget | null): boolean {
|
|
116
|
+
return target instanceof HTMLElement && !!target.closest('.ui-chip__remove');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { templateCompilerHooks } from 'aurelia';
|
|
2
|
+
|
|
3
|
+
@templateCompilerHooks
|
|
4
|
+
export class EnhanceUiCombobox {
|
|
5
|
+
compiling(template: HTMLElement | HTMLTemplateElement) {
|
|
6
|
+
template.innerHTML = template.innerHTML
|
|
7
|
+
.replaceAll('<ui-combobox ', '<label as-element="ui-combobox" ui-combobox-element ')
|
|
8
|
+
.replaceAll('</ui-combobox>', '</label>');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template class="ui-combobox"
|
|
2
|
+
data-disabled.attr="disabled ? '' : null"
|
|
3
|
+
data-invalid.attr="invalid || errors.size ? '' : null"
|
|
4
|
+
data-focus.attr="focus ? '' : null"
|
|
5
|
+
data-active.attr="active ? '' : null"
|
|
6
|
+
data-open.attr="open ? '' : null"
|
|
7
|
+
data-inset.attr="inset ? '' : null"
|
|
8
|
+
data-has-value.attr="hasValue ? '' : null">
|
|
9
|
+
<label class="ui-combobox__label"
|
|
10
|
+
for.bind="id"
|
|
11
|
+
id.bind="!inset && label ? labelId : null"
|
|
12
|
+
show.bind="label && !inset">${label}</label>
|
|
13
|
+
|
|
14
|
+
<div class="ui-combobox__control" ref="controlEl">
|
|
15
|
+
<span class="ui-combobox__leading" show.bind="leadingNodes.length">
|
|
16
|
+
<au-slot name="leading"></au-slot>
|
|
17
|
+
</span>
|
|
18
|
+
|
|
19
|
+
<span class="ui-combobox__inset-label"
|
|
20
|
+
id.bind="inset && label ? labelId : null"
|
|
21
|
+
show.bind="label && inset">${label}</span>
|
|
22
|
+
|
|
23
|
+
<input ref="inputEl"
|
|
24
|
+
class="ui-combobox__native"
|
|
25
|
+
id.bind="id"
|
|
26
|
+
name.attr="name || null"
|
|
27
|
+
value.bind="textValue"
|
|
28
|
+
placeholder.attr="placeholderText || null"
|
|
29
|
+
autocomplete.attr="autocomplete || null"
|
|
30
|
+
disabled.bind="disabled"
|
|
31
|
+
readonly.bind="readonly"
|
|
32
|
+
required.bind="required"
|
|
33
|
+
role="combobox"
|
|
34
|
+
aria-haspopup="listbox"
|
|
35
|
+
aria-expanded.attr="open ? 'true' : 'false'"
|
|
36
|
+
aria-labelledby.bind="label ? labelId : null"
|
|
37
|
+
aria-invalid.bind="invalid || errors.size ? 'true' : 'false'"
|
|
38
|
+
aria-describedby.bind="errors.size ? errorsId : (helperNodes.length ? helperId : null)"
|
|
39
|
+
input.trigger="onInput()"
|
|
40
|
+
keydown.trigger="onKeyDown($event)"
|
|
41
|
+
focusin.trigger="onFocusIn()"
|
|
42
|
+
focusout.trigger="onFocusOut($event)"
|
|
43
|
+
pointerdown.trigger="onPointerDown()"
|
|
44
|
+
pointerup.trigger="onPointerUp()"
|
|
45
|
+
pointerleave.trigger="onPointerLeave()">
|
|
46
|
+
|
|
47
|
+
<span class="ui-combobox__trailing">
|
|
48
|
+
<au-slot name="trailing">
|
|
49
|
+
<span class="ui-combobox__chevron" aria-hidden="true"></span>
|
|
50
|
+
</au-slot>
|
|
51
|
+
</span>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<ui-menu component.ref="menu"
|
|
55
|
+
open.bind="open"
|
|
56
|
+
anchor.bind="controlEl"
|
|
57
|
+
tab-reference.bind="inputEl"
|
|
58
|
+
match-anchor-width
|
|
59
|
+
focus-on-open.bind="false"
|
|
60
|
+
restore-focus.bind="false"
|
|
61
|
+
exposed-host.bind="slotHost"
|
|
62
|
+
menu-tab-away.trigger="onMenuTabAway()"
|
|
63
|
+
menu-select.trigger="onMenuSelect($event)">
|
|
64
|
+
<au-slot expose.bind="slotHost"></au-slot>
|
|
65
|
+
</ui-menu>
|
|
66
|
+
|
|
67
|
+
<div class="ui-combobox__subscript" show.bind="errors.size || helperText || helperNodes.length">
|
|
68
|
+
<div class="ui-combobox__helper" id.bind="helperId" show.bind="!errors.size && (helperText || helperNodes.length)">
|
|
69
|
+
<au-slot name="helper">${helperText}</au-slot>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div class="ui-combobox__errors" id.bind="errorsId" show.bind="errors.size">
|
|
73
|
+
<div class="ui-combobox__error" repeat.for="[error, _] of errors" if.bind="error.message">${error.message}</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|