prlg-ui 1.8.132 → 1.8.133
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/FileIcon-BE4ItwkK.cjs +1 -0
- package/dist/FileIcon-maHE2Nhr.js +101 -0
- package/dist/Image-BHDBSn7B.cjs +1 -0
- package/dist/Image-CAGIshx9.js +259 -0
- package/dist/QuestionIcon-DptFSXX2.cjs +1 -0
- package/dist/QuestionIcon-tK1kUB_h.js +340 -0
- package/dist/SendIcon-CH6S0QWh.cjs +1 -0
- package/dist/SendIcon-Cqdt2QWN.js +88 -0
- package/dist/blocks/index.cjs.js +1 -0
- package/dist/blocks/index.es.js +186 -0
- package/dist/blocks.d.ts +35 -0
- package/dist/eventBus.util-K9Yq6hZm.cjs +1 -0
- package/dist/eventBus.util-msbJpg6N.js +75 -0
- package/dist/fonts/Roboto/Roboto-Black.woff +0 -0
- package/dist/fonts/Roboto/Roboto-Black.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-Bold.woff +0 -0
- package/dist/fonts/Roboto/Roboto-Bold.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-ExtraBold.woff +0 -0
- package/dist/fonts/Roboto/Roboto-ExtraBold.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-ExtraLight.woff +0 -0
- package/dist/fonts/Roboto/Roboto-ExtraLight.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-Light.woff +0 -0
- package/dist/fonts/Roboto/Roboto-Light.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-Medium.woff +0 -0
- package/dist/fonts/Roboto/Roboto-Medium.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-Regular.woff +0 -0
- package/dist/fonts/Roboto/Roboto-Regular.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-SemiBold.woff +0 -0
- package/dist/fonts/Roboto/Roboto-SemiBold.woff2 +0 -0
- package/dist/fonts/Roboto/Roboto-Thin.woff +0 -0
- package/dist/fonts/Roboto/Roboto-Thin.woff2 +0 -0
- package/dist/icons/index.cjs.js +1 -0
- package/dist/icons/index.es.js +1487 -0
- package/dist/icons.d.ts +220 -0
- package/dist/index.d.ts +2096 -0
- package/dist/parseFileSize.util-Bg1rLRLQ.cjs +1 -0
- package/dist/parseFileSize.util-CxVk4CvB.js +785 -0
- package/dist/prlg-ui.cjs.js +1 -0
- package/dist/prlg-ui.css +1 -0
- package/dist/prlg-ui.es.js +6227 -0
- package/dist/scss/animations.scss +30 -0
- package/dist/scss/colors.scss +135 -0
- package/dist/scss/fonts.scss +3 -0
- package/dist/scss/main.scss +36 -0
- package/dist/scss/mixins.scss +177 -0
- package/dist/scss/reset.scss +51 -0
- package/dist/scss/root-vars.scss +12 -0
- package/dist/types/index.cjs.js +1 -0
- package/dist/types/index.es.js +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/uploadFile.util-DCFkx3w3.cjs +1 -0
- package/dist/uploadFile.util-DhavPrlY.js +37 -0
- package/dist/utils/date.util.ts +30 -0
- package/dist/utils/dayjs.util.ts +32 -0
- package/dist/utils/eventBus.util.ts +43 -0
- package/dist/utils/index.cjs.js +1 -0
- package/dist/utils/index.es.js +1891 -0
- package/dist/utils/index.ts +3 -0
- package/dist/utils/isClient.util.ts +3 -0
- package/dist/utils/mask.util.test.ts +170 -0
- package/dist/utils/mask.util.ts +217 -0
- package/dist/utils/onClickOutside.util.ts +78 -0
- package/dist/utils/parseDate.util.ts +41 -0
- package/dist/utils/parseFileSize.util.ts +38 -0
- package/dist/utils/price.util.ts +28 -0
- package/dist/utils/typeFile.util.ts +32 -0
- package/dist/utils/uploadFile.util.ts +94 -0
- package/dist/utils/useBodyScroll.util.ts +41 -0
- package/dist/utils.d.ts +141 -0
- package/dist/vite.svg +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { parseFileSize } from '@/utils/parseFileSize.util'
|
|
2
|
+
|
|
3
|
+
type FileType = 'image' | 'pdf' | 'excel' | 'word' | 'all';
|
|
4
|
+
|
|
5
|
+
interface OpenFileDialogOptions {
|
|
6
|
+
accept?: FileType | FileType[];
|
|
7
|
+
maxFileSize?: string; // например, "5mb"
|
|
8
|
+
maxFiles?: number;
|
|
9
|
+
multiple?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Преобразует типы файлов в accept-строку для input[type="file"]
|
|
14
|
+
*/
|
|
15
|
+
function getAcceptString(accept?: FileType | FileType[]): string | undefined {
|
|
16
|
+
if (!accept) return undefined;
|
|
17
|
+
const types = Array.isArray(accept) ? accept : [accept];
|
|
18
|
+
const map: Record<FileType, string[]> = {
|
|
19
|
+
image: ['image/*'],
|
|
20
|
+
pdf: ['application/pdf'],
|
|
21
|
+
excel: [
|
|
22
|
+
'application/vnd.ms-excel',
|
|
23
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
24
|
+
],
|
|
25
|
+
word: [
|
|
26
|
+
'application/msword',
|
|
27
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
28
|
+
],
|
|
29
|
+
all: ['*/*']
|
|
30
|
+
};
|
|
31
|
+
return types.flatMap(type => map[type] || []).join(',');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Открывает окно выбора файла для загрузки с ограничениями.
|
|
36
|
+
* @param options - настройки выбора файлов
|
|
37
|
+
* @returns {Promise<File[]>} - промис с выбранными файлами
|
|
38
|
+
*
|
|
39
|
+
* Пример использования:
|
|
40
|
+
*
|
|
41
|
+
* openFileDialog({
|
|
42
|
+
* accept: ['image', 'pdf'],
|
|
43
|
+
* maxFileSize: '5mb',
|
|
44
|
+
* maxFiles: 3
|
|
45
|
+
* }).then((files) => {
|
|
46
|
+
* // files — массив выбранных файлов, соответствующих ограничениям
|
|
47
|
+
* console.log(files);
|
|
48
|
+
* });
|
|
49
|
+
*/
|
|
50
|
+
export function openFileDialog(options: OpenFileDialogOptions = {}): Promise<File[]> {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
const input = document.createElement('input');
|
|
53
|
+
input.type = 'file';
|
|
54
|
+
input.style.display = 'none';
|
|
55
|
+
|
|
56
|
+
if (options.multiple && options.maxFiles && options.maxFiles > 1) {
|
|
57
|
+
input.multiple = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const acceptString = getAcceptString(options.accept);
|
|
61
|
+
if (acceptString) {
|
|
62
|
+
input.accept = acceptString;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
input.addEventListener('change', (event: Event) => {
|
|
66
|
+
const target = event.target as HTMLInputElement;
|
|
67
|
+
let files: File[] = [];
|
|
68
|
+
|
|
69
|
+
if (target.files && target.files.length > 0) {
|
|
70
|
+
files = Array.from(target.files);
|
|
71
|
+
|
|
72
|
+
// Ограничение по количеству файлов
|
|
73
|
+
if (options.maxFiles && files.length > options.maxFiles) {
|
|
74
|
+
files = files.slice(0, options.maxFiles);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Ограничение по размеру файла
|
|
78
|
+
if (options.maxFileSize) {
|
|
79
|
+
const maxSize = parseFileSize(options.maxFileSize);
|
|
80
|
+
files = files.filter(file => file.size <= maxSize);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
resolve(files);
|
|
85
|
+
document.body.removeChild(input);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
document.body.appendChild(input);
|
|
89
|
+
input.click();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
let restoreScroll: (() => void) | null = null;
|
|
2
|
+
let lockCount = 0;
|
|
3
|
+
|
|
4
|
+
function preventScrollMobileSafari() {
|
|
5
|
+
const scrollY = window.scrollY;
|
|
6
|
+
document.body.style.position = "fixed";
|
|
7
|
+
document.body.style.top = `-${scrollY}px`;
|
|
8
|
+
|
|
9
|
+
return () => {
|
|
10
|
+
document.body.style.position = "";
|
|
11
|
+
document.body.style.top = "";
|
|
12
|
+
window.scrollTo(0, scrollY);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Utility function to block scroll
|
|
17
|
+
const preventScroll = () => {
|
|
18
|
+
lockCount++;
|
|
19
|
+
if (lockCount === 1 && !restoreScroll) {
|
|
20
|
+
restoreScroll = preventScrollMobileSafari();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Utility function to restore scroll
|
|
25
|
+
const allowScroll = () => {
|
|
26
|
+
if (lockCount > 0) {
|
|
27
|
+
lockCount--;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (lockCount === 0 && restoreScroll) {
|
|
31
|
+
restoreScroll();
|
|
32
|
+
restoreScroll = null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const useBodyScroll = () => {
|
|
37
|
+
return {
|
|
38
|
+
unlockScroll: allowScroll,
|
|
39
|
+
lockScroll: preventScroll,
|
|
40
|
+
};
|
|
41
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
2
|
+
import { ComponentProvideOptions } from 'vue';
|
|
3
|
+
import { ComponentPublicInstance } from 'vue';
|
|
4
|
+
import { default as dayjs } from 'dayjs';
|
|
5
|
+
import { DefineComponent } from 'vue';
|
|
6
|
+
import { MaybeRef } from 'vue';
|
|
7
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
8
|
+
import { PublicProps } from 'vue';
|
|
9
|
+
|
|
10
|
+
declare const __VLS_component: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
11
|
+
target: string;
|
|
12
|
+
show: boolean;
|
|
13
|
+
overlayType: OverlayType;
|
|
14
|
+
teleport: boolean;
|
|
15
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
|
|
17
|
+
declare function __VLS_template(): {
|
|
18
|
+
attrs: Partial<{}>;
|
|
19
|
+
slots: {
|
|
20
|
+
default?(_: {}): any;
|
|
21
|
+
};
|
|
22
|
+
refs: {};
|
|
23
|
+
rootEl: any;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
27
|
+
|
|
28
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
29
|
+
new (): {
|
|
30
|
+
$slots: S;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { dayjs }
|
|
35
|
+
|
|
36
|
+
export declare function EventBus<Events extends Record<string, any>>(): TypedEventBus<Events>;
|
|
37
|
+
|
|
38
|
+
declare type FileType = 'image' | 'pdf' | 'excel' | 'word' | 'all';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Форматирует дату в человекочитаемый вид: 20 июня 2025
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatDateReadable(date: string | Date): string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Форматирует дату для отображения времени: 20 июня, 14:30
|
|
47
|
+
*/
|
|
48
|
+
export declare function formatDateWithTime(date: string | Date): string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Преобразует число в форматированную строку с валютой (по умолчанию: ₽)
|
|
52
|
+
*/
|
|
53
|
+
export declare function formatPrice(value: number, currency?: string): string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Возвращает разницу между датами в днях
|
|
57
|
+
*/
|
|
58
|
+
export declare function getDaysBetween(start: string | Date, end: string | Date): number;
|
|
59
|
+
|
|
60
|
+
export declare type Handler<T> = (event: T) => void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Проверяет, истекла ли дата
|
|
64
|
+
*/
|
|
65
|
+
export declare function isExpired(date: string | Date): boolean;
|
|
66
|
+
|
|
67
|
+
export declare type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
|
|
68
|
+
|
|
69
|
+
export declare type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
|
|
70
|
+
|
|
71
|
+
export declare type MaybeElementTarget = MaybeElementRef<MaybeElement> | string;
|
|
72
|
+
|
|
73
|
+
export declare function onClickOutside(target: MaybeElementTarget, handler: (event: MouseEvent | TouchEvent) => void, options?: OnClickOutsideOptions): () => void;
|
|
74
|
+
|
|
75
|
+
export declare interface OnClickOutsideOptions {
|
|
76
|
+
ignore?: MaybeRefOrGetter<(MaybeElementRef<MaybeElement> | string)[]>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Открывает окно выбора файла для загрузки с ограничениями.
|
|
81
|
+
* @param options - настройки выбора файлов
|
|
82
|
+
* @returns {Promise<File[]>} - промис с выбранными файлами
|
|
83
|
+
*
|
|
84
|
+
* Пример использования:
|
|
85
|
+
*
|
|
86
|
+
* openFileDialog({
|
|
87
|
+
* accept: ['image', 'pdf'],
|
|
88
|
+
* maxFileSize: '5mb',
|
|
89
|
+
* maxFiles: 3
|
|
90
|
+
* }).then((files) => {
|
|
91
|
+
* // files — массив выбранных файлов, соответствующих ограничениям
|
|
92
|
+
* console.log(files);
|
|
93
|
+
* });
|
|
94
|
+
*/
|
|
95
|
+
export declare function openFileDialog(options?: OpenFileDialogOptions): Promise<File[]>;
|
|
96
|
+
|
|
97
|
+
declare interface OpenFileDialogOptions {
|
|
98
|
+
accept?: FileType | FileType[];
|
|
99
|
+
maxFileSize?: string;
|
|
100
|
+
maxFiles?: number;
|
|
101
|
+
multiple?: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare type OverlayType = 'modal' | 'drawer' | 'popover' | 'tooltip' | 'confirm';
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Делает безопасное преобразование строки в число (цены из инпута)
|
|
108
|
+
*/
|
|
109
|
+
export declare function parsePrice(input: string): number;
|
|
110
|
+
|
|
111
|
+
export declare const Portal: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
112
|
+
|
|
113
|
+
declare interface Props {
|
|
114
|
+
overlayType?: OverlayType;
|
|
115
|
+
teleport?: boolean;
|
|
116
|
+
target?: string;
|
|
117
|
+
zIndex?: number;
|
|
118
|
+
show?: boolean;
|
|
119
|
+
parentId?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Возвращает сумму всех значений (например, для корзины)
|
|
124
|
+
*/
|
|
125
|
+
export declare function sumPrices(items: number[]): number;
|
|
126
|
+
|
|
127
|
+
export declare interface TypedEventBus<Events extends Record<string, any>> {
|
|
128
|
+
on<K extends keyof Events>(type: K, handler: Handler<Events[K]>): void;
|
|
129
|
+
off<K extends keyof Events>(type: K, handler: Handler<Events[K]>): void;
|
|
130
|
+
emit<K extends keyof Events>(type: K, evt?: Events[K]): void;
|
|
131
|
+
clear(): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare const useBodyScroll: () => {
|
|
135
|
+
unlockScroll: () => void;
|
|
136
|
+
lockScroll: () => void;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export declare type VueInstance = ComponentPublicInstance;
|
|
140
|
+
|
|
141
|
+
export { }
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|