@douyinfe/semi-ui 2.24.0-alpha.1 → 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.
Files changed (65) hide show
  1. package/dist/css/semi.css +33 -10
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +384 -225
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/_utils/index.d.ts +3 -3
  8. package/lib/cjs/carousel/CarouselIndicator.d.ts +1 -1
  9. package/lib/cjs/carousel/index.d.ts +2 -2
  10. package/lib/cjs/form/baseForm.d.ts +3 -3
  11. package/lib/cjs/form/field.d.ts +3 -3
  12. package/lib/cjs/form/hoc/withField.js +4 -0
  13. package/lib/cjs/highlight/index.d.ts +37 -0
  14. package/lib/cjs/highlight/index.js +72 -0
  15. package/lib/cjs/image/image.js +4 -1
  16. package/lib/cjs/image/index.d.ts +1 -1
  17. package/lib/cjs/image/interface.d.ts +2 -0
  18. package/lib/cjs/image/previewImage.js +4 -2
  19. package/lib/cjs/image/previewInner.d.ts +5 -0
  20. package/lib/cjs/image/previewInner.js +43 -0
  21. package/lib/cjs/index.d.ts +1 -0
  22. package/lib/cjs/index.js +8 -0
  23. package/lib/cjs/modal/Modal.d.ts +1 -1
  24. package/lib/cjs/modal/Modal.js +4 -4
  25. package/lib/cjs/navigation/SubNav.js +6 -1
  26. package/lib/cjs/navigation/index.d.ts +2 -0
  27. package/lib/cjs/navigation/index.js +6 -3
  28. package/lib/cjs/navigation/nav-context.d.ts +3 -1
  29. package/lib/cjs/radio/radio.d.ts +1 -1
  30. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  31. package/lib/cjs/select/index.d.ts +2 -0
  32. package/lib/cjs/select/index.js +9 -1
  33. package/lib/cjs/timePicker/TimePicker.js +0 -1
  34. package/lib/cjs/typography/numeral.d.ts +1 -1
  35. package/lib/cjs/typography/title.d.ts +1 -1
  36. package/lib/es/_utils/index.d.ts +3 -3
  37. package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
  38. package/lib/es/carousel/index.d.ts +2 -2
  39. package/lib/es/form/baseForm.d.ts +3 -3
  40. package/lib/es/form/field.d.ts +3 -3
  41. package/lib/es/form/hoc/withField.js +4 -0
  42. package/lib/es/highlight/index.d.ts +37 -0
  43. package/lib/es/highlight/index.js +56 -0
  44. package/lib/es/image/image.js +3 -1
  45. package/lib/es/image/index.d.ts +1 -1
  46. package/lib/es/image/interface.d.ts +2 -0
  47. package/lib/es/image/previewImage.js +4 -2
  48. package/lib/es/image/previewInner.d.ts +5 -0
  49. package/lib/es/image/previewInner.js +43 -0
  50. package/lib/es/index.d.ts +1 -0
  51. package/lib/es/index.js +1 -0
  52. package/lib/es/modal/Modal.d.ts +1 -1
  53. package/lib/es/modal/Modal.js +4 -4
  54. package/lib/es/navigation/SubNav.js +6 -1
  55. package/lib/es/navigation/index.d.ts +2 -0
  56. package/lib/es/navigation/index.js +6 -3
  57. package/lib/es/navigation/nav-context.d.ts +3 -1
  58. package/lib/es/radio/radio.d.ts +1 -1
  59. package/lib/es/radio/radioGroup.d.ts +1 -1
  60. package/lib/es/select/index.d.ts +2 -0
  61. package/lib/es/select/index.js +8 -1
  62. package/lib/es/timePicker/TimePicker.js +0 -1
  63. package/lib/es/typography/numeral.d.ts +1 -1
  64. package/lib/es/typography/title.d.ts +1 -1
  65. package/package.json +8 -8
@@ -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: Record<string, any>;
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?: any[];
49
+ searchWords?: string[];
50
50
  option: HighLightTextHTMLOption;
51
51
  }
