@milaboratories/uikit 2.2.12 → 2.2.13
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/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import './pl-file-dialog.scss';
|
|
3
3
|
import { watch, reactive, computed, toRef, onUpdated } from 'vue';
|
|
4
|
-
import { debounce } from '@milaboratories/helpers';
|
|
5
4
|
import { between, notEmpty, tapIf } from '@milaboratories/helpers';
|
|
6
5
|
import type { Option } from '@milaboratories/helpers';
|
|
7
6
|
import type { StorageEntry, StorageHandle } from '@platforma-sdk/model';
|
|
@@ -14,12 +13,6 @@ import { PlBtnPrimary } from '../PlBtnPrimary';
|
|
|
14
13
|
import { PlBtnGhost } from '../PlBtnGhost';
|
|
15
14
|
import { useEventListener } from '@/composition/useEventListener';
|
|
16
15
|
|
|
17
|
-
// const vFocus = {
|
|
18
|
-
// mounted: (el: HTMLElement) => {
|
|
19
|
-
// (el.querySelector('button.pl-btn-primary') as HTMLButtonElement | null)?.focus();
|
|
20
|
-
// },
|
|
21
|
-
// };
|
|
22
|
-
|
|
23
16
|
const emit = defineEmits<{
|
|
24
17
|
(e: 'update:modelValue', value: boolean): void;
|
|
25
18
|
(e: 'import:files', value: ImportedFiles): void;
|
|
@@ -44,6 +37,7 @@ const props = withDefaults(
|
|
|
44
37
|
|
|
45
38
|
const defaultData = () => ({
|
|
46
39
|
dirPath: '' as string,
|
|
40
|
+
search: '',
|
|
47
41
|
storageEntry: undefined as StorageEntry | undefined,
|
|
48
42
|
items: [] as FileDialogItem[],
|
|
49
43
|
error: '',
|
|
@@ -56,12 +50,25 @@ const defaultData = () => ({
|
|
|
56
50
|
|
|
57
51
|
const data = reactive(defaultData());
|
|
58
52
|
|
|
53
|
+
const resetData = () => {
|
|
54
|
+
data.search = '';
|
|
55
|
+
data.error = '';
|
|
56
|
+
data.lastSelected = undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
59
|
const visibleItems = computed(() => {
|
|
60
|
+
let items = data.items;
|
|
61
|
+
|
|
60
62
|
if (!data.showHiddenItems) {
|
|
61
|
-
|
|
63
|
+
items = items.filter((it) => !it.name.startsWith('.'));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (data.search) {
|
|
67
|
+
const search = data.search.toLocaleLowerCase();
|
|
68
|
+
items = items.filter((it) => it.name.toLocaleLowerCase().includes(search));
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
return
|
|
71
|
+
return items;
|
|
65
72
|
});
|
|
66
73
|
|
|
67
74
|
const lookup = computed(() => {
|
|
@@ -81,10 +88,6 @@ const query = (handle: StorageHandle, dirPath: string) => {
|
|
|
81
88
|
return;
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
data.error = '';
|
|
85
|
-
data.items = [];
|
|
86
|
-
data.lastSelected = undefined;
|
|
87
|
-
|
|
88
91
|
data.currentLoadingPath = dirPath;
|
|
89
92
|
|
|
90
93
|
window.platforma.lsDriver
|
|
@@ -126,10 +129,6 @@ const load = () => {
|
|
|
126
129
|
}
|
|
127
130
|
};
|
|
128
131
|
|
|
129
|
-
const updateDirPathDebounced = debounce((v: string) => {
|
|
130
|
-
data.dirPath = v ?? ''; // ???
|
|
131
|
-
}, 1000);
|
|
132
|
-
|
|
133
132
|
const breadcrumbs = computed(() => getFilePathBreadcrumbs(data.dirPath));
|
|
134
133
|
|
|
135
134
|
const selectedFiles = computed(() => data.items.filter((f) => f.canBeSelected && f.selected && !f.isDir));
|
|
@@ -152,9 +151,6 @@ const submit = () => {
|
|
|
152
151
|
|
|
153
152
|
const setDirPath = (dirPath: string) => {
|
|
154
153
|
data.dirPath = dirPath;
|
|
155
|
-
if (data.storageEntry) {
|
|
156
|
-
load();
|
|
157
|
-
}
|
|
158
154
|
};
|
|
159
155
|
|
|
160
156
|
const selectFile = (ev: MouseEvent, file: FileDialogItem) => {
|
|
@@ -213,8 +209,7 @@ const selectAll = () => changeAll(true);
|
|
|
213
209
|
const deselectAll = () => changeAll(false);
|
|
214
210
|
|
|
215
211
|
const loadAvailableStorages = () => {
|
|
216
|
-
|
|
217
|
-
data.lastSelected = undefined;
|
|
212
|
+
resetData();
|
|
218
213
|
deselectAll();
|
|
219
214
|
if (!window.platforma) {
|
|
220
215
|
console.warn('platforma API is not found');
|
|
@@ -237,7 +232,6 @@ const loadAvailableStorages = () => {
|
|
|
237
232
|
), // local drive where home folder is stored, normally C:\
|
|
238
233
|
(entry) => {
|
|
239
234
|
data.storageEntry = entry;
|
|
240
|
-
data.dirPath = entry.initialFullPath;
|
|
241
235
|
},
|
|
242
236
|
);
|
|
243
237
|
}
|
|
@@ -245,9 +239,14 @@ const loadAvailableStorages = () => {
|
|
|
245
239
|
.catch((err) => (data.error = String(err)));
|
|
246
240
|
};
|
|
247
241
|
|
|
248
|
-
watch(
|
|
249
|
-
data
|
|
250
|
-
|
|
242
|
+
watch(
|
|
243
|
+
toRef(data, 'storageEntry'),
|
|
244
|
+
(entry) => {
|
|
245
|
+
resetData();
|
|
246
|
+
data.dirPath = entry?.initialFullPath ?? '';
|
|
247
|
+
},
|
|
248
|
+
{ immediate: true },
|
|
249
|
+
);
|
|
251
250
|
|
|
252
251
|
watch([() => data.dirPath, () => data.storageEntry], () => {
|
|
253
252
|
load();
|
|
@@ -316,7 +315,7 @@ const vTextOverflown = {
|
|
|
316
315
|
<div class="file-dialog">
|
|
317
316
|
<div class="file-dialog__search">
|
|
318
317
|
<PlDropdown v-model="data.storageEntry" label="Select storage" :options="data.storageOptions" />
|
|
319
|
-
<PlTextField
|
|
318
|
+
<PlTextField v-model="data.search" label="Search in folder" :clearable="() => ''" />
|
|
320
319
|
</div>
|
|
321
320
|
<div class="ls-container">
|
|
322
321
|
<div class="ls-head">
|
|
@@ -3,13 +3,20 @@ import type { ImportFileHandle } from '@platforma-sdk/model';
|
|
|
3
3
|
export function getFilePathBreadcrumbs(filePath: string) {
|
|
4
4
|
const chunks = filePath.split('/');
|
|
5
5
|
|
|
6
|
+
if (chunks[0] !== '') {
|
|
7
|
+
chunks.unshift('');
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
const stack: { index: number; path: string; name: string }[] = [];
|
|
7
11
|
|
|
8
12
|
for (let i = 0; i < chunks.length; i++) {
|
|
9
13
|
stack.push({
|
|
10
14
|
index: i,
|
|
11
15
|
name: i === 0 ? 'Root' : chunks[i],
|
|
12
|
-
path: chunks
|
|
16
|
+
path: chunks
|
|
17
|
+
.slice(0, i + 1)
|
|
18
|
+
.filter((c) => c !== '')
|
|
19
|
+
.join('/'),
|
|
13
20
|
});
|
|
14
21
|
}
|
|
15
22
|
|