vueless 0.0.51 → 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.
Files changed (33) hide show
  1. package/adatper.locale/locales/en.js +2 -0
  2. package/index.js +9 -0
  3. package/package.json +4 -6
  4. package/service.ui/index.js +1 -0
  5. package/ui.button/composables/attrs.composable.js +9 -2
  6. package/ui.button-link/composables/attrs.composable.js +23 -3
  7. package/ui.button-toggle/configs/default.config.js +1 -0
  8. package/ui.container-modal-confirm/composable/attrs.composable.js +55 -5
  9. package/ui.form-calendar/configs/default.config.js +21 -21
  10. package/ui.form-color-picker/composables/attrs.composable.js +2 -9
  11. package/ui.form-date-picker/configs/default.config.js +1 -1
  12. package/ui.form-date-picker-range/configs/default.config.js +16 -16
  13. package/ui.form-input/configs/default.config.js +2 -2
  14. package/ui.form-radio-card/composables/attrs.composable.js +2 -2
  15. package/ui.form-select/configs/default.config.js +2 -2
  16. package/ui.form-textarea/configs/default.config.js +1 -1
  17. package/ui.loader-rendering/composables/useLoaderRendering.js +19 -0
  18. package/ui.loader-rendering/index.vue +15 -16
  19. package/ui.navigation-pagination/configs/default.config.js +2 -2
  20. package/ui.notify/Docs.mdx +84 -0
  21. package/ui.notify/composables/attrs.composable.js +30 -0
  22. package/ui.notify/configs/default.config.js +47 -0
  23. package/ui.notify/constants/index.js +19 -0
  24. package/ui.notify/index.stories.js +77 -0
  25. package/ui.notify/index.vue +196 -214
  26. package/ui.notify/services/index.js +65 -63
  27. package/ui.other-loader-top/composables/useLoaderTop.js +57 -0
  28. package/ui.other-loader-top/index.vue +12 -13
  29. package/ui.text-alert/composables/attrs.composable.js +1 -1
  30. package/web-types.json +21 -3
  31. package/ui.loader-rendering/store/index.js +0 -17
  32. package/ui.notify/index.sto_ries.js +0 -102
  33. package/ui.other-loader-top/store/index.js +0 -59