52
52
  export interface HighLightTextHTMLOption {
53
53
  highlightTag?: string;
54
54
  highlightClassName?: string;
55
- highlightStyle?: Record<string, any>;
55
+ highlightStyle?: React.CSSProperties;
56
56
  caseSensitive: boolean;
57
57
  autoEscape: boolean;
58
58
  }
@@ -8,7 +8,7 @@ declare class CarouselIndicator extends React.PureComponent<CarouselIndicatorPro
8
8
  position: PropTypes.Requireable<"left" | "right" | "center">;
9
9
  size: PropTypes.Requireable<"small" | "medium">;
10
10
  style: PropTypes.Requireable<object>;
11
- theme: PropTypes.Requireable<"primary" | "dark" | "light">;
11
+ theme: PropTypes.Requireable<"dark" | "light" | "primary">;
12
12
  total: PropTypes.Requireable<number>;
13
13
  onIndicatorChange: PropTypes.Requireable<(...args: any[]) => any>;
14
14
  type: PropTypes.Requireable<"line" | "dot" | "columnar">;
@@ -22,9 +22,9 @@ declare class Carousel extends BaseComponent<CarouselProps, CarouselState> {
22
22
  indicatorPosition: PropTypes.Requireable<"left" | "right" | "center">;
23
23
  indicatorSize: PropTypes.Requireable<"small" | "medium">;
24
24
  indicatorType: PropTypes.Requireable<"line" | "dot" | "columnar">;
25
- theme: PropTypes.Requireable<"primary" | "dark" | "light">;
25
+ theme: PropTypes.Requireable<"dark" | "light" | "primary">;
26
26
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
27
- arrowType: PropTypes.Requireable<"hover" | "always">;
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">;
@@ -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 | "true" | "false" | "grammar" | "spelling";
60
+ 'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling";
61
61
  'aria-labelledby'?: string;
62
- 'aria-required'?: boolean | "true" | "false";
62
+ 'aria-required'?: boolean | "false" | "true";
63
63
  id?: string;
64
64
  autoFocus?: boolean;
65
65
  autoClearSearchValue?: boolean;
@@ -128,7 +128,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
128
128
  preventScroll?: boolean;
129
129
  showRestTagsPopover?: boolean;
130
130
  restTagsPopoverProps?: import("../popover").PopoverProps;
131
- } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
131
+ } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
132
132
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
133
133
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & React.RefAttributes<any>>;
134
134
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -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 | "true" | "false" | "grammar" | "spelling";
8
+ 'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling";
9
9
  'aria-labelledby'?: string;
10
- 'aria-required'?: boolean | "true" | "false";
10
+ 'aria-required'?: boolean | "false" | "true";
11
11
  id?: string;
12
12
  autoFocus?: boolean;
13
13
  autoClearSearchValue?: boolean;
@@ -76,7 +76,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
76
76
  preventScroll?: boolean;
77
77
  showRestTagsPopover?: boolean;
78
78
  restTagsPopoverProps?: import("../popover").PopoverProps;
79
- } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "motion" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
79
+ } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
80
80
  declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
81
81
  declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
82
82
  declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
@@ -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;
@@ -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
  }
@@ -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 type { 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 */
@@ -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 originBodyWith;
97
+ private originBodyWidth;
98
98
  private _haveRendered;
99
99
  constructor(props: ModalReactProps);
100
100
  get adapter(): ModalAdapter;
@@ -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.originBodyWith = '100%';
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.originBodyWith || '100%', " - ").concat(this.scrollBarWidth, "px)");
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.originBodyWith;
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.originBodyWith = document.body.style.width;
272
+ this.originBodyWidth = document.body.style.width;
273
273
 
