Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/afraid-lies-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Fix version declaration.
5 changes: 5 additions & 0 deletions .changeset/cyan-clouds-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Fix warning about incorrectly rendered component in SliderBase.
5 changes: 5 additions & 0 deletions .changeset/itchy-guests-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Correctly pass focusWithinProps in Slider.
5 changes: 5 additions & 0 deletions .changeset/modern-bees-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Do not pass invalid isDisabled prop in Action.
25 changes: 25 additions & 0 deletions src/components/actions/Action/Action.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { StoryFn } from '@storybook/react';

import { baseProps } from '../../../stories/lists/baseProps';

import { Action, CubeActionProps } from './Action';

export default {
title: 'Actions/Action',
component: Action,
parameters: { controls: { exclude: baseProps } },
argTypes: {},
};

const Template: StoryFn<CubeActionProps> = (props) => <Action {...props} />;

export const Default = Template.bind({});
Default.args = {
children: 'Action',
};

export const Disabled = Template.bind({});
Disabled.args = {
children: 'Action',
isDisabled: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import {
TEXT_STYLES,
TextStyleProps,
tasty,
} from '../../tasty';

import { useAction } from './use-action';
} from '../../../tasty';
import { useAction } from '../use-action';

export interface CubeActionProps
extends BaseProps,
Expand Down Expand Up @@ -83,6 +82,7 @@ export const Action = forwardRef(function Action(
data-theme={theme}
download={download}
{...actionProps}
isDisabled={undefined}
styles={styles}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/actions/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cloneElement, forwardRef, ReactElement, useMemo } from 'react';
import { FocusableRef } from '@react-types/shared';

import { CubeActionProps } from '../Action';
import { CubeActionProps } from '../Action/Action';
import {
CONTAINER_STYLES,
extractStyles,
Expand Down
2 changes: 1 addition & 1 deletion src/components/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ const Button = Object.assign(
);

export * from './Button';
export * from './Action';
export * from './Action/Action';
export * from './use-action';
export { Button, ButtonGroup };
2 changes: 1 addition & 1 deletion src/components/fields/DatePicker/DatePickerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function DatePickerInput<T extends DateValue>(
state.segments = formatSegments(state.segments);
}

const focusWithinProps = useFocusWithin({
const { focusWithinProps } = useFocusWithin({
onFocusWithinChange: (isFocused) => {
if (isFocused) {
props.onFocus?.();
Expand Down
4 changes: 2 additions & 2 deletions src/components/fields/Slider/Slider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { forwardRef } from 'react';

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

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

return (
<SliderBase
{...otherProps}
{...baseProps}
{...mergeProps(otherProps, baseProps)}
ref={ref}
orientation={orientation}
styles={extractedStyles}
Expand Down
47 changes: 18 additions & 29 deletions src/components/fields/Slider/SliderBase.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RefObject, forwardRef, useRef, ReactNode } from 'react';
import { RefObject, forwardRef, useRef, ReactNode, useMemo } from 'react';
import { useFocusableRef } from '@react-spectrum/utils';
import { FocusableRef } from '@react-types/shared';
import { useSliderState } from 'react-stately';
Expand All @@ -7,7 +7,6 @@ import { useSlider, useNumberFormatter } from 'react-aria';
import { extractStyles, OUTER_STYLES, tasty } from '../../../tasty';
import { useFieldProps, useFormProps, wrapWithField } from '../../form';
import { Text } from '../../content/Text';
import { mergeProps } from '../../../utils/react';

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

Expand Down Expand Up @@ -186,22 +185,17 @@ function SliderBase(
</LabelValueElement>
);

const mods = useMemo(
() => ({
'side-label': labelPosition === 'side',
horizontal: orientation === 'horizontal',
}),
[labelPosition, orientation],
);

const sliderField = (
<SliderElement
ref={domRef}
{...groupProps}
mods={{
'side-label': labelPosition === 'side',
horizontal: orientation === 'horizontal',
}}
>
<SliderControlsElement
{...trackProps}
ref={trackRef}
mods={{
horizontal: orientation === 'horizontal',
}}
>
<SliderElement ref={domRef} {...groupProps} mods={mods}>
<SliderControlsElement {...trackProps} ref={trackRef} mods={mods}>
{children({
trackRef,
inputRef,
Expand All @@ -213,18 +207,13 @@ function SliderBase(

styles = extractStyles(otherProps, OUTER_STYLES, styles);

return wrapWithField(
sliderField,
ref,
mergeProps(
{
...props,
styles,
extra,
},
{ labelProps },
),
);
return wrapWithField(sliderField, ref, {
...props,
children: undefined,
styles,
extra,
labelProps,
});
}

const _SliderBase = forwardRef(SliderBase);
Expand Down
18 changes: 11 additions & 7 deletions src/components/fields/Slider/SliderThumb.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RefObject, useRef } from 'react';
import { RefObject, useMemo, useRef } from 'react';
import {
AriaSliderThumbOptions,
useHover,
Expand Down Expand Up @@ -37,14 +37,18 @@ export function SliderThumb(props: SliderThumbProps) {

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

const mods = useMemo(() => {
return {
hovered: isHovered,
dragged: isDragging,
focused: !isDragging && isFocused,
disabled: isDisabled,
};
}, [isHovered, isDragging, isFocused, isDisabled]);

return (
<SliderThumbElement
mods={{
hovered: isHovered,
dragged: isDragging,
focused: !isDragging && isFocused,
disabled: isDisabled,
}}
mods={mods}
{...mergeProps(thumbProps, hoverProps)}
role="presentation"
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createRoot } from 'react-dom/client';
import styled from 'styled-components';
import { CSSTransition } from 'react-transition-group';

import { Action } from '../../actions/Action';
import { Action } from '../../actions/Action/Action';
import { Card, CubeCardProps } from '../../content/Card/Card';
import { Flow } from '../../layout/Flow';
import { Flex } from '../../layout/Flex';
Expand Down
19 changes: 10 additions & 9 deletions src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ interface Window {
};
}

if (window.CubeUIKit?.version) {
const version = '__UIKIT_VERSION__';

// Ensure CubeUIKit is defined on window in a way bundlers recognize
window.CubeUIKit = window.CubeUIKit || { version };

// Check for multiple versions
if (window.CubeUIKit.version && window.CubeUIKit.version !== version) {
console.error('More than one version of CubeUIKit is loaded', {
loadedVersions: [window.CubeUIKit.version, '__UIKIT_VERSION'],
loadedVersions: [window.CubeUIKit.version, version],
});
} else {
if (!window.CubeUIKit || !Array.isArray(window.CubeUIKit)) {
window.CubeUIKit = {
version: '__UIKIT_VERSION__',
};
} else {
window.CubeUIKit.version = '__UIKIT_VERSION__';
}
// Set version if not already set
window.CubeUIKit.version = version;
}
Loading