@douyinfe/semi-ui 2.39.3 → 2.40.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.
@@ -27,12 +27,13 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
27
27
  };
28
28
  el: HTMLElement;
29
29
  context: ContextValue;
30
- constructor(props: PortalProps);
30
+ constructor(props: PortalProps, context: ContextValue);
31
31
  componentDidMount(): void;
32
+ initContainer: (context: ContextValue, catchError?: boolean) => HTMLElement;
32
33
  componentDidUpdate(prevProps: PortalProps): void;
33
34
  componentWillUnmount(): void;
34
35
  addStyle: (style?: {}) => void;
35
- addClass: (prefixCls: string, ...classNames: string[]) => void;
36
+ addClass: (prefixCls: string, context?: ContextValue, ...classNames: string[]) => void;
36
37
  render(): React.ReactPortal;
37
38
  }
38
39
  export default Portal;
@@ -14,10 +14,35 @@ require("@douyinfe/semi-foundation/lib/cjs/_portal/portal.css");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  const defaultGetContainer = () => document.body;
16
16
  class Portal extends _react.PureComponent {
17
- constructor(props) {
17
+ constructor(props, context) {
18
18
  var _this;
19
19
  super(props);
20
20
  _this = this;
21
+ this.initContainer = function (context) {
22
+ let catchError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
23
+ var _a, _b;
24
+ let container = undefined;
25
+ if (!_this.el) {
26
+ _this.el = document.createElement('div');
27
+ }
28
+ if (!((_a = _this.state) === null || _a === void 0 ? void 0 : _a.container)) {
29
+ try {
30
+ _this.el = document.createElement('div');
31
+ const getContainer = _this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
32
+ const portalContainer = getContainer();
33
+ portalContainer.appendChild(_this.el);
34
+ _this.addStyle(_this.props.style);
35
+ _this.addClass(_this.props.prefixCls, context, _this.props.className);
36
+ container = portalContainer;
37
+ return container;
38
+ } catch (e) {
39
+ if (!catchError) {
40
+ throw e;
41
+ }
42
+ }
43
+ }
44
+ return (_b = _this.state) === null || _b === void 0 ? void 0 : _b.container;
45
+ };
21
46
  this.addStyle = function () {
22
47
  let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
48
  if (_this.el) {
@@ -27,11 +52,12 @@ class Portal extends _react.PureComponent {
27
52
  }
28
53
  };
29
54
  this.addClass = function (prefixCls) {
55
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.context;
30
56
  const {
31
57
  direction
32
- } = _this.context;
33
- for (var _len = arguments.length, classNames = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
34
- classNames[_key - 1] = arguments[_key];
58
+ } = context;
59
+ for (var _len = arguments.length, classNames = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
60
+ classNames[_key - 2] = arguments[_key];
35
61
  }
36
62
  const cls = (0, _classnames.default)(prefixCls, ...classNames, {
37
63
  [`${prefixCls}-rtl`]: direction === 'rtl'
@@ -40,32 +66,13 @@ class Portal extends _react.PureComponent {
40
66
  _this.el.className = cls;
41
67
  }
42
68
  };
43
- try {
44
- this.el = document.createElement('div');
45
- } catch (e) {}
46
69
  this.state = {
47
- container: undefined
70
+ container: this.initContainer(context, true)
48
71
  };
49
72
  }
50
73
  componentDidMount() {
51
- if (!this.el) {
52
- this.el = document.createElement('div');
53
- }
54
- const {
55
- state,
56
- props,
57
- context
58
- } = this;
59
- const getContainer = props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
60
- const container = getContainer();
61
- if (container !== state.container) {
62
- // const computedStyle = window.getComputedStyle(container);
63
- // if (computedStyle.position !== 'relative') {
64
- // container.style.position = 'relative';
65
- // }
66
- container.appendChild(this.el);
67
- this.addStyle(props.style);
68
- this.addClass(props.prefixCls, props.className);
74
+ const container = this.initContainer(this.context);
75
+ if (container !== this.state.container) {
69
76
  this.setState({
70
77
  container
71
78
  });
@@ -60,11 +60,11 @@ class Form extends _baseComponent.default {
60
60
  get adapter() {
61
61
  return Object.assign(Object.assign({}, super.adapter), {
62
62
  cloneDeep: _index.cloneDeep,
63
- notifySubmit: values => {
64
- this.props.onSubmit(values);
63
+ notifySubmit: (values, e) => {
64
+ this.props.onSubmit(values, e);
65
65
  },
66
- notifySubmitFail: (errors, values) => {
67
- this.props.onSubmitFail(errors, values);
66
+ notifySubmitFail: (errors, values, e) => {
67
+ this.props.onSubmitFail(errors, values, e);
68
68
  },
69
69
  forceUpdate: callback => {
70
70
  this.forceUpdate(callback);
@@ -135,7 +135,7 @@ class Form extends _baseComponent.default {
135
135
  }
136
136
  submit(e) {
137
137
  e.preventDefault();
138
- this.foundation.submit();
138
+ this.foundation.submit(e);
139
139
  }
140
140
  reset(e) {
141
141
  e.preventDefault();
@@ -83,8 +83,8 @@ export interface FormFCChild<K extends Record<string, any> = any> {
83
83
  }
84
84
  export interface BaseFormProps<Values extends Record<string, any> = any> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'children' | 'onChange' | 'onSubmit' | 'onReset'> {
85
85
  'aria-label'?: React.AriaAttributes['aria-label'];
86
- onSubmit?: (values: Values) => void;
87
- onSubmitFail?: (errors: Record<keyof Values, FieldError>, values: Partial<Values>) => void;
86
+ onSubmit?: (values: Values, e?: React.FormEvent<HTMLFormElement>) => void;
87
+ onSubmitFail?: (errors: Record<keyof Values, FieldError>, values: Partial<Values>, e?: React.FormEvent<HTMLFormElement>) => void;
88
88
  onReset?: () => void;
89
89
  onValueChange?: (values: Values, changedValue: Partial<Values>) => void;
90
90
  onChange?: (formState: FormState<Values>) => void;
@@ -167,9 +167,10 @@ class Image extends _baseComponent.default {
167
167
  preview,
168
168
  fallback,
169
169
  placeholder,
170
- imageID
170
+ imageID,
171
+ setDownloadName
171
172
  } = _b,
172
- restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID"]);
173
+ restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
173
174
  const outerStyle = Object.assign({
174
175
  width,
175
176
  height
@@ -202,7 +203,8 @@ class Image extends _baseComponent.default {
202
203
  src: previewSrc,
203
204
  visible: previewVisible,
204
205
  onVisibleChange: this.handlePreviewVisibleChange,
205
- crossOrigin: !(0, _isUndefined2.default)(crossOrigin) ? crossOrigin : previewProps === null || previewProps === void 0 ? void 0 : previewProps.crossOrigin
206
+ crossOrigin: !(0, _isUndefined2.default)(crossOrigin) ? crossOrigin : previewProps === null || previewProps === void 0 ? void 0 : previewProps.crossOrigin,
207
+ setDownloadName: setDownloadName
206
208
  })));
207
209
  }
208
210
  }
@@ -21,6 +21,7 @@ export interface ImageProps extends BaseProps {
21
21
  crossOrigin?: "anonymous" | "use-credentials";
22
22
  children?: ReactNode;
23
23
  imageID?: number;
24
+ setDownloadName?: (src: string) => string;
24
25
  }
25
26
  export interface PreviewProps extends BaseProps {
26
27
  visible?: boolean;
@@ -65,6 +66,7 @@ export interface PreviewProps extends BaseProps {
65
66
  onRatioChange?: (type: RatioType) => void;
66
67
  onRotateLeft?: (angle: number) => void;
67
68
  onDownload?: (src: string, index: number) => void;
69
+ setDownloadName?: (src: string) => string;
68
70
  }
69
71
  export interface MenuProps {
70
72
  min?: number;
@@ -150,9 +150,10 @@ class Preview extends _baseComponent.default {
150
150
  src,
151
151
  className,
152
152
  style,
153
- lazyLoad
153
+ lazyLoad,
154
+ setDownloadName
154
155
  } = _a,
155
- restProps = __rest(_a, ["src", "className", "style", "lazyLoad"]);
156
+ restProps = __rest(_a, ["src", "className", "style", "lazyLoad", "setDownloadName"]);
156
157
  const {
157
158
  currentIndex,
158
159
  visible
@@ -174,7 +175,8 @@ class Preview extends _baseComponent.default {
174
175
  lazyLoad,
175
176
  previewObserver: this.previewObserver,
176
177
  setCurrentIndex: this.handleCurrentIndexChange,
177
- handleVisibleChange: this.handleVisibleChange
178
+ handleVisibleChange: this.handleVisibleChange,
179
+ setDownloadName: setDownloadName
178
180
  }
179
181
  }, /*#__PURE__*/_react.default.createElement("div", {
180
182
  id: this.previewGroupId,
@@ -9,5 +9,6 @@ export interface PreviewContextProps {
9
9
  previewObserver: IntersectionObserver;
10
10
  setCurrentIndex: (current: number) => void;
11
11
  handleVisibleChange: (visible: boolean, preVisible?: boolean) => void;
12
+ setDownloadName: (src: string) => string;
12
13
  }
13
14
  export declare const PreviewContext: import("react").Context<PreviewContextProps>;
@@ -49,7 +49,7 @@ export default class Footer extends BaseComponent<FooterProps> {
49
49
  handleSlideChange: import("lodash").DebouncedFunc<(value: any) => void>;
50
50
  handleRatioClick: () => void;
51
51
  customRenderViewMenu: () => ReactNode;
52
- getFinalIconElement: (element: ReactNode, content: ReactNode) => string | number | boolean | React.ReactFragment | JSX.Element;
52
+ getFinalIconElement: (element: ReactNode, content: ReactNode, key: string) => string | number | boolean | React.ReactFragment | JSX.Element;
53
53
  getLocalTextByKey: (key: string) => JSX.Element;
54
54
  getIconChevronLeft: () => string | number | boolean | React.ReactFragment | JSX.Element;
55
55
  getIconChevronRight: () => string | number | boolean | React.ReactFragment | JSX.Element;
@@ -58,5 +58,9 @@ export default class Footer extends BaseComponent<FooterProps> {
58
58
  getIconRatio: () => string | number | boolean | React.ReactFragment | JSX.Element;
59
59
  getIconRotate: () => string | number | boolean | React.ReactFragment | JSX.Element;
60
60
  getIconDownload: () => string | number | boolean | React.ReactFragment | JSX.Element;
61
+ getNumberInfo: () => JSX.Element;
62
+ getSlider: () => JSX.Element;
63
+ getMenu: () => (string | number | boolean | React.ReactFragment | JSX.Element)[];
64
+ getFooterMenu: () => (string | number | boolean | React.ReactFragment | JSX.Element)[];
61
65
  render(): JSX.Element;
62
66
  }
@@ -88,18 +88,20 @@ class Footer extends _baseComponent.default {
88
88
  disabledZoomOut: zoom === min,
89
89
  onRatioClick: this.handleRatioClick,
90
90
  onZoomIn: this.handlePlusClick,
91
- onZoomOut: this.handleMinusClick
91
+ onZoomOut: this.handleMinusClick,
92
+ menuItems: this.getMenu()
92
93
  };
93
94
  return renderPreviewMenu(props);
94
95
  };
95
96
  // According to showTooltip in props, decide whether to use Tooltip to pack a layer
96
97
  // 根据 props 中的 showTooltip 决定是否使用 Tooltip 包一层
97
- this.getFinalIconElement = (element, content) => {
98
+ this.getFinalIconElement = (element, content, key) => {
98
99
  const {
99
100
  showTooltip
100
101
  } = this.props;
101
102
  return showTooltip ? /*#__PURE__*/_react.default.createElement(_tooltip.default, {
102
- content: content
103
+ content: content,
104
+ key: `tooltip-${key}`
103
105
  }, element) : element;
104
106
  };
105
107
  this.getLocalTextByKey = key => /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
@@ -112,12 +114,13 @@ class Footer extends _baseComponent.default {
112
114
  prevTip
113
115
  } = this.props;
114
116
  const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronLeft, {
117
+ key: "chevron-left",
115
118
  size: "large",
116
119
  className: disabledPrev ? `${footerPrefixCls}-disabled` : "",
117
120
  onClick: !disabledPrev ? onPrev : undefined
118
121
  });
119
122
  const content = prevTip !== null && prevTip !== void 0 ? prevTip : this.getLocalTextByKey("prevTip");
120
- return this.getFinalIconElement(icon, content);
123
+ return this.getFinalIconElement(icon, content, 'chevron-left');
121
124
  };
122
125
  this.getIconChevronRight = () => {
123
126
  const {
@@ -126,12 +129,13 @@ class Footer extends _baseComponent.default {
126
129
  nextTip
127
130
  } = this.props;
128
131
  const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronRight, {
132
+ key: "chevron-right",
129
133
  size: "large",
130
134
  className: disabledNext ? `${footerPrefixCls}-disabled` : "",
131
135
  onClick: !disabledNext ? onNext : undefined
132
136
  });
133
137
  const content = nextTip !== null && nextTip !== void 0 ? nextTip : this.getLocalTextByKey("nextTip");
134
- return this.getFinalIconElement(icon, content);
138
+ return this.getFinalIconElement(icon, content, 'chevron-right');
135
139
  };
136
140
  this.getIconMinus = () => {
137
141
  const {
@@ -141,12 +145,13 @@ class Footer extends _baseComponent.default {
141
145
  } = this.props;
142
146
  const disabledZoomOut = zoom === min;
143
147
  const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconMinus, {
148
+ key: "minus",
144
149
  size: "large",
145
150
  onClick: !disabledZoomOut ? this.handleMinusClick : undefined,
146
151
  className: disabledZoomOut ? `${footerPrefixCls}-disabled` : ""
147
152
  });
148
153
  const content = zoomOutTip !== null && zoomOutTip !== void 0 ? zoomOutTip : this.getLocalTextByKey("zoomOutTip");
149
- return this.getFinalIconElement(icon, content);
154
+ return this.getFinalIconElement(icon, content, 'minus');
150
155
  };
151
156
  this.getIconPlus = () => {
152
157
  const {
@@ -156,12 +161,13 @@ class Footer extends _baseComponent.default {
156
161
  } = this.props;
157
162
  const disabledZoomIn = zoom === max;
158
163
  const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconPlus, {
164
+ key: "plus",
159
165
  size: "large",
160
166
  onClick: !disabledZoomIn ? this.handlePlusClick : undefined,
161
167
  className: disabledZoomIn ? `${footerPrefixCls}-disabled` : ""
162
168
  });
163
169
  const content = zoomInTip !== null && zoomInTip !== void 0 ? zoomInTip : this.getLocalTextByKey("zoomInTip");
164
- return this.getFinalIconElement(icon, content);
170
+ return this.getFinalIconElement(icon, content, 'plus');
165
171
  };
166
172
  this.getIconRatio = () => {
167
173
  const {
@@ -170,6 +176,7 @@ class Footer extends _baseComponent.default {
170
176
  adaptiveTip
171
177
  } = this.props;
172
178
  const props = {
179
+ key: "ratio",
173
180
  size: "large",
174
181
  className: (0, _classnames.default)(`${footerPrefixCls}-gap`),
175
182
  onClick: this.handleRatioClick
@@ -181,18 +188,19 @@ class Footer extends _baseComponent.default {
181
188
  } else {
182
189
  content = adaptiveTip !== null && adaptiveTip !== void 0 ? adaptiveTip : this.getLocalTextByKey("adaptiveTip");
183
190
  }
184
- return this.getFinalIconElement(icon, content);
191
+ return this.getFinalIconElement(icon, content, 'ratio');
185
192
  };
186
193
  this.getIconRotate = () => {
187
194
  const {
188
195
  rotateTip
189
196
  } = this.props;
190
197
  const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconRotate, {
198
+ key: "rotate",
191
199
  size: "large",
192
200
  onClick: this.handleRotateLeft
193
201
  });
194
202
  const content = rotateTip !== null && rotateTip !== void 0 ? rotateTip : this.getLocalTextByKey("rotateTip");
195
- return this.getFinalIconElement(icon, content);
203
+ return this.getFinalIconElement(icon, content, 'rotate');
196
204
  };
197
205
  this.getIconDownload = () => {
198
206
  const {
@@ -201,6 +209,7 @@ class Footer extends _baseComponent.default {
201
209
  disableDownload
202
210
  } = this.props;
203
211
  const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconDownload, {
212
+ key: 'download',
204
213
  size: "large",
205
214
  onClick: !disableDownload ? onDownload : undefined,
206
215
  className: (0, _classnames.default)(`${footerPrefixCls}-gap`, {
@@ -208,44 +217,63 @@ class Footer extends _baseComponent.default {
208
217
  })
209
218
  });
210
219
  const content = downloadTip !== null && downloadTip !== void 0 ? downloadTip : this.getLocalTextByKey("downloadTip");
211
- return this.getFinalIconElement(icon, content);
220
+ return this.getFinalIconElement(icon, content, 'download');
221
+ };
222
+ this.getNumberInfo = () => {
223
+ const {
224
+ curPage,
225
+ totalNum
226
+ } = this.props;
227
+ return /*#__PURE__*/_react.default.createElement("div", {
228
+ className: `${footerPrefixCls}-page`,
229
+ key: 'info'
230
+ }, curPage, "/", totalNum);
231
+ };
232
+ this.getSlider = () => {
233
+ const {
234
+ zoom,
235
+ min,
236
+ max,
237
+ step,
238
+ showTooltip
239
+ } = this.props;
240
+ return /*#__PURE__*/_react.default.createElement(_slider.default, {
241
+ key: 'slider',
242
+ value: zoom,
243
+ min: min,
244
+ max: max,
245
+ step: step,
246
+ tipFormatter: v => `${v}%`,
247
+ tooltipVisible: showTooltip ? undefined : false,
248
+ onChange: this.handleSlideChange
249
+ });
250
+ };
251
+ this.getMenu = () => [this.getIconChevronLeft(), this.getNumberInfo(), this.getIconChevronRight(), this.getIconMinus(), this.getSlider(), this.getIconPlus(), this.getIconRatio(), this.getIconRotate(), this.getIconDownload()];
252
+ this.getFooterMenu = () => {
253
+ const menuItems = this.getMenu();
254
+ menuItems.splice(3, 0, /*#__PURE__*/_react.default.createElement(_divider.default, {
255
+ layout: "vertical",
256
+ key: "divider-first"
257
+ }));
258
+ menuItems.splice(8, 0, /*#__PURE__*/_react.default.createElement(_divider.default, {
259
+ layout: "vertical",
260
+ key: "divider-second"
261
+ }));
262
+ return menuItems;
212
263
  };
213
264
  this.foundation = new _previewFooterFoundation.default(this.adapter);
214
265
  }
215
266
  render() {
216
267
  const {
217
- min,
218
- max,
219
- step,
220
- curPage,
221
- totalNum,
222
- zoom,
223
- showTooltip,
224
268
  className,
225
269
  renderPreviewMenu
226
270
  } = this.props;
227
- if (renderPreviewMenu) {
228
- return /*#__PURE__*/_react.default.createElement("div", {
229
- className: `${footerPrefixCls}-wrapper`
230
- }, this.customRenderViewMenu());
231
- }
271
+ const menuCls = (0, _classnames.default)(footerPrefixCls, `${footerPrefixCls}-wrapper`, className, {
272
+ [`${footerPrefixCls}-content`]: !Boolean(renderPreviewMenu)
273
+ });
232
274
  return /*#__PURE__*/_react.default.createElement("section", {
233
- className: (0, _classnames.default)(footerPrefixCls, `${footerPrefixCls}-wrapper`, className)
234
- }, this.getIconChevronLeft(), /*#__PURE__*/_react.default.createElement("div", {
235
- className: `${footerPrefixCls}-page`
236
- }, /*#__PURE__*/_react.default.createElement("span", null, curPage), /*#__PURE__*/_react.default.createElement("span", null, "/"), /*#__PURE__*/_react.default.createElement("span", null, totalNum)), this.getIconChevronRight(), /*#__PURE__*/_react.default.createElement(_divider.default, {
237
- layout: "vertical"
238
- }), this.getIconMinus(), /*#__PURE__*/_react.default.createElement(_slider.default, {
239
- value: zoom,
240
- min: min,
241
- max: max,
242
- step: step,
243
- tipFormatter: v => `${v}%`,
244
- tooltipVisible: showTooltip ? undefined : false,
245
- onChange: this.handleSlideChange
246
- }), this.getIconPlus(), this.getIconRatio(), /*#__PURE__*/_react.default.createElement(_divider.default, {
247
- layout: "vertical"
248
- }), this.getIconRotate(), this.getIconDownload());
275
+ className: menuCls
276
+ }, renderPreviewMenu ? this.customRenderViewMenu() : this.getFooterMenu());
249
277
  }
250
278
  }
251
279
  exports.default = Footer;
@@ -131,6 +131,10 @@ class PreviewInner extends _baseComponent.default {
131
131
  },
132
132
  setMouseActiveTime: time => {
133
133
  mouseActiveTime = time;
134
+ },
135
+ getSetDownloadFunc: () => {
136
+ var _a, _b;
137
+ return (_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.setDownloadName) !== null && _b !== void 0 ? _b : this.props.setDownloadName;
134
138
  }
135
139
  });
136
140
  }
@@ -88,10 +88,7 @@ class Upload extends _baseComponent.default {
88
88
  * manual upload by user
89
89
  */
90
90
  this.upload = () => {
91
- const {
92
- fileList
93
- } = this.state;
94
- this.foundation.startUpload(fileList);
91
+ this.foundation.manualUpload();
95
92
  };
96
93
  /**
97
94
  * ref method
@@ -27,12 +27,13 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
27
27
  };
28
28
  el: HTMLElement;
29
29
  context: ContextValue;
30
- constructor(props: PortalProps);
30
+ constructor(props: PortalProps, context: ContextValue);
31
31
  componentDidMount(): void;
32
+ initContainer: (context: ContextValue, catchError?: boolean) => HTMLElement;
32
33
  componentDidUpdate(prevProps: PortalProps): void;
33
34
  componentWillUnmount(): void;
34
35
  addStyle: (style?: {}) => void;
35
- addClass: (prefixCls: string, ...classNames: string[]) => void;
36
+ addClass: (prefixCls: string, context?: ContextValue, ...classNames: string[]) => void;
36
37
  render(): React.ReactPortal;
37
38
  }
38
39
  export default Portal;
@@ -7,10 +7,35 @@ import ConfigContext from '../configProvider/context';
7
7
  import '@douyinfe/semi-foundation/lib/es/_portal/portal.css';
8
8
  const defaultGetContainer = () => document.body;
9
9
  class Portal extends PureComponent {
10
- constructor(props) {
10
+ constructor(props, context) {
11
11
  var _this;
12
12
  super(props);
13
13
  _this = this;
14
+ this.initContainer = function (context) {
15
+ let catchError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
16
+ var _a, _b;
17
+ let container = undefined;
18
+ if (!_this.el) {
19
+ _this.el = document.createElement('div');
20
+ }
21
+ if (!((_a = _this.state) === null || _a === void 0 ? void 0 : _a.container)) {
22
+ try {
23
+ _this.el = document.createElement('div');
24
+ const getContainer = _this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
25
+ const portalContainer = getContainer();
26
+ portalContainer.appendChild(_this.el);
27
+ _this.addStyle(_this.props.style);
28
+ _this.addClass(_this.props.prefixCls, context, _this.props.className);
29
+ container = portalContainer;
30
+ return container;
31
+ } catch (e) {
32
+ if (!catchError) {
33
+ throw e;
34
+ }
35
+ }
36
+ }
37
+ return (_b = _this.state) === null || _b === void 0 ? void 0 : _b.container;
38
+ };
14
39
  this.addStyle = function () {
15
40
  let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
41
  if (_this.el) {
@@ -20,11 +45,12 @@ class Portal extends PureComponent {
20
45
  }
21
46
  };
22
47
  this.addClass = function (prefixCls) {
48
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.context;
23
49
  const {
24
50
  direction
25
- } = _this.context;
26
- for (var _len = arguments.length, classNames = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
27
- classNames[_key - 1] = arguments[_key];
51
+ } = context;
52
+ for (var _len = arguments.length, classNames = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
53
+ classNames[_key - 2] = arguments[_key];
28
54
  }
29
55
  const cls = classnames(prefixCls, ...classNames, {
30
56
  [`${prefixCls}-rtl`]: direction === 'rtl'
@@ -33,32 +59,13 @@ class Portal extends PureComponent {
33
59
  _this.el.className = cls;
34
60
  }
35
61
  };
36
- try {
37
- this.el = document.createElement('div');
38
- } catch (e) {}
39
62
  this.state = {
40
- container: undefined
63
+ container: this.initContainer(context, true)
41
64
  };
42
65
  }
43
66
  componentDidMount() {
44
- if (!this.el) {
45
- this.el = document.createElement('div');
46
- }
47
- const {
48
- state,
49
- props,
50
- context
51
- } = this;
52
- const getContainer = props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
53
- const container = getContainer();
54
- if (container !== state.container) {
55
- // const computedStyle = window.getComputedStyle(container);
56
- // if (computedStyle.position !== 'relative') {
57
- // container.style.position = 'relative';
58
- // }
59
- container.appendChild(this.el);
60
- this.addStyle(props.style);
61
- this.addClass(props.prefixCls, props.className);
67
+ const container = this.initContainer(this.context);
68
+ if (container !== this.state.container) {
62
69
  this.setState({
63
70
  container
64
71
  });
@@ -53,11 +53,11 @@ class Form extends BaseComponent {
53
53
  get adapter() {
54
54
  return Object.assign(Object.assign({}, super.adapter), {
55
55
  cloneDeep,
56
- notifySubmit: values => {
57
- this.props.onSubmit(values);
56
+ notifySubmit: (values, e) => {
57
+ this.props.onSubmit(values, e);
58
58
  },
59
- notifySubmitFail: (errors, values) => {
60
- this.props.onSubmitFail(errors, values);
59
+ notifySubmitFail: (errors, values, e) => {
60
+ this.props.onSubmitFail(errors, values, e);
61
61
  },
62
62
  forceUpdate: callback => {
63
63
  this.forceUpdate(callback);
@@ -128,7 +128,7 @@ class Form extends BaseComponent {
128
128
  }
129
129
  submit(e) {
130
130
  e.preventDefault();
131
- this.foundation.submit();
131
+ this.foundation.submit(e);
132
132
  }
133
133
  reset(e) {
134
134
  e.preventDefault();
@@ -83,8 +83,8 @@ export interface FormFCChild<K extends Record<string, any> = any> {
83
83
  }
84
84
  export interface BaseFormProps<Values extends Record<string, any> = any> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'children' | 'onChange' | 'onSubmit' | 'onReset'> {
85
85
  'aria-label'?: React.AriaAttributes['aria-label'];
86
- onSubmit?: (values: Values) => void;
87
- onSubmitFail?: (errors: Record<keyof Values, FieldError>, values: Partial<Values>) => void;
86
+ onSubmit?: (values: Values, e?: React.FormEvent<HTMLFormElement>) => void;
87
+ onSubmitFail?: (errors: Record<keyof Values, FieldError>, values: Partial<Values>, e?: React.FormEvent<HTMLFormElement>) => void;
88
88
  onReset?: () => void;
89
89
  onValueChange?: (values: Values, changedValue: Partial<Values>) => void;
90
90
  onChange?: (formState: FormState<Values>) => void;
@@ -160,9 +160,10 @@ export default class Image extends BaseComponent {
160
160
  preview,
161
161
  fallback,
162
162
  placeholder,
163
- imageID
163
+ imageID,
164
+ setDownloadName
164
165
  } = _b,
165
- restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID"]);
166
+ restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
166
167
  const outerStyle = Object.assign({
167
168
  width,
168
169
  height
@@ -195,7 +196,8 @@ export default class Image extends BaseComponent {
195
196
  src: previewSrc,
196
197
  visible: previewVisible,
197
198
  onVisibleChange: this.handlePreviewVisibleChange,
198
- crossOrigin: !_isUndefined(crossOrigin) ? crossOrigin : previewProps === null || previewProps === void 0 ? void 0 : previewProps.crossOrigin
199
+ crossOrigin: !_isUndefined(crossOrigin) ? crossOrigin : previewProps === null || previewProps === void 0 ? void 0 : previewProps.crossOrigin,
200
+ setDownloadName: setDownloadName
199
201
  })));
200
202
  }
201
203
  }
@@ -21,6 +21,7 @@ export interface ImageProps extends BaseProps {
21
21
  crossOrigin?: "anonymous" | "use-credentials";
22
22
  children?: ReactNode;
23
23
  imageID?: number;
24
+ setDownloadName?: (src: string) => string;
24
25
  }
25
26
  export interface PreviewProps extends BaseProps {
26
27
  visible?: boolean;
@@ -65,6 +66,7 @@ export interface PreviewProps extends BaseProps {
65
66
  onRatioChange?: (type: RatioType) => void;
66
67
  onRotateLeft?: (angle: number) => void;
67
68
  onDownload?: (src: string, index: number) => void;
69
+ setDownloadName?: (src: string) => string;
68
70
  }
69
71
  export interface MenuProps {
70
72
  min?: number;