274
274
  if (this.props.visible) {
275
275
  this.foundation.beforeShow();
@@ -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({
@@ -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;
@@ -113,6 +114,7 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
113
114
  header: PropTypes.Requireable<NonNullable<object | PropTypes.ReactNodeLike>>;
114
115
  footer: PropTypes.Requireable<NonNullable<object | PropTypes.ReactNodeLike>>;
115
116
  limitIndent: PropTypes.Requireable<boolean>;
117
+ getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
116
118
  };
117
119
  static defaultProps: {
118
120
  subNavCloseDelay: number;
@@ -206,7 +206,8 @@ class Nav extends BaseComponent {
206
206
  header,
207
207
  toggleIconPosition,
208
208
  limitIndent,
209
- renderWrapper
209
+ renderWrapper,
210
+ getPopupContainer
210
211
  } = this.props;
211
212
  const {
212
213
  selectedKeys,
@@ -312,7 +313,8 @@ class Nav extends BaseComponent {
312
313
  prefixCls,
313
314
  toggleIconPosition,
314
315
  limitIndent,
315
- renderWrapper
316
+ renderWrapper,
317
+ getPopupContainer
316
318
  }
317
319
  }, /*#__PURE__*/React.createElement("div", {
318
320
  className: finalCls,
@@ -373,7 +375,8 @@ Nav.propTypes = {
373
375
  prefixCls: PropTypes.string,
374
376
  header: PropTypes.oneOfType([PropTypes.node, PropTypes.object]),
375
377
  footer: PropTypes.oneOfType([PropTypes.node, PropTypes.object]),
376
- limitIndent: PropTypes.bool
378
+ limitIndent: PropTypes.bool,
379
+ getPopupContainer: PropTypes.func
377
380
  };
378
381
  Nav.defaultProps = {
379
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'];
@@ -19,6 +20,7 @@ export interface NavContextType {
19
20
  subNavOpenDelay?: NavProps['subNavOpenDelay'];
20
21
  canUpdateOpenKeys?: boolean;
21
22
  renderWrapper?: NavProps['renderWrapper'];
23
+ getPopupContainer?: DropdownProps['getPopupContainer'];
22
24
  }
23
25
  declare const NavContext: React.Context<NavContextType>;
24
26
  export default NavContext;
@@ -82,7 +82,7 @@ declare class Radio extends BaseComponent<RadioProps, RadioState> {
82
82
  prefixCls?: string;
83
83
  name?: string;
84
84
  onChange?: (e: RadioChangeEvent) => void;
85
- buttonSize?: "small" | "middle" | "large";
85
+ buttonSize?: "small" | "large" | "middle";
86
86
  isCardRadio?: boolean;
87
87
  isPureCardRadio?: boolean;
88
88
  };
@@ -48,7 +48,7 @@ declare class RadioGroup extends BaseComponent<RadioGroupProps, RadioGroupState>
48
48
  disabled: PropTypes.Requireable<boolean>;
49
49
  name: PropTypes.Requireable<string>;
50
50
  options: PropTypes.Requireable<any[]>;
51
- buttonSize: PropTypes.Requireable<"small" | "middle" | "large">;
51
+ buttonSize: PropTypes.Requireable<"small" | "large" | "middle">;
52
52
  type: PropTypes.Requireable<"default" | "button" | "card" | "pureCard">;
53
53
  value: PropTypes.Requireable<any>;
54
54
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
@@ -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;
@@ -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({
@@ -28,7 +28,7 @@ export default class Numeral extends PureComponent<NumeralProps> {
28
28
  static propTypes: {
29
29
  rule: PropTypes.Requireable<"text" | "numbers" | "bytes-decimal" | "bytes-binary" | "percentages" | "exponential">;
30
30
  precision: PropTypes.Requireable<number>;
31
- truncate: PropTypes.Requireable<"ceil" | "floor" | "round">;
31
+ truncate: PropTypes.Requireable<"round" | "ceil" | "floor">;
32
32
  parser: PropTypes.Requireable<(...args: any[]) => any>;
33
33
  copyable: PropTypes.Requireable<NonNullable<boolean | object>>;
34
34
  delete: PropTypes.Requireable<boolean>;
@@ -37,7 +37,7 @@ export default class Title extends PureComponent<TitleProps> {
37
37
  underline: PropTypes.Requireable<boolean>;
38
38
  strong: PropTypes.Requireable<boolean>;
39
39
  type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
40
- heading: PropTypes.Requireable<4 | 2 | 1 | 3 | 6 | 5>;
40
+ heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 6 | 5>;
41
41
  style: PropTypes.Requireable<object>;
42
42
  className: PropTypes.Requireable<string>;
43
43
  component: PropTypes.Requireable<string>;