plugin-ui-for-kzt 0.0.4 → 0.0.6

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.4",
3
+ "version": "0.0.6",
4
4
  "description": "plugin-ui for kazaktelekom",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -7,6 +7,7 @@
7
7
  [getTypeModal.nameClass]: getTypeModal.nameClass !== '',
8
8
  }"
9
9
  >
10
+ {{getTypeModal}}
10
11
  <div class="modal-container-header-title">
11
12
  <component :is="getTypeModal.img" />
12
13
  <div>{{ options.title }}</div>
@@ -27,26 +28,25 @@
27
28
  </template>
28
29
 
29
30
  <script setup lang="ts">
30
- import { ref, computed } from "vue";
31
+ import {ref, computed, Component} from "vue";
31
32
  import CloseIcon from "../icons/CloseIcon.vue";
32
33
  import ErrorIcon from "../icons/ErrorIcon.vue";
33
34
  import SuccessIcon from "../icons/SuccessIcon.vue";
34
35
  import WarningIcon from "../icons/WarningIcon.vue";
35
36
  import InfoIcon from "../icons/InfoIcon.vue";
37
+ import {IModalState, IModalType} from "../../types/index";
36
38
 
37
39
  interface IProps {
38
- options: {
39
- title: string;
40
- message: string;
41
- };
42
- name: string;
40
+ options:IModalState
41
+ name: IModalType;
43
42
  onClose: () => void;
44
43
  }
45
44
 
46
45
  const props = defineProps<IProps>();
47
46
  const showMore = ref<boolean>(false);
48
47
 
49
- const getTypeModal = computed<{ img: any; nameClass: string }>(() => {
48
+ const getTypeModal = computed<{ img: Component; nameClass: string }>(() => {
49
+ console.log(props.name);
50
50
  switch (props.name) {
51
51
  case "error":
52
52
  return { img: ErrorIcon, nameClass: "error" };
@@ -59,13 +59,13 @@ const getTypeModal = computed<{ img: any; nameClass: string }>(() => {
59
59
  default:
60
60
  return {
61
61
  img: SuccessIcon,
62
- nameClass: "",
62
+ nameClass: "info",
63
63
  };
64
64
  }
65
65
  });
66
66
  </script>
67
67
 
68
- <style lang="scss">
68
+ <style lang="scss" scoped>
69
69
  .modal {
70
70
  position: fixed;
71
71
  top: 0;
@@ -139,7 +139,7 @@ const getTypeModal = computed<{ img: any; nameClass: string }>(() => {
139
139
  background: #15b853;
140
140
  }
141
141
 
142
- .info {
142
+ .infoModal {
143
143
  background: #f4a900;
144
144
  }
145
145
 
@@ -2,7 +2,7 @@ import {createApp, h, getCurrentInstance} from "vue";
2
2
  import {useModalStore} from "../store/modal";
3
3
  import Modal from "../components/Modal/Modal.vue";
4
4
  import {watch} from "vue";
5
- import {IModalState} from "types";
5
+ import {IModalState, IModalType} from "types";
6
6
 
7
7
  export default {
8
8
  install(app: any) {
@@ -10,7 +10,7 @@ export default {
10
10
 
11
11
  // Добавление глобального метода $modal
12
12
  app.config.globalProperties.$modal = {
13
- open(name: string, options: IModalState) {
13
+ open(name: IModalType, options: IModalState) {
14
14
  modalStore.openModal(name, options); // Открытие модалки через Pinia
15
15
  console.log("Current modals:", modalStore.modals);
16
16
  },
@@ -36,15 +36,12 @@ export default {
36
36
 
37
37
  modalContainer.addEventListener("click", (event) => {
38
38
  console.log(`Closing modal with id: ${modal.id}`);
39
+ console.log("this click on background", modalStore.modals.length);
39
40
  modalStore.closeModal(modal.id);
41
+ if (modalStore.modals.length === 1) modalContainer.classList.remove("modal")
40
42
  });
41
43
  modalContainer.setAttribute("name", modal.name);
42
44
  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
- });
48
45
 
49
46
  const modalApp = createApp({
50
47
  render() {
@@ -75,7 +72,7 @@ export function useModal() {
75
72
  declare module "@vue/runtime-core" {
76
73
  interface ComponentCustomProperties {
77
74
  $modal: {
78
- open: (name: string, options?: Record<string, any>) => void;
75
+ open: (name: IModalType, options?: IModalState) => void;
79
76
  close: (id: number) => void;
80
77
  };
81
78
  }
@@ -1,4 +1,7 @@
1
1
  export interface IModalState{
2
2
  title: string;
3
3
  message: string;
4
- }
4
+ }
5
+
6
+ export type IModalType= string | 'success' | 'error' | 'info' | 'warning';
7
+