vueless 0.0.50 → 0.0.52
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/adatper.locale/locales/en.js +2 -0
- package/composable.breakpoint/index.js +93 -0
- package/index.js +9 -0
- package/package.json +4 -6
- package/service.ui/index.js +1 -0
- package/ui.button/composables/attrs.composable.js +9 -2
- package/ui.button-link/composables/attrs.composable.js +23 -3
- package/ui.button-toggle/configs/default.config.js +1 -0
- package/ui.container-card/composable/attrs.composable.js +2 -2
- package/ui.container-card/index.vue +3 -6
- package/ui.container-modal/composables/attrs.composable.js +5 -8
- package/ui.container-modal-confirm/composable/attrs.composable.js +55 -5
- package/ui.container-page/composables/attrs.composable.js +3 -3
- package/ui.container-page/index.vue +4 -6
- package/ui.form-calendar/configs/default.config.js +21 -21
- package/ui.form-color-picker/composables/attrs.composable.js +2 -9
- package/ui.form-date-picker/configs/default.config.js +1 -1
- package/ui.form-date-picker-range/configs/default.config.js +16 -16
- package/ui.form-date-picker-range/index.vue +3 -4
- package/ui.form-input/configs/default.config.js +2 -2
- package/ui.form-radio-card/composables/attrs.composable.js +2 -2
- package/ui.form-radio-card/index.vue +6 -10
- package/ui.form-select/configs/default.config.js +2 -2
- package/ui.form-textarea/configs/default.config.js +1 -1
- package/ui.loader-rendering/composables/useLoaderRendering.js +19 -0
- package/ui.loader-rendering/index.vue +15 -16
- package/ui.navigation-pagination/configs/default.config.js +2 -2
- package/ui.notify/Docs.mdx +84 -0
- package/ui.notify/composables/attrs.composable.js +30 -0
- package/ui.notify/configs/default.config.js +47 -0
- package/ui.notify/constants/index.js +19 -0
- package/ui.notify/index.stories.js +77 -0
- package/ui.notify/index.vue +196 -214
- package/ui.notify/services/index.js +65 -63
- package/ui.other-loader-top/composables/useLoaderTop.js +57 -0
- package/ui.other-loader-top/index.vue +12 -13
- package/ui.text-alert/composables/attrs.composable.js +1 -1
- package/web-types.json +21 -16
- package/ui.loader-rendering/store/index.js +0 -17
- package/ui.notify/index.sto_ries.js +0 -102
- package/ui.other-loader-top/store/index.js +0 -59
- package/ui.viewport/index.vue +0 -78
- package/ui.viewport/store/index.js +0 -47
package/ui.notify/index.vue
CHANGED
|
@@ -1,248 +1,230 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<TransitionGroup
|
|
3
|
+
ref="notificationsWrapperRef"
|
|
4
|
+
:style="notifyPositionStyles"
|
|
5
|
+
tag="div"
|
|
6
|
+
v-bind="{ ...config.transitionGroup, ...wrapperAttrs }"
|
|
6
7
|
>
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
8
|
+
<div
|
|
9
|
+
v-for="notification in notifications"
|
|
10
|
+
:key="notification.id"
|
|
11
|
+
v-bind="bodyAttrs"
|
|
12
|
+
:class="getNotificationClasses(notification)"
|
|
13
|
+
>
|
|
14
|
+
<UIcon
|
|
15
|
+
v-if="notification.type === NOTIFY_TYPE.success"
|
|
16
|
+
data-cy="type-notify"
|
|
17
|
+
color="green"
|
|
18
|
+
variant="light"
|
|
19
|
+
size="md"
|
|
20
|
+
:name="config.iconSuccessName"
|
|
21
|
+
v-bind="iconSuccessAttrs"
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<UIcon
|
|
25
|
+
v-else-if="notification.type === NOTIFY_TYPE.warning"
|
|
26
|
+
data-cy="type-notify"
|
|
27
|
+
color="orange"
|
|
28
|
+
variant="light"
|
|
29
|
+
size="md"
|
|
30
|
+
:name="config.iconWarningName"
|
|
31
|
+
v-bind="iconWarningAttrs"
|
|
32
|
+
/>
|
|
33
|
+
|
|
34
|
+
<UIcon
|
|
35
|
+
v-else-if="notification.type === NOTIFY_TYPE.error"
|
|
36
|
+
data-cy="type-notify"
|
|
37
|
+
color="red"
|
|
38
|
+
variant="light"
|
|
39
|
+
size="md"
|
|
40
|
+
:name="config.iconErrorName"
|
|
41
|
+
v-bind="iconErrorAttrs"
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
<div v-bind="contentAttrs">
|
|
45
|
+
<template v-if="vHtml">
|
|
46
|
+
<span v-bind="labelAttrs" v-html="notification.label" />
|
|
47
|
+
<span v-bind="descriptionAttrs" v-html="getText(notification.text, notification.type)" />
|
|
48
|
+
</template>
|
|
49
|
+
<template v-else>
|
|
50
|
+
<span v-bind="labelAttrs" v-text="notification.label" />
|
|
51
|
+
<span v-bind="descriptionAttrs" v-text="getText(notification.text, notification.type)" />
|
|
52
|
+
</template>
|
|
49
53
|
</div>
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
|
|
55
|
+
<UIcon
|
|
56
|
+
color="gray"
|
|
57
|
+
variant="light"
|
|
58
|
+
size="xs"
|
|
59
|
+
interactive
|
|
60
|
+
:name="config.iconCloseName"
|
|
61
|
+
v-bind="iconCloseAttrs"
|
|
62
|
+
@click="onClickClose(notification)"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
</TransitionGroup>
|
|
52
66
|
</template>
|
|
53
67
|
|
|
54
|
-
<script>
|
|
55
|
-
import {
|
|
68
|
+
<script setup>
|
|
69
|
+
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
70
|
+
import { merge } from "lodash-es";
|
|
56
71
|
|
|
57
|
-
import
|
|
72
|
+
import UIService, { globalComponentConfig, cx } from "../service.ui";
|
|
58
73
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
warning: "warning",
|
|
62
|
-
error: "error",
|
|
63
|
-
};
|
|
74
|
+
import { useLocale } from "../composable.locale";
|
|
75
|
+
import { useAttrs } from "./composables/attrs.composable";
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
components: {
|
|
68
|
-
UIcon,
|
|
69
|
-
},
|
|
77
|
+
import defaultConfig from "./configs/default.config";
|
|
78
|
+
import { UNotify, NOTIFY_TYPE, POSITION } from "./constants";
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A position on the x-axis.
|
|
74
|
-
* @values left, center, right
|
|
75
|
-
*/
|
|
76
|
-
xPosition: {
|
|
77
|
-
type: String,
|
|
78
|
-
default: "center",
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* A position on the y-axis.
|
|
83
|
-
* @values top, bottom
|
|
84
|
-
*/
|
|
85
|
-
yPosition: {
|
|
86
|
-
type: String,
|
|
87
|
-
default: "top",
|
|
88
|
-
},
|
|
89
|
-
},
|
|
80
|
+
import UIcon from "../ui.image-icon";
|
|
90
81
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
/* Should be a string for correct web-types gen */
|
|
83
|
+
defineOptions({ name: "UNotify", inheritAttrs: false });
|
|
84
|
+
|
|
85
|
+
const props = defineProps({
|
|
86
|
+
/**
|
|
87
|
+
* A position on the x-axis.
|
|
88
|
+
* @values left, center, right
|
|
89
|
+
*/
|
|
90
|
+
xPosition: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: UIService.get(defaultConfig, UNotify).default.xPosition,
|
|
95
93
|
},
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
isErrorType() {
|
|
107
|
-
return this.type === NOTIFY_TYPE.error;
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
i18n() {
|
|
111
|
-
return {
|
|
112
|
-
message: `${this.type}.default`,
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
position() {
|
|
117
|
-
return [this.yPosition, this.xPosition];
|
|
118
|
-
},
|
|
95
|
+
/**
|
|
96
|
+
* A position on the y-axis.
|
|
97
|
+
* @values top, bottom
|
|
98
|
+
*/
|
|
99
|
+
yPosition: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: UIService.get(defaultConfig, UNotify).default.yPosition,
|
|
119
102
|
},
|
|
120
103
|
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Use v-html to render notification label and description content.
|
|
106
|
+
*/
|
|
107
|
+
vHtml: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
default: UIService.get(defaultConfig, UNotify).default.vHtml,
|
|
123
110
|
},
|
|
124
111
|
|
|
125
|
-
|
|
126
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Sets component ui config object.
|
|
114
|
+
*/
|
|
115
|
+
config: {
|
|
116
|
+
type: Object,
|
|
117
|
+
default: () => ({}),
|
|
127
118
|
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const {
|
|
122
|
+
config,
|
|
123
|
+
wrapperAttrs,
|
|
124
|
+
bodyAttrs,
|
|
125
|
+
contentAttrs,
|
|
126
|
+
labelAttrs,
|
|
127
|
+
descriptionAttrs,
|
|
128
|
+
iconSuccessAttrs,
|
|
129
|
+
iconWarningAttrs,
|
|
130
|
+
iconErrorAttrs,
|
|
131
|
+
iconCloseAttrs,
|
|
132
|
+
} = useAttrs(props);
|
|
133
|
+
|
|
134
|
+
const { tm } = useLocale();
|
|
135
|
+
|
|
136
|
+
const notifications = ref([]);
|
|
137
|
+
const notifyPositionStyles = ref({});
|
|
138
|
+
|
|
139
|
+
const notificationsWrapperRef = ref(null);
|
|
140
|
+
|
|
141
|
+
const currentLocale = computed(() => merge(tm("UNotify"), props.config.i18n));
|
|
142
|
+
|
|
143
|
+
onMounted(() => {
|
|
144
|
+
window.addEventListener("resize", setPosition, { passive: true });
|
|
145
|
+
window.addEventListener("notifyStart", onNotifyStart);
|
|
146
|
+
window.addEventListener("notifyEnd", onNotifyEnd);
|
|
147
|
+
window.addEventListener("notifyClearAll", onClearAll);
|
|
148
|
+
|
|
149
|
+
setPosition();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
onBeforeUnmount(() => {
|
|
153
|
+
window.removeEventListener("resize", setPosition);
|
|
154
|
+
window.removeEventListener("notifyStart", onNotifyStart);
|
|
155
|
+
window.removeEventListener("notifyEnd", onNotifyEnd);
|
|
156
|
+
window.removeEventListener("notifyClearAll", onClearAll);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
function onNotifyStart(event) {
|
|
160
|
+
notifications.value.push({ ...event.detail });
|
|
161
|
+
}
|
|
128
162
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (text) {
|
|
136
|
-
return text;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return this.i18n.message;
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
setPosition() {
|
|
143
|
-
const getOffsetWidth = (className) =>
|
|
144
|
-
className ? document.querySelector(`.${className}`)?.offsetWidth : 0;
|
|
145
|
-
|
|
146
|
-
const NOTIFY_CLASS = "vueless-notify";
|
|
147
|
-
const classes = globalComponentConfig.UNotify?.positionClasses;
|
|
148
|
-
const pageWidth = getOffsetWidth(classes.page || "UNotifyPage");
|
|
149
|
-
const asideWidth = getOffsetWidth(classes.aside || "UNotifyAside");
|
|
150
|
-
const notifyWidth = getOffsetWidth(NOTIFY_CLASS);
|
|
163
|
+
function onNotifyEnd(event) {
|
|
164
|
+
notifications.value = notifications.value.filter(
|
|
165
|
+
(notification) => notification.id !== event.detail.id,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
151
168
|
|
|
152
|
-
|
|
169
|
+
function onClearAll() {
|
|
170
|
+
notifications.value = [];
|
|
171
|
+
}
|
|
153
172
|
|
|
154
|
-
|
|
173
|
+
function onClickClose(targetNotification) {
|
|
174
|
+
notifications.value = notifications.value.filter(
|
|
175
|
+
(notification) => notification.id !== targetNotification.id,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
155
178
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
160
|
-
</script>
|
|
179
|
+
function getOffsetWidth(selector) {
|
|
180
|
+
return document.querySelector(selector)?.offsetWidth || 0;
|
|
181
|
+
}
|
|
161
182
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
default: "Попередження."
|
|
184
|
-
</i18n>
|
|
185
|
-
|
|
186
|
-
<style lang="postcss" scoped>
|
|
187
|
-
.vueless-notify {
|
|
188
|
-
:deep(.vue-notification-wrapper) {
|
|
189
|
-
@apply overflow-visible;
|
|
183
|
+
function setPosition() {
|
|
184
|
+
const positionClasses = globalComponentConfig.UNotify?.positionClasses;
|
|
185
|
+
const pageClass = positionClasses?.page || config.value.positionClasses.page;
|
|
186
|
+
const asideClass = positionClasses?.aside || config.value.positionClasses.aside;
|
|
187
|
+
const pageWidth = getOffsetWidth(`${pageClass}`);
|
|
188
|
+
const asideWidth = getOffsetWidth(`${asideClass}`);
|
|
189
|
+
const notifyWidth = notificationsWrapperRef.value.$el?.offsetWidth || 0;
|
|
190
|
+
|
|
191
|
+
const styles = {
|
|
192
|
+
left: "auto",
|
|
193
|
+
top: "auto",
|
|
194
|
+
right: "auto",
|
|
195
|
+
bottom: "auto",
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
styles[props.yPosition] = "0px";
|
|
199
|
+
|
|
200
|
+
if (props.xPosition === POSITION.center) {
|
|
201
|
+
styles.left = `calc(50% - ${notifyWidth / 2}px)`;
|
|
202
|
+
} else {
|
|
203
|
+
styles[props.xPosition] = "0px";
|
|
190
204
|
}
|
|
191
205
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
@apply flex items-center;
|
|
195
|
-
@apply mb-3 p-4 shadow-[0_4px_16px_rgba(17,24,39,0.5)] md:shadow-[0_0px_12px_rgba(0,0,0,0.25)];
|
|
196
|
-
|
|
197
|
-
.icon-close {
|
|
198
|
-
path {
|
|
199
|
-
@apply fill-current text-gray-400;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
206
|
+
if (pageWidth && props.xPosition !== POSITION.right) {
|
|
207
|
+
styles.left = `${asideWidth + pageWidth / 2 - notifyWidth / 2}px`;
|
|
202
208
|
}
|
|
203
209
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
100.16% 500.78% at 0% 50%,
|
|
207
|
-
rgba(251, 146, 60, 0.2) 2.17%,
|
|
208
|
-
transparent
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
.type-icon path {
|
|
212
|
-
@apply fill-current text-orange-400;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
210
|
+
notifyPositionStyles.value = styles;
|
|
211
|
+
}
|
|
215
212
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
rgba(74, 222, 128, 0.1) 2.17%,
|
|
220
|
-
transparent
|
|
221
|
-
);
|
|
213
|
+
function getText(notificationText, type) {
|
|
214
|
+
return notificationText || currentLocale.value[type];
|
|
215
|
+
}
|
|
222
216
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
217
|
+
function getNotificationClasses(notification) {
|
|
218
|
+
if (notification.type === NOTIFY_TYPE.success) {
|
|
219
|
+
return cx([bodyAttrs.value.class, config.value.bodySuccess]);
|
|
226
220
|
}
|
|
227
221
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
100.16% 500.78% at 0% 50%,
|
|
231
|
-
rgba(251, 113, 133, 0.2) 2.17%,
|
|
232
|
-
transparent
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
.type-icon path {
|
|
236
|
-
@apply fill-current text-red-400;
|
|
237
|
-
}
|
|
222
|
+
if (notification.type === NOTIFY_TYPE.warning) {
|
|
223
|
+
return cx([bodyAttrs.value.class, config.value.bodyWarning]);
|
|
238
224
|
}
|
|
239
225
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
otherwise we will get gradient with white background
|
|
243
|
-
*/
|
|
244
|
-
:deep(.notify-body) {
|
|
245
|
-
@apply bg-gray-900 bg-opacity-90;
|
|
226
|
+
if (notification.type === NOTIFY_TYPE.error) {
|
|
227
|
+
return cx([bodyAttrs.value.class, config.value.bodyError]);
|
|
246
228
|
}
|
|
247
229
|
}
|
|
248
|
-
</
|
|
230
|
+
</script>
|
|
@@ -1,87 +1,89 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { globalComponentConfig, getRandomId } from "../../service.ui";
|
|
2
|
+
|
|
3
|
+
import { NOTIFY_TYPE } from "../constants";
|
|
4
|
+
|
|
5
|
+
const delayBetweenClones = 1000;
|
|
6
|
+
|
|
7
|
+
let lastMessageTime = undefined;
|
|
8
|
+
let lastMessage = undefined;
|
|
3
9
|
|
|
4
10
|
const defaultDuration = {
|
|
5
11
|
short: 4000,
|
|
6
12
|
medium: 8000,
|
|
7
13
|
long: 12000,
|
|
8
|
-
permanent: 300000,
|
|
9
14
|
};
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
notifyInstance = Vue3Notify;
|
|
16
|
+
const notifyClearAllEvent = new Event("notifyClearAll");
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
export function notify(settings) {
|
|
19
|
+
const { type, label, text, duration, delayDuplicates } = settings;
|
|
20
|
+
const currentNotifyDuration =
|
|
21
|
+
duration || globalComponentConfig.UNotify?.duration?.short || defaultDuration.short;
|
|
22
|
+
const isSameMessage = lastMessage === text && new Date() - lastMessageTime < delayBetweenClones;
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.#lastMessageCode === code && new Date() - this.#lastMessageTime < 1000;
|
|
24
|
+
if ((isSameMessage || !text) && delayDuplicates) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
lastMessageTime = new Date();
|
|
29
|
+
lastMessage = text;
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
const detail = {
|
|
32
|
+
type,
|
|
33
|
+
id: getRandomId(),
|
|
34
|
+
label: label || "",
|
|
35
|
+
text: text || "",
|
|
36
|
+
duration: currentNotifyDuration,
|
|
37
|
+
};
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
type,
|
|
30
|
-
title: title || "",
|
|
31
|
-
text: text || "",
|
|
32
|
-
duration: duration || globalComponentConfig.UNotify?.duration?.short || defaultDuration.short,
|
|
33
|
-
ignoreDuplicates: ignoreDuplicates || false,
|
|
34
|
-
closeOnClick: closeOnClick || false,
|
|
35
|
-
data: { ...data, code },
|
|
36
|
-
});
|
|
37
|
-
}
|
|
39
|
+
const notifyStart = new CustomEvent("notifyStart", { detail });
|
|
40
|
+
const notifyEnd = new CustomEvent("notifyEnd", { detail });
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
this.notify({
|
|
41
|
-
type: "success",
|
|
42
|
-
code: code,
|
|
43
|
-
duration: duration,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
42
|
+
window.dispatchEvent(notifyStart);
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
type: "warning",
|
|
50
|
-
code: code,
|
|
51
|
-
duration: duration,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
44
|
+
setTimeout(() => window.dispatchEvent(notifyEnd), currentNotifyDuration);
|
|
45
|
+
}
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
export function notifySuccess(text, duration = globalComponentConfig.UNotify?.duration?.short) {
|
|
48
|
+
notify({
|
|
49
|
+
type: NOTIFY_TYPE.success,
|
|
50
|
+
text,
|
|
51
|
+
duration,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
62
54
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
55
|
+
export function notifyWarning(text, duration = globalComponentConfig.UNotify?.duration?.medium) {
|
|
56
|
+
notify({
|
|
57
|
+
type: NOTIFY_TYPE.warning,
|
|
58
|
+
text,
|
|
59
|
+
duration,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
69
62
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
export function notifyError(text, duration = globalComponentConfig.UNotify?.duration?.long) {
|
|
64
|
+
notify({
|
|
65
|
+
type: NOTIFY_TYPE.error,
|
|
66
|
+
text,
|
|
67
|
+
duration,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function clearAllNotifications() {
|
|
72
|
+
window.dispatchEvent(notifyClearAllEvent);
|
|
73
|
+
}
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
export function setDelayedNotify(settings) {
|
|
76
|
+
localStorage.setItem("notify", JSON.stringify(settings));
|
|
77
|
+
}
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
export function getDelayedNotify() {
|
|
80
|
+
const notifyData = JSON.parse(localStorage.getItem("notify"));
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
const { type, message } = notifyData;
|
|
82
|
+
clearAllNotifications();
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
if (notifyData) {
|
|
85
|
+
notify(notifyData);
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
}
|
|
87
|
+
localStorage.removeItem("notify");
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ref, readonly } from "vue";
|
|
2
|
+
|
|
3
|
+
const isLoading = ref(false);
|
|
4
|
+
const requestQueue = ref([]);
|
|
5
|
+
const loaderRequestQueue = ref([]);
|
|
6
|
+
const loaderRequestTimeout = ref(0);
|
|
7
|
+
const componentLoaderRequestQueue = ref([]);
|
|
8
|
+
|
|
9
|
+
function setLoadingOn(url) {
|
|
10
|
+
loaderRequestQueue.value.push(url);
|
|
11
|
+
|
|
12
|
+
isLoading.value = true;
|
|
13
|
+
|
|
14
|
+
clearTimeout(loaderRequestTimeout.value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function setLoadingOff(url) {
|
|
18
|
+
loaderRequestQueue.value = url ? loaderRequestQueue.value.filter((item) => item !== url) : [];
|
|
19
|
+
|
|
20
|
+
loaderRequestTimeout.value = setTimeout(() => {
|
|
21
|
+
if (!loaderRequestQueue.value.length) {
|
|
22
|
+
isLoading.value = false;
|
|
23
|
+
}
|
|
24
|
+
}, 50);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function addRequestUrl(url) {
|
|
28
|
+
requestQueue.value.push(url);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function removeRequestUrl(url) {
|
|
32
|
+
requestQueue.value = requestQueue.value.filter((item) => item !== url);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function setComponentRequestQueue(requests) {
|
|
36
|
+
componentLoaderRequestQueue.value = [...componentLoaderRequestQueue, ...requests];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function removeComponentRequestQueue() {
|
|
40
|
+
componentLoaderRequestQueue.value = [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default function useLoaderTop() {
|
|
44
|
+
return {
|
|
45
|
+
isLoading: readonly(isLoading),
|
|
46
|
+
requestQueue: readonly(requestQueue),
|
|
47
|
+
loaderRequestQueue: readonly(loaderRequestQueue),
|
|
48
|
+
loaderRequestTimeout: readonly(loaderRequestTimeout),
|
|
49
|
+
componentLoaderRequestQueue: readonly(componentLoaderRequestQueue),
|
|
50
|
+
setLoadingOn,
|
|
51
|
+
setLoadingOff,
|
|
52
|
+
addRequestUrl,
|
|
53
|
+
removeRequestUrl,
|
|
54
|
+
setComponentRequestQueue,
|
|
55
|
+
removeComponentRequestQueue,
|
|
56
|
+
};
|
|
57
|
+
}
|