rsuite 6.0.0-canary-20241227 → 6.0.0-canary-20250103
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 +8 -16
- package/Badge/styles/index.css +83 -17
- package/Badge/styles/index.less +68 -9
- package/Button/styles/index.css +5 -10
- package/Button/styles/mixin.less +1 -2
- package/CHANGELOG.md +18 -0
- package/Calendar/styles/index.css +6 -12
- package/Cascader/styles/index.css +8 -16
- package/CheckPicker/styles/index.css +8 -16
- package/CheckTree/styles/index.css +8 -16
- package/CheckTreePicker/styles/index.css +8 -16
- package/DatePicker/styles/index.css +9 -18
- package/DateRangePicker/styles/index.css +9 -18
- package/Dropdown/styles/index.css +5 -10
- package/IconButton/styles/index.css +7 -14
- package/InputGroup/styles/index.css +6 -12
- package/InputNumber/styles/index.css +6 -12
- package/InputPicker/styles/index.css +8 -16
- package/MultiCascadeTree/styles/index.css +8 -16
- package/MultiCascader/styles/index.css +8 -16
- package/Nav/styles/index.css +5 -10
- package/Navbar/styles/index.css +5 -10
- package/Pagination/styles/index.css +11 -22
- package/Rate/styles/index.css +16 -8
- package/Rate/styles/index.less +6 -2
- package/SelectPicker/styles/index.css +8 -16
- package/Stat/styles/index.css +7 -14
- package/Table/styles/index.css +2 -2
- package/Tabs/styles/index.css +5 -10
- package/Tag/styles/index.css +29 -21
- package/Tag/styles/index.less +6 -3
- package/TagInput/styles/index.css +8 -16
- package/TagPicker/styles/index.css +8 -16
- package/TimePicker/styles/index.css +9 -18
- package/TimeRangePicker/styles/index.css +9 -18
- package/Tree/styles/index.css +8 -16
- package/TreePicker/styles/index.css +8 -16
- package/Uploader/styles/index.css +7 -14
- package/cjs/Accordion/Accordion.js +1 -1
- package/cjs/AutoComplete/AutoComplete.d.ts +2 -2
- package/cjs/AutoComplete/Combobox.js +1 -1
- package/cjs/Badge/Badge.d.ts +40 -5
- package/cjs/Badge/Badge.js +30 -19
- package/cjs/Breadcrumb/Breadcrumb.js +1 -1
- package/cjs/Button/Button.d.ts +5 -1
- package/cjs/Button/Button.js +17 -3
- package/cjs/Card/Card.js +1 -1
- package/cjs/CascadeTree/utils.js +1 -1
- package/cjs/CustomProvider/CustomProvider.d.ts +12 -4
- package/cjs/CustomProvider/CustomProvider.js +4 -3
- package/cjs/DateInput/hooks/useDateInputState.js +10 -8
- package/cjs/DateInput/hooks/useKeyboardInputEvent.js +1 -0
- package/cjs/DatePicker/PredefinedRanges.js +1 -1
- package/cjs/DateRangePicker/DateRangePicker.js +1 -1
- package/cjs/Drawer/Drawer.d.ts +2 -2
- package/cjs/Drawer/Drawer.js +1 -1
- package/cjs/Drawer/DrawerBody.js +7 -5
- package/cjs/Drawer/DrawerFooter.js +7 -5
- package/cjs/Drawer/DrawerHeader.js +7 -5
- package/cjs/Drawer/DrawerTitle.js +7 -5
- package/cjs/Dropdown/Dropdown.d.ts +2 -2
- package/cjs/Dropdown/Dropdown.js +1 -1
- package/cjs/Dropdown/DropdownContext.d.ts +1 -1
- package/cjs/Dropdown/DropdownMenu.d.ts +2 -2
- package/cjs/Dropdown/DropdownToggle.d.ts +2 -2
- package/cjs/FlexboxGrid/FlexboxGrid.js +1 -1
- package/cjs/Form/Form.js +1 -1
- package/cjs/FormControl/FormControl.d.ts +2 -2
- package/cjs/FormErrorMessage/FormErrorMessage.d.ts +2 -2
- package/cjs/InlineEdit/EditableControls.js +1 -1
- package/cjs/InputGroup/InputGroup.js +1 -1
- package/cjs/InputNumber/InputNumber.js +1 -1
- package/cjs/InputPicker/InputPicker.js +0 -1
- package/cjs/InputPicker/TagList.js +1 -0
- package/cjs/InputPicker/TextBox.js +1 -0
- package/cjs/InputPicker/hooks/useMaxWidth.js +0 -1
- package/cjs/List/List.js +1 -1
- package/cjs/MaskedInput/MaskedInput.js +1 -0
- package/cjs/MaskedInput/conformToMask.js +0 -1
- package/cjs/Modal/Modal.js +1 -1
- package/cjs/Modal/utils.js +0 -1
- package/cjs/Nav/Nav.js +1 -1
- package/cjs/Nav/NavDropdown.d.ts +2 -2
- package/cjs/Nav/NavDropdown.js +1 -1
- package/cjs/Nav/NavDropdownToggle.d.ts +2 -2
- package/cjs/Navbar/Navbar.js +1 -1
- package/cjs/Navbar/NavbarDropdown.d.ts +2 -2
- package/cjs/Navbar/NavbarDropdown.js +1 -1
- package/cjs/Navbar/NavbarDropdownToggle.d.ts +2 -2
- package/cjs/Navbar/index.js +0 -0
- package/cjs/RangeSlider/RangeSlider.js +4 -4
- package/cjs/Rate/Character.js +6 -6
- package/cjs/Rate/Rate.d.ts +4 -4
- package/cjs/Rate/Rate.js +16 -15
- package/cjs/Sidenav/ExpandedSidenavDropdown.d.ts +2 -2
- package/cjs/Sidenav/Sidenav.js +1 -1
- package/cjs/Sidenav/SidenavDropdown.d.ts +2 -2
- package/cjs/Sidenav/SidenavDropdown.js +1 -1
- package/cjs/Sidenav/SidenavDropdownToggle.d.ts +2 -2
- package/cjs/Stack/HStack.js +1 -1
- package/cjs/Stack/Stack.js +1 -1
- package/cjs/Stack/VStack.js +1 -1
- package/cjs/Stat/Stat.js +1 -1
- package/cjs/Steps/Steps.js +1 -1
- package/cjs/Table/Table.js +2 -2
- package/cjs/Tabs/Tabs.js +8 -9
- package/cjs/Tag/Tag.d.ts +2 -2
- package/cjs/Tag/Tag.js +12 -6
- package/cjs/Timeline/Timeline.js +8 -5
- package/cjs/Tooltip/Tooltip.d.ts +2 -2
- package/cjs/Tree/hooks/useFlattenTree.js +1 -3
- package/cjs/Tree/hooks/useFocusTree.js +0 -1
- package/cjs/Tree/hooks/useTreeSearch.js +0 -1
- package/cjs/Uploader/UploadTrigger.js +13 -28
- package/cjs/Uploader/utils/ajaxUpload.js +1 -1
- package/cjs/internals/Disclosure/Disclosure.js +1 -0
- package/cjs/internals/Menu/useMenu.js +51 -49
- package/cjs/internals/Overlay/Overlay.d.ts +2 -2
- package/cjs/internals/Overlay/OverlayTrigger.d.ts +2 -2
- package/cjs/internals/Overlay/Position.d.ts +2 -2
- package/cjs/internals/Overlay/positionUtils.d.ts +2 -2
- package/cjs/internals/Picker/PickerToggle.d.ts +2 -2
- package/cjs/internals/Picker/PickerToggleTrigger.d.ts +2 -2
- package/cjs/internals/Picker/hooks/useFocusItemValue.js +1 -1
- package/cjs/internals/Picker/hooks/usePickerClassName.d.ts +2 -2
- package/cjs/internals/ScrollView/hooks/useScrollState.d.ts +1 -1
- package/cjs/internals/Tree/TreeView.js +2 -1
- package/cjs/internals/Tree/utils/getPathTowardsItem.js +1 -1
- package/cjs/internals/Windowing/AutoSizer.js +1 -0
- package/cjs/internals/Windowing/List.js +2 -1
- package/cjs/internals/hooks/useClassNames.d.ts +1 -2
- package/cjs/internals/hooks/useClassNames.js +0 -2
- package/cjs/internals/hooks/usePortal.js +1 -1
- package/cjs/internals/hooks/useToggleCaret.d.ts +2 -2
- package/cjs/internals/hooks/useToggleCaret.js +1 -1
- package/cjs/internals/hooks/useUpdateEffect.js +0 -1
- package/cjs/internals/hooks/useWillUnmount.js +0 -2
- package/cjs/internals/symbols.d.ts +1 -0
- package/cjs/internals/symbols.js +3 -2
- package/cjs/internals/types/colours.d.ts +10 -0
- package/cjs/internals/types/colours.js +15 -0
- package/cjs/internals/types/index.d.ts +6 -7
- package/cjs/internals/types/index.js +13 -1
- package/cjs/internals/types/placement.d.ts +5 -0
- package/cjs/internals/types/placement.js +4 -0
- package/cjs/internals/utils/BrowserDetection.d.ts +0 -2
- package/cjs/internals/utils/BrowserDetection.js +2 -12
- package/cjs/internals/utils/ReactChildren.js +0 -2
- package/cjs/internals/utils/colours.d.ts +21 -0
- package/cjs/internals/utils/colours.js +86 -0
- package/cjs/internals/utils/css.d.ts +13 -1
- package/cjs/internals/utils/css.js +42 -3
- package/cjs/internals/utils/getDOMNode.js +2 -2
- package/cjs/internals/utils/getSafeRegExpString.js +2 -1
- package/cjs/internals/utils/index.d.ts +2 -2
- package/cjs/internals/utils/index.js +17 -9
- package/cjs/toaster/ToastContainer.d.ts +8 -8
- package/cjs/toaster/ToastContainer.js +39 -36
- package/cjs/toaster/render.d.ts +2 -0
- package/cjs/toaster/render.js +25 -0
- package/cjs/toaster/toaster.js +29 -19
- package/cjs/useMediaQuery/useMediaQuery.js +1 -3
- package/cjs/useToaster/useToaster.js +10 -5
- package/dist/rsuite-no-reset-rtl.css +143 -74
- package/dist/rsuite-no-reset-rtl.min.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
- package/dist/rsuite-no-reset.css +143 -74
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +143 -74
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +143 -74
- package/dist/rsuite.js +113 -91
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Accordion/Accordion.js +1 -1
- package/esm/AutoComplete/AutoComplete.d.ts +2 -2
- package/esm/AutoComplete/Combobox.js +1 -1
- package/esm/Badge/Badge.d.ts +40 -5
- package/esm/Badge/Badge.js +28 -19
- package/esm/Breadcrumb/Breadcrumb.js +1 -1
- package/esm/Button/Button.d.ts +5 -1
- package/esm/Button/Button.js +18 -4
- package/esm/Card/Card.js +1 -1
- package/esm/CascadeTree/utils.js +1 -1
- package/esm/CustomProvider/CustomProvider.d.ts +12 -4
- package/esm/CustomProvider/CustomProvider.js +5 -4
- package/esm/DateInput/hooks/useDateInputState.js +10 -8
- package/esm/DateInput/hooks/useKeyboardInputEvent.js +1 -0
- package/esm/DatePicker/PredefinedRanges.js +1 -1
- package/esm/DateRangePicker/DateRangePicker.js +1 -1
- package/esm/Drawer/Drawer.d.ts +2 -2
- package/esm/Drawer/Drawer.js +1 -1
- package/esm/Drawer/DrawerBody.js +7 -5
- package/esm/Drawer/DrawerFooter.js +7 -5
- package/esm/Drawer/DrawerHeader.js +7 -5
- package/esm/Drawer/DrawerTitle.js +7 -5
- package/esm/Dropdown/Dropdown.d.ts +2 -2
- package/esm/Dropdown/Dropdown.js +1 -1
- package/esm/Dropdown/DropdownContext.d.ts +1 -1
- package/esm/Dropdown/DropdownMenu.d.ts +2 -2
- package/esm/Dropdown/DropdownToggle.d.ts +2 -2
- package/esm/FlexboxGrid/FlexboxGrid.js +1 -1
- package/esm/Form/Form.js +1 -1
- package/esm/FormControl/FormControl.d.ts +2 -2
- package/esm/FormErrorMessage/FormErrorMessage.d.ts +2 -2
- package/esm/InlineEdit/EditableControls.js +1 -1
- package/esm/InputGroup/InputGroup.js +1 -1
- package/esm/InputNumber/InputNumber.js +1 -1
- package/esm/InputPicker/InputPicker.js +0 -1
- package/esm/InputPicker/TagList.js +1 -0
- package/esm/InputPicker/TextBox.js +1 -0
- package/esm/InputPicker/hooks/useMaxWidth.js +0 -1
- package/esm/List/List.js +1 -1
- package/esm/MaskedInput/MaskedInput.js +1 -0
- package/esm/MaskedInput/conformToMask.js +0 -1
- package/esm/Modal/Modal.js +1 -1
- package/esm/Modal/utils.js +0 -1
- package/esm/Nav/Nav.js +1 -1
- package/esm/Nav/NavDropdown.d.ts +2 -2
- package/esm/Nav/NavDropdown.js +1 -1
- package/esm/Nav/NavDropdownToggle.d.ts +2 -2
- package/esm/Navbar/Navbar.js +1 -1
- package/esm/Navbar/NavbarDropdown.d.ts +2 -2
- package/esm/Navbar/NavbarDropdown.js +1 -1
- package/esm/Navbar/NavbarDropdownToggle.d.ts +2 -2
- package/esm/Navbar/index.js +0 -0
- package/esm/RangeSlider/RangeSlider.js +4 -4
- package/esm/Rate/Character.js +8 -8
- package/esm/Rate/Rate.d.ts +4 -4
- package/esm/Rate/Rate.js +19 -18
- package/esm/Sidenav/ExpandedSidenavDropdown.d.ts +2 -2
- package/esm/Sidenav/Sidenav.js +1 -1
- package/esm/Sidenav/SidenavDropdown.d.ts +2 -2
- package/esm/Sidenav/SidenavDropdown.js +1 -1
- package/esm/Sidenav/SidenavDropdownToggle.d.ts +2 -2
- package/esm/Stack/HStack.js +1 -1
- package/esm/Stack/Stack.js +1 -1
- package/esm/Stack/VStack.js +1 -1
- package/esm/Stat/Stat.js +1 -1
- package/esm/Steps/Steps.js +1 -1
- package/esm/Table/Table.js +2 -2
- package/esm/Tabs/Tabs.js +8 -9
- package/esm/Tag/Tag.d.ts +2 -2
- package/esm/Tag/Tag.js +10 -6
- package/esm/Timeline/Timeline.js +8 -5
- package/esm/Tooltip/Tooltip.d.ts +2 -2
- package/esm/Tree/hooks/useFlattenTree.js +1 -3
- package/esm/Tree/hooks/useFocusTree.js +0 -1
- package/esm/Tree/hooks/useTreeSearch.js +0 -1
- package/esm/Uploader/UploadTrigger.js +15 -30
- package/esm/Uploader/utils/ajaxUpload.js +1 -1
- package/esm/internals/Disclosure/Disclosure.js +1 -0
- package/esm/internals/Menu/useMenu.js +51 -49
- package/esm/internals/Overlay/Overlay.d.ts +2 -2
- package/esm/internals/Overlay/OverlayTrigger.d.ts +2 -2
- package/esm/internals/Overlay/Position.d.ts +2 -2
- package/esm/internals/Overlay/positionUtils.d.ts +2 -2
- package/esm/internals/Picker/PickerToggle.d.ts +2 -2
- package/esm/internals/Picker/PickerToggleTrigger.d.ts +2 -2
- package/esm/internals/Picker/hooks/useFocusItemValue.js +1 -1
- package/esm/internals/Picker/hooks/usePickerClassName.d.ts +2 -2
- package/esm/internals/ScrollView/hooks/useScrollState.d.ts +1 -1
- package/esm/internals/Tree/TreeView.js +2 -1
- package/esm/internals/Tree/utils/getPathTowardsItem.js +1 -1
- package/esm/internals/Windowing/AutoSizer.js +1 -0
- package/esm/internals/Windowing/List.js +2 -1
- package/esm/internals/hooks/useClassNames.d.ts +1 -2
- package/esm/internals/hooks/useClassNames.js +0 -2
- package/esm/internals/hooks/usePortal.js +1 -1
- package/esm/internals/hooks/useToggleCaret.d.ts +2 -2
- package/esm/internals/hooks/useToggleCaret.js +1 -1
- package/esm/internals/hooks/useUpdateEffect.js +0 -1
- package/esm/internals/hooks/useWillUnmount.js +0 -2
- package/esm/internals/symbols.d.ts +1 -0
- package/esm/internals/symbols.js +2 -1
- package/esm/internals/types/colours.d.ts +10 -0
- package/esm/internals/types/colours.js +11 -0
- package/esm/internals/types/index.d.ts +6 -7
- package/esm/internals/types/index.js +6 -0
- package/esm/internals/types/placement.d.ts +5 -0
- package/esm/internals/types/placement.js +2 -0
- package/esm/internals/utils/BrowserDetection.d.ts +0 -2
- package/esm/internals/utils/BrowserDetection.js +1 -9
- package/esm/internals/utils/ReactChildren.js +0 -2
- package/esm/internals/utils/colours.d.ts +21 -0
- package/esm/internals/utils/colours.js +77 -0
- package/esm/internals/utils/css.d.ts +13 -1
- package/esm/internals/utils/css.js +40 -3
- package/esm/internals/utils/getDOMNode.js +1 -2
- package/esm/internals/utils/getSafeRegExpString.js +2 -1
- package/esm/internals/utils/index.d.ts +2 -2
- package/esm/internals/utils/index.js +3 -3
- package/esm/toaster/ToastContainer.d.ts +8 -8
- package/esm/toaster/ToastContainer.js +39 -37
- package/esm/toaster/render.d.ts +2 -0
- package/esm/toaster/render.js +21 -0
- package/esm/toaster/toaster.js +27 -18
- package/esm/useMediaQuery/useMediaQuery.js +1 -3
- package/esm/useToaster/useToaster.js +10 -5
- package/package.json +1 -1
- package/styles/color-modes/dark.less +1 -0
- package/styles/color-modes/high-contrast.less +1 -0
- package/styles/color-modes/light.less +1 -0
- package/styles/variables.less +1 -1
- package/cjs/internals/utils/render.d.ts +0 -7
- package/cjs/internals/utils/render.js +0 -26
- package/esm/internals/utils/render.d.ts +0 -7
- package/esm/internals/utils/render.js +0 -22
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ReactNode, CSSProperties, ElementType, InputHTMLAttributes, SyntheticEvent, FocusEventHandler } from 'react';
|
|
2
2
|
import { ReplaceProps } from './utils';
|
|
3
|
+
import { Placement } from './placement';
|
|
4
|
+
import { Colours } from './colours';
|
|
5
|
+
export * from './placement';
|
|
6
|
+
export * from './colours';
|
|
3
7
|
export interface StandardProps {
|
|
4
8
|
/** The prefix of the component CSS class */
|
|
5
9
|
classPrefix?: string;
|
|
@@ -20,7 +24,6 @@ export interface WithAsPropsWithoutChildren<As extends ElementType | string = El
|
|
|
20
24
|
}
|
|
21
25
|
export interface RsRefForwardingComponent<T extends ElementType, P = unknown, ExcludeChildren extends boolean = false> {
|
|
22
26
|
<As extends ElementType = T>(props: ReplaceProps<As, ExcludeChildren extends true ? WithAsPropsWithoutChildren<As> & P : WithAsProps<As> & P>, context?: any): any;
|
|
23
|
-
propTypes?: any;
|
|
24
27
|
contextTypes?: any;
|
|
25
28
|
displayName?: string;
|
|
26
29
|
}
|
|
@@ -66,7 +69,7 @@ export interface PickerBaseProps<L = any> extends WithAsProps, AnimationEventPro
|
|
|
66
69
|
/** Placeholder text */
|
|
67
70
|
placeholder?: ReactNode;
|
|
68
71
|
/** The placement of picker */
|
|
69
|
-
placement?:
|
|
72
|
+
placement?: Placement;
|
|
70
73
|
/** Prevent floating element overflow */
|
|
71
74
|
preventOverflow?: boolean;
|
|
72
75
|
/** Open the menu and control it */
|
|
@@ -169,12 +172,8 @@ export interface FormControlPickerProps<T = any, L = any, D = Record<string, any
|
|
|
169
172
|
export declare namespace TypeAttributes {
|
|
170
173
|
type Size = 'lg' | 'md' | 'sm' | 'xs';
|
|
171
174
|
type Status = 'success' | 'warning' | 'error' | 'info';
|
|
172
|
-
type Color =
|
|
175
|
+
type Color = `${Colours}`;
|
|
173
176
|
type Appearance = 'default' | 'primary' | 'link' | 'subtle' | 'ghost';
|
|
174
|
-
type Placement4 = 'top' | 'bottom' | 'right' | 'left';
|
|
175
|
-
type Placement8 = 'bottomStart' | 'bottomEnd' | 'topStart' | 'topEnd' | 'leftStart' | 'rightStart' | 'leftEnd' | 'rightEnd';
|
|
176
|
-
type PlacementAuto = 'auto' | 'autoVertical' | 'autoVerticalStart' | 'autoVerticalEnd' | 'autoHorizontal' | 'autoHorizontalStart' | 'autoHorizontalEnd';
|
|
177
|
-
type Placement = Placement4 | Placement8 | PlacementAuto;
|
|
178
177
|
type CheckTrigger = 'change' | 'blur' | 'none' | null;
|
|
179
178
|
type DisplayState = 'show' | 'hide' | 'hiding';
|
|
180
179
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
exports.__esModule = true;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
var _placement = require("./placement");
|
|
6
|
+
Object.keys(_placement).forEach(function (key) {
|
|
7
|
+
if (key === "default" || key === "__esModule") return;
|
|
8
|
+
if (key in exports && exports[key] === _placement[key]) return;
|
|
9
|
+
exports[key] = _placement[key];
|
|
10
|
+
});
|
|
11
|
+
var _colours = require("./colours");
|
|
12
|
+
Object.keys(_colours).forEach(function (key) {
|
|
13
|
+
if (key === "default" || key === "__esModule") return;
|
|
14
|
+
if (key in exports && exports[key] === _colours[key]) return;
|
|
15
|
+
exports[key] = _colours[key];
|
|
16
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type PlacementCardinal = 'top' | 'bottom' | 'right' | 'left';
|
|
2
|
+
export type PlacementCornersPolyfill = 'leftStart' | 'rightStart' | 'leftEnd' | 'rightEnd';
|
|
3
|
+
export type PlacementCorners = 'topStart' | 'topEnd' | 'bottomStart' | 'bottomEnd' | PlacementCornersPolyfill;
|
|
4
|
+
export type PlacementAuto = 'auto' | 'autoVertical' | 'autoVerticalStart' | 'autoVerticalEnd' | 'autoHorizontal' | 'autoHorizontalStart' | 'autoHorizontalEnd';
|
|
5
|
+
export type Placement = PlacementCardinal | PlacementCorners | PlacementAuto;
|
|
@@ -3,22 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.
|
|
6
|
+
exports.isIE = exports.isAndroid = void 0;
|
|
7
7
|
var _canUseDOM = _interopRequireDefault(require("dom-lib/canUseDOM"));
|
|
8
8
|
// from http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
|
|
9
9
|
|
|
10
10
|
// Internet Explorer 6-11
|
|
11
11
|
const isIE = () => _canUseDOM.default && /MSIE |Trident\/|Edge\//.test(window.navigator.userAgent);
|
|
12
12
|
exports.isIE = isIE;
|
|
13
|
-
const isIE11 = () => _canUseDOM.default && window.navigator.userAgent.indexOf('Trident') > -1 && window.navigator.userAgent.indexOf('rv:11.0') > -1;
|
|
14
|
-
exports.isIE11 = isIE11;
|
|
15
13
|
const isAndroid = () => _canUseDOM.default && /Android/i.test(navigator.userAgent);
|
|
16
|
-
exports.isAndroid = isAndroid;
|
|
17
|
-
const getChromeVersion = () => {
|
|
18
|
-
if (_canUseDOM.default) {
|
|
19
|
-
const match = window.navigator.userAgent.match(/Chrom(e|ium)\/([\d\.]+)\./);
|
|
20
|
-
return match ? parseFloat(match[2]) : false;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
};
|
|
24
|
-
exports.getChromeVersion = getChromeVersion;
|
|
14
|
+
exports.isAndroid = isAndroid;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Color } from '../types/colours';
|
|
2
|
+
export declare const isPresetColor: (color?: Color | React.CSSProperties['color']) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Convert short hex color to full hex color
|
|
5
|
+
* e.g. #fff -> #ffffff
|
|
6
|
+
*/
|
|
7
|
+
export declare const expandHexColor: (color: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate relative luminance of a color
|
|
10
|
+
* Using the formula from WCAG 2.0
|
|
11
|
+
*/
|
|
12
|
+
export declare const getLuminance: (color: string) => number;
|
|
13
|
+
/**
|
|
14
|
+
* Get contrasting text color (black or white) based on background color
|
|
15
|
+
*/
|
|
16
|
+
export declare const getContrastText: (bgColor: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Create CSS color variables for custom colors
|
|
19
|
+
* Returns background and optional text color variables
|
|
20
|
+
*/
|
|
21
|
+
export declare const createColorVariables: (color?: Color | React.CSSProperties['color'], bgFieldName?: string, textFieldName?: string) => React.CSSProperties | undefined;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.isPresetColor = exports.getLuminance = exports.getContrastText = exports.expandHexColor = exports.createColorVariables = void 0;
|
|
6
|
+
var _colours = require("../types/colours");
|
|
7
|
+
const isPresetColor = color => {
|
|
8
|
+
if (!color) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (color === 'default') {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return Object.values(_colours.Colours).includes(color);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Convert short hex color to full hex color
|
|
19
|
+
* e.g. #fff -> #ffffff
|
|
20
|
+
*/
|
|
21
|
+
exports.isPresetColor = isPresetColor;
|
|
22
|
+
const expandHexColor = color => {
|
|
23
|
+
const hex = color.toLowerCase().replace('#', '');
|
|
24
|
+
if (hex.length === 3) {
|
|
25
|
+
return `#${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
|
|
26
|
+
}
|
|
27
|
+
return `#${hex}`;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Calculate relative luminance of a color
|
|
32
|
+
* Using the formula from WCAG 2.0
|
|
33
|
+
*/
|
|
34
|
+
exports.expandHexColor = expandHexColor;
|
|
35
|
+
const getLuminance = color => {
|
|
36
|
+
// Convert hex to rgb
|
|
37
|
+
const fullHex = expandHexColor(color);
|
|
38
|
+
const hex = fullHex.replace('#', '');
|
|
39
|
+
const r = parseInt(hex.substring(0, 2), 16) / 255;
|
|
40
|
+
const g = parseInt(hex.substring(2, 4), 16) / 255;
|
|
41
|
+
const b = parseInt(hex.substring(4, 6), 16) / 255;
|
|
42
|
+
|
|
43
|
+
// Convert rgb to relative luminance
|
|
44
|
+
const rs = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
|
|
45
|
+
const gs = g <= 0.03928 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4);
|
|
46
|
+
const bs = b <= 0.03928 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4);
|
|
47
|
+
return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get contrasting text color (black or white) based on background color
|
|
52
|
+
*/
|
|
53
|
+
exports.getLuminance = getLuminance;
|
|
54
|
+
const getContrastText = bgColor => {
|
|
55
|
+
// For non-hex colors, return default dark text
|
|
56
|
+
if (!bgColor.startsWith('#')) {
|
|
57
|
+
return 'var(--rs-text-primary)';
|
|
58
|
+
}
|
|
59
|
+
const luminance = getLuminance(bgColor);
|
|
60
|
+
return luminance > 0.5 ? '#000000' : '#ffffff';
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create CSS color variables for custom colors
|
|
65
|
+
* Returns background and optional text color variables
|
|
66
|
+
*/
|
|
67
|
+
exports.getContrastText = getContrastText;
|
|
68
|
+
const createColorVariables = function (color, bgFieldName, textFieldName) {
|
|
69
|
+
if (bgFieldName === void 0) {
|
|
70
|
+
bgFieldName = '--rs-color-bg';
|
|
71
|
+
}
|
|
72
|
+
if (color && !isPresetColor(color)) {
|
|
73
|
+
const colorStr = color.toString();
|
|
74
|
+
// Only convert to hex if it's a hex color
|
|
75
|
+
const bgColor = colorStr.startsWith('#') ? expandHexColor(colorStr) : colorStr;
|
|
76
|
+
const styles = {
|
|
77
|
+
[bgFieldName]: bgColor
|
|
78
|
+
};
|
|
79
|
+
if (textFieldName) {
|
|
80
|
+
styles[textFieldName] = getContrastText(bgColor);
|
|
81
|
+
}
|
|
82
|
+
return styles;
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
};
|
|
86
|
+
exports.createColorVariables = createColorVariables;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
/**
|
|
2
3
|
* Processes and returns a value suitable for CSS (with a unit).
|
|
3
4
|
*/
|
|
4
|
-
export declare function getCssValue(value?: number | string, unit?: string): string
|
|
5
|
+
export declare function getCssValue(value?: number | string | null, unit?: string): string;
|
|
6
|
+
type CSSVariables = Partial<Record<`--${string}`, string>>;
|
|
7
|
+
type StyleProperties = React.CSSProperties & CSSVariables;
|
|
8
|
+
/**
|
|
9
|
+
* Merge multiple style objects, filtering out undefined values
|
|
10
|
+
*/
|
|
11
|
+
export declare function mergeStyles(...styles: (React.CSSProperties | undefined | null)[]): StyleProperties;
|
|
12
|
+
/**
|
|
13
|
+
* Create CSS variables for offset positioning
|
|
14
|
+
*/
|
|
15
|
+
export declare function createOffsetStyles(offset?: [number | string, number | string], prefix?: string): React.CSSProperties | undefined;
|
|
16
|
+
export {};
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
+
exports.createOffsetStyles = createOffsetStyles;
|
|
5
6
|
exports.getCssValue = getCssValue;
|
|
7
|
+
exports.mergeStyles = mergeStyles;
|
|
6
8
|
/**
|
|
7
9
|
* Processes and returns a value suitable for CSS (with a unit).
|
|
8
10
|
*/
|
|
@@ -10,13 +12,50 @@ function getCssValue(value, unit) {
|
|
|
10
12
|
if (unit === void 0) {
|
|
11
13
|
unit = 'px';
|
|
12
14
|
}
|
|
15
|
+
if (value === undefined || value === null || value === '') {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// If the value is 0, return it as a string without unit
|
|
20
|
+
if (value === 0) {
|
|
21
|
+
return '0';
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
// If the value is a number, append the default unit (defaults to 'px')
|
|
14
25
|
if (typeof value === 'number') {
|
|
15
26
|
return `${value}${unit}`;
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
// Return string values as is
|
|
30
|
+
return value.toString();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Merge multiple style objects, filtering out undefined values
|
|
34
|
+
*/
|
|
35
|
+
function mergeStyles() {
|
|
36
|
+
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
37
|
+
styles[_key] = arguments[_key];
|
|
38
|
+
}
|
|
39
|
+
return styles.filter(Boolean).reduce((acc, style) => {
|
|
40
|
+
if (!style) return acc;
|
|
41
|
+
return {
|
|
42
|
+
...acc,
|
|
43
|
+
...style
|
|
44
|
+
};
|
|
45
|
+
}, {});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create CSS variables for offset positioning
|
|
50
|
+
*/
|
|
51
|
+
function createOffsetStyles(offset, prefix) {
|
|
52
|
+
if (prefix === void 0) {
|
|
53
|
+
prefix = '--rs-offset';
|
|
21
54
|
}
|
|
55
|
+
if (!offset) return undefined;
|
|
56
|
+
const [x, y] = offset;
|
|
57
|
+
return {
|
|
58
|
+
[`${prefix}-x`]: getCssValue(x),
|
|
59
|
+
[`${prefix}-y`]: getCssValue(y)
|
|
60
|
+
};
|
|
22
61
|
}
|
|
@@ -6,10 +6,11 @@ exports.__esModule = true;
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.getDOMNode = getDOMNode;
|
|
8
8
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
|
+
/* eslint-disable react/no-find-dom-node */
|
|
10
|
+
|
|
9
11
|
function safeFindDOMNode(componentOrElement) {
|
|
10
12
|
if (componentOrElement && 'setState' in componentOrElement) {
|
|
11
13
|
var _ReactDOM$findDOMNode;
|
|
12
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
13
14
|
return (_ReactDOM$findDOMNode = _reactDom.default.findDOMNode) === null || _ReactDOM$findDOMNode === void 0 ? void 0 : _ReactDOM$findDOMNode.call(_reactDom.default, componentOrElement);
|
|
14
15
|
}
|
|
15
16
|
return componentOrElement !== null && componentOrElement !== void 0 ? componentOrElement : null;
|
|
@@ -27,7 +28,6 @@ function getDOMNode(elementOrRef) {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// If you can't get the native HTML element, you can only get it through findDOMNode.
|
|
30
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
31
31
|
return safeFindDOMNode(element);
|
|
32
32
|
}
|
|
33
33
|
var _default = exports.default = getDOMNode;
|
|
@@ -7,5 +7,6 @@ exports.getSafeRegExpString = getSafeRegExpString;
|
|
|
7
7
|
* @description escape Regular_Expressions special_characters '^$.|*+?{\\[()'
|
|
8
8
|
*/
|
|
9
9
|
function getSafeRegExpString(str) {
|
|
10
|
-
|
|
10
|
+
const specialChars = '\\^$.|?*+()[]{}';
|
|
11
|
+
return str.replace(new RegExp(`([${specialChars}])`, 'g'), '\\$1');
|
|
11
12
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './BrowserDetection';
|
|
2
2
|
export * from './htmlPropsUtils';
|
|
3
|
+
export * from './css';
|
|
4
|
+
export * from './colours';
|
|
3
5
|
export { stringifyReactNode, reactToString } from './stringifyReactNode';
|
|
4
6
|
export { getSafeRegExpString } from './getSafeRegExpString';
|
|
5
7
|
export { getDOMNode } from './getDOMNode';
|
|
@@ -13,7 +15,6 @@ export { placementPolyfill } from './placementPolyfill';
|
|
|
13
15
|
export { mergeRefs } from './mergeRefs';
|
|
14
16
|
export { shallowEqual, shallowEqualArray } from './shallowEqual';
|
|
15
17
|
export { composeFunctions } from './composeFunctions';
|
|
16
|
-
export { render } from './render';
|
|
17
18
|
export { safeSetSelection } from './safeSetSelection';
|
|
18
19
|
export { getStringLength } from './getStringLength';
|
|
19
20
|
export { getDataGroupBy } from './getDataGroupBy';
|
|
@@ -24,4 +25,3 @@ export type { ComponentProps } from './createComponent';
|
|
|
24
25
|
export { attachParent } from './attachParent';
|
|
25
26
|
export { isFocusEntering, isFocusLeaving } from './events';
|
|
26
27
|
export { isFocusableElement } from './dom';
|
|
27
|
-
export { getCssValue } from './css';
|
|
@@ -20,7 +20,6 @@ var _exportNames = {
|
|
|
20
20
|
shallowEqual: true,
|
|
21
21
|
shallowEqualArray: true,
|
|
22
22
|
composeFunctions: true,
|
|
23
|
-
render: true,
|
|
24
23
|
safeSetSelection: true,
|
|
25
24
|
getStringLength: true,
|
|
26
25
|
getDataGroupBy: true,
|
|
@@ -30,10 +29,9 @@ var _exportNames = {
|
|
|
30
29
|
attachParent: true,
|
|
31
30
|
isFocusEntering: true,
|
|
32
31
|
isFocusLeaving: true,
|
|
33
|
-
isFocusableElement: true
|
|
34
|
-
getCssValue: true
|
|
32
|
+
isFocusableElement: true
|
|
35
33
|
};
|
|
36
|
-
exports.warnOnce = exports.tplTransform = exports.stringifyReactNode = exports.shallowEqualArray = exports.shallowEqual = exports.safeSetSelection = exports.
|
|
34
|
+
exports.warnOnce = exports.tplTransform = exports.stringifyReactNode = exports.shallowEqualArray = exports.shallowEqual = exports.safeSetSelection = exports.reactToString = exports.prefix = exports.placementPolyfill = exports.mergeRefs = exports.isOneOf = exports.isFocusableElement = exports.isFocusLeaving = exports.isFocusEntering = exports.guid = exports.getStringLength = exports.getSafeRegExpString = exports.getDataGroupBy = exports.getDOMNode = exports.getClassNamePrefix = exports.deprecateComponent = exports.defaultClassPrefix = exports.createComponent = exports.createChainedFunction = exports.composeFunctions = exports.attachParent = exports.ReactChildren = void 0;
|
|
37
35
|
var _BrowserDetection = require("./BrowserDetection");
|
|
38
36
|
Object.keys(_BrowserDetection).forEach(function (key) {
|
|
39
37
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -48,6 +46,20 @@ Object.keys(_htmlPropsUtils).forEach(function (key) {
|
|
|
48
46
|
if (key in exports && exports[key] === _htmlPropsUtils[key]) return;
|
|
49
47
|
exports[key] = _htmlPropsUtils[key];
|
|
50
48
|
});
|
|
49
|
+
var _css = require("./css");
|
|
50
|
+
Object.keys(_css).forEach(function (key) {
|
|
51
|
+
if (key === "default" || key === "__esModule") return;
|
|
52
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
53
|
+
if (key in exports && exports[key] === _css[key]) return;
|
|
54
|
+
exports[key] = _css[key];
|
|
55
|
+
});
|
|
56
|
+
var _colours = require("./colours");
|
|
57
|
+
Object.keys(_colours).forEach(function (key) {
|
|
58
|
+
if (key === "default" || key === "__esModule") return;
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
60
|
+
if (key in exports && exports[key] === _colours[key]) return;
|
|
61
|
+
exports[key] = _colours[key];
|
|
62
|
+
});
|
|
51
63
|
var _stringifyReactNode = require("./stringifyReactNode");
|
|
52
64
|
exports.stringifyReactNode = _stringifyReactNode.stringifyReactNode;
|
|
53
65
|
exports.reactToString = _stringifyReactNode.reactToString;
|
|
@@ -78,8 +90,6 @@ exports.shallowEqual = _shallowEqual.shallowEqual;
|
|
|
78
90
|
exports.shallowEqualArray = _shallowEqual.shallowEqualArray;
|
|
79
91
|
var _composeFunctions = require("./composeFunctions");
|
|
80
92
|
exports.composeFunctions = _composeFunctions.composeFunctions;
|
|
81
|
-
var _render = require("./render");
|
|
82
|
-
exports.render = _render.render;
|
|
83
93
|
var _safeSetSelection = require("./safeSetSelection");
|
|
84
94
|
exports.safeSetSelection = _safeSetSelection.safeSetSelection;
|
|
85
95
|
var _getStringLength = require("./getStringLength");
|
|
@@ -98,6 +108,4 @@ var _events = require("./events");
|
|
|
98
108
|
exports.isFocusEntering = _events.isFocusEntering;
|
|
99
109
|
exports.isFocusLeaving = _events.isFocusLeaving;
|
|
100
110
|
var _dom = require("./dom");
|
|
101
|
-
exports.isFocusableElement = _dom.isFocusableElement;
|
|
102
|
-
var _css = require("./css");
|
|
103
|
-
exports.getCssValue = _css.getCssValue;
|
|
111
|
+
exports.isFocusableElement = _dom.isFocusableElement;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
|
|
3
|
+
export declare const defaultToasterContainer: () => HTMLElement | null;
|
|
3
4
|
export type PlacementType = 'topCenter' | 'bottomCenter' | 'topStart' | 'topEnd' | 'bottomStart' | 'bottomEnd';
|
|
4
5
|
export declare const toastPlacements: PlacementType[];
|
|
5
6
|
export interface ToastContainerProps extends WithAsProps {
|
|
@@ -12,7 +13,7 @@ export interface ToastContainerProps extends WithAsProps {
|
|
|
12
13
|
/**
|
|
13
14
|
* Set the message to appear in the specified container
|
|
14
15
|
*/
|
|
15
|
-
container?: HTMLElement | (() => HTMLElement);
|
|
16
|
+
container?: HTMLElement | (() => HTMLElement) | null;
|
|
16
17
|
/**
|
|
17
18
|
* The number of milliseconds to wait before automatically closing a message.
|
|
18
19
|
*/
|
|
@@ -21,18 +22,13 @@ export interface ToastContainerProps extends WithAsProps {
|
|
|
21
22
|
* Reset the hide timer if the mouse moves over the message.
|
|
22
23
|
*/
|
|
23
24
|
mouseReset?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Callback fired when the component mounts
|
|
26
|
-
*/
|
|
27
|
-
callback?: (ref: React.RefObject<ToastContainerInstance>) => void;
|
|
28
25
|
}
|
|
29
26
|
interface PushOptions {
|
|
30
27
|
duration?: number;
|
|
31
28
|
mouseReset?: boolean;
|
|
32
|
-
container?: HTMLElement | (() => HTMLElement);
|
|
29
|
+
container?: HTMLElement | (() => HTMLElement) | null;
|
|
33
30
|
}
|
|
34
31
|
export interface ToastContainerInstance {
|
|
35
|
-
root: HTMLElement;
|
|
36
32
|
push: (message: React.ReactNode, options?: PushOptions) => string;
|
|
37
33
|
remove: (key: string) => void;
|
|
38
34
|
clear: () => void;
|
|
@@ -41,8 +37,12 @@ export interface ToastContainerInstance {
|
|
|
41
37
|
export interface NodeProps extends WithAsProps {
|
|
42
38
|
onClose?: (event?: React.MouseEvent<HTMLDivElement>) => void;
|
|
43
39
|
}
|
|
40
|
+
export type GetInstancePropsType = Omit<ToastContainerProps, 'container' | 'placement'> & {
|
|
41
|
+
container: HTMLElement | null;
|
|
42
|
+
placement: PlacementType;
|
|
43
|
+
};
|
|
44
44
|
interface ToastContainerComponent extends RsRefForwardingComponent<'div', ToastContainerProps> {
|
|
45
|
-
getInstance: (props:
|
|
45
|
+
getInstance: (props: GetInstancePropsType) => Promise<[React.RefObject<ToastContainerInstance>, string]>;
|
|
46
46
|
}
|
|
47
47
|
declare const ToastContainer: ToastContainerComponent;
|
|
48
48
|
export default ToastContainer;
|
|
@@ -3,17 +3,22 @@
|
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.toastPlacements = exports.default = void 0;
|
|
6
|
+
exports.toastPlacements = exports.defaultToasterContainer = exports.default = void 0;
|
|
7
7
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactDom = require("react-dom");
|
|
10
9
|
var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
|
|
11
10
|
var _Transition = _interopRequireDefault(require("../Animation/Transition"));
|
|
11
|
+
var _ToastContext = _interopRequireDefault(require("./ToastContext"));
|
|
12
|
+
var _canUseDOM = _interopRequireDefault(require("dom-lib/canUseDOM"));
|
|
12
13
|
var _hooks = require("../internals/hooks");
|
|
13
14
|
var _utils = require("../internals/utils");
|
|
14
|
-
var
|
|
15
|
+
var _render = require("./render");
|
|
15
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
const defaultToasterContainer = () => {
|
|
19
|
+
return _canUseDOM.default ? document.body : null;
|
|
20
|
+
};
|
|
21
|
+
exports.defaultToasterContainer = defaultToasterContainer;
|
|
17
22
|
const toastPlacements = exports.toastPlacements = ['topCenter', 'bottomCenter', 'topStart', 'topEnd', 'bottomStart', 'bottomEnd'];
|
|
18
23
|
const useMessages = () => {
|
|
19
24
|
const [messages, setMessages] = (0, _react.useState)([]);
|
|
@@ -75,13 +80,11 @@ const useMessages = () => {
|
|
|
75
80
|
};
|
|
76
81
|
};
|
|
77
82
|
const ToastContainer = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
78
|
-
const rootRef = (0, _react.useRef)();
|
|
79
83
|
const {
|
|
80
84
|
as: Component = 'div',
|
|
81
85
|
className,
|
|
82
86
|
classPrefix = 'toast-container',
|
|
83
87
|
placement = 'topCenter',
|
|
84
|
-
callback,
|
|
85
88
|
...rest
|
|
86
89
|
} = props;
|
|
87
90
|
const {
|
|
@@ -97,7 +100,6 @@ const ToastContainer = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
97
100
|
messages
|
|
98
101
|
} = useMessages();
|
|
99
102
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
100
|
-
root: rootRef.current,
|
|
101
103
|
push,
|
|
102
104
|
clear,
|
|
103
105
|
remove
|
|
@@ -106,10 +108,16 @@ const ToastContainer = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
106
108
|
const {
|
|
107
109
|
mouseReset,
|
|
108
110
|
duration,
|
|
109
|
-
node
|
|
110
|
-
container
|
|
111
|
+
node
|
|
111
112
|
} = item;
|
|
112
|
-
|
|
113
|
+
return /*#__PURE__*/_react.default.createElement(_ToastContext.default.Provider, {
|
|
114
|
+
value: {
|
|
115
|
+
usedToaster: true,
|
|
116
|
+
mouseReset,
|
|
117
|
+
duration
|
|
118
|
+
},
|
|
119
|
+
key: item.key
|
|
120
|
+
}, /*#__PURE__*/_react.default.createElement(_Transition.default, {
|
|
113
121
|
in: item.visible,
|
|
114
122
|
exitedClassName: rootPrefix('toast-fade-exited'),
|
|
115
123
|
exitingClassName: rootPrefix('toast-fade-exiting'),
|
|
@@ -129,42 +137,37 @@ const ToastContainer = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
129
137
|
onClose: (0, _utils.createChainedFunction)((_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.onClose, () => remove(item.key)),
|
|
130
138
|
className: merge(rootPrefix('toast'), (_node$props2 = node.props) === null || _node$props2 === void 0 ? void 0 : _node$props2.className, transitionClassName)
|
|
131
139
|
});
|
|
132
|
-
});
|
|
133
|
-
return /*#__PURE__*/_react.default.createElement(_ToastContext.default.Provider, {
|
|
134
|
-
value: {
|
|
135
|
-
usedToaster: true,
|
|
136
|
-
mouseReset,
|
|
137
|
-
duration
|
|
138
|
-
},
|
|
139
|
-
key: item.key
|
|
140
|
-
}, container ? /*#__PURE__*/(0, _reactDom.createPortal)(toastWithTransition, typeof container === 'function' ? container() : container) : toastWithTransition);
|
|
140
|
+
}));
|
|
141
141
|
});
|
|
142
142
|
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
|
|
143
|
-
ref: selfRef => {
|
|
144
|
-
rootRef.current = selfRef;
|
|
145
|
-
callback === null || callback === void 0 || callback(selfRef);
|
|
146
|
-
},
|
|
147
143
|
className: classes
|
|
148
144
|
}), elements);
|
|
149
145
|
});
|
|
150
|
-
ToastContainer.getInstance = props => {
|
|
146
|
+
ToastContainer.getInstance = async props => {
|
|
151
147
|
const {
|
|
152
148
|
container,
|
|
153
|
-
...
|
|
149
|
+
...toastProps
|
|
154
150
|
} = props;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
};
|
|
161
|
-
const {
|
|
162
|
-
unmount
|
|
163
|
-
} = (0, _utils.render)(/*#__PURE__*/_react.default.createElement(ToastContainer, (0, _extends2.default)({}, rest, {
|
|
164
|
-
ref: containerRef,
|
|
165
|
-
callback: renderCallback
|
|
166
|
-
})), containerElement);
|
|
151
|
+
|
|
152
|
+
// Promise to wait for containerRef to be assigned
|
|
153
|
+
let resolveContainerRef = null;
|
|
154
|
+
const containerRefReady = new Promise(resolve => {
|
|
155
|
+
resolveContainerRef = resolve;
|
|
167
156
|
});
|
|
157
|
+
|
|
158
|
+
// Create a React ref for the ToastContainer instance
|
|
159
|
+
const toastContainerRef = /*#__PURE__*/_react.default.createRef();
|
|
160
|
+
|
|
161
|
+
// Render the ToastContainer component into the specified container
|
|
162
|
+
const containerId = (0, _render.render)(/*#__PURE__*/_react.default.createElement(ToastContainer, (0, _extends2.default)({}, toastProps, {
|
|
163
|
+
ref: ref => {
|
|
164
|
+
var _resolveContainerRef;
|
|
165
|
+
toastContainerRef.current = ref;
|
|
166
|
+
(_resolveContainerRef = resolveContainerRef) === null || _resolveContainerRef === void 0 || _resolveContainerRef();
|
|
167
|
+
}
|
|
168
|
+
})), container);
|
|
169
|
+
await containerRefReady;
|
|
170
|
+
return [toastContainerRef, containerId];
|
|
168
171
|
};
|
|
169
172
|
ToastContainer.displayName = 'ToastContainer';
|
|
170
173
|
var _default = exports.default = ToastContainer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.render = render;
|
|
6
|
+
var _client = require("react-dom/client");
|
|
7
|
+
var _utils = require("../internals/utils");
|
|
8
|
+
var _symbols = require("../internals/symbols");
|
|
9
|
+
function render(element, container) {
|
|
10
|
+
const mountElement = document.createElement('div');
|
|
11
|
+
mountElement.className = 'rs-toaster-mount-element';
|
|
12
|
+
const containerElement = container;
|
|
13
|
+
|
|
14
|
+
// Add the detached element to the root
|
|
15
|
+
containerElement.appendChild(mountElement);
|
|
16
|
+
if (!containerElement[_symbols.RSUITE_TOASTER_ID]) {
|
|
17
|
+
// Attach the containerId to the containerElement
|
|
18
|
+
containerElement[_symbols.RSUITE_TOASTER_ID] = (0, _utils.guid)();
|
|
19
|
+
}
|
|
20
|
+
const root = (0, _client.createRoot)(mountElement, {
|
|
21
|
+
identifierPrefix: 'rs-root-'
|
|
22
|
+
});
|
|
23
|
+
root.render(element);
|
|
24
|
+
return containerElement[_symbols.RSUITE_TOASTER_ID];
|
|
25
|
+
}
|