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.
Files changed (41) hide show
  1. package/README.md +13 -0
  2. package/dist/sprintify-ui.es.js +8969 -7917
  3. package/dist/types/src/components/BaseApp.vue.d.ts +48 -0
  4. package/dist/types/src/components/BaseAppDialogs.vue.d.ts +80 -0
  5. package/dist/types/src/components/BaseAppNotifications.vue.d.ts +44 -0
  6. package/dist/types/src/components/BaseAutocomplete.vue.d.ts +7 -7
  7. package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +7 -7
  8. package/dist/types/src/components/BaseBelongsTo.vue.d.ts +4 -4
  9. package/dist/types/src/components/BaseDataIterator.vue.d.ts +4 -4
  10. package/dist/types/src/components/BaseDataTable.vue.d.ts +4 -4
  11. package/dist/types/src/components/BaseFileUploader.vue.d.ts +20 -1
  12. package/dist/types/src/components/BaseInput.vue.d.ts +4 -4
  13. package/dist/types/src/components/BaseLoadingCover.vue.d.ts +4 -4
  14. package/dist/types/src/components/BasePassword.vue.d.ts +1 -1
  15. package/dist/types/src/components/BaseSelect.vue.d.ts +1 -1
  16. package/dist/types/src/components/BaseTextarea.vue.d.ts +4 -4
  17. package/dist/types/src/components/BaseTextareaAutoresize.vue.d.ts +1 -1
  18. package/dist/types/src/components/index.d.ts +9 -1
  19. package/dist/types/src/index.d.ts +10 -4
  20. package/dist/types/src/stores/dialogs.d.ts +9 -0
  21. package/dist/types/src/stores/notifications.d.ts +10 -0
  22. package/dist/types/src/stores/systemAlerts.d.ts +9 -0
  23. package/dist/types/src/types/types.d.ts +58 -0
  24. package/package.json +1 -1
  25. package/src/components/BaseApp.vue +15 -0
  26. package/src/components/BaseAppDialogs.vue +113 -0
  27. package/src/components/BaseAppNotifications.vue +73 -0
  28. package/src/components/BaseDataTable.vue +4 -4
  29. package/src/components/BaseDatePicker.vue +5 -6
  30. package/src/components/BaseDateSelect.vue +1 -1
  31. package/src/components/BaseDialog.vue +1 -0
  32. package/src/components/BaseFileUploader.vue +5 -1
  33. package/src/components/BaseInputLabel.vue +3 -3
  34. package/src/components/index.ts +16 -1
  35. package/src/index.ts +21 -14
  36. package/src/stores/dialogs.ts +45 -0
  37. package/src/stores/notifications.ts +47 -0
  38. package/src/stores/systemAlerts.ts +33 -0
  39. package/src/types/types.ts +67 -0
  40. package/dist/types/src/components/BaseLoadingPage.vue.d.ts +0 -2
  41. 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 SprintifyUIConfig {
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 pluginConfig = {
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, config?: SprintifyUIConfig) {
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 (config?.i18n) {
46
- pluginConfig.i18n = config.i18n;
48
+ if (options?.i18n) {
49
+ config.i18n = options.i18n;
47
50
  }
48
51
 
49
- if (config?.http) {
50
- pluginConfig.http = config.http;
52
+ if (options?.http) {
53
+ config.http = options.http;
51
54
  }
52
55
 
53
- if (config?.upload_url) {
54
- pluginConfig.upload_url = config.upload_url;
56
+ if (options?.upload_url) {
57
+ config.upload_url = options.upload_url;
55
58
  }
56
59
 
57
- if (config?.formatQueryString) {
58
- pluginConfig.formatQueryString = config.formatQueryString;
60
+ if (options?.formatQueryString) {
61
+ config.formatQueryString = options.formatQueryString;
59
62
  }
60
63
 
61
- if (config?.parseQueryString) {
62
- pluginConfig.parseQueryString = config.parseQueryString;
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 { pluginConfig as config };
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
+ });
@@ -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,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -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>