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 CHANGED
@@ -20,7 +20,7 @@ export {
20
20
  notifySuccess,
21
21
  notifyWarning,
22
22
  notifyError,
23
- clearAllNotifications,
23
+ clearNotifications,
24
24
  setDelayedNotify,
25
25
  getDelayedNotify,
26
26
  } from "./ui.text-notify/services";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.140",
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.25",
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",
@@ -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
- ## Trigger notifications
19
- You can trigger notification using *notify* method. Use *notifySuccess, notifyWarning, notifyError* methods to trigger notification of specific type.
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
- notify,
24
- notifySuccess,
25
- notifyWarning,
26
- notifyError,
24
+ notify,
25
+ notifySuccess,
26
+ notifyWarning,
27
+ notifyError,
27
28
  } from "vueless";
28
29
 
29
30
  notify({
30
- type: "success" // success, warning, error
31
- title: "" // Some label
32
- text: "" // Some text content
33
- duration: 1000 // Duration in milliseconds
34
- delayDuplicates: false // Delay notifications with same text
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
- const durationInMilliseconds = 1000;
38
-
39
- notifySuccess("Some success text", durationInMilliseconds);
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 active notifications
45
- Use *clearAllNotifications* method to clear all active notifications.
43
+ ## Clear notifications
44
+ Use `clearNotifications` method to clear active notifications.
46
45
 
47
46
  <Source code={`
48
- import { clearAllNotifications, notifySuccess } from "vueless";
47
+ import { clearNotifications, notifySuccess } from "vueless";
49
48
 
50
- const durationInMilliseconds = 1000;
51
- notifySuccess("Some success text", durationInMilliseconds);
49
+ notifySuccess({ description: "The file successfully downloaded." });
52
50
 
53
- clearAllNotifications();
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
- type: "success" // success, warning, error
64
- title: "" // Some label
65
- text: "" // Some text content
66
- duration: 1000 // Duration in milliseconds
67
- delayDuplicates: false // Delay notifications with same text
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
- setTimeout(getDelayedNotify, 10_000);
69
+ // and somewhere below
70
+ getDelayedNotify();
71
71
  `} language="jsx" dark />
72
72
 
73
- ## Place notification relatively to navigation elements
74
- Provide *positionClasses* key for UNotify config to take navigation elements offset into account.
75
- By default, it will be looking for UNotifyPage and UNotifyAside classes.
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
- const notifyConfig = {
79
+ {
80
+ ...
81
+ UNotify: {
79
82
  positionClasses: {
80
- page: "UNotifyPage",
81
- aside: "UNotifyAside",
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-fit items-center justify-center gap-3 rounded-2xl bg-gray-900/90
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 px-3 text-sm text-gray-200",
11
- label: "mb-1 font-medium",
12
- description: "break-words font-normal leading-5",
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
- <div>
32
- <UNotify v-bind="args" />
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
- const settings = {
39
+ notify({
41
40
  type: "success",
42
- label: "Some 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
- <div class="flex gap-4">
57
- <UNotify />
54
+ <UNotify class="m-4" />
58
55
 
59
- <UButton label="Success" @click="onClick('success')"/>
60
- <UButton label="Warning" @click="onClick('warning')"/>
61
- <UButton label="Error" @click="onClick('error')"/>
62
- </div>
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
- const settings = { type };
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
- notify(settings);
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
  });
@@ -45,13 +45,20 @@
45
45
  />
46
46
 
47
47
  <div v-bind="contentAttrs">
48
- <template v-if="vHtml">
48
+ <template v-if="html">
49
49
  <span v-bind="labelAttrs" v-html="notification.label" />
50
- <span v-bind="descriptionAttrs" v-html="getText(notification.text, notification.type)" />
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 v-bind="descriptionAttrs" v-text="getText(notification.text, notification.type)" />
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 v-html to render notification label and description content.
116
+ * Use html to render you own content.
110
117
  */
111
- vHtml: {
118
+ html: {
112
119
  type: Boolean,
113
- default: UIService.get(defaultConfig, UNotify).default.vHtml,
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
- import { NOTIFY_TYPE } from "../constants";
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
- const defaultDuration = {
11
- short: 4000,
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 notifyClearAllEvent = new Event("notifyClearAll");
13
+ const isSameMessage =
14
+ lastMessage === description && new Date() - lastMessageTime < DELAY_BETWEEN_CLONES;
17
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;
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 = text;
21
+ lastMessage = description;
30
22
 
31
- const detail = {
23
+ const eventDetail = {
32
24
  type,
33
25
  id: getRandomId(),
34
26
  label: label || "",
35
- text: text || "",
36
- duration: currentNotifyDuration,
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), currentNotifyDuration);
36
+ setTimeout(() => window.dispatchEvent(notifyEnd), notifyDuration);
45
37
  }
46
38
 
47
- export function notifySuccess(text, duration = globalComponentConfig.UNotify?.duration?.short) {
39
+ export function notifySuccess({ label, description, duration, ignoreDuplicates } = {}) {
48
40
  notify({
41
+ label,
42
+ description,
43
+ ignoreDuplicates,
49
44
  type: NOTIFY_TYPE.success,
50
- text,
51
- duration,
45
+ duration: duration || globalNotifyDuration?.short || DURATION.short,
52
46
  });
53
47
  }
54
48
 
55
- export function notifyWarning(text, duration = globalComponentConfig.UNotify?.duration?.medium) {
49
+ export function notifyWarning({ label, description, duration, ignoreDuplicates } = {}) {
56
50
  notify({
51
+ label,
52
+ description,
53
+ ignoreDuplicates,
57
54
  type: NOTIFY_TYPE.warning,
58
- text,
59
- duration,
55
+ duration: duration || globalNotifyDuration?.medium || DURATION.medium,
60
56
  });
61
57
  }
62
58
 
63
- export function notifyError(text, duration = globalComponentConfig.UNotify?.duration?.long) {
59
+ export function notifyError({ label, description, duration, ignoreDuplicates } = {}) {
64
60
  notify({
61
+ label,
62
+ description,
63
+ ignoreDuplicates,
65
64
  type: NOTIFY_TYPE.error,
66
- text,
67
- duration,
65
+ duration: duration || globalNotifyDuration?.long || DURATION.long,
68
66
  });
69
67
  }
70
68
 
71
- export function clearAllNotifications() {
69
+ export function clearNotifications() {
72
70
  window.dispatchEvent(notifyClearAllEvent);
73
71
  }
74
72
 
75
73
  export function setDelayedNotify(settings) {
76
- localStorage.setItem("notify", JSON.stringify(settings));
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("notify"));
78
+ const notifyData = JSON.parse(localStorage.getItem(LOCAL_STORAGE_ID));
81
79
 
82
- clearAllNotifications();
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.140",
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": "vHtml",
5124
- "description": "Use v-html to render notification label and description content.",
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": "false"
5129
+ "default": "UIService.get(defaultConfig, UNotify).default.html"
5130
5130
  },
5131
5131
  {
5132
5132
  "name": "config",