sprintify-ui 0.6.87 → 0.7.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/README.md +11 -11
- package/dist/sprintify-ui.es.js +245 -244
- package/dist/tailwindcss/theme.js +1 -1
- package/dist/types/components/BaseDataIteratorSectionColumns.vue.d.ts +34 -34
- package/dist/types/components/BaseDataTableTemplate.vue.d.ts +3 -3
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/index.d.ts +3 -1
- package/dist/types/stores/snackbars.d.ts +19 -0
- package/dist/types/types/index.d.ts +7 -7
- package/package.json +1 -1
- package/src/components/BaseApp.vue +2 -2
- package/src/components/{BaseAppNotifications.vue → BaseAppSnackbars.vue} +9 -9
- package/src/components/BaseCropper.stories.js +3 -3
- package/src/components/BaseCropperModal.stories.js +3 -3
- package/src/components/BaseDataTable.stories.js +3 -3
- package/src/components/BaseDataTable.vue +4 -4
- package/src/components/BaseDataTableTemplate.vue +8 -8
- package/src/components/BaseFilePicker.stories.js +3 -3
- package/src/components/BaseFilePicker.vue +4 -4
- package/src/components/BaseFilePickerCrop.stories.js +3 -3
- package/src/components/BaseFileUploader.stories.js +3 -3
- package/src/components/BaseFileUploader.vue +3 -3
- package/src/components/BaseForm.stories.js +3 -0
- package/src/components/BaseForm.vue +4 -4
- package/src/components/BaseHasMany.stories.js +5 -5
- package/src/components/BaseMediaLibrary.vue +3 -3
- package/src/components/BaseTagAutocomplete.stories.js +11 -5
- package/src/components/BaseTagAutocomplete.vue +3 -3
- package/src/components/BaseTagAutocompleteFetch.stories.js +3 -3
- package/src/components/index.ts +2 -2
- package/src/index.ts +3 -1
- package/src/stores/{notifications.ts → snackbars.ts} +15 -13
- package/src/stories/List.stories.js +3 -3
- package/src/stories/PageShow.vue +4 -4
- package/src/types/index.ts +7 -7
- package/dist/types/stores/notifications.d.ts +0 -10
- /package/dist/types/components/{BaseAppNotifications.vue.d.ts → BaseAppSnackbars.vue.d.ts} +0 -0
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
<script lang="ts" setup>
|
|
29
29
|
import { t } from '@/i18n';
|
|
30
|
-
import {
|
|
30
|
+
import { useSnackbarsStore } from '@/stores/snackbars';
|
|
31
31
|
import { fileSizeFormat, toHumanList } from '@/utils';
|
|
32
32
|
import { maxSize, validExtension } from '@/utils/fileValidations';
|
|
33
33
|
|
|
@@ -52,7 +52,7 @@ const props = withDefaults(
|
|
|
52
52
|
|
|
53
53
|
const emit = defineEmits(['select']);
|
|
54
54
|
|
|
55
|
-
const
|
|
55
|
+
const snackbars = useSnackbarsStore();
|
|
56
56
|
|
|
57
57
|
const selecting = ref(false);
|
|
58
58
|
const dragging = ref(false);
|
|
@@ -127,7 +127,7 @@ async function select(files: File[]) {
|
|
|
127
127
|
|
|
128
128
|
function isValid(file: File) {
|
|
129
129
|
if (!maxSize(file, props.maxSize)) {
|
|
130
|
-
|
|
130
|
+
snackbars.push({
|
|
131
131
|
color: 'danger',
|
|
132
132
|
title: t('sui.error'),
|
|
133
133
|
text: t('sui.the_file_size_must_not_exceed_x', {
|
|
@@ -141,7 +141,7 @@ function isValid(file: File) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
if (!validExtension(file, props.acceptedExtensions)) {
|
|
144
|
-
|
|
144
|
+
snackbars.push({
|
|
145
145
|
color: 'danger',
|
|
146
146
|
title: t('sui.error'),
|
|
147
147
|
text:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseFilePickerCrop from '@/components/BaseFilePickerCrop.vue';
|
|
2
2
|
import BaseLoadingCover from '@/components/BaseLoadingCover.vue';
|
|
3
|
-
import
|
|
3
|
+
import BaseAppSnackbars from '@/components/BaseAppSnackbars.vue';
|
|
4
4
|
import BaseCropper from '@/components/BaseCropper.vue';
|
|
5
5
|
import BaseModalCenter from '@/components/BaseModalCenter.vue';
|
|
6
6
|
import BaseButton from '@/components/BaseButton.vue';
|
|
@@ -22,7 +22,7 @@ const Template = (args) => ({
|
|
|
22
22
|
BaseFilePickerCrop,
|
|
23
23
|
BaseIcon,
|
|
24
24
|
BaseLoadingCover,
|
|
25
|
-
|
|
25
|
+
BaseAppSnackbars,
|
|
26
26
|
BaseCropper,
|
|
27
27
|
BaseModalCenter,
|
|
28
28
|
BaseButton,
|
|
@@ -77,7 +77,7 @@ const Template = (args) => ({
|
|
|
77
77
|
|
|
78
78
|
<ShowValue :value="file" />
|
|
79
79
|
|
|
80
|
-
<
|
|
80
|
+
<BaseAppSnackbars></BaseAppSnackbars>
|
|
81
81
|
`,
|
|
82
82
|
});
|
|
83
83
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseFileUploader from '@/components/BaseFileUploader.vue';
|
|
2
2
|
import BaseLoadingCover from '@/components/BaseLoadingCover.vue';
|
|
3
|
-
import
|
|
3
|
+
import BaseAppSnackbars from '@/components/BaseAppSnackbars.vue';
|
|
4
4
|
import ShowValue from '../../.storybook/components/ShowValue.vue';
|
|
5
5
|
import { Icon as BaseIcon } from '@iconify/vue';
|
|
6
6
|
import { t } from '@/i18n';
|
|
@@ -21,7 +21,7 @@ const Template = (args) => ({
|
|
|
21
21
|
BaseFileUploader,
|
|
22
22
|
BaseIcon,
|
|
23
23
|
BaseLoadingCover,
|
|
24
|
-
|
|
24
|
+
BaseAppSnackbars,
|
|
25
25
|
ShowValue,
|
|
26
26
|
},
|
|
27
27
|
setup() {
|
|
@@ -71,7 +71,7 @@ const Template = (args) => ({
|
|
|
71
71
|
|
|
72
72
|
<ShowValue :value="files" />
|
|
73
73
|
|
|
74
|
-
<
|
|
74
|
+
<BaseAppSnackbars></BaseAppSnackbars>
|
|
75
75
|
`,
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
<script lang="ts" setup>
|
|
33
33
|
import { config } from '@/index';
|
|
34
34
|
import { UploadedFile } from '@/types/UploadedFile';
|
|
35
|
-
import {
|
|
35
|
+
import { useSnackbarsStore } from '@/stores/snackbars';
|
|
36
36
|
import BaseLoadingCover from '@/components/BaseLoadingCover.vue';
|
|
37
37
|
import { BaseCropperConfig } from '@/types';
|
|
38
38
|
import BaseFilePicker from './BaseFilePicker.vue';
|
|
@@ -40,7 +40,7 @@ import BaseFilePickerCrop from './BaseFilePickerCrop.vue';
|
|
|
40
40
|
import { t } from '@/i18n';
|
|
41
41
|
|
|
42
42
|
const http = config.http;
|
|
43
|
-
const
|
|
43
|
+
const snackbarsStore = useSnackbarsStore();
|
|
44
44
|
|
|
45
45
|
const props = withDefaults(
|
|
46
46
|
defineProps<{
|
|
@@ -137,7 +137,7 @@ async function onFileSelect(files: File | File[]) {
|
|
|
137
137
|
} catch (e: unknown) {
|
|
138
138
|
console.error(e);
|
|
139
139
|
emit('fail');
|
|
140
|
-
|
|
140
|
+
snackbarsStore.push({
|
|
141
141
|
color: 'danger',
|
|
142
142
|
title: t('sui.error'),
|
|
143
143
|
text: t('sui.upload_failed'),
|
|
@@ -3,6 +3,7 @@ import BaseField from './BaseField.vue';
|
|
|
3
3
|
import BaseInput from './BaseInput.vue';
|
|
4
4
|
import BaseMediaLibrary from './BaseMediaLibrary.vue';
|
|
5
5
|
import ShowValue from '../../.storybook/components/ShowValue.vue';
|
|
6
|
+
import BaseAppSnackbars from './BaseAppSnackbars.vue';
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: 'Form/BaseForm',
|
|
@@ -16,6 +17,7 @@ const Template = (args) => ({
|
|
|
16
17
|
BaseInput,
|
|
17
18
|
BaseField,
|
|
18
19
|
BaseMediaLibrary,
|
|
20
|
+
BaseAppSnackbars,
|
|
19
21
|
},
|
|
20
22
|
setup() {
|
|
21
23
|
const form = ref({
|
|
@@ -25,6 +27,7 @@ const Template = (args) => ({
|
|
|
25
27
|
return { args, form };
|
|
26
28
|
},
|
|
27
29
|
template: `
|
|
30
|
+
<BaseAppSnackbars />
|
|
28
31
|
<BaseForm
|
|
29
32
|
method="post"
|
|
30
33
|
url="https://faker.witify.io/api/todos"
|
|
@@ -50,12 +50,12 @@ import { PropType } from 'vue';
|
|
|
50
50
|
import { serialize } from 'object-to-formdata';
|
|
51
51
|
import { Method, DataFormat } from '@/types';
|
|
52
52
|
import { AxiosError, AxiosInstance, AxiosResponse } from 'axios';
|
|
53
|
-
import { config,
|
|
53
|
+
import { config, useSnackbarsStore } from '@/index';
|
|
54
54
|
import { get, isArray } from 'lodash';
|
|
55
55
|
import { t } from '@/i18n';
|
|
56
56
|
import { twMerge } from 'tailwind-merge';
|
|
57
57
|
|
|
58
|
-
const
|
|
58
|
+
const snackbars = useSnackbarsStore();
|
|
59
59
|
|
|
60
60
|
type NextFunction = () => void;
|
|
61
61
|
|
|
@@ -236,7 +236,7 @@ function query() {
|
|
|
236
236
|
const errorMessage = get(error, 'response.data.message', null);
|
|
237
237
|
|
|
238
238
|
if (props.showNotificationOnError && errorMessage) {
|
|
239
|
-
|
|
239
|
+
snackbars.push({
|
|
240
240
|
color: 'danger',
|
|
241
241
|
title: t('sui.error'),
|
|
242
242
|
text: errorMessage,
|
|
@@ -258,7 +258,7 @@ function successHandler(response: AxiosResponse<any, any>) {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
if (props.showNotificationOnSuccess) {
|
|
261
|
-
|
|
261
|
+
snackbars.push({
|
|
262
262
|
color: 'success',
|
|
263
263
|
title: t('sui.success'),
|
|
264
264
|
text: message,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseHasMany from './BaseHasMany.vue';
|
|
2
2
|
import ShowValue from '@/../.storybook/components/ShowValue.vue';
|
|
3
3
|
import { createFieldStory, options } from '../../.storybook/utils';
|
|
4
|
-
import
|
|
4
|
+
import BaseAppSnackbars from './BaseAppSnackbars.vue';
|
|
5
5
|
import QueryString from 'qs';
|
|
6
6
|
import { random } from 'lodash';
|
|
7
7
|
|
|
@@ -30,7 +30,7 @@ export default {
|
|
|
30
30
|
|
|
31
31
|
const Template = (args) => {
|
|
32
32
|
return {
|
|
33
|
-
components: { BaseHasMany, ShowValue,
|
|
33
|
+
components: { BaseHasMany, ShowValue, BaseAppSnackbars },
|
|
34
34
|
setup() {
|
|
35
35
|
const value = ref([
|
|
36
36
|
"4",
|
|
@@ -49,7 +49,7 @@ const Template = (args) => {
|
|
|
49
49
|
:current-models="currentModels"
|
|
50
50
|
></BaseHasMany>
|
|
51
51
|
<ShowValue :value="value" />
|
|
52
|
-
<
|
|
52
|
+
<BaseAppSnackbars />
|
|
53
53
|
`,
|
|
54
54
|
};
|
|
55
55
|
};
|
|
@@ -228,7 +228,7 @@ export const SlotEmpty = (args) => {
|
|
|
228
228
|
|
|
229
229
|
const RaceConditionTemplate = (args) => {
|
|
230
230
|
return {
|
|
231
|
-
components: { BaseHasMany, ShowValue,
|
|
231
|
+
components: { BaseHasMany, ShowValue, BaseAppSnackbars },
|
|
232
232
|
setup() {
|
|
233
233
|
|
|
234
234
|
const value = ref([
|
|
@@ -265,7 +265,7 @@ const RaceConditionTemplate = (args) => {
|
|
|
265
265
|
|
|
266
266
|
<p class="-mb-4">Value from component</p>
|
|
267
267
|
<ShowValue :value="value" />
|
|
268
|
-
<
|
|
268
|
+
<BaseAppSnackbars />
|
|
269
269
|
`,
|
|
270
270
|
};
|
|
271
271
|
};
|
|
@@ -109,7 +109,7 @@ import { Media } from '@/types/Media';
|
|
|
109
109
|
import { BaseCropperConfig, MediaLibraryPayload } from '@/types';
|
|
110
110
|
import { fileSizeFormat } from '@/utils';
|
|
111
111
|
import { useDialogsStore } from '@/stores/dialogs';
|
|
112
|
-
import {
|
|
112
|
+
import { useSnackbarsStore } from '@/stores/snackbars';
|
|
113
113
|
import BaseFileUploader from './BaseFileUploader.vue';
|
|
114
114
|
import { useField } from '@/composables/field';
|
|
115
115
|
import { BaseIcon } from '.';
|
|
@@ -119,7 +119,7 @@ import BaseMediaGallery from './BaseMediaGallery.vue';
|
|
|
119
119
|
import { t } from '@/i18n';
|
|
120
120
|
|
|
121
121
|
const dialogs = useDialogsStore();
|
|
122
|
-
const
|
|
122
|
+
const snackbars = useSnackbarsStore();
|
|
123
123
|
|
|
124
124
|
const props = defineProps({
|
|
125
125
|
modelValue: {
|
|
@@ -264,7 +264,7 @@ function onSuccess(files: UploadedFile[]) {
|
|
|
264
264
|
modelValue.length >= normalizedMax.value &&
|
|
265
265
|
normalizedMax.value > 1
|
|
266
266
|
) {
|
|
267
|
-
|
|
267
|
+
snackbars.push({
|
|
268
268
|
title: t('sui.whoops'),
|
|
269
269
|
text: t('sui.you_can_upload_up_to_n_files', {
|
|
270
270
|
count: normalizedMax.value,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createFieldStory, options } from '../../.storybook/utils';
|
|
2
2
|
import BaseTagAutocomplete from './BaseTagAutocomplete.vue';
|
|
3
3
|
import ShowValue from '@/../.storybook/components/ShowValue.vue';
|
|
4
|
-
import
|
|
4
|
+
import BaseAppSnackbars from './BaseAppSnackbars.vue';
|
|
5
5
|
|
|
6
6
|
const sizes = ['xs', 'sm', 'md'];
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const Template = (args) => ({
|
|
30
|
-
components: { BaseTagAutocomplete, ShowValue,
|
|
30
|
+
components: { BaseTagAutocomplete, ShowValue, BaseAppSnackbars },
|
|
31
31
|
setup() {
|
|
32
32
|
const value = ref(null);
|
|
33
33
|
return { args, value };
|
|
@@ -35,12 +35,18 @@ const Template = (args) => ({
|
|
|
35
35
|
template: `
|
|
36
36
|
<BaseTagAutocomplete v-model="value" v-bind="args"></BaseTagAutocomplete>
|
|
37
37
|
<ShowValue :value="value" />
|
|
38
|
+
<BaseAppSnackbars />
|
|
38
39
|
`,
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
export const Demo = Template.bind({});
|
|
42
43
|
Demo.args = {};
|
|
43
44
|
|
|
45
|
+
export const Max = Template.bind({});
|
|
46
|
+
Max.args = {
|
|
47
|
+
max: 3
|
|
48
|
+
};
|
|
49
|
+
|
|
44
50
|
export const AlwaysShowDropdown = Template.bind({});
|
|
45
51
|
AlwaysShowDropdown.args = {
|
|
46
52
|
inline: true,
|
|
@@ -84,7 +90,7 @@ export const Sizes = (args) => ({
|
|
|
84
90
|
});
|
|
85
91
|
|
|
86
92
|
export const SlotOption = (args) => ({
|
|
87
|
-
components: { BaseTagAutocomplete, ShowValue,
|
|
93
|
+
components: { BaseTagAutocomplete, ShowValue, BaseAppSnackbars },
|
|
88
94
|
setup() {
|
|
89
95
|
const value = ref(null);
|
|
90
96
|
|
|
@@ -201,7 +207,7 @@ export const SlotBlockItem = (args) => {
|
|
|
201
207
|
|
|
202
208
|
export const SlotFooter = (args) => {
|
|
203
209
|
return {
|
|
204
|
-
components: { BaseTagAutocomplete, ShowValue,
|
|
210
|
+
components: { BaseTagAutocomplete, ShowValue, BaseAppSnackbars },
|
|
205
211
|
setup() {
|
|
206
212
|
const value = ref(null);
|
|
207
213
|
function onClick() {
|
|
@@ -228,7 +234,7 @@ export const SlotFooter = (args) => {
|
|
|
228
234
|
|
|
229
235
|
export const SlotEmpty = (args) => {
|
|
230
236
|
return {
|
|
231
|
-
components: { BaseTagAutocomplete, ShowValue,
|
|
237
|
+
components: { BaseTagAutocomplete, ShowValue, BaseAppSnackbars },
|
|
232
238
|
setup() {
|
|
233
239
|
const value = ref(null);
|
|
234
240
|
return { args, value };
|
|
@@ -96,13 +96,13 @@ import { NormalizedOption, RawOption } from '@/types';
|
|
|
96
96
|
import { useHasOptions } from '@/composables/hasOptions';
|
|
97
97
|
import { useField } from '@/composables/field';
|
|
98
98
|
import { useClickOutside } from '@/composables/clickOutside';
|
|
99
|
-
import {
|
|
99
|
+
import { useSnackbarsStore } from '@/stores/snackbars';
|
|
100
100
|
import BaseAutocompleteDrawer from './BaseAutocompleteDrawer.vue';
|
|
101
101
|
import { twMerge } from 'tailwind-merge';
|
|
102
102
|
import { t } from '@/i18n';
|
|
103
103
|
import { Size, sizes } from '@/utils/sizes';
|
|
104
104
|
|
|
105
|
-
const
|
|
105
|
+
const snackbars = useSnackbarsStore();
|
|
106
106
|
|
|
107
107
|
const props = defineProps({
|
|
108
108
|
modelValue: {
|
|
@@ -340,7 +340,7 @@ const onSelect = (option: NormalizedOption) => {
|
|
|
340
340
|
focus();
|
|
341
341
|
|
|
342
342
|
if (props.max && normalizedModelValue.value.length >= props.max) {
|
|
343
|
-
|
|
343
|
+
snackbars.push({
|
|
344
344
|
title: t('sui.whoops'),
|
|
345
345
|
text: t('sui.you_cannot_select_more_than_x_items', {
|
|
346
346
|
count: props.max,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseTagAutocompleteFetch from './BaseTagAutocompleteFetch.vue';
|
|
2
2
|
import ShowValue from '@/../.storybook/components/ShowValue.vue';
|
|
3
3
|
import { createFieldStory } from '../../.storybook/utils';
|
|
4
|
-
import
|
|
4
|
+
import BaseAppSnackbars from './BaseAppSnackbars.vue';
|
|
5
5
|
|
|
6
6
|
const sizes = ['xs', 'sm', 'md'];
|
|
7
7
|
|
|
@@ -24,7 +24,7 @@ export default {
|
|
|
24
24
|
|
|
25
25
|
const Template = (args) => {
|
|
26
26
|
return {
|
|
27
|
-
components: { BaseTagAutocompleteFetch, ShowValue,
|
|
27
|
+
components: { BaseTagAutocompleteFetch, ShowValue, BaseAppSnackbars },
|
|
28
28
|
setup() {
|
|
29
29
|
const value = ref([]);
|
|
30
30
|
return { args, value };
|
|
@@ -35,7 +35,7 @@ const Template = (args) => {
|
|
|
35
35
|
v-bind="args"
|
|
36
36
|
></BaseTagAutocompleteFetch>
|
|
37
37
|
<ShowValue :value="value" />
|
|
38
|
-
<
|
|
38
|
+
<BaseAppSnackbars />
|
|
39
39
|
`,
|
|
40
40
|
};
|
|
41
41
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import BaseAddressForm from './BaseAddressForm.vue';
|
|
|
3
3
|
import BaseAlert from './BaseAlert.vue';
|
|
4
4
|
import BaseApp from './BaseApp.vue';
|
|
5
5
|
import BaseAppDialogs from './BaseAppDialogs.vue';
|
|
6
|
-
import
|
|
6
|
+
import BaseAppSnackbars from './BaseAppSnackbars.vue';
|
|
7
7
|
import BaseAutocomplete from './BaseAutocomplete.vue';
|
|
8
8
|
import BaseAutocompleteFetch from './BaseAutocompleteFetch.vue';
|
|
9
9
|
import BaseAvatar from './BaseAvatar.vue';
|
|
@@ -109,7 +109,7 @@ export {
|
|
|
109
109
|
BaseAlert,
|
|
110
110
|
BaseApp,
|
|
111
111
|
BaseAppDialogs,
|
|
112
|
-
|
|
112
|
+
BaseAppSnackbars,
|
|
113
113
|
BaseAutocomplete,
|
|
114
114
|
BaseAutocompleteFetch,
|
|
115
115
|
BaseAvatar,
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import QueryString from 'qs';
|
|
|
5
5
|
import en from '@/lang/en.json';
|
|
6
6
|
import fr from '@/lang/fr.json';
|
|
7
7
|
import { useDialogsStore } from './stores/dialogs';
|
|
8
|
-
import { useNotificationsStore } from './stores/
|
|
8
|
+
import { useSnackbarsStore, useNotificationsStore } from './stores/snackbars';
|
|
9
9
|
import { useSystemAlertStore } from './stores/systemAlerts';
|
|
10
10
|
import { useClickOutside } from './composables/clickOutside';
|
|
11
11
|
import { useField } from './composables/field';
|
|
@@ -117,12 +117,14 @@ export default { install };
|
|
|
117
117
|
export * from './components';
|
|
118
118
|
export * from './constants';
|
|
119
119
|
export * from './utils';
|
|
120
|
+
export type * from './types';
|
|
120
121
|
|
|
121
122
|
export { messages };
|
|
122
123
|
|
|
123
124
|
export { config };
|
|
124
125
|
|
|
125
126
|
export { useDialogsStore };
|
|
127
|
+
export { useSnackbarsStore };
|
|
126
128
|
export { useNotificationsStore };
|
|
127
129
|
export { useSystemAlertStore };
|
|
128
130
|
export { useClickOutside };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { defineStore } from 'pinia';
|
|
2
|
-
import {
|
|
2
|
+
import { Snackbar, SnackbarOptions } from '../types';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const useSnackbarsStore = defineStore('notifications', {
|
|
5
5
|
state: () => {
|
|
6
6
|
return {
|
|
7
7
|
count: 0,
|
|
8
|
-
|
|
8
|
+
snackbars: [] as Snackbar[],
|
|
9
9
|
timeouts: {} as Record<number, number>,
|
|
10
10
|
};
|
|
11
11
|
},
|
|
12
12
|
actions: {
|
|
13
|
-
push(options:
|
|
13
|
+
push(options: SnackbarOptions) {
|
|
14
14
|
this.count++;
|
|
15
15
|
|
|
16
16
|
const id = this.count;
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const snackbar = {
|
|
19
19
|
id: id,
|
|
20
20
|
color: options.color ?? 'info',
|
|
21
21
|
title: options.title,
|
|
@@ -23,21 +23,21 @@ export const useNotificationsStore = defineStore('notifications', {
|
|
|
23
23
|
duration: options.duration ?? 3000,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
this.
|
|
26
|
+
this.snackbars.push(snackbar);
|
|
27
27
|
|
|
28
28
|
this.timeouts[id] = setTimeout(() => {
|
|
29
|
-
this.remove(
|
|
30
|
-
},
|
|
29
|
+
this.remove(snackbar);
|
|
30
|
+
}, snackbar.duration);
|
|
31
31
|
},
|
|
32
|
-
remove(
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
32
|
+
remove(snackbar: Snackbar) {
|
|
33
|
+
this.snackbars.splice(
|
|
34
|
+
this.snackbars.findIndex((n) => n.id === snackbar.id),
|
|
35
35
|
1
|
|
36
36
|
);
|
|
37
|
-
clearTimeout(this.timeouts[
|
|
37
|
+
clearTimeout(this.timeouts[snackbar.id]);
|
|
38
38
|
},
|
|
39
39
|
clear() {
|
|
40
|
-
this.
|
|
40
|
+
this.snackbars = [];
|
|
41
41
|
Object.values(this.timeouts).forEach((timeout) => {
|
|
42
42
|
clearTimeout(timeout);
|
|
43
43
|
});
|
|
@@ -45,3 +45,5 @@ export const useNotificationsStore = defineStore('notifications', {
|
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
|
+
|
|
49
|
+
export const useNotificationsStore = useSnackbarsStore;
|
|
@@ -7,7 +7,7 @@ import BaseBoolean from '../components/BaseBoolean.vue';
|
|
|
7
7
|
import BaseSelect from '../components/BaseSelect.vue';
|
|
8
8
|
import BaseBadge from '../components/BaseBadge.vue';
|
|
9
9
|
import BaseCounter from '../components/BaseCounter.vue';
|
|
10
|
-
import
|
|
10
|
+
import BaseAppSnackbars from '../components/BaseAppSnackbars.vue';
|
|
11
11
|
import BaseAppDialogs from '../components/BaseAppDialogs.vue';
|
|
12
12
|
import BaseContainer from '../components/BaseContainer.vue';
|
|
13
13
|
import { DateTime } from 'luxon';
|
|
@@ -83,7 +83,7 @@ const templateComponents = {
|
|
|
83
83
|
BaseBoolean,
|
|
84
84
|
BaseSelect,
|
|
85
85
|
BaseBadge,
|
|
86
|
-
|
|
86
|
+
BaseAppSnackbars,
|
|
87
87
|
BaseAppDialogs,
|
|
88
88
|
BaseCounter,
|
|
89
89
|
BaseContainer,
|
|
@@ -111,7 +111,7 @@ const template = `
|
|
|
111
111
|
|
|
112
112
|
${templateDataTable}
|
|
113
113
|
|
|
114
|
-
<
|
|
114
|
+
<BaseAppSnackbars></BaseAppSnackbars>
|
|
115
115
|
<BaseAppDialogs></BaseAppDialogs>
|
|
116
116
|
</BaseContainer>
|
|
117
117
|
</div>
|
package/src/stories/PageShow.vue
CHANGED
|
@@ -361,13 +361,13 @@
|
|
|
361
361
|
</div>
|
|
362
362
|
</BaseContainer>
|
|
363
363
|
|
|
364
|
-
<
|
|
364
|
+
<BaseAppSnackbars />
|
|
365
365
|
<BaseAppDialogs />
|
|
366
366
|
</div>
|
|
367
367
|
</template>
|
|
368
368
|
|
|
369
369
|
<script lang="ts" setup>
|
|
370
|
-
import {
|
|
370
|
+
import { useSnackbarsStore } from '..';
|
|
371
371
|
|
|
372
372
|
import BaseCard from '@/components/BaseCard.vue';
|
|
373
373
|
import BaseCardRow from '@/components/BaseCardRow.vue';
|
|
@@ -380,7 +380,7 @@ import BaseTimeline from '@/components/BaseTimeline.vue';
|
|
|
380
380
|
import { BaseIcon } from '../components/index';
|
|
381
381
|
import BaseContainer from '@/components/BaseContainer.vue';
|
|
382
382
|
import BaseClipboard from '@/components/BaseClipboard.vue';
|
|
383
|
-
import
|
|
383
|
+
import BaseAppSnackbars from '@/components/BaseAppSnackbars.vue';
|
|
384
384
|
import BaseAppDialogs from '@/components/BaseAppDialogs.vue';
|
|
385
385
|
|
|
386
386
|
const timelineItems = [
|
|
@@ -415,7 +415,7 @@ const timelineItems = [
|
|
|
415
415
|
];
|
|
416
416
|
|
|
417
417
|
function showAlert(text: string) {
|
|
418
|
-
|
|
418
|
+
useSnackbarsStore().push({
|
|
419
419
|
title: text,
|
|
420
420
|
text: text,
|
|
421
421
|
color: 'success'
|
package/src/types/index.ts
CHANGED
|
@@ -97,7 +97,7 @@ export interface ActionItem {
|
|
|
97
97
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
98
|
export type Row = Record<string, any>;
|
|
99
99
|
|
|
100
|
-
export interface
|
|
100
|
+
export interface BaseTableColumnData {
|
|
101
101
|
id: string;
|
|
102
102
|
label: string;
|
|
103
103
|
field: string;
|
|
@@ -116,9 +116,9 @@ export interface BaseTableColumn {
|
|
|
116
116
|
width: undefined | number;
|
|
117
117
|
};
|
|
118
118
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
|
-
thAttrs: (column:
|
|
119
|
+
thAttrs: (column: BaseTableColumnData) => Record<string, any>;
|
|
120
120
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
-
tdAttrs: (row: Row, column:
|
|
121
|
+
tdAttrs: (row: Row, column: BaseTableColumnData) => Record<string, any>;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
@@ -170,17 +170,17 @@ export interface Dialog {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
173
|
+
* Snackbar
|
|
174
174
|
*/
|
|
175
175
|
|
|
176
|
-
export interface
|
|
176
|
+
export interface SnackbarOptions {
|
|
177
177
|
title: string;
|
|
178
178
|
text: string;
|
|
179
179
|
color?: 'info' | 'success' | 'danger' | 'warning';
|
|
180
180
|
duration?: number;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
export interface
|
|
183
|
+
export interface Snackbar {
|
|
184
184
|
id: number;
|
|
185
185
|
title: string;
|
|
186
186
|
text: string;
|
|
@@ -189,7 +189,7 @@ export interface Notification {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
*
|
|
192
|
+
* Notification
|
|
193
193
|
*/
|
|
194
194
|
|
|
195
195
|
export interface NotificationsConfig {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Notification, NotificationOptions } from '../types';
|
|
2
|
-
export declare const useNotificationsStore: import("pinia").StoreDefinition<"notifications", {
|
|
3
|
-
count: number;
|
|
4
|
-
notifications: Notification[];
|
|
5
|
-
timeouts: Record<number, number>;
|
|
6
|
-
}, {}, {
|
|
7
|
-
push(options: NotificationOptions): void;
|
|
8
|
-
remove(notification: Notification): void;
|
|
9
|
-
clear(): void;
|
|
10
|
-
}>;
|
|
File without changes
|