rsuite 5.58.1 → 5.59.0
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/Avatar/styles/index.css +74 -3
- package/Avatar/styles/index.less +25 -1
- package/Avatar/styles/mixin.less +8 -0
- package/CHANGELOG.md +15 -0
- package/Drawer/styles/index.css +4 -0
- package/Drawer/styles/index.less +5 -0
- package/cjs/Avatar/Avatar.d.ts +30 -5
- package/cjs/Avatar/Avatar.js +47 -21
- package/cjs/Avatar/AvatarIcon.d.ts +3 -0
- package/cjs/Avatar/AvatarIcon.js +24 -0
- package/cjs/Avatar/useImage.d.ts +39 -0
- package/cjs/Avatar/useImage.js +75 -0
- package/cjs/AvatarGroup/AvatarGroup.d.ts +14 -6
- package/cjs/DateInput/DateField.js +5 -0
- package/cjs/Modal/Modal.js +36 -21
- package/cjs/internals/Overlay/Modal.js +2 -1
- package/dist/rsuite-no-reset-rtl.css +75 -3
- 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 +75 -3
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +75 -3
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +75 -3
- package/dist/rsuite.js +27 -5
- 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/Avatar/Avatar.d.ts +30 -5
- package/esm/Avatar/Avatar.js +48 -22
- package/esm/Avatar/AvatarIcon.d.ts +3 -0
- package/esm/Avatar/AvatarIcon.js +18 -0
- package/esm/Avatar/useImage.d.ts +39 -0
- package/esm/Avatar/useImage.js +70 -0
- package/esm/AvatarGroup/AvatarGroup.d.ts +14 -6
- package/esm/DateInput/DateField.js +5 -0
- package/esm/Modal/Modal.js +36 -21
- package/esm/internals/Overlay/Modal.js +2 -1
- package/package.json +1 -1
- package/styles/color-modes/dark.less +2 -0
- package/styles/color-modes/high-contrast.less +2 -0
- package/styles/color-modes/light.less +2 -0
- package/styles/variables.less +12 -20
package/esm/Avatar/Avatar.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WithAsProps, RsRefForwardingComponent, TypeAttributes } from '../@types/common';
|
|
3
|
+
import { type Size } from '../AvatarGroup/AvatarGroup';
|
|
3
4
|
export interface AvatarProps extends WithAsProps {
|
|
4
|
-
/**
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A avatar can have different sizes.
|
|
7
|
+
*
|
|
8
|
+
* @default 'md'
|
|
9
|
+
* @version xxl and xs added in v5.59.0
|
|
10
|
+
*/
|
|
11
|
+
size?: Size;
|
|
6
12
|
/**
|
|
7
13
|
* The `src` attribute for the `img` element.
|
|
8
14
|
*/
|
|
@@ -21,10 +27,29 @@ export interface AvatarProps extends WithAsProps {
|
|
|
21
27
|
* It can be used to listen for the loading error event.
|
|
22
28
|
*/
|
|
23
29
|
imgProps?: React.ImgHTMLAttributes<HTMLImageElement>;
|
|
24
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Set avatar shape to circle
|
|
32
|
+
*/
|
|
25
33
|
circle?: boolean;
|
|
26
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* This attribute defines an alternative text description of the image
|
|
36
|
+
*/
|
|
27
37
|
alt?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Show a border around the avatar.
|
|
40
|
+
* @version 5.59.0
|
|
41
|
+
*/
|
|
42
|
+
bordered?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Sets the avatar background color.
|
|
45
|
+
* @version 5.59.0
|
|
46
|
+
*/
|
|
47
|
+
color?: TypeAttributes.Color;
|
|
48
|
+
/**
|
|
49
|
+
* Callback fired when the image failed to load.
|
|
50
|
+
* @version 5.59.0
|
|
51
|
+
*/
|
|
52
|
+
onError?: OnErrorEventHandler;
|
|
28
53
|
}
|
|
29
54
|
/**
|
|
30
55
|
* The Avatar component is used to represent user or brand.
|
package/esm/Avatar/Avatar.js
CHANGED
|
@@ -1,51 +1,77 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
2
|
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
var _templateObject;
|
|
6
|
-
import React, { useContext } from 'react';
|
|
5
|
+
var _templateObject, _templateObject2;
|
|
6
|
+
import React, { useContext, useMemo } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useClassNames } from '../utils';
|
|
9
9
|
import { AvatarGroupContext } from '../AvatarGroup/AvatarGroup';
|
|
10
10
|
import { oneOf } from '../internals/propTypes';
|
|
11
|
+
import AvatarIcon from './AvatarIcon';
|
|
12
|
+
import useImage from './useImage';
|
|
11
13
|
/**
|
|
12
14
|
* The Avatar component is used to represent user or brand.
|
|
13
15
|
* @see https://rsuitejs.com/components/avatar
|
|
14
16
|
*/
|
|
15
17
|
var Avatar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
var _useContext = useContext(AvatarGroupContext),
|
|
19
|
+
groupSize = _useContext.size;
|
|
20
|
+
var _props$as = props.as,
|
|
19
21
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
20
|
-
|
|
22
|
+
bordered = props.bordered,
|
|
23
|
+
alt = props.alt,
|
|
21
24
|
className = props.className,
|
|
22
25
|
children = props.children,
|
|
26
|
+
circle = props.circle,
|
|
27
|
+
color = props.color,
|
|
28
|
+
_props$classPrefix = props.classPrefix,
|
|
29
|
+
classPrefix = _props$classPrefix === void 0 ? 'avatar' : _props$classPrefix,
|
|
30
|
+
_props$size = props.size,
|
|
31
|
+
size = _props$size === void 0 ? groupSize : _props$size,
|
|
23
32
|
src = props.src,
|
|
24
33
|
srcSet = props.srcSet,
|
|
25
34
|
sizes = props.sizes,
|
|
26
35
|
imgProps = props.imgProps,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
rest = _objectWithoutPropertiesLoose(props, ["classPrefix", "as", "size", "className", "children", "src", "srcSet", "sizes", "imgProps", "circle", "alt"]);
|
|
30
|
-
var _useContext = useContext(AvatarGroupContext),
|
|
31
|
-
size = _useContext.size;
|
|
36
|
+
onError = props.onError,
|
|
37
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "bordered", "alt", "className", "children", "circle", "color", "classPrefix", "size", "src", "srcSet", "sizes", "imgProps", "onError"]);
|
|
32
38
|
var _useClassNames = useClassNames(classPrefix),
|
|
33
39
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
34
40
|
prefix = _useClassNames.prefix,
|
|
35
41
|
merge = _useClassNames.merge;
|
|
36
|
-
var classes = merge(className, withClassPrefix(
|
|
37
|
-
circle: circle
|
|
42
|
+
var classes = merge(className, withClassPrefix(size, color, {
|
|
43
|
+
circle: circle,
|
|
44
|
+
bordered: bordered
|
|
38
45
|
}));
|
|
46
|
+
var imageProps = _extends({}, imgProps, {
|
|
47
|
+
alt: alt,
|
|
48
|
+
src: src,
|
|
49
|
+
srcSet: srcSet,
|
|
50
|
+
sizes: sizes
|
|
51
|
+
});
|
|
52
|
+
var _useImage = useImage(_extends({}, imageProps, {
|
|
53
|
+
onError: onError
|
|
54
|
+
})),
|
|
55
|
+
loaded = _useImage.loaded;
|
|
56
|
+
var altComponent = useMemo(function () {
|
|
57
|
+
if (alt) {
|
|
58
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
59
|
+
role: "img",
|
|
60
|
+
"aria-label": alt
|
|
61
|
+
}, alt);
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}, [alt]);
|
|
65
|
+
var placeholder = children || altComponent || /*#__PURE__*/React.createElement(AvatarIcon, {
|
|
66
|
+
className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["icon"])))
|
|
67
|
+
});
|
|
68
|
+
var image = loaded ? /*#__PURE__*/React.createElement("img", _extends({}, imageProps, {
|
|
69
|
+
className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["image"])))
|
|
70
|
+
})) : placeholder;
|
|
39
71
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
40
72
|
ref: ref,
|
|
41
73
|
className: classes
|
|
42
|
-
}), src
|
|
43
|
-
className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["image"]))),
|
|
44
|
-
src: src,
|
|
45
|
-
sizes: sizes,
|
|
46
|
-
srcSet: srcSet,
|
|
47
|
-
alt: alt
|
|
48
|
-
})) : children);
|
|
74
|
+
}), src ? image : placeholder);
|
|
49
75
|
});
|
|
50
76
|
Avatar.displayName = 'Avatar';
|
|
51
77
|
Avatar.propTypes = {
|
|
@@ -53,7 +79,7 @@ Avatar.propTypes = {
|
|
|
53
79
|
classPrefix: PropTypes.string,
|
|
54
80
|
className: PropTypes.string,
|
|
55
81
|
children: PropTypes.node,
|
|
56
|
-
size: oneOf(['lg', 'md', 'sm', 'xs']),
|
|
82
|
+
size: oneOf(['xxl', 'xl', 'lg', 'md', 'sm', 'xs']),
|
|
57
83
|
src: PropTypes.string,
|
|
58
84
|
sizes: PropTypes.string,
|
|
59
85
|
srcSet: PropTypes.string,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
var AvatarIcon = function AvatarIcon(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
6
|
+
role: "img",
|
|
7
|
+
"aria-label": "Avatar",
|
|
8
|
+
stroke: "currentColor",
|
|
9
|
+
fill: "currentColor",
|
|
10
|
+
strokeWidth: "0",
|
|
11
|
+
viewBox: "0 0 448 512",
|
|
12
|
+
height: "60%",
|
|
13
|
+
width: "60%"
|
|
14
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
15
|
+
d: "M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304H178.3z"
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
export default AvatarIcon;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ImgHTMLAttributes } from 'react';
|
|
2
|
+
interface UseImageProps {
|
|
3
|
+
/**
|
|
4
|
+
* The image `src` attribute
|
|
5
|
+
*/
|
|
6
|
+
src?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The image `srcSet` attribute
|
|
9
|
+
*/
|
|
10
|
+
srcSet?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The image `sizes` attribute
|
|
13
|
+
*/
|
|
14
|
+
sizes?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The image `crossOrigin` attribute
|
|
17
|
+
*/
|
|
18
|
+
crossOrigin?: ImgHTMLAttributes<HTMLImageElement>['crossOrigin'];
|
|
19
|
+
/**
|
|
20
|
+
* Callback fired when the image failed to load.
|
|
21
|
+
*/
|
|
22
|
+
onError?: OnErrorEventHandler;
|
|
23
|
+
}
|
|
24
|
+
declare type Status = 'pending' | 'loading' | 'error' | 'loaded';
|
|
25
|
+
/**
|
|
26
|
+
* A hook that loads an image and returns the status of the image.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```jsx
|
|
30
|
+
* const { loaded } = useImage({ src:'https://example.com/image.jpg' });
|
|
31
|
+
*
|
|
32
|
+
* return loaded ? <img src="https://example.com/image.jpg" /> : <Placeholder />;
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const useImage: (props: UseImageProps) => {
|
|
36
|
+
loaded: boolean;
|
|
37
|
+
status: Status;
|
|
38
|
+
};
|
|
39
|
+
export default useImage;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect } from '../utils';
|
|
4
|
+
/**
|
|
5
|
+
* A hook that loads an image and returns the status of the image.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```jsx
|
|
9
|
+
* const { loaded } = useImage({ src:'https://example.com/image.jpg' });
|
|
10
|
+
*
|
|
11
|
+
* return loaded ? <img src="https://example.com/image.jpg" /> : <Placeholder />;
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
var useImage = function useImage(props) {
|
|
15
|
+
var src = props.src,
|
|
16
|
+
srcSet = props.srcSet,
|
|
17
|
+
sizes = props.sizes,
|
|
18
|
+
crossOrigin = props.crossOrigin,
|
|
19
|
+
onError = props.onError;
|
|
20
|
+
var _useState = useState('pending'),
|
|
21
|
+
status = _useState[0],
|
|
22
|
+
setStatus = _useState[1];
|
|
23
|
+
var imgRef = useRef(null);
|
|
24
|
+
var flush = function flush() {
|
|
25
|
+
if (imgRef.current) {
|
|
26
|
+
imgRef.current.onload = null;
|
|
27
|
+
imgRef.current.onerror = null;
|
|
28
|
+
imgRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var handleLoad = useCallback(function () {
|
|
32
|
+
setStatus('loaded');
|
|
33
|
+
flush();
|
|
34
|
+
}, []);
|
|
35
|
+
var handleError = useCallback(function (event) {
|
|
36
|
+
setStatus('error');
|
|
37
|
+
flush();
|
|
38
|
+
onError === null || onError === void 0 ? void 0 : onError(event);
|
|
39
|
+
}, [onError]);
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
setStatus(src ? 'loading' : 'pending');
|
|
42
|
+
}, [src]);
|
|
43
|
+
var loadImge = useCallback(function () {
|
|
44
|
+
if (!src) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
var img = new Image();
|
|
48
|
+
img.onload = handleLoad;
|
|
49
|
+
img.onerror = handleError;
|
|
50
|
+
if (src) img.src = src;
|
|
51
|
+
if (srcSet) img.srcset = srcSet;
|
|
52
|
+
if (sizes) img.sizes = sizes;
|
|
53
|
+
if (crossOrigin) img.crossOrigin = crossOrigin;
|
|
54
|
+
imgRef.current = img;
|
|
55
|
+
}, [crossOrigin, handleError, handleLoad, sizes, src, srcSet]);
|
|
56
|
+
useIsomorphicLayoutEffect(function () {
|
|
57
|
+
if (status === 'loading') {
|
|
58
|
+
loadImge();
|
|
59
|
+
}
|
|
60
|
+
}, [loadImge, status]);
|
|
61
|
+
useEffect(function () {
|
|
62
|
+
return flush;
|
|
63
|
+
}, []);
|
|
64
|
+
console.log('status', status);
|
|
65
|
+
return {
|
|
66
|
+
loaded: status === 'loaded',
|
|
67
|
+
status: status
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export default useImage;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
|
+
export declare type Size = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
3
4
|
export interface AvatarGroupProps extends WithAsProps {
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Render all avatars as stacks
|
|
7
|
+
*/
|
|
5
8
|
stack?: boolean;
|
|
6
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Set the spacing of the avatar
|
|
11
|
+
*/
|
|
7
12
|
spacing?: number;
|
|
8
|
-
/**
|
|
9
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Set the size of all avatars.
|
|
15
|
+
* @version xxl and xs added in v5.59.0
|
|
16
|
+
*/
|
|
17
|
+
size?: Size;
|
|
10
18
|
}
|
|
11
19
|
export declare const AvatarGroupContext: React.Context<{
|
|
12
|
-
size?:
|
|
20
|
+
size?: Size | undefined;
|
|
13
21
|
}>;
|
|
14
22
|
/**
|
|
15
23
|
* The AvatarGroup component is used to represent a collection of avatars.
|
|
@@ -174,6 +174,11 @@ export var useDateField = function useDateField(format, localize, date) {
|
|
|
174
174
|
if (isEmptyValue(type, value)) {
|
|
175
175
|
return null;
|
|
176
176
|
}
|
|
177
|
+
|
|
178
|
+
// Invalid Date
|
|
179
|
+
return new Date('');
|
|
180
|
+
} else if (type === 'day' && value === 0) {
|
|
181
|
+
// Invalid Date. If the type is day and the value is 0, it is considered an invalid date.
|
|
177
182
|
return new Date('');
|
|
178
183
|
}
|
|
179
184
|
if (type === 'meridian' && typeof hour === 'number') {
|
package/esm/Modal/Modal.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
var _templateObject, _templateObject2;
|
|
5
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
6
6
|
import React, { useRef, useMemo, useState, useCallback, useContext } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import pick from 'lodash/pick';
|
|
@@ -27,39 +27,40 @@ var modalSizes = ['xs', 'sm', 'md', 'lg', 'full'];
|
|
|
27
27
|
* @see https://rsuitejs.com/components/modal
|
|
28
28
|
*/
|
|
29
29
|
var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
30
|
-
var _prefix;
|
|
31
|
-
var
|
|
30
|
+
var _prefix, _merge;
|
|
31
|
+
var _props$animation = props.animation,
|
|
32
|
+
animation = _props$animation === void 0 ? Bounce : _props$animation,
|
|
33
|
+
animationProps = props.animationProps,
|
|
34
|
+
_props$animationTimeo = props.animationTimeout,
|
|
35
|
+
animationTimeout = _props$animationTimeo === void 0 ? 300 : _props$animationTimeo,
|
|
36
|
+
ariaLabelledby = props['aria-labelledby'],
|
|
37
|
+
ariaDescribedby = props['aria-describedby'],
|
|
38
|
+
backdropClassName = props.backdropClassName,
|
|
39
|
+
_props$backdrop = props.backdrop,
|
|
40
|
+
backdrop = _props$backdrop === void 0 ? true : _props$backdrop,
|
|
41
|
+
className = props.className,
|
|
32
42
|
children = props.children,
|
|
33
43
|
_props$classPrefix = props.classPrefix,
|
|
34
44
|
classPrefix = _props$classPrefix === void 0 ? 'modal' : _props$classPrefix,
|
|
35
45
|
dialogClassName = props.dialogClassName,
|
|
36
|
-
backdropClassName = props.backdropClassName,
|
|
37
|
-
_props$backdrop = props.backdrop,
|
|
38
|
-
backdrop = _props$backdrop === void 0 ? true : _props$backdrop,
|
|
39
46
|
dialogStyle = props.dialogStyle,
|
|
40
|
-
_props$animation = props.animation,
|
|
41
|
-
animation = _props$animation === void 0 ? Bounce : _props$animation,
|
|
42
|
-
open = props.open,
|
|
43
|
-
_props$size = props.size,
|
|
44
|
-
size = _props$size === void 0 ? 'sm' : _props$size,
|
|
45
|
-
full = props.full,
|
|
46
47
|
_props$dialogAs = props.dialogAs,
|
|
47
48
|
Dialog = _props$dialogAs === void 0 ? ModalDialog : _props$dialogAs,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
animationTimeout = _props$animationTimeo === void 0 ? 300 : _props$animationTimeo,
|
|
49
|
+
enforceFocusProp = props.enforceFocus,
|
|
50
|
+
full = props.full,
|
|
51
51
|
_props$overflow = props.overflow,
|
|
52
52
|
overflow = _props$overflow === void 0 ? true : _props$overflow,
|
|
53
|
+
open = props.open,
|
|
53
54
|
onClose = props.onClose,
|
|
54
55
|
onEntered = props.onEntered,
|
|
55
56
|
onEntering = props.onEntering,
|
|
56
57
|
onExited = props.onExited,
|
|
57
58
|
_props$role = props.role,
|
|
58
59
|
role = _props$role === void 0 ? 'dialog' : _props$role,
|
|
60
|
+
_props$size = props.size,
|
|
61
|
+
size = _props$size === void 0 ? 'sm' : _props$size,
|
|
59
62
|
idProp = props.id,
|
|
60
|
-
|
|
61
|
-
ariaDescribedby = props['aria-describedby'],
|
|
62
|
-
rest = _objectWithoutPropertiesLoose(props, ["className", "children", "classPrefix", "dialogClassName", "backdropClassName", "backdrop", "dialogStyle", "animation", "open", "size", "full", "dialogAs", "animationProps", "animationTimeout", "overflow", "onClose", "onEntered", "onEntering", "onExited", "role", "id", "aria-labelledby", "aria-describedby"]);
|
|
63
|
+
rest = _objectWithoutPropertiesLoose(props, ["animation", "animationProps", "animationTimeout", "aria-labelledby", "aria-describedby", "backdropClassName", "backdrop", "className", "children", "classPrefix", "dialogClassName", "dialogStyle", "dialogAs", "enforceFocus", "full", "overflow", "open", "onClose", "onEntered", "onEntering", "onExited", "role", "size", "id"]);
|
|
63
64
|
var inClass = {
|
|
64
65
|
in: open && !animation
|
|
65
66
|
};
|
|
@@ -157,18 +158,32 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
157
158
|
placement = _ref2.placement; // The width or height of the drawer depends on the placement.
|
|
158
159
|
sizeKey = placement === 'top' || placement === 'bottom' ? 'height' : 'width';
|
|
159
160
|
}
|
|
161
|
+
var enforceFocus = useMemo(function () {
|
|
162
|
+
if (typeof enforceFocusProp === 'boolean') {
|
|
163
|
+
return enforceFocusProp;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// When the Drawer is displayed and the backdrop is not displayed, the focus is not restricted.
|
|
167
|
+
if (isDrawer && backdrop === false) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}, [backdrop, enforceFocusProp, isDrawer]);
|
|
171
|
+
var wrapperClassName = merge(prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["wrapper"]))), (_merge = {}, _merge[prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["no-backdrop"])))] = backdrop === false, _merge));
|
|
160
172
|
return /*#__PURE__*/React.createElement(ModalContext.Provider, {
|
|
161
173
|
value: modalContextValue
|
|
162
|
-
}, /*#__PURE__*/React.createElement(BaseModal, _extends({
|
|
174
|
+
}, /*#__PURE__*/React.createElement(BaseModal, _extends({
|
|
175
|
+
"data-testid": isDrawer ? 'drawer-wrapper' : 'modal-wrapper'
|
|
176
|
+
}, rest, {
|
|
163
177
|
ref: ref,
|
|
164
178
|
backdrop: backdrop,
|
|
179
|
+
enforceFocus: enforceFocus,
|
|
165
180
|
open: open,
|
|
166
181
|
onClose: onClose,
|
|
167
|
-
className:
|
|
182
|
+
className: wrapperClassName,
|
|
168
183
|
onEntered: handleEntered,
|
|
169
184
|
onEntering: handleEntering,
|
|
170
185
|
onExited: handleExited,
|
|
171
|
-
backdropClassName: merge(prefix(
|
|
186
|
+
backdropClassName: merge(prefix(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["backdrop"]))), backdropClassName, inClass),
|
|
172
187
|
containerClassName: prefix({
|
|
173
188
|
open: open,
|
|
174
189
|
'has-backdrop': backdrop
|
|
@@ -192,7 +192,8 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
192
192
|
var className = fadeProps.className,
|
|
193
193
|
rest = _objectWithoutPropertiesLoose(fadeProps, ["className"]);
|
|
194
194
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
195
|
-
"aria-hidden": true
|
|
195
|
+
"aria-hidden": true,
|
|
196
|
+
"data-testid": "backdrop"
|
|
196
197
|
}, rest, {
|
|
197
198
|
style: backdropStyle,
|
|
198
199
|
ref: mergeRefs(modal.setBackdropRef, ref),
|
package/package.json
CHANGED
package/styles/variables.less
CHANGED
|
@@ -268,26 +268,18 @@
|
|
|
268
268
|
@badge-dot-size: @badge-dot-side-length;
|
|
269
269
|
|
|
270
270
|
// Avatar
|
|
271
|
-
|
|
272
|
-
@avatar-
|
|
273
|
-
@avatar-
|
|
274
|
-
@avatar-size:
|
|
275
|
-
@avatar-
|
|
276
|
-
|
|
277
|
-
@avatar-
|
|
278
|
-
@avatar-
|
|
279
|
-
@avatar-size-
|
|
280
|
-
@avatar-font-size-
|
|
281
|
-
|
|
282
|
-
@avatar-
|
|
283
|
-
@avatar-sm-font-size: 14px; // @deprecated use @avatar-sm-font-size instead
|
|
284
|
-
@avatar-size-sm: @avatar-sm-side-length;
|
|
285
|
-
@avatar-font-size-sm: @avatar-sm-font-size;
|
|
286
|
-
|
|
287
|
-
@avatar-xs-side-length: 20px; // @deprecated use @avatar-size-xs instead
|
|
288
|
-
@avatar-xs-font-size: 12px; // @deprecated use @avatar-font-size-xs instead
|
|
289
|
-
@avatar-size-xs: @avatar-xs-side-length;
|
|
290
|
-
@avatar-font-size-xs: @avatar-xs-font-size;
|
|
271
|
+
@avatar-size-xxl: 120px;
|
|
272
|
+
@avatar-font-size-xxl: 48px;
|
|
273
|
+
@avatar-size-xl: 90px;
|
|
274
|
+
@avatar-font-size-xl: 36px;
|
|
275
|
+
@avatar-size-lg: 60px;
|
|
276
|
+
@avatar-font-size-lg: 26px;
|
|
277
|
+
@avatar-size: 40px;
|
|
278
|
+
@avatar-font-size: 18px;
|
|
279
|
+
@avatar-size-sm: 30px;
|
|
280
|
+
@avatar-font-size-sm: 14px;
|
|
281
|
+
@avatar-size-xs: 20px;
|
|
282
|
+
@avatar-font-size-xs: 12px;
|
|
291
283
|
|
|
292
284
|
// Forms
|
|
293
285
|
|