vueless 0.0.140 → 0.0.142
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.button/composables/attrs.composable.js +13 -3
- package/ui.button/configs/default.config.js +1 -1
- package/ui.button/index.vue +36 -13
- package/ui.loader/configs/default.config.js +25 -23
- package/ui.loader/index.stories.js +8 -14
- package/ui.loader/index.vue +4 -4
- 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 +5 -5
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.142",
|
|
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",
|
|
@@ -28,7 +28,7 @@ export function useAttrs(props) {
|
|
|
28
28
|
variant: props.variant,
|
|
29
29
|
pill: props.pill,
|
|
30
30
|
block: props.block,
|
|
31
|
-
square: props.square,
|
|
31
|
+
square: props.loading || props.square,
|
|
32
32
|
filled: props.filled,
|
|
33
33
|
loading: props.loading,
|
|
34
34
|
disabled: props.disabled,
|
|
@@ -37,12 +37,22 @@ export function useAttrs(props) {
|
|
|
37
37
|
),
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
-
const textClasses = computed(() =>
|
|
40
|
+
const textClasses = computed(() =>
|
|
41
|
+
setColor(
|
|
42
|
+
cvaText({
|
|
43
|
+
color: props.color,
|
|
44
|
+
}),
|
|
45
|
+
props.color,
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
|
|
41
49
|
const buttonAttrs = getAttrs("button", { classes: buttonClasses });
|
|
50
|
+
const loaderAttrs = getAttrs("loader");
|
|
42
51
|
const textAttrs = getAttrs("text", { classes: textClasses });
|
|
43
52
|
|
|
44
53
|
return {
|
|
45
|
-
textAttrs,
|
|
46
54
|
buttonAttrs,
|
|
55
|
+
loaderAttrs,
|
|
56
|
+
textAttrs,
|
|
47
57
|
};
|
|
48
58
|
}
|
package/ui.button/index.vue
CHANGED
|
@@ -8,22 +8,28 @@
|
|
|
8
8
|
v-bind="buttonAttrs"
|
|
9
9
|
@click="onClick"
|
|
10
10
|
>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
<template v-if="loading">
|
|
12
|
+
<!-- Label is needed to prevent changing button height -->
|
|
13
|
+
<div v-bind="textAttrs" tabindex="-1" class="invisible w-0" v-text="label" />
|
|
14
|
+
<ULoader :size="loaderSize" :color="loaderColor" v-bind="loaderAttrs" />
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<template v-else>
|
|
18
|
+
<!-- @slot Use it to add something before text. -->
|
|
19
|
+
<slot name="left" />
|
|
20
|
+
|
|
21
|
+
<!-- @slot Use it to add something instead of text. -->
|
|
22
|
+
<slot />
|
|
23
|
+
<div v-if="label" v-bind="textAttrs" tabindex="-1" v-text="label" />
|
|
24
|
+
|
|
25
|
+
<!-- @slot Use it to add something after text. -->
|
|
26
|
+
<slot name="right" />
|
|
27
|
+
</template>
|
|
22
28
|
</component>
|
|
23
29
|
</template>
|
|
24
30
|
|
|
25
31
|
<script setup>
|
|
26
|
-
import { ref } from "vue";
|
|
32
|
+
import { computed, ref } from "vue";
|
|
27
33
|
|
|
28
34
|
import UIService, { getRandomId } from "../service.ui";
|
|
29
35
|
import ULoader from "../ui.loader";
|
|
@@ -155,12 +161,29 @@ const props = defineProps({
|
|
|
155
161
|
|
|
156
162
|
const emit = defineEmits(["click"]);
|
|
157
163
|
|
|
158
|
-
const {
|
|
164
|
+
const { buttonAttrs, loaderAttrs, textAttrs } = useAttrs(props);
|
|
159
165
|
|
|
160
166
|
const buttonRef = ref(null);
|
|
161
167
|
|
|
162
168
|
defineExpose({ buttonRef });
|
|
163
169
|
|
|
170
|
+
const loaderSize = computed(() => {
|
|
171
|
+
const sizes = {
|
|
172
|
+
"2xs": "sm",
|
|
173
|
+
xs: "sm",
|
|
174
|
+
sm: "md",
|
|
175
|
+
md: "md",
|
|
176
|
+
lg: "lg",
|
|
177
|
+
xl: "lg",
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
return sizes[props.size];
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const loaderColor = computed(() => {
|
|
184
|
+
return props.variant === "primary" ? "white" : props.color;
|
|
185
|
+
});
|
|
186
|
+
|
|
164
187
|
function onClick(event) {
|
|
165
188
|
if (props.disabled) return;
|
|
166
189
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
loader: {
|
|
3
|
-
base: "relative
|
|
3
|
+
base: "relative flex items-center",
|
|
4
4
|
variants: {
|
|
5
5
|
size: {
|
|
6
|
-
sm: "w-9",
|
|
7
|
-
md: "w-[3.625rem]",
|
|
8
|
-
lg: "w-20",
|
|
6
|
+
sm: "h-1.5 w-9",
|
|
7
|
+
md: "h-2.5 w-[3.625rem]",
|
|
8
|
+
lg: "h-4 w-20",
|
|
9
9
|
},
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
ellipse: {
|
|
13
|
-
base:
|
|
13
|
+
base: "absolute rounded-full bg-{color}-600 ease-[cubic-bezier(0,1,1,0)]",
|
|
14
14
|
variants: {
|
|
15
15
|
color: {
|
|
16
16
|
white: "bg-white",
|
|
@@ -18,30 +18,32 @@ export default /*tw*/ {
|
|
|
18
18
|
},
|
|
19
19
|
size: {
|
|
20
20
|
sm: `
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
h-1.5 w-1.5
|
|
22
|
+
[&:nth-child(1)]:left-1
|
|
23
|
+
[&:nth-child(2)]:left-1
|
|
24
|
+
[&:nth-child(3)]:left-4
|
|
25
|
+
[&:nth-child(4)]:left-7
|
|
26
|
+
`,
|
|
25
27
|
md: `
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
h-2.5 w-2.5
|
|
29
|
+
[&:nth-child(1)]:left-1.5
|
|
30
|
+
[&:nth-child(2)]:left-1.5
|
|
31
|
+
[&:nth-child(3)]:left-6
|
|
32
|
+
[&:nth-child(4)]:left-[2.625rem]
|
|
33
|
+
`,
|
|
32
34
|
lg: `
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
h-4 w-4
|
|
36
|
+
[&:nth-child(1)]:left-2
|
|
37
|
+
[&:nth-child(2)]:left-2
|
|
38
|
+
[&:nth-child(3)]:left-8
|
|
39
|
+
[&:nth-child(4)]:left-14
|
|
40
|
+
`,
|
|
39
41
|
},
|
|
40
42
|
},
|
|
41
43
|
},
|
|
42
44
|
defaultVariants: {
|
|
43
|
-
size: "md",
|
|
44
45
|
color: "brand",
|
|
46
|
+
size: "md",
|
|
45
47
|
},
|
|
46
|
-
safelist: (colors) => [{ pattern: `bg-(${colors})-
|
|
48
|
+
safelist: (colors) => [{ pattern: `bg-(${colors})-600` }],
|
|
47
49
|
};
|
|
@@ -34,14 +34,14 @@ const ColorsTemplate = (args, { argTypes } = {}) => ({
|
|
|
34
34
|
};
|
|
35
35
|
},
|
|
36
36
|
template: `
|
|
37
|
-
<
|
|
37
|
+
<URow class="flex-wrap">
|
|
38
38
|
<ULoader
|
|
39
39
|
v-for="(color, index) in colors"
|
|
40
40
|
:color="color"
|
|
41
41
|
v-bind="args"
|
|
42
42
|
:key="index"
|
|
43
43
|
/>
|
|
44
|
-
</
|
|
44
|
+
</URow>
|
|
45
45
|
`,
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -57,25 +57,19 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
|
57
57
|
<URow>
|
|
58
58
|
<ULoader
|
|
59
59
|
v-for="(size, index) in sizes"
|
|
60
|
-
:size="size"
|
|
61
|
-
:label="getText(size)"
|
|
62
|
-
v-bind="args"
|
|
63
60
|
:key="index"
|
|
61
|
+
v-bind="args"
|
|
62
|
+
:size="size"
|
|
64
63
|
/>
|
|
65
64
|
</URow>
|
|
66
65
|
`,
|
|
67
|
-
methods: {
|
|
68
|
-
getText(value) {
|
|
69
|
-
return `Tag ${value}`;
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
66
|
});
|
|
73
67
|
|
|
74
68
|
export const Default = DefaultTemplate.bind({});
|
|
75
69
|
Default.args = {};
|
|
76
70
|
|
|
77
|
-
export const
|
|
78
|
-
|
|
71
|
+
export const sizes = SizesTemplate.bind({});
|
|
72
|
+
sizes.args = {};
|
|
79
73
|
|
|
80
|
-
export const
|
|
81
|
-
|
|
74
|
+
export const colors = ColorsTemplate.bind({});
|
|
75
|
+
colors.args = {};
|
package/ui.loader/index.vue
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="loaderAttrs">
|
|
3
|
-
<div v-for="ellipse in
|
|
3
|
+
<div v-for="ellipse in ELLIPSES_AMOUNT" :key="ellipse" v-bind="ellipseAttrs(ellipseClasses)" />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup>
|
|
8
|
-
import { computed
|
|
8
|
+
import { computed } from "vue";
|
|
9
9
|
import UIService from "../service.ui";
|
|
10
10
|
|
|
11
11
|
import { ULoader } from "./constants";
|
|
@@ -17,7 +17,7 @@ defineOptions({ name: "ULoader", inheritAttrs: false });
|
|
|
17
17
|
|
|
18
18
|
const props = defineProps({
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Loader size.
|
|
21
21
|
* @values sm, md, lg
|
|
22
22
|
*/
|
|
23
23
|
size: {
|
|
@@ -35,7 +35,7 @@ const props = defineProps({
|
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const ELLIPSES_AMOUNT = 4;
|
|
39
39
|
|
|
40
40
|
const { loaderAttrs, ellipseAttrs } = useAttrs(props);
|
|
41
41
|
|
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.142",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -4480,7 +4480,7 @@
|
|
|
4480
4480
|
"attributes": [
|
|
4481
4481
|
{
|
|
4482
4482
|
"name": "size",
|
|
4483
|
-
"description": "
|
|
4483
|
+
"description": "Loader size.",
|
|
4484
4484
|
"value": {
|
|
4485
4485
|
"kind": "expression",
|
|
4486
4486
|
"type": "'sm' | 'md' | 'lg'"
|
|
@@ -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",
|