@@ -1,87 +1,89 @@
1
- import Vue3Notify, { notify as VueNotify } from "@kyvg/vue3-notification";
2
- import { globalComponentConfig } from "../../service.ui";
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
- export default class NotifyServiceDefault {
12
- notifyInstance = Vue3Notify;
16
+ const notifyClearAllEvent = new Event("notifyClearAll");
13
17
 
14
- #lastMessageTime = 0;
15
- #lastMessageCode = "";
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
- notify(settings) {
18
- const { type, title, text, code, duration, ignoreDuplicates, closeOnClick, data } = settings;
19
- const isSameMessage =
20
- this.#lastMessageCode === code && new Date() - this.#lastMessageTime < 1000;
24
+ if ((isSameMessage || !text) && delayDuplicates) {
25
+ return;
26
+ }
21
27
 
22
- if (isSameMessage || !code) return;
28
+ lastMessageTime = new Date();
29
+ lastMessage = text;
23
30
 
24
- this.#lastMessageTime = new Date();
25
- this.#lastMessageCode = code;
31
+ const detail = {
32
+ type,
33
+ id: getRandomId(),
34
+ label: label || "",
35
+ text: text || "",
36
+ duration: currentNotifyDuration,
37
+ };
26
38
 
27
- VueNotify({
28
- group: "notify",
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
- success(code, duration = globalComponentConfig.UNotify?.duration?.short) {
40
- this.notify({
41
- type: "success",
42
- code: code,
43
- duration: duration,
44
- });
45
- }
42
+ window.dispatchEvent(notifyStart);
46
43
 
47
- warning(code, duration = globalComponentConfig.UNotify?.duration?.medium) {
48
- this.notify({
49
- type: "warning",
50
- code: code,
51
- duration: duration,
52
- });
53
- }
44
+ setTimeout(() => window.dispatchEvent(notifyEnd), currentNotifyDuration);
45
+ }
54
46
 
55
- error(code, duration = globalComponentConfig.UNotify?.duration?.long) {
56
- this.notify({
57
- type: "error",
58
- code: code,
59
- duration: duration,
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
- clearAll() {
64
- VueNotify({
65
- group: "notify",
66
- clean: true,
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
- setDelayed(type, message) {
71
- localStorage.setItem("notify", JSON.stringify({ type, message }));
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
- getDelayed() {
75
- const notifyData = JSON.parse(localStorage.getItem("notify"));
75
+ export function setDelayedNotify(settings) {
76
+ localStorage.setItem("notify", JSON.stringify(settings));
77
+ }
76
78
 
77
- this.clearAll();
79
+ export function getDelayedNotify() {
80
+ const notifyData = JSON.parse(localStorage.getItem("notify"));
78
81
 
79
- if (notifyData) {
80
- const { type, message } = notifyData;
82
+ clearAllNotifications();
81
83
 
82
- this[type](message);
84
+ if (notifyData) {
85
+ notify(notifyData);
83
86
 
84
- localStorage.removeItem("notify");
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
+ }
@@ -7,16 +7,16 @@
7
7
  <script setup>
8
8
  import { computed, onBeforeUnmount, watch, ref } from "vue";
9
9
 
10
- import { useStore } from "vuex";
11
-
12
10
  import UIService, { isMobileApp } from "../service.ui";
13
11
  import { clamp, queue } from "./services/loaderTop.service";
12
+ import useLoaderTop from "./composables/useLoaderTop";
14
13
 
15
14
  import { ULoaderTop, MAXIMUM, SPEED } from "./constants";
16
15
  import defaultConfig from "./configs/default.config";
17
16
  import { useAttrs } from "./composables/attrs.composable";
18
17
 
19
- defineOptions({ name: "ULoaderTop" });
18
+ /* Should be a string for correct web-types gen */
19
+ defineOptions({ name: "ULoaderTop", inheritAttrs: false });
20
20
 
21
21
  const props = defineProps({
22
22
  /**
@@ -46,22 +46,21 @@ const props = defineProps({
46
46
  },
47
47
  });
48
48
 
49
- const store = useStore();
50
-
51
49
  const error = ref(false);
52
50
  const show = ref(false);
53
51
  const progress = ref(0);
54
52
  const opacity = ref(1);
55
53
  const status = ref(null);
56
54
 
55
+ const {
56
+ loaderRequestQueue,
57
+ isLoading,
58
+ componentLoaderRequestQueue,
59
+ setComponentRequestQueue,
60
+ removeComponentRequestQueue,
61
+ } = useLoaderTop();
57
62
  const { progressAttrs } = useAttrs(props, { error, isMobileApp });
58
63
 
59
- const loaderRequestQueue = computed(() => store.state.loaderTop.loaderRequestQueue);
60
- const isLoading = computed(() => store.state.loaderTop.isLoading);
61
- const componentLoaderRequestQueue = computed(
62
- () => store.state.loaderTop.componentLoaderRequestQueue,
63
- );
64
-
65
64
  const isStarted = computed(() => {
66
65
  return typeof status.value === "number";
67
66
  });
@@ -81,12 +80,12 @@ watch(loaderRequestQueue, onChangeRequestsQueue, { deep: true });
81
80
  watch(isLoading, onChangeLoadingState, { deep: true });
82
81
 
83
82
  if (props.resourceNames) {
84
- store.commit("loaderTop/SET_COMPONENT_REQUEST_QUEUE", resourceNamesArray.value);
83
+ setComponentRequestQueue(resourceNamesArray.value);
85
84
  }
86
85
 
87
86
  onBeforeUnmount(() => {
88
87
  if (props.resourceNames) {
89
- store.commit("loaderTop/REMOVE_COMPONENT_REQUEST_QUEUE");
88
+ removeComponentRequestQueue();
90
89
  }
91
90
  });
92
91
 
@@ -30,7 +30,7 @@ export function useAttrs(props) {
30
30
  ),
31
31
  );
32
32
 
33
- const bodyClasses = computed(() => cvaBody({ size: props.size }));
33
+ const bodyClasses = computed(() => setColor(cvaBody({ size: props.size }), props.color));
34
34
 
35
35
  const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
36
36
  const bodyAttrs = getAttrs("body", { classes: bodyClasses });
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.51",
4
+ "version": "0.0.52",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -5027,7 +5027,7 @@
5027
5027
  "kind": "expression",
5028
5028
  "type": "'left' | 'center' | 'right'"
5029
5029
  },
5030
- "default": "\"center\""
5030
+ "default": "center"
5031
5031
  },
5032
5032
  {
5033
5033
  "name": "yPosition",
@@ -5036,7 +5036,25 @@
5036
5036
  "kind": "expression",
5037
5037
  "type": "'top' | 'bottom'"
5038
5038
  },
5039
- "default": "\"top\""
5039
+ "default": "top"
5040
+ },
5041
+ {
5042
+ "name": "vHtml",
5043
+ "description": "Use v-html to render notification label and description content.",
5044
+ "value": {
5045
+ "kind": "expression",
5046
+ "type": "boolean"
5047
+ },
5048
+ "default": "false"
5049
+ },
5050
+ {
5051
+ "name": "config",
5052
+ "description": "Sets component ui config object.",
5053
+ "value": {
5054
+ "kind": "expression",
5055
+ "type": "object"
5056
+ },
5057
+ "default": "{}"
5040
5058
  }
5041
5059
  ],
5042
5060
  "source": {
@@ -1,17 +0,0 @@
1
- export default {
2
- namespaced: true,
3
-
4
- state: {
5
- isRenderingPage: true,
6
- },
7
-
8
- mutations: {
9
- SET_RENDERING_STARTED(state) {
10
- state.isRenderingPage = true;
11
- },
12
-
13
- SET_RENDERING_FINISHED(state) {
14
- state.isRenderingPage = false;
15
- },
16
- },
17
- };
@@ -1,102 +0,0 @@
1
- import NotifyServiceDefault from "../ui.notify/services";
2
-
3
- import UNotify from "../ui.notify";
4
- import UButton from "../ui.button";
5
-
6
- import { getArgTypes } from "../service.storybook";
7
-
8
- const NotifyService = new NotifyServiceDefault();
9
-
10
- export default {
11
- title: "Other / Notify",
12
- component: UNotify,
13
- args: {
14
- type: "success",
15
- code: "code",
16
- title: "",
17
- text: "",
18
- duration: "short",
19
- ignoreDuplicates: false,
20
- },
21
- argTypes: {
22
- ...getArgTypes(UNotify.name),
23
- type: {
24
- description: "The type of notify.",
25
- defaultValue: { summary: "success" },
26
- options: ["success", "warning", "error"],
27
- control: {
28
- type: "radio",
29
- },
30
- },
31
- code: {
32
- description:
33
- "Unique translation code, for ex. `categoryCreated`, " +
34
- "which will be used in i18n translation path, for ex. `UNotify.success.categoryCreated`.",
35
- defaultValue: { summary: "" },
36
- control: {
37
- type: "text",
38
- },
39
- },
40
- title: {
41
- description: "Notify title.",
42
- defaultValue: { summary: "" },
43
- control: {
44
- type: "text",
45
- },
46
- },
47
- text: {
48
- description: "Notify text (description).",
49
- defaultValue: { summary: "" },
50
- control: {
51
- type: "text",
52
- },
53
- },
54
- duration: {
55
- description: "The notify visibility duration.",
56
- defaultValue: { summary: "short" },
57
- options: ["short", "medium", "long", "permanent"], //4000, 8000, 12000, 300000
58
- control: {
59
- type: "radio",
60
- },
61
- },
62
- ignoreDuplicates: {
63
- description: "Show only 1 notify at once.",
64
- defaultValue: { summary: false },
65
- control: {
66
- type: "boolean",
67
- },
68
- },
69
- },
70
- };
71
-
72
- const DefaultTemplate = (args) => ({
73
- components: { UNotify, UButton },
74
- setup() {
75
- return { args };
76
- },
77
- template: `
78
- <div>
79
- <UNotify v-bind="args"/>
80
-
81
- <UButton label="show notify" @click="onClick"/>
82
- </div>
83
- `,
84
-
85
- methods: {
86
- onClick() {
87
- const settings = {
88
- type: args.type,
89
- code: args.code,
90
- title: args.title,
91
- text: args.text,
92
- duration: args.duration,
93
- ignoreDuplicates: args.ignoreDuplicates,
94
- };
95
-
96
- NotifyService.notify(settings);
97
- },
98
- },
99
- });
100
-
101
- export const Default = DefaultTemplate.bind({});
102
- Default.args = {};
@@ -1,59 +0,0 @@
1
- export default {
2
- namespaced: true,
3
-
4
- state: {
5
- isLoading: false,
6
- requestQueue: [],
7
- loaderRequestQueue: [],
8
- loaderRequestTimeout: 0,
9
- componentLoaderRequestQueue: [],
10
- },
11
-
12
- mutations: {
13
- SET_LOADING_ON: (state, url) => {
14
- state.loaderRequestQueue.push(url);
15
-
16
- state.isLoading = true;
17
-
18
- clearTimeout(state.loaderRequestTimeout);
19
- },
20
-
21
- SET_LOADING_OFF: (state, url) => {
22
- if (url) {
23
- state.loaderRequestQueue.forEach((item, index) => {
24
- if (item === url) {
25
- state.loaderRequestQueue.splice(index, 1);
26
- }
27
- });
28
- } else {
29
- state.loaderRequestQueue = [];
30
- }
31
-
32
- state.loaderRequestTimeout = setTimeout(() => {
33
- if (!state.loaderRequestQueue.length) {
34
- state.isLoading = false;
35
- }
36
- }, 50);
37
- },
38
-
39
- ADD_REQUEST_URL: (state, url) => {
40
- state.requestQueue.push(url);
41
- },
42
-
43
- REMOVE_REQUEST_URL: (state, url) => {
44
- state.requestQueue.forEach((item, index) => {
45
- if (item === url) {
46
- state.requestQueue.splice(index, 1);
47
- }
48
- });
49
- },
50
-
51
- SET_COMPONENT_REQUEST_QUEUE(state, requests) {
52
- state.componentLoaderRequestQueue = [...state.componentLoaderRequestQueue, ...requests];
53
- },
54
-
55
- REMOVE_COMPONENT_REQUEST_QUEUE(state) {
56
- state.componentLoaderRequestQueue = [];
57
- },
58
- },
59
- };