@milaboratories/uikit 2.2.60 → 2.2.61
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/CHANGELOG.md +6 -0
- package/dist/pl-uikit.js +1633 -1620
- package/dist/pl-uikit.js.map +1 -1
- package/dist/pl-uikit.umd.cjs +6 -6
- package/dist/pl-uikit.umd.cjs.map +1 -1
- package/dist/src/components/PlFileDialog/utils.test.d.ts +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/PlFileDialog/utils.test.ts +51 -0
- package/src/components/PlFileDialog/utils.ts +27 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/uikit",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.61",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/pl-uikit.umd.js",
|
|
6
6
|
"module": "dist/pl-uikit.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@vueuse/core": "~12.4.0",
|
|
27
27
|
"jsdom": "^25.0.1",
|
|
28
28
|
"resize-observer-polyfill": "^1.5.1",
|
|
29
|
-
"@vitejs/plugin-vue": "^5.2.
|
|
29
|
+
"@vitejs/plugin-vue": "^5.2.3",
|
|
30
30
|
"tsc-alias": "^1.8.11",
|
|
31
31
|
"vitest": "^2.1.8",
|
|
32
32
|
"vite": "^5.4.11",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"yarpm": "^1.2.0",
|
|
35
35
|
"svgo": "^3.3.2",
|
|
36
36
|
"@types/d3": "^7.4.3",
|
|
37
|
-
"@milaboratories/eslint-config": "^1.0.1",
|
|
38
37
|
"@milaboratories/helpers": "^1.6.11",
|
|
39
|
-
"@platforma-sdk/model": "^1.
|
|
38
|
+
"@platforma-sdk/model": "^1.26.0",
|
|
39
|
+
"@milaboratories/eslint-config": "^1.0.4"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "vite",
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { getFilePathBreadcrumbs } from './utils';
|
|
3
|
+
|
|
4
|
+
describe('getFilePathBreadcrumbs', () => {
|
|
5
|
+
test.each([
|
|
6
|
+
{
|
|
7
|
+
name: 'root path "/"',
|
|
8
|
+
path: '/',
|
|
9
|
+
expected: [
|
|
10
|
+
{ index: 0, name: 'Root', path: '' },
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'empty path ""',
|
|
15
|
+
path: '',
|
|
16
|
+
expected: [
|
|
17
|
+
{ index: 0, name: 'Root', path: '' },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'single-level path "/folder"',
|
|
22
|
+
path: '/folder',
|
|
23
|
+
expected: [
|
|
24
|
+
{ index: 0, name: 'Root', path: '' },
|
|
25
|
+
{ index: 1, name: 'folder', path: '/folder' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'multi-level path "/folder/subfolder/file.txt"',
|
|
30
|
+
path: '/folder/subfolder/file.txt',
|
|
31
|
+
expected: [
|
|
32
|
+
{ index: 0, name: 'Root', path: '' },
|
|
33
|
+
{ index: 1, name: 'folder', path: '/folder' },
|
|
34
|
+
{ index: 2, name: 'subfolder', path: '/folder/subfolder' },
|
|
35
|
+
{ index: 3, name: 'file.txt', path: '/folder/subfolder/file.txt' },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'path without leading slash "folder/file.txt"',
|
|
40
|
+
path: 'folder/file.txt',
|
|
41
|
+
expected: [
|
|
42
|
+
{ index: 0, name: 'Root', path: '' },
|
|
43
|
+
{ index: 1, name: 'folder', path: 'folder' },
|
|
44
|
+
{ index: 2, name: 'file.txt', path: 'folder/file.txt' },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
])('should handle $name', ({ path, expected }) => {
|
|
48
|
+
const result = getFilePathBreadcrumbs(path);
|
|
49
|
+
expect(result).toEqual(expected);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -1,27 +1,42 @@
|
|
|
1
|
-
import { trimCharsLeft } from '@milaboratories/helpers';
|
|
1
|
+
import { trimChars, trimCharsLeft } from '@milaboratories/helpers';
|
|
2
2
|
import type { ImportFileHandle } from '@platforma-sdk/model';
|
|
3
3
|
|
|
4
4
|
export function normalizeExtensions(extensions: string[] | undefined) {
|
|
5
5
|
return extensions ? extensions.map((it) => '.' + trimCharsLeft(it, ['.'])) : undefined;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
// NOTE: works only with '/' separator on *nix systems.
|
|
8
9
|
export function getFilePathBreadcrumbs(filePath: string) {
|
|
9
|
-
|
|
10
|
+
// FIXME: separator probably should be got from ls driver from backend.
|
|
11
|
+
// or else this component won't work with remote storages on Windows.
|
|
12
|
+
const sep = '/';
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
// If file path starts with '/',
|
|
15
|
+
// the storage was set up with absolute paths,
|
|
16
|
+
// and we need to add the separator to the results.
|
|
17
|
+
const isAbsolute = filePath.startsWith(sep);
|
|
18
|
+
const chunks = trimChars(filePath, [sep]).split(sep);
|
|
19
|
+
|
|
20
|
+
const stack: { index: number; path: string; name: string }[] = [
|
|
21
|
+
{
|
|
22
|
+
index: 0,
|
|
23
|
+
name: 'Root',
|
|
24
|
+
path: '',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
if (chunks.length === 1 && chunks[0] === '') {
|
|
29
|
+
return stack;
|
|
30
|
+
}
|
|
16
31
|
|
|
17
32
|
for (let i = 0; i < chunks.length; i++) {
|
|
33
|
+
const pathPrefix = isAbsolute ? sep : '';
|
|
34
|
+
const p = pathPrefix + chunks.slice(0, i + 1).join(sep);
|
|
35
|
+
|
|
18
36
|
stack.push({
|
|
19
|
-
index: i,
|
|
20
|
-
name:
|
|
21
|
-
path:
|
|
22
|
-
.slice(0, i + 1)
|
|
23
|
-
.filter((c) => c !== '')
|
|
24
|
-
.join('/'),
|
|
37
|
+
index: i + 1,
|
|
38
|
+
name: chunks[i],
|
|
39
|
+
path: p,
|
|
25
40
|
});
|
|
26
41
|
}
|
|
27
42
|
|