@autoguru/overdrive 4.45.2 → 4.47.0
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/Calendar/Calendar.css.d.ts +8 -0
- package/dist/components/Calendar/Calendar.css.d.ts.map +1 -0
- package/dist/components/Calendar/Calendar.css.js +113 -0
- package/dist/components/Calendar/Calendar.d.ts +64 -0
- package/dist/components/Calendar/Calendar.d.ts.map +1 -0
- package/dist/components/Calendar/Calendar.js +122 -0
- package/dist/components/Calendar/CalendarButton.d.ts +7 -0
- package/dist/components/Calendar/CalendarButton.d.ts.map +1 -0
- package/dist/components/{DateTimePicker → Calendar}/CalendarButton.js +4 -3
- package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.d.ts +4 -1
- package/dist/components/Calendar/CalendarGrid.d.ts.map +1 -0
- package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.js +8 -7
- package/dist/components/Calendar/index.d.ts +3 -0
- package/dist/components/Calendar/index.d.ts.map +1 -0
- package/dist/components/Calendar/index.js +3 -0
- package/dist/components/DatePicker/DatePicker.css.d.ts +2 -1
- package/dist/components/DatePicker/DatePicker.css.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.css.js +60 -30
- package/dist/components/DatePicker/DatePicker.d.ts +83 -5
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +160 -43
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +0 -15
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.css.js +16 -99
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +5 -2
- package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.js +24 -80
- package/dist/components/OptionGrid/OptionGrid.css.d.ts +33 -34
- package/dist/components/OptionGrid/OptionGrid.css.d.ts.map +1 -1
- package/dist/components/OptionGrid/OptionGrid.css.js +208 -146
- package/dist/components/OptionGrid/OptionGrid.d.ts +16 -5
- package/dist/components/OptionGrid/OptionGrid.d.ts.map +1 -1
- package/dist/components/OptionGrid/OptionGrid.js +38 -13
- package/dist/components/OptionList/OptionList.css.d.ts +2 -10
- package/dist/components/OptionList/OptionList.css.d.ts.map +1 -1
- package/dist/components/OptionList/OptionList.css.js +92 -92
- package/dist/components/OptionList/OptionList.d.ts +10 -3
- package/dist/components/OptionList/OptionList.d.ts.map +1 -1
- package/dist/components/OptionList/OptionListItem.js +3 -3
- package/dist/components/Popover/Popover.css.d.ts +4 -0
- package/dist/components/Popover/Popover.css.d.ts.map +1 -0
- package/dist/components/Popover/Popover.css.js +46 -0
- package/dist/components/Popover/Popover.d.ts +34 -0
- package/dist/components/Popover/Popover.d.ts.map +1 -0
- package/dist/components/Popover/Popover.js +127 -0
- package/dist/components/Popover/PopoverTrigger.d.ts +51 -0
- package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -0
- package/dist/components/Popover/PopoverTrigger.js +94 -0
- package/dist/components/Popover/index.d.ts +5 -0
- package/dist/components/Popover/index.d.ts.map +1 -0
- package/dist/components/Popover/index.js +4 -0
- package/dist/components/SearchBar/SearchBar.css.d.ts +7 -12
- package/dist/components/SearchBar/SearchBar.css.d.ts.map +1 -1
- package/dist/components/SearchBar/SearchBar.css.js +121 -66
- package/dist/components/SearchBar/SearchBar.d.ts.map +1 -1
- package/dist/components/SearchBar/SearchBar.js +17 -10
- package/dist/components/Slider/Slider.css.d.ts +9 -0
- package/dist/components/Slider/Slider.css.d.ts.map +1 -0
- package/dist/components/Slider/Slider.css.js +92 -0
- package/dist/components/Slider/Slider.d.ts +47 -0
- package/dist/components/Slider/Slider.d.ts.map +1 -0
- package/dist/components/Slider/Slider.js +137 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Slider/index.js +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/hooks/useMedia/useMedia.spec.d.ts +2 -0
- package/dist/hooks/useMedia/useMedia.spec.d.ts.map +1 -0
- package/dist/hooks/useMedia/useMedia.spec.js +288 -0
- package/dist/styles/selectors.d.ts +14 -0
- package/dist/styles/selectors.d.ts.map +1 -0
- package/dist/styles/selectors.js +27 -0
- package/dist/utils/css.d.ts +0 -22
- package/dist/utils/css.d.ts.map +1 -1
- package/dist/utils/css.js +0 -52
- package/dist/utils/css.spec.d.ts +2 -0
- package/dist/utils/css.spec.d.ts.map +1 -0
- package/dist/utils/css.spec.js +66 -0
- package/dist/utils/dateFormat.d.ts +24 -0
- package/dist/utils/dateFormat.d.ts.map +1 -0
- package/dist/utils/dateFormat.js +57 -0
- package/dist/utils/object.spec.d.ts +2 -0
- package/dist/utils/object.spec.d.ts.map +1 -0
- package/dist/utils/object.spec.js +135 -0
- package/dist/utils/responsiveStyle.spec.d.ts +2 -0
- package/dist/utils/responsiveStyle.spec.d.ts.map +1 -0
- package/dist/utils/responsiveStyle.spec.js +134 -0
- package/dist/utils/utils.spec.d.ts.map +1 -1
- package/dist/utils/utils.spec.js +342 -0
- package/package.json +25 -25
- package/dist/components/DateTimePicker/CalendarButton.d.ts +0 -4
- package/dist/components/DateTimePicker/CalendarButton.d.ts.map +0 -1
- package/dist/components/DateTimePicker/CalendarGrid.d.ts.map +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { cssVarUnwrap, getThemeTokenValue } from "./css.js";
|
|
4
|
+
describe('css utilities', () => {
|
|
5
|
+
describe('cssVarUnwrap', () => {
|
|
6
|
+
it('extracts CSS variable name from var() function', () => {
|
|
7
|
+
expect(cssVarUnwrap('var(--color-primary)')).toBe('--color-primary');
|
|
8
|
+
expect(cssVarUnwrap('var(--spacing-2)')).toBe('--spacing-2');
|
|
9
|
+
expect(cssVarUnwrap('var(--border-radius, 4px)')).toBe('--border-radius, 4px');
|
|
10
|
+
});
|
|
11
|
+
it('returns original value if not a CSS variable', () => {
|
|
12
|
+
expect(cssVarUnwrap('#ff0000')).toBe('#ff0000');
|
|
13
|
+
expect(cssVarUnwrap('16px')).toBe('16px');
|
|
14
|
+
expect(cssVarUnwrap('solid')).toBe('solid');
|
|
15
|
+
});
|
|
16
|
+
it('handles edge cases', () => {
|
|
17
|
+
expect(cssVarUnwrap('')).toBe('');
|
|
18
|
+
expect(cssVarUnwrap('var()')).toBe('var()');
|
|
19
|
+
expect(cssVarUnwrap('var')).toBe('var');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('getThemeTokenValue', () => {
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
// Clean up any existing test elements
|
|
25
|
+
document.querySelectorAll('.test-theme').forEach(el => el.remove());
|
|
26
|
+
});
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
// Clean up test elements
|
|
29
|
+
document.querySelectorAll('.test-theme').forEach(el => el.remove());
|
|
30
|
+
});
|
|
31
|
+
it('returns empty string when themeClass is null/undefined', () => {
|
|
32
|
+
expect(getThemeTokenValue(null, '--color-primary')).toBe('');
|
|
33
|
+
expect(getThemeTokenValue(undefined, '--color-primary')).toBe('');
|
|
34
|
+
});
|
|
35
|
+
it('returns empty string when token is null/undefined', () => {
|
|
36
|
+
expect(getThemeTokenValue('theme-class', null)).toBe('');
|
|
37
|
+
expect(getThemeTokenValue('theme-class')).toBe('');
|
|
38
|
+
});
|
|
39
|
+
it('returns empty string when element is not found', () => {
|
|
40
|
+
expect(getThemeTokenValue('non-existent-theme', '--color-primary')).toBe('');
|
|
41
|
+
});
|
|
42
|
+
it('returns CSS custom property value from themed element', () => {
|
|
43
|
+
// Create a test element with CSS custom properties
|
|
44
|
+
const testElement = document.createElement('div');
|
|
45
|
+
testElement.className = 'test-theme';
|
|
46
|
+
testElement.style.setProperty('--color-primary', '#ff0000');
|
|
47
|
+
testElement.style.setProperty('--spacing-large', '24px');
|
|
48
|
+
document.body.append(testElement);
|
|
49
|
+
expect(getThemeTokenValue('test-theme', 'var(--color-primary)')).toBe('#ff0000');
|
|
50
|
+
expect(getThemeTokenValue('test-theme', '--spacing-large')).toBe('24px');
|
|
51
|
+
});
|
|
52
|
+
it('trims whitespace from computed values', () => {
|
|
53
|
+
const testElement = document.createElement('div');
|
|
54
|
+
testElement.className = 'test-theme';
|
|
55
|
+
testElement.style.setProperty('--color-with-spaces', ' #ff0000 ');
|
|
56
|
+
document.body.append(testElement);
|
|
57
|
+
expect(getThemeTokenValue('test-theme', '--color-with-spaces')).toBe('#ff0000');
|
|
58
|
+
});
|
|
59
|
+
it('returns empty string for non-existent CSS variables', () => {
|
|
60
|
+
const testElement = document.createElement('div');
|
|
61
|
+
testElement.className = 'test-theme';
|
|
62
|
+
document.body.append(testElement);
|
|
63
|
+
expect(getThemeTokenValue('test-theme', '--non-existent-var')).toBe('');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DateValue } from '@internationalized/date';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a given DateValue represents today's date
|
|
4
|
+
* @param dateValue
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare function isToday(date: DateValue | string | null | undefined): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Formats a date value or ISO date string for display, with special handling for "today"
|
|
10
|
+
*
|
|
11
|
+
* @param date - DateValue, ISO date string, or null/undefined
|
|
12
|
+
* @param format - Intl date formatting style (default: 'medium')
|
|
13
|
+
* @param locales - Locales for formatting (default: 'en-AU')
|
|
14
|
+
* @returns Formatted date string or empty string for null/undefined
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* displayFormattedDate('2025-05-01') // "May 01, 2025"
|
|
19
|
+
* displayFormattedDate('2024-01-15', 'full') // "Monday, January 15, 2024"
|
|
20
|
+
* displayFormattedDate('2025-09-21', 'short') // "21/9/25"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function displayFormattedDate(date: DateValue | string | null | undefined, format?: Intl.DateTimeFormatOptions['dateStyle'], locales?: Intl.LocalesArgument): string;
|
|
24
|
+
//# sourceMappingURL=dateFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateFormat.d.ts","sourceRoot":"","sources":["../../lib/utils/dateFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,WAUlE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3C,MAAM,GAAE,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAY,EAC1D,OAAO,GAAE,IAAI,CAAC,eAAyB,GACrC,MAAM,CAmBR"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getLocalTimeZone, parseDate, today } from '@internationalized/date';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a given DateValue represents today's date
|
|
7
|
+
* @param dateValue
|
|
8
|
+
* @returns boolean
|
|
9
|
+
*/
|
|
10
|
+
export function isToday(date) {
|
|
11
|
+
if (!date) return false;
|
|
12
|
+
if (typeof date === 'string') {
|
|
13
|
+
try {
|
|
14
|
+
date = parseDate(date);
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return date.compare(today(getLocalTimeZone())) === 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Formats a date value or ISO date string for display, with special handling for "today"
|
|
24
|
+
*
|
|
25
|
+
* @param date - DateValue, ISO date string, or null/undefined
|
|
26
|
+
* @param format - Intl date formatting style (default: 'medium')
|
|
27
|
+
* @param locales - Locales for formatting (default: 'en-AU')
|
|
28
|
+
* @returns Formatted date string or empty string for null/undefined
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* displayFormattedDate('2025-05-01') // "May 01, 2025"
|
|
33
|
+
* displayFormattedDate('2024-01-15', 'full') // "Monday, January 15, 2024"
|
|
34
|
+
* displayFormattedDate('2025-09-21', 'short') // "21/9/25"
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function displayFormattedDate(date, format = 'medium', locales = 'en-AU') {
|
|
38
|
+
if (!date) return '';
|
|
39
|
+
let dateValue;
|
|
40
|
+
|
|
41
|
+
// Handle string input by parsing it
|
|
42
|
+
if (typeof date === 'string') {
|
|
43
|
+
try {
|
|
44
|
+
dateValue = parseDate(date);
|
|
45
|
+
} catch {
|
|
46
|
+
return date; // Return original string if parsing fails
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
dateValue = date;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Format the date using Intl.DateTimeFormat
|
|
53
|
+
const formatter = new Intl.DateTimeFormat(locales, {
|
|
54
|
+
dateStyle: format
|
|
55
|
+
});
|
|
56
|
+
return formatter.format(dateValue.toDate(getLocalTimeZone()));
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.spec.d.ts","sourceRoot":"","sources":["../../lib/utils/object.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayFromKeys } from "./object.js";
|
|
4
|
+
describe('object utilities', () => {
|
|
5
|
+
describe('arrayFromKeys', () => {
|
|
6
|
+
it('returns array of object keys with proper typing', () => {
|
|
7
|
+
const testObj = {
|
|
8
|
+
name: 'John',
|
|
9
|
+
age: 30,
|
|
10
|
+
active: true
|
|
11
|
+
};
|
|
12
|
+
const keys = arrayFromKeys(testObj);
|
|
13
|
+
expect(keys).toEqual(['name', 'age', 'active']);
|
|
14
|
+
expect(keys).toHaveLength(3);
|
|
15
|
+
});
|
|
16
|
+
it('works with empty objects', () => {
|
|
17
|
+
const emptyObj = {};
|
|
18
|
+
const keys = arrayFromKeys(emptyObj);
|
|
19
|
+
expect(keys).toEqual([]);
|
|
20
|
+
expect(keys).toHaveLength(0);
|
|
21
|
+
});
|
|
22
|
+
it('preserves key order', () => {
|
|
23
|
+
const orderedObj = {
|
|
24
|
+
first: 1,
|
|
25
|
+
second: 2,
|
|
26
|
+
third: 3,
|
|
27
|
+
fourth: 4
|
|
28
|
+
};
|
|
29
|
+
const keys = arrayFromKeys(orderedObj);
|
|
30
|
+
expect(keys).toEqual(['first', 'second', 'third', 'fourth']);
|
|
31
|
+
});
|
|
32
|
+
it('works with objects containing different value types', () => {
|
|
33
|
+
const mixedObj = {
|
|
34
|
+
string: 'text',
|
|
35
|
+
number: 42,
|
|
36
|
+
boolean: false,
|
|
37
|
+
array: [1, 2, 3],
|
|
38
|
+
object: {
|
|
39
|
+
nested: true
|
|
40
|
+
},
|
|
41
|
+
nullValue: null,
|
|
42
|
+
undefinedValue: undefined,
|
|
43
|
+
functionValue: () => {}
|
|
44
|
+
};
|
|
45
|
+
const keys = arrayFromKeys(mixedObj);
|
|
46
|
+
expect(keys).toEqual(['string', 'number', 'boolean', 'array', 'object', 'nullValue', 'undefinedValue', 'functionValue']);
|
|
47
|
+
expect(keys).toHaveLength(8);
|
|
48
|
+
});
|
|
49
|
+
it('works with objects having symbol keys (should be excluded)', () => {
|
|
50
|
+
const symbolKey = Symbol('test');
|
|
51
|
+
const objWithSymbol = {
|
|
52
|
+
normalKey: 'value',
|
|
53
|
+
[symbolKey]: 'symbol value'
|
|
54
|
+
};
|
|
55
|
+
const keys = arrayFromKeys(objWithSymbol);
|
|
56
|
+
|
|
57
|
+
// Object.keys() only returns enumerable string keys, not symbols
|
|
58
|
+
expect(keys).toEqual(['normalKey']);
|
|
59
|
+
expect(keys).toHaveLength(1);
|
|
60
|
+
});
|
|
61
|
+
it('works with objects having numeric string keys', () => {
|
|
62
|
+
const numericKeysObj = {
|
|
63
|
+
'0': 'zero',
|
|
64
|
+
'1': 'one',
|
|
65
|
+
'10': 'ten',
|
|
66
|
+
'2': 'two'
|
|
67
|
+
};
|
|
68
|
+
const keys = arrayFromKeys(numericKeysObj);
|
|
69
|
+
|
|
70
|
+
// Object.keys() returns numeric keys in ascending order, then other keys
|
|
71
|
+
expect(keys).toEqual(['0', '1', '2', '10']);
|
|
72
|
+
expect(keys).toHaveLength(4);
|
|
73
|
+
});
|
|
74
|
+
it('works with objects created with null prototype', () => {
|
|
75
|
+
const nullProtoObj = Object.create(null);
|
|
76
|
+
nullProtoObj.key1 = 'value1';
|
|
77
|
+
nullProtoObj.key2 = 'value2';
|
|
78
|
+
const keys = arrayFromKeys(nullProtoObj);
|
|
79
|
+
expect(keys).toEqual(['key1', 'key2']);
|
|
80
|
+
expect(keys).toHaveLength(2);
|
|
81
|
+
});
|
|
82
|
+
it('ignores inherited properties', () => {
|
|
83
|
+
// Create a prototype object
|
|
84
|
+
const proto = {
|
|
85
|
+
inheritedProp: 'inherited'
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Create object that inherits from proto
|
|
89
|
+
const obj = Object.create(proto);
|
|
90
|
+
obj.ownProp1 = 'own1';
|
|
91
|
+
obj.ownProp2 = 'own2';
|
|
92
|
+
const keys = arrayFromKeys(obj);
|
|
93
|
+
|
|
94
|
+
// Should only include own properties, not inherited ones
|
|
95
|
+
expect(keys).toEqual(['ownProp1', 'ownProp2']);
|
|
96
|
+
expect(keys).toHaveLength(2);
|
|
97
|
+
});
|
|
98
|
+
it('works with array-like objects', () => {
|
|
99
|
+
const arrayLikeObj = {
|
|
100
|
+
'0': 'a',
|
|
101
|
+
'1': 'b',
|
|
102
|
+
'2': 'c',
|
|
103
|
+
length: 3
|
|
104
|
+
};
|
|
105
|
+
const keys = arrayFromKeys(arrayLikeObj);
|
|
106
|
+
|
|
107
|
+
// Array-like objects have numeric string keys + length
|
|
108
|
+
expect(keys).toEqual(['0', '1', '2', 'length']);
|
|
109
|
+
expect(keys).toHaveLength(4);
|
|
110
|
+
});
|
|
111
|
+
it('maintains type safety with specific object types', () => {
|
|
112
|
+
const typedObj = {
|
|
113
|
+
prop1: 'test',
|
|
114
|
+
prop2: 123
|
|
115
|
+
};
|
|
116
|
+
const keys = arrayFromKeys(typedObj);
|
|
117
|
+
|
|
118
|
+
// TypeScript should infer the correct key type
|
|
119
|
+
expect(keys).toEqual(['prop1', 'prop2']);
|
|
120
|
+
|
|
121
|
+
// This ensures the return type is properly typed
|
|
122
|
+
const firstKey = keys[0]; // Should be string
|
|
123
|
+
expect(['prop1', 'prop2']).toContain(firstKey);
|
|
124
|
+
});
|
|
125
|
+
it('works with readonly objects', () => {
|
|
126
|
+
const readonlyObj = {
|
|
127
|
+
readonly1: 'value1',
|
|
128
|
+
readonly2: 'value2'
|
|
129
|
+
};
|
|
130
|
+
const keys = arrayFromKeys(readonlyObj);
|
|
131
|
+
expect(keys).toEqual(['readonly1', 'readonly2']);
|
|
132
|
+
expect(keys).toHaveLength(2);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsiveStyle.spec.d.ts","sourceRoot":"","sources":["../../lib/utils/responsiveStyle.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { responsiveStyle } from "./responsiveStyle.js";
|
|
5
|
+
describe('responsiveStyle', () => {
|
|
6
|
+
it('applies mobile styles directly', () => {
|
|
7
|
+
const result = responsiveStyle({
|
|
8
|
+
mobile: {
|
|
9
|
+
color: 'red',
|
|
10
|
+
fontSize: '16px'
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
expect(result).toEqual({
|
|
14
|
+
color: 'red',
|
|
15
|
+
fontSize: '16px'
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
it('wraps non-mobile styles in media queries', () => {
|
|
19
|
+
const result = responsiveStyle({
|
|
20
|
+
tablet: {
|
|
21
|
+
color: 'blue'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
expect(result).toEqual({
|
|
25
|
+
'@media': {
|
|
26
|
+
'screen and (min-width: 768px)': {
|
|
27
|
+
color: 'blue'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
it('combines mobile and responsive styles', () => {
|
|
33
|
+
const result = responsiveStyle({
|
|
34
|
+
mobile: {
|
|
35
|
+
color: 'red',
|
|
36
|
+
fontSize: '14px'
|
|
37
|
+
},
|
|
38
|
+
tablet: {
|
|
39
|
+
fontSize: '16px'
|
|
40
|
+
},
|
|
41
|
+
desktop: {
|
|
42
|
+
color: 'blue'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
expect(result).toEqual({
|
|
46
|
+
color: 'red',
|
|
47
|
+
fontSize: '14px',
|
|
48
|
+
'@media': {
|
|
49
|
+
'screen and (min-width: 768px)': {
|
|
50
|
+
fontSize: '16px'
|
|
51
|
+
},
|
|
52
|
+
'screen and (min-width: 1024px)': {
|
|
53
|
+
color: 'blue'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it('handles multiple media queries', () => {
|
|
59
|
+
const result = responsiveStyle({
|
|
60
|
+
tablet: {
|
|
61
|
+
padding: '16px'
|
|
62
|
+
},
|
|
63
|
+
desktop: {
|
|
64
|
+
padding: '24px'
|
|
65
|
+
},
|
|
66
|
+
largeDesktop: {
|
|
67
|
+
padding: '32px'
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
expect(result).toEqual({
|
|
71
|
+
'@media': {
|
|
72
|
+
'screen and (min-width: 768px)': {
|
|
73
|
+
padding: '16px'
|
|
74
|
+
},
|
|
75
|
+
'screen and (min-width: 1024px)': {
|
|
76
|
+
padding: '24px'
|
|
77
|
+
},
|
|
78
|
+
'screen and (min-width: 1920px)': {
|
|
79
|
+
padding: '32px'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
it('handles empty input', () => {
|
|
85
|
+
const result = responsiveStyle({});
|
|
86
|
+
expect(result).toEqual({});
|
|
87
|
+
});
|
|
88
|
+
it('handles only mobile styles', () => {
|
|
89
|
+
const result = responsiveStyle({
|
|
90
|
+
mobile: {
|
|
91
|
+
margin: '8px',
|
|
92
|
+
padding: '4px'
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
expect(result).toEqual({
|
|
96
|
+
margin: '8px',
|
|
97
|
+
padding: '4px'
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
it('handles only responsive styles', () => {
|
|
101
|
+
const result = responsiveStyle({
|
|
102
|
+
desktop: {
|
|
103
|
+
maxWidth: '1200px'
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
expect(result).toEqual({
|
|
107
|
+
'@media': {
|
|
108
|
+
'screen and (min-width: 1024px)': {
|
|
109
|
+
maxWidth: '1200px'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
it('preserves complex style values', () => {
|
|
115
|
+
const result = responsiveStyle({
|
|
116
|
+
mobile: {
|
|
117
|
+
background: 'linear-gradient(to right, red, blue)',
|
|
118
|
+
transform: 'translateX(10px) scale(1.2)'
|
|
119
|
+
},
|
|
120
|
+
tablet: {
|
|
121
|
+
background: 'radial-gradient(circle, green, yellow)'
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
expect(result).toEqual({
|
|
125
|
+
background: 'linear-gradient(to right, red, blue)',
|
|
126
|
+
transform: 'translateX(10px) scale(1.2)',
|
|
127
|
+
'@media': {
|
|
128
|
+
'screen and (min-width: 768px)': {
|
|
129
|
+
background: 'radial-gradient(circle, green, yellow)'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.spec.d.ts","sourceRoot":"","sources":["../../lib/utils/utils.spec.
|
|
1
|
+
{"version":3,"file":"utils.spec.d.ts","sourceRoot":"","sources":["../../lib/utils/utils.spec.ts"],"names":[],"mappings":""}
|