rsuite 6.0.0-canary-20250620 → 6.0.0-canary-20250622
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/Accordion/styles/index.css +0 -78
- package/AutoComplete/styles/index.css +1 -79
- package/Avatar/styles/index.css +0 -78
- package/AvatarGroup/styles/index.css +0 -78
- package/Badge/styles/index.css +0 -78
- package/Box/styles/index.css +0 -78
- package/Breadcrumb/styles/index.css +0 -78
- package/Button/styles/index.css +0 -78
- package/ButtonGroup/styles/index.css +0 -78
- package/ButtonToolbar/styles/index.css +0 -82
- package/Calendar/styles/index.css +0 -78
- package/Card/styles/index.css +0 -78
- package/CardGroup/styles/index.css +0 -78
- package/Carousel/styles/index.css +0 -78
- package/CascadeTree/styles/index.css +0 -78
- package/Cascader/styles/index.css +1 -79
- package/Center/styles/index.css +0 -78
- package/CheckPicker/styles/index.css +1 -79
- package/CheckTree/styles/index.css +1 -79
- package/CheckTreePicker/styles/index.css +1 -79
- package/Checkbox/styles/index.css +0 -78
- package/CheckboxGroup/styles/index.css +0 -78
- package/Container/styles/index.css +0 -78
- package/Content/styles/index.css +0 -78
- package/DateInput/styles/index.css +0 -78
- package/DatePicker/styles/index.css +1 -79
- package/DateRangeInput/styles/index.css +0 -78
- package/DateRangePicker/styles/index.css +1 -79
- package/Divider/styles/index.css +0 -78
- package/Drawer/styles/index.css +0 -78
- package/Dropdown/styles/index.css +0 -78
- package/FlexboxGrid/styles/index.css +0 -78
- package/Footer/styles/index.css +0 -78
- package/Form/styles/index.css +0 -78
- package/FormControl/styles/index.css +0 -78
- package/FormControlLabel/styles/index.css +0 -78
- package/FormErrorMessage/styles/index.css +0 -78
- package/FormGroup/styles/index.css +0 -78
- package/FormHelpText/styles/index.css +0 -78
- package/FormStack/styles/index.css +0 -78
- package/Grid/styles/index.css +0 -78
- package/Header/styles/index.css +0 -78
- package/Heading/styles/index.css +0 -78
- package/HeadingGroup/styles/index.css +0 -78
- package/Highlight/styles/index.css +0 -78
- package/IconButton/styles/index.css +0 -78
- package/Image/styles/index.css +0 -78
- package/InlineEdit/styles/index.css +0 -78
- package/Input/styles/index.css +0 -78
- package/InputGroup/styles/index.css +1 -79
- package/InputNumber/styles/index.css +1 -79
- package/InputPicker/styles/index.css +1 -79
- package/Kbd/styles/index.css +0 -78
- package/Link/styles/index.css +0 -78
- package/List/styles/index.css +0 -78
- package/Loader/styles/index.css +0 -78
- package/Menu/styles/index.css +0 -78
- package/Message/styles/index.css +0 -78
- package/Modal/styles/index.css +0 -78
- package/MultiCascadeTree/styles/index.css +1 -79
- package/MultiCascader/styles/index.css +1 -79
- package/Nav/styles/index.css +0 -78
- package/Navbar/styles/index.css +0 -78
- package/Notification/styles/index.css +0 -78
- package/NumberInput/styles/index.css +1 -79
- package/Pagination/styles/index.css +1 -79
- package/Panel/styles/index.css +0 -78
- package/PanelGroup/styles/index.css +0 -78
- package/PasswordInput/styles/index.css +1 -79
- package/PasswordStrengthMeter/styles/index.css +0 -78
- package/PinInput/styles/index.css +0 -78
- package/Placeholder/styles/index.css +0 -78
- package/Popover/styles/index.css +0 -78
- package/Progress/styles/index.css +0 -78
- package/ProgressCircle/styles/index.css +0 -78
- package/Radio/styles/index.css +0 -78
- package/RadioGroup/styles/index.css +0 -78
- package/RadioTile/styles/index.css +0 -78
- package/RangeSlider/styles/index.css +0 -78
- package/Rate/styles/index.css +0 -78
- package/SegmentedControl/package.json +7 -0
- package/SegmentedControl/styles/index.css +159 -0
- package/SelectPicker/styles/index.css +1 -79
- package/Sidebar/styles/index.css +0 -78
- package/Sidenav/styles/index.css +0 -78
- package/Slider/styles/index.css +0 -78
- package/Stack/styles/index.css +0 -78
- package/Stat/styles/index.css +0 -78
- package/StatGroup/styles/index.css +0 -78
- package/Steps/styles/index.css +0 -78
- package/Table/styles/index.css +0 -78
- package/Tabs/styles/index.css +0 -78
- package/Tag/styles/index.css +0 -78
- package/TagGroup/styles/index.css +0 -78
- package/TagInput/styles/index.css +1 -79
- package/TagPicker/styles/index.css +1 -79
- package/Text/styles/index.css +0 -78
- package/Textarea/styles/index.css +0 -78
- package/TimePicker/styles/index.css +1 -79
- package/TimeRangePicker/styles/index.css +1 -79
- package/Timeline/styles/index.css +0 -78
- package/Toggle/styles/index.css +0 -78
- package/Tooltip/styles/index.css +0 -78
- package/Tree/styles/index.css +1 -79
- package/TreePicker/styles/index.css +1 -79
- package/Uploader/styles/index.css +0 -78
- package/cjs/ButtonToolbar/ButtonToolbar.js +2 -0
- package/cjs/Grid/utils/styles.d.ts +1 -1
- package/cjs/InputPicker/utils.d.ts +1 -1
- package/cjs/Nav/Nav.d.ts +2 -3
- package/cjs/RadioGroup/RadioGroup.d.ts +4 -1
- package/cjs/SegmentedControl/Indicator.d.ts +10 -0
- package/cjs/SegmentedControl/Indicator.js +22 -0
- package/cjs/SegmentedControl/SegmentedControl.d.ts +27 -0
- package/cjs/SegmentedControl/SegmentedControl.js +87 -0
- package/cjs/SegmentedControl/SegmentedItem.d.ts +16 -0
- package/cjs/SegmentedControl/SegmentedItem.js +44 -0
- package/cjs/SegmentedControl/hooks/useIndicatorPosition.d.ts +17 -0
- package/cjs/SegmentedControl/hooks/useIndicatorPosition.js +55 -0
- package/cjs/SegmentedControl/index.d.ts +4 -0
- package/cjs/SegmentedControl/index.js +11 -0
- package/cjs/Slider/ProgressBar.js +1 -1
- package/cjs/Stack/Stack.js +20 -5
- package/cjs/Stack/utils.d.ts +9 -0
- package/cjs/Stack/utils.js +38 -0
- package/cjs/Tabs/Tabs.d.ts +4 -2
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +6 -0
- package/cjs/internals/Box/Box.d.ts +27 -27
- package/cjs/internals/Box/Box.js +13 -8
- package/cjs/internals/Box/utils.d.ts +4 -1
- package/cjs/internals/Box/utils.js +154 -13
- package/cjs/internals/Provider/types.d.ts +2 -0
- package/cjs/internals/constants/index.js +2 -2
- package/cjs/internals/hooks/useElementResize.d.ts +2 -1
- package/cjs/internals/hooks/useElementResize.js +50 -7
- package/cjs/internals/hooks/useStyled.d.ts +60 -0
- package/cjs/internals/hooks/useStyled.js +257 -0
- package/cjs/internals/utils/colours.js +1 -1
- package/cjs/internals/utils/style-sheet/css.d.ts +1 -1
- package/cjs/internals/utils/style-sheet/css.js +1 -1
- package/cjs/internals/utils/style-sheet/index.d.ts +1 -0
- package/cjs/internals/utils/style-sheet/index.js +6 -0
- package/cjs/internals/utils/style-sheet/style-manager.d.ts +50 -0
- package/cjs/internals/utils/style-sheet/style-manager.js +97 -0
- package/dist/rsuite-no-reset.css +200 -101
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite.css +200 -101
- package/dist/rsuite.js +172 -14
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/ButtonToolbar/ButtonToolbar.js +2 -0
- package/esm/Grid/utils/styles.d.ts +1 -1
- package/esm/InputPicker/utils.d.ts +1 -1
- package/esm/Nav/Nav.d.ts +2 -3
- package/esm/RadioGroup/RadioGroup.d.ts +4 -1
- package/esm/SegmentedControl/Indicator.d.ts +10 -0
- package/esm/SegmentedControl/Indicator.js +17 -0
- package/esm/SegmentedControl/SegmentedControl.d.ts +27 -0
- package/esm/SegmentedControl/SegmentedControl.js +81 -0
- package/esm/SegmentedControl/SegmentedItem.d.ts +16 -0
- package/esm/SegmentedControl/SegmentedItem.js +39 -0
- package/esm/SegmentedControl/hooks/useIndicatorPosition.d.ts +17 -0
- package/esm/SegmentedControl/hooks/useIndicatorPosition.js +50 -0
- package/esm/SegmentedControl/index.d.ts +4 -0
- package/esm/SegmentedControl/index.js +8 -0
- package/esm/Slider/ProgressBar.js +1 -1
- package/esm/Stack/Stack.js +21 -6
- package/esm/Stack/utils.d.ts +9 -0
- package/esm/Stack/utils.js +35 -0
- package/esm/Tabs/Tabs.d.ts +4 -2
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/internals/Box/Box.d.ts +27 -27
- package/esm/internals/Box/Box.js +9 -4
- package/esm/internals/Box/utils.d.ts +4 -1
- package/esm/internals/Box/utils.js +153 -13
- package/esm/internals/Provider/types.d.ts +2 -0
- package/esm/internals/constants/index.js +2 -2
- package/esm/internals/hooks/useElementResize.d.ts +2 -1
- package/esm/internals/hooks/useElementResize.js +50 -7
- package/esm/internals/hooks/useStyled.d.ts +60 -0
- package/esm/internals/hooks/useStyled.js +251 -0
- package/esm/internals/utils/colours.js +1 -1
- package/esm/internals/utils/style-sheet/css.d.ts +1 -1
- package/esm/internals/utils/style-sheet/css.js +1 -1
- package/esm/internals/utils/style-sheet/index.d.ts +1 -0
- package/esm/internals/utils/style-sheet/index.js +2 -1
- package/esm/internals/utils/style-sheet/style-manager.d.ts +50 -0
- package/esm/internals/utils/style-sheet/style-manager.js +93 -0
- package/package.json +1 -1
|
@@ -25,6 +25,8 @@ const ButtonToolbar = forwardRef((props, ref) => {
|
|
|
25
25
|
} = useStyles(classPrefix);
|
|
26
26
|
const classes = merge(className, withPrefix());
|
|
27
27
|
return /*#__PURE__*/React.createElement(Stack, _extends({
|
|
28
|
+
wrap: true,
|
|
29
|
+
spacing: 8,
|
|
28
30
|
as: as,
|
|
29
31
|
role: role,
|
|
30
32
|
ref: ref,
|
|
@@ -3,4 +3,4 @@ import type { GutterType } from '../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Generates CSS variable styles for grid gutters, supporting both single values and arrays [horizontal, vertical]
|
|
5
5
|
*/
|
|
6
|
-
export declare const getResponsiveGutterStyles: (gutter?: GutterType | ResponsiveValue<GutterType>) => Record<string, string>;
|
|
6
|
+
export declare const getResponsiveGutterStyles: (gutter?: GutterType | ResponsiveValue<GutterType>) => Record<string, string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const convertSize: (size?: string) => "
|
|
1
|
+
export declare const convertSize: (size?: string) => "sm" | "md" | "lg";
|
package/esm/Nav/Nav.d.ts
CHANGED
|
@@ -4,11 +4,10 @@ import type { HTMLPropsWithoutSelect } from '../internals/types';
|
|
|
4
4
|
export interface NavProps<T = any> extends BoxProps, HTMLPropsWithoutSelect {
|
|
5
5
|
/**
|
|
6
6
|
* The appearance style of the Nav component.
|
|
7
|
-
*
|
|
7
|
+
* - 'pills' appearance is deprecated. Use `SegmentedControl` component instead.
|
|
8
8
|
* @default 'default'
|
|
9
|
-
* @version 'pills' is supported in version 5.68.0
|
|
10
9
|
*/
|
|
11
|
-
appearance?: 'default' | 'subtle' | 'tabs'
|
|
10
|
+
appearance?: 'default' | 'subtle' | 'tabs';
|
|
12
11
|
/**
|
|
13
12
|
* Whether the Nav component is reversed.
|
|
14
13
|
*/
|
|
@@ -14,7 +14,10 @@ export interface RadioContextProps {
|
|
|
14
14
|
]>;
|
|
15
15
|
}
|
|
16
16
|
export interface RadioGroupProps<T = string | number> extends BoxProps, FormControlBaseProps<T> {
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* A radio group can have different appearances
|
|
19
|
+
* @deprecated Use `<SegmentedControl indicator="underline" />` instead
|
|
20
|
+
*/
|
|
18
21
|
appearance?: 'default' | 'picker';
|
|
19
22
|
/** Name to use for form */
|
|
20
23
|
name?: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IndicatorProps {
|
|
3
|
+
style: React.CSSProperties;
|
|
4
|
+
classPrefix: string;
|
|
5
|
+
}
|
|
6
|
+
declare const Indicator: {
|
|
7
|
+
({ style, classPrefix }: IndicatorProps): React.JSX.Element;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export default Indicator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useStyles } from "../internals/hooks/index.js";
|
|
4
|
+
const Indicator = ({
|
|
5
|
+
style,
|
|
6
|
+
classPrefix
|
|
7
|
+
}) => {
|
|
8
|
+
const {
|
|
9
|
+
prefix
|
|
10
|
+
} = useStyles(classPrefix);
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: prefix('indicator'),
|
|
13
|
+
style: style
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
Indicator.displayName = 'Indicator';
|
|
17
|
+
export default Indicator;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BoxProps } from '../internals/Box';
|
|
3
|
+
import type { FormControlBaseProps, Size } from '../internals/types';
|
|
4
|
+
export interface SegmentedItemDataType {
|
|
5
|
+
/** The label of the item */
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
/** The value of the item */
|
|
8
|
+
value: string | number;
|
|
9
|
+
}
|
|
10
|
+
export interface SegmentedControlProps<T = string | number | null> extends BoxProps, Omit<FormControlBaseProps<T>, 'readOnly' | 'plaintext'> {
|
|
11
|
+
/** The indicator style of the segmented control */
|
|
12
|
+
indicator?: 'pill' | 'underline';
|
|
13
|
+
/** Name to use for form */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** Data of segmented items */
|
|
16
|
+
data?: SegmentedItemDataType[];
|
|
17
|
+
/** Display block style, fit the width of the container */
|
|
18
|
+
block?: boolean;
|
|
19
|
+
/** A segmented control can have different sizes */
|
|
20
|
+
size?: Size;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `SegmentedControl` component is used to offer multiple exclusive options.
|
|
24
|
+
* @see https://rsuitejs.com/components/segmented-control
|
|
25
|
+
*/
|
|
26
|
+
declare const SegmentedControl: import("../internals/types").InternalRefForwardingComponent<"div", SegmentedControlProps<string | number | null>, never> & Record<string, never>;
|
|
27
|
+
export default SegmentedControl;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import Box from "../internals/Box/index.js";
|
|
5
|
+
import SegmentedItem from "./SegmentedItem.js";
|
|
6
|
+
import Indicator from "./Indicator.js";
|
|
7
|
+
import { forwardRef, mergeRefs } from "../internals/utils/index.js";
|
|
8
|
+
import { useStyles, useCustom, useControlled, useEventCallback, useUniqueId } from "../internals/hooks/index.js";
|
|
9
|
+
import useIndicatorPosition from "./hooks/useIndicatorPosition.js";
|
|
10
|
+
/**
|
|
11
|
+
* The `SegmentedControl` component is used to offer multiple exclusive options.
|
|
12
|
+
* @see https://rsuitejs.com/components/segmented-control
|
|
13
|
+
*/
|
|
14
|
+
const SegmentedControl = forwardRef((props, ref) => {
|
|
15
|
+
const {
|
|
16
|
+
propsWithDefaults
|
|
17
|
+
} = useCustom('SegmentedControl', props);
|
|
18
|
+
const {
|
|
19
|
+
as,
|
|
20
|
+
className,
|
|
21
|
+
classPrefix = 'segmented-control',
|
|
22
|
+
value: valueProp,
|
|
23
|
+
defaultValue,
|
|
24
|
+
indicator = 'pill',
|
|
25
|
+
size = 'md',
|
|
26
|
+
block = false,
|
|
27
|
+
name,
|
|
28
|
+
disabled,
|
|
29
|
+
data,
|
|
30
|
+
onChange,
|
|
31
|
+
...rest
|
|
32
|
+
} = propsWithDefaults;
|
|
33
|
+
const {
|
|
34
|
+
merge,
|
|
35
|
+
withPrefix
|
|
36
|
+
} = useStyles(classPrefix);
|
|
37
|
+
const classes = merge(className, withPrefix());
|
|
38
|
+
const [value, setValue] = useControlled(valueProp, defaultValue);
|
|
39
|
+
const id = useUniqueId('segmented', name);
|
|
40
|
+
|
|
41
|
+
// Ref for container element
|
|
42
|
+
const containerRef = useRef(null);
|
|
43
|
+
|
|
44
|
+
// Get the active item index
|
|
45
|
+
const activeIndex = data === null || data === void 0 ? void 0 : data.findIndex(item => item.value === value);
|
|
46
|
+
const {
|
|
47
|
+
style: indicatorStyle
|
|
48
|
+
} = useIndicatorPosition({
|
|
49
|
+
containerRef,
|
|
50
|
+
activeIndex,
|
|
51
|
+
indicator,
|
|
52
|
+
data
|
|
53
|
+
});
|
|
54
|
+
const handleChange = useEventCallback((nextValue, event) => {
|
|
55
|
+
setValue(nextValue);
|
|
56
|
+
onChange === null || onChange === void 0 || onChange(nextValue !== null && nextValue !== void 0 ? nextValue : '', event);
|
|
57
|
+
});
|
|
58
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
59
|
+
as: as,
|
|
60
|
+
role: "radiogroup",
|
|
61
|
+
ref: mergeRefs(ref, containerRef),
|
|
62
|
+
className: classes,
|
|
63
|
+
"data-size": size,
|
|
64
|
+
"data-block": block || undefined,
|
|
65
|
+
"data-indicator": indicator
|
|
66
|
+
}, rest), data === null || data === void 0 ? void 0 : data.map((item, index) => /*#__PURE__*/React.createElement(SegmentedItem, {
|
|
67
|
+
key: index,
|
|
68
|
+
item: item,
|
|
69
|
+
index: index,
|
|
70
|
+
name: id,
|
|
71
|
+
active: value === item.value,
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
classPrefix: classPrefix,
|
|
74
|
+
onChange: handleChange
|
|
75
|
+
})), activeIndex !== -1 && /*#__PURE__*/React.createElement(Indicator, {
|
|
76
|
+
style: indicatorStyle,
|
|
77
|
+
classPrefix: classPrefix
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
SegmentedControl.displayName = 'SegmentedControl';
|
|
81
|
+
export default SegmentedControl;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SegmentedItemDataType } from './SegmentedControl';
|
|
3
|
+
export interface SegmentedItemProps {
|
|
4
|
+
item: SegmentedItemDataType;
|
|
5
|
+
index: number;
|
|
6
|
+
name?: string;
|
|
7
|
+
active: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
classPrefix: string;
|
|
10
|
+
onChange: (value: string | number, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const SegmentedItem: {
|
|
13
|
+
({ item, index, name, active, disabled, classPrefix, onChange }: SegmentedItemProps): React.JSX.Element;
|
|
14
|
+
displayName: string;
|
|
15
|
+
};
|
|
16
|
+
export default SegmentedItem;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useStyles } from "../internals/hooks/index.js";
|
|
4
|
+
const SegmentedItem = ({
|
|
5
|
+
item,
|
|
6
|
+
index,
|
|
7
|
+
name,
|
|
8
|
+
active,
|
|
9
|
+
disabled,
|
|
10
|
+
classPrefix,
|
|
11
|
+
onChange
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
prefix
|
|
15
|
+
} = useStyles(classPrefix);
|
|
16
|
+
const handleChange = event => {
|
|
17
|
+
if (disabled) return;
|
|
18
|
+
onChange(item.value, event);
|
|
19
|
+
};
|
|
20
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
21
|
+
className: prefix('item'),
|
|
22
|
+
"data-value": item.value,
|
|
23
|
+
"data-index": index,
|
|
24
|
+
"data-active": active || undefined,
|
|
25
|
+
"data-disabled": disabled || undefined
|
|
26
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
27
|
+
type: "radio",
|
|
28
|
+
name: name,
|
|
29
|
+
value: String(item.value),
|
|
30
|
+
checked: active,
|
|
31
|
+
disabled: disabled,
|
|
32
|
+
onChange: handleChange,
|
|
33
|
+
className: prefix('radio')
|
|
34
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
35
|
+
className: prefix('label')
|
|
36
|
+
}, item.label));
|
|
37
|
+
};
|
|
38
|
+
SegmentedItem.displayName = 'SegmentedItem';
|
|
39
|
+
export default SegmentedItem;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
interface UseIndicatorPositionProps {
|
|
3
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
4
|
+
activeIndex?: number;
|
|
5
|
+
indicator: 'pill' | 'underline';
|
|
6
|
+
data?: Array<{
|
|
7
|
+
value: string | number;
|
|
8
|
+
}>;
|
|
9
|
+
block?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Custom hook to calculate and update the indicator position
|
|
13
|
+
*/
|
|
14
|
+
declare const useIndicatorPosition: ({ containerRef, activeIndex, indicator, data }: UseIndicatorPositionProps) => {
|
|
15
|
+
style: import("react").CSSProperties;
|
|
16
|
+
};
|
|
17
|
+
export default useIndicatorPosition;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import isEqual from 'lodash/isEqual';
|
|
4
|
+
import { useElementResize } from "../../internals/hooks/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Updates the indicator position based on the active item
|
|
7
|
+
*/
|
|
8
|
+
const updateIndicatorPosition = (container, activeIndex, indicator) => {
|
|
9
|
+
if (activeIndex === -1) return {};
|
|
10
|
+
const activeItem = container.querySelector(`[data-index="${activeIndex}"]`);
|
|
11
|
+
if (!activeItem) return {};
|
|
12
|
+
const containerStyle = window.getComputedStyle(container);
|
|
13
|
+
const paddingLeft = parseFloat(containerStyle.paddingLeft) || 0;
|
|
14
|
+
return {
|
|
15
|
+
transform: `translateX(${activeItem.offsetLeft - paddingLeft}px)`,
|
|
16
|
+
width: activeItem.offsetWidth,
|
|
17
|
+
height: indicator === 'underline' ? 2 : activeItem.offsetHeight
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Custom hook to calculate and update the indicator position
|
|
23
|
+
*/
|
|
24
|
+
const useIndicatorPosition = ({
|
|
25
|
+
containerRef,
|
|
26
|
+
activeIndex,
|
|
27
|
+
indicator,
|
|
28
|
+
data
|
|
29
|
+
}) => {
|
|
30
|
+
const [indicatorStyle, setIndicatorStyle] = useState({});
|
|
31
|
+
const updatePosition = useCallback(() => {
|
|
32
|
+
if (!(containerRef !== null && containerRef !== void 0 && containerRef.current)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const newStyle = updateIndicatorPosition(containerRef.current, activeIndex, indicator);
|
|
36
|
+
setIndicatorStyle(prev => isEqual(prev, newStyle) ? prev : newStyle);
|
|
37
|
+
}, [containerRef, activeIndex, indicator]);
|
|
38
|
+
|
|
39
|
+
// Update position when active item or data changes
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
updatePosition();
|
|
42
|
+
}, [updatePosition, data]);
|
|
43
|
+
|
|
44
|
+
// Set up resize observer
|
|
45
|
+
useElementResize(containerRef, updatePosition);
|
|
46
|
+
return {
|
|
47
|
+
style: indicatorStyle
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export default useIndicatorPosition;
|
|
@@ -20,7 +20,7 @@ const ProgressBar = forwardRef((props, ref) => {
|
|
|
20
20
|
withPrefix
|
|
21
21
|
} = useStyles(classPrefix);
|
|
22
22
|
const sizeKey = vertical ? 'height' : 'width';
|
|
23
|
-
const startKey = vertical ? 'bottom' : '
|
|
23
|
+
const startKey = vertical ? 'bottom' : 'insetInlineStart';
|
|
24
24
|
const styles = mergeStyles(style, {
|
|
25
25
|
[startKey]: `${start}%`,
|
|
26
26
|
[sizeKey]: `${end - start}%`
|
package/esm/Stack/Stack.js
CHANGED
|
@@ -3,8 +3,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import StackItem from "./StackItem.js";
|
|
5
5
|
import Box from "../internals/Box/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useStyled } from "../internals/hooks/useStyled.js";
|
|
7
|
+
import { forwardRef } from "../internals/utils/index.js";
|
|
7
8
|
import { useStyles, useCustom } from "../internals/hooks/index.js";
|
|
9
|
+
import { generateStackCssVars } from "./utils.js";
|
|
8
10
|
const Subcomponents = {
|
|
9
11
|
Item: StackItem
|
|
10
12
|
};
|
|
@@ -38,20 +40,33 @@ const Stack = forwardRef((props, ref) => {
|
|
|
38
40
|
const {
|
|
39
41
|
withPrefix,
|
|
40
42
|
merge,
|
|
41
|
-
cssVar,
|
|
42
43
|
responsive
|
|
43
44
|
} = useStyles(classPrefix);
|
|
44
|
-
const
|
|
45
|
+
const baseClasses = merge(className, withPrefix({
|
|
45
46
|
wrap
|
|
46
47
|
}), ...responsive(direction));
|
|
47
|
-
|
|
48
|
+
|
|
49
|
+
// Generate CSS variables for Stack
|
|
50
|
+
const cssVars = generateStackCssVars({
|
|
51
|
+
spacing,
|
|
52
|
+
align,
|
|
53
|
+
justify
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Use the useStyled hook to manage CSS variables
|
|
57
|
+
const styled = useStyled({
|
|
58
|
+
cssVars,
|
|
59
|
+
className: baseClasses,
|
|
60
|
+
style,
|
|
61
|
+
prefix: classPrefix
|
|
62
|
+
});
|
|
48
63
|
const filteredChildren = React.Children.toArray(children);
|
|
49
64
|
const childCount = filteredChildren.length;
|
|
50
65
|
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
51
66
|
as: as,
|
|
52
67
|
ref: ref,
|
|
53
|
-
className:
|
|
54
|
-
style:
|
|
68
|
+
className: styled.className,
|
|
69
|
+
style: styled.style
|
|
55
70
|
}, rest), filteredChildren.map((child, index) => /*#__PURE__*/React.createElement(React.Fragment, {
|
|
56
71
|
key: index
|
|
57
72
|
}, child, index < childCount - 1 && divider)));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Generate CSS variables for Stack component
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateStackCssVars({ spacing, align, justify }: {
|
|
6
|
+
spacing?: number | string | (number | string)[];
|
|
7
|
+
align?: CSSProperties['alignItems'];
|
|
8
|
+
justify?: CSSProperties['justifyContent'];
|
|
9
|
+
}): Record<string, string | number | undefined>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { getCssValue } from "../internals/utils/index.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generate CSS variables for Stack component
|
|
6
|
+
*/
|
|
7
|
+
export function generateStackCssVars({
|
|
8
|
+
spacing,
|
|
9
|
+
align,
|
|
10
|
+
justify
|
|
11
|
+
}) {
|
|
12
|
+
const cssVars = {};
|
|
13
|
+
const prefix = `--rs-stack-`;
|
|
14
|
+
|
|
15
|
+
// Add spacing CSS variable
|
|
16
|
+
if (spacing !== undefined) {
|
|
17
|
+
// Handle array or single value for spacing
|
|
18
|
+
if (Array.isArray(spacing)) {
|
|
19
|
+
cssVars[`${prefix}spacing`] = spacing.map(s => getCssValue(s)).join(' ');
|
|
20
|
+
} else {
|
|
21
|
+
cssVars[`${prefix}spacing`] = getCssValue(spacing);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Add align CSS variable
|
|
26
|
+
if (align !== undefined) {
|
|
27
|
+
cssVars[`${prefix}align`] = align;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Add justify CSS variable
|
|
31
|
+
if (justify !== undefined) {
|
|
32
|
+
cssVars[`${prefix}justify`] = justify;
|
|
33
|
+
}
|
|
34
|
+
return cssVars;
|
|
35
|
+
}
|
package/esm/Tabs/Tabs.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ import { BoxProps } from '../internals/Box';
|
|
|
6
6
|
export interface TabsProps extends BoxProps {
|
|
7
7
|
/**
|
|
8
8
|
* The appearance of the tabs.
|
|
9
|
+
* - 'pills' appearance is deprecated. Use `SegmentedControl` component instead.
|
|
10
|
+
*
|
|
9
11
|
* @default 'tabs'
|
|
10
|
-
*
|
|
12
|
+
*
|
|
11
13
|
*/
|
|
12
|
-
appearance?: 'tabs' | 'subtle'
|
|
14
|
+
appearance?: 'tabs' | 'subtle';
|
|
13
15
|
/**
|
|
14
16
|
* The key of the active tab.
|
|
15
17
|
*/
|
package/esm/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export * from './RadioGroup';
|
|
|
57
57
|
export * from './RadioTile';
|
|
58
58
|
export * from './RadioTileGroup';
|
|
59
59
|
export * from './SelectPicker';
|
|
60
|
+
export * from './SegmentedControl';
|
|
60
61
|
export * from './CheckPicker';
|
|
61
62
|
export * from './InputPicker';
|
|
62
63
|
export * from './TagPicker';
|
package/esm/index.js
CHANGED
|
@@ -81,6 +81,7 @@ export * from "./RadioGroup/index.js";
|
|
|
81
81
|
export * from "./RadioTile/index.js";
|
|
82
82
|
export * from "./RadioTileGroup/index.js";
|
|
83
83
|
export * from "./SelectPicker/index.js";
|
|
84
|
+
export * from "./SegmentedControl/index.js";
|
|
84
85
|
export * from "./CheckPicker/index.js";
|
|
85
86
|
export * from "./InputPicker/index.js";
|
|
86
87
|
export * from "./TagPicker/index.js";
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { CSSProperties as CSS } from 'react';
|
|
2
|
-
import type { WithAsProps, Breakpoints, ColorScheme, Size } from '../types';
|
|
2
|
+
import type { WithAsProps, Breakpoints, ResponsiveValue, ColorScheme, Size } from '../types';
|
|
3
3
|
export interface BoxProps extends WithAsProps {
|
|
4
4
|
/** Breakpoint below which the component is shown with `display: block` */
|
|
5
5
|
showFrom?: Breakpoints;
|
|
6
6
|
/** Breakpoint above which the component is hidden with `display: none` */
|
|
7
7
|
hideFrom?: Breakpoints;
|
|
8
8
|
/** Display property */
|
|
9
|
-
display?: CSS['display']
|
|
9
|
+
display?: CSS['display'] | ResponsiveValue<CSS['display']>;
|
|
10
10
|
/** Padding */
|
|
11
|
-
p?: CSS['padding']
|
|
12
|
-
pt?: CSS['paddingTop']
|
|
13
|
-
pb?: CSS['paddingBottom']
|
|
14
|
-
pl?: CSS['paddingLeft']
|
|
15
|
-
pr?: CSS['paddingRight']
|
|
16
|
-
px?: CSS['paddingInline']
|
|
17
|
-
py?: CSS['paddingBlock']
|
|
11
|
+
p?: CSS['padding'] | ResponsiveValue<CSS['padding']>;
|
|
12
|
+
pt?: CSS['paddingTop'] | ResponsiveValue<CSS['paddingTop']>;
|
|
13
|
+
pb?: CSS['paddingBottom'] | ResponsiveValue<CSS['paddingBottom']>;
|
|
14
|
+
pl?: CSS['paddingLeft'] | ResponsiveValue<CSS['paddingLeft']>;
|
|
15
|
+
pr?: CSS['paddingRight'] | ResponsiveValue<CSS['paddingRight']>;
|
|
16
|
+
px?: CSS['paddingInline'] | ResponsiveValue<CSS['paddingInline']>;
|
|
17
|
+
py?: CSS['paddingBlock'] | ResponsiveValue<CSS['paddingBlock']>;
|
|
18
18
|
/** Margin */
|
|
19
|
-
m?: CSS['margin']
|
|
20
|
-
mt?: CSS['marginTop']
|
|
21
|
-
mb?: CSS['marginBottom']
|
|
22
|
-
ml?: CSS['marginLeft']
|
|
23
|
-
mr?: CSS['marginRight']
|
|
24
|
-
mx?: CSS['marginInline']
|
|
25
|
-
my?: CSS['marginBlock']
|
|
19
|
+
m?: CSS['margin'] | ResponsiveValue<CSS['margin']>;
|
|
20
|
+
mt?: CSS['marginTop'] | ResponsiveValue<CSS['marginTop']>;
|
|
21
|
+
mb?: CSS['marginBottom'] | ResponsiveValue<CSS['marginBottom']>;
|
|
22
|
+
ml?: CSS['marginLeft'] | ResponsiveValue<CSS['marginLeft']>;
|
|
23
|
+
mr?: CSS['marginRight'] | ResponsiveValue<CSS['marginRight']>;
|
|
24
|
+
mx?: CSS['marginInline'] | ResponsiveValue<CSS['marginInline']>;
|
|
25
|
+
my?: CSS['marginBlock'] | ResponsiveValue<CSS['marginBlock']>;
|
|
26
26
|
/** Box size */
|
|
27
|
-
w?: CSS['width']
|
|
28
|
-
h?: CSS['height']
|
|
29
|
-
minw?: CSS['minWidth']
|
|
30
|
-
maxw?: CSS['maxWidth']
|
|
31
|
-
minh?: CSS['minHeight']
|
|
32
|
-
maxh?: CSS['maxHeight']
|
|
27
|
+
w?: CSS['width'] | ResponsiveValue<CSS['width']>;
|
|
28
|
+
h?: CSS['height'] | ResponsiveValue<CSS['height']>;
|
|
29
|
+
minw?: CSS['minWidth'] | ResponsiveValue<CSS['minWidth']>;
|
|
30
|
+
maxw?: CSS['maxWidth'] | ResponsiveValue<CSS['maxWidth']>;
|
|
31
|
+
minh?: CSS['minHeight'] | ResponsiveValue<CSS['minHeight']>;
|
|
32
|
+
maxh?: CSS['maxHeight'] | ResponsiveValue<CSS['maxHeight']>;
|
|
33
33
|
/** Box Color */
|
|
34
|
-
c?: ColorScheme | CSS['color']
|
|
34
|
+
c?: ColorScheme | CSS['color'] | ResponsiveValue<ColorScheme | CSS['color']>;
|
|
35
35
|
/** Box Border */
|
|
36
|
-
bd?: CSS['border']
|
|
36
|
+
bd?: CSS['border'] | ResponsiveValue<CSS['border']>;
|
|
37
37
|
/** Box Background */
|
|
38
|
-
bg?: ColorScheme | CSS['backgroundColor']
|
|
38
|
+
bg?: ColorScheme | CSS['backgroundColor'] | ResponsiveValue<ColorScheme | CSS['backgroundColor']>;
|
|
39
39
|
/** Box Border Radius */
|
|
40
|
-
rounded?: Size | CSS['borderRadius'] | 'full'
|
|
40
|
+
rounded?: Size | CSS['borderRadius'] | 'full' | ResponsiveValue<Size | CSS['borderRadius'] | 'full'>;
|
|
41
41
|
/** Box Shadow */
|
|
42
|
-
shadow?: Size | CSS['boxShadow']
|
|
42
|
+
shadow?: Size | CSS['boxShadow'] | ResponsiveValue<Size | CSS['boxShadow']>;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Box component is the base component for all components,
|
package/esm/internals/Box/Box.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import { mergeStyles } from "../utils/index.js";
|
|
6
5
|
import { forwardRef } from "../utils/react/forwardRef.js";
|
|
7
6
|
import { getBoxCSSVariables, extractBoxProps, omitBoxProps } from "./utils.js";
|
|
7
|
+
import { useStyled } from "../hooks/useStyled.js";
|
|
8
8
|
/**
|
|
9
9
|
* Box component is the base component for all components,
|
|
10
10
|
* providing shorthand for style properties.
|
|
@@ -24,15 +24,20 @@ const Box = forwardRef((props, ref) => {
|
|
|
24
24
|
const boxProps = extractBoxProps(rest);
|
|
25
25
|
const domProps = omitBoxProps(rest);
|
|
26
26
|
const boxCSSVars = getBoxCSSVariables(boxProps);
|
|
27
|
-
const boxStyle = mergeStyles(style, boxCSSVars);
|
|
28
27
|
const isBox = !isEmpty(boxCSSVars) || showFrom || hideFrom;
|
|
28
|
+
const styled = useStyled({
|
|
29
|
+
cssVars: boxCSSVars,
|
|
30
|
+
className,
|
|
31
|
+
style,
|
|
32
|
+
enabled: isBox
|
|
33
|
+
});
|
|
29
34
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
30
35
|
ref: ref,
|
|
31
36
|
"data-rs": isBox ? 'box' : undefined,
|
|
32
37
|
"data-visible-from": showFrom,
|
|
33
38
|
"data-hidden-from": hideFrom,
|
|
34
|
-
className: className,
|
|
35
|
-
style:
|
|
39
|
+
className: styled.className,
|
|
40
|
+
style: styled.style
|
|
36
41
|
}, domProps), children);
|
|
37
42
|
});
|
|
38
43
|
Box.displayName = 'Box';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResponsiveValue } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* Extract box properties from props
|
|
3
4
|
* @param props Original props object
|
|
@@ -10,9 +11,11 @@ export declare const extractBoxProps: (props: Record<string, any>) => Record<str
|
|
|
10
11
|
* @returns New object without layout properties
|
|
11
12
|
*/
|
|
12
13
|
export declare const omitBoxProps: (props: Record<string, any>) => Record<string, any>;
|
|
14
|
+
type CSSVarValue = string | number | undefined | ResponsiveValue<string | number>;
|
|
13
15
|
/**
|
|
14
16
|
* Converts layout properties to CSS variables with abbreviated names
|
|
15
17
|
* @param props Object containing layout properties
|
|
16
18
|
* @returns Object with CSS variables
|
|
17
19
|
*/
|
|
18
|
-
export declare const getBoxCSSVariables: (props: Record<string, any>) => Record<string,
|
|
20
|
+
export declare const getBoxCSSVariables: (props: Record<string, any>) => Record<string, CSSVarValue>;
|
|
21
|
+
export {};
|