@getmicdrop/svelte-components 5.6.0 → 5.6.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.
Files changed (77) hide show
  1. package/dist/components/Layout/__tests__/AppShell.test.d.ts +2 -0
  2. package/dist/components/Layout/__tests__/AppShell.test.d.ts.map +1 -0
  3. package/dist/components/Layout/__tests__/AppShell.test.js +95 -0
  4. package/dist/components/Layout/__tests__/ContentSection.test.d.ts +2 -0
  5. package/dist/components/Layout/__tests__/ContentSection.test.d.ts.map +1 -0
  6. package/dist/components/Layout/__tests__/ContentSection.test.js +112 -0
  7. package/dist/components/Layout/__tests__/PageContainer.test.d.ts +2 -0
  8. package/dist/components/Layout/__tests__/PageContainer.test.d.ts.map +1 -0
  9. package/dist/components/Layout/__tests__/PageContainer.test.js +133 -0
  10. package/dist/components/Layout/__tests__/Responsive.test.d.ts +2 -0
  11. package/dist/components/Layout/__tests__/Responsive.test.d.ts.map +1 -0
  12. package/dist/components/Layout/__tests__/Responsive.test.js +123 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +41 -40
  15. package/dist/patterns/navigation/BottomNav.svelte +18 -8
  16. package/dist/patterns/navigation/BottomNav.svelte.d.ts.map +1 -1
  17. package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte +107 -107
  18. package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte.d.ts +2 -2
  19. package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte.d.ts.map +1 -1
  20. package/dist/primitives/Checkbox/Checkbox.svelte +3 -3
  21. package/dist/primitives/Dropdown/DropdownDivider.svelte +9 -0
  22. package/dist/primitives/Dropdown/DropdownDivider.svelte.d.ts +7 -0
  23. package/dist/primitives/Dropdown/DropdownDivider.svelte.d.ts.map +1 -0
  24. package/dist/primitives/Helper/Helper.svelte +33 -0
  25. package/dist/primitives/Helper/Helper.svelte.d.ts +18 -0
  26. package/dist/primitives/Helper/Helper.svelte.d.ts.map +1 -0
  27. package/dist/primitives/Input/Input.svelte +416 -417
  28. package/dist/primitives/Input/Input.svelte.d.ts +2 -4
  29. package/dist/primitives/Input/Input.svelte.d.ts.map +1 -1
  30. package/dist/primitives/Modal/Modal.svelte +157 -158
  31. package/dist/primitives/Modal/Modal.svelte.d.ts +6 -8
  32. package/dist/primitives/Modal/Modal.svelte.d.ts.map +1 -1
  33. package/dist/primitives/NumberInput/NumberInput.svelte +105 -106
  34. package/dist/primitives/NumberInput/NumberInput.svelte.d.ts +0 -2
  35. package/dist/primitives/NumberInput/NumberInput.svelte.d.ts.map +1 -1
  36. package/dist/primitives/Toggle.svelte +70 -71
  37. package/dist/primitives/Toggle.svelte.d.ts +2 -4
  38. package/dist/primitives/Toggle.svelte.d.ts.map +1 -1
  39. package/dist/primitives/Tooltip/Tooltip.svelte +83 -0
  40. package/dist/primitives/Tooltip/Tooltip.svelte.d.ts +15 -0
  41. package/dist/primitives/Tooltip/Tooltip.svelte.d.ts.map +1 -0
  42. package/dist/primitives/index.d.ts +3 -0
  43. package/dist/primitives/index.js +7 -0
  44. package/dist/recipes/ImageUploader/ImageUploader.spec.js +6 -5
  45. package/dist/recipes/inputs/MultiSelect.svelte +277 -256
  46. package/dist/recipes/inputs/MultiSelect.svelte.d.ts +54 -21
  47. package/dist/recipes/inputs/MultiSelect.svelte.d.ts.map +1 -1
  48. package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.spec.js +9 -4
  49. package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.svelte +332 -327
  50. package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.svelte.d.ts +12 -1
  51. package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.svelte.d.ts.map +1 -1
  52. package/dist/stores/auth.js +8 -0
  53. package/dist/stores/auth.svelte.d.ts +39 -0
  54. package/dist/stores/auth.svelte.d.ts.map +1 -0
  55. package/dist/stores/auth.svelte.js +60 -0
  56. package/dist/stores/formDataStore.d.ts.map +1 -1
  57. package/dist/stores/formDataStore.js +8 -0
  58. package/dist/stores/formDataStore.svelte.d.ts +47 -0
  59. package/dist/stores/formDataStore.svelte.d.ts.map +1 -0
  60. package/dist/stores/formDataStore.svelte.js +84 -0
  61. package/dist/stores/formSave.d.ts.map +1 -1
  62. package/dist/stores/formSave.js +8 -0
  63. package/dist/stores/formSave.svelte.d.ts +33 -0
  64. package/dist/stores/formSave.svelte.d.ts.map +1 -0
  65. package/dist/stores/formSave.svelte.js +113 -0
  66. package/dist/stores/navigation.d.ts.map +1 -1
  67. package/dist/stores/navigation.js +8 -0
  68. package/dist/stores/navigation.svelte.d.ts +35 -0
  69. package/dist/stores/navigation.svelte.d.ts.map +1 -0
  70. package/dist/stores/navigation.svelte.js +69 -0
  71. package/dist/telemetry.server.spec.js +11 -8
  72. package/dist/telemetry.spec.js +75 -50
  73. package/dist/utils/imageValidation.spec.js +62 -59
  74. package/dist/utils/logger.d.ts +19 -0
  75. package/dist/utils/logger.d.ts.map +1 -0
  76. package/dist/utils/logger.js +47 -0
  77. package/package.json +296 -292
