rsuite 6.0.0-canary-2025062016 → 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.
Files changed (152) hide show
  1. package/Accordion/styles/index.css +0 -78
  2. package/AutoComplete/styles/index.css +1 -79
  3. package/Avatar/styles/index.css +0 -78
  4. package/AvatarGroup/styles/index.css +0 -78
  5. package/Badge/styles/index.css +0 -78
  6. package/Box/styles/index.css +0 -78
  7. package/Breadcrumb/styles/index.css +0 -78
  8. package/Button/styles/index.css +0 -78
  9. package/ButtonGroup/styles/index.css +0 -78
  10. package/ButtonToolbar/styles/index.css +0 -82
  11. package/Calendar/styles/index.css +0 -78
  12. package/Card/styles/index.css +0 -78
  13. package/CardGroup/styles/index.css +0 -78
  14. package/Carousel/styles/index.css +0 -78
  15. package/CascadeTree/styles/index.css +0 -78
  16. package/Cascader/styles/index.css +1 -79
  17. package/Center/styles/index.css +0 -78
  18. package/CheckPicker/styles/index.css +1 -79
  19. package/CheckTree/styles/index.css +1 -79
  20. package/CheckTreePicker/styles/index.css +1 -79
  21. package/Checkbox/styles/index.css +0 -78
  22. package/CheckboxGroup/styles/index.css +0 -78
  23. package/Container/styles/index.css +0 -78
  24. package/Content/styles/index.css +0 -78
  25. package/DateInput/styles/index.css +0 -78
  26. package/DatePicker/styles/index.css +1 -79
  27. package/DateRangeInput/styles/index.css +0 -78
  28. package/DateRangePicker/styles/index.css +1 -79
  29. package/Divider/styles/index.css +0 -78
  30. package/Drawer/styles/index.css +0 -78
  31. package/Dropdown/styles/index.css +0 -78
  32. package/FlexboxGrid/styles/index.css +0 -78
  33. package/Footer/styles/index.css +0 -78
  34. package/Form/styles/index.css +0 -78
  35. package/FormControl/styles/index.css +0 -78
  36. package/FormControlLabel/styles/index.css +0 -78
  37. package/FormErrorMessage/styles/index.css +0 -78
  38. package/FormGroup/styles/index.css +0 -78
  39. package/FormHelpText/styles/index.css +0 -78
  40. package/FormStack/styles/index.css +0 -78
  41. package/Grid/styles/index.css +0 -78
  42. package/Header/styles/index.css +0 -78
  43. package/Heading/styles/index.css +0 -78
  44. package/HeadingGroup/styles/index.css +0 -78
  45. package/Highlight/styles/index.css +0 -78
  46. package/IconButton/styles/index.css +0 -78
  47. package/Image/styles/index.css +0 -78
  48. package/InlineEdit/styles/index.css +0 -78
  49. package/Input/styles/index.css +0 -78
  50. package/InputGroup/styles/index.css +1 -79
  51. package/InputNumber/styles/index.css +1 -79
  52. package/InputPicker/styles/index.css +1 -79
  53. package/Kbd/styles/index.css +0 -78
  54. package/Link/styles/index.css +0 -78
  55. package/List/styles/index.css +0 -78
  56. package/Loader/styles/index.css +0 -78
  57. package/Menu/styles/index.css +0 -78
  58. package/Message/styles/index.css +0 -78
  59. package/Modal/styles/index.css +0 -78
  60. package/MultiCascadeTree/styles/index.css +1 -79
  61. package/MultiCascader/styles/index.css +1 -79
  62. package/Nav/styles/index.css +0 -78
  63. package/Navbar/styles/index.css +0 -78
  64. package/Notification/styles/index.css +0 -78
  65. package/NumberInput/styles/index.css +1 -79
  66. package/Pagination/styles/index.css +1 -79
  67. package/Panel/styles/index.css +0 -78
  68. package/PanelGroup/styles/index.css +0 -78
  69. package/PasswordInput/styles/index.css +1 -79
  70. package/PasswordStrengthMeter/styles/index.css +0 -78
  71. package/PinInput/styles/index.css +0 -78
  72. package/Placeholder/styles/index.css +0 -78
  73. package/Popover/styles/index.css +0 -78
  74. package/Progress/styles/index.css +0 -78
  75. package/ProgressCircle/styles/index.css +0 -78
  76. package/Radio/styles/index.css +0 -78
  77. package/RadioGroup/styles/index.css +0 -78
  78. package/RadioTile/styles/index.css +0 -78
  79. package/RangeSlider/styles/index.css +0 -78
  80. package/Rate/styles/index.css +0 -78
  81. package/SegmentedControl/styles/index.css +2 -0
  82. package/SelectPicker/styles/index.css +1 -79
  83. package/Sidebar/styles/index.css +0 -78
  84. package/Sidenav/styles/index.css +0 -78
  85. package/Slider/styles/index.css +0 -78
  86. package/Stack/styles/index.css +0 -78
  87. package/Stat/styles/index.css +0 -78
  88. package/StatGroup/styles/index.css +0 -78
  89. package/Steps/styles/index.css +0 -78
  90. package/Table/styles/index.css +0 -78
  91. package/Tabs/styles/index.css +0 -78
  92. package/Tag/styles/index.css +0 -78
  93. package/TagGroup/styles/index.css +0 -78
  94. package/TagInput/styles/index.css +1 -79
  95. package/TagPicker/styles/index.css +1 -79
  96. package/Text/styles/index.css +0 -78
  97. package/Textarea/styles/index.css +0 -78
  98. package/TimePicker/styles/index.css +1 -79
  99. package/TimeRangePicker/styles/index.css +1 -79
  100. package/Timeline/styles/index.css +0 -78
  101. package/Toggle/styles/index.css +0 -78
  102. package/Tooltip/styles/index.css +0 -78
  103. package/Tree/styles/index.css +1 -79
  104. package/TreePicker/styles/index.css +1 -79
  105. package/Uploader/styles/index.css +0 -78
  106. package/cjs/ButtonToolbar/ButtonToolbar.js +2 -0
  107. package/cjs/InputPicker/utils.d.ts +1 -1
  108. package/cjs/Nav/Nav.d.ts +2 -3
  109. package/cjs/Stack/Stack.js +20 -5
  110. package/cjs/Stack/utils.d.ts +9 -0
  111. package/cjs/Stack/utils.js +38 -0
  112. package/cjs/Tabs/Tabs.d.ts +4 -2
  113. package/cjs/internals/Box/Box.d.ts +27 -27
  114. package/cjs/internals/Box/Box.js +13 -8
  115. package/cjs/internals/Box/utils.d.ts +4 -1
  116. package/cjs/internals/Box/utils.js +154 -13
  117. package/cjs/internals/constants/index.js +2 -2
  118. package/cjs/internals/hooks/useStyled.d.ts +60 -0
  119. package/cjs/internals/hooks/useStyled.js +257 -0
  120. package/cjs/internals/utils/colours.js +1 -1
  121. package/cjs/internals/utils/style-sheet/index.d.ts +1 -0
  122. package/cjs/internals/utils/style-sheet/index.js +6 -0
  123. package/cjs/internals/utils/style-sheet/style-manager.d.ts +50 -0
  124. package/cjs/internals/utils/style-sheet/style-manager.js +97 -0
  125. package/dist/rsuite-no-reset.css +3 -83
  126. package/dist/rsuite-no-reset.min.css +1 -1
  127. package/dist/rsuite.css +3 -83
  128. package/dist/rsuite.js +42 -9
  129. package/dist/rsuite.js.map +1 -1
  130. package/dist/rsuite.min.css +1 -1
  131. package/dist/rsuite.min.js +1 -1
  132. package/dist/rsuite.min.js.map +1 -1
  133. package/esm/ButtonToolbar/ButtonToolbar.js +2 -0
  134. package/esm/InputPicker/utils.d.ts +1 -1
  135. package/esm/Nav/Nav.d.ts +2 -3
  136. package/esm/Stack/Stack.js +21 -6
  137. package/esm/Stack/utils.d.ts +9 -0
  138. package/esm/Stack/utils.js +35 -0
  139. package/esm/Tabs/Tabs.d.ts +4 -2
  140. package/esm/internals/Box/Box.d.ts +27 -27
  141. package/esm/internals/Box/Box.js +9 -4
  142. package/esm/internals/Box/utils.d.ts +4 -1
  143. package/esm/internals/Box/utils.js +153 -13
  144. package/esm/internals/constants/index.js +2 -2
  145. package/esm/internals/hooks/useStyled.d.ts +60 -0
  146. package/esm/internals/hooks/useStyled.js +251 -0
  147. package/esm/internals/utils/colours.js +1 -1
  148. package/esm/internals/utils/style-sheet/index.d.ts +1 -0
  149. package/esm/internals/utils/style-sheet/index.js +2 -1
  150. package/esm/internals/utils/style-sheet/style-manager.d.ts +50 -0
  151. package/esm/internals/utils/style-sheet/style-manager.js +93 -0
  152. 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,
