@streamscloud/kit 0.82.4 → 0.83.1
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/dist/core/files/file-validation-localization.d.ts +2 -2
- package/dist/core/files/file-validation-localization.js +4 -4
- package/dist/core/files/file-validation-rules.d.ts +9 -9
- package/dist/core/files/file-validation-rules.js +20 -8
- package/dist/ui/tooltip/cmp.tooltip.svelte +4 -3
- package/package.json +1 -1
|
@@ -5,8 +5,8 @@ export declare class FileValidationLocalization {
|
|
|
5
5
|
get audioOnly(): string;
|
|
6
6
|
get maxSize(): (size: string) => string;
|
|
7
7
|
get extensions(): (list: string) => string;
|
|
8
|
-
get maxDimensions(): (
|
|
9
|
-
get minDimensions(): (
|
|
8
|
+
get maxDimensions(): (longSide: number, shortSide: number) => string;
|
|
9
|
+
get minDimensions(): (longSide: number, shortSide: number) => string;
|
|
10
10
|
get maxDuration(): (seconds: number) => string;
|
|
11
11
|
get aspectRatio(): (ratios: string) => string;
|
|
12
12
|
get aspectRatioRange(): (min: string, max: string) => string;
|
|
@@ -63,12 +63,12 @@ const loc = {
|
|
|
63
63
|
no: (list) => `Tillatte filtyper: ${list}`
|
|
64
64
|
},
|
|
65
65
|
maxDimensions: {
|
|
66
|
-
en: (
|
|
67
|
-
no: (
|
|
66
|
+
en: (longSide, shortSide) => `Maximum dimensions: ${longSide}×${shortSide}px, either orientation`,
|
|
67
|
+
no: (longSide, shortSide) => `Maks oppløsning: ${longSide}×${shortSide}px, liggende eller stående`
|
|
68
68
|
},
|
|
69
69
|
minDimensions: {
|
|
70
|
-
en: (
|
|
71
|
-
no: (
|
|
70
|
+
en: (longSide, shortSide) => `Minimum dimensions: ${longSide}×${shortSide}px, either orientation`,
|
|
71
|
+
no: (longSide, shortSide) => `Min oppløsning: ${longSide}×${shortSide}px, liggende eller stående`
|
|
72
72
|
},
|
|
73
73
|
maxDuration: {
|
|
74
74
|
en: (seconds) => `Maximum duration: ${seconds}s`,
|
|
@@ -21,13 +21,13 @@ export declare const FileRules: {
|
|
|
21
21
|
AudioDuration: (maxSeconds: number, message?: string) => FileValidationRule;
|
|
22
22
|
AudioOnly: (message?: string) => FileValidationRule;
|
|
23
23
|
Extensions: (extensions: string[], message?: string) => FileValidationRule;
|
|
24
|
-
ImageDimensions: (
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
ImageDimensions: (limits: {
|
|
25
|
+
max1: number;
|
|
26
|
+
max2: number;
|
|
27
27
|
}, message?: string) => FileValidationRule;
|
|
28
|
-
ImageMinDimensions: (
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
ImageMinDimensions: (limits: {
|
|
29
|
+
min1: number;
|
|
30
|
+
min2: number;
|
|
31
31
|
}, message?: string) => FileValidationRule;
|
|
32
32
|
MaxSize: (bytes: number, message?: string) => FileValidationRule;
|
|
33
33
|
Mime: (accept: string, message?: string) => FileValidationRule;
|
|
@@ -43,9 +43,9 @@ export declare const FileRules: {
|
|
|
43
43
|
max?: AspectRatioBound;
|
|
44
44
|
}, message?: string, tolerancePercent?: number) => FileValidationRule;
|
|
45
45
|
VideoOrientation: (orientation: VideoOrientationValue, message?: string, tolerancePercent?: number) => FileValidationRule;
|
|
46
|
-
VideoDimensions: (
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
VideoDimensions: (limits: {
|
|
47
|
+
max1: number;
|
|
48
|
+
max2: number;
|
|
49
49
|
}, message?: string) => FileValidationRule;
|
|
50
50
|
VideoDuration: (maxSeconds: number, message?: string) => FileValidationRule;
|
|
51
51
|
};
|
|
@@ -55,6 +55,16 @@ const resolveBound = (value) => {
|
|
|
55
55
|
return Number.isFinite(ratio) ? ratio : null;
|
|
56
56
|
};
|
|
57
57
|
const formatBound = (value) => (value === undefined ? '' : typeof value === 'number' ? String(value) : value);
|
|
58
|
+
const toSides = (a, b) => ({ long: Math.max(a, b), short: Math.min(a, b) });
|
|
59
|
+
const exceedsMax = (size, limits) => {
|
|
60
|
+
const actual = toSides(size.width, size.height);
|
|
61
|
+
const limit = toSides(limits.max1, limits.max2);
|
|
62
|
+
return actual.long > limit.long || actual.short > limit.short;
|
|
63
|
+
};
|
|
64
|
+
const maxDimensionsMessage = (limits) => {
|
|
65
|
+
const limit = toSides(limits.max1, limits.max2);
|
|
66
|
+
return messages.maxDimensions(limit.long, limit.short);
|
|
67
|
+
};
|
|
58
68
|
const formatExtensions = (extensions) => extensions.map((ext) => '.' + ext.replace(/^\./, '')).join(', ');
|
|
59
69
|
const messages = new FileValidationLocalization();
|
|
60
70
|
/**
|
|
@@ -96,13 +106,15 @@ export const FileRules = {
|
|
|
96
106
|
const allowed = extensions.map((ext) => ext.replace(/^\./, '').toLowerCase());
|
|
97
107
|
return allowed.includes(extension) ? null : (message ?? messages.extensions(formatExtensions(extensions)));
|
|
98
108
|
},
|
|
99
|
-
ImageDimensions: (
|
|
100
|
-
const
|
|
101
|
-
return
|
|
109
|
+
ImageDimensions: (limits, message) => async (file) => {
|
|
110
|
+
const size = await readImageDimensions(file);
|
|
111
|
+
return exceedsMax(size, limits) ? (message ?? maxDimensionsMessage(limits)) : null;
|
|
102
112
|
},
|
|
103
|
-
ImageMinDimensions: (
|
|
113
|
+
ImageMinDimensions: (limits, message) => async (file) => {
|
|
104
114
|
const { width, height } = await readImageDimensions(file);
|
|
105
|
-
|
|
115
|
+
const actual = toSides(width, height);
|
|
116
|
+
const limit = toSides(limits.min1, limits.min2);
|
|
117
|
+
return actual.long < limit.long || actual.short < limit.short ? (message ?? messages.minDimensions(limit.long, limit.short)) : null;
|
|
106
118
|
},
|
|
107
119
|
MaxSize: (bytes, message) => (file) => file.size > bytes ? (message ?? messages.maxSize(StringHelper.toFileSizeString(bytes))) : null,
|
|
108
120
|
Mime: (accept, message) => {
|
|
@@ -151,9 +163,9 @@ export const FileRules = {
|
|
|
151
163
|
const ok = orientation === 'landscape' ? actual > 1 + margin : orientation === 'portrait' ? actual < 1 - margin : Math.abs(actual - 1) <= margin;
|
|
152
164
|
return ok ? null : (message ?? messages.orientation(orientation));
|
|
153
165
|
},
|
|
154
|
-
VideoDimensions: (
|
|
155
|
-
const
|
|
156
|
-
return
|
|
166
|
+
VideoDimensions: (limits, message) => async (file) => {
|
|
167
|
+
const size = await readMedia(file);
|
|
168
|
+
return exceedsMax(size, limits) ? (message ?? maxDimensionsMessage(limits)) : null;
|
|
157
169
|
},
|
|
158
170
|
VideoDuration: (maxSeconds, message) => async (file) => {
|
|
159
171
|
const durationSec = await readDuration(file);
|
|
@@ -19,7 +19,7 @@ const position = async () => {
|
|
|
19
19
|
if (arrowEl) {
|
|
20
20
|
middleware.push(arrowMiddleware({ element: arrowEl }));
|
|
21
21
|
}
|
|
22
|
-
const result = await computePosition(triggerEl, bubbleEl, { placement, middleware });
|
|
22
|
+
const result = await computePosition(triggerEl, bubbleEl, { placement, middleware, strategy: 'fixed' });
|
|
23
23
|
Object.assign(bubbleEl.style, {
|
|
24
24
|
left: `${result.x}px`,
|
|
25
25
|
top: `${result.y}px`
|
|
@@ -72,8 +72,8 @@ $effect(() => () => {
|
|
|
72
72
|
onfocusout={hide}
|
|
73
73
|
role="presentation">
|
|
74
74
|
{@render children({ 'aria-describedby': descriptionId })}
|
|
75
|
+
<span id={descriptionId} class="tooltip__description" aria-hidden="true">{text}</span>
|
|
75
76
|
</span>
|
|
76
|
-
<span id={descriptionId} class="tooltip__description" aria-hidden="true">{text}</span>
|
|
77
77
|
|
|
78
78
|
{#if visible}
|
|
79
79
|
<span bind:this={bubbleEl} class="tooltip__bubble" role="tooltip" aria-hidden="true" data-placement={resolvedPlacement}>
|
|
@@ -105,6 +105,7 @@ or plain text. Bubble flips and shifts on viewport collision; an arrow points to
|
|
|
105
105
|
-->
|
|
106
106
|
|
|
107
107
|
<style>.tooltip {
|
|
108
|
+
position: relative;
|
|
108
109
|
display: inline-flex;
|
|
109
110
|
align-items: center;
|
|
110
111
|
}
|
|
@@ -138,7 +139,7 @@ or plain text. Bubble flips and shifts on viewport collision; an arrow points to
|
|
|
138
139
|
--_tt--arrow-bottom: auto;
|
|
139
140
|
--_tt--arrow-left: auto;
|
|
140
141
|
--_tt--arrow-right: auto;
|
|
141
|
-
position:
|
|
142
|
+
position: fixed;
|
|
142
143
|
top: 0;
|
|
143
144
|
left: 0;
|
|
144
145
|
z-index: var(--_tt--z-index);
|