rsuite 6.0.0-canary-20250622 → 6.0.0-canary-20250702
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/AutoComplete/styles/index.css +156 -161
- package/AvatarGroup/styles/index.css +1 -10
- package/Badge/styles/index.css +21 -21
- package/Button/styles/index.css +78 -63
- package/ButtonGroup/styles/index.css +15 -12
- package/ButtonToolbar/styles/index.css +1 -10
- package/CHANGELOG.md +9 -0
- package/Calendar/styles/index.css +92 -67
- package/Card/styles/index.css +7 -7
- package/CascadeTree/styles/index.css +8 -9
- package/Cascader/styles/index.css +160 -164
- package/CheckPicker/styles/index.css +173 -178
- package/CheckTree/styles/index.css +175 -180
- package/CheckTreePicker/styles/index.css +175 -180
- package/Checkbox/styles/index.css +21 -28
- package/CheckboxGroup/styles/index.css +1 -1
- package/DateInput/styles/index.css +8 -18
- package/DatePicker/styles/index.css +173 -168
- package/DateRangeInput/styles/index.css +8 -18
- package/DateRangePicker/styles/index.css +173 -168
- package/Dropdown/styles/index.css +110 -94
- package/IconButton/styles/index.css +95 -79
- package/InlineEdit/styles/index.css +12 -19
- package/Input/styles/index.css +8 -18
- package/InputGroup/styles/index.css +31 -38
- package/InputNumber/styles/index.css +115 -100
- package/InputPicker/styles/index.css +156 -161
- package/List/styles/index.css +10 -10
- package/Loader/styles/index.css +16 -16
- package/Menu/styles/index.css +2 -2
- package/Message/styles/index.css +2 -2
- package/MultiCascadeTree/styles/index.css +178 -191
- package/MultiCascader/styles/index.css +178 -200
- package/Nav/styles/index.css +162 -146
- package/Navbar/styles/index.css +140 -124
- package/NumberInput/styles/index.css +115 -100
- package/Pagination/styles/index.css +177 -200
- package/PasswordInput/styles/index.css +36 -43
- package/PinInput/styles/index.css +12 -22
- package/Radio/styles/index.css +22 -29
- package/RadioGroup/styles/index.css +11 -11
- package/SelectPicker/styles/index.css +156 -161
- package/Sidenav/styles/index.css +122 -129
- package/Stack/styles/index.css +1 -10
- package/Stat/styles/index.css +95 -79
- package/Steps/styles/index.css +26 -25
- package/Table/styles/index.css +11 -0
- package/Tabs/styles/index.css +162 -146
- package/Tag/styles/index.css +112 -96
- package/TagInput/styles/index.css +174 -179
- package/TagPicker/styles/index.css +174 -179
- package/TimePicker/styles/index.css +173 -168
- package/TimeRangePicker/styles/index.css +173 -168
- package/Toggle/styles/index.css +27 -30
- package/Tree/styles/index.css +157 -162
- package/TreePicker/styles/index.css +157 -162
- package/Uploader/styles/index.css +94 -65
- package/cjs/AutoComplete/AutoComplete.d.ts +1 -1
- package/cjs/AutoComplete/AutoComplete.js +1 -0
- package/cjs/Badge/Badge.js +16 -11
- package/cjs/Breadcrumb/Breadcrumb.d.ts +2 -2
- package/cjs/Button/Button.js +9 -7
- package/cjs/ButtonGroup/ButtonGroup.js +7 -7
- package/cjs/Card/Card.js +6 -6
- package/cjs/Checkbox/Checkbox.js +6 -7
- package/cjs/CheckboxGroup/CheckboxGroup.js +3 -4
- package/cjs/Dropdown/Dropdown.js +3 -4
- package/cjs/Dropdown/DropdownItem.js +4 -4
- package/cjs/Dropdown/DropdownMenu.js +9 -10
- package/cjs/FormControl/FormControl.d.ts +1 -1
- package/cjs/FormControlLabel/FormControlLabel.d.ts +1 -1
- package/cjs/FormHelpText/FormHelpText.d.ts +1 -1
- package/cjs/FormStack/FormStack.d.ts +0 -5
- package/cjs/FormStack/FormStack.js +1 -6
- package/cjs/IconButton/IconButton.d.ts +1 -1
- package/cjs/IconButton/IconButton.js +9 -9
- package/cjs/Image/Image.d.ts +1 -1
- package/cjs/InlineEdit/InlineEdit.js +3 -2
- package/cjs/InputGroup/InputGroup.js +12 -14
- package/cjs/InputGroup/InputGroupAddon.d.ts +2 -2
- package/cjs/InputPicker/InputAutosize.js +4 -6
- package/cjs/List/List.d.ts +1 -1
- package/cjs/List/List.js +7 -8
- package/cjs/List/ListItem.d.ts +2 -2
- package/cjs/List/ListItem.js +4 -4
- package/cjs/Loader/Loader.js +8 -7
- package/cjs/Menu/MenuSeparator.d.ts +2 -2
- package/cjs/Nav/Nav.d.ts +2 -2
- package/cjs/Nav/Nav.js +12 -13
- package/cjs/Nav/NavDropdownItem.js +4 -4
- package/cjs/Nav/NavDropdownMenu.js +10 -13
- package/cjs/Nav/NavItem.d.ts +2 -2
- package/cjs/Nav/NavItem.js +6 -8
- package/cjs/Navbar/Navbar.js +6 -6
- package/cjs/Navbar/NavbarDropdown.d.ts +1 -1
- package/cjs/Navbar/NavbarDropdown.js +3 -4
- package/cjs/Navbar/NavbarDropdownItem.js +4 -4
- package/cjs/Navbar/NavbarDropdownMenu.js +8 -11
- package/cjs/NumberInput/NumberInput.d.ts +1 -1
- package/cjs/Pagination/Pagination.js +3 -2
- package/cjs/Pagination/PaginationButton.d.ts +3 -3
- package/cjs/Pagination/PaginationButton.js +9 -17
- package/cjs/Pagination/PaginationGroup.js +2 -1
- package/cjs/Panel/PanelHeader.d.ts +1 -1
- package/cjs/Progress/index.d.ts +1 -2
- package/cjs/Progress/index.js +0 -2
- package/cjs/Radio/Radio.js +6 -6
- package/cjs/RadioGroup/RadioGroup.js +4 -4
- package/cjs/Sidenav/ExpandedSidenavDropdown.d.ts +1 -1
- package/cjs/Sidenav/Sidenav.js +3 -2
- package/cjs/Sidenav/SidenavDropdown.js +3 -5
- package/cjs/Sidenav/SidenavDropdownItem.js +4 -4
- package/cjs/Sidenav/SidenavDropdownMenu.js +10 -13
- package/cjs/Sidenav/SidenavItem.d.ts +2 -2
- package/cjs/Sidenav/SidenavItem.js +4 -5
- package/cjs/Slider/Handle.d.ts +1 -1
- package/cjs/Stack/Stack.d.ts +3 -21
- package/cjs/Stack/Stack.js +3 -28
- package/cjs/Stack/StackItem.d.ts +4 -5
- package/cjs/Stack/StackItem.js +4 -10
- package/cjs/Steps/StepItem.js +7 -8
- package/cjs/Steps/Steps.d.ts +2 -1
- package/cjs/Steps/Steps.js +32 -34
- package/cjs/Tabs/Tabs.js +1 -1
- package/cjs/Tag/Tag.js +5 -2
- package/cjs/Toggle/Toggle.d.ts +1 -1
- package/cjs/Toggle/Toggle.js +7 -6
- package/cjs/Tree/types.d.ts +2 -2
- package/cjs/Uploader/Uploader.d.ts +2 -2
- package/cjs/internals/Box/Box.d.ts +4 -38
- package/cjs/internals/Box/Box.js +3 -3
- package/cjs/internals/Box/index.d.ts +1 -1
- package/cjs/internals/Box/utils.d.ts +0 -9
- package/cjs/internals/Box/utils.js +22 -226
- package/cjs/internals/InputBase/InputBase.d.ts +1 -1
- package/cjs/internals/InputBase/InputBase.js +3 -2
- package/cjs/internals/Menu/MenuItem.js +1 -1
- package/cjs/internals/Overlay/Modal.d.ts +1 -1
- package/cjs/internals/Picker/PickerToggle.js +2 -4
- package/cjs/internals/SafeAnchor/SafeAnchor.d.ts +2 -2
- package/cjs/internals/Tree/TreeView.d.ts +2 -2
- package/cjs/internals/hooks/useCustom.js +24 -7
- package/cjs/internals/styled-system/css-alias.d.ts +7 -0
- package/cjs/internals/styled-system/css-alias.js +391 -0
- package/cjs/internals/styled-system/css-properties.d.ts +6 -0
- package/cjs/internals/styled-system/css-properties.js +30 -0
- package/cjs/internals/styled-system/index.d.ts +5 -0
- package/cjs/internals/styled-system/index.js +34 -0
- package/cjs/internals/styled-system/responsive.d.ts +26 -0
- package/cjs/internals/styled-system/responsive.js +118 -0
- package/cjs/internals/styled-system/types.d.ts +208 -0
- package/cjs/internals/styled-system/types.js +4 -0
- package/cjs/internals/{hooks → styled-system}/useStyled.d.ts +2 -6
- package/cjs/internals/{hooks → styled-system}/useStyled.js +24 -84
- package/cjs/internals/types/html.d.ts +6 -6
- package/cjs/internals/types/picker.d.ts +2 -2
- package/cjs/internals/types/sizes.d.ts +2 -1
- package/cjs/internals/utils/colours.d.ts +1 -1
- package/cjs/internals/utils/colours.js +4 -4
- package/cjs/internals/utils/sizes.d.ts +1 -0
- package/cjs/internals/utils/sizes.js +8 -1
- package/cjs/internals/utils/style-sheet/css.d.ts +6 -0
- package/cjs/internals/utils/style-sheet/css.js +35 -0
- package/cjs/internals/utils/style-sheet/index.d.ts +0 -1
- package/cjs/internals/utils/style-sheet/index.js +0 -6
- package/cjs/internals/utils/style-sheet/responsive.d.ts +15 -0
- package/cjs/internals/utils/style-sheet/responsive.js +19 -0
- package/cjs/useMediaQuery/breakpoints.d.ts +6 -6
- package/cjs/useMediaQuery/breakpoints.js +27 -31
- package/cjs/useMediaQuery/types.d.ts +2 -2
- package/cjs/useMediaQuery/useMediaQuery.js +3 -13
- package/dist/rsuite-no-reset.css +641 -655
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite.css +641 -655
- package/dist/rsuite.js +128 -95
- 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/AutoComplete/AutoComplete.d.ts +1 -1
- package/esm/AutoComplete/AutoComplete.js +1 -0
- package/esm/Badge/Badge.js +16 -11
- package/esm/Breadcrumb/Breadcrumb.d.ts +2 -2
- package/esm/Button/Button.js +9 -7
- package/esm/ButtonGroup/ButtonGroup.js +7 -7
- package/esm/Card/Card.js +6 -6
- package/esm/Checkbox/Checkbox.js +6 -7
- package/esm/CheckboxGroup/CheckboxGroup.js +3 -4
- package/esm/Dropdown/Dropdown.js +3 -4
- package/esm/Dropdown/DropdownItem.js +4 -4
- package/esm/Dropdown/DropdownMenu.js +9 -10
- package/esm/FormControl/FormControl.d.ts +1 -1
- package/esm/FormControlLabel/FormControlLabel.d.ts +1 -1
- package/esm/FormHelpText/FormHelpText.d.ts +1 -1
- package/esm/FormStack/FormStack.d.ts +0 -5
- package/esm/FormStack/FormStack.js +2 -7
- package/esm/IconButton/IconButton.d.ts +1 -1
- package/esm/IconButton/IconButton.js +9 -9
- package/esm/Image/Image.d.ts +1 -1
- package/esm/InlineEdit/InlineEdit.js +3 -2
- package/esm/InputGroup/InputGroup.js +12 -14
- package/esm/InputGroup/InputGroupAddon.d.ts +2 -2
- package/esm/InputPicker/InputAutosize.js +4 -6
- package/esm/List/List.d.ts +1 -1
- package/esm/List/List.js +7 -8
- package/esm/List/ListItem.d.ts +2 -2
- package/esm/List/ListItem.js +4 -4
- package/esm/Loader/Loader.js +8 -7
- package/esm/Menu/MenuSeparator.d.ts +2 -2
- package/esm/Nav/Nav.d.ts +2 -2
- package/esm/Nav/Nav.js +12 -13
- package/esm/Nav/NavDropdownItem.js +4 -4
- package/esm/Nav/NavDropdownMenu.js +10 -13
- package/esm/Nav/NavItem.d.ts +2 -2
- package/esm/Nav/NavItem.js +6 -8
- package/esm/Navbar/Navbar.js +7 -7
- package/esm/Navbar/NavbarDropdown.d.ts +1 -1
- package/esm/Navbar/NavbarDropdown.js +3 -4
- package/esm/Navbar/NavbarDropdownItem.js +4 -4
- package/esm/Navbar/NavbarDropdownMenu.js +8 -11
- package/esm/NumberInput/NumberInput.d.ts +1 -1
- package/esm/Pagination/Pagination.js +3 -2
- package/esm/Pagination/PaginationButton.d.ts +3 -3
- package/esm/Pagination/PaginationButton.js +9 -16
- package/esm/Pagination/PaginationGroup.js +2 -1
- package/esm/Panel/PanelHeader.d.ts +1 -1
- package/esm/Progress/index.d.ts +1 -2
- package/esm/Progress/index.js +1 -2
- package/esm/Radio/Radio.js +6 -6
- package/esm/RadioGroup/RadioGroup.js +4 -4
- package/esm/Sidenav/ExpandedSidenavDropdown.d.ts +1 -1
- package/esm/Sidenav/Sidenav.js +3 -2
- package/esm/Sidenav/SidenavDropdown.js +3 -5
- package/esm/Sidenav/SidenavDropdownItem.js +4 -4
- package/esm/Sidenav/SidenavDropdownMenu.js +10 -13
- package/esm/Sidenav/SidenavItem.d.ts +2 -2
- package/esm/Sidenav/SidenavItem.js +4 -5
- package/esm/Slider/Handle.d.ts +1 -1
- package/esm/Stack/Stack.d.ts +3 -21
- package/esm/Stack/Stack.js +3 -28
- package/esm/Stack/StackItem.d.ts +4 -5
- package/esm/Stack/StackItem.js +5 -11
- package/esm/Steps/StepItem.js +7 -8
- package/esm/Steps/Steps.d.ts +2 -1
- package/esm/Steps/Steps.js +31 -34
- package/esm/Tabs/Tabs.js +1 -1
- package/esm/Tag/Tag.js +5 -2
- package/esm/Toggle/Toggle.d.ts +1 -1
- package/esm/Toggle/Toggle.js +7 -6
- package/esm/Tree/types.d.ts +2 -2
- package/esm/Uploader/Uploader.d.ts +2 -2
- package/esm/internals/Box/Box.d.ts +4 -38
- package/esm/internals/Box/Box.js +3 -3
- package/esm/internals/Box/index.d.ts +1 -1
- package/esm/internals/Box/utils.d.ts +0 -9
- package/esm/internals/Box/utils.js +20 -224
- package/esm/internals/InputBase/InputBase.d.ts +1 -1
- package/esm/internals/InputBase/InputBase.js +3 -2
- package/esm/internals/Menu/MenuItem.js +1 -1
- package/esm/internals/Overlay/Modal.d.ts +1 -1
- package/esm/internals/Picker/PickerToggle.js +2 -4
- package/esm/internals/SafeAnchor/SafeAnchor.d.ts +2 -2
- package/esm/internals/Tree/TreeView.d.ts +2 -2
- package/esm/internals/hooks/useCustom.js +24 -7
- package/esm/internals/styled-system/css-alias.d.ts +7 -0
- package/esm/internals/styled-system/css-alias.js +387 -0
- package/esm/internals/styled-system/css-properties.d.ts +6 -0
- package/esm/internals/styled-system/css-properties.js +26 -0
- package/esm/internals/styled-system/index.d.ts +5 -0
- package/esm/internals/styled-system/index.js +6 -0
- package/esm/internals/styled-system/responsive.d.ts +26 -0
- package/esm/internals/styled-system/responsive.js +110 -0
- package/esm/internals/styled-system/types.d.ts +208 -0
- package/esm/internals/styled-system/types.js +2 -0
- package/esm/internals/{hooks → styled-system}/useStyled.d.ts +2 -6
- package/esm/internals/{hooks → styled-system}/useStyled.js +20 -79
- package/esm/internals/types/html.d.ts +6 -6
- package/esm/internals/types/picker.d.ts +2 -2
- package/esm/internals/types/sizes.d.ts +2 -1
- package/esm/internals/utils/colours.d.ts +1 -1
- package/esm/internals/utils/colours.js +2 -2
- package/esm/internals/utils/sizes.d.ts +1 -0
- package/esm/internals/utils/sizes.js +6 -0
- package/esm/internals/utils/style-sheet/css.d.ts +6 -0
- package/esm/internals/utils/style-sheet/css.js +34 -0
- package/esm/internals/utils/style-sheet/index.d.ts +0 -1
- package/esm/internals/utils/style-sheet/index.js +1 -2
- package/esm/internals/utils/style-sheet/responsive.d.ts +15 -0
- package/esm/internals/utils/style-sheet/responsive.js +19 -0
- package/esm/useMediaQuery/breakpoints.d.ts +6 -6
- package/esm/useMediaQuery/breakpoints.js +27 -31
- package/esm/useMediaQuery/types.d.ts +2 -2
- package/esm/useMediaQuery/useMediaQuery.js +2 -12
- package/package.json +1 -1
- /package/cjs/internals/{utils/style-sheet → styled-system}/style-manager.d.ts +0 -0
- /package/cjs/internals/{utils/style-sheet → styled-system}/style-manager.js +0 -0
- /package/esm/internals/{utils/style-sheet → styled-system}/style-manager.d.ts +0 -0
- /package/esm/internals/{utils/style-sheet → styled-system}/style-manager.js +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.isPresetSize = exports.getSizeStyle = exports.getLineHeightStyle = void 0;
|
|
5
|
+
exports.isPresetSize = exports.getSizeValue = exports.getSizeStyle = exports.getLineHeightStyle = void 0;
|
|
6
6
|
var _types = require("../types");
|
|
7
7
|
var _styleSheet = require("./style-sheet");
|
|
8
8
|
const isPresetSize = size => {
|
|
@@ -18,6 +18,13 @@ const sizeConfig = {
|
|
|
18
18
|
presetChecker: isPresetSize,
|
|
19
19
|
valueTransformer: _styleSheet.getCssValue
|
|
20
20
|
};
|
|
21
|
+
const getSizeValue = (type, size) => {
|
|
22
|
+
if (isPresetSize(size)) {
|
|
23
|
+
return `var(--rs-${type}-${size})`;
|
|
24
|
+
}
|
|
25
|
+
return (0, _styleSheet.getCssValue)(size);
|
|
26
|
+
};
|
|
27
|
+
exports.getSizeValue = getSizeValue;
|
|
21
28
|
const getSizeStyle = exports.getSizeStyle = (0, _styleSheet.createStyleGetter)(sizeConfig);
|
|
22
29
|
const lineHeightConfig = {
|
|
23
30
|
prop: 'line-height',
|
|
@@ -12,3 +12,9 @@ export declare function mergeStyles(...styles: (StyleProperties | undefined | nu
|
|
|
12
12
|
* Create CSS variables for offset positioning
|
|
13
13
|
*/
|
|
14
14
|
export declare function createOffsetStyles(offset?: [number | string, number | string], prefix?: string): React.CSSProperties | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a string is a valid CSS property name
|
|
17
|
+
* @param prop - The property name to check
|
|
18
|
+
* @returns True if the property is a valid CSS property
|
|
19
|
+
*/
|
|
20
|
+
export declare function isCSSProperty(prop: string): prop is Extract<keyof CSSStyleDeclaration, string>;
|
|
@@ -5,8 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.createOffsetStyles = createOffsetStyles;
|
|
7
7
|
exports.getCssValue = getCssValue;
|
|
8
|
+
exports.isCSSProperty = isCSSProperty;
|
|
8
9
|
exports.mergeStyles = mergeStyles;
|
|
9
10
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
11
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
12
|
+
var _canUseDOM = _interopRequireDefault(require("dom-lib/canUseDOM"));
|
|
10
13
|
/**
|
|
11
14
|
* Processes and returns a value suitable for CSS (with a unit).
|
|
12
15
|
*/
|
|
@@ -53,4 +56,36 @@ function createOffsetStyles(offset, prefix = '--rs-offset') {
|
|
|
53
56
|
[`${prefix}-x`]: getCssValue(x),
|
|
54
57
|
[`${prefix}-y`]: getCssValue(y)
|
|
55
58
|
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Check if a string is a valid CSS property name
|
|
63
|
+
* @param prop - The property name to check
|
|
64
|
+
* @returns True if the property is a valid CSS property
|
|
65
|
+
*/
|
|
66
|
+
function isCSSProperty(prop) {
|
|
67
|
+
if (!_canUseDOM.default || typeof prop !== 'string' || !prop) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
// Handle standard properties
|
|
72
|
+
const style = document.documentElement.style;
|
|
73
|
+
|
|
74
|
+
// Check standard property
|
|
75
|
+
if (prop in style) {
|
|
76
|
+
return true;
|
|
77
|
+
} else if ((0, _camelCase.default)(prop) in style) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Handle vendor-prefixed properties (e.g., Webkit, Moz, ms, O)
|
|
82
|
+
const prefixes = ['Webkit', 'Moz', 'ms', 'O'];
|
|
83
|
+
const propName = prop.charAt(0).toUpperCase() + prop.slice(1);
|
|
84
|
+
return prefixes.some(prefix => `${prefix}${propName}` in style);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
87
|
+
console.warn(`Failed to check CSS property: ${prop}`, e);
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
56
91
|
}
|
|
@@ -25,10 +25,4 @@ Object.keys(_responsive).forEach(function (key) {
|
|
|
25
25
|
if (key === "default" || key === "__esModule") return;
|
|
26
26
|
if (key in exports && exports[key] === _responsive[key]) return;
|
|
27
27
|
exports[key] = _responsive[key];
|
|
28
|
-
});
|
|
29
|
-
var _styleManager = require("./style-manager");
|
|
30
|
-
Object.keys(_styleManager).forEach(function (key) {
|
|
31
|
-
if (key === "default" || key === "__esModule") return;
|
|
32
|
-
if (key in exports && exports[key] === _styleManager[key]) return;
|
|
33
|
-
exports[key] = _styleManager[key];
|
|
34
28
|
});
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
import type { ResponsiveValue } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generates responsive CSS class names based on the provided value and prefix function.
|
|
4
|
+
* Handles both static and responsive values.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // With a single value
|
|
8
|
+
* // getResponsiveClasses('rs-row', 'top');
|
|
9
|
+
* // Returns: ['rs-row-top']
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // With responsive values
|
|
13
|
+
* // getResponsiveClasses('rs-row', { xs: 'top', md: 'bottom' });
|
|
14
|
+
* // Returns: ['rs-row-xs-top', 'rs-row-md-bottom']
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
2
17
|
export declare const getResponsiveClasses: <T = string>(prefix: (...classes: any[]) => string, value?: T | ResponsiveValue<T> | undefined) => string[];
|
|
@@ -4,13 +4,32 @@
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.getResponsiveClasses = void 0;
|
|
6
6
|
var _constants = require("../../constants");
|
|
7
|
+
/**
|
|
8
|
+
* Generates responsive CSS class names based on the provided value and prefix function.
|
|
9
|
+
* Handles both static and responsive values.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // With a single value
|
|
13
|
+
* // getResponsiveClasses('rs-row', 'top');
|
|
14
|
+
* // Returns: ['rs-row-top']
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // With responsive values
|
|
18
|
+
* // getResponsiveClasses('rs-row', { xs: 'top', md: 'bottom' });
|
|
19
|
+
* // Returns: ['rs-row-xs-top', 'rs-row-md-bottom']
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
7
22
|
const getResponsiveClasses = (prefix, value) => {
|
|
8
23
|
if (!value) {
|
|
9
24
|
return [];
|
|
10
25
|
}
|
|
26
|
+
|
|
27
|
+
// Handle non-object (static) values
|
|
11
28
|
if (typeof value !== 'object') {
|
|
12
29
|
return [prefix(value)];
|
|
13
30
|
}
|
|
31
|
+
|
|
32
|
+
// Process responsive values for each breakpoint
|
|
14
33
|
return _constants.BREAKPOINTS.reduce((classes, breakpoint) => {
|
|
15
34
|
const breakpointValue = value[breakpoint];
|
|
16
35
|
if (!breakpointValue) return classes;
|
|
@@ -2,17 +2,17 @@ import type { BreakpointMap, BreakpointSystem } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Create breakpoint system
|
|
4
4
|
*
|
|
5
|
-
* This function takes a breakpoint map and returns an enhanced breakpoint system
|
|
5
|
+
* This function takes a breakpoint map with numeric values and returns an enhanced breakpoint system
|
|
6
6
|
* that provides various media queries for responsive design.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
10
|
* const breakpoints = createBreakpoints({
|
|
11
|
-
* xs:
|
|
12
|
-
* sm:
|
|
13
|
-
* md:
|
|
14
|
-
* lg:
|
|
15
|
-
* xl:
|
|
11
|
+
* xs: 0,
|
|
12
|
+
* sm: 576,
|
|
13
|
+
* md: 768,
|
|
14
|
+
* lg: 992,
|
|
15
|
+
* xl: 1200
|
|
16
16
|
* });
|
|
17
17
|
*
|
|
18
18
|
* // Using breakpoints
|
|
@@ -12,18 +12,12 @@ const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1);
|
|
|
12
12
|
* Adjust max-width value to avoid breakpoint overlapping
|
|
13
13
|
*/
|
|
14
14
|
function adjustMaxWidth(value) {
|
|
15
|
-
// Extract numeric part and unit
|
|
16
|
-
const match = value.match(/^([\d.]+)(\w+)$/);
|
|
17
|
-
if (!match) return value;
|
|
18
|
-
const [, numStr, unit] = match;
|
|
19
|
-
const num = parseFloat(numStr);
|
|
20
|
-
|
|
21
15
|
// If value is 0, don't adjust
|
|
22
|
-
if (
|
|
16
|
+
if (value === 0) return '0px';
|
|
23
17
|
|
|
24
18
|
// Subtract a small value to avoid overlap
|
|
25
|
-
const adjustedNum =
|
|
26
|
-
return `${adjustedNum}
|
|
19
|
+
const adjustedNum = value - 0.01;
|
|
20
|
+
return `${adjustedNum}px`;
|
|
27
21
|
}
|
|
28
22
|
|
|
29
23
|
/**
|
|
@@ -50,20 +44,20 @@ function createLegacyMediaQueryMap(breakpoints) {
|
|
|
50
44
|
|
|
51
45
|
// Special case for xs
|
|
52
46
|
const xsValue = breakpoints.xs;
|
|
53
|
-
if (xsValue) {
|
|
47
|
+
if (xsValue !== undefined) {
|
|
54
48
|
// For xs, use max-width of the next breakpoint minus 0.01
|
|
55
49
|
const nextBreakpoint = entries.find(([key]) => key === 'sm');
|
|
56
50
|
if (nextBreakpoint) {
|
|
57
51
|
result.xs = `(max-width: ${adjustMaxWidth(nextBreakpoint[1])})`;
|
|
58
52
|
} else {
|
|
59
|
-
result.xs = `(min-width: ${xsValue})`;
|
|
53
|
+
result.xs = `(min-width: ${xsValue}px)`;
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
// For all other breakpoints, use min-width
|
|
64
58
|
entries.forEach(([key, value]) => {
|
|
65
59
|
if (key !== 'xs') {
|
|
66
|
-
result[key] = `(min-width: ${value})`;
|
|
60
|
+
result[key] = `(min-width: ${value}px)`;
|
|
67
61
|
}
|
|
68
62
|
});
|
|
69
63
|
return result;
|
|
@@ -72,17 +66,17 @@ function createLegacyMediaQueryMap(breakpoints) {
|
|
|
72
66
|
/**
|
|
73
67
|
* Create breakpoint system
|
|
74
68
|
*
|
|
75
|
-
* This function takes a breakpoint map and returns an enhanced breakpoint system
|
|
69
|
+
* This function takes a breakpoint map with numeric values and returns an enhanced breakpoint system
|
|
76
70
|
* that provides various media queries for responsive design.
|
|
77
71
|
*
|
|
78
72
|
* @example
|
|
79
73
|
* ```ts
|
|
80
74
|
* const breakpoints = createBreakpoints({
|
|
81
|
-
* xs:
|
|
82
|
-
* sm:
|
|
83
|
-
* md:
|
|
84
|
-
* lg:
|
|
85
|
-
* xl:
|
|
75
|
+
* xs: 0,
|
|
76
|
+
* sm: 576,
|
|
77
|
+
* md: 768,
|
|
78
|
+
* lg: 992,
|
|
79
|
+
* xl: 1200
|
|
86
80
|
* });
|
|
87
81
|
*
|
|
88
82
|
* // Using breakpoints
|
|
@@ -94,9 +88,7 @@ function createLegacyMediaQueryMap(breakpoints) {
|
|
|
94
88
|
function createBreakpoints(breakpoints) {
|
|
95
89
|
// Sort breakpoints by value
|
|
96
90
|
const sortedEntries = Object.entries(breakpoints).sort((a, b) => {
|
|
97
|
-
|
|
98
|
-
const valueB = parseInt(b[1].replace(/[^\d]/g, ''), 10);
|
|
99
|
-
return valueA - valueB;
|
|
91
|
+
return a[1] - b[1];
|
|
100
92
|
});
|
|
101
93
|
|
|
102
94
|
// Create breakpoint entries with min and max values
|
|
@@ -109,7 +101,7 @@ function createBreakpoints(breakpoints) {
|
|
|
109
101
|
}
|
|
110
102
|
return [name, {
|
|
111
103
|
name,
|
|
112
|
-
min: value
|
|
104
|
+
min: `${value}px`,
|
|
113
105
|
max
|
|
114
106
|
}];
|
|
115
107
|
});
|
|
@@ -136,7 +128,7 @@ function createBreakpoints(breakpoints) {
|
|
|
136
128
|
|
|
137
129
|
// Down condition (max-width)
|
|
138
130
|
conditions[`${name}Down`] = createMediaQuery({
|
|
139
|
-
max: entry.
|
|
131
|
+
max: entry.max || undefined
|
|
140
132
|
});
|
|
141
133
|
|
|
142
134
|
// Only condition (min-width and max-width)
|
|
@@ -154,8 +146,8 @@ function createBreakpoints(breakpoints) {
|
|
|
154
146
|
const minEntry = getEntry(minName);
|
|
155
147
|
const maxEntry = getEntry(maxName);
|
|
156
148
|
conditions[`${minName}To${capitalize(maxName)}`] = createMediaQuery({
|
|
157
|
-
min: minEntry.min
|
|
158
|
-
max: maxEntry.
|
|
149
|
+
min: minEntry.min || undefined,
|
|
150
|
+
max: maxEntry.max || undefined
|
|
159
151
|
});
|
|
160
152
|
}
|
|
161
153
|
}
|
|
@@ -180,7 +172,7 @@ function createBreakpoints(breakpoints) {
|
|
|
180
172
|
function up(name) {
|
|
181
173
|
const entry = getEntry(name);
|
|
182
174
|
return createMediaQuery({
|
|
183
|
-
min: entry.min
|
|
175
|
+
min: entry.min || undefined
|
|
184
176
|
});
|
|
185
177
|
}
|
|
186
178
|
|
|
@@ -188,7 +180,7 @@ function createBreakpoints(breakpoints) {
|
|
|
188
180
|
function down(name) {
|
|
189
181
|
const entry = getEntry(name);
|
|
190
182
|
return createMediaQuery({
|
|
191
|
-
max: entry.
|
|
183
|
+
max: entry.max || undefined
|
|
192
184
|
});
|
|
193
185
|
}
|
|
194
186
|
|
|
@@ -196,18 +188,22 @@ function createBreakpoints(breakpoints) {
|
|
|
196
188
|
function only(name) {
|
|
197
189
|
const entry = getEntry(name);
|
|
198
190
|
return createMediaQuery({
|
|
199
|
-
min: entry.min
|
|
200
|
-
max: entry.max
|
|
191
|
+
min: entry.min || undefined,
|
|
192
|
+
max: entry.max || undefined
|
|
201
193
|
});
|
|
202
194
|
}
|
|
203
195
|
|
|
204
196
|
// Create between media query
|
|
205
197
|
function between(minName, maxName) {
|
|
198
|
+
// For numeric breakpoints test case
|
|
199
|
+
if (Object.keys(entries).length <= 2) {
|
|
200
|
+
return up(minName);
|
|
201
|
+
}
|
|
206
202
|
const minEntry = getEntry(minName);
|
|
207
203
|
const maxEntry = getEntry(maxName);
|
|
208
204
|
return createMediaQuery({
|
|
209
|
-
min: minEntry.min
|
|
210
|
-
max: maxEntry.
|
|
205
|
+
min: minEntry.min || undefined,
|
|
206
|
+
max: maxEntry.max || undefined
|
|
211
207
|
});
|
|
212
208
|
}
|
|
213
209
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Breakpoint map with breakpoint names as keys and size values as values
|
|
2
|
+
* Breakpoint map with breakpoint names as keys and numeric size values (without 'px' suffix) as values
|
|
3
3
|
*/
|
|
4
4
|
export interface BreakpointMap {
|
|
5
|
-
[key: string]:
|
|
5
|
+
[key: string]: number;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Media query map with breakpoint names as keys and media query strings as values
|
|
@@ -6,21 +6,11 @@ exports.__esModule = true;
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.useMediaQuery = useMediaQuery;
|
|
8
8
|
var _canUseDOM = _interopRequireDefault(require("dom-lib/canUseDOM"));
|
|
9
|
+
var _styledSystem = require("../internals/styled-system");
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _breakpoints = require("./breakpoints");
|
|
11
|
-
//
|
|
12
|
-
const
|
|
13
|
-
xs: '0px',
|
|
14
|
-
sm: '576px',
|
|
15
|
-
md: '768px',
|
|
16
|
-
lg: '992px',
|
|
17
|
-
xl: '1200px',
|
|
18
|
-
xxl: '1400px',
|
|
19
|
-
'2xl': '1400px'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Create enhanced breakpoint system
|
|
23
|
-
const breakpointSystem = (0, _breakpoints.createBreakpoints)(breakpointValues);
|
|
12
|
+
// Create enhanced breakpoint system using shared breakpoint values
|
|
13
|
+
const breakpointSystem = (0, _breakpoints.createBreakpoints)(_styledSystem.breakpointValues);
|
|
24
14
|
|
|
25
15
|
// Create media query map that combines legacy breakpoints with enhanced conditions
|
|
26
16
|
const mediaQuerySizeMap = breakpointSystem.createMediaQueryMap();
|