rsuite 5.83.2 → 5.83.4
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/CHANGELOG.md +20 -0
- package/FormGroup/styles/index.css +3 -0
- package/FormGroup/styles/index.less +1 -0
- package/Table/styles/index.css +21 -0
- package/Table/styles/index.less +11 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +4 -2
- package/cjs/toaster/ToastContainer.d.ts +4 -1
- package/cjs/toaster/ToastContainer.js +4 -4
- package/cjs/toaster/render.d.ts +2 -1
- package/cjs/toaster/render.js +17 -7
- package/cjs/toaster/toaster.d.ts +3 -1
- package/cjs/toaster/toaster.js +8 -5
- package/cjs/useCreateRoot/index.d.ts +4 -0
- package/cjs/useCreateRoot/index.js +8 -0
- package/cjs/useCreateRoot/useCreateRoot.d.ts +10 -0
- package/cjs/useCreateRoot/useCreateRoot.js +13 -0
- package/cjs/useToaster/useToaster.js +4 -2
- package/dist/rsuite-no-reset-rtl.css +24 -0
- 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 +24 -0
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +24 -0
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +24 -0
- package/dist/rsuite.js +33 -11
- 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/index.d.ts +2 -0
- package/esm/index.js +1 -1
- package/esm/toaster/ToastContainer.d.ts +4 -1
- package/esm/toaster/ToastContainer.js +4 -4
- package/esm/toaster/render.d.ts +2 -1
- package/esm/toaster/render.js +17 -7
- package/esm/toaster/toaster.d.ts +3 -1
- package/esm/toaster/toaster.js +8 -5
- package/esm/useCreateRoot/index.d.ts +4 -0
- package/esm/useCreateRoot/index.js +4 -0
- package/esm/useCreateRoot/useCreateRoot.d.ts +10 -0
- package/esm/useCreateRoot/useCreateRoot.js +8 -0
- package/esm/useToaster/useToaster.js +5 -2
- package/package.json +1 -1
- package/useCreateRoot/package.json +7 -0
package/esm/index.d.ts
CHANGED
|
@@ -195,6 +195,8 @@ export type { Locale, CalendarLocale, PlaintextLocale, PaginationLocale, TableLo
|
|
|
195
195
|
export type { PickerHandle } from './internals/Picker';
|
|
196
196
|
export { default as useMediaQuery } from './useMediaQuery';
|
|
197
197
|
export { default as useBreakpointValue } from './useBreakpointValue';
|
|
198
|
+
export { default as CreateRootContextProvider } from './useCreateRoot';
|
|
199
|
+
export type { ReactRoot, CreateRootFn } from './useCreateRoot';
|
|
198
200
|
export { default as VisuallyHidden } from './VisuallyHidden';
|
|
199
201
|
export type { VisuallyHiddenProps } from './VisuallyHidden';
|
|
200
202
|
export { default as Tabs } from './Tabs';
|
package/esm/index.js
CHANGED
|
@@ -123,7 +123,7 @@ export { default as CustomProvider } from "./CustomProvider/index.js";
|
|
|
123
123
|
|
|
124
124
|
export { default as useMediaQuery } from "./useMediaQuery/index.js";
|
|
125
125
|
export { default as useBreakpointValue } from "./useBreakpointValue/index.js";
|
|
126
|
-
|
|
126
|
+
export { default as CreateRootContextProvider } from "./useCreateRoot/index.js";
|
|
127
127
|
// Disclosure
|
|
128
128
|
// --------------------------------------------------------
|
|
129
129
|
export { default as VisuallyHidden } from "./VisuallyHidden/index.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
|
|
3
|
+
import { CreateRootFn } from '../useCreateRoot';
|
|
3
4
|
export declare const defaultToasterContainer: () => HTMLElement | null;
|
|
4
5
|
export type PlacementType = 'topCenter' | 'bottomCenter' | 'topStart' | 'topEnd' | 'bottomStart' | 'bottomEnd';
|
|
5
6
|
export declare const toastPlacements: PlacementType[];
|
|
@@ -42,7 +43,9 @@ export type GetInstancePropsType = Omit<ToastContainerProps, 'container' | 'plac
|
|
|
42
43
|
placement: PlacementType;
|
|
43
44
|
};
|
|
44
45
|
interface ToastContainerComponent extends RsRefForwardingComponent<'div', ToastContainerProps> {
|
|
45
|
-
getInstance: (props: GetInstancePropsType
|
|
46
|
+
getInstance: (props: GetInstancePropsType & {
|
|
47
|
+
userCreateRoot?: CreateRootFn;
|
|
48
|
+
}) => Promise<[React.RefObject<ToastContainerInstance>, string]>;
|
|
46
49
|
}
|
|
47
50
|
declare const ToastContainer: ToastContainerComponent;
|
|
48
51
|
export default ToastContainer;
|
|
@@ -4,7 +4,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
var _excluded = ["as", "className", "classPrefix", "placement"],
|
|
6
6
|
_excluded2 = ["className"],
|
|
7
|
-
_excluded3 = ["container"];
|
|
7
|
+
_excluded3 = ["container", "userCreateRoot"];
|
|
8
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
9
|
import React, { useState, useImperativeHandle, useCallback } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
@@ -153,11 +153,11 @@ var ToastContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
153
153
|
});
|
|
154
154
|
ToastContainer.getInstance = /*#__PURE__*/function () {
|
|
155
155
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(props) {
|
|
156
|
-
var container, rest, getRefResolve, getRefPromise, containerRef, containerId;
|
|
156
|
+
var container, userCreateRoot, rest, getRefResolve, getRefPromise, containerRef, containerId;
|
|
157
157
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
158
158
|
while (1) switch (_context.prev = _context.next) {
|
|
159
159
|
case 0:
|
|
160
|
-
container = props.container, rest = _objectWithoutPropertiesLoose(props, _excluded3);
|
|
160
|
+
container = props.container, userCreateRoot = props.userCreateRoot, rest = _objectWithoutPropertiesLoose(props, _excluded3);
|
|
161
161
|
getRefResolve = null;
|
|
162
162
|
getRefPromise = new Promise(function (res) {
|
|
163
163
|
getRefResolve = res;
|
|
@@ -168,7 +168,7 @@ ToastContainer.getInstance = /*#__PURE__*/function () {
|
|
|
168
168
|
containerRef.current = _ref3;
|
|
169
169
|
getRefResolve && getRefResolve();
|
|
170
170
|
}
|
|
171
|
-
})), container);
|
|
171
|
+
})), container, userCreateRoot);
|
|
172
172
|
_context.next = 7;
|
|
173
173
|
return getRefPromise;
|
|
174
174
|
case 7:
|
package/esm/toaster/render.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { CreateRootFn } from '../useCreateRoot';
|
|
2
3
|
export declare const toasterKeyOfContainerElement = "toasterId";
|
|
3
|
-
export declare function render(element: React.ReactElement<any>, container: HTMLElement | null): string;
|
|
4
|
+
export declare function render(element: React.ReactElement<any>, container: HTMLElement | null, userCreateRoot?: CreateRootFn): string;
|
package/esm/toaster/render.js
CHANGED
|
@@ -5,7 +5,22 @@ import * as ReactDOM from 'react-dom';
|
|
|
5
5
|
var majorVersion = parseInt(React.version);
|
|
6
6
|
var SuperposedReactDOM = ReactDOM;
|
|
7
7
|
export var toasterKeyOfContainerElement = 'toasterId';
|
|
8
|
-
|
|
8
|
+
function getCreateRoot(userCreateRoot) {
|
|
9
|
+
if (userCreateRoot) return userCreateRoot;
|
|
10
|
+
if (majorVersion === 19) {
|
|
11
|
+
console.info('Use CreateRootContextProvider to pass createRoot function from react-dom/client');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// just to disable the rspack warning
|
|
15
|
+
var secretInternals = '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED';
|
|
16
|
+
/**
|
|
17
|
+
* ignore react 18 warnings
|
|
18
|
+
* Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".
|
|
19
|
+
*/
|
|
20
|
+
ReactDOM[secretInternals].usingClientEntryPoint = true;
|
|
21
|
+
return SuperposedReactDOM.createRoot;
|
|
22
|
+
}
|
|
23
|
+
export function render(element, container, userCreateRoot) {
|
|
9
24
|
var mountElement = document.createElement('div');
|
|
10
25
|
mountElement.className = 'rs-toaster-mount-element';
|
|
11
26
|
var containerElement = container;
|
|
@@ -18,12 +33,7 @@ export function render(element, container) {
|
|
|
18
33
|
containerElement[toasterKeyOfContainerElement] = newContainerId;
|
|
19
34
|
}
|
|
20
35
|
if (majorVersion >= 18) {
|
|
21
|
-
|
|
22
|
-
* ignore react 18 warnings
|
|
23
|
-
* Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".
|
|
24
|
-
*/
|
|
25
|
-
ReactDOM['__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED'].usingClientEntryPoint = true;
|
|
26
|
-
var createRoot = SuperposedReactDOM.createRoot;
|
|
36
|
+
var createRoot = getCreateRoot(userCreateRoot);
|
|
27
37
|
var root = createRoot(mountElement, {
|
|
28
38
|
identifierPrefix: 'rs-root-'
|
|
29
39
|
});
|
package/esm/toaster/toaster.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ToastContainerProps } from './ToastContainer';
|
|
3
|
+
import type { CreateRootFn } from '../useCreateRoot';
|
|
3
4
|
export interface Toaster {
|
|
4
5
|
/**
|
|
5
6
|
* Push a toast message.
|
|
@@ -7,9 +8,10 @@ export interface Toaster {
|
|
|
7
8
|
* eg: `<Message type="success" description="Success" />` or `<Notification type="success" closable>Success</Notification>`
|
|
8
9
|
* @param options The options of the toast message. (optional)
|
|
9
10
|
* eg: `{ placement: 'topCenter', duration: 5000 }`
|
|
11
|
+
* @param userCreateRoot React DOM's createRoot function
|
|
10
12
|
* @returns The key of the toast message.
|
|
11
13
|
*/
|
|
12
|
-
push(message: React.ReactNode, options?: ToastContainerProps): string | undefined | Promise<string | undefined>;
|
|
14
|
+
push(message: React.ReactNode, options?: ToastContainerProps, userCreateRoot?: CreateRootFn): string | undefined | Promise<string | undefined>;
|
|
13
15
|
/**
|
|
14
16
|
* Remove a toast message.
|
|
15
17
|
* @param key The key of the toast message.
|
package/esm/toaster/toaster.js
CHANGED
|
@@ -12,8 +12,9 @@ var containers = new Map();
|
|
|
12
12
|
* Create a container instance.
|
|
13
13
|
* @param placement
|
|
14
14
|
* @param props
|
|
15
|
+
* @param userCreateRoot
|
|
15
16
|
*/
|
|
16
|
-
function createContainer(_x, _x2) {
|
|
17
|
+
function createContainer(_x, _x2, _x3) {
|
|
17
18
|
return _createContainer.apply(this, arguments);
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -22,13 +23,15 @@ function createContainer(_x, _x2) {
|
|
|
22
23
|
* @param placement
|
|
23
24
|
*/
|
|
24
25
|
function _createContainer() {
|
|
25
|
-
_createContainer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(placement, props) {
|
|
26
|
+
_createContainer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(placement, props, userCreateRoot) {
|
|
26
27
|
var _yield$ToastContainer, container, containerId;
|
|
27
28
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
29
|
while (1) switch (_context.prev = _context.next) {
|
|
29
30
|
case 0:
|
|
30
31
|
_context.next = 2;
|
|
31
|
-
return ToastContainer.getInstance(props
|
|
32
|
+
return ToastContainer.getInstance(_extends({}, props, {
|
|
33
|
+
userCreateRoot: userCreateRoot
|
|
34
|
+
}));
|
|
32
35
|
case 2:
|
|
33
36
|
_yield$ToastContainer = _context.sent;
|
|
34
37
|
container = _yield$ToastContainer[0];
|
|
@@ -49,7 +52,7 @@ function getContainer(containerId, placement) {
|
|
|
49
52
|
var _toaster = function toaster(message) {
|
|
50
53
|
return _toaster.push(message);
|
|
51
54
|
};
|
|
52
|
-
_toaster.push = function (message, options) {
|
|
55
|
+
_toaster.push = function (message, options, userCreateRoot) {
|
|
53
56
|
if (options === void 0) {
|
|
54
57
|
options = {};
|
|
55
58
|
}
|
|
@@ -72,7 +75,7 @@ _toaster.push = function (message, options) {
|
|
|
72
75
|
container: containerElement,
|
|
73
76
|
placement: placement
|
|
74
77
|
});
|
|
75
|
-
return createContainer(placement, newOptions).then(function (ref) {
|
|
78
|
+
return createContainer(placement, newOptions, userCreateRoot).then(function (ref) {
|
|
76
79
|
var _ref$current;
|
|
77
80
|
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.push(message, restOptions);
|
|
78
81
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Container } from 'react-dom';
|
|
3
|
+
export interface ReactRoot {
|
|
4
|
+
render(children: ReactNode): void;
|
|
5
|
+
unmount(): void;
|
|
6
|
+
}
|
|
7
|
+
export type CreateRootFn = (container: Container, options?: any) => ReactRoot;
|
|
8
|
+
export declare function useCreateRoot(): CreateRootFn | undefined;
|
|
9
|
+
export declare const CreateRootContextProvider: import("react").Provider<CreateRootFn | null>;
|
|
10
|
+
export default CreateRootContextProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
var CreateRootContext = /*#__PURE__*/createContext(null);
|
|
4
|
+
export function useCreateRoot() {
|
|
5
|
+
return useContext(CreateRootContext) || undefined;
|
|
6
|
+
}
|
|
7
|
+
export var CreateRootContextProvider = CreateRootContext.Provider;
|
|
8
|
+
export default CreateRootContextProvider;
|
|
@@ -4,6 +4,8 @@ import toaster from "../toaster/index.js";
|
|
|
4
4
|
// From CustomProvider/CustomProvider.tsx import CustomContext instead of directly from 'CustomProvider/index.ts'
|
|
5
5
|
// because babel compiles commonjs, which causes CustomContext to be undefined
|
|
6
6
|
import { CustomContext } from "../CustomProvider/CustomContext.js";
|
|
7
|
+
import { useCreateRoot } from "../useCreateRoot/index.js";
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Toaster display brief, temporary notifications of actions, errors, or other events in an application.
|
|
9
11
|
* It is often used with the Message and Notification components.
|
|
@@ -15,6 +17,7 @@ var useToaster = function useToaster() {
|
|
|
15
17
|
var _useContext = useContext(CustomContext),
|
|
16
18
|
toasters = _useContext.toasters,
|
|
17
19
|
toastContainer = _useContext.toastContainer;
|
|
20
|
+
var userCreateRoot = useCreateRoot();
|
|
18
21
|
return useMemo(function () {
|
|
19
22
|
return {
|
|
20
23
|
/**
|
|
@@ -31,7 +34,7 @@ var useToaster = function useToaster() {
|
|
|
31
34
|
var _toasters$current;
|
|
32
35
|
return toasters === null || toasters === void 0 || (_toasters$current = toasters.current) === null || _toasters$current === void 0 || (_toasters$current = _toasters$current.get((options === null || options === void 0 ? void 0 : options.placement) || 'topCenter')) === null || _toasters$current === void 0 ? void 0 : _toasters$current.push(message, options);
|
|
33
36
|
} else {
|
|
34
|
-
return toaster.push(message, options);
|
|
37
|
+
return toaster.push(message, options, userCreateRoot);
|
|
35
38
|
}
|
|
36
39
|
},
|
|
37
40
|
/**
|
|
@@ -54,6 +57,6 @@ var useToaster = function useToaster() {
|
|
|
54
57
|
}) : toaster.clear();
|
|
55
58
|
}
|
|
56
59
|
};
|
|
57
|
-
}, [toastContainer, toasters]);
|
|
60
|
+
}, [toastContainer, toasters, userCreateRoot]);
|
|
58
61
|
};
|
|
59
62
|
export default useToaster;
|
package/package.json
CHANGED