@milaboratories/uikit 2.2.76 → 2.2.77
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 +2441 -2430
- package/dist/pl-uikit.js.map +1 -1
- package/dist/pl-uikit.umd.cjs +7 -6
- package/dist/pl-uikit.umd.cjs.map +1 -1
- package/dist/src/__tests__/use-debounce-fn.test.d.ts +2 -0
- package/dist/src/__tests__/use-debounce-fn.test.d.ts.map +1 -0
- package/dist/src/components/PlFileInput/PlFileInput.vue.d.ts +2 -2
- package/dist/src/components/PlFileInput/PlFileInput.vue.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/__tests__/use-debounce-fn.test.ts +27 -0
- package/src/components/PlFileInput/PlFileInput.vue +27 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/uikit",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.77",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/pl-uikit.umd.js",
|
|
6
6
|
"module": "dist/pl-uikit.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"svgo": "^3.3.2",
|
|
36
36
|
"@types/d3": "^7.4.3",
|
|
37
37
|
"@milaboratories/helpers": "^1.6.11",
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
38
|
+
"@platforma-sdk/model": "^1.32.1",
|
|
39
|
+
"@milaboratories/eslint-config": "^1.0.4"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "vite",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { useDebounceFn } from '@vueuse/core';
|
|
3
|
+
import { delay } from '@milaboratories/helpers';
|
|
4
|
+
|
|
5
|
+
test('useDebounceFn', async () => {
|
|
6
|
+
const s = {
|
|
7
|
+
r: 0,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const debouncedFn = useDebounceFn(async (i: number) => {
|
|
11
|
+
await delay(0);
|
|
12
|
+
console.log('fn', i);
|
|
13
|
+
s.r = i;
|
|
14
|
+
}, 20, { maxWait: 40 });
|
|
15
|
+
|
|
16
|
+
const t1 = performance.now();
|
|
17
|
+
for (let i = 0; i < 10; i++) {
|
|
18
|
+
await delay(10);
|
|
19
|
+
debouncedFn(i);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log('calls span', performance.now() - t1);
|
|
23
|
+
|
|
24
|
+
await delay(200);
|
|
25
|
+
console.log('s.r', s.r);
|
|
26
|
+
expect(s.r).toBe(9);
|
|
27
|
+
});
|
|
@@ -9,7 +9,7 @@ import type { ImportFileHandle, ImportProgress } from '@platforma-sdk/model';
|
|
|
9
9
|
import { getFileNameFromHandle, getFilePathFromHandle } from '@platforma-sdk/model';
|
|
10
10
|
import DoubleContour from '@/utils/DoubleContour.vue';
|
|
11
11
|
import { useLabelNotch } from '@/utils/useLabelNotch';
|
|
12
|
-
import { prettyBytes } from '@milaboratories/helpers';
|
|
12
|
+
import { prettyBytes, tryDo } from '@milaboratories/helpers';
|
|
13
13
|
|
|
14
14
|
const data = reactive({
|
|
15
15
|
fileDialogOpen: false,
|
|
@@ -55,7 +55,7 @@ const props = withDefaults(
|
|
|
55
55
|
/**
|
|
56
56
|
* An error message to display below the input field.
|
|
57
57
|
*/
|
|
58
|
-
error?:
|
|
58
|
+
error?: unknown;
|
|
59
59
|
/**
|
|
60
60
|
* A helper text to display below the input field when there are no errors.
|
|
61
61
|
*/
|
|
@@ -99,6 +99,10 @@ const tryValue = <T extends ImportFileHandle>(v: T | undefined, cb: (v: T) => st
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
const isErrorObject = (error: unknown): error is { message: string } => {
|
|
103
|
+
return typeof error === 'object' && error != null && 'message' in error && typeof error.message === 'string';
|
|
104
|
+
};
|
|
105
|
+
|
|
102
106
|
const fileName = computed(() => tryValue(props.modelValue, getFileNameFromHandle));
|
|
103
107
|
|
|
104
108
|
const filePath = computed(() => tryValue(props.modelValue, getFilePathFromHandle));
|
|
@@ -107,9 +111,28 @@ const isUploading = computed(() => props.progress && !props.progress.done);
|
|
|
107
111
|
|
|
108
112
|
const isUploaded = computed(() => props.progress && props.progress.done);
|
|
109
113
|
|
|
110
|
-
const computedError = computed(() =>
|
|
114
|
+
const computedError = computed(() => {
|
|
115
|
+
let message: undefined | string = undefined;
|
|
116
|
+
|
|
117
|
+
if (data.error.length > 0) {
|
|
118
|
+
message = data.error;
|
|
119
|
+
} else if (typeof props.error === 'string') {
|
|
120
|
+
message = props.error;
|
|
121
|
+
} else if (isErrorObject(props.error)) {
|
|
122
|
+
message = props.error.message;
|
|
123
|
+
} else if (props.error != null) {
|
|
124
|
+
const unknownString = tryDo(() => JSON.stringify(props.error, null, 4), () => String(props.error));
|
|
125
|
+
message = `Unknown error type:\n${unknownString}`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (typeof message === 'string' && message.length === 0) {
|
|
129
|
+
message = 'Empty error';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return message;
|
|
133
|
+
});
|
|
111
134
|
|
|
112
|
-
const hasErrors = computed(() =>
|
|
135
|
+
const hasErrors = computed(() => typeof computedError.value === 'string' && computedError.value.length > 0);
|
|
113
136
|
|
|
114
137
|
const uploadStats = computed(() => {
|
|
115
138
|
const { status, done } = props.progress ?? {};
|