@@ -1,34 +1,39 @@
1
1
  // @ts-nocheck
2
2
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
3
3
 
4
+ // Vitest 4.x requires class syntax for constructor mocks
4
5
  // Mock all OpenTelemetry modules before importing telemetry
5
6
  vi.mock('@opentelemetry/sdk-trace-web', () => ({
6
- WebTracerProvider: vi.fn().mockImplementation(() => ({
7
- addSpanProcessor: vi.fn(),
8
- register: vi.fn(),
9
- getTracer: vi.fn().mockReturnValue({
10
- startSpan: vi.fn().mockReturnValue({
11
- setAttribute: vi.fn(),
12
- setStatus: vi.fn(),
13
- recordException: vi.fn(),
14
- end: vi.fn(),
15
- name: 'test-span',
16
- }),
17
- }),
18
- shutdown: vi.fn().mockResolvedValue(undefined),
19
- })),
7
+ WebTracerProvider: class MockWebTracerProvider {
8
+ constructor() {
9
+ this.addSpanProcessor = vi.fn();
10
+ this.register = vi.fn();
11
+ this.shutdown = vi.fn().mockResolvedValue(undefined);
12
+ }
13
+ getTracer() {
14
+ return {
15
+ startSpan: vi.fn().mockReturnValue({
16
+ setAttribute: vi.fn(),
17
+ setStatus: vi.fn(),
18
+ recordException: vi.fn(),
19
+ end: vi.fn(),
20
+ name: 'test-span',
21
+ }),
22
+ };
23
+ }
24
+ },
20
25
  }));
21
26
 
22
27
  vi.mock('@opentelemetry/sdk-trace-base', () => ({
23
- BatchSpanProcessor: vi.fn(),
28
+ BatchSpanProcessor: class MockBatchSpanProcessor {},
24
29
  }));
25
30
 
26
31
  vi.mock('@opentelemetry/exporter-trace-otlp-http', () => ({
27
- OTLPTraceExporter: vi.fn(),
32
+ OTLPTraceExporter: class MockOTLPTraceExporter {},
28
33
  }));
29
34
 
30
35
  vi.mock('@opentelemetry/resources', () => ({
31
- Resource: vi.fn(),
36
+ Resource: class MockResource {},
32
37
  }));
33
38
 
