@milaboratories/uikit 2.2.80 → 2.2.82
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 +12 -0
- package/dist/pl-uikit.js +4081 -4063
- package/dist/pl-uikit.js.map +1 -1
- package/dist/src/components/PlAutocomplete/PlAutocomplete.vue.d.ts +1 -1
- package/dist/src/components/PlAutocomplete/PlAutocomplete.vue.d.ts.map +1 -1
- package/dist/src/components/PlBtnGroup/PlBtnGroup.vue.d.ts +1 -1
- package/dist/src/components/PlBtnGroup/PlBtnGroup.vue.d.ts.map +1 -1
- package/dist/src/components/PlDropdown/PlDropdown.vue.d.ts +1 -1
- package/dist/src/components/PlDropdown/PlDropdown.vue.d.ts.map +1 -1
- package/dist/src/components/PlDropdownLegacy/PlDropdownLegacy.vue.d.ts +1 -1
- package/dist/src/components/PlDropdownLegacy/PlDropdownLegacy.vue.d.ts.map +1 -1
- package/dist/src/components/PlDropdownMulti/PlDropdownMulti.vue.d.ts +1 -1
- package/dist/src/components/PlDropdownMulti/PlDropdownMulti.vue.d.ts.map +1 -1
- package/dist/src/components/PlDropdownMultiRef/PlDropdownMultiRef.vue.d.ts +2 -2
- package/dist/src/components/PlDropdownMultiRef/PlDropdownMultiRef.vue.d.ts.map +1 -1
- package/dist/src/components/PlDropdownRef/PlDropdownRef.vue.d.ts +3 -3
- package/dist/src/components/PlDropdownRef/PlDropdownRef.vue.d.ts.map +1 -1
- package/dist/src/components/PlFileInput/PlFileInput.vue.d.ts.map +1 -1
- package/dist/src/components/PlProgressCell/PlProgressCell.vue.d.ts +1 -1
- package/dist/src/components/PlProgressCell/PlProgressCell.vue.d.ts.map +1 -1
- package/dist/src/components/PlProgressCell/types.d.ts +1 -1
- package/dist/src/components/PlProgressCell/types.d.ts.map +1 -1
- package/dist/src/components/PlTextArea/PlTextArea.vue.d.ts +2 -2
- package/dist/src/components/PlTextArea/PlTextArea.vue.d.ts.map +1 -1
- package/dist/src/components/PlTextField/PlTextField.vue.d.ts +1 -1
- package/dist/src/components/PlTextField/PlTextField.vue.d.ts.map +1 -1
- package/dist/src/components/Slider.vue.d.ts +2 -2
- package/dist/src/components/Slider.vue.d.ts.map +1 -1
- package/dist/src/components/SliderRange.vue.d.ts +2 -2
- package/dist/src/components/SliderRange.vue.d.ts.map +1 -1
- package/dist/src/components/SliderRangeTriple.vue.d.ts +2 -2
- package/dist/src/components/SliderRangeTriple.vue.d.ts.map +1 -1
- package/dist/src/helpers/error.d.ts +2 -0
- package/dist/src/helpers/error.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/__tests__/use-debounce-fn.test.ts +1 -1
- package/src/components/PlAutocomplete/PlAutocomplete.vue +3 -2
- package/src/components/PlBtnGroup/PlBtnGroup.vue +3 -2
- package/src/components/PlDropdown/PlDropdown.vue +3 -2
- package/src/components/PlDropdownLegacy/PlDropdownLegacy.vue +3 -2
- package/src/components/PlDropdownMulti/PlDropdownMulti.vue +3 -2
- package/src/components/PlDropdownMultiRef/PlDropdownMultiRef.vue +1 -1
- package/src/components/PlDropdownRef/PlDropdownRef.vue +1 -1
- package/src/components/PlFileInput/PlFileInput.vue +7 -27
- package/src/components/PlProgressCell/PlProgressCell.vue +3 -2
- package/src/components/PlProgressCell/types.ts +1 -1
- package/src/components/PlTextArea/PlTextArea.vue +8 -3
- package/src/components/PlTextField/PlTextField.vue +5 -3
- package/src/components/PlTooltip/PlTooltip.vue +2 -2
- package/src/components/Slider.vue +3 -2
- package/src/components/SliderRange.vue +3 -2
- package/src/components/SliderRangeTriple.vue +3 -2
- package/src/helpers/error.ts +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/uikit",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.82",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/pl-uikit.js",
|
|
6
6
|
"module": "dist/pl-uikit.js",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"yarpm": "^1.2.0",
|
|
32
32
|
"svgo": "^3.3.2",
|
|
33
33
|
"@types/d3": "^7.4.3",
|
|
34
|
+
"@platforma-sdk/model": "^1.33.10",
|
|
34
35
|
"@milaboratories/eslint-config": "^1.0.4",
|
|
35
|
-
"@milaboratories/helpers": "^1.6.12"
|
|
36
|
-
"@platforma-sdk/model": "^1.33.2"
|
|
36
|
+
"@milaboratories/helpers": "^1.6.12"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"dev": "vite",
|
|
@@ -24,6 +24,7 @@ import { PlMaskIcon24 } from '../PlMaskIcon24';
|
|
|
24
24
|
import { DropdownOverlay } from '@/utils/DropdownOverlay';
|
|
25
25
|
import { refDebounced } from '@vueuse/core';
|
|
26
26
|
import { useWatchFetch } from '@/composition/useWatchFetch.ts';
|
|
27
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* The current selected value.
|
|
@@ -55,7 +56,7 @@ const props = withDefaults(
|
|
|
55
56
|
/**
|
|
56
57
|
* Error message displayed below the dropdown (optional)
|
|
57
58
|
*/
|
|
58
|
-
error?:
|
|
59
|
+
error?: unknown;
|
|
59
60
|
/**
|
|
60
61
|
* Placeholder text shown when no value is selected.
|
|
61
62
|
*/
|
|
@@ -155,7 +156,7 @@ const computedError = computed(() => {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
if (props.error) {
|
|
158
|
-
return props.error;
|
|
159
|
+
return getErrorMessage(props.error);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
if (isLoadingError.value) {
|
|
@@ -13,6 +13,7 @@ import { computed, useSlots } from 'vue';
|
|
|
13
13
|
import { PlTooltip } from '@/components/PlTooltip';
|
|
14
14
|
import InnerBorder from '@/utils/InnerBorder.vue';
|
|
15
15
|
import type { SimpleOption } from '@/types';
|
|
16
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
16
17
|
|
|
17
18
|
const slots = useSlots();
|
|
18
19
|
|
|
@@ -53,7 +54,7 @@ const props = defineProps<{
|
|
|
53
54
|
/**
|
|
54
55
|
* Error message displayed below the component (optional)
|
|
55
56
|
*/
|
|
56
|
-
error?:
|
|
57
|
+
error?: unknown;
|
|
57
58
|
}>();
|
|
58
59
|
|
|
59
60
|
const normalizedOptions = computed(() =>
|
|
@@ -88,6 +89,6 @@ const normalizedOptions = computed(() =>
|
|
|
88
89
|
</div>
|
|
89
90
|
</InnerBorder>
|
|
90
91
|
<div v-if="helper" class="pl-btn-group__helper">{{ helper }}</div>
|
|
91
|
-
<div v-else-if="error" class="pl-btn-group__error">{{ error }}</div>
|
|
92
|
+
<div v-else-if="error" class="pl-btn-group__error">{{ getErrorMessage(error) }}</div>
|
|
92
93
|
</div>
|
|
93
94
|
</template>
|
|
@@ -22,6 +22,7 @@ import { normalizeListOptions } from '@/helpers/utils';
|
|
|
22
22
|
import { PlIcon16 } from '../PlIcon16';
|
|
23
23
|
import { PlMaskIcon24 } from '../PlMaskIcon24';
|
|
24
24
|
import { DropdownOverlay } from '@/utils/DropdownOverlay';
|
|
25
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
25
26
|
|
|
26
27
|
const emit = defineEmits<{
|
|
27
28
|
/**
|
|
@@ -55,7 +56,7 @@ const props = withDefaults(
|
|
|
55
56
|
/**
|
|
56
57
|
* Error message displayed below the dropdown (optional)
|
|
57
58
|
*/
|
|
58
|
-
error?:
|
|
59
|
+
error?: unknown;
|
|
59
60
|
/**
|
|
60
61
|
* Placeholder text shown when no value is selected.
|
|
61
62
|
*/
|
|
@@ -145,7 +146,7 @@ const computedError = computed(() => {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
if (props.error) {
|
|
148
|
-
return props.error;
|
|
149
|
+
return getErrorMessage(props.error);
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
if (props.modelValue !== undefined && selectedIndex.value === -1) {
|
|
@@ -22,6 +22,7 @@ import LongText from '@/components/LongText.vue';
|
|
|
22
22
|
import { PlIcon16 } from '../PlIcon16';
|
|
23
23
|
import { PlMaskIcon24 } from '../PlMaskIcon24';
|
|
24
24
|
import { normalizeListOptions } from '@/helpers/utils';
|
|
25
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
25
26
|
|
|
26
27
|
const emit = defineEmits<{
|
|
27
28
|
/**
|
|
@@ -55,7 +56,7 @@ const props = withDefaults(
|
|
|
55
56
|
/**
|
|
56
57
|
* Error message displayed below the dropdown (optional)
|
|
57
58
|
*/
|
|
58
|
-
error?:
|
|
59
|
+
error?: unknown;
|
|
59
60
|
/**
|
|
60
61
|
* Placeholder text shown when no value is selected.
|
|
61
62
|
*/
|
|
@@ -143,7 +144,7 @@ const computedError = computed(() => {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
if (props.error) {
|
|
146
|
-
return props.error;
|
|
147
|
+
return getErrorMessage(props.error);
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
if (props.modelValue !== undefined && selectedIndex.value === -1) {
|
|
@@ -21,6 +21,7 @@ import { deepEqual, deepIncludes } from '@/helpers/objects';
|
|
|
21
21
|
import { normalizeListOptions } from '@/helpers/utils';
|
|
22
22
|
import DropdownOverlay from '@/utils/DropdownOverlay/DropdownOverlay.vue';
|
|
23
23
|
import { PlMaskIcon24 } from '../PlMaskIcon24';
|
|
24
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
24
25
|
|
|
25
26
|
const emit = defineEmits<{
|
|
26
27
|
(e: 'update:modelValue', v: M[]): void;
|
|
@@ -51,7 +52,7 @@ const props = withDefaults(
|
|
|
51
52
|
/**
|
|
52
53
|
* Error message displayed below the dropdown (optional)
|
|
53
54
|
*/
|
|
54
|
-
error?:
|
|
55
|
+
error?: unknown;
|
|
55
56
|
/**
|
|
56
57
|
* Placeholder text shown when no value is selected.
|
|
57
58
|
*/
|
|
@@ -312,7 +313,7 @@ watchPostEffect(() => {
|
|
|
312
313
|
<DoubleContour class="pl-dropdown-multi__contour" />
|
|
313
314
|
</div>
|
|
314
315
|
</div>
|
|
315
|
-
<div v-if="error" class="pl-dropdown-multi__error">{{ error }}</div>
|
|
316
|
+
<div v-if="error" class="pl-dropdown-multi__error">{{ getErrorMessage(error) }}</div>
|
|
316
317
|
<div v-else-if="helper" class="pl-dropdown-multi__helper">{{ helper }}</div>
|
|
317
318
|
</div>
|
|
318
319
|
</template>
|
|
@@ -9,11 +9,12 @@ 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 {
|
|
12
|
+
import { prettyBytes } from '@milaboratories/helpers';
|
|
13
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
13
14
|
|
|
14
15
|
const data = reactive({
|
|
15
16
|
fileDialogOpen: false,
|
|
16
|
-
error:
|
|
17
|
+
error: undefined as undefined | string,
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
const slots = useSlots();
|
|
@@ -107,28 +108,9 @@ const isUploading = computed(() => props.progress && !props.progress.done);
|
|
|
107
108
|
|
|
108
109
|
const isUploaded = computed(() => props.progress && props.progress.done);
|
|
109
110
|
|
|
110
|
-
const
|
|
111
|
-
let message: undefined | string = undefined;
|
|
112
|
-
|
|
113
|
-
if (data.error.length > 0) {
|
|
114
|
-
message = data.error;
|
|
115
|
-
} else if (typeof props.error === 'string') {
|
|
116
|
-
message = props.error;
|
|
117
|
-
} else if (isErrorLike(props.error)) {
|
|
118
|
-
message = props.error.message;
|
|
119
|
-
} else if (props.error != null) {
|
|
120
|
-
const unknownString = tryDo(() => JSON.stringify(props.error, null, 4), () => String(props.error));
|
|
121
|
-
message = `Unknown error type:\n${unknownString}`;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (typeof message === 'string' && message.length === 0) {
|
|
125
|
-
message = 'Empty error';
|
|
126
|
-
}
|
|
111
|
+
const computedErrorMessage = computed(() => getErrorMessage(data.error, props.error));
|
|
127
112
|
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
const hasErrors = computed(() => typeof computedError.value === 'string' && computedError.value.length > 0);
|
|
113
|
+
const hasErrors = computed(() => typeof computedErrorMessage.value === 'string');
|
|
132
114
|
|
|
133
115
|
const uploadStats = computed(() => {
|
|
134
116
|
const { status, done } = props.progress ?? {};
|
|
@@ -170,9 +152,7 @@ const clear = () => emit('update:modelValue', undefined);
|
|
|
170
152
|
|
|
171
153
|
watch(
|
|
172
154
|
() => props.modelValue,
|
|
173
|
-
() =>
|
|
174
|
-
data.error = '';
|
|
175
|
-
},
|
|
155
|
+
() => (data.error = undefined),
|
|
176
156
|
{ immediate: true },
|
|
177
157
|
);
|
|
178
158
|
|
|
@@ -216,7 +196,7 @@ if (!props.cellStyle) {
|
|
|
216
196
|
<DoubleContour class="pl-file-input__contour" />
|
|
217
197
|
</div>
|
|
218
198
|
<div v-if="hasErrors" class="pl-file-input__error">
|
|
219
|
-
{{
|
|
199
|
+
{{ computedErrorMessage }}
|
|
220
200
|
</div>
|
|
221
201
|
<div v-else-if="helper" class="pl-file-input__helper">{{ helper }}</div>
|
|
222
202
|
</div>
|
|
@@ -3,13 +3,14 @@ import { computed } from 'vue';
|
|
|
3
3
|
import './pl-progress-cell.scss';
|
|
4
4
|
import PlMaskIcon24 from '../PlMaskIcon24/PlMaskIcon24.vue';
|
|
5
5
|
import type { PlProgressCellProps } from './types';
|
|
6
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
6
7
|
|
|
7
8
|
const props = withDefaults(defineProps<PlProgressCellProps>(), {
|
|
8
9
|
stage: 'not_started',
|
|
9
10
|
step: '', // main text (left)
|
|
10
11
|
progressString: '', // appended text on the right side (right)
|
|
11
12
|
progress: undefined,
|
|
12
|
-
error:
|
|
13
|
+
error: undefined,
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
const canShowWhiteBg = computed(() => props.stage !== 'not_started');
|
|
@@ -27,7 +28,7 @@ const canShowInfinityLoader = computed(() => props.progress === undefined && pro
|
|
|
27
28
|
<div v-if="!canShowInfinityLoader && !error" class="progress-cell__indicator" :style="{ width: currentProgress + '%' }"/>
|
|
28
29
|
<div class="progress-cell__body">
|
|
29
30
|
<div class="progress-cell__stage text-s">
|
|
30
|
-
{{ error ? error : step }}
|
|
31
|
+
{{ error ? getErrorMessage(error) : step }}
|
|
31
32
|
</div>
|
|
32
33
|
<div class="progress-cell__percentage text-s d-flex align-center justify-end">
|
|
33
34
|
<PlMaskIcon24 v-if="error" name="error" />
|
|
@@ -3,5 +3,5 @@ export type PlProgressCellProps = {
|
|
|
3
3
|
step?: string; // "Alignment" / "Queued" (main left text)
|
|
4
4
|
progressString?: string; // "20%" or "2 / 4" (right text)
|
|
5
5
|
progress?: number; // Percent value! (from 0 to 100) i.e. 20 for 20%; 'undefined' for unknown progress = animated progressbar
|
|
6
|
-
error?:
|
|
6
|
+
error?: unknown;
|
|
7
7
|
};
|
|
@@ -12,6 +12,7 @@ import { PlTooltip } from '@/components/PlTooltip';
|
|
|
12
12
|
import DoubleContour from '@/utils/DoubleContour.vue';
|
|
13
13
|
import { useLabelNotch } from '@/utils/useLabelNotch';
|
|
14
14
|
import { useValidation } from '@/utils/useValidation';
|
|
15
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
15
16
|
|
|
16
17
|
const slots = useSlots();
|
|
17
18
|
|
|
@@ -38,7 +39,7 @@ const props = defineProps<{
|
|
|
38
39
|
/**
|
|
39
40
|
* An error message to display below the textarea.
|
|
40
41
|
*/
|
|
41
|
-
error?:
|
|
42
|
+
error?: unknown;
|
|
42
43
|
/**
|
|
43
44
|
* A helper text to display below the textarea when there are no errors.
|
|
44
45
|
*/
|
|
@@ -92,10 +93,14 @@ useLabelNotch(root);
|
|
|
92
93
|
|
|
93
94
|
const displayErrors = computed(() => {
|
|
94
95
|
const errors: string[] = [];
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
const propsError = getErrorMessage(props.error);
|
|
97
|
+
|
|
98
|
+
if (propsError) {
|
|
99
|
+
errors.push(propsError);
|
|
97
100
|
}
|
|
101
|
+
|
|
98
102
|
errors.push(...validationData.value.errors);
|
|
103
|
+
|
|
99
104
|
return errors;
|
|
100
105
|
});
|
|
101
106
|
|
|
@@ -17,6 +17,7 @@ import { useValidation } from '@/utils/useValidation';
|
|
|
17
17
|
import { PlIcon16 } from '../PlIcon16';
|
|
18
18
|
import { PlMaskIcon24 } from '../PlMaskIcon24';
|
|
19
19
|
import type { Equal } from '@milaboratories/helpers';
|
|
20
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
20
21
|
|
|
21
22
|
const slots = useSlots();
|
|
22
23
|
|
|
@@ -51,7 +52,7 @@ const props = defineProps<{
|
|
|
51
52
|
/**
|
|
52
53
|
* An error message to display below the input field.
|
|
53
54
|
*/
|
|
54
|
-
error?:
|
|
55
|
+
error?: unknown;
|
|
55
56
|
/**
|
|
56
57
|
* A helper text to display below the input field when there are no errors.
|
|
57
58
|
*/
|
|
@@ -148,8 +149,9 @@ const nonEmpty = computed(() => !isEmpty.value);
|
|
|
148
149
|
|
|
149
150
|
const displayErrors = computed(() => {
|
|
150
151
|
const errors: string[] = [];
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
const propsError = getErrorMessage(props.error);
|
|
153
|
+
if (propsError) {
|
|
154
|
+
errors.push(propsError);
|
|
153
155
|
}
|
|
154
156
|
if (data.cached) {
|
|
155
157
|
errors.push(data.cached.error);
|
|
@@ -108,7 +108,7 @@ const onOver = async () => {
|
|
|
108
108
|
|
|
109
109
|
clearTimeout();
|
|
110
110
|
|
|
111
|
-
await utils.delay(100);
|
|
111
|
+
await utils.delay(props.openDelay ?? 100);
|
|
112
112
|
|
|
113
113
|
if (data.over) {
|
|
114
114
|
showTooltip();
|
|
@@ -154,7 +154,7 @@ onUnmounted(() => {
|
|
|
154
154
|
<slot />
|
|
155
155
|
<Teleport v-if="$slots['tooltip'] && data.open" to="body">
|
|
156
156
|
<Transition name="tooltip-transition">
|
|
157
|
-
<div v-if="data.tooltipOpen" class="pl-tooltip__container" :style="style">
|
|
157
|
+
<div v-if="data.tooltipOpen" class="pl-tooltip__container" :style="style" @click.stop>
|
|
158
158
|
<div ref="tooltip" class="pl-tooltip" :style="tooltipStyle" :class="position" @mouseover="onOver" @mouseleave="onLeave">
|
|
159
159
|
<!-- should be one line -->
|
|
160
160
|
<div><slot name="tooltip" /></div>
|
|
@@ -6,6 +6,7 @@ import { clamp } from '@/helpers/math';
|
|
|
6
6
|
import { PlTooltip } from '@/components/PlTooltip';
|
|
7
7
|
import type { SliderMode } from '@/types';
|
|
8
8
|
import { useSliderBreakpoints } from '@/composition/useSliderBreakpoints';
|
|
9
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
9
10
|
|
|
10
11
|
const slots = useSlots();
|
|
11
12
|
|
|
@@ -19,7 +20,7 @@ const props = withDefaults(
|
|
|
19
20
|
step?: number;
|
|
20
21
|
label?: string;
|
|
21
22
|
helper?: string;
|
|
22
|
-
error?:
|
|
23
|
+
error?: unknown;
|
|
23
24
|
mode?: SliderMode;
|
|
24
25
|
measure?: string;
|
|
25
26
|
breakpoints?: boolean;
|
|
@@ -65,7 +66,7 @@ const error = computed(() => {
|
|
|
65
66
|
return `Max value: ${props.max}`;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
return props.error;
|
|
69
|
+
return getErrorMessage(props.error);
|
|
69
70
|
});
|
|
70
71
|
|
|
71
72
|
const propsRef = computed(() => props);
|
|
@@ -7,6 +7,7 @@ import { PlTooltip } from '@/components/PlTooltip';
|
|
|
7
7
|
import type { SliderMode } from '@/types';
|
|
8
8
|
import InputRange from '@/components/InputRange.vue';
|
|
9
9
|
import { useSliderBreakpoints } from '@/composition/useSliderBreakpoints';
|
|
10
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
10
11
|
|
|
11
12
|
const slots = useSlots();
|
|
12
13
|
|
|
@@ -20,7 +21,7 @@ const props = withDefaults(
|
|
|
20
21
|
step?: number;
|
|
21
22
|
label?: string;
|
|
22
23
|
helper?: string;
|
|
23
|
-
error?:
|
|
24
|
+
error?: unknown;
|
|
24
25
|
mode?: SliderMode;
|
|
25
26
|
measure?: string;
|
|
26
27
|
breakpoints?: boolean;
|
|
@@ -74,7 +75,7 @@ const error = computed(() => {
|
|
|
74
75
|
return 'Expected model [number, number]';
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
return props.error;
|
|
78
|
+
return getErrorMessage(props.error);
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
const position1 = computed(() => {
|
|
@@ -6,6 +6,7 @@ import { clamp } from '@/helpers/math';
|
|
|
6
6
|
import { PlTooltip } from '@/components/PlTooltip';
|
|
7
7
|
import type { SliderMode } from '@/types';
|
|
8
8
|
import { useSliderBreakpoints } from '@/composition/useSliderBreakpoints';
|
|
9
|
+
import { getErrorMessage } from '@/helpers/error.ts';
|
|
9
10
|
|
|
10
11
|
type ModelType = [number, number, number];
|
|
11
12
|
const slots = useSlots();
|
|
@@ -20,7 +21,7 @@ const props = withDefaults(
|
|
|
20
21
|
step?: number;
|
|
21
22
|
label?: string;
|
|
22
23
|
helper?: string;
|
|
23
|
-
error?:
|
|
24
|
+
error?: unknown;
|
|
24
25
|
mode?: SliderMode;
|
|
25
26
|
measure?: string;
|
|
26
27
|
breakpoints?: boolean;
|
|
@@ -84,7 +85,7 @@ const error = computed(() => {
|
|
|
84
85
|
return errors.join(' ');
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
return props.error;
|
|
88
|
+
return getErrorMessage(props.error);
|
|
88
89
|
});
|
|
89
90
|
|
|
90
91
|
const position1 = computed(() => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isErrorLike, tryDo } from '@milaboratories/helpers';
|
|
2
|
+
|
|
3
|
+
// order of errors is important, we will show first
|
|
4
|
+
export function getErrorMessage(...errors: unknown[]): undefined | string {
|
|
5
|
+
for (let i = 0; i < errors.length; i++) {
|
|
6
|
+
const error = errors[i];
|
|
7
|
+
const message = extractMessage(error);
|
|
8
|
+
if (message !== undefined) return message;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function extractMessage(error: unknown): undefined | string {
|
|
13
|
+
if (typeof error === 'string') {
|
|
14
|
+
return error;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (isErrorLike(error) && error.message.length > 0) {
|
|
18
|
+
return error.message;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (error != null) {
|
|
22
|
+
const unknownString = tryDo(() => JSON.stringify(error, null, 4), () => String(error));
|
|
23
|
+
return `Unknown error message:\n${unknownString}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|