Skip to content

Commit 719898c

Browse files
committed
fix(Select,ComboBox): wrapperStyles and style props extraction
1 parent 900201f commit 719898c

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

.changeset/young-bears-add.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": minor
3+
---
4+
5+
Add wrapperStyles to Select and ComboBox components and fix style props extraction.

src/components/fields/ComboBox/ComboBox.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { useEvent } from '../../../_internal/index';
2222
import { LoadingIcon } from '../../../icons';
2323
import { useProviderProps } from '../../../provider';
2424
import {
25-
BLOCK_STYLES,
25+
BASE_STYLES,
26+
COLOR_STYLES,
2627
extractStyles,
2728
OUTER_STYLES,
2829
tasty,
@@ -138,6 +139,8 @@ export interface CubeComboBoxProps<T>
138139
allowsCustomValue?: boolean;
139140
}
140141

142+
const PROP_STYLES = [...BASE_STYLES, ...OUTER_STYLES, ...COLOR_STYLES];
143+
141144
export const ComboBox = forwardRef(function ComboBox<T extends object>(
142145
props: CubeComboBoxProps<T>,
143146
ref: ForwardedRef<HTMLDivElement>,
@@ -191,9 +194,10 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
191194
inputStyles,
192195
optionStyles,
193196
triggerStyles,
194-
suffix,
195197
listBoxStyles,
196198
overlayStyles,
199+
wrapperStyles,
200+
suffix,
197201
hideTrigger,
198202
message,
199203
description,
@@ -223,9 +227,7 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
223227
menuTrigger,
224228
});
225229

226-
const outerStyles = extractStyles(otherProps, OUTER_STYLES, styles);
227-
228-
inputStyles = extractStyles(otherProps, BLOCK_STYLES, inputStyles);
230+
styles = extractStyles(otherProps, PROP_STYLES, styles);
229231

230232
ref = useCombinedRefs(ref);
231233
wrapperRef = useCombinedRefs(wrapperRef);
@@ -409,7 +411,7 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
409411
ref={wrapperRef}
410412
qa={qa || 'ComboBox'}
411413
{...modAttrs(mods)}
412-
styles={outerStyles}
414+
styles={wrapperStyles}
413415
style={{
414416
zIndex: isFocused ? 1 : 'initial',
415417
}}

src/components/fields/Select/Select.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ import { LoadingIcon } from '../../../icons/index';
2828
import { useProviderProps } from '../../../provider';
2929
import { FieldBaseProps } from '../../../shared/index';
3030
import {
31+
BASE_STYLES,
3132
BasePropsWithoutChildren,
32-
BLOCK_STYLES,
33-
BlockStyleProps,
33+
BaseStyleProps,
34+
COLOR_STYLES,
35+
ColorStyleProps,
3436
extractStyles,
3537
OUTER_STYLES,
3638
OuterStyleProps,
@@ -244,9 +246,10 @@ const StyledOverlayElement = styled(OverlayElement)`
244246
export interface CubeSelectBaseProps<T>
245247
extends BasePropsWithoutChildren,
246248
AriaLabelingProps,
249+
BaseStyleProps,
247250
OuterStyleProps,
251+
ColorStyleProps,
248252
FieldBaseProps,
249-
BlockStyleProps,
250253
CollectionBase<T>,
251254
AriaSelectProps<T> {
252255
icon?: ReactElement;
@@ -262,6 +265,7 @@ export interface CubeSelectBaseProps<T>
262265
triggerStyles?: Styles;
263266
listBoxStyles?: Styles;
264267
overlayStyles?: Styles;
268+
wrapperStyles?: Styles;
265269
direction?: 'top' | 'bottom';
266270
shouldFlip?: boolean;
267271
inputProps?: Props;
@@ -278,6 +282,8 @@ export interface CubeSelectProps<T> extends CubeSelectBaseProps<T> {
278282
placeholder?: string;
279283
}
280284

285+
const PROP_STYLES = [...BASE_STYLES, ...OUTER_STYLES, ...COLOR_STYLES];
286+
281287
function Select<T extends object>(
282288
props: CubeSelectProps<T>,
283289
ref: DOMRef<HTMLDivElement>,
@@ -313,9 +319,10 @@ function Select<T extends object>(
313319
overlayOffset = 8,
314320
inputStyles,
315321
optionStyles,
316-
suffix,
322+
wrapperStyles,
317323
listBoxStyles,
318324
overlayStyles,
325+
suffix,
319326
message,
320327
description,
321328
direction = 'bottom',
@@ -332,9 +339,8 @@ function Select<T extends object>(
332339
...otherProps
333340
} = props;
334341
let state = useSelectState(props);
335-
const outerStyles = extractStyles(otherProps, OUTER_STYLES, styles);
336342

337-
inputStyles = extractStyles(otherProps, BLOCK_STYLES, inputStyles);
343+
styles = extractStyles(otherProps, PROP_STYLES, styles);
338344

339345
ref = useCombinedRefs(ref);
340346
triggerRef = useCombinedRefs(triggerRef);
@@ -417,7 +423,7 @@ function Select<T extends object>(
417423
<SelectWrapperElement
418424
qa={qa || 'Select'}
419425
mods={modifiers}
420-
styles={outerStyles}
426+
styles={wrapperStyles}
421427
data-size={size}
422428
data-type={type}
423429
data-theme={theme}

0 commit comments

Comments
 (0)