plugin-ui-for-kzt 0.0.23 → 0.0.25
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/dist/assets/0e28e37419c99ac65b12.png +0 -0
- package/dist/assets/264165b2b0e8a6840eb0.png +0 -0
- package/dist/components/{DataTable/DataTable.vue.d.ts → BaseDefaultPages/BaseDefaultPages.vue.d.ts} +8 -6
- package/dist/components/BaseInput/BaseInput.vue.d.ts +1 -1
- package/dist/components/{Tooltip/Tooltip.vue.d.ts → BasePageLoader/BasePageLoader.vue.d.ts} +24 -11
- package/dist/components/BaseTable/BaseTable.vue.d.ts +44 -0
- package/dist/components/BaseToast/BaseToast.vue.d.ts +69 -0
- package/dist/composables/useToast.d.ts +2 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +1 -1
- package/dist/plugins/toastPlugin.d.ts +4 -0
- package/dist/sprite.svg +1 -1
- package/dist/store/toast.d.ts +8 -0
- package/example/App.vue +196 -29
- package/package.json +1 -1
- package/src/assets/404.png +0 -0
- package/src/assets/icons/arrow-down-stick.svg +4 -0
- package/src/assets/icons/edit-table.svg +5 -0
- package/src/assets/icons/ellipsis.svg +5 -0
- package/src/assets/icons/loading-page-default.svg +4 -0
- package/src/assets/icons/loading-page-error.svg +6 -0
- package/src/assets/icons/loading-page-success.svg +5 -0
- package/src/assets/icons/loading-page-warning.svg +6 -0
- package/src/assets/icons/more-dots.svg +5 -0
- package/src/assets/icons/time-table.svg +7 -0
- package/src/assets/icons/toast-error.svg +3 -0
- package/src/assets/icons/toast-info.svg +3 -0
- package/src/assets/icons/toast-success.svg +3 -0
- package/src/assets/icons/toast-warning.svg +3 -0
- package/src/assets/icons/trash-table.svg +7 -0
- package/src/assets/tech-work.png +0 -0
- package/src/components/BaseChips/BaseChips.vue +3 -1
- package/src/components/BaseDefaultPages/BaseDefaultPages.vue +140 -0
- package/src/components/BaseDefaultPages/README.md +128 -0
- package/src/components/BaseOpenedListItem/BaseOpenedListItem.vue +3 -3
- package/src/components/BasePageLoader/BasePageLoader.vue +211 -0
- package/src/components/BasePageLoader/README.md +80 -0
- package/src/components/BaseSelect/BaseSelect.vue +7 -3
- package/src/components/BaseTable/BaseTable.vue +411 -0
- package/src/components/BaseTable/README.md +294 -0
- package/src/components/BaseToast/BaseToast.vue +200 -0
- package/src/components/BaseToast/README.md +103 -0
- package/src/components/BaseTooltip/BaseTooltip.vue +1 -0
- package/src/components/BaseUpload/BaseUpload.vue +1 -1
- package/src/composables/useToast.ts +10 -0
- package/src/index.ts +17 -13
- package/src/plugins/toastPlugin.ts +100 -0
- package/src/store/toast.ts +59 -0
- package/src/styles/root.scss +2 -0
- package/src/styles/toast.scss +36 -0
- package/src/types/default-pages.d.ts +6 -0
- package/src/types/loading-page.d.ts +12 -0
- package/src/types/pagination.d.ts +1 -0
- package/src/types/table.d.ts +33 -0
- package/src/types/toast.d.ts +25 -0
- package/webpack.config.js +12 -0
- package/dist/components/Spinner/Spinner.vue.d.ts +0 -20
- package/dist/components/Toaster/Toaster.vue.d.ts +0 -80
- package/dist/components/Toaster/timer.d.ts +0 -12
- package/dist/plugins/toasterPlugin.d.ts +0 -26
- package/src/components/DataTable/DataTable.vue +0 -169
- package/src/components/DataTable/README.md +0 -57
- package/src/components/Spinner/README.md +0 -35
- package/src/components/Spinner/Spinner.vue +0 -60
- package/src/components/Toaster/README.md +0 -70
- package/src/components/Toaster/Toaster.vue +0 -235
- package/src/components/Toaster/timer.ts +0 -45
- package/src/components/Tooltip/README.md +0 -37
- package/src/components/Tooltip/Tooltip.vue +0 -96
- package/src/components/icons/CloseIcon.vue +0 -5
- package/src/components/icons/ErrorIcon.vue +0 -7
- package/src/components/icons/InfoIcon.vue +0 -7
- package/src/components/icons/SuccessIcon.vue +0 -6
- package/src/components/icons/WarningIcon.vue +0 -7
- package/src/plugins/toasterPlugin.ts +0 -179
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { createApp, h, ref, getCurrentInstance } from "vue";
|
|
2
|
-
import Toaster from "../components/Toaster/Toaster.vue";
|
|
3
|
-
|
|
4
|
-
interface ToastOptions {
|
|
5
|
-
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
6
|
-
duration?: number;
|
|
7
|
-
dismissible?: boolean;
|
|
8
|
-
pauseOnHover?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface Toast {
|
|
12
|
-
id: number;
|
|
13
|
-
type: "success" | "error" | "info" | "warning";
|
|
14
|
-
message: string;
|
|
15
|
-
position: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
16
|
-
duration: number;
|
|
17
|
-
dismissible: boolean;
|
|
18
|
-
pauseOnHover: boolean;
|
|
19
|
-
height?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface ToastPosition {
|
|
23
|
-
toasts: Toast[];
|
|
24
|
-
totalHeight: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default {
|
|
28
|
-
install(app: any) {
|
|
29
|
-
app.config.globalProperties.$toast = {
|
|
30
|
-
success: (message: string, options: ToastOptions = {}) =>
|
|
31
|
-
addToast("success", message, options),
|
|
32
|
-
error: (message: string, options: ToastOptions = {}) =>
|
|
33
|
-
addToast("error", message, options),
|
|
34
|
-
info: (message: string, options: ToastOptions = {}) =>
|
|
35
|
-
addToast("info", message, options),
|
|
36
|
-
warning: (message: string, options: ToastOptions = {}) =>
|
|
37
|
-
addToast("warning", message, options),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const toasts = ref<Toast[]>([]);
|
|
41
|
-
const toastPositions = ref<Record<string, ToastPosition>>({
|
|
42
|
-
"top-right": { toasts: [], totalHeight: 0 },
|
|
43
|
-
"top-left": { toasts: [], totalHeight: 0 },
|
|
44
|
-
"bottom-right": { toasts: [], totalHeight: 0 },
|
|
45
|
-
"bottom-left": { toasts: [], totalHeight: 0 },
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const calculatePosition = (toast: Toast, index: number): number => {
|
|
49
|
-
const position = toast.position;
|
|
50
|
-
const positionData = toastPositions.value[position];
|
|
51
|
-
const gap = 10;
|
|
52
|
-
let offset = 20;
|
|
53
|
-
|
|
54
|
-
for (let i = 0; i < index; i++) {
|
|
55
|
-
const prevToast = positionData.toasts[i];
|
|
56
|
-
offset += (prevToast.height || 0) + gap;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return offset;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const updateToastHeight = (id: number, height: number) => {
|
|
63
|
-
const toast = toasts.value.find((t) => t.id === id);
|
|
64
|
-
if (toast) {
|
|
65
|
-
toast.height = height;
|
|
66
|
-
const position = toast.position;
|
|
67
|
-
const positionData = toastPositions.value[position];
|
|
68
|
-
positionData.totalHeight = positionData.toasts.reduce(
|
|
69
|
-
(total, t) => total + (t.height || 0) + 10,
|
|
70
|
-
20
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const addToast = (
|
|
76
|
-
type: "success" | "error" | "info" | "warning",
|
|
77
|
-
message: string,
|
|
78
|
-
options: ToastOptions = {}
|
|
79
|
-
) => {
|
|
80
|
-
const id = Date.now();
|
|
81
|
-
const position = options.position || "top-right";
|
|
82
|
-
const duration = options.duration || 5000;
|
|
83
|
-
const dismissible =
|
|
84
|
-
options.dismissible !== undefined ? options.dismissible : true;
|
|
85
|
-
const pauseOnHover =
|
|
86
|
-
options.pauseOnHover !== undefined ? options.pauseOnHover : true;
|
|
87
|
-
|
|
88
|
-
const toastData: Toast = {
|
|
89
|
-
id,
|
|
90
|
-
type,
|
|
91
|
-
message,
|
|
92
|
-
position,
|
|
93
|
-
duration,
|
|
94
|
-
dismissible,
|
|
95
|
-
pauseOnHover,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
toasts.value = [...toasts.value, toastData];
|
|
99
|
-
toastPositions.value[position].toasts.push(toastData);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const removeToast = (id: number) => {
|
|
103
|
-
const toast = toasts.value.find((t) => t.id === id);
|
|
104
|
-
if (toast) {
|
|
105
|
-
const position = toast.position;
|
|
106
|
-
toastPositions.value[position].toasts = toastPositions.value[
|
|
107
|
-
position
|
|
108
|
-
].toasts.filter((t) => t.id !== id);
|
|
109
|
-
|
|
110
|
-
toastPositions.value[position].totalHeight = toastPositions.value[
|
|
111
|
-
position
|
|
112
|
-
].toasts.reduce((total, t) => total + (t.height || 0) + 10, 20);
|
|
113
|
-
}
|
|
114
|
-
toasts.value = toasts.value.filter((t) => t.id !== id);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const createContainer = (position: string) => {
|
|
118
|
-
const container = document.createElement("div");
|
|
119
|
-
container.classList.add("toast-container", `toast--${position}`);
|
|
120
|
-
document.body.appendChild(container);
|
|
121
|
-
return container;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const topRightContainer = createContainer("top-right");
|
|
125
|
-
const bottomRightContainer = createContainer("bottom-right");
|
|
126
|
-
const topLeftContainer = createContainer("top-left");
|
|
127
|
-
const bottomLeftContainer = createContainer("bottom-left");
|
|
128
|
-
|
|
129
|
-
const createAppInstance = (position: string, container: HTMLElement) => {
|
|
130
|
-
createApp({
|
|
131
|
-
setup() {
|
|
132
|
-
return { toasts, toastPositions };
|
|
133
|
-
},
|
|
134
|
-
render() {
|
|
135
|
-
const positionToasts = toastPositions.value[position].toasts;
|
|
136
|
-
|
|
137
|
-
return positionToasts.map((toast, index) => {
|
|
138
|
-
const offset = calculatePosition(toast, index);
|
|
139
|
-
|
|
140
|
-
return h(Toaster, {
|
|
141
|
-
key: toast.id,
|
|
142
|
-
...toast,
|
|
143
|
-
style: {
|
|
144
|
-
position: "fixed",
|
|
145
|
-
[position.includes("top") ? "top" : "bottom"]: `${offset}px`,
|
|
146
|
-
[position.includes("right") ? "right" : "left"]: "20px",
|
|
147
|
-
transition: "all 0.3s ease",
|
|
148
|
-
},
|
|
149
|
-
onDismiss: () => removeToast(toast.id),
|
|
150
|
-
onHeightUpdate: (height: number) =>
|
|
151
|
-
updateToastHeight(toast.id, height),
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
},
|
|
155
|
-
}).mount(container);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
createAppInstance("top-right", topRightContainer);
|
|
159
|
-
createAppInstance("bottom-right", bottomRightContainer);
|
|
160
|
-
createAppInstance("top-left", topLeftContainer);
|
|
161
|
-
createAppInstance("bottom-left", bottomLeftContainer);
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export function useToast() {
|
|
166
|
-
const instance = getCurrentInstance();
|
|
167
|
-
return instance?.appContext.config.globalProperties.$toast;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
declare module "@vue/runtime-core" {
|
|
171
|
-
interface ComponentCustomProperties {
|
|
172
|
-
$toast: {
|
|
173
|
-
success: (message: string, options?: ToastOptions) => void;
|
|
174
|
-
error: (message: string, options?: ToastOptions) => void;
|
|
175
|
-
info: (message: string, options?: ToastOptions) => void;
|
|
176
|
-
warning: (message: string, options?: ToastOptions) => void;
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}
|