@bexis2/bexis2-core-ui 0.2.17 → 0.2.18
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 +303 -293
- package/dist/components/file/FileUploader.svelte +34 -34
- package/dist/components/form/MultiSelect.svelte +61 -58
- 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 +101 -101
- package/src/lib/components/file/FileUploader.svelte +189 -184
- package/src/lib/components/form/MultiSelect.svelte +61 -58
- 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
|
@@ -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();
|