@autoguru/overdrive 4.45.2-next.0 → 4.46.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.
Files changed (43) hide show
  1. package/dist/components/DateTimePicker/CalendarButton.js +2 -2
  2. package/dist/components/DateTimePicker/CalendarGrid.js +2 -2
  3. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +2 -10
  4. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +1 -1
  5. package/dist/components/DateTimePicker/DateTimePicker.css.js +108 -81
  6. package/dist/components/OptionGrid/OptionGrid.css.d.ts +33 -34
  7. package/dist/components/OptionGrid/OptionGrid.css.d.ts.map +1 -1
  8. package/dist/components/OptionGrid/OptionGrid.css.js +208 -146
  9. package/dist/components/OptionGrid/OptionGrid.d.ts +16 -5
  10. package/dist/components/OptionGrid/OptionGrid.d.ts.map +1 -1
  11. package/dist/components/OptionGrid/OptionGrid.js +38 -13
  12. package/dist/components/OptionList/OptionList.css.d.ts +2 -10
  13. package/dist/components/OptionList/OptionList.css.d.ts.map +1 -1
  14. package/dist/components/OptionList/OptionList.css.js +92 -92
  15. package/dist/components/OptionList/OptionList.d.ts +7 -0
  16. package/dist/components/OptionList/OptionList.d.ts.map +1 -1
  17. package/dist/components/OptionList/OptionListItem.js +3 -3
  18. package/dist/components/SearchBar/SearchBar.css.d.ts +7 -12
  19. package/dist/components/SearchBar/SearchBar.css.d.ts.map +1 -1
  20. package/dist/components/SearchBar/SearchBar.css.js +121 -66
  21. package/dist/components/SearchBar/SearchBar.d.ts.map +1 -1
  22. package/dist/components/SearchBar/SearchBar.js +17 -10
  23. package/dist/hooks/useMedia/useMedia.spec.d.ts +2 -0
  24. package/dist/hooks/useMedia/useMedia.spec.d.ts.map +1 -0
  25. package/dist/hooks/useMedia/useMedia.spec.js +288 -0
  26. package/dist/styles/selectors.d.ts +13 -0
  27. package/dist/styles/selectors.d.ts.map +1 -0
  28. package/dist/styles/selectors.js +26 -0
  29. package/dist/utils/css.d.ts +0 -22
  30. package/dist/utils/css.d.ts.map +1 -1
  31. package/dist/utils/css.js +0 -52
  32. package/dist/utils/css.spec.d.ts +2 -0
  33. package/dist/utils/css.spec.d.ts.map +1 -0
  34. package/dist/utils/css.spec.js +66 -0
  35. package/dist/utils/object.spec.d.ts +2 -0
  36. package/dist/utils/object.spec.d.ts.map +1 -0
  37. package/dist/utils/object.spec.js +135 -0
  38. package/dist/utils/responsiveStyle.spec.d.ts +2 -0
  39. package/dist/utils/responsiveStyle.spec.d.ts.map +1 -0
  40. package/dist/utils/responsiveStyle.spec.js +134 -0
  41. package/dist/utils/utils.spec.d.ts.map +1 -1
  42. package/dist/utils/utils.spec.js +342 -0
  43. package/package.json +8 -8
