vgapp 1.4.4 → 1.4.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/README.md +270 -270
- package/app/langs/en/buttons.json +17 -17
- package/app/langs/en/messages.json +36 -36
- package/app/langs/ru/buttons.json +17 -17
- package/app/langs/ru/messages.json +36 -36
- package/app/modules/vgalert/js/vgalert.js +266 -266
- package/app/modules/vgalert/scss/_variables.scss +16 -16
- package/app/modules/vgalert/scss/vgalert.scss +107 -107
- package/app/modules/vgcollapse/scss/_variables.scss +7 -7
- package/app/modules/vgcollapse/scss/vgcollapse.scss +5 -5
- package/app/modules/vgdropdown/scss/_variables.scss +14 -14
- package/app/modules/vgdropdown/scss/vgdropdown.scss +5 -5
- package/app/modules/vgdynamictable/index.js +4 -4
- package/app/modules/vgdynamictable/js/filters.js +21 -21
- package/app/modules/vgdynamictable/js/fixed.js +179 -179
- package/app/modules/vgdynamictable/js/options.js +3 -3
- package/app/modules/vgdynamictable/js/pagination.js +1 -1
- package/app/modules/vgdynamictable/js/search.js +12 -12
- package/app/modules/vgdynamictable/js/skeleton.js +27 -19
- package/app/modules/vgdynamictable/js/sortable.js +71 -71
- package/app/modules/vgdynamictable/js/summary-footer.js +28 -28
- package/app/modules/vgdynamictable/js/table-url-state.js +31 -31
- package/app/modules/vgdynamictable/js/utils/common.js +48 -48
- package/app/modules/vgdynamictable/js/vgdynamictable.js +79 -79
- package/app/modules/vgdynamictable/scss/_actions.scss +19 -19
- package/app/modules/vgdynamictable/scss/_pagination.scss +5 -5
- package/app/modules/vgdynamictable/scss/_skeleton.scss +11 -11
- package/app/modules/vgdynamictable/scss/_sortable.scss +28 -28
- package/app/modules/vgdynamictable/scss/_table.scss +7 -30
- package/app/modules/vgdynamictable/scss/_variables.scss +46 -46
- package/app/modules/vgdynamictable/scss/vgdynamictable.scss +28 -36
- package/app/modules/vgfilepreview/js/i18n.js +56 -56
- package/app/modules/vgfilepreview/js/renderers/image-modal.js +145 -145
- package/app/modules/vgfilepreview/js/renderers/image.js +92 -92
- package/app/modules/vgfilepreview/js/renderers/index.js +19 -19
- package/app/modules/vgfilepreview/js/renderers/office-modal.js +168 -168
- package/app/modules/vgfilepreview/js/renderers/office.js +79 -79
- package/app/modules/vgfilepreview/js/renderers/pdf-modal.js +260 -260
- package/app/modules/vgfilepreview/js/renderers/pdf.js +76 -76
- package/app/modules/vgfilepreview/js/renderers/playlist.js +71 -71
- package/app/modules/vgfilepreview/js/renderers/text-modal.js +343 -343
- package/app/modules/vgfilepreview/js/renderers/text.js +83 -83
- package/app/modules/vgfilepreview/js/renderers/video-modal.js +272 -272
- package/app/modules/vgfilepreview/js/renderers/video.js +80 -80
- package/app/modules/vgfilepreview/js/renderers/zip-modal.js +522 -522
- package/app/modules/vgfilepreview/js/renderers/zip.js +89 -89
- package/app/modules/vgfilepreview/js/vgfilepreview.js +7 -7
- package/app/modules/vgfilepreview/readme.md +68 -68
- package/app/modules/vgfilepreview/scss/_variables.scss +115 -115
- package/app/modules/vgfilepreview/scss/vgfilepreview.scss +463 -463
- package/app/modules/vgfiles/js/droppable.js +20 -9
- package/app/modules/vgfiles/js/render.js +153 -153
- package/app/modules/vgfiles/js/vgfiles.js +104 -104
- package/app/modules/vgfiles/readme.md +123 -123
- package/app/modules/vgfiles/scss/_mixins.scss +9 -9
- package/app/modules/vgfiles/scss/_variables.scss +41 -41
- package/app/modules/vgfiles/scss/vgfiles.scss +161 -161
- package/app/modules/vgformsender/js/hideshowpass.js +21 -16
- package/app/modules/vgformsender/js/vgformsender.js +4 -6
- package/app/modules/vgformsender/readme.md +1 -1
- package/app/modules/vgformsender/scss/_variables.scss +5 -5
- package/app/modules/vgformsender/scss/vgformsender.scss +42 -42
- package/app/modules/vglawcookie/js/vglawcookie.js +11 -8
- package/app/modules/vglawcookie/scss/_variables.scss +13 -13
- package/app/modules/vglawcookie/scss/vglawcookie.scss +5 -5
- package/app/modules/vgmodal/js/vgmodal.interaction.js +216 -216
- package/app/modules/vgmodal/js/vgmodal.js +355 -355
- package/app/modules/vgmodal/js/vgmodal.minimized.js +227 -227
- package/app/modules/vgmodal/scss/_variables.scss +17 -17
- package/app/modules/vgmodal/scss/vgmodal.scss +77 -77
- package/app/modules/vgnav/js/vgnav.js +180 -180
- package/app/modules/vgnav/scss/_breakpoints.scss +36 -36
- package/app/modules/vgnav/scss/_hamburger.scss +5 -5
- package/app/modules/vgnav/scss/_placement.scss +5 -5
- package/app/modules/vgnav/scss/_toggle.scss +5 -5
- package/app/modules/vgnav/scss/_variables.scss +26 -26
- package/app/modules/vgnav/scss/vgnav.scss +41 -41
- package/app/modules/vgnestable/README.md +39 -39
- package/app/modules/vgnestable/js/vgnestable.js +358 -358
- package/app/modules/vgnestable/scss/_variables.scss +35 -35
- package/app/modules/vgnestable/scss/vgnestable.scss +55 -55
- package/app/modules/vgrangeslider/js/skins.js +222 -222
- package/app/modules/vgrangeslider/js/vgrangeslider.js +704 -704
- package/app/modules/vgrangeslider/scss/_variables.scss +55 -55
- package/app/modules/vgrangeslider/scss/vgrangeslider.scss +239 -239
- package/app/modules/vgrollup/scss/_variables.scss +15 -15
- package/app/modules/vgrollup/scss/vgrollup.scss +6 -6
- package/app/modules/vgselect/js/vgselect.js +129 -129
- package/app/modules/vgselect/readme.md +11 -11
- package/app/modules/vgselect/scss/_variables.scss +50 -50
- package/app/modules/vgselect/scss/vgselect.scss +48 -48
- package/app/modules/vgsidebar/js/vgsidebar.js +79 -79
- package/app/modules/vgsidebar/scss/_variables.scss +10 -10
- package/app/modules/vgsidebar/scss/vgsidebar.scss +5 -5
- package/app/modules/vgtabs/scss/_variables.scss +23 -23
- package/app/modules/vgtabs/scss/vgtabs.scss +5 -5
- package/app/modules/vgtoast/scss/_variables.scss +13 -13
- package/app/modules/vgtoast/scss/vgtoast.scss +5 -5
- package/app/modules/vgtooltip/js/vgtooltip.js +107 -51
- package/app/modules/vgtooltip/scss/_variables.scss +10 -10
- package/app/modules/vgtooltip/scss/vgtooltip.scss +5 -5
- package/app/utils/js/components/audio-metadata.js +240 -240
- package/app/utils/js/components/backdrop.js +116 -116
- package/app/utils/js/components/file-icon.js +109 -109
- package/app/utils/js/components/file-preview.js +304 -304
- package/app/utils/js/components/sanitize.js +150 -150
- package/app/utils/js/components/video-metadata.js +140 -140
- package/app/utils/scss/_backdrop.scss +5 -5
- package/app/utils/scss/_theme-default.scss +12 -12
- package/app/utils/scss/_theme.scss +7 -7
- package/app/utils/scss/_tokens.scss +170 -170
- package/app/utils/scss/default.scss +9 -9
- package/app/utils/scss/functions.scss +21 -21
- package/app/utils/scss/index.scss +4 -4
- package/app/utils/scss/mixin.scss +16 -16
- package/app/utils/scss/variables.scss +105 -105
- package/app/vgapp.js +295 -295
- package/build/vgapp.css +1 -1
- package/build/vgapp.css.map +1 -1
- package/build/vgapp.js +1 -1
- package/build/vgapp.js.map +1 -1
- package/index.scss +20 -20
- package/package.json +4 -2
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import { execute } from "../functions";
|
|
2
|
-
import Html from "../components/templater";
|
|
3
|
-
import { Classes } from "../dom/manipulator";
|
|
4
|
-
import ScrollBarHelper from "./scrollbar";
|
|
5
|
-
|
|
6
|
-
const NAME = 'backdrop';
|
|
7
|
-
const CLASS_NAME = 'vg-backdrop';
|
|
8
|
-
const CLASS_NAME_FADE = 'fade';
|
|
9
|
-
const CLASS_NAME_SHOW = 'show';
|
|
10
|
-
|
|
11
|
-
const backdropDelay = 150;
|
|
12
|
-
|
|
13
|
-
class Backdrop {
|
|
14
|
-
static get _rootEl() {
|
|
15
|
-
return document.body;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static _scrollbar = new ScrollBarHelper();
|
|
19
|
-
static _backdrop = null;
|
|
20
|
-
static _backdrops = [];
|
|
21
|
-
|
|
22
|
-
static getElement() {
|
|
23
|
-
this._syncBackdrops();
|
|
24
|
-
return this._backdrop;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static isActive() {
|
|
28
|
-
this._syncBackdrops();
|
|
29
|
-
return this._backdrops.length > 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Показывает новый backdrop и кладёт его поверх предыдущих.
|
|
34
|
-
* @param {Function} callback - Вызывается после добавления backdrop в DOM.
|
|
35
|
-
*/
|
|
36
|
-
static show(callback) {
|
|
37
|
-
const backdrop = this._append();
|
|
38
|
-
execute(callback, [backdrop]);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Скрывает только верхний backdrop.
|
|
43
|
-
* @param {Function} callback - Вызывается после скрытия.
|
|
44
|
-
*/
|
|
45
|
-
static hide(callback, backdrop = null) {
|
|
46
|
-
this._syncBackdrops();
|
|
47
|
-
|
|
48
|
-
const targetBackdrop = backdrop && backdrop.isConnected ? backdrop : this._backdrop;
|
|
49
|
-
|
|
50
|
-
if (!targetBackdrop) {
|
|
51
|
-
execute(callback);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this._destroy(targetBackdrop).then(execute.bind(null, callback));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Создаёт и добавляет backdrop.
|
|
60
|
-
* @returns {HTMLElement}
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
static _append() {
|
|
64
|
-
const html = Html('dom');
|
|
65
|
-
const backdrop = html.div({ class: CLASS_NAME });
|
|
66
|
-
|
|
67
|
-
this._rootEl.appendChild(backdrop);
|
|
68
|
-
this._backdrops.push(backdrop);
|
|
69
|
-
this._backdrop = backdrop;
|
|
70
|
-
|
|
71
|
-
requestAnimationFrame(() => {
|
|
72
|
-
Classes.add(backdrop, CLASS_NAME_SHOW);
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
if (backdrop.isConnected) {
|
|
75
|
-
Classes.add(backdrop, CLASS_NAME_FADE);
|
|
76
|
-
}
|
|
77
|
-
}, backdropDelay);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return backdrop;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Удаляет backdrop с анимацией.
|
|
85
|
-
* @param {HTMLElement} backdrop
|
|
86
|
-
* @returns {Promise}
|
|
87
|
-
* @private
|
|
88
|
-
*/
|
|
89
|
-
static _destroy(backdrop) {
|
|
90
|
-
return new Promise((resolve) => {
|
|
91
|
-
Classes.remove(backdrop, CLASS_NAME_FADE);
|
|
92
|
-
setTimeout(() => {
|
|
93
|
-
Classes.remove(backdrop, CLASS_NAME_SHOW);
|
|
94
|
-
backdrop.remove();
|
|
95
|
-
this._backdrops = this._backdrops.filter(item => item !== backdrop && item.isConnected);
|
|
96
|
-
this._backdrop = this._backdrops.length ? this._backdrops[this._backdrops.length - 1] : null;
|
|
97
|
-
|
|
98
|
-
if (!this._backdrop) {
|
|
99
|
-
this._scrollbar.reset();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
resolve();
|
|
103
|
-
}, backdropDelay);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
static _syncBackdrops() {
|
|
108
|
-
this._backdrops = this._backdrops.filter(item => item && item.isConnected);
|
|
109
|
-
if (!this._backdrops.length) {
|
|
110
|
-
this._backdrops = Array.from(this._rootEl.querySelectorAll(`.${CLASS_NAME}`));
|
|
111
|
-
}
|
|
112
|
-
this._backdrop = this._backdrops.length ? this._backdrops[this._backdrops.length - 1] : null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export default Backdrop;
|
|
1
|
+
import { execute } from "../functions";
|
|
2
|
+
import Html from "../components/templater";
|
|
3
|
+
import { Classes } from "../dom/manipulator";
|
|
4
|
+
import ScrollBarHelper from "./scrollbar";
|
|
5
|
+
|
|
6
|
+
const NAME = 'backdrop';
|
|
7
|
+
const CLASS_NAME = 'vg-backdrop';
|
|
8
|
+
const CLASS_NAME_FADE = 'fade';
|
|
9
|
+
const CLASS_NAME_SHOW = 'show';
|
|
10
|
+
|
|
11
|
+
const backdropDelay = 150;
|
|
12
|
+
|
|
13
|
+
class Backdrop {
|
|
14
|
+
static get _rootEl() {
|
|
15
|
+
return document.body;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static _scrollbar = new ScrollBarHelper();
|
|
19
|
+
static _backdrop = null;
|
|
20
|
+
static _backdrops = [];
|
|
21
|
+
|
|
22
|
+
static getElement() {
|
|
23
|
+
this._syncBackdrops();
|
|
24
|
+
return this._backdrop;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static isActive() {
|
|
28
|
+
this._syncBackdrops();
|
|
29
|
+
return this._backdrops.length > 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Показывает новый backdrop и кладёт его поверх предыдущих.
|
|
34
|
+
* @param {Function} callback - Вызывается после добавления backdrop в DOM.
|
|
35
|
+
*/
|
|
36
|
+
static show(callback) {
|
|
37
|
+
const backdrop = this._append();
|
|
38
|
+
execute(callback, [backdrop]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Скрывает только верхний backdrop.
|
|
43
|
+
* @param {Function} callback - Вызывается после скрытия.
|
|
44
|
+
*/
|
|
45
|
+
static hide(callback, backdrop = null) {
|
|
46
|
+
this._syncBackdrops();
|
|
47
|
+
|
|
48
|
+
const targetBackdrop = backdrop && backdrop.isConnected ? backdrop : this._backdrop;
|
|
49
|
+
|
|
50
|
+
if (!targetBackdrop) {
|
|
51
|
+
execute(callback);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this._destroy(targetBackdrop).then(execute.bind(null, callback));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Создаёт и добавляет backdrop.
|
|
60
|
+
* @returns {HTMLElement}
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
static _append() {
|
|
64
|
+
const html = Html('dom');
|
|
65
|
+
const backdrop = html.div({ class: CLASS_NAME });
|
|
66
|
+
|
|
67
|
+
this._rootEl.appendChild(backdrop);
|
|
68
|
+
this._backdrops.push(backdrop);
|
|
69
|
+
this._backdrop = backdrop;
|
|
70
|
+
|
|
71
|
+
requestAnimationFrame(() => {
|
|
72
|
+
Classes.add(backdrop, CLASS_NAME_SHOW);
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
if (backdrop.isConnected) {
|
|
75
|
+
Classes.add(backdrop, CLASS_NAME_FADE);
|
|
76
|
+
}
|
|
77
|
+
}, backdropDelay);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return backdrop;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Удаляет backdrop с анимацией.
|
|
85
|
+
* @param {HTMLElement} backdrop
|
|
86
|
+
* @returns {Promise}
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
static _destroy(backdrop) {
|
|
90
|
+
return new Promise((resolve) => {
|
|
91
|
+
Classes.remove(backdrop, CLASS_NAME_FADE);
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
Classes.remove(backdrop, CLASS_NAME_SHOW);
|
|
94
|
+
backdrop.remove();
|
|
95
|
+
this._backdrops = this._backdrops.filter(item => item !== backdrop && item.isConnected);
|
|
96
|
+
this._backdrop = this._backdrops.length ? this._backdrops[this._backdrops.length - 1] : null;
|
|
97
|
+
|
|
98
|
+
if (!this._backdrop) {
|
|
99
|
+
this._scrollbar.reset();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
resolve();
|
|
103
|
+
}, backdropDelay);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static _syncBackdrops() {
|
|
108
|
+
this._backdrops = this._backdrops.filter(item => item && item.isConnected);
|
|
109
|
+
if (!this._backdrops.length) {
|
|
110
|
+
this._backdrops = Array.from(this._rootEl.querySelectorAll(`.${CLASS_NAME}`));
|
|
111
|
+
}
|
|
112
|
+
this._backdrop = this._backdrops.length ? this._backdrops[this._backdrops.length - 1] : null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default Backdrop;
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
const FILE_ICON_BY_EXT = {
|
|
2
|
-
pdf: 'file-pdf',
|
|
3
|
-
doc: 'file-word',
|
|
4
|
-
docx: 'file-word',
|
|
5
|
-
odt: 'file-word',
|
|
6
|
-
rtf: 'file-word',
|
|
7
|
-
xls: 'file-exel',
|
|
8
|
-
xlsx: 'file-exel',
|
|
9
|
-
xlsm: 'file-exel',
|
|
10
|
-
ods: 'file-exel',
|
|
11
|
-
csv: 'file-exel',
|
|
12
|
-
zip: 'file-zip',
|
|
13
|
-
rar: 'file-zip',
|
|
14
|
-
'7z': 'file-zip',
|
|
15
|
-
tar: 'file-zip',
|
|
16
|
-
gz: 'file-zip',
|
|
17
|
-
tgz: 'file-zip',
|
|
18
|
-
txt: 'file-text',
|
|
19
|
-
md: 'file-text',
|
|
20
|
-
log: 'file-text',
|
|
21
|
-
json: 'file-text',
|
|
22
|
-
xml: 'file-text',
|
|
23
|
-
yml: 'file-text',
|
|
24
|
-
yaml: 'file-text',
|
|
25
|
-
php: 'file-php',
|
|
26
|
-
png: 'file-image',
|
|
27
|
-
jpg: 'file-image',
|
|
28
|
-
jpeg: 'file-image',
|
|
29
|
-
gif: 'file-image',
|
|
30
|
-
webp: 'file-image',
|
|
31
|
-
svg: 'file-image',
|
|
32
|
-
bmp: 'file-image',
|
|
33
|
-
tif: 'file-image',
|
|
34
|
-
tiff: 'file-image',
|
|
35
|
-
heic: 'file-image',
|
|
36
|
-
heif: 'file-image',
|
|
37
|
-
avif: 'file-image',
|
|
38
|
-
mp3: 'file-audio',
|
|
39
|
-
wav: 'file-audio',
|
|
40
|
-
ogg: 'file-audio',
|
|
41
|
-
flac: 'file-audio',
|
|
42
|
-
aac: 'file-audio',
|
|
43
|
-
m4a: 'file-audio',
|
|
44
|
-
mp4: 'file-video',
|
|
45
|
-
webm: 'file-video',
|
|
46
|
-
mov: 'file-video',
|
|
47
|
-
mkv: 'file-video',
|
|
48
|
-
avi: 'file-video'
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const extractExtension = (value) => {
|
|
52
|
-
if (!value) return '';
|
|
53
|
-
|
|
54
|
-
const cleanValue = String(value).toLowerCase().split('#')[0].split('?')[0];
|
|
55
|
-
const lastSegment = cleanValue.split('/').pop() || '';
|
|
56
|
-
if (!lastSegment.includes('.')) return '';
|
|
57
|
-
|
|
58
|
-
return lastSegment.split('.').pop() || '';
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const parseFileDescriptor = (value) => {
|
|
62
|
-
if (!value) return {type: '', ext: ''};
|
|
63
|
-
|
|
64
|
-
if (typeof value === 'object') {
|
|
65
|
-
const type = String(value.type || '').toLowerCase();
|
|
66
|
-
const name = String(value.name || value.path || value.url || '').toLowerCase();
|
|
67
|
-
return {type, ext: extractExtension(name)};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {type: '', ext: extractExtension(value)};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const resolveFileIconName = (descriptor) => {
|
|
74
|
-
const {type, ext} = parseFileDescriptor(descriptor);
|
|
75
|
-
|
|
76
|
-
if (type === 'application/pdf') return 'file-pdf';
|
|
77
|
-
if (type.includes('word')) return 'file-word';
|
|
78
|
-
if (type.includes('excel') || type.includes('spreadsheet')) return 'file-exel';
|
|
79
|
-
if (type.includes('zip') || type.includes('compressed')) return 'file-zip';
|
|
80
|
-
if (type.startsWith('text/')) return 'file-text';
|
|
81
|
-
if (type.startsWith('image/')) return 'file-image';
|
|
82
|
-
if (type.startsWith('audio/')) return 'file-audio';
|
|
83
|
-
if (type.startsWith('video/')) return 'file-video';
|
|
84
|
-
|
|
85
|
-
return FILE_ICON_BY_EXT[ext] || 'file-generic';
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const getSVG = (name, icons = {}) => {
|
|
89
|
-
const explicitIcon = icons[name];
|
|
90
|
-
if (explicitIcon) {
|
|
91
|
-
return explicitIcon;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const autoIconName = resolveFileIconName(name);
|
|
95
|
-
const autoIcon = icons[autoIconName];
|
|
96
|
-
if (autoIcon) {
|
|
97
|
-
return autoIcon;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return icons['file-generic'] || '';
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export {
|
|
104
|
-
FILE_ICON_BY_EXT,
|
|
105
|
-
extractExtension,
|
|
106
|
-
parseFileDescriptor,
|
|
107
|
-
resolveFileIconName,
|
|
108
|
-
getSVG
|
|
109
|
-
};
|
|
1
|
+
const FILE_ICON_BY_EXT = {
|
|
2
|
+
pdf: 'file-pdf',
|
|
3
|
+
doc: 'file-word',
|
|
4
|
+
docx: 'file-word',
|
|
5
|
+
odt: 'file-word',
|
|
6
|
+
rtf: 'file-word',
|
|
7
|
+
xls: 'file-exel',
|
|
8
|
+
xlsx: 'file-exel',
|
|
9
|
+
xlsm: 'file-exel',
|
|
10
|
+
ods: 'file-exel',
|
|
11
|
+
csv: 'file-exel',
|
|
12
|
+
zip: 'file-zip',
|
|
13
|
+
rar: 'file-zip',
|
|
14
|
+
'7z': 'file-zip',
|
|
15
|
+
tar: 'file-zip',
|
|
16
|
+
gz: 'file-zip',
|
|
17
|
+
tgz: 'file-zip',
|
|
18
|
+
txt: 'file-text',
|
|
19
|
+
md: 'file-text',
|
|
20
|
+
log: 'file-text',
|
|
21
|
+
json: 'file-text',
|
|
22
|
+
xml: 'file-text',
|
|
23
|
+
yml: 'file-text',
|
|
24
|
+
yaml: 'file-text',
|
|
25
|
+
php: 'file-php',
|
|
26
|
+
png: 'file-image',
|
|
27
|
+
jpg: 'file-image',
|
|
28
|
+
jpeg: 'file-image',
|
|
29
|
+
gif: 'file-image',
|
|
30
|
+
webp: 'file-image',
|
|
31
|
+
svg: 'file-image',
|
|
32
|
+
bmp: 'file-image',
|
|
33
|
+
tif: 'file-image',
|
|
34
|
+
tiff: 'file-image',
|
|
35
|
+
heic: 'file-image',
|
|
36
|
+
heif: 'file-image',
|
|
37
|
+
avif: 'file-image',
|
|
38
|
+
mp3: 'file-audio',
|
|
39
|
+
wav: 'file-audio',
|
|
40
|
+
ogg: 'file-audio',
|
|
41
|
+
flac: 'file-audio',
|
|
42
|
+
aac: 'file-audio',
|
|
43
|
+
m4a: 'file-audio',
|
|
44
|
+
mp4: 'file-video',
|
|
45
|
+
webm: 'file-video',
|
|
46
|
+
mov: 'file-video',
|
|
47
|
+
mkv: 'file-video',
|
|
48
|
+
avi: 'file-video'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const extractExtension = (value) => {
|
|
52
|
+
if (!value) return '';
|
|
53
|
+
|
|
54
|
+
const cleanValue = String(value).toLowerCase().split('#')[0].split('?')[0];
|
|
55
|
+
const lastSegment = cleanValue.split('/').pop() || '';
|
|
56
|
+
if (!lastSegment.includes('.')) return '';
|
|
57
|
+
|
|
58
|
+
return lastSegment.split('.').pop() || '';
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const parseFileDescriptor = (value) => {
|
|
62
|
+
if (!value) return {type: '', ext: ''};
|
|
63
|
+
|
|
64
|
+
if (typeof value === 'object') {
|
|
65
|
+
const type = String(value.type || '').toLowerCase();
|
|
66
|
+
const name = String(value.name || value.path || value.url || '').toLowerCase();
|
|
67
|
+
return {type, ext: extractExtension(name)};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {type: '', ext: extractExtension(value)};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const resolveFileIconName = (descriptor) => {
|
|
74
|
+
const {type, ext} = parseFileDescriptor(descriptor);
|
|
75
|
+
|
|
76
|
+
if (type === 'application/pdf') return 'file-pdf';
|
|
77
|
+
if (type.includes('word')) return 'file-word';
|
|
78
|
+
if (type.includes('excel') || type.includes('spreadsheet')) return 'file-exel';
|
|
79
|
+
if (type.includes('zip') || type.includes('compressed')) return 'file-zip';
|
|
80
|
+
if (type.startsWith('text/')) return 'file-text';
|
|
81
|
+
if (type.startsWith('image/')) return 'file-image';
|
|
82
|
+
if (type.startsWith('audio/')) return 'file-audio';
|
|
83
|
+
if (type.startsWith('video/')) return 'file-video';
|
|
84
|
+
|
|
85
|
+
return FILE_ICON_BY_EXT[ext] || 'file-generic';
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const getSVG = (name, icons = {}) => {
|
|
89
|
+
const explicitIcon = icons[name];
|
|
90
|
+
if (explicitIcon) {
|
|
91
|
+
return explicitIcon;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const autoIconName = resolveFileIconName(name);
|
|
95
|
+
const autoIcon = icons[autoIconName];
|
|
96
|
+
if (autoIcon) {
|
|
97
|
+
return autoIcon;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return icons['file-generic'] || '';
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
FILE_ICON_BY_EXT,
|
|
105
|
+
extractExtension,
|
|
106
|
+
parseFileDescriptor,
|
|
107
|
+
resolveFileIconName,
|
|
108
|
+
getSVG
|
|
109
|
+
};
|