vueless 0.0.140 → 0.0.141
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/index.js +1 -1
- package/package.json +2 -2
- package/ui.text-notify/Docs.mdx +39 -35
- package/ui.text-notify/configs/default.config.js +11 -12
- package/ui.text-notify/constants/index.js +10 -0
- package/ui.text-notify/index.stories.js +43 -26
- package/ui.text-notify/index.vue +13 -6
- package/ui.text-notify/services/index.js +35 -38
- package/web-types.json +4 -4
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.141",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue Styleless Component Framework.",
|
|
6
6
|
"homepage": "https://vueless.com",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@release-it/bumper": "^6.0.1",
|
|
38
38
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
39
39
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
40
|
-
"@vueless/plugin-vite": "^0.0.
|
|
40
|
+
"@vueless/plugin-vite": "^0.0.27",
|
|
41
41
|
"@vueless/storybook": "^0.0.27",
|
|
42
42
|
"@vueless/web-types": "^0.0.8",
|
|
43
43
|
"autoprefixer": "^10.4.19",
|
package/ui.text-notify/Docs.mdx
CHANGED
|
@@ -15,70 +15,74 @@ import defaultConfig from "./configs/default.config?raw"
|
|
|
15
15
|
## **Default config**
|
|
16
16
|
<Source code={getSource(defaultConfig)} language="jsx" dark />
|
|
17
17
|
|
|
18
|
-
##
|
|
19
|
-
You can trigger notification using
|
|
18
|
+
## Triggering notification
|
|
19
|
+
You can trigger notification using `notify` method.
|
|
20
|
+
Use `notifySuccess`, `notifyWarning`, `notifyError` shortcut methods to trigger notification of a specific type.
|
|
20
21
|
|
|
21
22
|
<Source code={`
|
|
22
23
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
notify,
|
|
25
|
+
notifySuccess,
|
|
26
|
+
notifyWarning,
|
|
27
|
+
notifyError,
|
|
27
28
|
} from "vueless";
|
|
28
29
|
|
|
29
30
|
notify({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
type: "success", // @values: success, warning, error
|
|
32
|
+
label: "Hurray!",
|
|
33
|
+
description: "The file successfully downloaded.",
|
|
34
|
+
duration: 1000, // in milliseconds
|
|
35
|
+
ignoreDuplicates: false // ignore notifications with the same 'description'
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
notifyWarning("Some warning text", durationInMilliseconds);
|
|
41
|
-
notifyError("Some error text", durationInMilliseconds);
|
|
38
|
+
notifySuccess({ description: "The file successfully downloaded." });
|
|
39
|
+
notifyWarning({ description: "The file have been downloaded, but some data is missing." });
|
|
40
|
+
notifyError({ description: "The file can't be downloaded, please check the fields and try again." });
|
|
42
41
|
`} language="jsx" dark />
|
|
43
42
|
|
|
44
|
-
## Clear
|
|
45
|
-
Use
|
|
43
|
+
## Clear notifications
|
|
44
|
+
Use `clearNotifications` method to clear active notifications.
|
|
46
45
|
|
|
47
46
|
<Source code={`
|
|
48
|
-
import {
|
|
47
|
+
import { clearNotifications, notifySuccess } from "vueless";
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
notifySuccess("Some success text", durationInMilliseconds);
|
|
49
|
+
notifySuccess({ description: "The file successfully downloaded." });
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
// and somewhere below
|
|
52
|
+
clearNotifications();
|
|
54
53
|
`} language="jsx" dark />
|
|
55
54
|
|
|
56
55
|
## Trigger notifications
|
|
57
|
-
You can create delayed notification which you can trigger any time later.
|
|
56
|
+
You can create a delayed notification which you can trigger any time later.
|
|
58
57
|
|
|
59
58
|
<Source code={`
|
|
60
59
|
import { setDelayedNotify, getDelayedNotify } from "vueless";
|
|
61
60
|
|
|
62
61
|
setDelayedNotify({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
type: "success", // @values: success, warning, error
|
|
63
|
+
label: "Hurray!",
|
|
64
|
+
description: "The file successfully downloaded.",
|
|
65
|
+
duration: 1000, // in milliseconds
|
|
66
|
+
ignoreDuplicates: false // ignore notifications with the same 'description'
|
|
68
67
|
});
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
// and somewhere below
|
|
70
|
+
getDelayedNotify();
|
|
71
71
|
`} language="jsx" dark />
|
|
72
72
|
|
|
73
|
-
##
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
## Align notification relatively to the layout
|
|
74
|
+
Use `positionClasses` in UNotify config to align a notification component related to layout.
|
|
75
|
+
* `page` – align UNotify inside an element with provided class (UNotifyPage is a default class name).
|
|
76
|
+
* `aside` – add shift for aside width (UNotifyAside is a default class name).
|
|
76
77
|
|
|
77
78
|
<Source code={`
|
|
78
|
-
|
|
79
|
+
{
|
|
80
|
+
...
|
|
81
|
+
UNotify: {
|
|
79
82
|
positionClasses: {
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
page: "UNotifyPage",
|
|
84
|
+
aside: "UNotifyAside",
|
|
82
85
|
},
|
|
86
|
+
}
|
|
83
87
|
}
|
|
84
88
|
`} language="jsx" dark />
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
+
transitionGroup: {
|
|
3
|
+
moveClass: "transition-all duration-500",
|
|
4
|
+
enterActiveClass: "transition-all duration-500",
|
|
5
|
+
leaveActiveClass: "transition-all duration-500 absolute",
|
|
6
|
+
enterFromClass: "opacity-0",
|
|
7
|
+
leaveToClass: "opacity-0",
|
|
8
|
+
},
|
|
2
9
|
wrapper: "absolute overflow-visible md:w-[22rem]",
|
|
3
10
|
body: `
|
|
4
|
-
mb-3 flex w-
|
|
11
|
+
mb-3 flex w-full items-center justify-center gap-3 rounded-2xl bg-gray-900/90
|
|
5
12
|
p-4 shadow-[0_4px_16px_rgba(17,24,39,0.5)] backdrop-blur-md md:shadow-[0_0px_12px_rgba(0,0,0,0.25)]
|
|
6
13
|
`,
|
|
7
14
|
bodySuccess: "bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(74,222,128,0.1)_2.17%,transparent)]",
|
|
8
15
|
bodyWarning: "bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(251,146,60,0.2)_2.17%,transparent)]",
|
|
9
16
|
bodyError: "bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(251,113,133,0.2)_2.17%,transparent)]",
|
|
10
|
-
content: "w-full flex flex-col max-w-full
|
|
11
|
-
label: "mb-
|
|
12
|
-
description: "break-words font-normal
|
|
17
|
+
content: "w-full flex flex-col max-w-full text-sm text-gray-200",
|
|
18
|
+
label: "mb-0.5 font-medium",
|
|
19
|
+
description: "break-words font-normal",
|
|
13
20
|
successIcon: "",
|
|
14
21
|
successIconName: "check_circle",
|
|
15
22
|
warningIcon: "",
|
|
@@ -18,13 +25,6 @@ export default /*tw*/ {
|
|
|
18
25
|
errorIconName: "error",
|
|
19
26
|
closeIcon: "",
|
|
20
27
|
closeIconName: "close",
|
|
21
|
-
transitionGroup: {
|
|
22
|
-
moveClass: "transition-all duration-500",
|
|
23
|
-
enterActiveClass: "transition-all duration-500",
|
|
24
|
-
leaveActiveClass: "transition-all duration-500 absolute",
|
|
25
|
-
enterFromClass: "opacity-0",
|
|
26
|
-
leaveToClass: "opacity-0",
|
|
27
|
-
},
|
|
28
28
|
duration: {
|
|
29
29
|
short: 4000,
|
|
30
30
|
medium: 8000,
|
|
@@ -48,6 +48,5 @@ export default /*tw*/ {
|
|
|
48
48
|
defaultVariants: {
|
|
49
49
|
xPosition: "center",
|
|
50
50
|
yPosition: "top",
|
|
51
|
-
vHtml: false,
|
|
52
51
|
},
|
|
53
52
|
};
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const UNotify = "UNotify";
|
|
6
6
|
|
|
7
|
+
export const LOCAL_STORAGE_ID = "vueless:notify";
|
|
8
|
+
|
|
7
9
|
export const NOTIFY_TYPE = {
|
|
8
10
|
success: "success",
|
|
9
11
|
warning: "warning",
|
|
@@ -17,3 +19,11 @@ export const POSITION = {
|
|
|
17
19
|
bottom: "bottom",
|
|
18
20
|
center: "center",
|
|
19
21
|
};
|
|
22
|
+
|
|
23
|
+
export const DURATION = {
|
|
24
|
+
short: 4000,
|
|
25
|
+
medium: 8000,
|
|
26
|
+
long: 12000,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const DELAY_BETWEEN_CLONES = 1000;
|
|
@@ -2,6 +2,7 @@ import { notify } from "./services";
|
|
|
2
2
|
|
|
3
3
|
import UNotify from "../ui.text-notify";
|
|
4
4
|
import UButton from "../ui.button";
|
|
5
|
+
import UGroup from "../ui.container-group";
|
|
5
6
|
|
|
6
7
|
import { getArgTypes } from "../service.storybook";
|
|
7
8
|
|
|
@@ -12,14 +13,16 @@ export default {
|
|
|
12
13
|
id: "4035",
|
|
13
14
|
title: "Text & Content / Notify",
|
|
14
15
|
component: UNotify,
|
|
15
|
-
args: {
|
|
16
|
-
type: "success",
|
|
17
|
-
label: "",
|
|
18
|
-
text: "",
|
|
19
|
-
},
|
|
20
16
|
argTypes: {
|
|
21
17
|
...getArgTypes(UNotify.name),
|
|
22
18
|
},
|
|
19
|
+
parameters: {
|
|
20
|
+
docs: {
|
|
21
|
+
story: {
|
|
22
|
+
height: "280px",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
const DefaultTemplate = (args) => ({
|
|
@@ -28,45 +31,59 @@ const DefaultTemplate = (args) => ({
|
|
|
28
31
|
return { args };
|
|
29
32
|
},
|
|
30
33
|
template: `
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<UButton label="show notify" @click="onClick"/>
|
|
35
|
-
</div>
|
|
34
|
+
<UNotify class="m-4" v-bind="args" />
|
|
35
|
+
<UButton label="Show notify" @click="onClick"/>
|
|
36
36
|
`,
|
|
37
|
-
|
|
38
37
|
methods: {
|
|
39
38
|
onClick() {
|
|
40
|
-
|
|
39
|
+
notify({
|
|
41
40
|
type: "success",
|
|
42
|
-
label: "
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
notify(settings);
|
|
41
|
+
label: "Hurray!",
|
|
42
|
+
description: "The file successfully downloaded.",
|
|
43
|
+
});
|
|
46
44
|
},
|
|
47
45
|
},
|
|
48
46
|
});
|
|
49
47
|
|
|
50
48
|
const TypesTemplate = (args) => ({
|
|
51
|
-
components: { UNotify, UButton },
|
|
49
|
+
components: { UNotify, UButton, UGroup },
|
|
52
50
|
setup() {
|
|
53
51
|
return { args };
|
|
54
52
|
},
|
|
55
53
|
template: `
|
|
56
|
-
<
|
|
57
|
-
<UNotify />
|
|
54
|
+
<UNotify class="m-4" />
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
<UButton label="
|
|
61
|
-
<UButton label="
|
|
62
|
-
|
|
56
|
+
<UGroup>
|
|
57
|
+
<UButton label="Success" color="green" @click="onClick('success')"/>
|
|
58
|
+
<UButton label="Warning" color="orange" @click="onClick('warning')"/>
|
|
59
|
+
<UButton label="Error" color="red" @click="onClick('error')"/>
|
|
60
|
+
</UGroup>
|
|
63
61
|
`,
|
|
64
|
-
|
|
65
62
|
methods: {
|
|
66
63
|
onClick(type) {
|
|
67
|
-
|
|
64
|
+
if (type === "success") {
|
|
65
|
+
notify({
|
|
66
|
+
type,
|
|
67
|
+
label: "Hurray!",
|
|
68
|
+
description: "The file successfully downloaded.",
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (type === "warning") {
|
|
73
|
+
notify({
|
|
74
|
+
type,
|
|
75
|
+
label: "Be aware!",
|
|
76
|
+
description: "The file have been downloaded, but some data is missing.",
|
|
77
|
+
});
|
|
78
|
+
}
|
|
68
79
|
|
|
69
|
-
|
|
80
|
+
if (type === "error") {
|
|
81
|
+
notify({
|
|
82
|
+
type,
|
|
83
|
+
label: "Ooops!",
|
|
84
|
+
description: "The file can't be downloaded, please check the fields and try again.",
|
|
85
|
+
});
|
|
86
|
+
}
|
|
70
87
|
},
|
|
71
88
|
},
|
|
72
89
|
});
|
package/ui.text-notify/index.vue
CHANGED
|
@@ -45,13 +45,20 @@
|
|
|
45
45
|
/>
|
|
46
46
|
|
|
47
47
|
<div v-bind="contentAttrs">
|
|
48
|
-
<template v-if="
|
|
48
|
+
<template v-if="html">
|
|
49
49
|
<span v-bind="labelAttrs" v-html="notification.label" />
|
|
50
|
-
<span
|
|
50
|
+
<span
|
|
51
|
+
v-bind="descriptionAttrs"
|
|
52
|
+
v-html="getText(notification.description, notification.type)"
|
|
53
|
+
/>
|
|
51
54
|
</template>
|
|
55
|
+
|
|
52
56
|
<template v-else>
|
|
53
57
|
<span v-bind="labelAttrs" v-text="notification.label" />
|
|
54
|
-
<span
|
|
58
|
+
<span
|
|
59
|
+
v-bind="descriptionAttrs"
|
|
60
|
+
v-text="getText(notification.description, notification.type)"
|
|
61
|
+
/>
|
|
55
62
|
</template>
|
|
56
63
|
</div>
|
|
57
64
|
|
|
@@ -106,11 +113,11 @@ const props = defineProps({
|
|
|
106
113
|
},
|
|
107
114
|
|
|
108
115
|
/**
|
|
109
|
-
* Use
|
|
116
|
+
* Use html to render you own content.
|
|
110
117
|
*/
|
|
111
|
-
|
|
118
|
+
html: {
|
|
112
119
|
type: Boolean,
|
|
113
|
-
default: UIService.get(defaultConfig, UNotify).default.
|
|
120
|
+
default: UIService.get(defaultConfig, UNotify).default.html,
|
|
114
121
|
},
|
|
115
122
|
|
|
116
123
|
/**
|
|
@@ -1,89 +1,86 @@
|
|
|
1
1
|
import { globalComponentConfig, getRandomId } from "../../service.ui";
|
|
2
|
+
import { DELAY_BETWEEN_CLONES, DURATION, LOCAL_STORAGE_ID, NOTIFY_TYPE } from "../constants";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const delayBetweenClones = 1000;
|
|
4
|
+
const globalNotifyDuration = globalComponentConfig.UNotify?.duration;
|
|
5
|
+
const notifyClearAllEvent = new Event("notifyClearAll");
|
|
6
6
|
|
|
7
7
|
let lastMessageTime = undefined;
|
|
8
8
|
let lastMessage = undefined;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
short
|
|
12
|
-
medium: 8000,
|
|
13
|
-
long: 12000,
|
|
14
|
-
};
|
|
10
|
+
export function notify({ type, label, description, duration, ignoreDuplicates } = {}) {
|
|
11
|
+
const notifyDuration = duration || globalNotifyDuration?.short || DURATION.short;
|
|
15
12
|
|
|
16
|
-
const
|
|
13
|
+
const isSameMessage =
|
|
14
|
+
lastMessage === description && new Date() - lastMessageTime < DELAY_BETWEEN_CLONES;
|
|
17
15
|
|
|
18
|
-
|
|
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;
|
|
23
|
-
|
|
24
|
-
if ((isSameMessage || !text) && delayDuplicates) {
|
|
16
|
+
if ((isSameMessage || !description) && ignoreDuplicates) {
|
|
25
17
|
return;
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
lastMessageTime = new Date();
|
|
29
|
-
lastMessage =
|
|
21
|
+
lastMessage = description;
|
|
30
22
|
|
|
31
|
-
const
|
|
23
|
+
const eventDetail = {
|
|
32
24
|
type,
|
|
33
25
|
id: getRandomId(),
|
|
34
26
|
label: label || "",
|
|
35
|
-
|
|
36
|
-
duration:
|
|
27
|
+
description: description || "",
|
|
28
|
+
duration: notifyDuration,
|
|
37
29
|
};
|
|
38
30
|
|
|
39
|
-
const notifyStart = new CustomEvent("notifyStart", { detail });
|
|
40
|
-
const notifyEnd = new CustomEvent("notifyEnd", { detail });
|
|
31
|
+
const notifyStart = new CustomEvent("notifyStart", { detail: eventDetail });
|
|
32
|
+
const notifyEnd = new CustomEvent("notifyEnd", { detail: eventDetail });
|
|
41
33
|
|
|
42
34
|
window.dispatchEvent(notifyStart);
|
|
43
35
|
|
|
44
|
-
setTimeout(() => window.dispatchEvent(notifyEnd),
|
|
36
|
+
setTimeout(() => window.dispatchEvent(notifyEnd), notifyDuration);
|
|
45
37
|
}
|
|
46
38
|
|
|
47
|
-
export function notifySuccess(
|
|
39
|
+
export function notifySuccess({ label, description, duration, ignoreDuplicates } = {}) {
|
|
48
40
|
notify({
|
|
41
|
+
label,
|
|
42
|
+
description,
|
|
43
|
+
ignoreDuplicates,
|
|
49
44
|
type: NOTIFY_TYPE.success,
|
|
50
|
-
|
|
51
|
-
duration,
|
|
45
|
+
duration: duration || globalNotifyDuration?.short || DURATION.short,
|
|
52
46
|
});
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
export function notifyWarning(
|
|
49
|
+
export function notifyWarning({ label, description, duration, ignoreDuplicates } = {}) {
|
|
56
50
|
notify({
|
|
51
|
+
label,
|
|
52
|
+
description,
|
|
53
|
+
ignoreDuplicates,
|
|
57
54
|
type: NOTIFY_TYPE.warning,
|
|
58
|
-
|
|
59
|
-
duration,
|
|
55
|
+
duration: duration || globalNotifyDuration?.medium || DURATION.medium,
|
|
60
56
|
});
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
export function notifyError(
|
|
59
|
+
export function notifyError({ label, description, duration, ignoreDuplicates } = {}) {
|
|
64
60
|
notify({
|
|
61
|
+
label,
|
|
62
|
+
description,
|
|
63
|
+
ignoreDuplicates,
|
|
65
64
|
type: NOTIFY_TYPE.error,
|
|
66
|
-
|
|
67
|
-
duration,
|
|
65
|
+
duration: duration || globalNotifyDuration?.long || DURATION.long,
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
export function
|
|
69
|
+
export function clearNotifications() {
|
|
72
70
|
window.dispatchEvent(notifyClearAllEvent);
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
export function setDelayedNotify(settings) {
|
|
76
|
-
localStorage.setItem(
|
|
74
|
+
localStorage.setItem(LOCAL_STORAGE_ID, JSON.stringify(settings));
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
export function getDelayedNotify() {
|
|
80
|
-
const notifyData = JSON.parse(localStorage.getItem(
|
|
78
|
+
const notifyData = JSON.parse(localStorage.getItem(LOCAL_STORAGE_ID));
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
clearNotifications();
|
|
83
81
|
|
|
84
82
|
if (notifyData) {
|
|
85
83
|
notify(notifyData);
|
|
86
|
-
|
|
87
|
-
localStorage.removeItem("notify");
|
|
84
|
+
localStorage.removeItem(LOCAL_STORAGE_ID);
|
|
88
85
|
}
|
|
89
86
|
}
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "vueless",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.141",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -5120,13 +5120,13 @@
|
|
|
5120
5120
|
"default": "top"
|
|
5121
5121
|
},
|
|
5122
5122
|
{
|
|
5123
|
-
"name": "
|
|
5124
|
-
"description": "Use
|
|
5123
|
+
"name": "html",
|
|
5124
|
+
"description": "Use html to render you own content.",
|
|
5125
5125
|
"value": {
|
|
5126
5126
|
"kind": "expression",
|
|
5127
5127
|
"type": "boolean"
|
|
5128
5128
|
},
|
|
5129
|
-
"default": "
|
|
5129
|
+
"default": "UIService.get(defaultConfig, UNotify).default.html"
|
|
5130
5130
|
},
|
|
5131
5131
|
{
|
|
5132
5132
|
"name": "config",
|