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
@@ -30,6 +30,8 @@ const ButtonToolbar = (0, _utils.forwardRef)((props, ref) => {
30
30
  } = (0, _hooks.useStyles)(classPrefix);
31
31
  const classes = merge(className, withPrefix());
32
32
  return /*#__PURE__*/_react.default.createElement(_Stack.default, (0, _extends2.default)({
33
+ wrap: true,
34
+ spacing: 8,
33
35
  as: as,
34
36
  role: role,
35
37
  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/cjs/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
  */
@@ -8,8 +8,10 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _StackItem = _interopRequireDefault(require("./StackItem"));
10
10
  var _Box = _interopRequireDefault(require("../internals/Box"));
11
+ var _useStyled = require("../internals/hooks/useStyled");
11
12
  var _utils = require("../internals/utils");
12
13
  var _hooks = require("../internals/hooks");
14
+ var _utils2 = require("./utils");
13
15
  const Subcomponents = {
14
16
  Item: _StackItem.default
15
17
  };
@@ -43,20 +45,33 @@ const Stack = (0, _utils.forwardRef)((props, ref) => {
43
45
  const {
44
46
  withPrefix,
45
47
  merge,
46
- cssVar,
47
48
  responsive
48
49
  } = (0, _hooks.useStyles)(classPrefix);
49
- const classes = merge(className, withPrefix({
50
+ const baseClasses = merge(className, withPrefix({
50
51
  wrap
51
52
  }), ...responsive(direction));
52
- const styles = (0, _utils.mergeStyles)(style, cssVar('spacing', spacing, _utils.getCssValue), cssVar('align', align), cssVar('justify', justify));
53
+
54
+ // Generate CSS variables for Stack
55
+ const cssVars = (0, _utils2.generateStackCssVars)({
56
+ spacing,
57
+ align,
58
+ justify
59
+ });
60
+
61
+ // Use the useStyled hook to manage CSS variables
62
+ const styled = (0, _useStyled.useStyled)({
63
+ cssVars,
64
+ className: baseClasses,
65
+ style,
66
+ prefix: classPrefix
67
+ });
53
68
  const filteredChildren = _react.default.Children.toArray(children);
54
69
  const childCount = filteredChildren.length;
55
70
  return /*#__PURE__*/_react.default.createElement(_Box.default, (0, _extends2.default)({
56
71
  as: as,
57
72
  ref: ref,
58
- className: classes,
59
- style: styles
73
+ className: styled.className,
74
+ style: styled.style
60
75
  }, rest), filteredChildren.map((child, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
61
76
  key: index
62
77
  }, 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,38 @@
1
+ 'use client';
2
+ "use strict";
3
+
4
+ exports.__esModule = true;
5
+ exports.generateStackCssVars = generateStackCssVars;
6
+ var _utils = require("../internals/utils");
7
+ /**
8
+ * Generate CSS variables for Stack component
9
+ */
10
+ function generateStackCssVars({
11
+ spacing,
12
+ align,
13
+ justify
14
+ }) {
15
+ const cssVars = {};
16
+ const prefix = `--rs-stack-`;
17
+
18
+ // Add spacing CSS variable
19
+ if (spacing !== undefined) {
20
+ // Handle array or single value for spacing
21
+ if (Array.isArray(spacing)) {
22
+ cssVars[`${prefix}spacing`] = spacing.map(s => (0, _utils.getCssValue)(s)).join(' ');
23
+ } else {
24
+ cssVars[`${prefix}spacing`] = (0, _utils.getCssValue)(spacing);
25
+ }
26
+ }
27
+
28
+ // Add align CSS variable
29
+ if (align !== undefined) {
30
+ cssVars[`${prefix}align`] = align;
31
+ }
32
+
33
+ // Add justify CSS variable
34
+ if (justify !== undefined) {
35
+ cssVars[`${prefix}justify`] = justify;
36
+ }
37
+ return cssVars;
38
+ }
@@ -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,
@@ -7,9 +7,9 @@ exports.default = void 0;
7
7
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
10
- var _utils = require("../utils");
11
10
  var _forwardRef = require("../utils/react/forwardRef");
12
- var _utils2 = require("./utils");
11
+ var _utils = require("./utils");
12
+ var _useStyled = require("../hooks/useStyled");
13
13
  /**
14
14
  * Box component is the base component for all components,
15
15
  * providing shorthand for style properties.
@@ -26,18 +26,23 @@ const Box = (0, _forwardRef.forwardRef)((props, ref) => {
26
26
  style,
27
27
  ...rest
28
28
  } = props;
29
- const boxProps = (0, _utils2.extractBoxProps)(rest);
30
- const domProps = (0, _utils2.omitBoxProps)(rest);
31
- const boxCSSVars = (0, _utils2.getBoxCSSVariables)(boxProps);
32
- const boxStyle = (0, _utils.mergeStyles)(style, boxCSSVars);
29
+ const boxProps = (0, _utils.extractBoxProps)(rest);
30
+ const domProps = (0, _utils.omitBoxProps)(rest);
31
+ const boxCSSVars = (0, _utils.getBoxCSSVariables)(boxProps);
33
32
  const isBox = !(0, _isEmpty.default)(boxCSSVars) || showFrom || hideFrom;
33
+ const styled = (0, _useStyled.useStyled)({
34
+ cssVars: boxCSSVars,
35
+ className,
36
+ style,
37
+ enabled: isBox
38
+ });
34
39
  return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({
35
40
  ref: ref,
36
41
  "data-rs": isBox ? 'box' : undefined,
37
42
  "data-visible-from": showFrom,
38
43
  "data-hidden-from": hideFrom,
39
- className: className,
40
- style: boxStyle
44
+ className: styled.className,
45
+ style: styled.style
41
46
  }, domProps), children);
42
47
  });
43
48
  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 {};
@@ -4,6 +4,7 @@
4
4
  exports.__esModule = true;
5
5
  exports.omitBoxProps = exports.getBoxCSSVariables = exports.extractBoxProps = void 0;
6
6
  var _utils = require("../utils");
7
+ var _constants = require("../constants");
7
8
  // Mapping for padding properties to their CSS style equivalents
8
9
  const paddingStyleMap = {
9
10
  p: 'padding',
@@ -74,51 +75,191 @@ const omitBoxProps = props => {
74
75
  return filteredProps;
75
76
  };
76
77
 
78
+ /**
79
+ * Checks if a value is a responsive value object
80
+ * @param value - Value to check
81
+ * @returns True if the value is a responsive value object
82
+ */
83
+ exports.omitBoxProps = omitBoxProps;
84
+ function isResponsiveValue(value) {
85
+ return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).some(key => _constants.BREAKPOINTS.includes(key));
86
+ }
87
+
88
+ /**
89
+ * Process a value that might be a responsive value
90
+ * @param value - Value to process
91
+ * @param processor - Function to process non-responsive values
92
+ * @returns Processed value or responsive object with processed values
93
+ */
94
+ function processResponsiveValue(value, processor) {
95
+ if (value === undefined) {
96
+ return undefined;
97
+ }
98
+ if (isResponsiveValue(value)) {
99
+ const result = {};
100
+ Object.entries(value).forEach(([breakpoint, val]) => {
101
+ if (val !== undefined) {
102
+ const processed = processor(val);
103
+ if (processed !== undefined) {
104
+ result[breakpoint] = processed;
105
+ }
106
+ }
107
+ });
108
+ return Object.keys(result).length > 0 ? result : undefined;
109
+ }
110
+ return processor(value);
111
+ }
112
+
113
+ // Type for CSS variable values that can be string, number, or responsive values
114
+
115
+ // Silence ESLint warnings for unused parameters in forEach callbacks
116
+ /* eslint-disable @typescript-eslint/no-unused-vars */
117
+
77
118
  /**
78
119
  * Converts layout properties to CSS variables with abbreviated names
79
120
  * @param props Object containing layout properties
80
121
  * @returns Object with CSS variables
81
122
  */
82
- exports.omitBoxProps = omitBoxProps;
83
123
  const getBoxCSSVariables = props => {
84
124
  const cssVars = {};
125
+ const prefix = `--rs-box-`;
85
126
 
86
127
  // Process padding properties
87
128
  Object.keys(paddingStyleMap).forEach(propKey => {
88
129
  if (props[propKey] !== undefined) {
89
- cssVars[`--rs-box-${propKey}`] = (0, _utils.getCssValue)(props[propKey]);
130
+ cssVars[`${prefix}${propKey}`] = processResponsiveValue(props[propKey], val => (0, _utils.getCssValue)(val));
90
131
  }
91
132
  });
92
133
 
93
134
  // Process margin properties
94
135
  Object.keys(marginStyleMap).forEach(propKey => {
95
136
  if (props[propKey] !== undefined) {
96
- cssVars[`--rs-box-${propKey}`] = (0, _utils.getCssValue)(props[propKey]);
137
+ cssVars[`${prefix}${propKey}`] = processResponsiveValue(props[propKey], val => (0, _utils.getCssValue)(val));
97
138
  }
98
139
  });
99
140
 
100
141
  // Process size properties
101
142
  Object.keys(sizeStyleMap).forEach(propKey => {
102
143
  if (props[propKey] !== undefined) {
103
- cssVars[`--rs-box-${propKey}`] = (0, _utils.getCssValue)(props[propKey]);
144
+ cssVars[`${prefix}${propKey}`] = processResponsiveValue(props[propKey], val => (0, _utils.getCssValue)(val));
104
145
  }
105
146
  });
106
147
  if (props.bd !== undefined) {
107
- cssVars['--rs-box-bd'] = (0, _utils.getCssValue)(props.bd);
148
+ cssVars[`${prefix}bd`] = processResponsiveValue(props.bd, val => (0, _utils.getCssValue)(val));
108
149
  }
109
150
  if (props.display !== undefined) {
110
- cssVars['--rs-box-display'] = props.display;
151
+ cssVars[`${prefix}display`] = processResponsiveValue(props.display, val => val);
111
152
  }
112
153
  if (props.c !== undefined) {
113
- cssVars['--rs-box-c'] = (0, _utils.getColorVar)(props.c);
154
+ cssVars[`${prefix}c`] = processResponsiveValue(props.c, val => (0, _utils.getColorVar)(val));
114
155
  }
115
156
  if (props.bg !== undefined) {
116
- cssVars['--rs-box-bg'] = (0, _utils.getColorVar)(props.bg);
157
+ cssVars[`${prefix}bg`] = processResponsiveValue(props.bg, val => (0, _utils.getColorVar)(val));
158
+ }
159
+
160
+ // Handle special cases for rounded and shadow
161
+ if (props.rounded !== undefined) {
162
+ const processRounded = val => {
163
+ const result = (0, _utils.getSizeStyle)(val, 'box', 'rounded');
164
+ return result ? result : undefined;
165
+ };
166
+ if (isResponsiveValue(props.rounded)) {
167
+ // Handle responsive rounded values
168
+ const responsiveRounded = {};
169
+ Object.entries(props.rounded).forEach(([breakpoint, val]) => {
170
+ if (val !== undefined) {
171
+ const styleObj = processRounded(val);
172
+ if (styleObj) {
173
+ responsiveRounded[breakpoint] = styleObj;
174
+ }
175
+ }
176
+ });
177
+
178
+ // For each CSS variable key in the rounded styles, create a responsive value
179
+ const processedKeys = new Set();
180
+ Object.entries(responsiveRounded).forEach(([_breakpoint, styleObj]) => {
181
+ if (styleObj) {
182
+ Object.entries(styleObj).forEach(([key, _value]) => {
183
+ processedKeys.add(key);
184
+ });
185
+ }
186
+ });
187
+ processedKeys.forEach(key => {
188
+ const responsiveValue = {};
189
+ Object.entries(responsiveRounded).forEach(([breakpoint, styleObj]) => {
190
+ if (styleObj && styleObj[key] !== undefined) {
191
+ // Ensure we're only using string values for CSS variables
192
+ const value = styleObj[key];
193
+ if (typeof value === 'string' || typeof value === 'number') {
194
+ responsiveValue[breakpoint] = value;
195
+ }
196
+ }
197
+ });
198
+ if (Object.keys(responsiveValue).length > 0) {
199
+ cssVars[key] = responsiveValue;
200
+ }
201
+ });
202
+ } else {
203
+ // Handle non-responsive rounded value
204
+ const styleObj = processRounded(props.rounded);
205
+ if (styleObj) {
206
+ Object.entries(styleObj).forEach(([key, value]) => {
207
+ cssVars[key] = value;
208
+ });
209
+ }
210
+ }
211
+ }
212
+ if (props.shadow !== undefined) {
213
+ const processShadow = val => {
214
+ const result = (0, _utils.getSizeStyle)(val, 'box', 'shadow');
215
+ return result ? result : undefined;
216
+ };
217
+ if (isResponsiveValue(props.shadow)) {
218
+ // Handle responsive shadow values
219
+ const responsiveShadow = {};
220
+ Object.entries(props.shadow).forEach(([breakpoint, val]) => {
221
+ if (val !== undefined) {
222
+ const styleObj = processShadow(val);
223
+ if (styleObj) {
224
+ responsiveShadow[breakpoint] = styleObj;
225
+ }
226
+ }
227
+ });
228
+
229
+ // For each CSS variable key in the shadow styles, create a responsive value
230
+ const processedKeys = new Set();
231
+ Object.entries(responsiveShadow).forEach(([_breakpoint, styleObj]) => {
232
+ if (styleObj) {
233
+ Object.entries(styleObj).forEach(([key, _value]) => {
234
+ processedKeys.add(key);
235
+ });
236
+ }
237
+ });
238
+ processedKeys.forEach(key => {
239
+ const responsiveValue = {};
240
+ Object.entries(responsiveShadow).forEach(([breakpoint, styleObj]) => {
241
+ if (styleObj && styleObj[key] !== undefined) {
242
+ // Ensure we're only using string values for CSS variables
243
+ const value = styleObj[key];
244
+ if (typeof value === 'string' || typeof value === 'number') {
245
+ responsiveValue[breakpoint] = value;
246
+ }
247
+ }
248
+ });
249
+ if (Object.keys(responsiveValue).length > 0) {
250
+ cssVars[key] = responsiveValue;
251
+ }
252
+ });
253
+ } else {
254
+ // Handle non-responsive shadow value
255
+ const styleObj = processShadow(props.shadow);
256
+ if (styleObj) {
257
+ Object.entries(styleObj).forEach(([key, value]) => {
258
+ cssVars[key] = value;
259
+ });
260
+ }
261
+ }
117
262
  }
118
- return {
119
- ...cssVars,
120
- ...(0, _utils.getSizeStyle)(props.rounded, 'box', 'rounded'),
121
- ...(0, _utils.getSizeStyle)(props.shadow, 'box', 'shadow')
122
- };
263
+ return cssVars;
123
264
  };
124
265
  exports.getBoxCSSVariables = getBoxCSSVariables;
@@ -3,8 +3,8 @@
3
3
 
4
4
  exports.__esModule = true;
5
5
  exports.TREE_NODE_DROP_POSITION = exports.STATUS = exports.SIZE = exports.PLACEMENT_AUTO = exports.PLACEMENT_8 = exports.PLACEMENT_4 = exports.PLACEMENT = exports.KEY_VALUES = exports.DATERANGE_DISABLED_TARGET = exports.COLOR = exports.CHECK_STATE = exports.BREAKPOINTS = void 0;
6
- const SIZE = exports.SIZE = ['lg', 'md', 'sm', 'xs'];
7
- const BREAKPOINTS = exports.BREAKPOINTS = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'];
6
+ const SIZE = exports.SIZE = ['xs', 'sm', 'md', 'lg'];
7
+ const BREAKPOINTS = exports.BREAKPOINTS = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
8
8
  const STATUS = exports.STATUS = ['success', 'warning', 'error', 'info'];
9
9
  const COLOR = exports.COLOR = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'violet'];
10
10
  const PLACEMENT_4 = exports.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;