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.
Files changed (193) 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/package.json +7 -0
  82. package/SegmentedControl/styles/index.css +159 -0
  83. package/SelectPicker/styles/index.css +1 -79
  84. package/Sidebar/styles/index.css +0 -78
  85. package/Sidenav/styles/index.css +0 -78
  86. package/Slider/styles/index.css +0 -78
  87. package/Stack/styles/index.css +0 -78
  88. package/Stat/styles/index.css +0 -78
  89. package/StatGroup/styles/index.css +0 -78
  90. package/Steps/styles/index.css +0 -78
  91. package/Table/styles/index.css +0 -78
  92. package/Tabs/styles/index.css +0 -78
  93. package/Tag/styles/index.css +0 -78
  94. package/TagGroup/styles/index.css +0 -78
  95. package/TagInput/styles/index.css +1 -79
  96. package/TagPicker/styles/index.css +1 -79
  97. package/Text/styles/index.css +0 -78
  98. package/Textarea/styles/index.css +0 -78
  99. package/TimePicker/styles/index.css +1 -79
  100. package/TimeRangePicker/styles/index.css +1 -79
  101. package/Timeline/styles/index.css +0 -78
  102. package/Toggle/styles/index.css +0 -78
  103. package/Tooltip/styles/index.css +0 -78
  104. package/Tree/styles/index.css +1 -79
  105. package/TreePicker/styles/index.css +1 -79
  106. package/Uploader/styles/index.css +0 -78
  107. package/cjs/ButtonToolbar/ButtonToolbar.js +2 -0
  108. package/cjs/Grid/utils/styles.d.ts +1 -1
  109. package/cjs/InputPicker/utils.d.ts +1 -1
  110. package/cjs/Nav/Nav.d.ts +2 -3
  111. package/cjs/RadioGroup/RadioGroup.d.ts +4 -1
  112. package/cjs/SegmentedControl/Indicator.d.ts +10 -0
  113. package/cjs/SegmentedControl/Indicator.js +22 -0
  114. package/cjs/SegmentedControl/SegmentedControl.d.ts +27 -0
  115. package/cjs/SegmentedControl/SegmentedControl.js +87 -0
  116. package/cjs/SegmentedControl/SegmentedItem.d.ts +16 -0
  117. package/cjs/SegmentedControl/SegmentedItem.js +44 -0
  118. package/cjs/SegmentedControl/hooks/useIndicatorPosition.d.ts +17 -0
  119. package/cjs/SegmentedControl/hooks/useIndicatorPosition.js +55 -0
  120. package/cjs/SegmentedControl/index.d.ts +4 -0
  121. package/cjs/SegmentedControl/index.js +11 -0
  122. package/cjs/Slider/ProgressBar.js +1 -1
  123. package/cjs/Stack/Stack.js +20 -5
  124. package/cjs/Stack/utils.d.ts +9 -0
  125. package/cjs/Stack/utils.js +38 -0
  126. package/cjs/Tabs/Tabs.d.ts +4 -2
  127. package/cjs/index.d.ts +1 -0
  128. package/cjs/index.js +6 -0
  129. package/cjs/internals/Box/Box.d.ts +27 -27
  130. package/cjs/internals/Box/Box.js +13 -8
  131. package/cjs/internals/Box/utils.d.ts +4 -1
  132. package/cjs/internals/Box/utils.js +154 -13
  133. package/cjs/internals/Provider/types.d.ts +2 -0
  134. package/cjs/internals/constants/index.js +2 -2
  135. package/cjs/internals/hooks/useElementResize.d.ts +2 -1
  136. package/cjs/internals/hooks/useElementResize.js +50 -7
  137. package/cjs/internals/hooks/useStyled.d.ts +60 -0
  138. package/cjs/internals/hooks/useStyled.js +257 -0
  139. package/cjs/internals/utils/colours.js +1 -1
  140. package/cjs/internals/utils/style-sheet/css.d.ts +1 -1
  141. package/cjs/internals/utils/style-sheet/css.js +1 -1
  142. package/cjs/internals/utils/style-sheet/index.d.ts +1 -0
  143. package/cjs/internals/utils/style-sheet/index.js +6 -0
  144. package/cjs/internals/utils/style-sheet/style-manager.d.ts +50 -0
  145. package/cjs/internals/utils/style-sheet/style-manager.js +97 -0
  146. package/dist/rsuite-no-reset.css +200 -101
  147. package/dist/rsuite-no-reset.min.css +1 -1
  148. package/dist/rsuite.css +200 -101
  149. package/dist/rsuite.js +172 -14
  150. package/dist/rsuite.js.map +1 -1
  151. package/dist/rsuite.min.css +1 -1
  152. package/dist/rsuite.min.js +1 -1
  153. package/dist/rsuite.min.js.map +1 -1
  154. package/esm/ButtonToolbar/ButtonToolbar.js +2 -0
  155. package/esm/Grid/utils/styles.d.ts +1 -1
  156. package/esm/InputPicker/utils.d.ts +1 -1
  157. package/esm/Nav/Nav.d.ts +2 -3
  158. package/esm/RadioGroup/RadioGroup.d.ts +4 -1
  159. package/esm/SegmentedControl/Indicator.d.ts +10 -0
  160. package/esm/SegmentedControl/Indicator.js +17 -0
  161. package/esm/SegmentedControl/SegmentedControl.d.ts +27 -0
  162. package/esm/SegmentedControl/SegmentedControl.js +81 -0
  163. package/esm/SegmentedControl/SegmentedItem.d.ts +16 -0
  164. package/esm/SegmentedControl/SegmentedItem.js +39 -0
  165. package/esm/SegmentedControl/hooks/useIndicatorPosition.d.ts +17 -0
  166. package/esm/SegmentedControl/hooks/useIndicatorPosition.js +50 -0
  167. package/esm/SegmentedControl/index.d.ts +4 -0
  168. package/esm/SegmentedControl/index.js +8 -0
  169. package/esm/Slider/ProgressBar.js +1 -1
  170. package/esm/Stack/Stack.js +21 -6
  171. package/esm/Stack/utils.d.ts +9 -0
  172. package/esm/Stack/utils.js +35 -0
  173. package/esm/Tabs/Tabs.d.ts +4 -2
  174. package/esm/index.d.ts +1 -0
  175. package/esm/index.js +1 -0
  176. package/esm/internals/Box/Box.d.ts +27 -27
  177. package/esm/internals/Box/Box.js +9 -4
  178. package/esm/internals/Box/utils.d.ts +4 -1
  179. package/esm/internals/Box/utils.js +153 -13
  180. package/esm/internals/Provider/types.d.ts +2 -0
  181. package/esm/internals/constants/index.js +2 -2
  182. package/esm/internals/hooks/useElementResize.d.ts +2 -1
  183. package/esm/internals/hooks/useElementResize.js +50 -7
  184. package/esm/internals/hooks/useStyled.d.ts +60 -0
  185. package/esm/internals/hooks/useStyled.js +251 -0
  186. package/esm/internals/utils/colours.js +1 -1
  187. package/esm/internals/utils/style-sheet/css.d.ts +1 -1
  188. package/esm/internals/utils/style-sheet/css.js +1 -1
  189. package/esm/internals/utils/style-sheet/index.d.ts +1 -0
  190. package/esm/internals/utils/style-sheet/index.js +2 -1
  191. package/esm/internals/utils/style-sheet/style-manager.d.ts +50 -0
  192. package/esm/internals/utils/style-sheet/style-manager.js +93 -0
  193. package/package.json +1 -1
