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
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.getCSSVariables = exports.breakpointValues = void 0;
|
|
7
|
+
exports.isResponsiveValue = isResponsiveValue;
|
|
8
|
+
exports.processResponsiveValue = processResponsiveValue;
|
|
9
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
10
|
+
var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
|
|
11
|
+
var _utils = require("../utils");
|
|
12
|
+
var _constants = require("../constants");
|
|
13
|
+
var _cssAlias = require("./css-alias");
|
|
14
|
+
/**
|
|
15
|
+
* Breakpoint values in pixels - matching SCSS variables
|
|
16
|
+
* These values are used for responsive design across the application.
|
|
17
|
+
* They follow a mobile-first approach where 'xs' is the base breakpoint.
|
|
18
|
+
*/
|
|
19
|
+
const breakpointValues = exports.breakpointValues = {
|
|
20
|
+
xs: 0,
|
|
21
|
+
// Base mobile first
|
|
22
|
+
sm: 576,
|
|
23
|
+
// $screen-sm
|
|
24
|
+
md: 768,
|
|
25
|
+
// $screen-md
|
|
26
|
+
lg: 992,
|
|
27
|
+
// $screen-lg
|
|
28
|
+
xl: 1200,
|
|
29
|
+
// $screen-xl
|
|
30
|
+
xxl: 1400,
|
|
31
|
+
// $screen-xxl
|
|
32
|
+
'2xl': 1400 // Alias for xxl for compatibility
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a value is a responsive value object
|
|
37
|
+
* @param value - Value to check
|
|
38
|
+
* @returns True if the value is a responsive value object
|
|
39
|
+
*/
|
|
40
|
+
function isResponsiveValue(value) {
|
|
41
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).some(key => _constants.BREAKPOINTS.includes(key));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Process a value that might be a responsive value
|
|
46
|
+
* @param value - Value to process
|
|
47
|
+
* @param processor - Function to process non-responsive values
|
|
48
|
+
* @returns Processed value or responsive object with processed values
|
|
49
|
+
*/
|
|
50
|
+
function processResponsiveValue(value, processor) {
|
|
51
|
+
if (value === undefined) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (isResponsiveValue(value)) {
|
|
55
|
+
const result = {};
|
|
56
|
+
Object.entries(value).forEach(([breakpoint, val]) => {
|
|
57
|
+
if (val !== undefined) {
|
|
58
|
+
const processed = processor(val);
|
|
59
|
+
if (processed !== undefined) {
|
|
60
|
+
result[breakpoint] = processed;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
65
|
+
}
|
|
66
|
+
return processor(value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Type for CSS variable values that can be string, number, or responsive values
|
|
70
|
+
|
|
71
|
+
const transformCSSValue = (value, type) => {
|
|
72
|
+
if (type === 'number') {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
return (0, _utils.getCssValue)(value);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Converts layout properties to CSS variables with abbreviated names
|
|
80
|
+
*/
|
|
81
|
+
const getCSSVariables = (props, prefix = `--rs-`) => {
|
|
82
|
+
const cssVars = {};
|
|
83
|
+
const cssVar = name => `${prefix}${(0, _kebabCase.default)(name)}`;
|
|
84
|
+
const getCSSProperty = name => {
|
|
85
|
+
let cssName = name;
|
|
86
|
+
let cssProp = _cssAlias.cssSystemPropAlias[name];
|
|
87
|
+
if (!cssProp) {
|
|
88
|
+
Object.entries(_cssAlias.cssSystemPropAlias).forEach(([key, prop]) => {
|
|
89
|
+
if ((0, _camelCase.default)(prop.property) === name) {
|
|
90
|
+
cssProp = prop;
|
|
91
|
+
cssName = key;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return [cssName, cssProp];
|
|
96
|
+
};
|
|
97
|
+
Object.entries(props).forEach(([name, value]) => {
|
|
98
|
+
if (typeof value === 'undefined') {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const [cssName, cssProp] = getCSSProperty(name);
|
|
102
|
+
const varName = cssVar(cssName);
|
|
103
|
+
if (cssProp) {
|
|
104
|
+
const {
|
|
105
|
+
transformer,
|
|
106
|
+
type
|
|
107
|
+
} = cssProp;
|
|
108
|
+
cssVars[varName] = processResponsiveValue(value, val => {
|
|
109
|
+
return transformer ? transformer(val) : transformCSSValue(val, type);
|
|
110
|
+
});
|
|
111
|
+
} else if ((0, _utils.isCSSProperty)(cssName)) {
|
|
112
|
+
// For non-predefined CSS properties, directly process with getCssValue
|
|
113
|
+
cssVars[varName] = processResponsiveValue(value, val => (0, _utils.getCssValue)(val));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return cssVars;
|
|
117
|
+
};
|
|
118
|
+
exports.getCSSVariables = getCSSVariables;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { CSSProperties as CSS } from 'react';
|
|
2
|
+
import { supportedCSSProperties } from './css-properties';
|
|
3
|
+
import type { WithResponsive, ColorScheme, Size } from '../types';
|
|
4
|
+
export type CSSPropertyValueType = 'string' | 'number' | 'any';
|
|
5
|
+
export type CSSProperty = {
|
|
6
|
+
/**
|
|
7
|
+
* CSS Property Type
|
|
8
|
+
*/
|
|
9
|
+
type: CSSPropertyValueType;
|
|
10
|
+
/**
|
|
11
|
+
* CSS Property
|
|
12
|
+
*/
|
|
13
|
+
property: string;
|
|
14
|
+
/**
|
|
15
|
+
* Value Transformer
|
|
16
|
+
*/
|
|
17
|
+
transformer?: (value: any) => any;
|
|
18
|
+
};
|
|
19
|
+
export type SupportedCSSProperty = (typeof supportedCSSProperties)[number];
|
|
20
|
+
type MakeResponsive<T> = {
|
|
21
|
+
[K in keyof T]?: T[K] | WithResponsive<T[K]>;
|
|
22
|
+
};
|
|
23
|
+
export type StandardCSSProps = MakeResponsive<Pick<CSS, SupportedCSSProperty>>;
|
|
24
|
+
/**
|
|
25
|
+
* CSS Properties type for Box component
|
|
26
|
+
* This type maps all the CSS properties defined in cssSystemPropAlias to their corresponding React CSS types
|
|
27
|
+
*/
|
|
28
|
+
export interface CSSSystemProps extends StandardCSSProps {
|
|
29
|
+
/** Shorthand for CSS property `padding` */
|
|
30
|
+
p?: WithResponsive<CSS['padding']>;
|
|
31
|
+
/** Shorthand for CSS property `paddingTop` */
|
|
32
|
+
pt?: WithResponsive<CSS['paddingTop']>;
|
|
33
|
+
/** Shorthand for CSS property `paddingRight` */
|
|
34
|
+
pr?: WithResponsive<CSS['paddingRight']>;
|
|
35
|
+
/** Shorthand for CSS property `paddingBottom` */
|
|
36
|
+
pb?: WithResponsive<CSS['paddingBottom']>;
|
|
37
|
+
/** Shorthand for CSS property `paddingLeft` */
|
|
38
|
+
pl?: WithResponsive<CSS['paddingLeft']>;
|
|
39
|
+
/** Shorthand for CSS property `paddingInline` */
|
|
40
|
+
px?: WithResponsive<CSS['paddingInline']>;
|
|
41
|
+
/** Shorthand for CSS property `paddingBlock` */
|
|
42
|
+
py?: WithResponsive<CSS['paddingBlock']>;
|
|
43
|
+
/** Shorthand for CSS property `paddingInlineStart` */
|
|
44
|
+
ps?: WithResponsive<CSS['paddingInlineStart']>;
|
|
45
|
+
/** Shorthand for CSS property `paddingInlineEnd` */
|
|
46
|
+
pe?: WithResponsive<CSS['paddingInlineEnd']>;
|
|
47
|
+
/** Shorthand for CSS property `margin` */
|
|
48
|
+
m?: WithResponsive<CSS['margin']>;
|
|
49
|
+
/** Shorthand for CSS property `marginTop` */
|
|
50
|
+
mt?: WithResponsive<CSS['marginTop']>;
|
|
51
|
+
/** Shorthand for CSS property `marginRight` */
|
|
52
|
+
mr?: WithResponsive<CSS['marginRight']>;
|
|
53
|
+
/** Shorthand for CSS property `marginBottom` */
|
|
54
|
+
mb?: WithResponsive<CSS['marginBottom']>;
|
|
55
|
+
/** Shorthand for CSS property `marginLeft` */
|
|
56
|
+
ml?: WithResponsive<CSS['marginLeft']>;
|
|
57
|
+
/** Shorthand for CSS property `marginInline` */
|
|
58
|
+
mx?: WithResponsive<CSS['marginInline']>;
|
|
59
|
+
/** Shorthand for CSS property `marginBlock` */
|
|
60
|
+
my?: WithResponsive<CSS['marginBlock']>;
|
|
61
|
+
/** Shorthand for CSS property `marginInlineStart` */
|
|
62
|
+
ms?: WithResponsive<CSS['marginInlineStart']>;
|
|
63
|
+
/** Shorthand for CSS property `marginInlineEnd` */
|
|
64
|
+
me?: WithResponsive<CSS['marginInlineEnd']>;
|
|
65
|
+
/** Shorthand for CSS property `width` */
|
|
66
|
+
w?: WithResponsive<CSS['width']>;
|
|
67
|
+
/** Shorthand for CSS property `height` */
|
|
68
|
+
h?: WithResponsive<CSS['height']>;
|
|
69
|
+
/** Shorthand for CSS property `minWidth` */
|
|
70
|
+
minw?: WithResponsive<CSS['minWidth']>;
|
|
71
|
+
/** Shorthand for CSS property `maxWidth` */
|
|
72
|
+
maxw?: WithResponsive<CSS['maxWidth']>;
|
|
73
|
+
/** Shorthand for CSS property `minHeight` */
|
|
74
|
+
minh?: WithResponsive<CSS['minHeight']>;
|
|
75
|
+
/** Shorthand for CSS property `maxHeight` */
|
|
76
|
+
maxh?: WithResponsive<CSS['maxHeight']>;
|
|
77
|
+
/** Shorthand for CSS property `display` */
|
|
78
|
+
display?: WithResponsive<CSS['display']>;
|
|
79
|
+
/** Shorthand for CSS property `position` */
|
|
80
|
+
pos?: WithResponsive<CSS['position']>;
|
|
81
|
+
/** Shorthand for CSS property `left` */
|
|
82
|
+
left?: WithResponsive<CSS['left']>;
|
|
83
|
+
/** Shorthand for CSS property `top` */
|
|
84
|
+
top?: WithResponsive<CSS['top']>;
|
|
85
|
+
/** Shorthand for CSS property `right` */
|
|
86
|
+
right?: WithResponsive<CSS['right']>;
|
|
87
|
+
/** Shorthand for CSS property `bottom` */
|
|
88
|
+
bottom?: WithResponsive<CSS['bottom']>;
|
|
89
|
+
/** Shorthand for CSS property `inset` */
|
|
90
|
+
inset?: WithResponsive<CSS['inset']>;
|
|
91
|
+
/** Shorthand for CSS property `insetInline` */
|
|
92
|
+
insetx?: WithResponsive<CSS['insetInline']>;
|
|
93
|
+
/** Shorthand for CSS property `insetBlock` */
|
|
94
|
+
insety?: WithResponsive<CSS['insetBlock']>;
|
|
95
|
+
/** Shorthand for CSS property `boxSizing` */
|
|
96
|
+
bsz?: WithResponsive<CSS['boxSizing']>;
|
|
97
|
+
/** Shorthand for CSS property `zIndex` */
|
|
98
|
+
z?: WithResponsive<CSS['zIndex']>;
|
|
99
|
+
/** Shorthand for CSS property `background` */
|
|
100
|
+
bg?: WithResponsive<ColorScheme | CSS['background']>;
|
|
101
|
+
/** Shorthand for CSS property `backgroundColor` */
|
|
102
|
+
bgc?: WithResponsive<ColorScheme | CSS['backgroundColor']>;
|
|
103
|
+
/** Shorthand for CSS property `backgroundImage` */
|
|
104
|
+
bgi?: WithResponsive<CSS['backgroundImage']>;
|
|
105
|
+
/** Shorthand for CSS property `backgroundAttachment` */
|
|
106
|
+
bga?: WithResponsive<CSS['backgroundAttachment']>;
|
|
107
|
+
/** Shorthand for CSS property `backgroundPosition` */
|
|
108
|
+
bgp?: WithResponsive<CSS['backgroundPosition']>;
|
|
109
|
+
/** Shorthand for CSS property `backgroundSize` */
|
|
110
|
+
bgsz?: WithResponsive<CSS['backgroundSize']>;
|
|
111
|
+
/** Shorthand for CSS property `backgroundRepeat` */
|
|
112
|
+
bgr?: WithResponsive<CSS['backgroundRepeat']>;
|
|
113
|
+
/** Shorthand for CSS property `color` */
|
|
114
|
+
c?: WithResponsive<ColorScheme | CSS['color']>;
|
|
115
|
+
/** Shorthand for CSS property `fontFamily` */
|
|
116
|
+
ff?: WithResponsive<CSS['fontFamily']>;
|
|
117
|
+
/** Shorthand for CSS property `fontSize` */
|
|
118
|
+
fs?: WithResponsive<CSS['fontSize']>;
|
|
119
|
+
/** Shorthand for CSS property `fontWeight` */
|
|
120
|
+
fw?: WithResponsive<CSS['fontWeight']>;
|
|
121
|
+
/** Shorthand for CSS property `textAlign` */
|
|
122
|
+
ta?: WithResponsive<CSS['textAlign']>;
|
|
123
|
+
/** Shorthand for CSS property `textTransform` */
|
|
124
|
+
tt?: WithResponsive<CSS['textTransform']>;
|
|
125
|
+
/** Shorthand for CSS property `textDecoration` */
|
|
126
|
+
td?: WithResponsive<CSS['textDecoration']>;
|
|
127
|
+
/** Shorthand for CSS property `textDecorationStyle` */
|
|
128
|
+
tds?: WithResponsive<CSS['textDecorationStyle']>;
|
|
129
|
+
/** Shorthand for CSS property `textDecorationColor` */
|
|
130
|
+
tdc?: WithResponsive<ColorScheme | CSS['textDecorationColor']>;
|
|
131
|
+
/** Shorthand for CSS property `letterSpacing` */
|
|
132
|
+
lts?: WithResponsive<CSS['letterSpacing']>;
|
|
133
|
+
/** Shorthand for CSS property `lineHeight` */
|
|
134
|
+
lh?: WithResponsive<CSS['lineHeight']>;
|
|
135
|
+
/** Shorthand for CSS property `border` */
|
|
136
|
+
bd?: WithResponsive<CSS['border']>;
|
|
137
|
+
/** Shorthand for CSS property `borderStyle` */
|
|
138
|
+
bs?: WithResponsive<CSS['borderStyle']>;
|
|
139
|
+
/** Shorthand for CSS property `borderColor` */
|
|
140
|
+
bc?: WithResponsive<ColorScheme | CSS['borderColor']>;
|
|
141
|
+
/** Shorthand for CSS property `borderWidth` */
|
|
142
|
+
bw?: WithResponsive<CSS['borderWidth']>;
|
|
143
|
+
/** Shorthand for CSS property `borderTop` */
|
|
144
|
+
bdt?: WithResponsive<CSS['borderTop']>;
|
|
145
|
+
/** Shorthand for CSS property `borderBottom` */
|
|
146
|
+
bdb?: WithResponsive<CSS['borderBottom']>;
|
|
147
|
+
/** Shorthand for CSS property `borderLeft` */
|
|
148
|
+
bdl?: WithResponsive<CSS['borderLeft']>;
|
|
149
|
+
/** Shorthand for CSS property `borderRight` */
|
|
150
|
+
bdr?: WithResponsive<CSS['borderRight']>;
|
|
151
|
+
/** Shorthand for CSS property `borderTopStyle` */
|
|
152
|
+
bdts?: WithResponsive<CSS['borderTopStyle']>;
|
|
153
|
+
/** Shorthand for CSS property `borderBottomStyle` */
|
|
154
|
+
bdbs?: WithResponsive<CSS['borderBottomStyle']>;
|
|
155
|
+
/** Shorthand for CSS property `borderLeftStyle` */
|
|
156
|
+
bdls?: WithResponsive<CSS['borderLeftStyle']>;
|
|
157
|
+
/** Shorthand for CSS property `borderRightStyle` */
|
|
158
|
+
bdrs?: WithResponsive<CSS['borderRightStyle']>;
|
|
159
|
+
/** Shorthand for CSS property `borderTopColor` */
|
|
160
|
+
bdtc?: WithResponsive<ColorScheme | CSS['borderTopColor']>;
|
|
161
|
+
/** Shorthand for CSS property `borderBottomColor` */
|
|
162
|
+
bdbc?: WithResponsive<ColorScheme | CSS['borderBottomColor']>;
|
|
163
|
+
/** Shorthand for CSS property `borderLeftColor` */
|
|
164
|
+
bdlc?: WithResponsive<ColorScheme | CSS['borderLeftColor']>;
|
|
165
|
+
/** Shorthand for CSS property `borderRightColor` */
|
|
166
|
+
bdrc?: WithResponsive<ColorScheme | CSS['borderRightColor']>;
|
|
167
|
+
/** Shorthand for CSS property `borderTopWidth` */
|
|
168
|
+
bdtw?: WithResponsive<CSS['borderTopWidth']>;
|
|
169
|
+
/** Shorthand for CSS property `borderBottomWidth` */
|
|
170
|
+
bdbw?: WithResponsive<CSS['borderBottomWidth']>;
|
|
171
|
+
/** Shorthand for CSS property `borderLeftWidth` */
|
|
172
|
+
bdlw?: WithResponsive<CSS['borderLeftWidth']>;
|
|
173
|
+
/** Shorthand for CSS property `borderRightWidth` */
|
|
174
|
+
bdrw?: WithResponsive<CSS['borderRightWidth']>;
|
|
175
|
+
/** Shorthand for CSS property `borderRadius` */
|
|
176
|
+
rounded?: WithResponsive<Size | CSS['borderRadius'] | 'full'>;
|
|
177
|
+
/** Shorthand for CSS property `boxShadow` */
|
|
178
|
+
shadow?: WithResponsive<Size | CSS['boxShadow']>;
|
|
179
|
+
/** CSS property `opacity` */
|
|
180
|
+
opacity?: WithResponsive<CSS['opacity']>;
|
|
181
|
+
/** Shorthand for CSS property `gap` */
|
|
182
|
+
spacing?: WithResponsive<CSS['gap']>;
|
|
183
|
+
/** CSS property `gap` */
|
|
184
|
+
gap?: WithResponsive<CSS['gap']>;
|
|
185
|
+
/** CSS property `rowGap` */
|
|
186
|
+
rowgap?: WithResponsive<CSS['rowGap']>;
|
|
187
|
+
/** CSS property `columnGap` */
|
|
188
|
+
colgap?: WithResponsive<CSS['columnGap']>;
|
|
189
|
+
/** Shorthand for CSS property `alignItems` */
|
|
190
|
+
align?: WithResponsive<CSS['alignItems']>;
|
|
191
|
+
/** Shorthand for CSS property `justifyContent` */
|
|
192
|
+
justify?: WithResponsive<CSS['justifyContent']>;
|
|
193
|
+
/** Shorthand for CSS property `alignSelf` */
|
|
194
|
+
self?: WithResponsive<CSS['alignSelf']>;
|
|
195
|
+
/** Shorthand for CSS property `flexBasis` */
|
|
196
|
+
basis?: WithResponsive<CSS['flexBasis']>;
|
|
197
|
+
/** Shorthand for CSS property `flex` */
|
|
198
|
+
flex?: WithResponsive<CSS['flex']>;
|
|
199
|
+
/** Shorthand for CSS property `flexGrow` */
|
|
200
|
+
grow?: WithResponsive<CSS['flexGrow']>;
|
|
201
|
+
/** Shorthand for CSS property `order` */
|
|
202
|
+
order?: WithResponsive<CSS['order']>;
|
|
203
|
+
/** Shorthand for CSS property `flexShrink` */
|
|
204
|
+
shrink?: WithResponsive<CSS['flexShrink']>;
|
|
205
|
+
/** Shorthand for CSS property `flexDirection` */
|
|
206
|
+
direction?: WithResponsive<CSS['flexDirection']>;
|
|
207
|
+
}
|
|
208
|
+
export {};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
import type { Breakpoints,
|
|
3
|
-
/**
|
|
4
|
-
* Options for the useStyled hook
|
|
5
|
-
*/
|
|
2
|
+
import type { Breakpoints, WithResponsive } from '../types';
|
|
6
3
|
interface UseStyledOptions {
|
|
7
4
|
/**
|
|
8
5
|
* CSS variables to apply
|
|
9
6
|
*/
|
|
10
|
-
cssVars?: Record<string, string | number | undefined
|
|
7
|
+
cssVars?: Record<string, WithResponsive<string | number | undefined>>;
|
|
11
8
|
/**
|
|
12
9
|
* Base class name to include
|
|
13
10
|
*/
|
|
@@ -23,7 +20,6 @@ interface UseStyledOptions {
|
|
|
23
20
|
enabled?: boolean | Breakpoints;
|
|
24
21
|
/**
|
|
25
22
|
* Prefix for the generated class name
|
|
26
|
-
* @default 'rs'
|
|
27
23
|
*/
|
|
28
24
|
prefix?: string;
|
|
29
25
|
}
|
|
@@ -5,84 +5,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.useStyled = useStyled;
|
|
8
|
-
var _react = require("react");
|
|
9
8
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
10
|
-
var
|
|
11
|
-
var
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _hooks = require("../hooks");
|
|
11
|
+
var _utils = require("../utils");
|
|
12
12
|
var _CustomContext = require("../Provider/CustomContext");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
p: 'padding',
|
|
17
|
-
pt: 'padding-top',
|
|
18
|
-
pr: 'padding-right',
|
|
19
|
-
pb: 'padding-bottom',
|
|
20
|
-
pl: 'padding-left',
|
|
21
|
-
px: 'padding-inline',
|
|
22
|
-
py: 'padding-block',
|
|
23
|
-
// Margin
|
|
24
|
-
m: 'margin',
|
|
25
|
-
mt: 'margin-top',
|
|
26
|
-
mr: 'margin-right',
|
|
27
|
-
mb: 'margin-bottom',
|
|
28
|
-
ml: 'margin-left',
|
|
29
|
-
mx: 'margin-inline',
|
|
30
|
-
my: 'margin-block',
|
|
31
|
-
// Size
|
|
32
|
-
w: 'width',
|
|
33
|
-
h: 'height',
|
|
34
|
-
minw: 'min-width',
|
|
35
|
-
maxw: 'max-width',
|
|
36
|
-
minh: 'min-height',
|
|
37
|
-
maxh: 'max-height',
|
|
38
|
-
// Display
|
|
39
|
-
display: 'display',
|
|
40
|
-
// Color and Background
|
|
41
|
-
c: 'color',
|
|
42
|
-
bg: 'background',
|
|
43
|
-
// Border
|
|
44
|
-
bd: 'border',
|
|
45
|
-
rounded: 'border-radius',
|
|
46
|
-
// Shadow
|
|
47
|
-
shadow: 'box-shadow',
|
|
48
|
-
// Stack
|
|
49
|
-
spacing: 'gap',
|
|
50
|
-
align: 'align-items',
|
|
51
|
-
justify: 'justify-content'
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Breakpoint values in pixels - matching SCSS variables
|
|
55
|
-
const breakpointValues = {
|
|
56
|
-
xs: 0,
|
|
57
|
-
// Base mobile first
|
|
58
|
-
sm: 576,
|
|
59
|
-
// $screen-sm
|
|
60
|
-
md: 768,
|
|
61
|
-
// $screen-md
|
|
62
|
-
lg: 992,
|
|
63
|
-
// $screen-lg
|
|
64
|
-
xl: 1200,
|
|
65
|
-
// $screen-xl
|
|
66
|
-
xxl: 1400 // $screen-xxl
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Options for the useStyled hook
|
|
71
|
-
*/
|
|
72
|
-
|
|
13
|
+
var _responsive = require("./responsive");
|
|
14
|
+
var _cssAlias = require("./css-alias");
|
|
15
|
+
var _styleManager = require("./style-manager");
|
|
73
16
|
/**
|
|
74
17
|
* Result of the useStyled hook
|
|
75
18
|
*/
|
|
76
19
|
|
|
77
|
-
/**
|
|
78
|
-
* Checks if a value is a responsive value object
|
|
79
|
-
* @param value - Value to check
|
|
80
|
-
* @returns True if the value is a responsive value object
|
|
81
|
-
*/
|
|
82
|
-
function isResponsiveValue(value) {
|
|
83
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).some(key => _constants.BREAKPOINTS.includes(key));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
20
|
/**
|
|
87
21
|
* Custom hook for managing component styling with scoped CSS variables
|
|
88
22
|
*
|
|
@@ -118,7 +52,7 @@ function useStyled(options) {
|
|
|
118
52
|
const shouldApplyStyles = enabled && !(0, _isEmpty.default)(cssVars);
|
|
119
53
|
|
|
120
54
|
// Apply CSS variables through StyleManager
|
|
121
|
-
(0,
|
|
55
|
+
(0, _hooks.useIsomorphicLayoutEffect)(() => {
|
|
122
56
|
if (!shouldApplyStyles) return;
|
|
123
57
|
|
|
124
58
|
// Create base CSS rules for the variables
|
|
@@ -131,7 +65,7 @@ function useStyled(options) {
|
|
|
131
65
|
// Process CSS variables, separating responsive from non-responsive
|
|
132
66
|
Object.entries(cssVars).forEach(([key, value]) => {
|
|
133
67
|
if (value !== undefined) {
|
|
134
|
-
if (isResponsiveValue(value)) {
|
|
68
|
+
if ((0, _responsive.isResponsiveValue)(value)) {
|
|
135
69
|
// Store responsive values for later processing
|
|
136
70
|
responsiveVars[key] = value;
|
|
137
71
|
|
|
@@ -156,9 +90,11 @@ function useStyled(options) {
|
|
|
156
90
|
const propName = varName.startsWith(cssVarPrefix) ? varName.substring(cssVarPrefix.length) : varName;
|
|
157
91
|
|
|
158
92
|
// Check if the property has a corresponding CSS property mapping
|
|
159
|
-
const cssProperty =
|
|
93
|
+
const cssProperty = _cssAlias.cssSystemPropAlias[propName];
|
|
160
94
|
if (cssProperty) {
|
|
161
|
-
basePropRules += `${cssProperty}: var(${varName}); `;
|
|
95
|
+
basePropRules += `${cssProperty.property}: var(${varName}); `;
|
|
96
|
+
} else if ((0, _utils.isCSSProperty)(propName)) {
|
|
97
|
+
basePropRules += `${propName}: var(${varName}); `;
|
|
162
98
|
}
|
|
163
99
|
});
|
|
164
100
|
|
|
@@ -180,7 +116,8 @@ function useStyled(options) {
|
|
|
180
116
|
md: '',
|
|
181
117
|
lg: '',
|
|
182
118
|
xl: '',
|
|
183
|
-
xxl: ''
|
|
119
|
+
xxl: '',
|
|
120
|
+
'2xl': ''
|
|
184
121
|
};
|
|
185
122
|
const breakpointPropRules = {
|
|
186
123
|
xs: '',
|
|
@@ -188,7 +125,8 @@ function useStyled(options) {
|
|
|
188
125
|
md: '',
|
|
189
126
|
lg: '',
|
|
190
127
|
xl: '',
|
|
191
|
-
xxl: ''
|
|
128
|
+
xxl: '',
|
|
129
|
+
'2xl': ''
|
|
192
130
|
};
|
|
193
131
|
|
|
194
132
|
// Group styles by breakpoint
|
|
@@ -196,7 +134,6 @@ function useStyled(options) {
|
|
|
196
134
|
Object.entries(responsiveValue).forEach(([breakpoint, value]) => {
|
|
197
135
|
const bp = breakpoint;
|
|
198
136
|
if (value !== undefined && bp !== 'xs') {
|
|
199
|
-
// Skip xs as it's already in base styles
|
|
200
137
|
// Add the CSS variable definition for this breakpoint
|
|
201
138
|
breakpointVarRules[bp] += `${varName}: ${value}; `;
|
|
202
139
|
|
|
@@ -204,9 +141,11 @@ function useStyled(options) {
|
|
|
204
141
|
const propName = varName.startsWith(cssVarPrefix) ? varName.substring(cssVarPrefix.length) : varName;
|
|
205
142
|
|
|
206
143
|
// Check if the property has a corresponding CSS property mapping
|
|
207
|
-
const cssProperty =
|
|
144
|
+
const cssProperty = _cssAlias.cssSystemPropAlias[propName];
|
|
208
145
|
if (cssProperty) {
|
|
209
146
|
breakpointPropRules[bp] += `${cssProperty}: var(${varName}); `;
|
|
147
|
+
} else if ((0, _utils.isCSSProperty)(propName)) {
|
|
148
|
+
breakpointPropRules[bp] += `${propName}: var(${varName}); `;
|
|
210
149
|
}
|
|
211
150
|
}
|
|
212
151
|
});
|
|
@@ -219,14 +158,15 @@ function useStyled(options) {
|
|
|
219
158
|
md: breakpointVarRules.md + breakpointPropRules.md,
|
|
220
159
|
lg: breakpointVarRules.lg + breakpointPropRules.lg,
|
|
221
160
|
xl: breakpointVarRules.xl + breakpointPropRules.xl,
|
|
222
|
-
xxl: breakpointVarRules.xxl + breakpointPropRules.xxl
|
|
161
|
+
xxl: breakpointVarRules.xxl + breakpointPropRules.xxl,
|
|
162
|
+
'2xl': breakpointVarRules['2xl'] + breakpointPropRules['2xl']
|
|
223
163
|
};
|
|
224
164
|
|
|
225
165
|
// Add media queries for each breakpoint with rules (skip xs)
|
|
226
166
|
Object.entries(breakpointRules).forEach(([breakpoint, rules]) => {
|
|
227
167
|
if (rules && breakpoint !== 'xs') {
|
|
228
168
|
const bp = breakpoint;
|
|
229
|
-
const minWidth = breakpointValues[bp];
|
|
169
|
+
const minWidth = _responsive.breakpointValues[bp];
|
|
230
170
|
_styleManager.StyleManager.addRule(`@media (min-width: ${minWidth}px)`, `.${componentId} { ${rules} }`, {
|
|
231
171
|
nonce: csp === null || csp === void 0 ? void 0 : csp.nonce
|
|
232
172
|
});
|
|
@@ -238,9 +178,9 @@ function useStyled(options) {
|
|
|
238
178
|
_styleManager.StyleManager.removeRule(`.${componentId}`);
|
|
239
179
|
|
|
240
180
|
// Clean up media query rules
|
|
241
|
-
Object.keys(breakpointValues).forEach(breakpoint => {
|
|
181
|
+
Object.keys(_responsive.breakpointValues).forEach(breakpoint => {
|
|
242
182
|
const bp = breakpoint;
|
|
243
|
-
const minWidth = breakpointValues[bp];
|
|
183
|
+
const minWidth = _responsive.breakpointValues[bp];
|
|
244
184
|
_styleManager.StyleManager.removeRule(`@media (min-width: ${minWidth}px)`);
|
|
245
185
|
});
|
|
246
186
|
};
|
|
@@ -2,20 +2,20 @@ import React from 'react';
|
|
|
2
2
|
/** React element with optional props and HTML attributes. */
|
|
3
3
|
export type ReactElement<P = any> = React.ReactElement<P & React.HTMLAttributes<any>>;
|
|
4
4
|
/** Removes 'onSelect' property from the given type. */
|
|
5
|
-
export type PropsWithoutSelect<T> = Omit<T, 'onSelect'>;
|
|
5
|
+
export type PropsWithoutSelect<T> = Omit<T, 'onSelect' | 'color'>;
|
|
6
6
|
/** Removes 'onChange' property from the given type. */
|
|
7
|
-
export type PropsWithoutChange<T> = Omit<T, 'onChange'>;
|
|
7
|
+
export type PropsWithoutChange<T> = Omit<T, 'onChange' | 'color'>;
|
|
8
8
|
export type PropsWithout<T, K extends keyof T> = Omit<T, K>;
|
|
9
9
|
/** HTML props excluding 'onSelect' attribute. */
|
|
10
10
|
export type HTMLPropsWithoutSelect<T extends HTMLElement = HTMLElement, P extends Record<string, any> = React.HTMLAttributes<T>> = PropsWithoutSelect<P>;
|
|
11
11
|
/** HTML props excluding 'onChange' attribute. */
|
|
12
12
|
export type HTMLPropsWithoutChange<T extends HTMLElement = HTMLElement, P extends Record<string, any> = React.HTMLAttributes<T>> = PropsWithoutChange<P>;
|
|
13
13
|
/** Input props with 'onChange' and 'size' attributes removed. */
|
|
14
|
-
export type SanitizedInputProps = PropsWithout<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'>;
|
|
14
|
+
export type SanitizedInputProps = PropsWithout<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size' | 'color'>;
|
|
15
15
|
/** Textarea props with 'onChange' attribute removed. */
|
|
16
|
-
export type SanitizedTextareaProps = PropsWithout<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'>;
|
|
16
|
+
export type SanitizedTextareaProps = PropsWithout<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange' | 'color'>;
|
|
17
17
|
/** HTML props excluding 'title', 'onToggle', and 'onSelect' attributes. */
|
|
18
|
-
export type SanitizedHTMListProps<T extends HTMLElement = HTMLElement, P extends Record<string, any> = React.HTMLAttributes<T>> = PropsWithout<P, 'title' | 'onToggle' | 'onSelect'>;
|
|
19
|
-
export type WithoutChildren<T> = Omit<T, 'children'>;
|
|
18
|
+
export type SanitizedHTMListProps<T extends HTMLElement = HTMLElement, P extends Record<string, any> = React.HTMLAttributes<T>> = PropsWithout<P, 'title' | 'onToggle' | 'onSelect' | 'color'>;
|
|
19
|
+
export type WithoutChildren<T> = Omit<T, 'children' | 'color'>;
|
|
20
20
|
export type CSSVariables = Partial<Record<`--${string}`, string | number | undefined>>;
|
|
21
21
|
export type StyleProperties = React.CSSProperties | CSSVariables;
|
|
@@ -90,7 +90,7 @@ export interface DataProps<TData> {
|
|
|
90
90
|
*/
|
|
91
91
|
childrenKey?: string;
|
|
92
92
|
}
|
|
93
|
-
export interface PickerBaseProps<L = any> extends PopupProps, BoxProps, AnimationEventProps {
|
|
93
|
+
export interface PickerBaseProps<L = any> extends PopupProps, Omit<BoxProps, 'height'>, AnimationEventProps {
|
|
94
94
|
id?: string;
|
|
95
95
|
/**
|
|
96
96
|
* Custom Ref for the picker
|
|
@@ -139,7 +139,7 @@ export interface PickerBaseProps<L = any> extends PopupProps, BoxProps, Animatio
|
|
|
139
139
|
/** Custom render extra footer */
|
|
140
140
|
renderExtraFooter?: () => ReactNode;
|
|
141
141
|
}
|
|
142
|
-
export interface FormControlPickerProps<T = any, L = any, D = Record<string, any>, I = T> extends PickerBaseProps<L>, FormControlBaseProps<T
|
|
142
|
+
export interface FormControlPickerProps<T = any, L = any, D = Record<string, any>, I = T> extends DataProps<D>, PickerBaseProps<L>, FormControlBaseProps<T> {
|
|
143
143
|
/**
|
|
144
144
|
* Disabled items
|
|
145
145
|
*/
|
|
@@ -21,7 +21,8 @@ export type Size = `${SizeEnum}`;
|
|
|
21
21
|
/** Basic size type (xs, sm, md, lg) */
|
|
22
22
|
export type BasicSize = Exclude<Size, 'xl'>;
|
|
23
23
|
export type TextSize = `${TypographySizeEnum}`;
|
|
24
|
-
export type Breakpoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
24
|
+
export type Breakpoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | '2xl';
|
|
25
25
|
export type ResponsiveValue<T> = {
|
|
26
26
|
[key in Breakpoints]?: T;
|
|
27
27
|
};
|
|
28
|
+
export type WithResponsive<T> = T | ResponsiveValue<T>;
|
|
@@ -5,7 +5,7 @@ import { Color } from '../types/colours';
|
|
|
5
5
|
* @param color The color value to check
|
|
6
6
|
* @returns The CSS variable if it's a valid color type, or the original value
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const getColorValue: (color: Color | string | undefined) => string | undefined;
|
|
9
9
|
export declare const isPresetColor: (color?: Color | React.CSSProperties['color']) => boolean;
|
|
10
10
|
export declare const getColorStyle: (value?: import("csstype").Property.Color | undefined, name?: string | undefined, prop?: string) => {
|
|
11
11
|
[x: string]: string | (string & {}) | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.isPresetColor = exports.getLuminance = exports.getContrastText = exports.
|
|
5
|
+
exports.isPresetColor = exports.getLuminance = exports.getContrastText = exports.getColorValue = exports.getColorStyle = exports.expandHexColor = exports.createColorVariables = void 0;
|
|
6
6
|
var _colours = require("../types/colours");
|
|
7
7
|
var _styleSheet = require("./style-sheet");
|
|
8
8
|
/**
|
|
@@ -11,7 +11,7 @@ var _styleSheet = require("./style-sheet");
|
|
|
11
11
|
* @param color The color value to check
|
|
12
12
|
* @returns The CSS variable if it's a valid color type, or the original value
|
|
13
13
|
*/
|
|
14
|
-
const
|
|
14
|
+
const getColorValue = color => {
|
|
15
15
|
if (!color) return undefined;
|
|
16
16
|
|
|
17
17
|
// Check if color is a base color (e.g., 'red', 'blue')
|
|
@@ -31,7 +31,7 @@ const getColorVar = color => {
|
|
|
31
31
|
// Return the original value if it's not a recognized color pattern
|
|
32
32
|
return color;
|
|
33
33
|
};
|
|
34
|
-
exports.
|
|
34
|
+
exports.getColorValue = getColorValue;
|
|
35
35
|
const isPresetColor = color => {
|
|
36
36
|
if (!color) {
|
|
37
37
|
return false;
|
|
@@ -46,7 +46,7 @@ const colorConfig = {
|
|
|
46
46
|
prop: 'color',
|
|
47
47
|
useGlobalVar: true,
|
|
48
48
|
presetChecker: isPresetColor,
|
|
49
|
-
valueTransformer:
|
|
49
|
+
valueTransformer: getColorValue
|
|
50
50
|
};
|
|
51
51
|
const getColorStyle = exports.getColorStyle = (0, _styleSheet.createStyleGetter)(colorConfig);
|
|
52
52
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SizeEnum } from '../types';
|
|
2
2
|
export declare const isPresetSize: (size?: SizeEnum | number | string | null) => boolean;
|
|
3
|
+
export declare const getSizeValue: (type: string, size: SizeEnum | number | string | null) => string | undefined;
|
|
3
4
|
export declare const getSizeStyle: (value?: string | number | undefined, name?: string | undefined, prop?: string) => {
|
|
4
5
|
[x: string]: string | number | undefined;
|
|
5
6
|
} | undefined;
|