@@ -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.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"utils.spec.d.ts","sourceRoot":"","sources":["../../lib/utils/utils.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,342 @@
1
+ "use strict";
2
+
3
+ import { renderHook, act } from '@testing-library/react';
4
+ import React from 'react';
5
+ import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
6
+ import { useId, setRef, mergeRefs, isHtmlElement, hex2rgba, ownerDocument, ownerWindow, useEventCallback, useUncontrolledState, useInputControlledState, animate, arrayRingLookup } from "./index.js"; // Mock requestAnimationFrame for animate tests
7
+ const mockRequestAnimationFrame = vi.fn();
8
+ const mockCancelAnimationFrame = vi.fn();
9
+ Object.defineProperty(window, 'requestAnimationFrame', {
10
+ writable: true,
11
+ value: mockRequestAnimationFrame
12
+ });
13
+ Object.defineProperty(window, 'cancelAnimationFrame', {
14
+ writable: true,
15
+ value: mockCancelAnimationFrame
16
+ });
17
+ describe('Utils', () => {
18
+ beforeEach(() => {
19
+ vi.clearAllMocks();
20
+ mockRequestAnimationFrame.mockClear();
21
+ mockCancelAnimationFrame.mockClear();
22
+ });
23
+ afterEach(() => {
24
+ vi.restoreAllMocks();
25
+ });
26
+ describe('useId', () => {
27
+ it('generates unique IDs', () => {
28
+ const {
29
+ result: result1
30
+ } = renderHook(() => useId());
31
+ const {
32
+ result: result2
33
+ } = renderHook(() => useId());
34
+ expect(result1.current).toBeTruthy();
35
+ expect(result2.current).toBeTruthy();
36
+ expect(result1.current).not.toBe(result2.current);
37
+ });
38
+ it('generates consistent ID for same hook instance', () => {
39
+ const {
40
+ result,
41
+ rerender
42
+ } = renderHook(() => useId());
43
+ const firstId = result.current;
44
+ rerender();
45
+ expect(result.current).toBe(firstId);
46
+ });
47
+ it('uses provided prefix', () => {
48
+ const {
49
+ result
50
+ } = renderHook(() => useId('test-prefix'));
51
+ expect(result.current).toContain('test-prefix');
52
+ });
53
+ });
54
+ describe('setRef', () => {
55
+ it('sets ref object current value', () => {
56
+ const refObject = {
57
+ current: null
58
+ };
59
+ const value = document.createElement('div');
60
+ setRef(refObject, value);
61
+ expect(refObject.current).toBe(value);
62
+ });
63
+ it('calls ref function', () => {
64
+ const refFunction = vi.fn();
65
+ const value = document.createElement('div');
66
+ setRef(refFunction, value);
67
+ expect(refFunction).toHaveBeenCalledWith(value);
68
+ });
69
+ it('handles null ref gracefully', () => {
70
+ const value = document.createElement('div');
71
+ expect(() => setRef(null, value)).not.toThrow();
72
+ });
73
+ it('handles undefined ref gracefully', () => {
74
+ const value = document.createElement('div');
75
+ expect(() => setRef(undefined, value)).not.toThrow();
76
+ });
77
+ });
78
+ describe('mergeRefs', () => {
79
+ it('merges ref objects', () => {
80
+ const ref1 = /*#__PURE__*/React.createRef();
81
+ const ref2 = /*#__PURE__*/React.createRef();
82
+ const value = document.createElement('div');
83
+ const mergedRef = mergeRefs([ref1, ref2]);
84
+ mergedRef(value);
85
+ expect(ref1.current).toBe(value);
86
+ expect(ref2.current).toBe(value);
87
+ });
88
+ it('merges ref functions', () => {
89
+ const ref1 = vi.fn();
90
+ const ref2 = vi.fn();
91
+ const value = document.createElement('div');
92
+ const mergedRef = mergeRefs([ref1, ref2]);
93
+ mergedRef(value);
94
+ expect(ref1).toHaveBeenCalledWith(value);
95
+ expect(ref2).toHaveBeenCalledWith(value);
96
+ });
97
+ it('handles mixed ref types', () => {
98
+ const refObject = /*#__PURE__*/React.createRef();
99
+ const refFunction = vi.fn();
100
+ const value = document.createElement('div');
101
+ const mergedRef = mergeRefs([refObject, refFunction]);
102
+ mergedRef(value);
103
+ expect(refObject.current).toBe(value);
104
+ expect(refFunction).toHaveBeenCalledWith(value);
105
+ });
106
+ it('handles null and undefined refs', () => {
107
+ const ref = /*#__PURE__*/React.createRef();
108
+ const value = document.createElement('div');
109
+ const mergedRef = mergeRefs([ref, null, undefined]);
110
+ expect(() => mergedRef(value)).not.toThrow();
111
+ expect(ref.current).toBe(value);
112
+ });
113
+ });
114
+ describe('isHtmlElement', () => {
115
+ it('returns true for Element instances', () => {
116
+ const div = document.createElement('div');
117
+ expect(isHtmlElement(div)).toBe(true);
118
+ });
119
+ it('returns true for Document instances', () => {
120
+ expect(isHtmlElement(document)).toBe(true);
121
+ });
122
+ it('returns false for non-DOM objects', () => {
123
+ expect(isHtmlElement({})).toBe(false);
124
+ expect(isHtmlElement('string')).toBe(false);
125
+ expect(isHtmlElement(123)).toBe(false);
126
+ expect(isHtmlElement(null)).toBe(false);
127
+ let undefinedValue;
128
+ expect(isHtmlElement(undefinedValue)).toBe(false);
129
+ });
130
+ });
131
+ describe('hex2rgba', () => {
132
+ it('converts hex color to rgba', () => {
133
+ expect(hex2rgba('#ff0000')).toBe('rgb(255,0,0,1)');
134
+ expect(hex2rgba('#00ff00')).toBe('rgb(0,255,0,1)');
135
+ expect(hex2rgba('#0000ff')).toBe('rgb(0,0,255,1)');
136
+ });
137
+ it('handles custom alpha values', () => {
138
+ expect(hex2rgba('#ff0000', '0.5')).toBe('rgb(255,0,0,0.5)');
139
+ expect(hex2rgba('#000000', '0')).toBe('rgb(0,0,0,0)');
140
+ });
141
+ it('handles uppercase hex values', () => {
142
+ expect(hex2rgba('#FF0000')).toBe('rgb(255,0,0,1)');
143
+ });
144
+ it('handles mixed case hex values', () => {
145
+ expect(hex2rgba('#Ff00Aa')).toBe('rgb(255,0,170,1)');
146
+ });
147
+ });
148
+ describe('ownerDocument', () => {
149
+ it('returns node ownerDocument when available', () => {
150
+ const div = document.createElement('div');
151
+ expect(ownerDocument(div)).toBe(document);
152
+ });
153
+ it('returns global document when node is undefined', () => {
154
+ expect(ownerDocument()).toBe(document);
155
+ });
156
+ it('returns global document when node has no ownerDocument', () => {
157
+ const nodeWithoutOwner = {
158
+ ownerDocument: null
159
+ };
160
+ expect(ownerDocument(nodeWithoutOwner)).toBe(document);
161
+ });
162
+ });
163
+ describe('ownerWindow', () => {
164
+ it('returns window from node ownerDocument', () => {
165
+ const div = document.createElement('div');
166
+ expect(ownerWindow(div)).toBe(window);
167
+ });
168
+ it('returns global window when node is undefined', () => {
169
+ expect(ownerWindow()).toBe(window);
170
+ });
171
+ });
172
+ describe('useEventCallback', () => {
173
+ it('returns a stable callback function', () => {
174
+ const fn = vi.fn();
175
+ const {
176
+ result,
177
+ rerender
178
+ } = renderHook(() => useEventCallback(fn));
179
+ const callback1 = result.current;
180
+ rerender();
181
+ const callback2 = result.current;
182
+ expect(callback1).toBe(callback2);
183
+ });
184
+ it('calls the latest version of the function', () => {
185
+ let fn = vi.fn();
186
+ const {
187
+ result,
188
+ rerender
189
+ } = renderHook(({
190
+ fn
191
+ }) => useEventCallback(fn), {
192
+ initialProps: {
193
+ fn
194
+ }
195
+ });
196
+
197
+ // Call initial version
198
+ result.current('test1');
199
+ expect(fn).toHaveBeenCalledWith('test1');
200
+
201
+ // Update function and rerender
202
+ fn = vi.fn();
203
+ rerender({
204
+ fn
205
+ });
206
+
207
+ // Call updated version
208
+ result.current('test2');
209
+ expect(fn).toHaveBeenCalledWith('test2');
210
+ });
211
+ });
212
+ describe('useUncontrolledState', () => {
213
+ it('returns controlled state when onChange is provided', () => {
214
+ const onChange = vi.fn();
215
+ const {
216
+ result
217
+ } = renderHook(() => useUncontrolledState('test', onChange));
218
+ const [value, setter] = result.current;
219
+ expect(value).toBe('test');
220
+ expect(setter).toBe(onChange);
221
+ });
222
+ it('returns uncontrolled state when onChange is not provided', () => {
223
+ const {
224
+ result
225
+ } = renderHook(() => useUncontrolledState('test'));
226
+ const [value, setter] = result.current;
227
+ expect(value).toBe('test');
228
+ expect(typeof setter).toBe('function');
229
+ expect(setter).not.toBe(undefined);
230
+ });
231
+ it('updates uncontrolled state when setter is called', () => {
232
+ const {
233
+ result
234
+ } = renderHook(() => useUncontrolledState('initial'));
235
+ const [, setter] = result.current;
236
+ act(() => {
237
+ setter('updated');
238
+ });
239
+ const [newValue] = result.current;
240
+ expect(newValue).toBe('updated');
241
+ });
242
+ });
243
+ describe('useInputControlledState', () => {
244
+ it('returns controlled state when onChange is provided', () => {
245
+ const onChange = vi.fn();
246
+ const {
247
+ result
248
+ } = renderHook(() => useInputControlledState('test', onChange));
249
+ const [value, handler] = result.current;
250
+ expect(value).toBe('test');
251
+ expect(handler).toBe(onChange);
252
+ });
253
+ it('returns uncontrolled state when onChange is not provided', () => {
254
+ const {
255
+ result
256
+ } = renderHook(() => useInputControlledState('test'));
257
+ const [value, handler] = result.current;
258
+ expect(value).toBe('test');
259
+ expect(typeof handler).toBe('function');
260
+ });
261
+ it('handles input events in uncontrolled mode', () => {
262
+ const {
263
+ result
264
+ } = renderHook(() => useInputControlledState('initial'));
265
+ const [, handler] = result.current;
266
+
267
+ // Simulate input event
268
+ const event = {
269
+ target: {
270
+ value: 'new value'
271
+ }
272
+ };
273
+ act(() => {
274
+ handler(event);
275
+ });
276
+ const [newValue] = result.current;
277
+ expect(newValue).toBe('new value');
278
+ });
279
+ });
280
+ describe('animate', () => {
281
+ beforeEach(() => {
282
+ // Mock performance.now for consistent testing
283
+ vi.spyOn(performance, 'now').mockReturnValue(0);
284
+ });
285
+ it('returns cancellation function', () => {
286
+ const element = {
287
+ scrollTop: 0
288
+ };
289
+ const cancel = animate(element, 'scrollTop', 100);
290
+ expect(typeof cancel).toBe('function');
291
+ });
292
+ it('starts animation with requestAnimationFrame', () => {
293
+ const element = {
294
+ scrollTop: 0
295
+ };
296
+ animate(element, 'scrollTop', 100);
297
+ expect(mockRequestAnimationFrame).toHaveBeenCalled();
298
+ });
299
+ });
300
+ describe('arrayRingLookup', () => {
301
+ const array = ['a', 'b', 'c'];
302
+ it('returns function that looks up array values', () => {
303
+ const lookup = arrayRingLookup(array);
304
+ expect(typeof lookup).toBe('function');
305
+ });
306
+ it('handles positive indices', () => {
307
+ const lookup = arrayRingLookup(array);
308
+ expect(lookup(0)).toBe('a');
309
+ expect(lookup(1)).toBe('b');
310
+ expect(lookup(2)).toBe('c');
311
+ });
312
+ it('wraps around for indices beyond array length', () => {
313
+ const lookup = arrayRingLookup(array);
314
+ expect(lookup(3)).toBe('a');
315
+ expect(lookup(4)).toBe('b');
316
+ expect(lookup(5)).toBe('c');
317
+ });
318
+ it('handles negative indices', () => {
319
+ const lookup = arrayRingLookup(array);
320
+ expect(lookup(-1)).toBe('c');
321
+ expect(lookup(-2)).toBe('b');
322
+ expect(lookup(-3)).toBe('a');
323
+ });
324
+ it('handles large negative indices', () => {
325
+ const lookup = arrayRingLookup(array);
326
+ expect(lookup(-4)).toBe('c');
327
+ expect(lookup(-5)).toBe('b');
328
+ });
329
+ it('handles empty arrays', () => {
330
+ const lookup = arrayRingLookup([]);
331
+ expect(lookup(0)).toBeUndefined();
332
+ expect(lookup(1)).toBeUndefined();
333
+ expect(lookup(-1)).toBeUndefined();
334
+ });
335
+ it('handles single element arrays', () => {
336
+ const lookup = arrayRingLookup(['only']);
337
+ expect(lookup(0)).toBe('only');
338
+ expect(lookup(1)).toBe('only');
339
+ expect(lookup(-1)).toBe('only');
340
+ });
341
+ });
342
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.45.2-next.0",
3
+ "version": "4.46.0",
4
4
  "description": "Overdrive is a product component library, and design system for AutoGuru.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -81,10 +81,10 @@
81
81
  "@babel/runtime-corejs3": "7.28.3",
82
82
  "@changesets/cli": "2.29.6",
83
83
  "@chromatic-com/storybook": "4.1.1",
84
- "@internationalized/date": "3.8.2",
84
+ "@internationalized/date": "3.9.0",
85
85
  "@octokit/rest": "22.0.0",
86
86
  "@popperjs/core": "2.11.8",
87
- "@react-stately/toggle": "3.8.5",
87
+ "@react-stately/toggle": "3.9.1",
88
88
  "@storybook/addon-a11y": "9.1.3",
89
89
  "@storybook/addon-docs": "9.1.3",
90
90
  "@storybook/addon-links": "9.1.3",
@@ -139,13 +139,13 @@
139
139
  "prop-types": "15.8.1",
140
140
  "rand-seed": "3.0.0",
141
141
  "react": "19.1.1",
142
- "react-aria": "3.41.1",
143
- "react-aria-components": "1.10.1",
142
+ "react-aria": "3.43.1",
143
+ "react-aria-components": "1.12.1",
144
144
  "react-dom": "19.1.1",
145
145
  "react-focus-lock": "2.13.6",
146
146
  "react-intersection-observer": "9.16.0",
147
147
  "react-keyed-flatten-children": "5.0.1",
148
- "react-stately": "3.39.0",
148
+ "react-stately": "3.41.0",
149
149
  "react-swipeable": "7.0.2",
150
150
  "rollup-plugin-visualizer": "6.0.3",
151
151
  "storybook": "9.1.3",
@@ -168,7 +168,7 @@
168
168
  "csstype": "^3.1.3",
169
169
  "es-toolkit": "^1.34.1",
170
170
  "react": ">=18 || >=19.0.0-rc.0",
171
- "react-aria": "^3.38.1",
171
+ "react-aria": "^3.43.1",
172
172
  "react-dom": ">=18 || >=19.0.0-rc.0",
173
173
  "react-focus-lock": "^2.13.6",
174
174
  "react-intersection-observer": ">=9.16.0",
@@ -177,7 +177,7 @@
177
177
  "webpack": "*"
178
178
  },
179
179
  "volta": {
180
- "node": "22.18.0",
180
+ "node": "22.19.0",
181
181
  "yarn": "4.9.4"
182
182
  },
183
183
  "packageManager": "yarn@4.9.4"