package/cjs/index.js CHANGED
@@ -356,6 +356,12 @@ Object.keys(_SelectPicker).forEach(function (key) {
356
356
  if (key in exports && exports[key] === _SelectPicker[key]) return;
357
357
  exports[key] = _SelectPicker[key];
358
358
  });
359
+ var _SegmentedControl = require("./SegmentedControl");
360
+ Object.keys(_SegmentedControl).forEach(function (key) {
361
+ if (key === "default" || key === "__esModule") return;
362
+ if (key in exports && exports[key] === _SegmentedControl[key]) return;
363
+ exports[key] = _SegmentedControl[key];
364
+ });
359
365
  var _CheckPicker = require("./CheckPicker");
360
366
  Object.keys(_CheckPicker).forEach(function (key) {
361
367
  if (key === "default" || key === "__esModule") return;
@@ -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;
@@ -87,6 +87,7 @@ import type { RangeSliderProps } from '../../RangeSlider';
87
87
  import type { RateProps } from '../../Rate';
88
88
  import type { RowProps } from '../../Row';
89
89
  import type { SelectPickerProps } from '../../SelectPicker';
90
+ import type { SegmentedControlProps } from '../../SegmentedControl';
90
91
  import type { SidebarProps } from '../../Sidebar';
91
92
  import type { SidenavProps } from '../../Sidenav';
92
93
  import type { SliderProps } from '../../Slider';
@@ -209,6 +210,7 @@ export interface ReactSuiteComponents {
209
210
  Rate: ComponentProps<RateProps>;
210
211
  Row: ComponentProps<RowProps>;
211
212
  SelectPicker: ComponentProps<SelectPickerProps>;
213
+ SegmentedControl: ComponentProps<SegmentedControlProps>;
212
214
  Sidebar: ComponentProps<SidebarProps>;
213
215
  Sidenav: ComponentProps<SidenavProps>;
214
216
  Slider: ComponentProps<SliderProps>;
@@ -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'];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * Attach the event handler directly to the specified DOM element,
3
4
  * and it will be triggered when the size of the DOM element is changed.
@@ -5,5 +6,5 @@
5
6
  * @param eventTarget The target to listen for events on
6
7
  * @param listener An event handler
7
8
  */
8
- export declare function useElementResize(eventTarget: Element | null | (() => Element | null), listener: ResizeObserverCallback): void;
9
+ export declare function useElementResize(eventTarget: Element | null | (() => Element | null) | React.RefObject<Element | null>, listener: ResizeObserverCallback): void;
9
10
  export default useElementResize;
@@ -15,18 +15,61 @@ var _resizeObserver = require("@juggle/resize-observer");
15
15
  */
16
16
  function useElementResize(eventTarget, listener) {
17
17
  const resizeObserver = (0, _react.useRef)(null);
18
+ const currentElement = (0, _react.useRef)(null);
19
+
20
+ // Create the observer
18
21
  (0, _react.useEffect)(() => {
19
- if (!resizeObserver.current) {
20
- const target = typeof eventTarget === 'function' ? eventTarget() : eventTarget;
21
- if (target) {
22
- resizeObserver.current = new _resizeObserver.ResizeObserver(listener);
23
- resizeObserver.current.observe(target);
22
+ // Get the target element
23
+ let target = null;
24
+ if (eventTarget) {
25
+ if (typeof eventTarget === 'function') {
26
+ target = eventTarget();
27
+ } else if ('current' in eventTarget) {
28
+ target = eventTarget.current;
29
+ } else {
30
+ target = eventTarget;
31
+ }
32
+ }
33
+
34
+ // If target changed, disconnect the previous observer
35
+ if (currentElement.current !== target) {
36
+ if (resizeObserver.current) {
37
+ resizeObserver.current.disconnect();
38
+ resizeObserver.current = null;
24
39
  }
40
+ currentElement.current = target;
41
+ }
42
+
43
+ // If we have a target and no observer, create one
44
+ if (target && !resizeObserver.current) {
45
+ const observer = new _resizeObserver.ResizeObserver(listener);
46
+ observer.observe(target);
47
+ resizeObserver.current = observer;
25
48
  }
49
+
50
+ // Cleanup function
26
51
  return () => {
27
- var _resizeObserver$curre;
28
- (_resizeObserver$curre = resizeObserver.current) === null || _resizeObserver$curre === void 0 || _resizeObserver$curre.disconnect();
52
+ if (resizeObserver.current) {
53
+ resizeObserver.current.disconnect();
54
+ resizeObserver.current = null;
55
+ }
56
+ currentElement.current = null;
29
57
  };
30
58
  }, [eventTarget, listener]);
59
+
60
+ // Update the current element reference if it changes
61
+ (0, _react.useEffect)(() => {
62
+ if (eventTarget) {
63
+ if (typeof eventTarget === 'function') {
64
+ currentElement.current = eventTarget();
65
+ } else if ('current' in eventTarget) {
66
+ currentElement.current = eventTarget.current;
67
+ } else {
68
+ currentElement.current = eventTarget;
69
+ }
70
+ } else {
71
+ currentElement.current = null;
72
+ }
73
+ }, [eventTarget]);
31
74
  }
32
75
  var _default = exports.default = useElementResize;
@@ -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;