@bexis2/bexis2-core-ui 0.2.17 → 0.2.19
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/README.md +306 -293
- package/dist/components/file/FileUploader.svelte +34 -34
- package/dist/components/form/MultiSelect.svelte +69 -59
- package/dist/components/page/Notification.svelte +8 -0
- package/dist/components/page/Notification.svelte.d.ts +14 -0
- package/dist/components/page/Page.svelte +2 -0
- package/dist/components/page/TablePlaceholder.svelte +16 -0
- package/dist/components/page/TablePlaceholder.svelte.d.ts +17 -0
- package/dist/components/page/menu/Menu.svelte +0 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -0
- package/dist/models/Enums.d.ts +6 -0
- package/dist/models/Enums.js +8 -0
- package/dist/models/Models.d.ts +10 -1
- package/dist/models/Models.js +1 -1
- package/dist/stores/pageStores.d.ts +13 -2
- package/dist/stores/pageStores.js +106 -0
- package/package.json +1 -1
- package/src/lib/components/file/FileUploader.svelte +189 -184
- package/src/lib/components/form/MultiSelect.svelte +69 -59
- package/src/lib/components/page/Notification.svelte +12 -0
- package/src/lib/components/page/Page.svelte +2 -0
- package/src/lib/components/page/TablePlaceholder.svelte +17 -0
- package/src/lib/components/page/menu/Menu.svelte +0 -1
- package/src/lib/index.ts +99 -78
- package/src/lib/models/Enums.ts +40 -32
- package/src/lib/models/Models.ts +19 -3
- package/src/lib/stores/pageStores.ts +240 -121
package/src/lib/index.ts
CHANGED
|
@@ -1,78 +1,99 @@
|
|
|
1
|
-
// Reexport your entry components here
|
|
2
|
-
// import ListView from './components/ListView.svelte';
|
|
3
|
-
// import TableView from './TableView.svelte';
|
|
4
|
-
|
|
5
|
-
import FileIcon from './components/file/FileIcon.svelte';
|
|
6
|
-
import FileInfo from './components/file/FileInfo.svelte';
|
|
7
|
-
import FileUploader from './components/file/FileUploader.svelte';
|
|
8
|
-
|
|
9
|
-
//page
|
|
10
|
-
import Spinner from './components/page/Spinner.svelte';
|
|
11
|
-
import Page from './components/page/Page.svelte';
|
|
12
|
-
import Alert from './components/page/Alert.svelte';
|
|
13
|
-
import Menu from './components/page/menu/Menu.svelte';
|
|
14
|
-
import ErrorMessage from './components/page/ErrorMessage.svelte';
|
|
15
|
-
|
|
16
|
-
// input
|
|
17
|
-
import Checkbox from './components/form/Checkbox.svelte';
|
|
18
|
-
import CheckboxKVPList from './components/form/CheckboxKvPList.svelte';
|
|
19
|
-
import CheckboxList from './components/form/CheckboxList.svelte';
|
|
20
|
-
import DateInput from './components/form/DateInput.svelte';
|
|
21
|
-
import DropdownKVP from './components/form/DropdownKvP.svelte';
|
|
22
|
-
import MultiSelect from './components/form/MultiSelect.svelte';
|
|
23
|
-
import NumberInput from './components/form/NumberInput.svelte';
|
|
24
|
-
import TextInput from './components/form/TextInput.svelte';
|
|
25
|
-
import TextArea from './components/form/TextArea.svelte';
|
|
26
|
-
|
|
27
|
-
//table
|
|
28
|
-
import Table from './components/Table/Table.svelte';
|
|
29
|
-
import TableFilter from './components/Table/TableFilter.svelte';
|
|
30
|
-
import { columnFilter, searchFilter } from './components/Table/filter';
|
|
31
|
-
import type { TableConfig, Columns, Column } from './models/Models';
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
export {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export {
|
|
78
|
-
|
|
1
|
+
// Reexport your entry components here
|
|
2
|
+
// import ListView from './components/ListView.svelte';
|
|
3
|
+
// import TableView from './TableView.svelte';
|
|
4
|
+
|
|
5
|
+
import FileIcon from './components/file/FileIcon.svelte';
|
|
6
|
+
import FileInfo from './components/file/FileInfo.svelte';
|
|
7
|
+
import FileUploader from './components/file/FileUploader.svelte';
|
|
8
|
+
|
|
9
|
+
//page
|
|
10
|
+
import Spinner from './components/page/Spinner.svelte';
|
|
11
|
+
import Page from './components/page/Page.svelte';
|
|
12
|
+
import Alert from './components/page/Alert.svelte';
|
|
13
|
+
import Menu from './components/page/menu/Menu.svelte';
|
|
14
|
+
import ErrorMessage from './components/page/ErrorMessage.svelte';
|
|
15
|
+
|
|
16
|
+
// input
|
|
17
|
+
import Checkbox from './components/form/Checkbox.svelte';
|
|
18
|
+
import CheckboxKVPList from './components/form/CheckboxKvPList.svelte';
|
|
19
|
+
import CheckboxList from './components/form/CheckboxList.svelte';
|
|
20
|
+
import DateInput from './components/form/DateInput.svelte';
|
|
21
|
+
import DropdownKVP from './components/form/DropdownKvP.svelte';
|
|
22
|
+
import MultiSelect from './components/form/MultiSelect.svelte';
|
|
23
|
+
import NumberInput from './components/form/NumberInput.svelte';
|
|
24
|
+
import TextInput from './components/form/TextInput.svelte';
|
|
25
|
+
import TextArea from './components/form/TextArea.svelte';
|
|
26
|
+
|
|
27
|
+
//table
|
|
28
|
+
import Table from './components/Table/Table.svelte';
|
|
29
|
+
import TableFilter from './components/Table/TableFilter.svelte';
|
|
30
|
+
import { columnFilter, searchFilter } from './components/Table/filter';
|
|
31
|
+
import type { TableConfig, Columns, Column } from './models/Models';
|
|
32
|
+
|
|
33
|
+
//notification
|
|
34
|
+
import Notification from './components/page/Notification.svelte';
|
|
35
|
+
|
|
36
|
+
//table placeholder
|
|
37
|
+
import TablePlaceholder from './components/page/TablePlaceholder.svelte';
|
|
38
|
+
|
|
39
|
+
//Form
|
|
40
|
+
export {
|
|
41
|
+
Checkbox,
|
|
42
|
+
CheckboxKVPList,
|
|
43
|
+
CheckboxList,
|
|
44
|
+
DateInput,
|
|
45
|
+
DropdownKVP,
|
|
46
|
+
MultiSelect,
|
|
47
|
+
NumberInput,
|
|
48
|
+
TextArea,
|
|
49
|
+
TextInput
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//File
|
|
53
|
+
export { FileInfo, FileIcon, FileUploader };
|
|
54
|
+
|
|
55
|
+
//others
|
|
56
|
+
export { Spinner, Page, Alert, Menu, ErrorMessage };
|
|
57
|
+
|
|
58
|
+
//Api
|
|
59
|
+
export { Api } from './services/Api.js';
|
|
60
|
+
export { host, username, password, setApiConfig } from './stores/apiStores.js';
|
|
61
|
+
|
|
62
|
+
//Type
|
|
63
|
+
export type {
|
|
64
|
+
userType,
|
|
65
|
+
inputType,
|
|
66
|
+
fileUploaderType,
|
|
67
|
+
linkType,
|
|
68
|
+
listItemType,
|
|
69
|
+
keyValuePairType,
|
|
70
|
+
fileInfoType,
|
|
71
|
+
fileReaderInfoType,
|
|
72
|
+
asciiFileReaderInfoType
|
|
73
|
+
} from './models/Models.js';
|
|
74
|
+
|
|
75
|
+
//help
|
|
76
|
+
export { helpStore } from '$store/pageStores';
|
|
77
|
+
export type { helpStoreType, helpItemType } from './models/Models';
|
|
78
|
+
|
|
79
|
+
//notification
|
|
80
|
+
export { notificationStore } from '$store/pageStores';
|
|
81
|
+
export type { notificationItemType, notificationStoreType } from './models/Models';
|
|
82
|
+
export { notificationType } from './models/Enums';
|
|
83
|
+
export { Notification };
|
|
84
|
+
|
|
85
|
+
//table placholder
|
|
86
|
+
export { TablePlaceholder };
|
|
87
|
+
//enum
|
|
88
|
+
export {
|
|
89
|
+
positionType,
|
|
90
|
+
pageContentLayoutType,
|
|
91
|
+
decimalCharacterType,
|
|
92
|
+
orientationType,
|
|
93
|
+
textMarkerType,
|
|
94
|
+
textSeperatorType
|
|
95
|
+
} from './models/Enums';
|
|
96
|
+
|
|
97
|
+
// Table
|
|
98
|
+
export { Table, TableFilter, columnFilter, searchFilter };
|
|
99
|
+
export type { TableConfig, Columns, Column };
|
package/src/lib/models/Enums.ts
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
export enum positionType {
|
|
2
|
-
start = 'start',
|
|
3
|
-
end = 'end',
|
|
4
|
-
center = 'center'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export enum pageContentLayoutType {
|
|
8
|
-
full = 'full',
|
|
9
|
-
center = 'center'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export enum decimalCharacterType {
|
|
13
|
-
point,
|
|
14
|
-
comma
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export enum orientationType {
|
|
18
|
-
columnwise,
|
|
19
|
-
rowwise
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export enum textSeperatorType {
|
|
23
|
-
tab = 9,
|
|
24
|
-
comma = 44,
|
|
25
|
-
semicolon = 59,
|
|
26
|
-
space = 32
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export enum textMarkerType {
|
|
30
|
-
quotes,
|
|
31
|
-
doubleQuotes
|
|
32
|
-
}
|
|
1
|
+
export enum positionType {
|
|
2
|
+
start = 'start',
|
|
3
|
+
end = 'end',
|
|
4
|
+
center = 'center'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum pageContentLayoutType {
|
|
8
|
+
full = 'full',
|
|
9
|
+
center = 'center'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export enum decimalCharacterType {
|
|
13
|
+
point,
|
|
14
|
+
comma
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum orientationType {
|
|
18
|
+
columnwise,
|
|
19
|
+
rowwise
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum textSeperatorType {
|
|
23
|
+
tab = 9,
|
|
24
|
+
comma = 44,
|
|
25
|
+
semicolon = 59,
|
|
26
|
+
space = 32
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum textMarkerType {
|
|
30
|
+
quotes,
|
|
31
|
+
doubleQuotes
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//types for the notification styling
|
|
35
|
+
export enum notificationType {
|
|
36
|
+
success,
|
|
37
|
+
warning,
|
|
38
|
+
error,
|
|
39
|
+
surface
|
|
40
|
+
}
|
package/src/lib/models/Models.ts
CHANGED
|
@@ -2,7 +2,13 @@ import type { SvelteComponent } from 'svelte';
|
|
|
2
2
|
import type { ColumnFilterFn } from 'svelte-headless-table/lib/plugins';
|
|
3
3
|
import type { Writable } from 'svelte/store';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
|
+
decimalCharacterType,
|
|
7
|
+
notificationType,
|
|
8
|
+
orientationType,
|
|
9
|
+
textMarkerType,
|
|
10
|
+
textSeperatorType
|
|
11
|
+
} from './Enums';
|
|
6
12
|
|
|
7
13
|
// page
|
|
8
14
|
export interface linkType {
|
|
@@ -43,7 +49,6 @@ export interface asciiFileReaderInfoType extends fileReaderInfoType {
|
|
|
43
49
|
textMarker: textMarkerType;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
|
|
47
52
|
export interface fileReaderInfoType {
|
|
48
53
|
decimal: decimalCharacterType;
|
|
49
54
|
orientation: orientationType;
|
|
@@ -55,7 +60,6 @@ export interface fileReaderInfoType {
|
|
|
55
60
|
dateformat: string;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
|
-
|
|
59
63
|
export interface filesType {
|
|
60
64
|
accepted: Blob[];
|
|
61
65
|
rejected: Blob[];
|
|
@@ -132,3 +136,15 @@ export interface helpStoreType {
|
|
|
132
136
|
itemId?: string;
|
|
133
137
|
helpItems: helpItemType[];
|
|
134
138
|
}
|
|
139
|
+
|
|
140
|
+
// notifications (toasts)
|
|
141
|
+
export interface notificationItemType {
|
|
142
|
+
notificationType?: notificationType;
|
|
143
|
+
message: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface notificationStoreType {
|
|
147
|
+
notificationType: notificationType;
|
|
148
|
+
message: string;
|
|
149
|
+
btnStyle: string;
|
|
150
|
+
}
|
|
@@ -1,121 +1,240 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
set
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
import { notificationType } from '$models/Enums';
|
|
2
|
+
import type {
|
|
3
|
+
helpItemType,
|
|
4
|
+
helpStoreType,
|
|
5
|
+
notificationItemType,
|
|
6
|
+
notificationStoreType
|
|
7
|
+
} from '$models/Models';
|
|
8
|
+
import type { MenuModel, breadcrumbItemType } from '$models/Page';
|
|
9
|
+
import { BreadcrumbModel } from '$models/Page';
|
|
10
|
+
import { toastStore, type ToastSettings } from '@skeletonlabs/skeleton';
|
|
11
|
+
import { writable, type Writable } from 'svelte/store';
|
|
12
|
+
|
|
13
|
+
function createHelpStore() {
|
|
14
|
+
// set Store Type
|
|
15
|
+
const { subscribe, set, update } = writable<helpStoreType>();
|
|
16
|
+
|
|
17
|
+
const h: helpItemType[] = [];
|
|
18
|
+
let v: helpStoreType;
|
|
19
|
+
|
|
20
|
+
set({ itemId: undefined, helpItems: h });
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
//pass Store default functions
|
|
24
|
+
subscribe,
|
|
25
|
+
set,
|
|
26
|
+
update,
|
|
27
|
+
//set the list of help items to show
|
|
28
|
+
setHelpItemList: (helpItems: helpItemType[]) => {
|
|
29
|
+
helpStore.set({ itemId: undefined, helpItems: helpItems });
|
|
30
|
+
},
|
|
31
|
+
//set the ID of the help item and display it
|
|
32
|
+
setItemId: (itemId: string) => {
|
|
33
|
+
helpStore.subscribe((value) => {
|
|
34
|
+
value = value === undefined ? { itemId: undefined, helpItems: h } : value;
|
|
35
|
+
value.helpItems = value.helpItems === undefined ? h : value.helpItems;
|
|
36
|
+
v = { itemId: itemId, helpItems: value.helpItems };
|
|
37
|
+
});
|
|
38
|
+
update((u) => (u = v));
|
|
39
|
+
},
|
|
40
|
+
//reset the ID of the help item and hide it
|
|
41
|
+
resetItemId: () => {
|
|
42
|
+
helpStore.subscribe((value) => {
|
|
43
|
+
value = value === undefined ? { itemId: undefined, helpItems: h } : value;
|
|
44
|
+
value.helpItems = value.helpItems === undefined ? h : value.helpItems;
|
|
45
|
+
v = { itemId: undefined, helpItems: value.helpItems };
|
|
46
|
+
});
|
|
47
|
+
update((u) => (u = v));
|
|
48
|
+
},
|
|
49
|
+
//set the ID of the help item and display it
|
|
50
|
+
show: (itemId: string) => {
|
|
51
|
+
helpStore.setItemId(itemId);
|
|
52
|
+
},
|
|
53
|
+
//set a help item and display it
|
|
54
|
+
showHelpItem: (helpItem: helpItemType) => {
|
|
55
|
+
helpItem.id = helpItem.id === undefined ? 'default' : helpItem.id;
|
|
56
|
+
helpStore.set({ itemId: helpItem.id, helpItems: [helpItem] });
|
|
57
|
+
},
|
|
58
|
+
//reset the ID of the help item and hide it
|
|
59
|
+
hide: () => {
|
|
60
|
+
helpStore.resetItemId();
|
|
61
|
+
},
|
|
62
|
+
//reset the ID of the help item and hide it
|
|
63
|
+
toggle: (itemId: string) => {
|
|
64
|
+
helpStore.subscribe((value) => {
|
|
65
|
+
value = value === undefined ? { itemId: undefined, helpItems: h } : value;
|
|
66
|
+
value.helpItems = value.helpItems === undefined ? h : value.helpItems;
|
|
67
|
+
v = { itemId: itemId, helpItems: value.helpItems };
|
|
68
|
+
});
|
|
69
|
+
update((u) => (u = v));
|
|
70
|
+
},
|
|
71
|
+
reset: () => {
|
|
72
|
+
helpStore.set({ itemId: undefined, helpItems: h });
|
|
73
|
+
},
|
|
74
|
+
clear: () => {
|
|
75
|
+
helpStore.reset();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//crate and export the instance of the store
|
|
81
|
+
export const helpStore = createHelpStore();
|
|
82
|
+
|
|
83
|
+
// store for menu
|
|
84
|
+
export const menuStore = writable<MenuModel>();
|
|
85
|
+
|
|
86
|
+
function createBreadcrumbStore() {
|
|
87
|
+
// set Store Type
|
|
88
|
+
const { subscribe, set, update } = writable<BreadcrumbModel>();
|
|
89
|
+
|
|
90
|
+
set(new BreadcrumbModel());
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
//pass Store default functions
|
|
94
|
+
subscribe,
|
|
95
|
+
set,
|
|
96
|
+
update,
|
|
97
|
+
|
|
98
|
+
//set the ID of the help item and display it
|
|
99
|
+
addItem: (item: breadcrumbItemType) => {
|
|
100
|
+
let b: BreadcrumbModel;
|
|
101
|
+
breadcrumbStore.subscribe((value) => {
|
|
102
|
+
value = value === undefined ? new BreadcrumbModel() : value;
|
|
103
|
+
// value.items = (value.items === undefined) ? b:value.items
|
|
104
|
+
if (!value.items.find((i) => i.label === item.label)) {
|
|
105
|
+
value.items = [...value.items, item];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
b = value;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
update((s) => (s = b));
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
clean: () => {
|
|
115
|
+
let b: BreadcrumbModel;
|
|
116
|
+
breadcrumbStore.subscribe((value) => {
|
|
117
|
+
value = new BreadcrumbModel();
|
|
118
|
+
b = value;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
update((s) => (s = b));
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// store for breadcrumb navigation
|
|
127
|
+
export const breadcrumbStore = createBreadcrumbStore();
|
|
128
|
+
|
|
129
|
+
// store for notification (toasts)
|
|
130
|
+
function createNotificationStore() {
|
|
131
|
+
// set Store Type
|
|
132
|
+
const { subscribe, set, update } = writable<notificationStoreType>();
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
//pass Store default functions
|
|
136
|
+
subscribe,
|
|
137
|
+
set,
|
|
138
|
+
update,
|
|
139
|
+
// set notificationStroe, notificationType, message and button style
|
|
140
|
+
setNotification: (notificationItem: notificationItemType) => {
|
|
141
|
+
notificationItem.notificationType =
|
|
142
|
+
notificationItem.notificationType === undefined
|
|
143
|
+
? notificationType.surface
|
|
144
|
+
: notificationItem.notificationType;
|
|
145
|
+
let btnStyle: string;
|
|
146
|
+
|
|
147
|
+
switch (notificationItem.notificationType) {
|
|
148
|
+
case notificationType.success:
|
|
149
|
+
btnStyle = 'btn-icon btn-icon-sm variant-filled-success shadow-md';
|
|
150
|
+
break;
|
|
151
|
+
case notificationType.warning:
|
|
152
|
+
btnStyle = 'btn-icon btn-icon-sm variant-filled-warning shadow-md';
|
|
153
|
+
break;
|
|
154
|
+
case notificationType.error:
|
|
155
|
+
btnStyle = 'btn-icon btn-icon-sm variant-filled-error shadow-md';
|
|
156
|
+
break;
|
|
157
|
+
case notificationType.surface:
|
|
158
|
+
btnStyle = 'btn-icon btn-icon-sm variant-filled-surface shadow-md';
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
notificationStore.set({
|
|
163
|
+
notificationType: notificationItem.notificationType,
|
|
164
|
+
message: notificationItem.message,
|
|
165
|
+
btnStyle: btnStyle
|
|
166
|
+
});
|
|
167
|
+
notificationStore.subscribe((value) => {});
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
// triggers the notification to show
|
|
171
|
+
triggerNotification: () => {
|
|
172
|
+
let timeout: number = 30000;
|
|
173
|
+
let classes: string = '';
|
|
174
|
+
let message: string = '';
|
|
175
|
+
notificationStore.subscribe((value) => {
|
|
176
|
+
switch (value.notificationType) {
|
|
177
|
+
case notificationType.success:
|
|
178
|
+
classes =
|
|
179
|
+
'bg-success-300 border-solid border-2 border-success-500 shadow-md text-surface-900';
|
|
180
|
+
break;
|
|
181
|
+
case notificationType.warning:
|
|
182
|
+
classes =
|
|
183
|
+
'bg-warning-300 border-solid border-2 border-warning-500 shadow-md text-surface-900';
|
|
184
|
+
break;
|
|
185
|
+
case notificationType.error:
|
|
186
|
+
classes =
|
|
187
|
+
'bg-error-300 border-solid border-2 border-error-500 shadow-md text-surface-900';
|
|
188
|
+
break;
|
|
189
|
+
case notificationType.surface:
|
|
190
|
+
classes =
|
|
191
|
+
'bg-surface-300 border-solid border-2 border-surface-500 shadow-md text-surface-900';
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
message = value.message;
|
|
196
|
+
});
|
|
197
|
+
if (classes != '' && message != '') {
|
|
198
|
+
const notificationToast: ToastSettings = {
|
|
199
|
+
classes: classes,
|
|
200
|
+
message: message,
|
|
201
|
+
timeout: timeout
|
|
202
|
+
};
|
|
203
|
+
toastStore.trigger(notificationToast);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
// cleans the toastStore
|
|
208
|
+
clear: () => {
|
|
209
|
+
toastStore.clear();
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
// cleans, sets, and schows the notification (all you need ;))
|
|
213
|
+
showNotification: (notificationItem: notificationItemType) => {
|
|
214
|
+
notificationStore.clear();
|
|
215
|
+
notificationStore.setNotification({
|
|
216
|
+
notificationType: notificationItem.notificationType,
|
|
217
|
+
message: notificationItem.message
|
|
218
|
+
});
|
|
219
|
+
notificationStore.triggerNotification();
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
// gets the dissmiss Button style
|
|
223
|
+
getBtnStyle: () => {
|
|
224
|
+
let btnStyle: string = '';
|
|
225
|
+
notificationStore.subscribe((value) => {
|
|
226
|
+
do {
|
|
227
|
+
if (value === undefined || value.btnStyle === undefined) {
|
|
228
|
+
notificationStore.setNotification({ message: '' });
|
|
229
|
+
} else {
|
|
230
|
+
btnStyle = value.btnStyle;
|
|
231
|
+
}
|
|
232
|
+
} while (btnStyle === '');
|
|
233
|
+
});
|
|
234
|
+
return btnStyle;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
//crate and export the instance of the store
|
|
240
|
+
export const notificationStore = createNotificationStore();
|