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,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
|
}
|
|
@@ -1,82 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useId, useLayoutEffect, useContext } from 'react';
|
|
3
2
|
import isEmpty from 'lodash/isEmpty';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useId, useContext } from 'react';
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "../hooks/index.js";
|
|
5
|
+
import { isCSSProperty } from "../utils/index.js";
|
|
6
6
|
import { CustomContext } from "../Provider/CustomContext.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
p: 'padding',
|
|
11
|
-
pt: 'padding-top',
|
|
12
|
-
pr: 'padding-right',
|
|
13
|
-
pb: 'padding-bottom',
|
|
14
|
-
pl: 'padding-left',
|
|
15
|
-
px: 'padding-inline',
|
|
16
|
-
py: 'padding-block',
|
|
17
|
-
// Margin
|
|
18
|
-
m: 'margin',
|
|
19
|
-
mt: 'margin-top',
|
|
20
|
-
mr: 'margin-right',
|
|
21
|
-
mb: 'margin-bottom',
|
|
22
|
-
ml: 'margin-left',
|
|
23
|
-
mx: 'margin-inline',
|
|
24
|
-
my: 'margin-block',
|
|
25
|
-
// Size
|
|
26
|
-
w: 'width',
|
|
27
|
-
h: 'height',
|
|
28
|
-
minw: 'min-width',
|
|
29
|
-
maxw: 'max-width',
|
|
30
|
-
minh: 'min-height',
|
|
31
|
-
maxh: 'max-height',
|
|
32
|
-
// Display
|
|
33
|
-
display: 'display',
|
|
34
|
-
// Color and Background
|
|
35
|
-
c: 'color',
|
|
36
|
-
bg: 'background',
|
|
37
|
-
// Border
|
|
38
|
-
bd: 'border',
|
|
39
|
-
rounded: 'border-radius',
|
|
40
|
-
// Shadow
|
|
41
|
-
shadow: 'box-shadow',
|
|
42
|
-
// Stack
|
|
43
|
-
spacing: 'gap',
|
|
44
|
-
align: 'align-items',
|
|
45
|
-
justify: 'justify-content'
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Breakpoint values in pixels - matching SCSS variables
|
|
49
|
-
const breakpointValues = {
|
|
50
|
-
xs: 0,
|
|
51
|
-
// Base mobile first
|
|
52
|
-
sm: 576,
|
|
53
|
-
// $screen-sm
|
|
54
|
-
md: 768,
|
|
55
|
-
// $screen-md
|
|
56
|
-
lg: 992,
|
|
57
|
-
// $screen-lg
|
|
58
|
-
xl: 1200,
|
|
59
|
-
// $screen-xl
|
|
60
|
-
xxl: 1400 // $screen-xxl
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Options for the useStyled hook
|
|
65
|
-
*/
|
|
7
|
+
import { breakpointValues, isResponsiveValue } from "./responsive.js";
|
|
8
|
+
import { cssSystemPropAlias } from "./css-alias.js";
|
|
9
|
+
import { StyleManager } from "./style-manager.js";
|
|
66
10
|
|
|
67
11
|
/**
|
|
68
12
|
* Result of the useStyled hook
|
|
69
13
|
*/
|
|
70
14
|
|
|
71
|
-
/**
|
|
72
|
-
* Checks if a value is a responsive value object
|
|
73
|
-
* @param value - Value to check
|
|
74
|
-
* @returns True if the value is a responsive value object
|
|
75
|
-
*/
|
|
76
|
-
function isResponsiveValue(value) {
|
|
77
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).some(key => BREAKPOINTS.includes(key));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
15
|
/**
|
|
81
16
|
* Custom hook for managing component styling with scoped CSS variables
|
|
82
17
|
*
|
|
@@ -112,7 +47,7 @@ export function useStyled(options) {
|
|
|
112
47
|
const shouldApplyStyles = enabled && !isEmpty(cssVars);
|
|
113
48
|
|
|
114
49
|
// Apply CSS variables through StyleManager
|
|
115
|
-
|
|
50
|
+
useIsomorphicLayoutEffect(() => {
|
|
116
51
|
if (!shouldApplyStyles) return;
|
|
117
52
|
|
|
118
53
|
// Create base CSS rules for the variables
|
|
@@ -150,9 +85,11 @@ export function useStyled(options) {
|
|
|
150
85
|
const propName = varName.startsWith(cssVarPrefix) ? varName.substring(cssVarPrefix.length) : varName;
|
|
151
86
|
|
|
152
87
|
// Check if the property has a corresponding CSS property mapping
|
|
153
|
-
const cssProperty =
|
|
88
|
+
const cssProperty = cssSystemPropAlias[propName];
|
|
154
89
|
if (cssProperty) {
|
|
155
|
-
basePropRules += `${cssProperty}: var(${varName}); `;
|
|
90
|
+
basePropRules += `${cssProperty.property}: var(${varName}); `;
|
|
91
|
+
} else if (isCSSProperty(propName)) {
|
|
92
|
+
basePropRules += `${propName}: var(${varName}); `;
|
|
156
93
|
}
|
|
157
94
|
});
|
|
158
95
|
|
|
@@ -174,7 +111,8 @@ export function useStyled(options) {
|
|
|
174
111
|
md: '',
|
|
175
112
|
lg: '',
|
|
176
113
|
xl: '',
|
|
177
|
-
xxl: ''
|
|
114
|
+
xxl: '',
|
|
115
|
+
'2xl': ''
|
|
178
116
|
};
|
|
179
117
|
const breakpointPropRules = {
|
|
180
118
|
xs: '',
|
|
@@ -182,7 +120,8 @@ export function useStyled(options) {
|
|
|
182
120
|
md: '',
|
|
183
121
|
lg: '',
|
|
184
122
|
xl: '',
|
|
185
|
-
xxl: ''
|
|
123
|
+
xxl: '',
|
|
124
|
+
'2xl': ''
|
|
186
125
|
};
|
|
187
126
|
|
|
188
127
|
// Group styles by breakpoint
|
|
@@ -190,7 +129,6 @@ export function useStyled(options) {
|
|
|
190
129
|
Object.entries(responsiveValue).forEach(([breakpoint, value]) => {
|
|
191
130
|
const bp = breakpoint;
|
|
192
131
|
if (value !== undefined && bp !== 'xs') {
|
|
193
|
-
// Skip xs as it's already in base styles
|
|
194
132
|
// Add the CSS variable definition for this breakpoint
|
|
195
133
|
breakpointVarRules[bp] += `${varName}: ${value}; `;
|
|
196
134
|
|
|
@@ -198,9 +136,11 @@ export function useStyled(options) {
|
|
|
198
136
|
const propName = varName.startsWith(cssVarPrefix) ? varName.substring(cssVarPrefix.length) : varName;
|
|
199
137
|
|
|
200
138
|
// Check if the property has a corresponding CSS property mapping
|
|
201
|
-
const cssProperty =
|
|
139
|
+
const cssProperty = cssSystemPropAlias[propName];
|
|
202
140
|
if (cssProperty) {
|
|
203
141
|
breakpointPropRules[bp] += `${cssProperty}: var(${varName}); `;
|
|
142
|
+
} else if (isCSSProperty(propName)) {
|
|
143
|
+
breakpointPropRules[bp] += `${propName}: var(${varName}); `;
|
|
204
144
|
}
|
|
205
145
|
}
|
|
206
146
|
});
|
|
@@ -213,7 +153,8 @@ export function useStyled(options) {
|
|
|
213
153
|
md: breakpointVarRules.md + breakpointPropRules.md,
|
|
214
154
|
lg: breakpointVarRules.lg + breakpointPropRules.lg,
|
|
215
155
|
xl: breakpointVarRules.xl + breakpointPropRules.xl,
|
|
216
|
-
xxl: breakpointVarRules.xxl + breakpointPropRules.xxl
|
|
156
|
+
xxl: breakpointVarRules.xxl + breakpointPropRules.xxl,
|
|
157
|
+
'2xl': breakpointVarRules['2xl'] + breakpointPropRules['2xl']
|
|
217
158
|
};
|
|
218
159
|
|
|
219
160
|
// Add media queries for each breakpoint with rules (skip xs)
|
|
@@ -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;
|
|
@@ -8,7 +8,7 @@ import { createStyleGetter } from "./style-sheet/index.js";
|
|
|
8
8
|
* @param color The color value to check
|
|
9
9
|
* @returns The CSS variable if it's a valid color type, or the original value
|
|
10
10
|
*/
|
|
11
|
-
export const
|
|
11
|
+
export const getColorValue = color => {
|
|
12
12
|
if (!color) return undefined;
|
|
13
13
|
|
|
14
14
|
// Check if color is a base color (e.g., 'red', 'blue')
|
|
@@ -41,7 +41,7 @@ const colorConfig = {
|
|
|
41
41
|
prop: 'color',
|
|
42
42
|
useGlobalVar: true,
|
|
43
43
|
presetChecker: isPresetColor,
|
|
44
|
-
valueTransformer:
|
|
44
|
+
valueTransformer: getColorValue
|
|
45
45
|
};
|
|
46
46
|
export const getColorStyle = createStyleGetter(colorConfig);
|
|
47
47
|
|
|
@@ -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;
|
|
@@ -13,6 +13,12 @@ const sizeConfig = {
|
|
|
13
13
|
presetChecker: isPresetSize,
|
|
14
14
|
valueTransformer: getCssValue
|
|
15
15
|
};
|
|
16
|
+
export const getSizeValue = (type, size) => {
|
|
17
|
+
if (isPresetSize(size)) {
|
|
18
|
+
return `var(--rs-${type}-${size})`;
|
|
19
|
+
}
|
|
20
|
+
return getCssValue(size);
|
|
21
|
+
};
|
|
16
22
|
export const getSizeStyle = createStyleGetter(sizeConfig);
|
|
17
23
|
const lineHeightConfig = {
|
|
18
24
|
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>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import isEmpty from 'lodash/isEmpty';
|
|
3
|
+
import camelCase from 'lodash/camelCase';
|
|
4
|
+
import canUseDOM from 'dom-lib/canUseDOM';
|
|
3
5
|
/**
|
|
4
6
|
* Processes and returns a value suitable for CSS (with a unit).
|
|
5
7
|
*/
|
|
@@ -46,4 +48,36 @@ export function createOffsetStyles(offset, prefix = '--rs-offset') {
|
|
|
46
48
|
[`${prefix}-x`]: getCssValue(x),
|
|
47
49
|
[`${prefix}-y`]: getCssValue(y)
|
|
48
50
|
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Check if a string is a valid CSS property name
|
|
55
|
+
* @param prop - The property name to check
|
|
56
|
+
* @returns True if the property is a valid CSS property
|
|
57
|
+
*/
|
|
58
|
+
export function isCSSProperty(prop) {
|
|
59
|
+
if (!canUseDOM || typeof prop !== 'string' || !prop) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
// Handle standard properties
|
|
64
|
+
const style = document.documentElement.style;
|
|
65
|
+
|
|
66
|
+
// Check standard property
|
|
67
|
+
if (prop in style) {
|
|
68
|
+
return true;
|
|
69
|
+
} else if (camelCase(prop) in style) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Handle vendor-prefixed properties (e.g., Webkit, Moz, ms, O)
|
|
74
|
+
const prefixes = ['Webkit', 'Moz', 'ms', 'O'];
|
|
75
|
+
const propName = prop.charAt(0).toUpperCase() + prop.slice(1);
|
|
76
|
+
return prefixes.some(prefix => `${prefix}${propName}` in style);
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
79
|
+
console.warn(`Failed to check CSS property: ${prop}`, e);
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
49
83
|
}
|
|
@@ -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[];
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { BREAKPOINTS } from "../../constants/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Generates responsive CSS class names based on the provided value and prefix function.
|
|
5
|
+
* Handles both static and responsive values.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // With a single value
|
|
9
|
+
* // getResponsiveClasses('rs-row', 'top');
|
|
10
|
+
* // Returns: ['rs-row-top']
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // With responsive values
|
|
14
|
+
* // getResponsiveClasses('rs-row', { xs: 'top', md: 'bottom' });
|
|
15
|
+
* // Returns: ['rs-row-xs-top', 'rs-row-md-bottom']
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
3
18
|
export const getResponsiveClasses = (prefix, value) => {
|
|
4
19
|
if (!value) {
|
|
5
20
|
return [];
|
|
6
21
|
}
|
|
22
|
+
|
|
23
|
+
// Handle non-object (static) values
|
|
7
24
|
if (typeof value !== 'object') {
|
|
8
25
|
return [prefix(value)];
|
|
9
26
|
}
|
|
27
|
+
|
|
28
|
+
// Process responsive values for each breakpoint
|
|
10
29
|
return BREAKPOINTS.reduce((classes, breakpoint) => {
|
|
11
30
|
const breakpointValue = value[breakpoint];
|
|
12
31
|
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
|