34
39
  vi.mock('@opentelemetry/semantic-conventions', () => ({
@@ -38,35 +43,43 @@ vi.mock('@opentelemetry/semantic-conventions', () => ({
38
43
  }));
39
44
 
40
45
  vi.mock('@opentelemetry/instrumentation-document-load', () => ({
41
- DocumentLoadInstrumentation: vi.fn().mockImplementation(() => ({
42
- enable: vi.fn(),
43
- })),
46
+ DocumentLoadInstrumentation: class MockDocumentLoadInstrumentation {
47
+ constructor() {
48
+ this.enable = vi.fn();
49
+ }
50
+ },
44
51
  }));
45
52
 
46
53
  vi.mock('@opentelemetry/instrumentation-fetch', () => ({
47
- FetchInstrumentation: vi.fn().mockImplementation(() => ({
48
- enable: vi.fn(),
49
- })),
54
+ FetchInstrumentation: class MockFetchInstrumentation {
55
+ constructor() {
56
+ this.enable = vi.fn();
57
+ }
58
+ },
50
59
  }));
51
60
 
52
61
  vi.mock('@opentelemetry/instrumentation-xml-http-request', () => ({
53
- XMLHttpRequestInstrumentation: vi.fn().mockImplementation(() => ({
54
- enable: vi.fn(),
55
- })),
62
+ XMLHttpRequestInstrumentation: class MockXMLHttpRequestInstrumentation {
63
+ constructor() {
64
+ this.enable = vi.fn();
65
+ }
66
+ },
56
67
  }));
57
68
 
58
69
  vi.mock('@opentelemetry/instrumentation-user-interaction', () => ({
59
- UserInteractionInstrumentation: vi.fn().mockImplementation(() => ({
60
- enable: vi.fn(),
61
- })),
70
+ UserInteractionInstrumentation: class MockUserInteractionInstrumentation {
71
+ constructor() {
72
+ this.enable = vi.fn();
73
+ }
74
+ },
62
75
  }));
63
76
 
64
77
  vi.mock('@opentelemetry/context-zone', () => ({
65
- ZoneContextManager: vi.fn(),
78
+ ZoneContextManager: class MockZoneContextManager {},
66
79
  }));
67
80
 
68
81
  vi.mock('@opentelemetry/propagator-b3', () => ({
69
- B3Propagator: vi.fn(),
82
+ B3Propagator: class MockB3Propagator {},
70
83
  }));
71
84
 
72
85
  describe('Telemetry Module', () => {
@@ -504,22 +517,26 @@ describe('Telemetry shutdown error handling', () => {
504
517
  beforeEach(async () => {
505
518
  vi.resetModules();
506
519
 
507
- // Mock shutdown to throw error
520
+ // Mock shutdown to throw error - Vitest 4.x requires class syntax
508
521
  vi.mock('@opentelemetry/sdk-trace-web', () => ({
509
- WebTracerProvider: vi.fn().mockImplementation(() => ({
510
- addSpanProcessor: vi.fn(),
511
- register: vi.fn(),
512
- getTracer: vi.fn().mockReturnValue({
513
- startSpan: vi.fn().mockReturnValue({
514
- setAttribute: vi.fn(),
515
- setStatus: vi.fn(),
516
- recordException: vi.fn(),
517
- end: vi.fn(),
518
- name: 'test-span',
519
- }),
520
- }),
521
- shutdown: vi.fn().mockRejectedValue(new Error('Shutdown failed')),
522
- })),
522
+ WebTracerProvider: class MockWebTracerProviderWithError {
523
+ constructor() {
524
+ this.addSpanProcessor = vi.fn();
525
+ this.register = vi.fn();
526
+ this.shutdown = vi.fn().mockRejectedValue(new Error('Shutdown failed'));
527
+ }
528
+ getTracer() {
529
+ return {
530
+ startSpan: vi.fn().mockReturnValue({
531
+ setAttribute: vi.fn(),
532
+ setStatus: vi.fn(),
533
+ recordException: vi.fn(),
534
+ end: vi.fn(),
535
+ name: 'test-span',
536
+ }),
537
+ };
538
+ }
539
+ },
523
540
  }));
524
541
 
525
542
  global.window = {
@@ -813,9 +830,13 @@ describe('Telemetry tracking with initialized tracer', () => {
813
830
  shutdown: vi.fn().mockResolvedValue(undefined),
814
831
  };
815
832
 
816
- // Mock WebTracerProvider to return our mock
833
+ // Mock WebTracerProvider to return our mock - Vitest 4.x requires class syntax
817
834
  vi.doMock('@opentelemetry/sdk-trace-web', () => ({
818
- WebTracerProvider: vi.fn().mockImplementation(() => mockTracerProvider),
835
+ WebTracerProvider: class MockWebTracerProviderForTracking {
836
+ constructor() {
837
+ Object.assign(this, mockTracerProvider);
838
+ }
839
+ },
819
840
  }));
820
841
 
821
842
  // Mock registerInstrumentations to avoid instrumentation errors
@@ -1069,9 +1090,13 @@ describe('connectWithSSRTrace functionality', () => {
1069
1090
  shutdown: vi.fn().mockResolvedValue(undefined),
1070
1091
  };
1071
1092
 
1072
- // Mock WebTracerProvider to return our mock
1093
+ // Mock WebTracerProvider to return our mock - Vitest 4.x requires class syntax
1073
1094
  vi.doMock('@opentelemetry/sdk-trace-web', () => ({
1074
- WebTracerProvider: vi.fn().mockImplementation(() => mockTracerProvider),
1095
+ WebTracerProvider: class MockWebTracerProviderForSSR {
1096
+ constructor() {
1097
+ Object.assign(this, mockTracerProvider);
1098
+ }
1099
+ },
1075
1100
  }));
1076
1101
 
1077
1102
  // Mock registerInstrumentations
@@ -57,17 +57,20 @@ describe('imageValidation', () => {
57
57
  it('accepts valid JPEG file', async () => {
58
58
  const file = new File(['content'], 'test.jpg', { type: 'image/jpeg' });
59
59
 
60
- // Mock Image loading
61
- const mockImage = {
62
- width: 100,
63
- height: 100,
64
- onload: null,
65
- onerror: null,
66
- src: '',
67
- };
68
- vi.spyOn(global, 'Image').mockImplementation(() => {
69
- setTimeout(() => mockImage.onload?.call(mockImage), 0);
70
- return mockImage;
60
+ // Mock Image loading using class
61
+ vi.stubGlobal('Image', class {
62
+ constructor() {
63
+ this.width = 100;
64
+ this.height = 100;
65
+ this.onload = null;
66
+ this.onerror = null;
67
+ this._src = '';
68
+ }
69
+ set src(value) {
70
+ this._src = value;
71
+ setTimeout(() => this.onload?.call(this), 0);
72
+ }
73
+ get src() { return this._src; }
71
74
  });
72
75
 
73
76
  const result = await validateImage(file);
@@ -80,16 +83,16 @@ describe('imageValidation', () => {
80
83
  it('accepts valid PNG file', async () => {
81
84
  const file = new File(['content'], 'test.png', { type: 'image/png' });
82
85
 
83
- const mockImage = {
84
- width: 500,
85
- height: 500,
86
- onload: null,
87
- onerror: null,
88
- src: '',
89
- };
90
- vi.spyOn(global, 'Image').mockImplementation(() => {
91
- setTimeout(() => mockImage.onload?.call(mockImage), 0);
92
- return mockImage;
86
+ vi.stubGlobal('Image', class {
87
+ constructor() {
88
+ this.width = 500;
89
+ this.height = 500;
90
+ this.onload = null;
91
+ this.onerror = null;
92
+ this._src = '';
93
+ }
94
+ set src(value) { this._src = value; setTimeout(() => this.onload?.call(this), 0); }
95
+ get src() { return this._src; }
93
96
  });
94
97
 
95
98
  const result = await validateImage(file);
@@ -100,16 +103,16 @@ describe('imageValidation', () => {
100
103
  it('accepts valid WebP file', async () => {
101
104
  const file = new File(['content'], 'test.webp', { type: 'image/webp' });
102
105
 
103
- const mockImage = {
104
- width: 200,
105
- height: 200,
106
- onload: null,
107
- onerror: null,
108
- src: '',
109
- };
110
- vi.spyOn(global, 'Image').mockImplementation(() => {
111
- setTimeout(() => mockImage.onload?.call(mockImage), 0);
112
- return mockImage;
106
+ vi.stubGlobal('Image', class {
107
+ constructor() {
108
+ this.width = 200;
109
+ this.height = 200;
110
+ this.onload = null;
111
+ this.onerror = null;
112
+ this._src = '';
113
+ }
114
+ set src(value) { this._src = value; setTimeout(() => this.onload?.call(this), 0); }
115
+ get src() { return this._src; }
113
116
  });
114
117
 
115
118
  const result = await validateImage(file);
@@ -120,16 +123,16 @@ describe('imageValidation', () => {
120
123
  it('rejects image with dimensions too large', async () => {
121
124
  const file = new File(['content'], 'test.jpg', { type: 'image/jpeg' });
122
125
 
123
- const mockImage = {
124
- width: 9000,
125
- height: 9000,
126
- onload: null,
127
- onerror: null,
128
- src: '',
129
- };
130
- vi.spyOn(global, 'Image').mockImplementation(() => {
131
- setTimeout(() => mockImage.onload?.call(mockImage), 0);
132
- return mockImage;
126
+ vi.stubGlobal('Image', class {
127
+ constructor() {
128
+ this.width = 9000;
129
+ this.height = 9000;
130
+ this.onload = null;
131
+ this.onerror = null;
132
+ this._src = '';
133
+ }
134
+ set src(value) { this._src = value; setTimeout(() => this.onload?.call(this), 0); }
135
+ get src() { return this._src; }
133
136
  });
134
137
 
135
138
  const result = await validateImage(file);
@@ -142,14 +145,14 @@ describe('imageValidation', () => {
142
145
  it('handles image load error', async () => {
143
146
  const file = new File(['content'], 'test.jpg', { type: 'image/jpeg' });
144
147
 
145
- const mockImage = {
146
- onload: null,
147
- onerror: null,
148
- src: '',
149
- };
150
- vi.spyOn(global, 'Image').mockImplementation(() => {
151
- setTimeout(() => mockImage.onerror?.(), 0);
152
- return mockImage;
148
+ vi.stubGlobal('Image', class {
149
+ constructor() {
150
+ this.onload = null;
151
+ this.onerror = null;
152
+ this._src = '';
153
+ }
154
+ set src(value) { this._src = value; setTimeout(() => this.onerror?.(), 0); }
155
+ get src() { return this._src; }
153
156
  });
154
157
 
155
158
  const result = await validateImage(file);
@@ -161,16 +164,16 @@ describe('imageValidation', () => {
161
164
  it('handles HEIC format', async () => {
162
165
  const file = new File(['content'], 'test.heic', { type: 'image/heic' });
163
166
 
164
- const mockImage = {
165
- width: 100,
166
- height: 100,
167
- onload: null,
168
- onerror: null,
169
- src: '',
170
- };
171
- vi.spyOn(global, 'Image').mockImplementation(() => {
172
- setTimeout(() => mockImage.onload?.call(mockImage), 0);
173
- return mockImage;
167
+ vi.stubGlobal('Image', class {
168
+ constructor() {
169
+ this.width = 100;
170
+ this.height = 100;
171
+ this.onload = null;
172
+ this.onerror = null;
173
+ this._src = '';
174
+ }
175
+ set src(value) { this._src = value; setTimeout(() => this.onload?.call(this), 0); }
176
+ get src() { return this._src; }
174
177
  });
175
178
 
176
179
  const result = await validateImage(file);
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Centralized logger utility for MicDrop applications
3
+ * Can be disabled in production or configured for different log levels
4
+ */
5
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
6
+ interface LoggerConfig {
7
+ enabled: boolean;
8
+ level: LogLevel;
9
+ prefix: string;
10
+ }
11
+ export declare function configureLogger(options: Partial<LoggerConfig>): void;
12
+ export declare const logger: {
13
+ debug: (message: string, ...args: unknown[]) => void;
14
+ info: (message: string, ...args: unknown[]) => void;
15
+ warn: (message: string, ...args: unknown[]) => void;
16
+ error: (message: string, ...args: unknown[]) => void;
17
+ };
18
+ export default logger;
19
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,UAAU,YAAY;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAeD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAEpE;AAUD,eAAO,MAAM,MAAM;qBACA,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;oBAMlC,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;oBAMjC,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;qBAMhC,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;CAKnD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Centralized logger utility for MicDrop applications
3
+ * Can be disabled in production or configured for different log levels
4
+ */
5
+ const LOG_LEVELS = {
6
+ debug: 0,
7
+ info: 1,
8
+ warn: 2,
9
+ error: 3,
10
+ };
11
+ let config = {
12
+ enabled: typeof window !== 'undefined' && import.meta.env?.DEV !== false,
13
+ level: 'debug',
14
+ prefix: '[MicDrop]',
15
+ };
16
+ export function configureLogger(options) {
17
+ config = { ...config, ...options };
18
+ }
19
+ function shouldLog(level) {
20
+ return config.enabled && LOG_LEVELS[level] >= LOG_LEVELS[config.level];
21
+ }
22
+ function formatMessage(level, message) {
23
+ return `${config.prefix} [${level.toUpperCase()}] ${message}`;
24
+ }
25
+ export const logger = {
26
+ debug: (message, ...args) => {
27
+ if (shouldLog('debug')) {
28
+ console.log(formatMessage('debug', message), ...args);
29
+ }
30
+ },
31
+ info: (message, ...args) => {
32
+ if (shouldLog('info')) {
33
+ console.info(formatMessage('info', message), ...args);
34
+ }
35
+ },
36
+ warn: (message, ...args) => {
37
+ if (shouldLog('warn')) {
38
+ console.warn(formatMessage('warn', message), ...args);
39
+ }
40
+ },
41
+ error: (message, ...args) => {
42
+ if (shouldLog('error')) {
43
+ console.error(formatMessage('error', message), ...args);
44
+ }
45
+ },
46
+ };
47
+ export default logger;