@autoguru/overdrive 4.43.8 → 4.43.9
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/styles/componentStyles.d.ts +1 -1
- package/dist/styles/componentStyles.d.ts.map +1 -1
- package/dist/styles/componentStyles.js +2 -3
- package/dist/styles/componentStyles.spec.d.ts +2 -0
- package/dist/styles/componentStyles.spec.d.ts.map +1 -0
- package/dist/styles/componentStyles.spec.js +247 -0
- package/package.json +16 -16
|
@@ -3,7 +3,7 @@ import type { ElementType, ReactElement } from 'react';
|
|
|
3
3
|
import { type ResetVariantProps } from './elementReset.css';
|
|
4
4
|
import { type Sprinkles } from './sprinkles.css';
|
|
5
5
|
type ResetPropsWithoutAs = Omit<ResetVariantProps, 'as'>;
|
|
6
|
-
export declare const resetStyles: (element:
|
|
6
|
+
export declare const resetStyles: (element: unknown, options?: ResetPropsWithoutAs) => string;
|
|
7
7
|
export interface ComponentStylesProps extends Sprinkles {
|
|
8
8
|
as?: string | ElementType | ReactElement;
|
|
9
9
|
className?: ClassName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentStyles.d.ts","sourceRoot":"","sources":["../../lib/styles/componentStyles.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,UAAU,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5D,KAAK,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAuCzD,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"componentStyles.d.ts","sourceRoot":"","sources":["../../lib/styles/componentStyles.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,UAAU,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5D,KAAK,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAuCzD,eAAO,MAAM,WAAW,GACvB,SAAS,OAAO,EAChB,UAAU,mBAAmB,WAW7B,CAAC;AAEF,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACtD,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;IACzC,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB;AAWD,eAAO,MAAM,eAAe,GAAI,kCAI7B,oBAAoB,WAKrB,CAAC"}
|
|
@@ -7,6 +7,7 @@ import { elementReset, resetVariants } from "./elementReset.css.js";
|
|
|
7
7
|
import { sprinkles } from "./sprinkles.css.js";
|
|
8
8
|
const hasBorderRelatedProp = props => Boolean(props.borderColor || props.borderStyle || props.borderWidth || props.borderWidthX || props.borderWidthY || props.borderBottomColor || props.borderBottomStyle || props.borderBottomWidth || props.borderLeftColor || props.borderLeftStyle || props.borderLeftWidth || props.borderRightColor || props.borderRightStyle || props.borderRightWidth || props.borderTopColor || props.borderTopStyle || props.borderTopWidth || props.borderWidthTop || props.borderWidthRight || props.borderWidthBottom || props.borderWidthLeft || props.borderColour || props.borderColourX || props.borderColourY || props.borderBottomColour || props.borderLeftColour || props.borderRightColour || props.borderTopColour);
|
|
9
9
|
export const resetStyles = (element, options) => {
|
|
10
|
+
if (typeof element !== 'string') return '';
|
|
10
11
|
const as = element in elementReset ? element : undefined;
|
|
11
12
|
return resetVariants({
|
|
12
13
|
as,
|
|
@@ -19,9 +20,7 @@ export const componentStyles = _ref => {
|
|
|
19
20
|
className
|
|
20
21
|
} = _ref,
|
|
21
22
|
styleProps = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
-
if (typeof as !== 'string') return clsx(className);
|
|
23
|
-
const hasBorder = hasBorderRelatedProp(styleProps);
|
|
24
23
|
return clsx(resetStyles(as, {
|
|
25
|
-
hasBorder
|
|
24
|
+
hasBorder: hasBorderRelatedProp(styleProps)
|
|
26
25
|
}), sprinkles(styleProps), className);
|
|
27
26
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentStyles.spec.d.ts","sourceRoot":"","sources":["../../lib/styles/componentStyles.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
import { componentStyles } from "./componentStyles.js";
|
|
8
|
+
const MOCK_CLASS_NAME = 'custom-class';
|
|
9
|
+
const MockComponent = () => null;
|
|
10
|
+
const createMockSprinklesProps = props => props;
|
|
11
|
+
describe('componentStyles', () => {
|
|
12
|
+
describe('with no props', () => {
|
|
13
|
+
it('should return empty string when no props are provided', () => {
|
|
14
|
+
const result = componentStyles({});
|
|
15
|
+
expect(result).toBe('');
|
|
16
|
+
});
|
|
17
|
+
it('should return empty string when only non-string as prop is provided', () => {
|
|
18
|
+
const result = componentStyles({
|
|
19
|
+
as: MockComponent
|
|
20
|
+
});
|
|
21
|
+
expect(result).toBe('');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('with className only', () => {
|
|
25
|
+
it('should return the className when only className is provided', () => {
|
|
26
|
+
const result = componentStyles({
|
|
27
|
+
className: MOCK_CLASS_NAME
|
|
28
|
+
});
|
|
29
|
+
expect(result).toBe(MOCK_CLASS_NAME);
|
|
30
|
+
});
|
|
31
|
+
it('should return the className when className and non-string as prop are provided', () => {
|
|
32
|
+
const result = componentStyles({
|
|
33
|
+
className: MOCK_CLASS_NAME,
|
|
34
|
+
as: MockComponent
|
|
35
|
+
});
|
|
36
|
+
expect(result).toBe(MOCK_CLASS_NAME);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('with as prop', () => {
|
|
40
|
+
it('should return styles with length when as prop is a valid HTML element', () => {
|
|
41
|
+
const result = componentStyles({
|
|
42
|
+
as: 'div'
|
|
43
|
+
});
|
|
44
|
+
expect(typeof result).toBe('string');
|
|
45
|
+
expect(result.length).toBeGreaterThan(0);
|
|
46
|
+
});
|
|
47
|
+
it('should return styles with length when as prop is a known element with reset styles', () => {
|
|
48
|
+
const result = componentStyles({
|
|
49
|
+
as: 'button'
|
|
50
|
+
});
|
|
51
|
+
expect(typeof result).toBe('string');
|
|
52
|
+
expect(result.length).toBeGreaterThan(0);
|
|
53
|
+
});
|
|
54
|
+
it('should return styles with length when as prop is an unknown element', () => {
|
|
55
|
+
const result = componentStyles({
|
|
56
|
+
as: 'custom-element'
|
|
57
|
+
});
|
|
58
|
+
expect(typeof result).toBe('string');
|
|
59
|
+
expect(result.length).toBeGreaterThan(0);
|
|
60
|
+
});
|
|
61
|
+
it('should return only className when as prop is not a string', () => {
|
|
62
|
+
const result = componentStyles({
|
|
63
|
+
as: MockComponent,
|
|
64
|
+
className: 'test-class'
|
|
65
|
+
});
|
|
66
|
+
expect(result).toBe('test-class');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('with style props', () => {
|
|
70
|
+
it('should return styles with length when padding prop is provided', () => {
|
|
71
|
+
const result = componentStyles(_objectSpread({}, createMockSprinklesProps({
|
|
72
|
+
padding: '4'
|
|
73
|
+
})));
|
|
74
|
+
expect(typeof result).toBe('string');
|
|
75
|
+
expect(result.length).toBeGreaterThan(0);
|
|
76
|
+
});
|
|
77
|
+
it('should return styles with length when margin prop is provided', () => {
|
|
78
|
+
const result = componentStyles(_objectSpread({}, createMockSprinklesProps({
|
|
79
|
+
margin: '2'
|
|
80
|
+
})));
|
|
81
|
+
expect(typeof result).toBe('string');
|
|
82
|
+
expect(result.length).toBeGreaterThan(0);
|
|
83
|
+
});
|
|
84
|
+
it('should return styles with length when multiple style props are provided', () => {
|
|
85
|
+
const result = componentStyles(_objectSpread({}, createMockSprinklesProps({
|
|
86
|
+
padding: '4',
|
|
87
|
+
margin: '2',
|
|
88
|
+
backgroundColor: 'transparent'
|
|
89
|
+
})));
|
|
90
|
+
expect(typeof result).toBe('string');
|
|
91
|
+
expect(result.length).toBeGreaterThan(0);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('with border props', () => {
|
|
95
|
+
it('should return styles with length when borderColor is provided', () => {
|
|
96
|
+
const result = componentStyles(_objectSpread({
|
|
97
|
+
as: 'div'
|
|
98
|
+
}, createMockSprinklesProps({
|
|
99
|
+
borderColor: 'default'
|
|
100
|
+
})));
|
|
101
|
+
expect(typeof result).toBe('string');
|
|
102
|
+
expect(result.length).toBeGreaterThan(0);
|
|
103
|
+
});
|
|
104
|
+
it('should return styles with length when borderWidth is provided', () => {
|
|
105
|
+
const result = componentStyles(_objectSpread({
|
|
106
|
+
as: 'div'
|
|
107
|
+
}, createMockSprinklesProps({
|
|
108
|
+
borderWidth: '1'
|
|
109
|
+
})));
|
|
110
|
+
expect(typeof result).toBe('string');
|
|
111
|
+
expect(result.length).toBeGreaterThan(0);
|
|
112
|
+
});
|
|
113
|
+
it('should return styles with length when borderStyle is provided', () => {
|
|
114
|
+
const result = componentStyles(_objectSpread({
|
|
115
|
+
as: 'div'
|
|
116
|
+
}, createMockSprinklesProps({
|
|
117
|
+
borderStyle: 'solid'
|
|
118
|
+
})));
|
|
119
|
+
expect(typeof result).toBe('string');
|
|
120
|
+
expect(result.length).toBeGreaterThan(0);
|
|
121
|
+
});
|
|
122
|
+
it('should return styles with length when specific border side props are provided', () => {
|
|
123
|
+
const result = componentStyles(_objectSpread({
|
|
124
|
+
as: 'div'
|
|
125
|
+
}, createMockSprinklesProps({
|
|
126
|
+
borderTopColor: 'default',
|
|
127
|
+
borderBottomWidth: '2'
|
|
128
|
+
})));
|
|
129
|
+
expect(typeof result).toBe('string');
|
|
130
|
+
expect(result.length).toBeGreaterThan(0);
|
|
131
|
+
});
|
|
132
|
+
it('should return styles with length when legacy border colour props are provided', () => {
|
|
133
|
+
const result = componentStyles(_objectSpread({
|
|
134
|
+
as: 'div'
|
|
135
|
+
}, createMockSprinklesProps({
|
|
136
|
+
borderColour: 'gray'
|
|
137
|
+
})));
|
|
138
|
+
expect(typeof result).toBe('string');
|
|
139
|
+
expect(result.length).toBeGreaterThan(0);
|
|
140
|
+
});
|
|
141
|
+
it('should return styles with length when borderColourX is provided', () => {
|
|
142
|
+
const result = componentStyles(_objectSpread({
|
|
143
|
+
as: 'div'
|
|
144
|
+
}, createMockSprinklesProps({
|
|
145
|
+
borderColourX: 'light'
|
|
146
|
+
})));
|
|
147
|
+
expect(typeof result).toBe('string');
|
|
148
|
+
expect(result.length).toBeGreaterThan(0);
|
|
149
|
+
});
|
|
150
|
+
it('should return styles with length when borderColourY is provided', () => {
|
|
151
|
+
const result = componentStyles(_objectSpread({
|
|
152
|
+
as: 'div'
|
|
153
|
+
}, createMockSprinklesProps({
|
|
154
|
+
borderColourY: 'dark'
|
|
155
|
+
})));
|
|
156
|
+
expect(typeof result).toBe('string');
|
|
157
|
+
expect(result.length).toBeGreaterThan(0);
|
|
158
|
+
});
|
|
159
|
+
it('should return styles with length when specific side borderColour props are provided', () => {
|
|
160
|
+
const result = componentStyles(_objectSpread({
|
|
161
|
+
as: 'div'
|
|
162
|
+
}, createMockSprinklesProps({
|
|
163
|
+
borderTopColour: 'primary',
|
|
164
|
+
borderLeftColour: 'secondary'
|
|
165
|
+
})));
|
|
166
|
+
expect(typeof result).toBe('string');
|
|
167
|
+
expect(result.length).toBeGreaterThan(0);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('with combined props', () => {
|
|
171
|
+
it('should return styles with length when as, className, and style props are provided', () => {
|
|
172
|
+
const result = componentStyles(_objectSpread({
|
|
173
|
+
as: 'div',
|
|
174
|
+
className: MOCK_CLASS_NAME
|
|
175
|
+
}, createMockSprinklesProps({
|
|
176
|
+
padding: '4',
|
|
177
|
+
borderColor: 'default'
|
|
178
|
+
})));
|
|
179
|
+
expect(typeof result).toBe('string');
|
|
180
|
+
expect(result.length).toBeGreaterThan(0);
|
|
181
|
+
});
|
|
182
|
+
it('should return styles with length when complex combination of props is provided', () => {
|
|
183
|
+
const result = componentStyles(_objectSpread({
|
|
184
|
+
as: 'section',
|
|
185
|
+
className: 'complex-component'
|
|
186
|
+
}, createMockSprinklesProps({
|
|
187
|
+
padding: '8',
|
|
188
|
+
margin: '4',
|
|
189
|
+
backgroundColor: 'transparent',
|
|
190
|
+
borderTopWidth: '1',
|
|
191
|
+
borderTopColor: 'default',
|
|
192
|
+
borderBottomColour: 'primary'
|
|
193
|
+
})));
|
|
194
|
+
expect(typeof result).toBe('string');
|
|
195
|
+
expect(result.length).toBeGreaterThan(0);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
describe('edge cases', () => {
|
|
199
|
+
it('should handle undefined className', () => {
|
|
200
|
+
const result = componentStyles({
|
|
201
|
+
as: 'span',
|
|
202
|
+
className: undefined
|
|
203
|
+
});
|
|
204
|
+
expect(typeof result).toBe('string');
|
|
205
|
+
expect(result.length).toBeGreaterThan(0);
|
|
206
|
+
});
|
|
207
|
+
it('should handle null className', () => {
|
|
208
|
+
const result = componentStyles({
|
|
209
|
+
as: 'section',
|
|
210
|
+
className: null
|
|
211
|
+
});
|
|
212
|
+
expect(typeof result).toBe('string');
|
|
213
|
+
expect(result.length).toBeGreaterThan(0);
|
|
214
|
+
});
|
|
215
|
+
it('should handle array className', () => {
|
|
216
|
+
const result = componentStyles({
|
|
217
|
+
as: 'ul',
|
|
218
|
+
className: ['class1', 'class2']
|
|
219
|
+
});
|
|
220
|
+
expect(typeof result).toBe('string');
|
|
221
|
+
expect(result.length).toBeGreaterThan(0);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
describe('type safety', () => {
|
|
225
|
+
it('should accept all optional props', () => {
|
|
226
|
+
expect(() => {
|
|
227
|
+
componentStyles({});
|
|
228
|
+
componentStyles({
|
|
229
|
+
as: 'div'
|
|
230
|
+
});
|
|
231
|
+
componentStyles({
|
|
232
|
+
className: 'test'
|
|
233
|
+
});
|
|
234
|
+
componentStyles(createMockSprinklesProps({
|
|
235
|
+
padding: '4'
|
|
236
|
+
}));
|
|
237
|
+
componentStyles(_objectSpread({
|
|
238
|
+
as: 'div',
|
|
239
|
+
className: 'test'
|
|
240
|
+
}, createMockSprinklesProps({
|
|
241
|
+
padding: '4',
|
|
242
|
+
borderColor: 'default'
|
|
243
|
+
})));
|
|
244
|
+
}).not.toThrow();
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autoguru/overdrive",
|
|
3
|
-
"version": "4.43.
|
|
3
|
+
"version": "4.43.9",
|
|
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",
|
|
@@ -87,18 +87,18 @@
|
|
|
87
87
|
"@babel/preset-react": "7.27.1",
|
|
88
88
|
"@babel/preset-typescript": "7.27.1",
|
|
89
89
|
"@babel/runtime-corejs3": "7.27.6",
|
|
90
|
-
"@changesets/cli": "2.29.
|
|
91
|
-
"@chromatic-com/storybook": "4.0.
|
|
90
|
+
"@changesets/cli": "2.29.5",
|
|
91
|
+
"@chromatic-com/storybook": "4.0.1",
|
|
92
92
|
"@internationalized/date": "^3.8.2",
|
|
93
93
|
"@octokit/rest": "^22.0.0",
|
|
94
94
|
"@popperjs/core": "^2.11.8",
|
|
95
95
|
"@react-stately/toggle": "^3.8.5",
|
|
96
|
-
"@storybook/addon-a11y": "9.0.
|
|
97
|
-
"@storybook/addon-docs": "9.0.
|
|
98
|
-
"@storybook/addon-links": "9.0.
|
|
99
|
-
"@storybook/addon-onboarding": "9.0.
|
|
100
|
-
"@storybook/addon-vitest": "9.0.
|
|
101
|
-
"@storybook/react-vite": "9.0.
|
|
96
|
+
"@storybook/addon-a11y": "9.0.12",
|
|
97
|
+
"@storybook/addon-docs": "9.0.12",
|
|
98
|
+
"@storybook/addon-links": "9.0.12",
|
|
99
|
+
"@storybook/addon-onboarding": "9.0.12",
|
|
100
|
+
"@storybook/addon-vitest": "9.0.12",
|
|
101
|
+
"@storybook/react-vite": "9.0.12",
|
|
102
102
|
"@testing-library/dom": "^10.4.0",
|
|
103
103
|
"@testing-library/jest-dom": "^6.6.3",
|
|
104
104
|
"@testing-library/react": "^16.3.0",
|
|
@@ -116,23 +116,23 @@
|
|
|
116
116
|
"@vanilla-extract/sprinkles": "^1.6.5",
|
|
117
117
|
"@vanilla-extract/vite-plugin": "^5.0.6",
|
|
118
118
|
"@vanilla-extract/webpack-plugin": "^2.3.22",
|
|
119
|
-
"@vitest/browser": "3.2.
|
|
120
|
-
"@vitest/coverage-v8": "3.2.
|
|
119
|
+
"@vitest/browser": "3.2.4",
|
|
120
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
121
121
|
"@vitest/eslint-plugin": "1.2.7",
|
|
122
122
|
"babel-plugin-add-import-extension": "^1.6.0",
|
|
123
123
|
"babel-plugin-dev-expression": "^0.2.3",
|
|
124
124
|
"babel-plugin-macros": "^3.1.0",
|
|
125
125
|
"browserslist-config-autoguru": "^2.4.4",
|
|
126
|
-
"chromatic": "13.0.
|
|
126
|
+
"chromatic": "13.0.1",
|
|
127
127
|
"clsx": "^2.1.1",
|
|
128
128
|
"colord": "^2.9.3",
|
|
129
129
|
"concurrently": "^9.1.2",
|
|
130
130
|
"core-js": "^3.43.0",
|
|
131
131
|
"csstype": "^3.1.3",
|
|
132
132
|
"deepmerge": "^4.3.1",
|
|
133
|
-
"es-toolkit": "1.39.
|
|
133
|
+
"es-toolkit": "1.39.4",
|
|
134
134
|
"eslint": "9.29.0",
|
|
135
|
-
"eslint-plugin-storybook": "9.0.
|
|
135
|
+
"eslint-plugin-storybook": "9.0.12",
|
|
136
136
|
"husky": "^9.1.7",
|
|
137
137
|
"intersection-observer": "^0.12.2",
|
|
138
138
|
"jsdom": "26.1.0",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"magic-string": "^0.30.17",
|
|
141
141
|
"mini-css-extract-plugin": "^2.9.2",
|
|
142
142
|
"mockdate": "^3.0.5",
|
|
143
|
-
"playwright": "
|
|
143
|
+
"playwright": "1.53.1",
|
|
144
144
|
"plop": "^4.0.1",
|
|
145
145
|
"postcss": "^8.5.6",
|
|
146
146
|
"prettier": "^3.5.3",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"react-stately": "^3.39.0",
|
|
157
157
|
"react-swipeable": "^7.0.2",
|
|
158
158
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
159
|
-
"storybook": "9.0.
|
|
159
|
+
"storybook": "9.0.12",
|
|
160
160
|
"storybook-addon-tag-badges": "^2.0.1",
|
|
161
161
|
"typescript": "5.8.3",
|
|
162
162
|
"url-loader": "^4.1.1",
|