sprintify-ui 0.6.88 → 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/index.d.ts +2 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/types/stores/snackbars.d.ts +19 -0
- package/dist/types/types/index.d.ts +4 -4
- 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/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 +2 -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 +4 -4
- package/dist/types/stores/notifications.d.ts +0 -10
- /package/dist/types/components/{BaseAppNotifications.vue.d.ts → BaseAppSnackbars.vue.d.ts} +0 -0
|
@@ -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';
|
|
@@ -101,4 +101,4 @@ import BaseLayoutStacked from './BaseLayoutStacked.vue';
|
|
|
101
101
|
import BaseLayoutStackedConfigurable from './BaseLayoutStackedConfigurable.vue';
|
|
102
102
|
import BaseLayoutSidebar from './BaseLayoutSidebar.vue';
|
|
103
103
|
import BaseLayoutSidebarConfigurable from './BaseLayoutSidebarConfigurable.vue';
|
|
104
|
-
export { BaseActionItem, BaseAddressForm, BaseAlert, BaseApp, BaseAppDialogs,
|
|
104
|
+
export { BaseActionItem, BaseAddressForm, BaseAlert, BaseApp, BaseAppDialogs, BaseAppSnackbars, BaseAutocomplete, BaseAutocompleteFetch, BaseAvatar, BaseAvatarGroup, BaseBadge, BaseBelongsTo, BaseBelongsToFetch, BaseBoolean, BaseBreadcrumbs, BaseButton, BaseButtonGroup, BaseCard, BaseCardRow, BaseCharacterCounter, BaseClipboard, BaseCalendar, BaseColor, BaseContainer, BaseCounter, BaseCropper, BaseCropperModal, BaseDataIterator, BaseDataTable, BaseDatePicker, BaseTimePicker, BaseDateSelect, BaseDescriptionList, BaseDescriptionListItem, BaseDialog, BaseDisplayRelativeTime, BaseDropdown, BaseDropdownAutocomplete, BaseEmptyState, BaseField, BaseFieldI18n, BaseFilePicker, BaseFilePickerCrop, BaseFileUploader, BaseForm, BaseGantt, BaseHasMany, BaseHeader, BaseIcon, BaseIconPicker, BaseInput, BaseInputLabel, BaseInputPercent, BaseLoadingCover, BaseMediaItem, BaseMediaLibrary, BaseMediaPreview, BaseMenu, BaseMenuItem, BaseModalCenter, BaseModalSide, BaseNavbar, BaseNavbarItem, BaseNavbarItemContent, BaseNavbarSideItem, BasePagination, BasePanel, BasePassword, BaseProgressCircle, BaseRadioGroup, BaseReadMore, BaseRichText, BaseSelect, BaseShortcut, BaseSideNavigation, BaseSideNavigationItem, BaseSkeleton, BaseStatistic, BaseStepper, BaseStepperItem, BaseSwitch, BaseSystemAlert, BaseTable, BaseTableBody, BaseTableCell, BaseTableHead, BaseTableHeader, BaseTableRow, BaseTabs, BaseTabItem, BaseTagAutocomplete, BaseTagAutocompleteFetch, BaseTableColumn, BaseTextarea, BaseTextareaAutoresize, BaseTimeline, BaseTimelineItem, BaseTooltip, BaseUniqueCode, BaseLayoutStacked, BaseLayoutStackedConfigurable, BaseLayoutSidebar, BaseLayoutSidebarConfigurable, };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { App } from 'vue';
|
|
3
3
|
import { useDialogsStore } from './stores/dialogs';
|
|
4
|
-
import { useNotificationsStore } from './stores/
|
|
4
|
+
import { useSnackbarsStore, useNotificationsStore } from './stores/snackbars';
|
|
5
5
|
import { useSystemAlertStore } from './stores/systemAlerts';
|
|
6
6
|
import { useClickOutside } from './composables/clickOutside';
|
|
7
7
|
import { useField } from './composables/field';
|
|
@@ -245,6 +245,7 @@ export type * from './types';
|
|
|
245
245
|
export { messages };
|
|
246
246
|
export { config };
|
|
247
247
|
export { useDialogsStore };
|
|
248
|
+
export { useSnackbarsStore };
|
|
248
249
|
export { useNotificationsStore };
|
|
249
250
|
export { useSystemAlertStore };
|
|
250
251
|
export { useClickOutside };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Snackbar, SnackbarOptions } from '../types';
|
|
2
|
+
export declare const useSnackbarsStore: import("pinia").StoreDefinition<"notifications", {
|
|
3
|
+
count: number;
|
|
4
|
+
snackbars: Snackbar[];
|
|
5
|
+
timeouts: Record<number, number>;
|
|
6
|
+
}, {}, {
|
|
7
|
+
push(options: SnackbarOptions): void;
|
|
8
|
+
remove(snackbar: Snackbar): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const useNotificationsStore: import("pinia").StoreDefinition<"notifications", {
|
|
12
|
+
count: number;
|
|
13
|
+
snackbars: Snackbar[];
|
|
14
|
+
timeouts: Record<number, number>;
|
|
15
|
+
}, {}, {
|
|
16
|
+
push(options: SnackbarOptions): void;
|
|
17
|
+
remove(snackbar: Snackbar): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}>;
|
|
@@ -134,15 +134,15 @@ export interface Dialog {
|
|
|
134
134
|
onCancel: () => void;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
*
|
|
137
|
+
* Snackbar
|
|
138
138
|
*/
|
|
139
|
-
export interface
|
|
139
|
+
export interface SnackbarOptions {
|
|
140
140
|
title: string;
|
|
141
141
|
text: string;
|
|
142
142
|
color?: 'info' | 'success' | 'danger' | 'warning';
|
|
143
143
|
duration?: number;
|
|
144
144
|
}
|
|
145
|
-
export interface
|
|
145
|
+
export interface Snackbar {
|
|
146
146
|
id: number;
|
|
147
147
|
title: string;
|
|
148
148
|
text: string;
|
|
@@ -150,7 +150,7 @@ export interface Notification {
|
|
|
150
150
|
duration: number;
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
|
-
*
|
|
153
|
+
* Notification
|
|
154
154
|
*/
|
|
155
155
|
export interface NotificationsConfig {
|
|
156
156
|
count: number;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<slot />
|
|
4
4
|
|
|
5
5
|
<!-- Notifications -->
|
|
6
|
-
<
|
|
6
|
+
<BaseAppSnackbars />
|
|
7
7
|
|
|
8
8
|
<!-- Dialogs -->
|
|
9
9
|
<BaseAppDialogs />
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
14
|
import BaseAppDialogs from './BaseAppDialogs.vue';
|
|
15
|
-
import
|
|
15
|
+
import BaseAppSnackbars from './BaseAppSnackbars.vue';
|
|
16
16
|
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Teleport to="body">
|
|
3
3
|
<div
|
|
4
|
-
class="pointer-events-none fixed inset-0 z-
|
|
4
|
+
class="pointer-events-none fixed inset-0 z-snackbars flex items-end justify-end p-6 md:p-8"
|
|
5
5
|
>
|
|
6
6
|
<div class="w-full">
|
|
7
7
|
<TransitionGroup
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
leave-to-class="translate-y-2 opacity-0"
|
|
14
14
|
>
|
|
15
15
|
<div
|
|
16
|
-
v-for="
|
|
17
|
-
:key="
|
|
16
|
+
v-for="snackbar in snackbars"
|
|
17
|
+
:key="snackbar.id"
|
|
18
18
|
>
|
|
19
19
|
<BaseToast
|
|
20
20
|
class="mt-4"
|
|
21
|
-
:text="
|
|
22
|
-
:color="
|
|
21
|
+
:text="snackbar.text"
|
|
22
|
+
:color="snackbar.color"
|
|
23
23
|
/>
|
|
24
24
|
</div>
|
|
25
25
|
</TransitionGroup>
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
31
|
<script lang="ts" setup>
|
|
32
|
-
import {
|
|
32
|
+
import { useSnackbarsStore } from '@/index';
|
|
33
33
|
import BaseToast from './BaseToast.vue';
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const snackbarsStore = useSnackbarsStore();
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
return
|
|
37
|
+
const snackbars = computed(() => {
|
|
38
|
+
return snackbarsStore.snackbars;
|
|
39
39
|
});
|
|
40
40
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseCropper from '@/components/BaseCropper.vue';
|
|
2
2
|
import BaseLoadingCover from '@/components/BaseLoadingCover.vue';
|
|
3
|
-
import
|
|
3
|
+
import BaseAppSnackbars from '@/components/BaseAppSnackbars.vue';
|
|
4
4
|
import { Icon as BaseIcon } from '@iconify/vue';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
@@ -17,7 +17,7 @@ const Template = (args) => ({
|
|
|
17
17
|
BaseCropper,
|
|
18
18
|
BaseIcon,
|
|
19
19
|
BaseLoadingCover,
|
|
20
|
-
|
|
20
|
+
BaseAppSnackbars,
|
|
21
21
|
},
|
|
22
22
|
setup() {
|
|
23
23
|
const cropperRef = ref(null);
|
|
@@ -74,7 +74,7 @@ const Template = (args) => ({
|
|
|
74
74
|
</template>
|
|
75
75
|
</BaseCropper>
|
|
76
76
|
|
|
77
|
-
<
|
|
77
|
+
<BaseAppSnackbars></BaseAppSnackbars>
|
|
78
78
|
`,
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseCropperModal from '@/components/BaseCropperModal.vue';
|
|
2
|
-
import
|
|
2
|
+
import BaseAppSnackbars from '@/components/BaseAppSnackbars.vue';
|
|
3
3
|
|
|
4
4
|
const source =
|
|
5
5
|
'https://images.unsplash.com/photo-1560250097-0b93528c311a?auto=format&fit=crop&q=80';
|
|
@@ -13,7 +13,7 @@ export default {
|
|
|
13
13
|
const Template = (args) => ({
|
|
14
14
|
components: {
|
|
15
15
|
BaseCropperModal,
|
|
16
|
-
|
|
16
|
+
BaseAppSnackbars,
|
|
17
17
|
},
|
|
18
18
|
setup() {
|
|
19
19
|
const value = ref(true);
|
|
@@ -21,7 +21,7 @@ const Template = (args) => ({
|
|
|
21
21
|
},
|
|
22
22
|
template: `
|
|
23
23
|
<BaseCropperModal v-bind="args" v-model="value"></BaseCropperModal>
|
|
24
|
-
<
|
|
24
|
+
<BaseAppSnackbars></BaseAppSnackbars>
|
|
25
25
|
`,
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -3,7 +3,7 @@ import BaseTableColumn from './BaseTableColumn.vue';
|
|
|
3
3
|
import BaseBoolean from './BaseBoolean.vue';
|
|
4
4
|
import BaseSelect from './BaseSelect.vue';
|
|
5
5
|
import BaseBadge from './BaseBadge.vue';
|
|
6
|
-
import
|
|
6
|
+
import BaseAppSnackbars from './BaseAppSnackbars.vue';
|
|
7
7
|
import BaseAppDialogs from './BaseAppDialogs.vue';
|
|
8
8
|
import { onBeforeUnmount } from 'vue';
|
|
9
9
|
import { DateTime } from 'luxon';
|
|
@@ -37,7 +37,7 @@ const templateComponents = {
|
|
|
37
37
|
BaseBoolean,
|
|
38
38
|
BaseSelect,
|
|
39
39
|
BaseBadge,
|
|
40
|
-
|
|
40
|
+
BaseAppSnackbars,
|
|
41
41
|
BaseAppDialogs,
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ const template = `
|
|
|
45
45
|
<div class="font-mono text-sm bg-black px-2 py-1 rounded text-white">Last fetch: {{ lastFetch?.getTime() }} (should update on each fetch)</div>
|
|
46
46
|
<br/>
|
|
47
47
|
${templateDataTable}
|
|
48
|
-
<
|
|
48
|
+
<BaseAppSnackbars></BaseAppSnackbars>
|
|
49
49
|
<BaseAppDialogs></BaseAppDialogs>
|
|
50
50
|
`;
|
|
51
51
|
|
|
@@ -239,7 +239,7 @@ import {
|
|
|
239
239
|
RowAction,
|
|
240
240
|
} from '@/types';
|
|
241
241
|
import { useDialogsStore } from '@/stores/dialogs';
|
|
242
|
-
import {
|
|
242
|
+
import { useSnackbarsStore } from '../stores/snackbars';
|
|
243
243
|
import BaseDataIterator from './BaseDataIterator.vue';
|
|
244
244
|
import { cloneDeep, isArray } from 'lodash';
|
|
245
245
|
|
|
@@ -262,7 +262,7 @@ const router = useRouter();
|
|
|
262
262
|
const http = config.http;
|
|
263
263
|
|
|
264
264
|
const dialogs = useDialogsStore();
|
|
265
|
-
const
|
|
265
|
+
const snackbars = useSnackbarsStore();
|
|
266
266
|
|
|
267
267
|
const table = ref<null | InstanceType<typeof BaseDataTableTemplate>>(null);
|
|
268
268
|
|
|
@@ -564,7 +564,7 @@ const onDelete = (row: CollectionItem) => {
|
|
|
564
564
|
.delete(props.deleteUrl(row))
|
|
565
565
|
.then((response) => {
|
|
566
566
|
if (response.data && response.data.message) {
|
|
567
|
-
|
|
567
|
+
snackbars.push({
|
|
568
568
|
title: t('sui.success'),
|
|
569
569
|
text: response.data.message,
|
|
570
570
|
color: 'success',
|
|
@@ -576,7 +576,7 @@ const onDelete = (row: CollectionItem) => {
|
|
|
576
576
|
fetch();
|
|
577
577
|
})
|
|
578
578
|
.catch((error) => {
|
|
579
|
-
|
|
579
|
+
snackbars.push({
|
|
580
580
|
title: t('sui.error'),
|
|
581
581
|
text: error.response.data?.message ?? 'Unknown error',
|
|
582
582
|
color: 'danger',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseFilePicker from './BaseFilePicker.vue';
|
|
2
2
|
import { Icon as BaseIcon } from '@iconify/vue';
|
|
3
3
|
import ShowValue from '../../.storybook/components/ShowValue.vue';
|
|
4
|
-
import
|
|
4
|
+
import BaseAppSnackbars from '@/components/BaseAppSnackbars.vue';
|
|
5
5
|
import { t } from '@/i18n';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const Template = (args) => ({
|
|
14
|
-
components: { BaseFilePicker, BaseIcon, ShowValue,
|
|
14
|
+
components: { BaseFilePicker, BaseIcon, ShowValue, BaseAppSnackbars },
|
|
15
15
|
setup() {
|
|
16
16
|
const file = ref(null);
|
|
17
17
|
|
|
@@ -56,7 +56,7 @@ const Template = (args) => ({
|
|
|
56
56
|
|
|
57
57
|
<ShowValue :value="file" />
|
|
58
58
|
|
|
59
|
-
<
|
|
59
|
+
<BaseAppSnackbars></BaseAppSnackbars>
|
|
60
60
|
`,
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -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,
|