Skip to content

Commit 12c317f

Browse files
committed
fix: multiple minor fixes
1 parent ddfe630 commit 12c317f

File tree

12 files changed

+78
-45
lines changed

12 files changed

+78
-45
lines changed

.changeset/cyan-clouds-juggle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Fix warning about incorrectly rendered component in SliderBase.

.changeset/itchy-guests-dress.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Correctly pass focusWithinProps in Slider.

.changeset/modern-bees-push.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Do not pass invalid isDisabled prop in Action.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { StoryFn } from '@storybook/react';
2+
3+
import { baseProps } from '../../../stories/lists/baseProps';
4+
5+
import { Action, CubeActionProps } from './Action';
6+
7+
export default {
8+
title: 'Actions/Action',
9+
component: Action,
10+
parameters: { controls: { exclude: baseProps } },
11+
argTypes: {},
12+
};
13+
14+
const Template: StoryFn<CubeActionProps> = (props) => <Action {...props} />;
15+
16+
export const Default = Template.bind({});
17+
Default.args = {
18+
children: 'Action',
19+
};
20+
21+
export const Disabled = Template.bind({});
22+
Disabled.args = {
23+
children: 'Action',
24+
isDisabled: true,
25+
};

src/components/actions/Action.tsx renamed to src/components/actions/Action/Action.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import {
1313
TEXT_STYLES,
1414
TextStyleProps,
1515
tasty,
16-
} from '../../tasty';
17-
18-
import { useAction } from './use-action';
16+
} from '../../../tasty';
17+
import { useAction } from '../use-action';
1918

2019
export interface CubeActionProps
2120
extends BaseProps,
@@ -83,6 +82,7 @@ export const Action = forwardRef(function Action(
8382
data-theme={theme}
8483
download={download}
8584
{...actionProps}
85+
isDisabled={undefined}
8686
styles={styles}
8787
/>
8888
);

src/components/actions/Button/Button.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cloneElement, forwardRef, ReactElement, useMemo } from 'react';
22
import { FocusableRef } from '@react-types/shared';
33

4-
import { CubeActionProps } from '../Action';
4+
import { CubeActionProps } from '../Action/Action';
55
import {
66
CONTAINER_STYLES,
77
extractStyles,

src/components/actions/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ const Button = Object.assign(
99
);
1010

1111
export * from './Button';
12-
export * from './Action';
12+
export * from './Action/Action';
1313
export * from './use-action';
1414
export { Button, ButtonGroup };

src/components/fields/DatePicker/DatePickerInput.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function DatePickerInput<T extends DateValue>(
5151
state.segments = formatSegments(state.segments);
5252
}
5353

54-
const focusWithinProps = useFocusWithin({
54+
const { focusWithinProps } = useFocusWithin({
5555
onFocusWithinChange: (isFocused) => {
5656
if (isFocused) {
5757
props.onFocus?.();

src/components/fields/Slider/Slider.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { forwardRef } from 'react';
22

33
import { extractStyles, OUTER_STYLES } from '../../../tasty';
4+
import { mergeProps } from '../../../utils/react/index';
45

56
import { SliderThumb } from './SliderThumb';
67
import { SliderTrack } from './SliderTrack';
@@ -50,8 +51,7 @@ function Slider(props: CubeSliderProps, ref: FocusableRef<HTMLDivElement>) {
5051

5152
return (
5253
<SliderBase
53-
{...otherProps}
54-
{...baseProps}
54+
{...mergeProps(otherProps, baseProps)}
5555
ref={ref}
5656
orientation={orientation}
5757
styles={extractedStyles}

src/components/fields/Slider/SliderBase.tsx

+18-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RefObject, forwardRef, useRef, ReactNode } from 'react';
1+
import { RefObject, forwardRef, useRef, ReactNode, useMemo } from 'react';
22
import { useFocusableRef } from '@react-spectrum/utils';
33
import { FocusableRef } from '@react-types/shared';
44
import { useSliderState } from 'react-stately';
@@ -7,7 +7,6 @@ import { useSlider, useNumberFormatter } from 'react-aria';
77
import { extractStyles, OUTER_STYLES, tasty } from '../../../tasty';
88
import { useFieldProps, useFormProps, wrapWithField } from '../../form';
99
import { Text } from '../../content/Text';
10-
import { mergeProps } from '../../../utils/react';
1110

1211
import { SliderControlsElement, SliderElement } from './elements';
1312

@@ -186,22 +185,17 @@ function SliderBase(
186185
</LabelValueElement>
187186
);
188187

188+
const mods = useMemo(
189+
() => ({
190+
'side-label': labelPosition === 'side',
191+
horizontal: orientation === 'horizontal',
192+
}),
193+
[labelPosition, orientation],
194+
);
195+
189196
const sliderField = (
190-
<SliderElement
191-
ref={domRef}
192-
{...groupProps}
193-
mods={{
194-
'side-label': labelPosition === 'side',
195-
horizontal: orientation === 'horizontal',
196-
}}
197-
>
198-
<SliderControlsElement
199-
{...trackProps}
200-
ref={trackRef}
201-
mods={{
202-
horizontal: orientation === 'horizontal',
203-
}}
204-
>
197+
<SliderElement ref={domRef} {...groupProps} mods={mods}>
198+
<SliderControlsElement {...trackProps} ref={trackRef} mods={mods}>
205199
{children({
206200
trackRef,
207201
inputRef,
@@ -213,18 +207,13 @@ function SliderBase(
213207

214208
styles = extractStyles(otherProps, OUTER_STYLES, styles);
215209

216-
return wrapWithField(
217-
sliderField,
218-
ref,
219-
mergeProps(
220-
{
221-
...props,
222-
styles,
223-
extra,
224-
},
225-
{ labelProps },
226-
),
227-
);
210+
return wrapWithField(sliderField, ref, {
211+
...props,
212+
children: undefined,
213+
styles,
214+
extra,
215+
labelProps,
216+
});
228217
}
229218

230219
const _SliderBase = forwardRef(SliderBase);

src/components/fields/Slider/SliderThumb.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RefObject, useRef } from 'react';
1+
import { RefObject, useMemo, useRef } from 'react';
22
import {
33
AriaSliderThumbOptions,
44
useHover,
@@ -37,14 +37,18 @@ export function SliderThumb(props: SliderThumbProps) {
3737

3838
const { hoverProps, isHovered } = useHover({ isDisabled });
3939

40+
const mods = useMemo(() => {
41+
return {
42+
hovered: isHovered,
43+
dragged: isDragging,
44+
focused: !isDragging && isFocused,
45+
disabled: isDisabled,
46+
};
47+
}, [isHovered, isDragging, isFocused, isDisabled]);
48+
4049
return (
4150
<SliderThumbElement
42-
mods={{
43-
hovered: isHovered,
44-
dragged: isDragging,
45-
focused: !isDragging && isFocused,
46-
disabled: isDisabled,
47-
}}
51+
mods={mods}
4852
{...mergeProps(thumbProps, hoverProps)}
4953
role="presentation"
5054
>

src/components/organisms/Modal/Modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createRoot } from 'react-dom/client';
33
import styled from 'styled-components';
44
import { CSSTransition } from 'react-transition-group';
55

6-
import { Action } from '../../actions/Action';
6+
import { Action } from '../../actions/Action/Action';
77
import { Card, CubeCardProps } from '../../content/Card/Card';
88
import { Flow } from '../../layout/Flow';
99
import { Flex } from '../../layout/Flex';

0 commit comments

Comments
 (0)