plugin-ui-for-kzt 0.0.3 → 0.0.5
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/README.md +88 -52
- package/package.json +1 -1
- package/src/components/Modal/Modal.vue +3 -3
- package/src/plugins/modalPlugin.ts +64 -63
- package/src/types/index.ts +4 -1
package/README.md
CHANGED
|
@@ -1,83 +1,119 @@
|
|
|
1
|
-
# plugin-ui-kzt
|
|
1
|
+
# plugin-ui-for-kzt
|
|
2
2
|
|
|
3
3
|
A custom UI plugin for Vue 3 + TypeScript projects, with Quasar integration support.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
## Installation
|
|
7
|
+
## 🚀 Installation
|
|
8
8
|
|
|
9
|
-
### Prerequisites
|
|
10
|
-
|
|
9
|
+
### ✅ Prerequisites
|
|
10
|
+
|
|
11
|
+
- Node.js **v23.x** or higher
|
|
12
|
+
- Vue 3 project (with or without Quasar)
|
|
13
|
+
|
|
14
|
+
### 📦 Install the Plugin
|
|
11
15
|
|
|
12
|
-
### Install the Plugin
|
|
13
16
|
```bash
|
|
14
17
|
npm install plugin-ui-for-kzt
|
|
15
18
|
```
|
|
16
19
|
|
|
17
20
|
---
|
|
18
21
|
|
|
19
|
-
## Quasar
|
|
22
|
+
## ⚙️ Quasar Integration Setup
|
|
23
|
+
|
|
24
|
+
If you're using **Quasar**, follow these additional steps to properly integrate the plugin:
|
|
25
|
+
|
|
26
|
+
### 1. Create a Boot File
|
|
27
|
+
|
|
28
|
+
Create a new file named `plugin-ui-for-kzt.ts` in your project's `boot/` directory.
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
```ts
|
|
31
|
+
// src/boot/plugin-ui-for-kzt.ts
|
|
32
|
+
import { boot } from 'quasar/wrappers'
|
|
33
|
+
import PluginUIForKZT from 'plugin-ui-for-kzt'
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
export default boot(({ app }) => {
|
|
36
|
+
app.use(PluginUIForKZT)
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Register the Boot File in `quasar.config.js`
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
boot: [
|
|
44
|
+
'plugin-ui-for-kzt',
|
|
45
|
+
// other boot files
|
|
46
|
+
]
|
|
47
|
+
```
|
|
25
48
|
|
|
26
|
-
|
|
27
|
-
- In `quasar.config.js`, add `'plugin-ui-for-kzt'` to the `boot` array:
|
|
28
|
-
```js
|
|
29
|
-
boot: [
|
|
30
|
-
'plugin-ui-kzt',
|
|
31
|
-
// other boot files
|
|
32
|
-
]
|
|
33
|
-
```
|
|
49
|
+
### 3. (Optional) Import in `client-entry.js` if needed
|
|
34
50
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
import('boot/plugin-ui-for-kzt')
|
|
39
|
-
```
|
|
51
|
+
```js
|
|
52
|
+
import('boot/plugin-ui-for-kzt')
|
|
53
|
+
```
|
|
40
54
|
|
|
41
55
|
---
|
|
42
56
|
|
|
43
|
-
##
|
|
57
|
+
## 🔢 Plugin Versioning Rules
|
|
44
58
|
|
|
45
|
-
|
|
59
|
+
The plugin version must follow the pattern: `X.Y.Z`, with a **maximum version value of 100**.
|
|
60
|
+
Examples of valid versions:
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
- `version: "0.0.25"`
|
|
63
|
+
- `version: "0.25.99"`
|
|
64
|
+
- `version: "46.25.46"`
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
- Commit and push all your changes to your GitLab repository.
|
|
66
|
+
---
|
|
52
67
|
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
npm login
|
|
56
|
-
```
|
|
57
|
-
- Use the **npm credentials** stored in GitLab.
|
|
68
|
+
## 🚀 Publishing the Plugin to npm
|
|
58
69
|
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
npm publish --access public
|
|
62
|
-
```
|
|
70
|
+
Follow these steps to update and publish a new version of the plugin:
|
|
63
71
|
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
npm cache clean --force
|
|
67
|
-
```
|
|
72
|
+
### 1. Update the Version
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
npm install plugin-ui-for-kzt@latest --force
|
|
72
|
-
```
|
|
74
|
+
Update the `version` field in your `package.json` file according to [Semantic Versioning](https://semver.org/).
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
quasar clean
|
|
77
|
-
quasar dev
|
|
78
|
-
```
|
|
76
|
+
### 2. Commit and Push to GitLab
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
```bash
|
|
79
|
+
git add .
|
|
80
|
+
git commit -m "chore: bump version to x.x.x"
|
|
81
|
+
git push
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. Log in to npm
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm login
|
|
88
|
+
```
|
|
81
89
|
|
|
82
|
-
|
|
90
|
+
> 💡 Use the **npm credentials** stored in your GitLab vault or settings.
|
|
91
|
+
|
|
92
|
+
### 4. Publish the Package
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm publish --access public
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 5. (Optional) Clear npm Cache
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm cache clean --force
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 6. Update the Plugin in Your Project
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm install plugin-ui-for-kzt@latest --force
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 7. Restart Your Quasar Project
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
quasar clean
|
|
114
|
+
quasar dev
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
83
118
|
|
|
119
|
+
✅ **Done!** Your plugin is now published and integrated successfully into your Quasar project.
|
package/package.json
CHANGED
|
@@ -54,8 +54,8 @@ const getTypeModal = computed<{ img: any; nameClass: string }>(() => {
|
|
|
54
54
|
return { img: SuccessIcon, nameClass: "success" };
|
|
55
55
|
case "warning":
|
|
56
56
|
return { img: WarningIcon, nameClass: "warning" };
|
|
57
|
-
case "
|
|
58
|
-
return { img: InfoIcon, nameClass: "
|
|
57
|
+
case "infoModal":
|
|
58
|
+
return { img: InfoIcon, nameClass: "infoModal" };
|
|
59
59
|
default:
|
|
60
60
|
return {
|
|
61
61
|
img: SuccessIcon,
|
|
@@ -139,7 +139,7 @@ const getTypeModal = computed<{ img: any; nameClass: string }>(() => {
|
|
|
139
139
|
background: #15b853;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
.
|
|
142
|
+
.infoModal {
|
|
143
143
|
background: #f4a900;
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -1,81 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {createApp, h, getCurrentInstance} from "vue";
|
|
2
|
+
import {useModalStore} from "../store/modal";
|
|
3
3
|
import Modal from "../components/Modal/Modal.vue";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import {watch} from "vue";
|
|
5
|
+
import {IModalState, IModalType} from "types";
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
install(app: any) {
|
|
9
|
+
const modalStore = useModalStore();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
// Добавление глобального метода $modal
|
|
12
|
+
app.config.globalProperties.$modal = {
|
|
13
|
+
open(name: IModalType, 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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
// Найдем элемент с классом container
|
|
23
|
+
const modalContainer = document.createElement("div");
|
|
24
|
+
document.body.appendChild(modalContainer);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
// Реактивное обновление модалок через watch
|
|
27
|
+
watch(
|
|
28
|
+
() => modalStore.modals,
|
|
29
|
+
(newModals) => {
|
|
30
|
+
// Очищаем контейнер
|
|
31
|
+
modalContainer.innerHTML = "";
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// Добавляем модалки в DOM
|
|
34
|
+
newModals.forEach((modal) => {
|
|
35
|
+
modalContainer.dataset.modalId = String(modal.id);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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 === 0) modalContainer.classList.remove("modal")
|
|
47
|
+
});
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
{ deep: true }
|
|
64
|
-
);
|
|
65
|
-
},
|
|
64
|
+
{deep: true}
|
|
65
|
+
);
|
|
66
|
+
},
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
export function useModal() {
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
interface ComponentCustomProperties {
|
|
77
|
+
$modal: {
|
|
78
|
+
open: (name: IModalType, options?: IModalState) => void;
|
|
79
|
+
close: (id: number) => void;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
81
82
|
}
|