@douyinfe/semi-ui 2.24.0-alpha.0 → 2.24.0-beta.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/dist/css/semi.css +33 -10
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +395 -230
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/_utils/index.d.ts +3 -3
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +2 -2
- package/lib/cjs/form/field.d.ts +2 -2
- package/lib/cjs/form/hoc/withField.js +4 -0
- package/lib/cjs/highlight/index.d.ts +37 -0
- package/lib/cjs/highlight/index.js +72 -0
- package/lib/cjs/image/image.js +4 -1
- package/lib/cjs/image/index.d.ts +1 -1
- package/lib/cjs/image/interface.d.ts +2 -0
- package/lib/cjs/image/previewImage.js +4 -2
- package/lib/cjs/image/previewInner.d.ts +5 -0
- package/lib/cjs/image/previewInner.js +43 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/modal/Modal.d.ts +1 -1
- package/lib/cjs/modal/Modal.js +4 -4
- package/lib/cjs/navigation/Item.d.ts +1 -1
- package/lib/cjs/navigation/Item.js +9 -0
- package/lib/cjs/navigation/SubNav.js +6 -1
- package/lib/cjs/navigation/index.d.ts +9 -1
- package/lib/cjs/navigation/index.js +8 -3
- package/lib/cjs/navigation/nav-context.d.ts +4 -1
- package/lib/cjs/select/index.d.ts +2 -0
- package/lib/cjs/select/index.js +9 -1
- package/lib/cjs/timePicker/TimePicker.js +0 -1
- package/lib/cjs/upload/index.d.ts +3 -3
- package/lib/es/_utils/index.d.ts +3 -3
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +2 -2
- package/lib/es/form/field.d.ts +2 -2
- package/lib/es/form/hoc/withField.js +4 -0
- package/lib/es/highlight/index.d.ts +37 -0
- package/lib/es/highlight/index.js +56 -0
- package/lib/es/image/image.js +3 -1
- package/lib/es/image/index.d.ts +1 -1
- package/lib/es/image/interface.d.ts +2 -0
- package/lib/es/image/previewImage.js +4 -2
- package/lib/es/image/previewInner.d.ts +5 -0
- package/lib/es/image/previewInner.js +43 -0
- package/lib/es/index.d.ts +1 -0
- package/lib/es/index.js +1 -0
- package/lib/es/modal/Modal.d.ts +1 -1
- package/lib/es/modal/Modal.js +4 -4
- package/lib/es/navigation/Item.d.ts +1 -1
- package/lib/es/navigation/Item.js +9 -0
- package/lib/es/navigation/SubNav.js +6 -1
- package/lib/es/navigation/index.d.ts +9 -1
- package/lib/es/navigation/index.js +8 -3
- package/lib/es/navigation/nav-context.d.ts +4 -1
- package/lib/es/select/index.d.ts +2 -0
- package/lib/es/select/index.js +8 -1
- package/lib/es/timePicker/TimePicker.js +0 -1
- package/lib/es/upload/index.d.ts +3 -3
- package/package.json +8 -8
|
@@ -3,12 +3,12 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import UploadFoundation from '@douyinfe/semi-foundation/lib/cjs/upload/foundation';
|
|
4
4
|
import FileCard from './fileCard';
|
|
5
5
|
import BaseComponent from '../_base/baseComponent';
|
|
6
|
-
import { FileItem, RenderFileItemProps, UploadListType, PromptPositionType, BeforeUploadProps, AfterUploadProps, OnChangeProps, customRequestArgs, CustomError } from './interface';
|
|
6
|
+
import type { FileItem, RenderFileItemProps, UploadListType, PromptPositionType, BeforeUploadProps, AfterUploadProps, OnChangeProps, customRequestArgs, CustomError } from './interface';
|
|
7
7
|
import { Locale } from '../locale/interface';
|
|
8
8
|
import '@douyinfe/semi-foundation/lib/cjs/upload/upload.css';
|
|
9
9
|
import type { CustomFile, UploadAdapter, BeforeUploadObjectResult, AfterUploadResult } from '@douyinfe/semi-foundation/lib/cjs/upload/foundation';
|
|
10
10
|
import type { ValidateStatus } from '../_base/baseComponent';
|
|
11
|
-
export { FileItem, RenderFileItemProps, UploadListType, PromptPositionType, BeforeUploadProps, AfterUploadProps, OnChangeProps, customRequestArgs, CustomError, BeforeUploadObjectResult, AfterUploadResult, };
|
|
11
|
+
export type { FileItem, RenderFileItemProps, UploadListType, PromptPositionType, BeforeUploadProps, AfterUploadProps, OnChangeProps, customRequestArgs, CustomError, BeforeUploadObjectResult, AfterUploadResult, };
|
|
12
12
|
export interface UploadProps {
|
|
13
13
|
accept?: string;
|
|
14
14
|
action: string;
|
|
@@ -142,7 +142,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
142
142
|
style: PropTypes.Requireable<object>;
|
|
143
143
|
timeout: PropTypes.Requireable<number>;
|
|
144
144
|
transformFile: PropTypes.Requireable<(...args: any[]) => any>;
|
|
145
|
-
uploadTrigger: PropTypes.Requireable<"
|
|
145
|
+
uploadTrigger: PropTypes.Requireable<"auto" | "custom">;
|
|
146
146
|
validateMessage: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
147
147
|
validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
|
|
148
148
|
withCredentials: PropTypes.Requireable<boolean>;
|
package/lib/es/_utils/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare function cloneDeep(value: any, customizer?: (value: any) => void)
|
|
|
28
28
|
* @return {Array<object>}
|
|
29
29
|
*/
|
|
30
30
|
export declare const getHighLightTextHTML: ({ sourceString, searchWords, option }: GetHighLightTextHTMLProps) => (string | React.ReactElement<{
|
|
31
|
-
style:
|
|
31
|
+
style: React.CSSProperties;
|
|
32
32
|
className: string;
|
|
33
33
|
key: string;
|
|
34
34
|
}, string | React.JSXElementConstructor<any>>)[];
|
|
@@ -46,13 +46,13 @@ export interface RegisterMediaQueryOption {
|
|
|
46
46
|
export declare const registerMediaQuery: (media: string, { match, unmatch, callInInit }: RegisterMediaQueryOption) => () => void;
|
|
47
47
|
export interface GetHighLightTextHTMLProps {
|
|
48
48
|
sourceString?: string;
|
|
49
|
-
searchWords?:
|
|
49
|
+
searchWords?: string[];
|
|
50
50
|
option: HighLightTextHTMLOption;
|
|
51
51
|
}
|
|
52
52
|
export interface HighLightTextHTMLOption {
|
|
53
53
|
highlightTag?: string;
|
|
54
54
|
highlightClassName?: string;
|
|
55
|
-
highlightStyle?:
|
|
55
|
+
highlightStyle?: React.CSSProperties;
|
|
56
56
|
caseSensitive: boolean;
|
|
57
57
|
autoEscape: boolean;
|
|
58
58
|
}
|
|
@@ -24,7 +24,7 @@ declare class Carousel extends BaseComponent<CarouselProps, CarouselState> {
|
|
|
24
24
|
indicatorType: PropTypes.Requireable<"line" | "dot" | "columnar">;
|
|
25
25
|
theme: PropTypes.Requireable<"dark" | "light" | "primary">;
|
|
26
26
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
-
arrowType: PropTypes.Requireable<"
|
|
27
|
+
arrowType: PropTypes.Requireable<"always" | "hover">;
|
|
28
28
|
showArrow: PropTypes.Requireable<boolean>;
|
|
29
29
|
showIndicator: PropTypes.Requireable<boolean>;
|
|
30
30
|
slideDirection: PropTypes.Requireable<"left" | "right">;
|
|
@@ -26,7 +26,7 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
26
26
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
27
|
value: PropTypes.Requireable<any[]>;
|
|
28
28
|
disabled: PropTypes.Requireable<boolean>;
|
|
29
|
-
type: PropTypes.Requireable<"
|
|
29
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
30
30
|
showClear: PropTypes.Requireable<boolean>;
|
|
31
31
|
format: PropTypes.Requireable<string>;
|
|
32
32
|
inputStyle: PropTypes.Requireable<object>;
|
|
@@ -43,7 +43,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
43
43
|
'aria-invalid': PropTypes.Requireable<boolean>;
|
|
44
44
|
'aria-labelledby': PropTypes.Requireable<string>;
|
|
45
45
|
'aria-required': PropTypes.Requireable<boolean>;
|
|
46
|
-
type: PropTypes.Requireable<"
|
|
46
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
47
47
|
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
48
48
|
density: PropTypes.Requireable<"default" | "compact">;
|
|
49
49
|
defaultValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
@@ -19,7 +19,7 @@ export interface MonthsGridProps extends MonthsGridFoundationProps, BaseProps {
|
|
|
19
19
|
export declare type MonthsGridState = MonthsGridFoundationState;
|
|
20
20
|
export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGridState> {
|
|
21
21
|
static propTypes: {
|
|
22
|
-
type: PropTypes.Requireable<"
|
|
22
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
23
23
|
defaultValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
24
24
|
defaultPickerValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
25
25
|
multiple: PropTypes.Requireable<boolean>;
|
|
@@ -57,9 +57,9 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
|
|
|
57
57
|
static Select: React.ComponentType<import("utility-types").Subtract<{
|
|
58
58
|
'aria-describedby'?: string;
|
|
59
59
|
'aria-errormessage'?: string;
|
|
60
|
-
'aria-invalid'?: boolean | "
|
|
60
|
+
'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling";
|
|
61
61
|
'aria-labelledby'?: string;
|
|
62
|
-
'aria-required'?: boolean | "
|
|
62
|
+
'aria-required'?: boolean | "false" | "true";
|
|
63
63
|
id?: string;
|
|
64
64
|
autoFocus?: boolean;
|
|
65
65
|
autoClearSearchValue?: boolean;
|
package/lib/es/form/field.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ declare const FormTextArea: import("react").ComponentType<import("utility-types"
|
|
|
5
5
|
declare const FormSelect: import("react").ComponentType<import("utility-types").Subtract<{
|
|
6
6
|
'aria-describedby'?: string;
|
|
7
7
|
'aria-errormessage'?: string;
|
|
8
|
-
'aria-invalid'?: boolean | "
|
|
8
|
+
'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling";
|
|
9
9
|
'aria-labelledby'?: string;
|
|
10
|
-
'aria-required'?: boolean | "
|
|
10
|
+
'aria-required'?: boolean | "false" | "true";
|
|
11
11
|
id?: string;
|
|
12
12
|
autoFocus?: boolean;
|
|
13
13
|
autoClearSearchValue?: boolean;
|
|
@@ -433,6 +433,10 @@ function withField(Component, opts) {
|
|
|
433
433
|
'aria-labelledby': labelId
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
+
if (name) {
|
|
437
|
+
newProps['name'] = name;
|
|
438
|
+
}
|
|
439
|
+
|
|
436
440
|
if (helpText) {
|
|
437
441
|
newProps['aria-describedby'] = extraText ? "".concat(helpTextId, " ").concat(extraTextId) : helpTextId;
|
|
438
442
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import '@douyinfe/semi-foundation/lib/es/highlight/highlight.css';
|
|
4
|
+
export interface HighlightProps {
|
|
5
|
+
autoEscape?: boolean;
|
|
6
|
+
caseSensitive?: boolean;
|
|
7
|
+
sourceString?: string;
|
|
8
|
+
searchWords?: Array<string>;
|
|
9
|
+
highlightStyle?: React.CSSProperties;
|
|
10
|
+
highlightClassName?: string;
|
|
11
|
+
component?: string;
|
|
12
|
+
}
|
|
13
|
+
declare class Highlight extends PureComponent<HighlightProps> {
|
|
14
|
+
static propTypes: {
|
|
15
|
+
style: PropTypes.Requireable<object>;
|
|
16
|
+
className: PropTypes.Requireable<string>;
|
|
17
|
+
autoEscape: PropTypes.Requireable<boolean>;
|
|
18
|
+
caseSensitive: PropTypes.Requireable<boolean>;
|
|
19
|
+
sourceString: PropTypes.Requireable<string>;
|
|
20
|
+
searchWords: PropTypes.Requireable<string[]>;
|
|
21
|
+
highlightStyle: PropTypes.Requireable<object>;
|
|
22
|
+
highlightClassName: PropTypes.Requireable<string>;
|
|
23
|
+
component: PropTypes.Requireable<string>;
|
|
24
|
+
};
|
|
25
|
+
static defaultProps: {
|
|
26
|
+
component: string;
|
|
27
|
+
autoEscape: boolean;
|
|
28
|
+
caseSensitive: boolean;
|
|
29
|
+
sourceString: string;
|
|
30
|
+
};
|
|
31
|
+
render(): (string | React.ReactElement<{
|
|
32
|
+
style: React.CSSProperties;
|
|
33
|
+
className: string;
|
|
34
|
+
key: string;
|
|
35
|
+
}, string | React.JSXElementConstructor<any>>)[];
|
|
36
|
+
}
|
|
37
|
+
export default Highlight;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PureComponent } from 'react';
|
|
2
|
+
import cls from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { cssClasses } from '@douyinfe/semi-foundation/lib/es/highlight/constants';
|
|
5
|
+
import { getHighLightTextHTML } from '../_utils/index';
|
|
6
|
+
import '@douyinfe/semi-foundation/lib/es/highlight/highlight.css';
|
|
7
|
+
const prefixCls = cssClasses.PREFIX;
|
|
8
|
+
|
|
9
|
+
class Highlight extends PureComponent {
|
|
10
|
+
render() {
|
|
11
|
+
const {
|
|
12
|
+
searchWords,
|
|
13
|
+
sourceString,
|
|
14
|
+
component,
|
|
15
|
+
highlightClassName,
|
|
16
|
+
highlightStyle,
|
|
17
|
+
caseSensitive,
|
|
18
|
+
autoEscape
|
|
19
|
+
} = this.props;
|
|
20
|
+
const tagCls = cls({
|
|
21
|
+
["".concat(prefixCls, "-tag")]: true
|
|
22
|
+
}, highlightClassName);
|
|
23
|
+
const option = {
|
|
24
|
+
highlightTag: component,
|
|
25
|
+
highlightClassName: tagCls,
|
|
26
|
+
highlightStyle,
|
|
27
|
+
caseSensitive,
|
|
28
|
+
autoEscape
|
|
29
|
+
};
|
|
30
|
+
return getHighLightTextHTML({
|
|
31
|
+
sourceString,
|
|
32
|
+
searchWords,
|
|
33
|
+
option
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Highlight.propTypes = {
|
|
40
|
+
style: PropTypes.object,
|
|
41
|
+
className: PropTypes.string,
|
|
42
|
+
autoEscape: PropTypes.bool,
|
|
43
|
+
caseSensitive: PropTypes.bool,
|
|
44
|
+
sourceString: PropTypes.string,
|
|
45
|
+
searchWords: PropTypes.arrayOf(PropTypes.string),
|
|
46
|
+
highlightStyle: PropTypes.object,
|
|
47
|
+
highlightClassName: PropTypes.string,
|
|
48
|
+
component: PropTypes.string
|
|
49
|
+
};
|
|
50
|
+
Highlight.defaultProps = {
|
|
51
|
+
component: 'mark',
|
|
52
|
+
autoEscape: true,
|
|
53
|
+
caseSensitive: false,
|
|
54
|
+
sourceString: ''
|
|
55
|
+
};
|
|
56
|
+
export default Highlight;
|
package/lib/es/image/image.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isUndefined from "lodash/isUndefined";
|
|
1
2
|
import _isObject from "lodash/isObject";
|
|
2
3
|
import _isBoolean from "lodash/isBoolean";
|
|
3
4
|
|
|
@@ -207,7 +208,8 @@ export default class Image extends BaseComponent {
|
|
|
207
208
|
}), loadStatus !== "success" && this.renderExtra(), canPreview && /*#__PURE__*/React.createElement(PreviewInner, Object.assign({}, previewProps, {
|
|
208
209
|
src: previewSrc,
|
|
209
210
|
visible: previewVisible,
|
|
210
|
-
onVisibleChange: this.handlePreviewVisibleChange
|
|
211
|
+
onVisibleChange: this.handlePreviewVisibleChange,
|
|
212
|
+
crossOrigin: !_isUndefined(crossOrigin) ? crossOrigin : previewProps === null || previewProps === void 0 ? void 0 : previewProps.crossOrigin
|
|
211
213
|
})))
|
|
212
214
|
);
|
|
213
215
|
}
|
package/lib/es/image/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import Preview from "./preview";
|
|
|
4
4
|
import '@douyinfe/semi-foundation/lib/es/image/image.css';
|
|
5
5
|
export default Image;
|
|
6
6
|
export { PreviewInner, Preview, };
|
|
7
|
-
export { ImageProps, PreviewImageProps, PreviewProps, } from "./interface";
|
|
7
|
+
export type { ImageProps, PreviewImageProps, PreviewProps, MenuProps } from "./interface";
|
|
@@ -49,6 +49,7 @@ export interface PreviewProps extends BaseProps {
|
|
|
49
49
|
disableDownload?: boolean;
|
|
50
50
|
zIndex?: number;
|
|
51
51
|
children?: ReactNode;
|
|
52
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
52
53
|
renderHeader?: (info: any) => ReactNode;
|
|
53
54
|
renderPreviewMenu?: (props: MenuProps) => ReactNode;
|
|
54
55
|
getPopupContainer?: () => HTMLElement;
|
|
@@ -146,6 +147,7 @@ export interface PreviewImageProps {
|
|
|
146
147
|
ratio?: RatioType;
|
|
147
148
|
disableDownload?: boolean;
|
|
148
149
|
clickZoom?: number;
|
|
150
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
149
151
|
setRatio?: (type: RatioType) => void;
|
|
150
152
|
onZoom?: (zoom: number) => void;
|
|
151
153
|
onLoad?: (src: string) => void;
|
|
@@ -172,7 +172,8 @@ export default class PreviewImage extends BaseComponent {
|
|
|
172
172
|
render() {
|
|
173
173
|
const {
|
|
174
174
|
src,
|
|
175
|
-
rotation
|
|
175
|
+
rotation,
|
|
176
|
+
crossOrigin
|
|
176
177
|
} = this.props;
|
|
177
178
|
const {
|
|
178
179
|
loading,
|
|
@@ -206,7 +207,8 @@ export default class PreviewImage extends BaseComponent {
|
|
|
206
207
|
onDragStart: e => e.preventDefault(),
|
|
207
208
|
onLoad: this.handleLoad,
|
|
208
209
|
onError: this.handleError,
|
|
209
|
-
style: imgStyle
|
|
210
|
+
style: imgStyle,
|
|
211
|
+
crossOrigin: crossOrigin
|
|
210
212
|
}), loading && /*#__PURE__*/React.createElement(Spin, {
|
|
211
213
|
size: "large",
|
|
212
214
|
wrapperClassName: "".concat(preViewImgPrefixCls, "-spin")
|
|
@@ -59,12 +59,17 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
59
59
|
maskClosable: boolean;
|
|
60
60
|
viewerVisibleDelay: number;
|
|
61
61
|
};
|
|
62
|
+
private bodyOverflow;
|
|
63
|
+
private scrollBarWidth;
|
|
64
|
+
private originBodyWidth;
|
|
62
65
|
get adapter(): PreviewInnerAdapter<PreviewInnerProps, PreviewInnerStates>;
|
|
63
66
|
timer: any;
|
|
64
67
|
context: PreviewContextProps;
|
|
65
68
|
foundation: PreviewInnerFoundation;
|
|
66
69
|
constructor(props: PreviewInnerProps);
|
|
67
70
|
static getDerivedStateFromProps(props: PreviewInnerProps, state: PreviewInnerStates): Partial<PreviewInnerStates>;
|
|
71
|
+
static getScrollbarWidth(): number;
|
|
72
|
+
componentDidMount(): void;
|
|
68
73
|
componentDidUpdate(prevProps: PreviewInnerProps, prevState: PreviewInnerStates): void;
|
|
69
74
|
componentWillUnmount(): void;
|
|
70
75
|
isInGroup(): boolean;
|
|
@@ -100,11 +100,35 @@ export default class PreviewInner extends BaseComponent {
|
|
|
100
100
|
direction: ""
|
|
101
101
|
};
|
|
102
102
|
this.foundation = new PreviewInnerFoundation(this.adapter);
|
|
103
|
+
this.bodyOverflow = '';
|
|
104
|
+
this.originBodyWidth = '100%';
|
|
105
|
+
this.scrollBarWidth = 0;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
get adapter() {
|
|
106
109
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
107
110
|
getIsInGroup: () => this.isInGroup(),
|
|
111
|
+
disabledBodyScroll: () => {
|
|
112
|
+
const {
|
|
113
|
+
getPopupContainer
|
|
114
|
+
} = this.props;
|
|
115
|
+
this.bodyOverflow = document.body.style.overflow || '';
|
|
116
|
+
|
|
117
|
+
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
118
|
+
document.body.style.overflow = 'hidden';
|
|
119
|
+
document.body.style.width = "calc(".concat(this.originBodyWidth || '100%', " - ").concat(this.scrollBarWidth, "px)");
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
enabledBodyScroll: () => {
|
|
123
|
+
const {
|
|
124
|
+
getPopupContainer
|
|
125
|
+
} = this.props;
|
|
126
|
+
|
|
127
|
+
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
128
|
+
document.body.style.overflow = this.bodyOverflow;
|
|
129
|
+
document.body.style.width = this.originBodyWidth;
|
|
130
|
+
}
|
|
131
|
+
},
|
|
108
132
|
notifyChange: (index, direction) => {
|
|
109
133
|
const {
|
|
110
134
|
onChange,
|
|
@@ -219,6 +243,23 @@ export default class PreviewInner extends BaseComponent {
|
|
|
219
243
|
return willUpdateStates;
|
|
220
244
|
}
|
|
221
245
|
|
|
246
|
+
static getScrollbarWidth() {
|
|
247
|
+
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
248
|
+
return window.innerWidth - document.documentElement.clientWidth;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
componentDidMount() {
|
|
255
|
+
this.scrollBarWidth = PreviewInner.getScrollbarWidth();
|
|
256
|
+
this.originBodyWidth = document.body.style.width;
|
|
257
|
+
|
|
258
|
+
if (this.props.visible) {
|
|
259
|
+
this.foundation.beforeShow();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
222
263
|
componentDidUpdate(prevProps, prevState) {
|
|
223
264
|
if (prevState.visible !== this.props.visible && this.props.visible) {
|
|
224
265
|
mouseActiveTime = new Date().getTime();
|
|
@@ -254,6 +295,7 @@ export default class PreviewInner extends BaseComponent {
|
|
|
254
295
|
style,
|
|
255
296
|
infinite,
|
|
256
297
|
zoomStep,
|
|
298
|
+
crossOrigin,
|
|
257
299
|
prevTip,
|
|
258
300
|
nextTip,
|
|
259
301
|
zoomInTip,
|
|
@@ -322,6 +364,7 @@ export default class PreviewInner extends BaseComponent {
|
|
|
322
364
|
ratio: ratio,
|
|
323
365
|
zoomStep: zoomStep,
|
|
324
366
|
rotation: rotation,
|
|
367
|
+
crossOrigin: crossOrigin,
|
|
325
368
|
onError: this.onImageError,
|
|
326
369
|
onLoad: this.onImageLoad
|
|
327
370
|
}), showPrev &&
|
package/lib/es/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export { default as TreeSelect } from './treeSelect';
|
|
|
76
76
|
export { default as Upload } from './upload';
|
|
77
77
|
export { default as Typography } from './typography';
|
|
78
78
|
export { default as Transfer } from './transfer';
|
|
79
|
+
export { default as Highlight } from './highlight';
|
|
79
80
|
export { default as LocaleProvider } from './locale/localeProvider';
|
|
80
81
|
export { default as LocaleConsumer } from './locale/localeConsumer';
|
|
81
82
|
/** Form */
|
package/lib/es/index.js
CHANGED
|
@@ -76,6 +76,7 @@ export { default as TreeSelect } from './treeSelect';
|
|
|
76
76
|
export { default as Upload } from './upload';
|
|
77
77
|
export { default as Typography } from './typography';
|
|
78
78
|
export { default as Transfer } from './transfer';
|
|
79
|
+
export { default as Highlight } from './highlight';
|
|
79
80
|
export { default as LocaleProvider } from './locale/localeProvider';
|
|
80
81
|
export { default as LocaleConsumer } from './locale/localeConsumer';
|
|
81
82
|
/** Form */
|
package/lib/es/modal/Modal.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ declare class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
94
94
|
private readonly modalRef;
|
|
95
95
|
private bodyOverflow;
|
|
96
96
|
private scrollBarWidth;
|
|
97
|
-
private
|
|
97
|
+
private originBodyWidth;
|
|
98
98
|
private _haveRendered;
|
|
99
99
|
constructor(props: ModalReactProps);
|
|
100
100
|
get adapter(): ModalAdapter;
|
package/lib/es/modal/Modal.js
CHANGED
|
@@ -188,7 +188,7 @@ class Modal extends BaseComponent {
|
|
|
188
188
|
this.modalRef = /*#__PURE__*/React.createRef();
|
|
189
189
|
this.bodyOverflow = '';
|
|
190
190
|
this.scrollBarWidth = 0;
|
|
191
|
-
this.
|
|
191
|
+
this.originBodyWidth = '100%';
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
get adapter() {
|
|
@@ -202,7 +202,7 @@ class Modal extends BaseComponent {
|
|
|
202
202
|
|
|
203
203
|
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
204
204
|
document.body.style.overflow = 'hidden';
|
|
205
|
-
document.body.style.width = "calc(".concat(this.
|
|
205
|
+
document.body.style.width = "calc(".concat(this.originBodyWidth || '100%', " - ").concat(this.scrollBarWidth, "px)");
|
|
206
206
|
}
|
|
207
207
|
},
|
|
208
208
|
enabledBodyScroll: () => {
|
|
@@ -212,7 +212,7 @@ class Modal extends BaseComponent {
|
|
|
212
212
|
|
|
213
213
|
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
214
214
|
document.body.style.overflow = this.bodyOverflow;
|
|
215
|
-
document.body.style.width = this.
|
|
215
|
+
document.body.style.width = this.originBodyWidth;
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
notifyCancel: e => {
|
|
@@ -269,7 +269,7 @@ class Modal extends BaseComponent {
|
|
|
269
269
|
|
|
270
270
|
componentDidMount() {
|
|
271
271
|
this.scrollBarWidth = Modal.getScrollbarWidth();
|
|
272
|
-
this.
|
|
272
|
+
this.originBodyWidth = document.body.style.width;
|
|
273
273
|
|
|
274
274
|
if (this.props.visible) {
|
|
275
275
|
this.foundation.beforeShow();
|
|
@@ -69,5 +69,5 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
69
69
|
wrapTooltip: (node: React.ReactNode) => JSX.Element;
|
|
70
70
|
handleClick: (e: React.MouseEvent) => void;
|
|
71
71
|
handleKeyPress: (e: React.KeyboardEvent) => void;
|
|
72
|
-
render(): React.
|
|
72
|
+
render(): React.ReactNode;
|
|
73
73
|
}
|
|
@@ -247,6 +247,15 @@ export default class NavItem extends BaseComponent {
|
|
|
247
247
|
itemDom = this.wrapTooltip(itemDom);
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
if (typeof this.context.renderWrapper === 'function') {
|
|
251
|
+
return this.context.renderWrapper({
|
|
252
|
+
itemElement: itemDom,
|
|
253
|
+
isSubNav: isSubNav,
|
|
254
|
+
isInSubNav: isInSubNav,
|
|
255
|
+
props: this.props
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
250
259
|
return itemDom;
|
|
251
260
|
}
|
|
252
261
|
|
|
@@ -272,7 +272,8 @@ export default class SubNav extends BaseComponent {
|
|
|
272
272
|
isCollapsed,
|
|
273
273
|
subNavCloseDelay,
|
|
274
274
|
subNavOpenDelay,
|
|
275
|
-
prefixCls
|
|
275
|
+
prefixCls,
|
|
276
|
+
getPopupContainer
|
|
276
277
|
} = this.context;
|
|
277
278
|
const isOpen = this.adapter.getIsOpen();
|
|
278
279
|
const openKeysIsControlled = this.adapter.getOpenKeysIsControlled();
|
|
@@ -289,6 +290,10 @@ export default class SubNav extends BaseComponent {
|
|
|
289
290
|
dropdownProps.visible = isOpen;
|
|
290
291
|
}
|
|
291
292
|
|
|
293
|
+
if (getPopupContainer) {
|
|
294
|
+
dropdownProps.getPopupContainer = getPopupContainer;
|
|
295
|
+
}
|
|
296
|
+
|
|
292
297
|
if (isCollapsed || mode === strings.MODE_HORIZONTAL) {
|
|
293
298
|
// Do not show dropdown when disabled
|
|
294
299
|
_elem = !disabled ? /*#__PURE__*/React.createElement(Dropdown, Object.assign({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { NavigationAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/foundation';
|
|
5
5
|
import SubNav, { SubNavProps } from './SubNav';
|
|
@@ -49,6 +49,7 @@ export interface NavProps extends BaseProps {
|
|
|
49
49
|
toggleIconPosition?: string;
|
|
50
50
|
tooltipHideDelay?: number;
|
|
51
51
|
tooltipShowDelay?: number;
|
|
52
|
+
getPopupContainer?: () => HTMLElement;
|
|
52
53
|
onClick?: (data: {
|
|
53
54
|
itemKey: React.ReactText;
|
|
54
55
|
domEvent: MouseEvent;
|
|
@@ -63,6 +64,12 @@ export interface NavProps extends BaseProps {
|
|
|
63
64
|
isOpen: boolean;
|
|
64
65
|
}) => void;
|
|
65
66
|
onSelect?: (data: OnSelectedData) => void;
|
|
67
|
+
renderWrapper?: ({ itemElement, isSubNav, isInSubNav, props }: {
|
|
68
|
+
itemElement: ReactElement;
|
|
69
|
+
isInSubNav: boolean;
|
|
70
|
+
isSubNav: boolean;
|
|
71
|
+
props: NavItemProps | SubNavProps;
|
|
72
|
+
}) => ReactNode;
|
|
66
73
|
}
|
|
67
74
|
export interface NavState {
|
|
68
75
|
isCollapsed: boolean;
|
|
@@ -107,6 +114,7 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
|
|
|
107
114
|
header: PropTypes.Requireable<NonNullable<object | PropTypes.ReactNodeLike>>;
|
|
108
115
|
footer: PropTypes.Requireable<NonNullable<object | PropTypes.ReactNodeLike>>;
|
|
109
116
|
limitIndent: PropTypes.Requireable<boolean>;
|
|
117
|
+
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
110
118
|
};
|
|
111
119
|
static defaultProps: {
|
|
112
120
|
subNavCloseDelay: number;
|
|
@@ -205,7 +205,9 @@ class Nav extends BaseComponent {
|
|
|
205
205
|
footer,
|
|
206
206
|
header,
|
|
207
207
|
toggleIconPosition,
|
|
208
|
-
limitIndent
|
|
208
|
+
limitIndent,
|
|
209
|
+
renderWrapper,
|
|
210
|
+
getPopupContainer
|
|
209
211
|
} = this.props;
|
|
210
212
|
const {
|
|
211
213
|
selectedKeys,
|
|
@@ -310,7 +312,9 @@ class Nav extends BaseComponent {
|
|
|
310
312
|
locale,
|
|
311
313
|
prefixCls,
|
|
312
314
|
toggleIconPosition,
|
|
313
|
-
limitIndent
|
|
315
|
+
limitIndent,
|
|
316
|
+
renderWrapper,
|
|
317
|
+
getPopupContainer
|
|
314
318
|
}
|
|
315
319
|
}, /*#__PURE__*/React.createElement("div", {
|
|
316
320
|
className: finalCls,
|
|
@@ -371,7 +375,8 @@ Nav.propTypes = {
|
|
|
371
375
|
prefixCls: PropTypes.string,
|
|
372
376
|
header: PropTypes.oneOfType([PropTypes.node, PropTypes.object]),
|
|
373
377
|
footer: PropTypes.oneOfType([PropTypes.node, PropTypes.object]),
|
|
374
|
-
limitIndent: PropTypes.bool
|
|
378
|
+
limitIndent: PropTypes.bool,
|
|
379
|
+
getPopupContainer: PropTypes.func
|
|
375
380
|
};
|
|
376
381
|
Nav.defaultProps = {
|
|
377
382
|
subNavCloseDelay: numbers.DEFAULT_SUBNAV_CLOSE_DELAY,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { NavProps } from './index';
|
|
2
|
+
import type { NavProps } from './index';
|
|
3
3
|
import { Locale } from '../locale/interface';
|
|
4
|
+
import type { DropdownProps } from '../dropdown';
|
|
4
5
|
export interface NavContextType {
|
|
5
6
|
isCollapsed?: boolean;
|
|
6
7
|
mode?: NavProps['mode'];
|
|
@@ -18,6 +19,8 @@ export interface NavContextType {
|
|
|
18
19
|
subNavCloseDelay?: NavProps['subNavCloseDelay'];
|
|
19
20
|
subNavOpenDelay?: NavProps['subNavOpenDelay'];
|
|
20
21
|
canUpdateOpenKeys?: boolean;
|
|
22
|
+
renderWrapper?: NavProps['renderWrapper'];
|
|
23
|
+
getPopupContainer?: DropdownProps['getPopupContainer'];
|
|
21
24
|
}
|
|
22
25
|
declare const NavContext: React.Context<NavContextType>;
|
|
23
26
|
export default NavContext;
|
package/lib/es/select/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ContextValue } from '../configProvider/context';
|
|
|
4
4
|
import SelectFoundation, { SelectAdapter } from '@douyinfe/semi-foundation/lib/es/select/foundation';
|
|
5
5
|
import BaseComponent, { ValidateStatus } from '../_base/baseComponent';
|
|
6
6
|
import { PopoverProps } from '../popover/index';
|
|
7
|
+
import Event from '@douyinfe/semi-foundation/lib/es/utils/Event';
|
|
7
8
|
import { InputProps } from '../input/index';
|
|
8
9
|
import Option, { OptionProps } from './option';
|
|
9
10
|
import OptionGroup from './optionGroup';
|
|
@@ -233,6 +234,7 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
233
234
|
clickOutsideHandler: (e: MouseEvent) => void;
|
|
234
235
|
foundation: SelectFoundation;
|
|
235
236
|
context: ContextValue;
|
|
237
|
+
eventManager: Event;
|
|
236
238
|
constructor(props: SelectProps);
|
|
237
239
|
setOptionContainerEl: (node: HTMLDivElement) => {
|
|
238
240
|
current: HTMLDivElement;
|
package/lib/es/select/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import TagGroup from '../tag/group';
|
|
|
20
20
|
import LocaleConsumer from '../locale/localeConsumer';
|
|
21
21
|
import Popover from '../popover/index';
|
|
22
22
|
import { numbers as popoverNumbers } from '@douyinfe/semi-foundation/lib/es/popover/constants';
|
|
23
|
+
import Event from '@douyinfe/semi-foundation/lib/es/utils/Event';
|
|
23
24
|
import { FixedSizeList as List } from 'react-window';
|
|
24
25
|
import { getOptionsFromGroup } from './utils';
|
|
25
26
|
import VirtualRow from './virtualRow';
|
|
@@ -128,6 +129,7 @@ class Select extends BaseComponent {
|
|
|
128
129
|
this.onMouseLeave = this.onMouseLeave.bind(this);
|
|
129
130
|
this.renderOption = this.renderOption.bind(this);
|
|
130
131
|
this.onKeyPress = this.onKeyPress.bind(this);
|
|
132
|
+
this.eventManager = new Event();
|
|
131
133
|
this.foundation = new SelectFoundation(this.adapter);
|
|
132
134
|
warning('optionLabelProp' in this.props, '[Semi Select] \'optionLabelProp\' has already been deprecated, please use \'renderSelectedItem\' instead.');
|
|
133
135
|
warning('labelInValue' in this.props, '[Semi Select] \'labelInValue\' has already been deprecated, please use \'onChangeWithObject\' instead.');
|
|
@@ -223,6 +225,10 @@ class Select extends BaseComponent {
|
|
|
223
225
|
}
|
|
224
226
|
};
|
|
225
227
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, super.adapter), keyboardAdapter), filterAdapter), multipleAdapter), {
|
|
228
|
+
on: (eventName, eventCallback) => this.eventManager.on(eventName, eventCallback),
|
|
229
|
+
off: eventName => this.eventManager.off(eventName),
|
|
230
|
+
once: (eventName, eventCallback) => this.eventManager.once(eventName, eventCallback),
|
|
231
|
+
emit: eventName => this.eventManager.emit(eventName),
|
|
226
232
|
// Collect all subitems, each item is visible by default when collected, and is not selected
|
|
227
233
|
getOptionsFromChildren: function () {
|
|
228
234
|
let children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.children;
|
|
@@ -1075,7 +1081,8 @@ class Select extends BaseComponent {
|
|
|
1075
1081
|
spacing: spacing,
|
|
1076
1082
|
stopPropagation: stopPropagation,
|
|
1077
1083
|
disableArrowKeyDown: true,
|
|
1078
|
-
onVisibleChange: status => this.handlePopoverVisibleChange(status)
|
|
1084
|
+
onVisibleChange: status => this.handlePopoverVisibleChange(status),
|
|
1085
|
+
afterClose: () => this.foundation.handlePopoverClose()
|
|
1079
1086
|
}, selection);
|
|
1080
1087
|
}
|
|
1081
1088
|
|
|
@@ -344,7 +344,6 @@ export default class TimePicker extends BaseComponent {
|
|
|
344
344
|
outerProps.onClick = this.openPanel;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
console.log("===>", disabled ? false : open, motion);
|
|
348
347
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
349
348
|
ref: this.setTimePickerRef,
|
|
350
349
|
className: classNames({
|