@@ -1 +1 @@
1
- export declare const convertSize: (size?: string) => "lg" | "md" | "sm";
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' | 'pills';
10
+ appearance?: 'default' | 'subtle' | 'tabs';
12
11
  /**
13
12
  * Whether the Nav component is reversed.
14
13
  */
@@ -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 { forwardRef, mergeStyles, getCssValue } from "../internals/utils/index.js";
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 classes = merge(className, withPrefix({
45
+ const baseClasses = merge(className, withPrefix({
45
46
  wrap
46
47
  }), ...responsive(direction));
47
- const styles = mergeStyles(style, cssVar('spacing', spacing, getCssValue), cssVar('align', align), cssVar('justify', justify));
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: classes,
54
- style: styles
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
+ }
@@ -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
- * @version 'pills' is supported in version 5.68.0
12
+ *
11
13
  */
12
- appearance?: 'tabs' | 'subtle' | 'pills';
14
+ appearance?: 'tabs' | 'subtle';
13
15
  /**
14
16
  * The key of the active tab.
15
17
  */
@@ -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,
@@ -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: boxStyle
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, string | number | undefined>;
20
+ export declare const getBoxCSSVariables: (props: Record<string, any>) => Record<string, CSSVarValue>;
21
+ export {};
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { getCssValue, getSizeStyle, getColorVar } from "../utils/index.js";
3
-
3
+ import { BREAKPOINTS } from "../constants/index.js";
4
4
  // Mapping for padding properties to their CSS style equivalents
5
5
  const paddingStyleMap = {
6
6
  p: 'padding',
@@ -70,6 +70,45 @@ export const omitBoxProps = props => {
70
70
  return filteredProps;
71
71
  };
72
72
 
73
+ /**
74
+ * Checks if a value is a responsive value object
75
+ * @param value - Value to check
76
+ * @returns True if the value is a responsive value object
77
+ */
78
+ function isResponsiveValue(value) {
79
+ return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).some(key => BREAKPOINTS.includes(key));
80
+ }
81
+
82
+ /**
83
+ * Process a value that might be a responsive value
84
+ * @param value - Value to process
85
+ * @param processor - Function to process non-responsive values
86
+ * @returns Processed value or responsive object with processed values
87
+ */
88
+ function processResponsiveValue(value, processor) {
89
+ if (value === undefined) {
90
+ return undefined;
91
+ }
92
+ if (isResponsiveValue(value)) {
93
+ const result = {};
94
+ Object.entries(value).forEach(([breakpoint, val]) => {
95
+ if (val !== undefined) {
96
+ const processed = processor(val);
97
+ if (processed !== undefined) {
98
+ result[breakpoint] = processed;
99
+ }
100
+ }
101
+ });
102
+ return Object.keys(result).length > 0 ? result : undefined;
103
+ }
104
+ return processor(value);
105
+ }
106
+
107
+ // Type for CSS variable values that can be string, number, or responsive values
108
+
109
+ // Silence ESLint warnings for unused parameters in forEach callbacks
110
+ /* eslint-disable @typescript-eslint/no-unused-vars */
111
+
73
112
  /**
74
113
  * Converts layout properties to CSS variables with abbreviated names
75
114
  * @param props Object containing layout properties
@@ -77,42 +116,143 @@ export const omitBoxProps = props => {
77
116
  */
78
117
  export const getBoxCSSVariables = props => {
79
118
  const cssVars = {};
119
+ const prefix = `--rs-box-`;
80
120
 
81
121
  // Process padding properties
82
122
  Object.keys(paddingStyleMap).forEach(propKey => {
83
123
  if (props[propKey] !== undefined) {
84
- cssVars[`--rs-box-${propKey}`] = getCssValue(props[propKey]);
124
+ cssVars[`${prefix}${propKey}`] = processResponsiveValue(props[propKey], val => getCssValue(val));
85
125
  }
86
126
  });
87
127
 
88
128
  // Process margin properties
89
129
  Object.keys(marginStyleMap).forEach(propKey => {
90
130
  if (props[propKey] !== undefined) {
91
- cssVars[`--rs-box-${propKey}`] = getCssValue(props[propKey]);
131
+ cssVars[`${prefix}${propKey}`] = processResponsiveValue(props[propKey], val => getCssValue(val));
92
132
  }
93
133
  });
94
134
 
95
135
  // Process size properties
96
136
  Object.keys(sizeStyleMap).forEach(propKey => {
97
137
  if (props[propKey] !== undefined) {
98
- cssVars[`--rs-box-${propKey}`] = getCssValue(props[propKey]);
138
+ cssVars[`${prefix}${propKey}`] = processResponsiveValue(props[propKey], val => getCssValue(val));
99
139
  }
100
140
  });
101
141
  if (props.bd !== undefined) {
102
- cssVars['--rs-box-bd'] = getCssValue(props.bd);
142
+ cssVars[`${prefix}bd`] = processResponsiveValue(props.bd, val => getCssValue(val));
103
143
  }
104
144
  if (props.display !== undefined) {
105
- cssVars['--rs-box-display'] = props.display;
145
+ cssVars[`${prefix}display`] = processResponsiveValue(props.display, val => val);
106
146
  }
107
147
  if (props.c !== undefined) {
108
- cssVars['--rs-box-c'] = getColorVar(props.c);
148
+ cssVars[`${prefix}c`] = processResponsiveValue(props.c, val => getColorVar(val));
109
149
  }
110
150
  if (props.bg !== undefined) {
111
- cssVars['--rs-box-bg'] = getColorVar(props.bg);
151
+ cssVars[`${prefix}bg`] = processResponsiveValue(props.bg, val => getColorVar(val));
152
+ }
153
+
154
+ // Handle special cases for rounded and shadow
155
+ if (props.rounded !== undefined) {
156
+ const processRounded = val => {
157
+ const result = getSizeStyle(val, 'box', 'rounded');
158
+ return result ? result : undefined;
159
+ };
160
+ if (isResponsiveValue(props.rounded)) {
161
+ // Handle responsive rounded values
162
+ const responsiveRounded = {};
163
+ Object.entries(props.rounded).forEach(([breakpoint, val]) => {
164
+ if (val !== undefined) {
165
+ const styleObj = processRounded(val);
166
+ if (styleObj) {
167
+ responsiveRounded[breakpoint] = styleObj;
168
+ }
169
+ }
170
+ });
171
+
172
+ // For each CSS variable key in the rounded styles, create a responsive value
173
+ const processedKeys = new Set();
174
+ Object.entries(responsiveRounded).forEach(([_breakpoint, styleObj]) => {
175
+ if (styleObj) {
176
+ Object.entries(styleObj).forEach(([key, _value]) => {
177
+ processedKeys.add(key);
178
+ });
179
+ }
180
+ });
181
+ processedKeys.forEach(key => {
182
+ const responsiveValue = {};
183
+ Object.entries(responsiveRounded).forEach(([breakpoint, styleObj]) => {
184
+ if (styleObj && styleObj[key] !== undefined) {
185
+ // Ensure we're only using string values for CSS variables
186
+ const value = styleObj[key];
187
+ if (typeof value === 'string' || typeof value === 'number') {
188
+ responsiveValue[breakpoint] = value;
189
+ }
190
+ }
191
+ });
192
+ if (Object.keys(responsiveValue).length > 0) {
193
+ cssVars[key] = responsiveValue;
194
+ }
195
+ });
196
+ } else {
197
+ // Handle non-responsive rounded value
198
+ const styleObj = processRounded(props.rounded);
199
+ if (styleObj) {
200
+ Object.entries(styleObj).forEach(([key, value]) => {
201
+ cssVars[key] = value;
202
+ });
203
+ }
204
+ }
205
+ }
206
+ if (props.shadow !== undefined) {
207
+ const processShadow = val => {
208
+ const result = getSizeStyle(val, 'box', 'shadow');
209
+ return result ? result : undefined;
210
+ };
211
+ if (isResponsiveValue(props.shadow)) {
212
+ // Handle responsive shadow values
213
+ const responsiveShadow = {};
214
+ Object.entries(props.shadow).forEach(([breakpoint, val]) => {
215
+ if (val !== undefined) {
216
+ const styleObj = processShadow(val);
217
+ if (styleObj) {
218
+ responsiveShadow[breakpoint] = styleObj;
219
+ }
220
+ }
221
+ });
222
+
223
+ // For each CSS variable key in the shadow styles, create a responsive value
224
+ const processedKeys = new Set();
225
+ Object.entries(responsiveShadow).forEach(([_breakpoint, styleObj]) => {
226
+ if (styleObj) {
227
+ Object.entries(styleObj).forEach(([key, _value]) => {
228
+ processedKeys.add(key);
229
+ });
230
+ }
231
+ });
232
+ processedKeys.forEach(key => {
233
+ const responsiveValue = {};
234
+ Object.entries(responsiveShadow).forEach(([breakpoint, styleObj]) => {
235
+ if (styleObj && styleObj[key] !== undefined) {
236
+ // Ensure we're only using string values for CSS variables
237
+ const value = styleObj[key];
238
+ if (typeof value === 'string' || typeof value === 'number') {
239
+ responsiveValue[breakpoint] = value;
240
+ }
241
+ }
242
+ });
243
+ if (Object.keys(responsiveValue).length > 0) {
244
+ cssVars[key] = responsiveValue;
245
+ }
246
+ });
247
+ } else {
248
+ // Handle non-responsive shadow value
249
+ const styleObj = processShadow(props.shadow);
250
+ if (styleObj) {
251
+ Object.entries(styleObj).forEach(([key, value]) => {
252
+ cssVars[key] = value;
253
+ });
254
+ }
255
+ }
112
256
  }
113
- return {
114
- ...cssVars,
115
- ...getSizeStyle(props.rounded, 'box', 'rounded'),
116
- ...getSizeStyle(props.shadow, 'box', 'shadow')
117
- };
257
+ return cssVars;
118
258
  };
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- export const SIZE = ['lg', 'md', 'sm', 'xs'];
3
- export const BREAKPOINTS = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'];
2
+ export const SIZE = ['xs', 'sm', 'md', 'lg'];
3
+ export const BREAKPOINTS = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
4
4
  export const STATUS = ['success', 'warning', 'error', 'info'];
5
5
  export const COLOR = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'violet'];
6
6
  export const PLACEMENT_4 = ['top', 'bottom', 'right', 'left'];
@@ -0,0 +1,60 @@
1
+ import { CSSProperties } from 'react';
2
+ import type { Breakpoints, ResponsiveValue } from '../types';
3
+ /**
4
+ * Options for the useStyled hook
5
+ */
6
+ interface UseStyledOptions {
7
+ /**
8
+ * CSS variables to apply
9
+ */
10
+ cssVars?: Record<string, string | number | undefined | ResponsiveValue<string | number>>;
11
+ /**
12
+ * Base class name to include
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Base style to merge with
17
+ */
18
+ style?: CSSProperties;
19
+ /**
20
+ * Whether this element should be styled
21
+ * Can be a boolean or a breakpoint string
22
+ */
23
+ enabled?: boolean | Breakpoints;
24
+ /**
25
+ * Prefix for the generated class name
26
+ * @default 'rs'
27
+ */
28
+ prefix?: string;
29
+ }
30
+ /**
31
+ * Result of the useStyled hook
32
+ */
33
+ interface UseStyledResult {
34
+ /**
35
+ * Combined class name including the unique identifier
36
+ */
37
+ className: string | undefined;
38
+ /**
39
+ * Style object without CSS variables
40
+ */
41
+ style: CSSProperties | undefined;
42
+ /**
43
+ * Unique identifier for this styled element
44
+ */
45
+ id: string;
46
+ }
47
+ /**
48
+ * Custom hook for managing component styling with scoped CSS variables
49
+ *
50
+ * This hook handles:
51
+ * 1. Generating a unique class name for the component
52
+ * 2. Creating a scoped style rule to prevent CSS variable inheritance
53
+ * 3. Managing the lifecycle of style rules
54
+ * 4. Handling responsive values for different breakpoints
55
+ *
56
+ * @param options - Styling options
57
+ * @returns Styling properties to apply to the component
58
+ */
59
+ export declare function useStyled(options: UseStyledOptions): UseStyledResult;
60
+ export default useStyled;