@getmicdrop/svelte-components 2.0.4 → 2.0.6
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/components/Alert/Alert.spec.js +170 -170
- package/dist/components/Badges/Badge.spec.js +103 -103
- package/dist/components/BottomSheet/BottomSheet.spec.js +127 -127
- package/dist/components/Breadcrumb/Breadcrumb.spec.js +120 -120
- package/dist/components/Button/Button.spec.js +211 -211
- package/dist/components/Button/ButtonSaveDemo.spec.js +48 -48
- package/dist/components/Calendar/Calendar.spec.js +131 -131
- package/dist/components/Calendar/QuarterView.spec.js +394 -394
- package/dist/components/Card.spec.js +47 -47
- package/dist/components/CropImage/CropImage.spec.js +216 -216
- package/dist/components/DarkModeToggle.spec.js +357 -357
- package/dist/components/ErrorDisplay.spec.js +69 -69
- package/dist/components/FormActions.spec.js +88 -88
- package/dist/components/FormValidationSummary.spec.js +203 -203
- package/dist/components/Icons/Icon.spec.js +175 -175
- package/dist/components/Icons/MoreHori.spec.js +67 -67
- package/dist/components/Icons/WarningIcon.spec.js +30 -30
- package/dist/components/Input/Input.spec.js +573 -573
- package/dist/components/Input/MultiSelect.spec.js +257 -257
- package/dist/components/Input/OTPInput.spec.js +238 -238
- package/dist/components/Input/Select.spec.js +218 -218
- package/dist/components/Layout/BottomNav.spec.js +130 -130
- package/dist/components/Layout/Header.spec.js +203 -203
- package/dist/components/Modal/ConfirmationModal.spec.js +191 -191
- package/dist/components/Modal/Modal.spec.js +95 -95
- package/dist/components/Modal/ModalStateManager.spec.js +100 -100
- package/dist/components/PageLoader.spec.js +54 -54
- package/dist/components/PasswordStrengthIndicator/PasswordStrengthIndicator.spec.js +173 -173
- package/dist/components/PlaceAutocomplete/PlaceAutocomplete.spec.js +300 -300
- package/dist/components/Spinner/Spinner.spec.js +75 -75
- package/dist/components/StatusIndicator/StatusIndicator.spec.js +129 -129
- package/dist/components/Toaster/Toaster.stories.svelte +1 -1
- package/dist/components/Toggle.spec.js +158 -158
- package/dist/components/ValidationError.spec.js +79 -79
- package/dist/components/pages/performers/AvailabilityCalendarModal.spec.js +606 -606
- package/dist/components/pages/performers/AvailabilityCalendarModal.svelte +4 -4
- package/dist/components/pages/performers/ModalShowInfo.spec.js +124 -124
- package/dist/components/pages/performers/ModalShowInfo.svelte +1 -1
- package/dist/components/pages/performers/PageBackButton.spec.js +89 -89
- package/dist/components/pages/performers/SectionHeader.spec.js +75 -75
- package/dist/components/pages/performers/ShowDetails.spec.js +166 -166
- package/dist/components/pages/performers/ShowItemCard.spec.js +793 -793
- package/dist/components/pages/performers/ShowItemCard.svelte +4 -4
- package/dist/components/pages/performers/SwitchOption.spec.js +127 -127
- package/dist/components/pages/performers/VenueInfo.spec.js +167 -167
- package/dist/components/pages/performers/VenueInfo.svelte +1 -1
- package/dist/components/pages/performers/VenueItemCard.spec.js +763 -763
- package/dist/components/pages/performers/VenueItemCard.svelte +4 -4
- package/dist/components/pages/profile/profile-form.spec.js +9 -9
- package/dist/components/pages/settings/tabs/CustomImageDropzone.svelte +3 -3
- package/dist/components/pages/shows/ShowList.spec.js +33 -33
- package/dist/components/pages/shows/TabContent.spec.js +90 -90
- package/dist/components/pages/shows/TabNavigation.spec.js +143 -143
- package/dist/config.js +5 -5
- package/dist/config.spec.js +29 -29
- package/dist/constants/formOptions.js +25 -25
- package/dist/constants/formOptions.spec.js +88 -88
- package/dist/index.js +111 -111
- package/dist/stores/auth.d.ts +9 -0
- package/dist/stores/auth.d.ts.map +1 -0
- package/dist/stores/auth.js +36 -0
- package/dist/stores/auth.spec.d.ts +2 -0
- package/dist/stores/auth.spec.d.ts.map +1 -0
- package/dist/stores/auth.spec.js +139 -0
- package/dist/stores/formDataStore.d.ts +17 -0
- package/dist/stores/formDataStore.d.ts.map +1 -0
- package/dist/stores/formDataStore.js +25 -0
- package/dist/stores/formDataStore.spec.d.ts +2 -0
- package/dist/stores/formDataStore.spec.d.ts.map +1 -0
- package/dist/stores/formDataStore.spec.js +257 -0
- package/dist/stores/formSave.d.ts +24 -0
- package/dist/stores/formSave.d.ts.map +1 -0
- package/dist/stores/formSave.js +132 -0
- package/dist/stores/formSave.spec.d.ts +2 -0
- package/dist/stores/formSave.spec.d.ts.map +1 -0
- package/dist/stores/formSave.spec.js +296 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +0 -0
- package/dist/stores/navigation.d.ts +5 -0
- package/dist/stores/navigation.d.ts.map +1 -0
- package/dist/stores/navigation.js +12 -0
- package/dist/stores/navigation.spec.d.ts +2 -0
- package/dist/stores/navigation.spec.d.ts.map +1 -0
- package/dist/stores/navigation.spec.js +136 -0
- package/dist/stores/toaster.d.ts +4 -0
- package/dist/stores/toaster.d.ts.map +1 -0
- package/dist/stores/toaster.js +13 -0
- package/dist/stores/toaster.spec.d.ts +2 -0
- package/dist/stores/toaster.spec.d.ts.map +1 -0
- package/dist/stores/toaster.spec.js +59 -0
- package/dist/telemetry.js +357 -357
- package/dist/telemetry.server.js +211 -211
- package/dist/telemetry.server.spec.js +434 -434
- package/dist/telemetry.spec.js +660 -660
- package/dist/utils/apiConfig.js +49 -49
- package/dist/utils/apiConfig.spec.js +118 -118
- package/dist/utils/greetings.js +187 -187
- package/dist/utils/greetings.spec.js +337 -337
- package/dist/utils/imageValidation.js +121 -121
- package/dist/utils/imageValidation.spec.js +220 -220
- package/dist/utils/portal.js +25 -25
- package/dist/utils/portal.spec.js +143 -143
- package/dist/utils/utils/utils.js +323 -323
- package/dist/utils/utils/utils.spec.js +698 -698
- package/dist/utils/utils.spec.js +643 -643
- package/package.json +1 -1
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image validation utilities for file uploads
|
|
3
|
-
*
|
|
4
|
-
* Guidelines:
|
|
5
|
-
* - Formats: PNG, JPG, JPEG, WebP, HEIC, HEIF
|
|
6
|
-
* - Max dimension: 8000px (to handle phone screenshots up to 4K)
|
|
7
|
-
* - Max file size: 20MB (we crop and optimize to 1000x1000 WebP anyway)
|
|
8
|
-
* - Aspect ratio: Any
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const MAX_FILE_SIZE = 20 * 1024 * 1024; // 20 MB - generous since we optimize
|
|
12
|
-
const MAX_DIMENSION = 8000; // pixels - handles 4K+ phone screenshots
|
|
13
|
-
const ALLOWED_IMAGE_TYPES = [
|
|
14
|
-
'image/jpeg',
|
|
15
|
-
'image/jpg',
|
|
16
|
-
'image/png',
|
|
17
|
-
'image/webp',
|
|
18
|
-
'image/heic',
|
|
19
|
-
'image/heif'
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Validates an image file according to upload guidelines
|
|
24
|
-
* @param {File} file - The image file to validate
|
|
25
|
-
* @returns {Promise<{valid: boolean, error: string|null, dimensions: {width: number, height: number}}>}
|
|
26
|
-
*/
|
|
27
|
-
export async function validateImage(file) {
|
|
28
|
-
// Check file type
|
|
29
|
-
if (!ALLOWED_IMAGE_TYPES.includes(file.type.toLowerCase())) {
|
|
30
|
-
return {
|
|
31
|
-
valid: false,
|
|
32
|
-
error: 'Invalid file format. Please upload PNG, JPG, WebP, or HEIC images only.',
|
|
33
|
-
dimensions: null
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Check file size
|
|
38
|
-
if (file.size > MAX_FILE_SIZE) {
|
|
39
|
-
const sizeMB = (file.size / (1024 * 1024)).toFixed(2);
|
|
40
|
-
return {
|
|
41
|
-
valid: false,
|
|
42
|
-
error: `File too large (${sizeMB}MB). Maximum file size is 20MB.`,
|
|
43
|
-
dimensions: null
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Check dimensions
|
|
48
|
-
try {
|
|
49
|
-
const dimensions = await getImageDimensions(file);
|
|
50
|
-
|
|
51
|
-
if (dimensions.width > MAX_DIMENSION || dimensions.height > MAX_DIMENSION) {
|
|
52
|
-
return {
|
|
53
|
-
valid: false,
|
|
54
|
-
error: `Image dimensions too large (${dimensions.width}x${dimensions.height}px). Maximum dimension is ${MAX_DIMENSION}px.`,
|
|
55
|
-
dimensions
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
valid: true,
|
|
61
|
-
error: null,
|
|
62
|
-
dimensions
|
|
63
|
-
};
|
|
64
|
-
} catch (error) {
|
|
65
|
-
return {
|
|
66
|
-
valid: false,
|
|
67
|
-
error: 'Failed to read image dimensions. Please try another file.',
|
|
68
|
-
dimensions: null
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Gets the dimensions of an image file
|
|
75
|
-
* @param {File} file - The image file
|
|
76
|
-
* @returns {Promise<{width: number, height: number}>}
|
|
77
|
-
*/
|
|
78
|
-
function getImageDimensions(file) {
|
|
79
|
-
return new Promise((resolve, reject) => {
|
|
80
|
-
const img = new Image();
|
|
81
|
-
const objectUrl = URL.createObjectURL(file);
|
|
82
|
-
|
|
83
|
-
img.onload = function() {
|
|
84
|
-
URL.revokeObjectURL(objectUrl);
|
|
85
|
-
resolve({
|
|
86
|
-
width: this.width,
|
|
87
|
-
height: this.height
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
img.onerror = function() {
|
|
92
|
-
URL.revokeObjectURL(objectUrl);
|
|
93
|
-
reject(new Error('Failed to load image'));
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
img.src = objectUrl;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Gets the accept attribute value for file inputs
|
|
102
|
-
* @returns {string}
|
|
103
|
-
*/
|
|
104
|
-
export function getImageAcceptAttribute() {
|
|
105
|
-
return 'image/png,image/jpeg,image/jpg,image/webp,image/heic,image/heif';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Gets formatted error messages for display in UI
|
|
110
|
-
* @returns {object}
|
|
111
|
-
*/
|
|
112
|
-
export function getValidationMessages() {
|
|
113
|
-
return {
|
|
114
|
-
formats: 'PNG, JPG, WebP, HEIC',
|
|
115
|
-
maxSize: '20MB',
|
|
116
|
-
maxDimension: '8000px',
|
|
117
|
-
aspectRatio: 'Any'
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { MAX_FILE_SIZE, MAX_DIMENSION, ALLOWED_IMAGE_TYPES };
|
|
1
|
+
/**
|
|
2
|
+
* Image validation utilities for file uploads
|
|
3
|
+
*
|
|
4
|
+
* Guidelines:
|
|
5
|
+
* - Formats: PNG, JPG, JPEG, WebP, HEIC, HEIF
|
|
6
|
+
* - Max dimension: 8000px (to handle phone screenshots up to 4K)
|
|
7
|
+
* - Max file size: 20MB (we crop and optimize to 1000x1000 WebP anyway)
|
|
8
|
+
* - Aspect ratio: Any
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const MAX_FILE_SIZE = 20 * 1024 * 1024; // 20 MB - generous since we optimize
|
|
12
|
+
const MAX_DIMENSION = 8000; // pixels - handles 4K+ phone screenshots
|
|
13
|
+
const ALLOWED_IMAGE_TYPES = [
|
|
14
|
+
'image/jpeg',
|
|
15
|
+
'image/jpg',
|
|
16
|
+
'image/png',
|
|
17
|
+
'image/webp',
|
|
18
|
+
'image/heic',
|
|
19
|
+
'image/heif'
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Validates an image file according to upload guidelines
|
|
24
|
+
* @param {File} file - The image file to validate
|
|
25
|
+
* @returns {Promise<{valid: boolean, error: string|null, dimensions: {width: number, height: number}}>}
|
|
26
|
+
*/
|
|
27
|
+
export async function validateImage(file) {
|
|
28
|
+
// Check file type
|
|
29
|
+
if (!ALLOWED_IMAGE_TYPES.includes(file.type.toLowerCase())) {
|
|
30
|
+
return {
|
|
31
|
+
valid: false,
|
|
32
|
+
error: 'Invalid file format. Please upload PNG, JPG, WebP, or HEIC images only.',
|
|
33
|
+
dimensions: null
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Check file size
|
|
38
|
+
if (file.size > MAX_FILE_SIZE) {
|
|
39
|
+
const sizeMB = (file.size / (1024 * 1024)).toFixed(2);
|
|
40
|
+
return {
|
|
41
|
+
valid: false,
|
|
42
|
+
error: `File too large (${sizeMB}MB). Maximum file size is 20MB.`,
|
|
43
|
+
dimensions: null
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check dimensions
|
|
48
|
+
try {
|
|
49
|
+
const dimensions = await getImageDimensions(file);
|
|
50
|
+
|
|
51
|
+
if (dimensions.width > MAX_DIMENSION || dimensions.height > MAX_DIMENSION) {
|
|
52
|
+
return {
|
|
53
|
+
valid: false,
|
|
54
|
+
error: `Image dimensions too large (${dimensions.width}x${dimensions.height}px). Maximum dimension is ${MAX_DIMENSION}px.`,
|
|
55
|
+
dimensions
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
valid: true,
|
|
61
|
+
error: null,
|
|
62
|
+
dimensions
|
|
63
|
+
};
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
valid: false,
|
|
67
|
+
error: 'Failed to read image dimensions. Please try another file.',
|
|
68
|
+
dimensions: null
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets the dimensions of an image file
|
|
75
|
+
* @param {File} file - The image file
|
|
76
|
+
* @returns {Promise<{width: number, height: number}>}
|
|
77
|
+
*/
|
|
78
|
+
function getImageDimensions(file) {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
const img = new Image();
|
|
81
|
+
const objectUrl = URL.createObjectURL(file);
|
|
82
|
+
|
|
83
|
+
img.onload = function() {
|
|
84
|
+
URL.revokeObjectURL(objectUrl);
|
|
85
|
+
resolve({
|
|
86
|
+
width: this.width,
|
|
87
|
+
height: this.height
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
img.onerror = function() {
|
|
92
|
+
URL.revokeObjectURL(objectUrl);
|
|
93
|
+
reject(new Error('Failed to load image'));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
img.src = objectUrl;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Gets the accept attribute value for file inputs
|
|
102
|
+
* @returns {string}
|
|
103
|
+
*/
|
|
104
|
+
export function getImageAcceptAttribute() {
|
|
105
|
+
return 'image/png,image/jpeg,image/jpg,image/webp,image/heic,image/heif';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Gets formatted error messages for display in UI
|
|
110
|
+
* @returns {object}
|
|
111
|
+
*/
|
|
112
|
+
export function getValidationMessages() {
|
|
113
|
+
return {
|
|
114
|
+
formats: 'PNG, JPG, WebP, HEIC',
|
|
115
|
+
maxSize: '20MB',
|
|
116
|
+
maxDimension: '8000px',
|
|
117
|
+
aspectRatio: 'Any'
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { MAX_FILE_SIZE, MAX_DIMENSION, ALLOWED_IMAGE_TYPES };
|