sprintify-ui 0.0.5 → 0.0.7
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 +13 -0
- package/dist/sprintify-ui.es.js +8969 -7917
- package/dist/types/src/components/BaseApp.vue.d.ts +48 -0
- package/dist/types/src/components/BaseAppDialogs.vue.d.ts +80 -0
- package/dist/types/src/components/BaseAppNotifications.vue.d.ts +44 -0
- package/dist/types/src/components/BaseAutocomplete.vue.d.ts +7 -7
- package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +7 -7
- package/dist/types/src/components/BaseBelongsTo.vue.d.ts +4 -4
- package/dist/types/src/components/BaseDataIterator.vue.d.ts +4 -4
- package/dist/types/src/components/BaseDataTable.vue.d.ts +4 -4
- package/dist/types/src/components/BaseFileUploader.vue.d.ts +20 -1
- package/dist/types/src/components/BaseInput.vue.d.ts +4 -4
- package/dist/types/src/components/BaseLoadingCover.vue.d.ts +4 -4
- package/dist/types/src/components/BasePassword.vue.d.ts +1 -1
- package/dist/types/src/components/BaseSelect.vue.d.ts +1 -1
- package/dist/types/src/components/BaseTextarea.vue.d.ts +4 -4
- package/dist/types/src/components/BaseTextareaAutoresize.vue.d.ts +1 -1
- package/dist/types/src/components/index.d.ts +9 -1
- package/dist/types/src/index.d.ts +10 -4
- package/dist/types/src/stores/dialogs.d.ts +9 -0
- package/dist/types/src/stores/notifications.d.ts +10 -0
- package/dist/types/src/stores/systemAlerts.d.ts +9 -0
- package/dist/types/src/types/types.d.ts +58 -0
- package/package.json +1 -1
- package/src/components/BaseApp.vue +15 -0
- package/src/components/BaseAppDialogs.vue +113 -0
- package/src/components/BaseAppNotifications.vue +73 -0
- package/src/components/BaseDataTable.vue +4 -4
- package/src/components/BaseDatePicker.vue +5 -6
- package/src/components/BaseDateSelect.vue +1 -1
- package/src/components/BaseDialog.vue +1 -0
- package/src/components/BaseFileUploader.vue +5 -1
- package/src/components/BaseInputLabel.vue +3 -3
- package/src/components/index.ts +16 -1
- package/src/index.ts +21 -14
- package/src/stores/dialogs.ts +45 -0
- package/src/stores/notifications.ts +47 -0
- package/src/stores/systemAlerts.ts +33 -0
- package/src/types/types.ts +67 -0
- package/dist/types/src/components/BaseLoadingPage.vue.d.ts +0 -2
- package/src/components/BaseLoadingPage.vue +0 -19
package/src/index.ts
CHANGED
|
@@ -5,12 +5,15 @@ import QueryString from 'qs';
|
|
|
5
5
|
import { createI18n, I18n } from 'vue-i18n';
|
|
6
6
|
import en from '@/lang/en.json';
|
|
7
7
|
import fr from '@/lang/fr.json';
|
|
8
|
+
import { useDialogsStore } from './stores/dialogs';
|
|
9
|
+
import { useNotificationsStore } from './stores/notifications';
|
|
10
|
+
import { useSystemAlertStore } from './stores/systemAlerts';
|
|
8
11
|
|
|
9
12
|
const messages = { en, fr };
|
|
10
13
|
|
|
11
14
|
import './assets/main.css';
|
|
12
15
|
|
|
13
|
-
interface
|
|
16
|
+
export interface Options {
|
|
14
17
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
15
18
|
i18n?: I18n<typeof messages, {}, {}, string, true>;
|
|
16
19
|
http?: AxiosInstance;
|
|
@@ -19,7 +22,7 @@ interface SprintifyUIConfig {
|
|
|
19
22
|
parseQueryString?: (params: string) => Record<string, any>;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
const
|
|
25
|
+
const config = {
|
|
23
26
|
i18n: createI18n({
|
|
24
27
|
messages: { en, fr },
|
|
25
28
|
}),
|
|
@@ -36,30 +39,30 @@ const pluginConfig = {
|
|
|
36
39
|
},
|
|
37
40
|
};
|
|
38
41
|
|
|
39
|
-
function install(app: App,
|
|
42
|
+
function install(app: App, options?: Options) {
|
|
40
43
|
for (const key in components) {
|
|
41
44
|
// @ts-expect-error Will throw
|
|
42
45
|
app.component(key, components[key]);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
if (
|
|
46
|
-
|
|
48
|
+
if (options?.i18n) {
|
|
49
|
+
config.i18n = options.i18n;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
52
|
+
if (options?.http) {
|
|
53
|
+
config.http = options.http;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
if (
|
|
54
|
-
|
|
56
|
+
if (options?.upload_url) {
|
|
57
|
+
config.upload_url = options.upload_url;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
if (
|
|
58
|
-
|
|
60
|
+
if (options?.formatQueryString) {
|
|
61
|
+
config.formatQueryString = options.formatQueryString;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
if (
|
|
62
|
-
|
|
64
|
+
if (options?.parseQueryString) {
|
|
65
|
+
config.parseQueryString = options.parseQueryString;
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -71,4 +74,8 @@ export * from './utils';
|
|
|
71
74
|
|
|
72
75
|
export { messages };
|
|
73
76
|
|
|
74
|
-
export {
|
|
77
|
+
export { config };
|
|
78
|
+
|
|
79
|
+
export { useDialogsStore };
|
|
80
|
+
export { useNotificationsStore };
|
|
81
|
+
export { useSystemAlertStore };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { config } from '@/index';
|
|
3
|
+
import { Dialog, DialogOptions } from '../types/types';
|
|
4
|
+
|
|
5
|
+
export const useDialogsStore = defineStore('dialogs', {
|
|
6
|
+
state: () => {
|
|
7
|
+
return {
|
|
8
|
+
count: 0,
|
|
9
|
+
dialogs: [] as Dialog[],
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
push(options: DialogOptions) {
|
|
14
|
+
this.count++;
|
|
15
|
+
this.dialogs.push({
|
|
16
|
+
id: this.count,
|
|
17
|
+
color: options.color ?? 'info',
|
|
18
|
+
title: options.title,
|
|
19
|
+
message: options.message,
|
|
20
|
+
confirmText: options.confirmText ?? config.i18n.global.t('sui.confirm'),
|
|
21
|
+
cancelText: options.cancelText ?? config.i18n.global.t('sui.cancel'),
|
|
22
|
+
closeOnOutsideClick: options.closeOnOutsideClick ?? true,
|
|
23
|
+
onConfirm:
|
|
24
|
+
options.onConfirm ??
|
|
25
|
+
function () {
|
|
26
|
+
return;
|
|
27
|
+
},
|
|
28
|
+
onCancel:
|
|
29
|
+
options.onCancel ??
|
|
30
|
+
function () {
|
|
31
|
+
return;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
remove(dialog: Dialog) {
|
|
36
|
+
this.dialogs.splice(
|
|
37
|
+
this.dialogs.findIndex((a) => a.id === dialog.id),
|
|
38
|
+
1
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
clear() {
|
|
42
|
+
this.dialogs = [];
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { Notification, NotificationOptions } from '../types/types';
|
|
3
|
+
|
|
4
|
+
export const useNotificationsStore = defineStore('notifications', {
|
|
5
|
+
state: () => {
|
|
6
|
+
return {
|
|
7
|
+
count: 0,
|
|
8
|
+
notifications: [] as Notification[],
|
|
9
|
+
timeouts: {} as Record<number, number>,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
push(options: NotificationOptions) {
|
|
14
|
+
this.count++;
|
|
15
|
+
|
|
16
|
+
const id = this.count;
|
|
17
|
+
|
|
18
|
+
const notification = {
|
|
19
|
+
id: id,
|
|
20
|
+
color: options.color ?? 'info',
|
|
21
|
+
title: options.title,
|
|
22
|
+
text: options.text,
|
|
23
|
+
duration: options.duration ?? 3000,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
this.notifications.push(notification);
|
|
27
|
+
|
|
28
|
+
this.timeouts[id] = setTimeout(() => {
|
|
29
|
+
this.remove(notification);
|
|
30
|
+
}, notification.duration);
|
|
31
|
+
},
|
|
32
|
+
remove(notification: Notification) {
|
|
33
|
+
this.notifications.splice(
|
|
34
|
+
this.notifications.findIndex((n) => n.id === notification.id),
|
|
35
|
+
1
|
|
36
|
+
);
|
|
37
|
+
clearTimeout(this.timeouts[notification.id]);
|
|
38
|
+
},
|
|
39
|
+
clear() {
|
|
40
|
+
this.notifications = [];
|
|
41
|
+
Object.values(this.timeouts).forEach((timeout) => {
|
|
42
|
+
clearTimeout(timeout);
|
|
43
|
+
});
|
|
44
|
+
this.timeouts = [];
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { SystemAlert, SystemAlertOptions } from '../types/types';
|
|
3
|
+
|
|
4
|
+
export const useSystemAlertStore = defineStore('systemAlerts', {
|
|
5
|
+
state: () => {
|
|
6
|
+
return {
|
|
7
|
+
count: 0,
|
|
8
|
+
systemAlerts: [] as SystemAlert[],
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
actions: {
|
|
12
|
+
push(systemAlert: SystemAlertOptions) {
|
|
13
|
+
this.count++;
|
|
14
|
+
this.systemAlerts.push({
|
|
15
|
+
id: this.count,
|
|
16
|
+
color: systemAlert.color ?? 'info',
|
|
17
|
+
message: systemAlert.message,
|
|
18
|
+
to: systemAlert.to,
|
|
19
|
+
action: systemAlert.action,
|
|
20
|
+
closable: systemAlert.closable ?? false,
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
remove(systemAlert: SystemAlert) {
|
|
24
|
+
this.systemAlerts.splice(
|
|
25
|
+
this.systemAlerts.findIndex((a) => a.id === systemAlert.id),
|
|
26
|
+
1
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
clear() {
|
|
30
|
+
this.systemAlerts = [];
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
package/src/types/types.ts
CHANGED
|
@@ -110,3 +110,70 @@ export interface BaseTableColumn {
|
|
|
110
110
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
111
|
tdAttrs: (row: Row, column: BaseTableColumn) => Record<string, any>;
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* System alert
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
export interface SystemAlertOptions {
|
|
119
|
+
color?: 'info' | 'success' | 'danger' | 'warning';
|
|
120
|
+
message: string;
|
|
121
|
+
to?: RouteLocationRaw;
|
|
122
|
+
action?: () => void;
|
|
123
|
+
closable?: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface SystemAlert {
|
|
127
|
+
id: number;
|
|
128
|
+
color: 'info' | 'success' | 'danger' | 'warning';
|
|
129
|
+
message: string;
|
|
130
|
+
to?: RouteLocationRaw;
|
|
131
|
+
action?: () => void;
|
|
132
|
+
closable: boolean;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Dialog
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
export interface DialogOptions {
|
|
140
|
+
color?: 'info' | 'success' | 'danger' | 'warning';
|
|
141
|
+
title: string;
|
|
142
|
+
message: string;
|
|
143
|
+
confirmText?: string;
|
|
144
|
+
cancelText?: string;
|
|
145
|
+
closeOnOutsideClick?: boolean;
|
|
146
|
+
onConfirm?: () => void;
|
|
147
|
+
onCancel?: () => void;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface Dialog {
|
|
151
|
+
id: number;
|
|
152
|
+
color: 'info' | 'success' | 'danger' | 'warning';
|
|
153
|
+
title: string;
|
|
154
|
+
message: string;
|
|
155
|
+
confirmText: string;
|
|
156
|
+
cancelText: string;
|
|
157
|
+
closeOnOutsideClick: boolean;
|
|
158
|
+
onConfirm: () => void;
|
|
159
|
+
onCancel: () => void;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Notification
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
export interface NotificationOptions {
|
|
167
|
+
title: string;
|
|
168
|
+
text: string;
|
|
169
|
+
color?: 'info' | 'success' | 'danger' | 'warning';
|
|
170
|
+
duration?: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface Notification {
|
|
174
|
+
id: number;
|
|
175
|
+
title: string;
|
|
176
|
+
text: string;
|
|
177
|
+
color: 'info' | 'success' | 'danger' | 'warning';
|
|
178
|
+
duration: number;
|
|
179
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="fixed inset-0 z-loading flex h-full w-full items-center justify-center bg-white"
|
|
4
|
-
>
|
|
5
|
-
<div class="flex flex-col items-center">
|
|
6
|
-
<img
|
|
7
|
-
:src="'/img/logo/icon-color.svg'"
|
|
8
|
-
alt="Loading"
|
|
9
|
-
class="mb-14 w-16 animate-pulse"
|
|
10
|
-
/>
|
|
11
|
-
<svg class="h-6 w-6 animate-spin text-primary-500" viewBox="0 0 24 24">
|
|
12
|
-
<path
|
|
13
|
-
fill="currentColor"
|
|
14
|
-
d="M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z"
|
|
15
|
-
/>
|
|
16
|
-
</svg>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</template>
|