@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,116 @@
|
|
|
1
|
+
import { DialogCloseResult, IDialogService } from '@aurelia/dialog';
|
|
2
|
+
import { resolve } from 'aurelia';
|
|
3
|
+
import { AlertConfiguration } from './alert-configuration';
|
|
4
|
+
import { AlertModal } from './alert-modal/alert-modal';
|
|
5
|
+
import { IAlertModalPayload } from './alert-modal/i-alert-modal-payload';
|
|
6
|
+
import { ExceptionsTracker } from './exceptions-tracker';
|
|
7
|
+
import { IPromptDialogData, PromptDialog } from './prompt-dialog/prompt-dialog';
|
|
8
|
+
|
|
9
|
+
export class AlertService {
|
|
10
|
+
private readonly dialogService = resolve(IDialogService);
|
|
11
|
+
private readonly exceptionsTracker = resolve(ExceptionsTracker);
|
|
12
|
+
private readonly configuration = resolve(AlertConfiguration);
|
|
13
|
+
private progressDepth: number = 0;
|
|
14
|
+
|
|
15
|
+
showProgress(): void {
|
|
16
|
+
this.progressDepth++;
|
|
17
|
+
document.dispatchEvent(new CustomEvent('alert-service:progress', { detail: { busy: true } }));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
hideProgress(): void {
|
|
21
|
+
this.progressDepth = Math.max(0, this.progressDepth - 1);
|
|
22
|
+
document.dispatchEvent(new CustomEvent('alert-service:progress', { detail: { busy: this.progressDepth > 0 } }));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async usingProgress<T, E = never>(action: () => Promise<T>, catchHandler?: (e: unknown) => Promise<E> | E): Promise<T | E> {
|
|
26
|
+
try {
|
|
27
|
+
this.showProgress();
|
|
28
|
+
return await action();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
if (catchHandler) {
|
|
31
|
+
return await catchHandler(e);
|
|
32
|
+
}
|
|
33
|
+
throw e;
|
|
34
|
+
} finally {
|
|
35
|
+
this.hideProgress();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async showModal(model: Partial<IAlertModalPayload>): Promise<string | undefined> {
|
|
40
|
+
const payload: IAlertModalPayload = { ...model };
|
|
41
|
+
const result = await this.dialogService.open({
|
|
42
|
+
component: () => this.configuration.defaultAlertModal || AlertModal,
|
|
43
|
+
model: payload,
|
|
44
|
+
rejectOnCancel: false,
|
|
45
|
+
options: { modal: true, closedby: 'closerequest' }
|
|
46
|
+
}).whenClosed() as DialogCloseResult;
|
|
47
|
+
return typeof result.value === 'string' ? result.value : undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async alert(message: string | Partial<IAlertModalPayload>): Promise<boolean> {
|
|
51
|
+
const payload = typeof message === 'string' ? { message } : message;
|
|
52
|
+
const model: IAlertModalPayload = {
|
|
53
|
+
icon: 'i',
|
|
54
|
+
tone: 'info',
|
|
55
|
+
button2Text: this.configuration.okText,
|
|
56
|
+
button2Action: 'ok',
|
|
57
|
+
defaultAction: 'ok',
|
|
58
|
+
successAction: 'ok',
|
|
59
|
+
...payload
|
|
60
|
+
};
|
|
61
|
+
return await this.showModal(model) === model.successAction;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async confirm(message: string | Partial<IAlertModalPayload>): Promise<boolean> {
|
|
65
|
+
const payload = typeof message === 'string' ? { message } : message;
|
|
66
|
+
const model: IAlertModalPayload = payload.defensive
|
|
67
|
+
? {
|
|
68
|
+
icon: '?',
|
|
69
|
+
tone: 'warning',
|
|
70
|
+
button1Text: this.configuration.yesText,
|
|
71
|
+
button1Action: 'yes',
|
|
72
|
+
button2Text: this.configuration.noText,
|
|
73
|
+
button2Action: 'no',
|
|
74
|
+
defaultAction: 'no',
|
|
75
|
+
successAction: 'yes',
|
|
76
|
+
...payload
|
|
77
|
+
}
|
|
78
|
+
: {
|
|
79
|
+
icon: '?',
|
|
80
|
+
tone: 'info',
|
|
81
|
+
button1Text: this.configuration.noText,
|
|
82
|
+
button1Action: 'no',
|
|
83
|
+
button2Text: this.configuration.yesText,
|
|
84
|
+
button2Action: 'yes',
|
|
85
|
+
defaultAction: 'yes',
|
|
86
|
+
successAction: 'yes',
|
|
87
|
+
...payload
|
|
88
|
+
};
|
|
89
|
+
return await this.showModal(model) === model.successAction;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async prompt(data: Partial<IPromptDialogData>): Promise<boolean> {
|
|
93
|
+
data.okText ??= this.configuration.okText;
|
|
94
|
+
data.cancelText ??= this.configuration.cancelText;
|
|
95
|
+
const result = await this.dialogService.open({
|
|
96
|
+
component: () => this.configuration.defaultPromptDialog || PromptDialog,
|
|
97
|
+
model: data,
|
|
98
|
+
rejectOnCancel: false,
|
|
99
|
+
options: { modal: true, closedby: 'closerequest' }
|
|
100
|
+
}).whenClosed() as DialogCloseResult;
|
|
101
|
+
if (result.status === 'ok' && typeof result.value === 'string') {
|
|
102
|
+
data.text = result.value;
|
|
103
|
+
}
|
|
104
|
+
return result.status === 'ok';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async error(message: string | Partial<IAlertModalPayload>): Promise<boolean> {
|
|
108
|
+
const payload = typeof message === 'string' ? { message } : message;
|
|
109
|
+
return this.alert({ icon: '!', tone: 'danger', ...payload });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async criticalError(message: string | Partial<IAlertModalPayload>, error: Error): Promise<boolean> {
|
|
113
|
+
this.exceptionsTracker.track(error);
|
|
114
|
+
return this.error(message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IAlertModalPayload } from '../alert-modal/i-alert-modal-payload';
|
|
2
|
+
import { IWithAlertService } from './using-progress';
|
|
3
|
+
|
|
4
|
+
export function confirmAction(message: string | Partial<IAlertModalPayload>) {
|
|
5
|
+
return function actualDecorator<This extends IWithAlertService, Args extends unknown[], Return>(originalMethod: (this: This, ...args: Args) => Return,
|
|
6
|
+
_context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>) {
|
|
7
|
+
return async function replacementMethod(this: This, ...args: Args) {
|
|
8
|
+
if (!this.alertService) {
|
|
9
|
+
throw new Error('Did you forget to inject AlertService?');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (!await this.alertService.confirm(message)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return originalMethod.call(this, ...args);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IAlertModalPayload } from '../alert-modal/i-alert-modal-payload';
|
|
2
|
+
import { AlertService } from '../alert-service';
|
|
3
|
+
|
|
4
|
+
export interface IWithAlertService {
|
|
5
|
+
alertService: AlertService;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function usingProgress(errorMessage?: string | Partial<IAlertModalPayload> | ((e: unknown) => string | Partial<IAlertModalPayload>)) {
|
|
9
|
+
return function actualDecorator<This extends IWithAlertService, Args extends unknown[], Return>(originalMethod: (this: This, ...args: Args) => Return,
|
|
10
|
+
_context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>) {
|
|
11
|
+
return function replacementMethod(this: This, ...args: Args) {
|
|
12
|
+
if (!this.alertService) {
|
|
13
|
+
throw new Error('Did you forget to inject AlertService?');
|
|
14
|
+
}
|
|
15
|
+
return this.alertService.usingProgress(async () => {
|
|
16
|
+
return await originalMethod.call(this, ...args);
|
|
17
|
+
}, async e => {
|
|
18
|
+
const message = errorMessage instanceof Function ? errorMessage(e) : errorMessage;
|
|
19
|
+
await this.alertService.criticalError(message ?? errorToMessage(e), errorToError(e));
|
|
20
|
+
throw e;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function errorToMessage(error: unknown): string {
|
|
27
|
+
return error instanceof Error ? error.message : String(error);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function errorToError(error: unknown): Error {
|
|
31
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template class="prompt-dialog">
|
|
2
|
+
<h2 class="prompt-dialog__title" if.bind="data.title">${data.title}</h2>
|
|
3
|
+
<label class="prompt-dialog__field">
|
|
4
|
+
<span class="prompt-dialog__label" if.bind="data.label">${data.label}</span>
|
|
5
|
+
<textarea class="prompt-dialog__control" if.bind="data.textarea" value.bind="data.text" required.bind="data.required" autofocus></textarea>
|
|
6
|
+
<input class="prompt-dialog__control" else type="text" value.bind="data.text" required.bind="data.required" autofocus>
|
|
7
|
+
</label>
|
|
8
|
+
<div class="prompt-dialog__error" if.bind="invalid">This field is required.</div>
|
|
9
|
+
<div class="prompt-dialog__actions">
|
|
10
|
+
<button ui-button outlined type="button" if.bind="data.cancelText" click.trigger="cancel()">${data.cancelText}</button>
|
|
11
|
+
<button ui-button primary type="button" if.bind="data.okText" click.trigger="ok()">${data.okText}</button>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IDialogController } from '@aurelia/dialog';
|
|
2
|
+
import { customElement, resolve } from 'aurelia';
|
|
3
|
+
import template from './prompt-dialog.html?raw';
|
|
4
|
+
|
|
5
|
+
export interface IPromptDialogData {
|
|
6
|
+
title?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
textarea?: boolean;
|
|
11
|
+
okText?: string;
|
|
12
|
+
cancelText?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@customElement({ name: 'prompt-dialog', template })
|
|
16
|
+
export class PromptDialog {
|
|
17
|
+
private readonly dialog = resolve(IDialogController);
|
|
18
|
+
|
|
19
|
+
data: IPromptDialogData = {};
|
|
20
|
+
invalid: boolean = false;
|
|
21
|
+
|
|
22
|
+
activate(data: IPromptDialogData): void {
|
|
23
|
+
this.data = data;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
cancel(): Promise<unknown> {
|
|
27
|
+
return this.dialog.cancel();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ok(): Promise<unknown> | void {
|
|
31
|
+
this.invalid = !!this.data.required && !this.data.text?.trim();
|
|
32
|
+
if (this.invalid) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
return this.dialog.ok(this.data.text ?? '');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { bindable, customElement } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import template from './ui-badge.html?raw';
|
|
4
|
+
|
|
5
|
+
type BadgeTone = 'neutral' | 'primary' | 'success' | 'warning' | 'danger';
|
|
6
|
+
|
|
7
|
+
@customElement({ name: 'ui-badge', template })
|
|
8
|
+
export class UiBadge {
|
|
9
|
+
@bindable
|
|
10
|
+
tone: BadgeTone = 'neutral';
|
|
11
|
+
|
|
12
|
+
@bindable({ set: booleanAttr })
|
|
13
|
+
pill = false;
|
|
14
|
+
|
|
15
|
+
@bindable({ set: booleanAttr })
|
|
16
|
+
outlined = false;
|
|
17
|
+
}
|
package/src/base/keys.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<template class="ui-breadcrumbs">
|
|
2
|
+
<nav class="ui-breadcrumbs__nav" aria-label="Breadcrumb">
|
|
3
|
+
<ol class="ui-breadcrumbs__list">
|
|
4
|
+
<li class="ui-breadcrumbs__item" repeat.for="item of items" data-current.attr="item.current ? '' : null">
|
|
5
|
+
<a class="ui-breadcrumbs__link" if.bind="item.href && !item.current" href.bind="item.href">${item.label}</a>
|
|
6
|
+
<span class="ui-breadcrumbs__current" else aria-current.bind="item.current ? 'page' : null">${item.label}</span>
|
|
7
|
+
</li>
|
|
8
|
+
</ol>
|
|
9
|
+
</nav>
|
|
10
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { bindable, customElement } from 'aurelia';
|
|
2
|
+
import template from './ui-breadcrumbs.html?raw';
|
|
3
|
+
|
|
4
|
+
export interface UiBreadcrumbItem {
|
|
5
|
+
label: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
current?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@customElement({ name: 'ui-breadcrumbs', template })
|
|
11
|
+
export class UiBreadcrumbs {
|
|
12
|
+
@bindable
|
|
13
|
+
items: readonly UiBreadcrumbItem[] = [];
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { templateCompilerHooks } from 'aurelia';
|
|
2
|
+
|
|
3
|
+
@templateCompilerHooks
|
|
4
|
+
export class EnhanceUiButton {
|
|
5
|
+
compiling(template: HTMLElement | HTMLTemplateElement) {
|
|
6
|
+
template.innerHTML = template.innerHTML.replace(/\sui-button(?:="")?(?=\s|>)/g, ' as-element="ui-button"');
|
|
7
|
+
template.innerHTML = template.innerHTML.replace(/\sui-icon-button(?:="")?(?=\s|>)/g, ' as-element="ui-icon-button"');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template class="ui-button"
|
|
2
|
+
role="button"
|
|
3
|
+
tabindex.bind="disabled ? -1 : 0"
|
|
4
|
+
aria-disabled.attr="disabled ? '' : null"
|
|
5
|
+
data-disabled.attr="disabled ? '' : null"
|
|
6
|
+
data-hover.attr="hover ? '' : null"
|
|
7
|
+
data-focus.attr="focus ? '' : null"
|
|
8
|
+
data-active.attr="active ? '' : null"
|
|
9
|
+
data-primary.attr="primary ? '' : null"
|
|
10
|
+
data-outlined.attr="outlined ? '' : null"
|
|
11
|
+
mouseenter.trigger="onMouseEnter()"
|
|
12
|
+
mouseleave.trigger="onMouseLeave()"
|
|
13
|
+
focusin.trigger="onFocusIn()"
|
|
14
|
+
focusout.trigger="onFocusOut()"
|
|
15
|
+
pointerdown.trigger="onPointerDown()"
|
|
16
|
+
pointerup.trigger="onPointerUp()"
|
|
17
|
+
pointerleave.trigger="onPointerLeave()"
|
|
18
|
+
click.trigger="onClick($event)">
|
|
19
|
+
<au-slot></au-slot>
|
|
20
|
+
</template>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { bindable, customElement } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import template from './ui-button.html?raw';
|
|
4
|
+
|
|
5
|
+
@customElement({ name: 'ui-button', template })
|
|
6
|
+
export class UiButton {
|
|
7
|
+
@bindable({ set: booleanAttr })
|
|
8
|
+
disabled: boolean = false;
|
|
9
|
+
|
|
10
|
+
@bindable({ set: booleanAttr })
|
|
11
|
+
primary: boolean = false;
|
|
12
|
+
|
|
13
|
+
@bindable({ set: booleanAttr })
|
|
14
|
+
outlined: boolean = false;
|
|
15
|
+
|
|
16
|
+
hover: boolean = false;
|
|
17
|
+
focus: boolean = false;
|
|
18
|
+
active: boolean = false;
|
|
19
|
+
|
|
20
|
+
onMouseEnter(): void {
|
|
21
|
+
if (!this.disabled) {
|
|
22
|
+
this.hover = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
onMouseLeave(): void {
|
|
27
|
+
this.hover = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onFocusIn(): void {
|
|
31
|
+
if (!this.disabled) {
|
|
32
|
+
this.focus = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
onFocusOut(): void {
|
|
37
|
+
this.focus = false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onPointerDown(): void {
|
|
41
|
+
if (!this.disabled) {
|
|
42
|
+
this.active = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
onPointerUp(): void {
|
|
47
|
+
this.active = false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
onPointerLeave(): void {
|
|
51
|
+
this.active = false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
onClick(event: MouseEvent): void {
|
|
55
|
+
if (this.disabled) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
event.stopImmediatePropagation();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template class="ui-icon-button"
|
|
2
|
+
role="button"
|
|
3
|
+
tabindex.bind="disabled ? -1 : 0"
|
|
4
|
+
aria-disabled.attr="disabled ? '' : null"
|
|
5
|
+
data-disabled.attr="disabled ? '' : null"
|
|
6
|
+
data-hover.attr="hover ? '' : null"
|
|
7
|
+
data-focus.attr="focus ? '' : null"
|
|
8
|
+
data-active.attr="active ? '' : null"
|
|
9
|
+
data-size.attr="size"
|
|
10
|
+
data-outlined.attr="outlined ? '' : null"
|
|
11
|
+
mouseenter.trigger="onMouseEnter()"
|
|
12
|
+
mouseleave.trigger="onMouseLeave()"
|
|
13
|
+
focusin.trigger="onFocusIn()"
|
|
14
|
+
focusout.trigger="onFocusOut()"
|
|
15
|
+
pointerdown.trigger="onPointerDown()"
|
|
16
|
+
pointerup.trigger="onPointerUp()"
|
|
17
|
+
pointerleave.trigger="onPointerLeave()"
|
|
18
|
+
click.trigger="onClick($event)">
|
|
19
|
+
<au-slot></au-slot>
|
|
20
|
+
</template>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { bindable, customElement } from 'aurelia';
|
|
2
|
+
import { booleanAttr } from '../base/boolean-attr';
|
|
3
|
+
import template from './ui-icon-button.html?raw';
|
|
4
|
+
|
|
5
|
+
type IconButtonSize = 'small' | 'medium' | 'large';
|
|
6
|
+
|
|
7
|
+
@customElement({ name: 'ui-icon-button', template })
|
|
8
|
+
export class UiIconButton {
|
|
9
|
+
@bindable({ set: booleanAttr })
|
|
10
|
+
disabled: boolean = false;
|
|
11
|
+
|
|
12
|
+
@bindable
|
|
13
|
+
size: IconButtonSize = 'medium';
|
|
14
|
+
|
|
15
|
+
@bindable({ set: booleanAttr })
|
|
16
|
+
outlined: boolean = false;
|
|
17
|
+
|
|
18
|
+
hover: boolean = false;
|
|
19
|
+
focus: boolean = false;
|
|
20
|
+
active: boolean = false;
|
|
21
|
+
|
|
22
|
+
onMouseEnter(): void {
|
|
23
|
+
if (!this.disabled) {
|
|
24
|
+
this.hover = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onMouseLeave(): void {
|
|
29
|
+
this.hover = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onFocusIn(): void {
|
|
33
|
+
if (!this.disabled) {
|
|
34
|
+
this.focus = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
onFocusOut(): void {
|
|
39
|
+
this.focus = false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
onPointerDown(): void {
|
|
43
|
+
if (!this.disabled) {
|
|
44
|
+
this.active = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onPointerUp(): void {
|
|
49
|
+
this.active = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
onPointerLeave(): void {
|
|
53
|
+
this.active = false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onClick(event: MouseEvent): void {
|
|
57
|
+
if (this.disabled) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
event.stopImmediatePropagation();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template class="ui-checkbox"
|
|
2
|
+
role="checkbox"
|
|
3
|
+
tabindex.bind="disabled ? null : tabIndex"
|
|
4
|
+
aria-checked.attr="indeterminate ? 'mixed' : checked ? 'true' : 'false'"
|
|
5
|
+
aria-disabled.attr="disabled ? '' : null"
|
|
6
|
+
data-checked.attr="checked ? '' : null"
|
|
7
|
+
data-disabled.attr="disabled ? '' : null"
|
|
8
|
+
data-indeterminate.attr="indeterminate ? '' : null"
|
|
9
|
+
data-hover.attr="hover ? '' : null"
|
|
10
|
+
data-focus.attr="focus ? '' : null"
|
|
11
|
+
data-active.attr="active ? '' : null"
|
|
12
|
+
data-changing.attr="changing ? '' : null"
|
|
13
|
+
click.trigger="onClick($event)"
|
|
14
|
+
keyup.trigger="onKeyUp($event)"
|
|
15
|
+
keypress.trigger="onKeyPress($event)"
|
|
16
|
+
mouseenter.trigger="onMouseEnter()"
|
|
17
|
+
mouseleave.trigger="onMouseLeave()"
|
|
18
|
+
focusin.trigger="onFocusIn()"
|
|
19
|
+
focusout.trigger="onFocusOut()"
|
|
20
|
+
pointerdown.trigger="onPointerDown()"
|
|
21
|
+
pointerup.trigger="onPointerUp()"
|
|
22
|
+
pointerleave.trigger="onPointerLeave()">
|
|
23
|
+
<input ref="controlEl"
|
|
24
|
+
class="ui-checkbox__control"
|
|
25
|
+
type="checkbox"
|
|
26
|
+
id.attr="id || null"
|
|
27
|
+
checked.bind="checked"
|
|
28
|
+
disabled.bind="disabled"
|
|
29
|
+
click.trigger="onInputClick($event)"
|
|
30
|
+
change.trigger="onInputChange($event)">
|
|
31
|
+
<span class="ui-checkbox__indicator" aria-hidden="true"></span>
|
|
32
|
+
</template>
|