plugin-ui-for-kzt 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-ui-for-kzt",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "plugin-ui for kazaktelekom",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -139,7 +139,7 @@ const getTypeModal = computed<{ img: any; nameClass: string }>(() => {
139
139
  background: #15b853;
140
140
  }
141
141
 
142
- .warning {
142
+ .info {
143
143
  background: #f4a900;
144
144
  }
145
145
 
@@ -24,18 +24,19 @@
24
24
  ## Использование
25
25
 
26
26
  ```vue
27
+
27
28
  <script setup>
28
- import { useToast } from "modal-plugin-nikitas/plugins/toasterPlugin";
29
+ import {useToast} from "../../plugins/toasterPlugin";
29
30
 
30
- const toast = useToast();
31
+ const toast = useToast();
31
32
 
32
- const showSuccessToast = () => {
33
- toast?.success("Toast on top", {
34
- position: "top-left",
35
- duration: 4000,
36
- pauseOnHover: false,
37
- });
38
- };
33
+ const showSuccessToast = () => {
34
+ toast?.success("Toast on top", {
35
+ position: "top-left",
36
+ duration: 4000,
37
+ pauseOnHover: false,
38
+ });
39
+ };
39
40
  </script>
40
41
  ```
41
42
 
@@ -1,81 +1,82 @@
1
- import { createApp, h, getCurrentInstance } from "vue";
2
- import { useModalStore } from "../store/modal";
1
+ import {createApp, h, getCurrentInstance} from "vue";
2
+ import {useModalStore} from "../store/modal";
3
3
  import Modal from "../components/Modal/Modal.vue";
4
- import { watch } from "vue";
5
- import { IModalState } from "types";
4
+ import {watch} from "vue";
5
+ import {IModalState} from "types";
6
6
 
7
7
  export default {
8
- install(app: any) {
9
- const modalStore = useModalStore();
8
+ install(app: any) {
9
+ const modalStore = useModalStore();
10
10
 
11
- // Добавление глобального метода $modal
12
- app.config.globalProperties.$modal = {
13
- open(name: string, options: IModalState) {
14
- modalStore.openModal(name, options); // Открытие модалки через Pinia
15
- console.log("Current modals:", modalStore.modals);
16
- },
17
- close(id: number) {
18
- modalStore.closeModal(id); // Закрытие модалки через Pinia
19
- },
20
- };
11
+ // Добавление глобального метода $modal
12
+ app.config.globalProperties.$modal = {
13
+ open(name: string, options: IModalState) {
14
+ modalStore.openModal(name, options); // Открытие модалки через Pinia
15
+ console.log("Current modals:", modalStore.modals);
16
+ },
17
+ close(id: number) {
18
+ modalStore.closeModal(id); // Закрытие модалки через Pinia
19
+ },
20
+ };
21
21
 
22
- // Найдем элемент с классом container
23
- const modalContainer = document.createElement("div");
24
- document.body.appendChild(modalContainer);
22
+ // Найдем элемент с классом container
23
+ const modalContainer = document.createElement("div");
24
+ document.body.appendChild(modalContainer);
25
25
 
26
- // Реактивное обновление модалок через watch
27
- watch(
28
- () => modalStore.modals,
29
- (newModals) => {
30
- // Очищаем контейнер
31
- modalContainer.innerHTML = "";
26
+ // Реактивное обновление модалок через watch
27
+ watch(
28
+ () => modalStore.modals,
29
+ (newModals) => {
30
+ // Очищаем контейнер
31
+ modalContainer.innerHTML = "";
32
32
 
33
- // Добавляем модалки в DOM
34
- newModals.forEach((modal) => {
35
- modalContainer.dataset.modalId = String(modal.id);
33
+ // Добавляем модалки в DOM
34
+ newModals.forEach((modal) => {
35
+ modalContainer.dataset.modalId = String(modal.id);
36
36
 
37
- modalContainer.addEventListener("click", (event) => {
38
- console.log(`Closing modal with id: ${modal.id}`);
39
- modalStore.closeModal(modal.id);
40
- });
41
- modalContainer.setAttribute("name", modal.name);
42
- modalContainer.classList.add("modal");
43
- modalContainer.addEventListener("click", () => {
44
- console.log("this click on background");
45
- modalStore.closeModal(modal.id);
46
- });
37
+ modalContainer.addEventListener("click", (event) => {
38
+ console.log(`Closing modal with id: ${modal.id}`);
39
+ modalStore.closeModal(modal.id);
40
+ });
41
+ modalContainer.setAttribute("name", modal.name);
42
+ modalContainer.classList.add("modal");
43
+ modalContainer.addEventListener("click", () => {
44
+ console.log("this click on background");
45
+ modalStore.closeModal(modal.id);
46
+ if (modalStore.modals.length === 1) modalContainer.classList.remove("modal")
47
+ });
47
48
 
48
- const modalApp = createApp({
49
- render() {
50
- return h(Modal, {
51
- options: modal.options,
52
- name: modal.name,
53
- onClose: () => {
54
- modalContainer.classList.remove("modal");
55
- modalStore.closeModal(modal.id);
56
- },
57
- });
49
+ const modalApp = createApp({
50
+ render() {
51
+ return h(Modal, {
52
+ options: modal.options,
53
+ name: modal.name,
54
+ onClose: () => {
55
+ modalContainer.classList.remove("modal");
56
+ modalStore.closeModal(modal.id);
57
+ },
58
+ });
59
+ },
60
+ });
61
+ modalApp.mount(modalContainer);
62
+ });
58
63
  },
59
- });
60
- modalApp.mount(modalContainer);
61
- });
62
- },
63
- { deep: true }
64
- );
65
- },
64
+ {deep: true}
65
+ );
66
+ },
66
67
  };
67
68
 
68
69
  export function useModal() {
69
- const instance = getCurrentInstance();
70
- return instance?.appContext.config.globalProperties.$modal;
70
+ const instance = getCurrentInstance();
71
+ return instance?.appContext.config.globalProperties.$modal;
71
72
  }
72
73
 
73
74
  // Расширение глобального интерфейса для TypeScript
74
75
  declare module "@vue/runtime-core" {
75
- interface ComponentCustomProperties {
76
- $modal: {
77
- open: (name: string, options?: Record<string, any>) => void;
78
- close: (id: number) => void;
79
- };
80
- }
76
+ interface ComponentCustomProperties {
77
+ $modal: {
78
+ open: (name: string, options?: Record<string, any>) => void;
79
+ close: (id: number) => void;
80
+ };
81
+ }
81
82
  }