@douyinfe/semi-ui 2.22.2 → 2.23.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 (53) hide show
  1. package/dist/css/semi.css +8 -1
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +69 -35
  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/form/baseForm.d.ts +4 -4
  8. package/lib/cjs/form/errorMessage.d.ts +2 -1
  9. package/lib/cjs/form/hooks/useFormState.d.ts +2 -1
  10. package/lib/cjs/form/interface.d.ts +15 -15
  11. package/lib/cjs/image/image.js +12 -0
  12. package/lib/cjs/image/interface.d.ts +1 -1
  13. package/lib/cjs/image/preview.d.ts +1 -1
  14. package/lib/cjs/image/preview.js +2 -2
  15. package/lib/cjs/image/previewImage.d.ts +1 -1
  16. package/lib/cjs/image/previewImage.js +1 -1
  17. package/lib/cjs/image/previewInner.d.ts +1 -1
  18. package/lib/cjs/image/previewInner.js +13 -5
  19. package/lib/cjs/locale/source/tr_TR.js +2 -2
  20. package/lib/cjs/navigation/Item.d.ts +3 -0
  21. package/lib/cjs/navigation/Item.js +9 -5
  22. package/lib/cjs/table/Body/index.js +2 -2
  23. package/lib/cjs/table/Table.js +3 -2
  24. package/lib/cjs/tabs/TabPane.js +4 -3
  25. package/lib/cjs/tabs/interface.d.ts +1 -0
  26. package/lib/cjs/tagInput/index.d.ts +1 -1
  27. package/lib/cjs/tagInput/index.js +6 -4
  28. package/lib/cjs/transfer/index.d.ts +1 -0
  29. package/lib/cjs/transfer/index.js +7 -1
  30. package/lib/es/form/baseForm.d.ts +4 -4
  31. package/lib/es/form/errorMessage.d.ts +2 -1
  32. package/lib/es/form/hooks/useFormState.d.ts +2 -1
  33. package/lib/es/form/interface.d.ts +15 -15
  34. package/lib/es/image/image.js +11 -0
  35. package/lib/es/image/interface.d.ts +1 -1
  36. package/lib/es/image/preview.d.ts +1 -1
  37. package/lib/es/image/preview.js +2 -2
  38. package/lib/es/image/previewImage.d.ts +1 -1
  39. package/lib/es/image/previewImage.js +1 -1
  40. package/lib/es/image/previewInner.d.ts +1 -1
  41. package/lib/es/image/previewInner.js +13 -5
  42. package/lib/es/locale/source/tr_TR.js +2 -2
  43. package/lib/es/navigation/Item.d.ts +3 -0
  44. package/lib/es/navigation/Item.js +9 -5
  45. package/lib/es/table/Body/index.js +3 -3
  46. package/lib/es/table/Table.js +3 -2
  47. package/lib/es/tabs/TabPane.js +4 -3
  48. package/lib/es/tabs/interface.d.ts +1 -0
  49. package/lib/es/tagInput/index.d.ts +1 -1
  50. package/lib/es/tagInput/index.js +6 -4
  51. package/lib/es/transfer/index.d.ts +1 -0
  52. package/lib/es/transfer/index.js +7 -1
  53. package/package.json +7 -7
@@ -11,7 +11,7 @@ import { BaseFormProps, FormApi } from './interface';
11
11
  interface BaseFormState {
12
12
  formId: string;
13
13
  }
14
- declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
14
+ declare class Form<Values extends Record<string, any> = any> extends BaseComponent<BaseFormProps<Values>, BaseFormState> {
15
15
  static propTypes: {
16
16
  'aria-label': PropTypes.Requireable<string>;
17
17
  onSubmit: PropTypes.Requireable<(...args: any[]) => any>;
@@ -148,11 +148,11 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
148
148
  static InputGroup: typeof FormInputGroup;
149
149
  static Label: typeof Label;
150
150
  static Section: typeof Section;
151
- formApi: FormApi;
152
- constructor(props: BaseFormProps);
151
+ formApi: FormApi<Values>;
152
+ constructor(props: BaseFormProps<Values>);
153
153
  componentDidMount(): void;
154
154
  componentWillUnmount(): void;
155
- get adapter(): BaseFormAdapter<BaseFormProps, BaseFormState>;
155
+ get adapter(): BaseFormAdapter<BaseFormProps<Values>, BaseFormState, Values>;
156
156
  get content(): React.ReactNode;
157
157
  submit(e: React.FormEvent<HTMLFormElement>): void;
158
158
  reset(e: React.FormEvent<HTMLFormElement>): void;
@@ -1,6 +1,7 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- export declare type ReactFieldError = Array<any> | React.ReactNode;
3
+ import type { BasicFieldError } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
4
+ export declare type ReactFieldError = BasicFieldError | React.ReactNode;
4
5
  export interface ErrorMessageProps {
5
6
  error?: ReactFieldError;
6
7
  className?: string;
@@ -1,2 +1,3 @@
1
- declare function useFormState(): import("@douyinfe/semi-foundation/lib/cjs/form/interface").FormState<any>;
1
+ import { FormState } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
2
+ declare function useFormState<T extends Record<string, any> = any>(): FormState<T>;
2
3
  export default useFormState;
@@ -1,16 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { Subtract } from 'utility-types';
3
3
  import type { RuleItem } from 'async-validator';
4
- import { Options as scrollIntoViewOptions } from 'scroll-into-view-if-needed';
5
- import { BaseFormApi as FormApi, FormState, WithFieldOption } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
6
- import { SelectProps } from '../select/index';
4
+ import type { Options as scrollIntoViewOptions } from 'scroll-into-view-if-needed';
5
+ import type { BaseFormApi as FormApi, FormState, WithFieldOption, AllErrors } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
6
+ import type { SelectProps } from '../select/index';
7
7
  import Option from '../select/option';
8
8
  import OptGroup from '../select/optionGroup';
9
- import { CheckboxProps } from '../checkbox/index';
10
- import { RadioProps } from '../radio/index';
9
+ import type { CheckboxProps } from '../checkbox/index';
10
+ import type { RadioProps } from '../radio/index';
11
11
  import { ReactFieldError as FieldError } from './errorMessage';
12
- import { LabelProps } from './label';
13
- export { FormState, FormApi, WithFieldOption, RuleItem };
12
+ import type { LabelProps } from './label';
13
+ export type { FormState, FormApi, WithFieldOption, RuleItem };
14
14
  export declare type CommonFieldProps = {
15
15
  /** Field is required (except Form. Checkbox within the Group, Form. Radio) */
16
16
  field: string;
@@ -81,19 +81,19 @@ export interface FormFCChild<K extends Record<string, any> = any> {
81
81
  values: K;
82
82
  formApi: FormApi<K>;
83
83
  }
84
- export interface BaseFormProps extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'children' | 'onChange'> {
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: Record<string, any>) => void;
87
- onSubmitFail?: (errors: Record<string, FieldError>, values: any) => void;
86
+ onSubmit?: (values: Values) => void;
87
+ onSubmitFail?: (errors: Record<keyof Values, FieldError>, values: Partial<Values>) => void;
88
88
  onReset?: () => void;
89
- onValueChange?: (values: Record<string, any>, changedValue: Record<string, any>) => void;
90
- onChange?: (formState: FormState) => void;
91
- validateFields?: (values: Record<string, any>) => string | Record<string, any>;
89
+ onValueChange?: (values: Values, changedValue: Partial<Values>) => void;
90
+ onChange?: (formState: FormState<Values>) => void;
91
+ validateFields?: (values: Values) => string | Partial<AllErrors<Values>>;
92
92
  /** Use this if you want to populate the form with initial values. */
93
- initValues?: Record<string, any>;
93
+ initValues?: Values;
94
94
  id?: string;
95
95
  /** getFormApi will be call once when Form mounted, u can save formApi reference in your component */
96
- getFormApi?: (formApi: FormApi) => void;
96
+ getFormApi?: (formApi: FormApi<Values>) => void;
97
97
  style?: React.CSSProperties;
98
98
  className?: string;
99
99
  layout?: 'horizontal' | 'vertical';
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
9
9
 
10
+ var _isBoolean2 = _interopRequireDefault(require("lodash/isBoolean"));
11
+
10
12
  var _react = _interopRequireDefault(require("react"));
11
13
 
12
14
  var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
@@ -153,6 +155,16 @@ class Image extends _baseComponent.default {
153
155
  willUpdateStates.loadStatus = "loading";
154
156
  }
155
157
 
158
+ if ((0, _isObject2.default)(props.preview)) {
159
+ const {
160
+ visible
161
+ } = props.preview;
162
+
163
+ if ((0, _isBoolean2.default)(visible)) {
164
+ willUpdateStates.previewVisible = visible;
165
+ }
166
+ }
167
+
156
168
  return willUpdateStates;
157
169
  }
158
170
 
@@ -60,7 +60,7 @@ export interface PreviewProps extends BaseProps {
60
60
  onPrev?: (index: number) => void;
61
61
  onNext?: (index: number) => void;
62
62
  onRatioChange?: (type: RatioType) => void;
63
- onRotateChange?: (angle: number) => void;
63
+ onRotateLeft?: (angle: number) => void;
64
64
  onDownload?: (src: string, index: number) => void;
65
65
  }
66
66
  export interface MenuProps {
@@ -44,8 +44,8 @@ export default class Preview extends BaseComponent<PreviewProps, PreviewState> {
44
44
  onPrev: PropTypes.Requireable<(...args: any[]) => any>;
45
45
  onNext: PropTypes.Requireable<(...args: any[]) => any>;
46
46
  onDownload: PropTypes.Requireable<(...args: any[]) => any>;
47
+ onRotateLeft: PropTypes.Requireable<(...args: any[]) => any>;
47
48
  onRatioChange: PropTypes.Requireable<(...args: any[]) => any>;
48
- onRotateChange: PropTypes.Requireable<(...args: any[]) => any>;
49
49
  };
50
50
  static defaultProps: {
51
51
  src: any[];
@@ -241,8 +241,8 @@ Preview.propTypes = {
241
241
  onPrev: _propTypes.default.func,
242
242
  onNext: _propTypes.default.func,
243
243
  onDownload: _propTypes.default.func,
244
- onRatioChange: _propTypes.default.func,
245
- onRotateChange: _propTypes.default.func
244
+ onRotateLeft: _propTypes.default.func,
245
+ onRatioChange: _propTypes.default.func
246
246
  };
247
247
  Preview.defaultProps = {
248
248
  src: [],
@@ -13,7 +13,7 @@ export default class PreviewImage extends BaseComponent<PreviewImageProps, Previ
13
13
  zoomStep: PropTypes.Requireable<number>;
14
14
  zoom: PropTypes.Requireable<number>;
15
15
  ratio: PropTypes.Requireable<string>;
16
- disableDownload: PropTypes.Requireable<number>;
16
+ disableDownload: PropTypes.Requireable<boolean>;
17
17
  clickZoom: PropTypes.Requireable<number>;
18
18
  setRatio: PropTypes.Requireable<(...args: any[]) => any>;
19
19
  onZoom: PropTypes.Requireable<(...args: any[]) => any>;
@@ -241,7 +241,7 @@ PreviewImage.propTypes = {
241
241
  zoomStep: _propTypes.default.number,
242
242
  zoom: _propTypes.default.number,
243
243
  ratio: _propTypes.default.string,
244
- disableDownload: _propTypes.default.number,
244
+ disableDownload: _propTypes.default.bool,
245
245
  clickZoom: _propTypes.default.number,
246
246
  setRatio: _propTypes.default.func,
247
247
  onZoom: _propTypes.default.func,
@@ -45,7 +45,7 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
45
45
  onNext: PropTypes.Requireable<(...args: any[]) => any>;
46
46
  onDownload: PropTypes.Requireable<(...args: any[]) => any>;
47
47
  onRatioChange: PropTypes.Requireable<(...args: any[]) => any>;
48
- onRotateChange: PropTypes.Requireable<(...args: any[]) => any>;
48
+ onRotateLeft: PropTypes.Requireable<(...args: any[]) => any>;
49
49
  };
50
50
  static defaultProps: {
51
51
  showTooltip: boolean;
@@ -127,11 +127,19 @@ class PreviewInner extends _baseComponent.default {
127
127
  get adapter() {
128
128
  return Object.assign(Object.assign({}, super.adapter), {
129
129
  getIsInGroup: () => this.isInGroup(),
130
- notifyChange: index => {
130
+ notifyChange: (index, direction) => {
131
131
  const {
132
- onChange
132
+ onChange,
133
+ onPrev,
134
+ onNext
133
135
  } = this.props;
134
136
  (0, _isFunction2.default)(onChange) && onChange(index);
137
+
138
+ if (direction === "prev") {
139
+ onPrev && onPrev(index);
140
+ } else {
141
+ onNext && onNext(index);
142
+ }
135
143
  },
136
144
  notifyZoom: (zoom, increase) => {
137
145
  const {
@@ -165,9 +173,9 @@ class PreviewInner extends _baseComponent.default {
165
173
  },
166
174
  notifyRotateChange: angle => {
167
175
  const {
168
- onRotateChange
176
+ onRotateLeft
169
177
  } = this.props;
170
- (0, _isFunction2.default)(onRotateChange) && onRotateChange(angle);
178
+ (0, _isFunction2.default)(onRotateLeft) && onRotateLeft(angle);
171
179
  },
172
180
  notifyDownload: (src, index) => {
173
181
  const {
@@ -427,7 +435,7 @@ PreviewInner.propTypes = {
427
435
  onNext: _propTypes.default.func,
428
436
  onDownload: _propTypes.default.func,
429
437
  onRatioChange: _propTypes.default.func,
430
- onRotateChange: _propTypes.default.func
438
+ onRotateLeft: _propTypes.default.func
431
439
  };
432
440
  PreviewInner.defaultProps = {
433
441
  showTooltip: false,
@@ -88,8 +88,8 @@ const local = {
88
88
  Wed: 'Çar',
89
89
  Thu: 'Perş',
90
90
  Fri: 'Cum',
91
- Sat: 'Oturdu',
92
- Sun: 'Güneş'
91
+ Sat: 'Cmt',
92
+ Sun: 'Paz'
93
93
  },
94
94
  localeFormatToken: {
95
95
  FORMAT_SWITCH_DATE: 'yyyy-MM-dd'
@@ -12,6 +12,7 @@ export interface NavItemProps extends ItemProps, BaseProps {
12
12
  level?: number;
13
13
  link?: string;
14
14
  linkOptions?: React.AnchorHTMLAttributes<HTMLAnchorElement>;
15
+ tabIndex?: number;
15
16
  text?: React.ReactNode;
16
17
  tooltipHideDelay?: number;
17
18
  tooltipShowDelay?: number;
@@ -45,6 +46,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
45
46
  link: PropTypes.Requireable<string>;
46
47
  linkOptions: PropTypes.Requireable<object>;
47
48
  disabled: PropTypes.Requireable<boolean>;
49
+ tabIndex: PropTypes.Requireable<number>;
48
50
  };
49
51
  static defaultProps: {
50
52
  isSubNav: boolean;
@@ -55,6 +57,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
55
57
  onMouseEnter: (...args: any[]) => void;
56
58
  onMouseLeave: (...args: any[]) => void;
57
59
  disabled: boolean;
60
+ tabIndex: number;
58
61
  };
59
62
  foundation: ItemFoundation;
60
63
  context: NavContextType;
@@ -170,7 +170,8 @@ class NavItem extends _baseComponent.default {
170
170
  link,
171
171
  linkOptions,
172
172
  disabled,
173
- level = 0
173
+ level = 0,
174
+ tabIndex
174
175
  } = this.props;
175
176
  const {
176
177
  mode,
@@ -233,7 +234,8 @@ class NavItem extends _baseComponent.default {
233
234
  ["".concat(clsPrefix, "-sub")]: isSubNav,
234
235
  ["".concat(clsPrefix, "-selected")]: selected && !isSubNav,
235
236
  ["".concat(clsPrefix, "-collapsed")]: isCollapsed,
236
- ["".concat(clsPrefix, "-disabled")]: disabled
237
+ ["".concat(clsPrefix, "-disabled")]: disabled,
238
+ ["".concat(clsPrefix, "-has-link")]: typeof link === 'string'
237
239
  });
238
240
  const ariaProps = {
239
241
  'aria-disabled': disabled
@@ -250,7 +252,7 @@ class NavItem extends _baseComponent.default {
250
252
  _react.default.createElement("li", Object.assign({
251
253
  // if role = menuitem, the narration will read all expanded li
252
254
  role: isSubNav ? null : "menuitem",
253
- tabIndex: isSubNav ? -1 : 0
255
+ tabIndex: isSubNav ? -1 : tabIndex
254
256
  }, ariaProps, {
255
257
  style: style,
256
258
  ref: this.setItemRef,
@@ -291,7 +293,8 @@ NavItem.propTypes = {
291
293
  isSubNav: _propTypes.default.bool,
292
294
  link: _propTypes.default.string,
293
295
  linkOptions: _propTypes.default.object,
294
- disabled: _propTypes.default.bool
296
+ disabled: _propTypes.default.bool,
297
+ tabIndex: _propTypes.default.number
295
298
  };
296
299
  NavItem.defaultProps = {
297
300
  isSubNav: false,
@@ -301,5 +304,6 @@ NavItem.defaultProps = {
301
304
  onClick: _noop2.default,
302
305
  onMouseEnter: _noop2.default,
303
306
  onMouseLeave: _noop2.default,
304
- disabled: false
307
+ disabled: false,
308
+ tabIndex: 0
305
309
  };
@@ -269,7 +269,7 @@ class Body extends _baseComponent.default {
269
269
  width: tableWidth
270
270
  },
271
271
  className: tableCls
272
- }, (0, _size2.default)(dataSource) === 0 ? emptySlot : children));
272
+ }, children), (0, _size2.default)(dataSource) === 0 && emptySlot);
273
273
  });
274
274
 
275
275
  this.onItemsRendered = props => {
@@ -308,7 +308,7 @@ class Body extends _baseComponent.default {
308
308
 
309
309
  const listStyle = {
310
310
  width: '100%',
311
- height: (virtualizedData === null || virtualizedData === void 0 ? void 0 : virtualizedData.length) ? y : 0,
311
+ height: (virtualizedData === null || virtualizedData === void 0 ? void 0 : virtualizedData.length) ? y : _constants.numbers.DEFAULT_EMPTYSLOT_HEIGHT,
312
312
  overflowX: 'auto',
313
313
  overflowY: 'auto'
314
314
  };
@@ -678,8 +678,9 @@ class Table extends _baseComponent.default {
678
678
  useFixedHeader,
679
679
  headerRef: this._cacheHeaderRef,
680
680
  bodyRef: this.bodyWrapRef,
681
- includeHeader: !useFixedHeader
682
- })), emptySlot, this.renderFooter(props)];
681
+ includeHeader: !useFixedHeader,
682
+ emptySlot
683
+ })), this.renderFooter(props)];
683
684
  return table;
684
685
  };
685
686
 
@@ -83,9 +83,10 @@ class TabPane extends _react.PureComponent {
83
83
  className,
84
84
  style,
85
85
  children,
86
- itemKey
86
+ itemKey,
87
+ tabIndex
87
88
  } = _a,
88
- restProps = __rest(_a, ["className", "style", "children", "itemKey"]);
89
+ restProps = __rest(_a, ["className", "style", "children", "itemKey", "tabIndex"]);
89
90
 
90
91
  const active = this.context.activeKey === itemKey;
91
92
  const classNames = (0, _classnames.default)(className, {
@@ -123,7 +124,7 @@ class TabPane extends _react.PureComponent {
123
124
  className: classNames,
124
125
  style: style,
125
126
  "aria-hidden": active ? 'false' : 'true',
126
- tabIndex: 0
127
+ tabIndex: tabIndex ? tabIndex : 0
127
128
  }, (0, _getDataAttr.default)(restProps), {
128
129
  "x-semi-prop": "children"
129
130
  }), /*#__PURE__*/_react.default.createElement(_cssAnimation.default, {
@@ -61,6 +61,7 @@ export interface TabPaneProps {
61
61
  style?: CSSProperties;
62
62
  tab?: ReactNode;
63
63
  closable?: boolean;
64
+ tabIndex?: number;
64
65
  }
65
66
  export interface TabPaneTransitionProps {
66
67
  [key: string]: any;
@@ -37,7 +37,7 @@ export interface TagInputProps {
37
37
  insetLabel?: React.ReactNode;
38
38
  insetLabelId?: string;
39
39
  prefix?: React.ReactNode;
40
- renderTagItem?: (value: string, index: number) => React.ReactNode;
40
+ renderTagItem?: (value: string, index: number, onClose: () => void) => React.ReactNode;
41
41
  separator?: string | string[] | null;
42
42
  showClear?: boolean;
43
43
  size?: Size;
@@ -152,20 +152,22 @@ class TagInput extends _baseComponent.default {
152
152
  return tagsArray.map((value, index) => {
153
153
  const elementKey = showIconHandler ? value : "".concat(index).concat(value);
154
154
 
155
+ const onClose = () => {
156
+ !disabled && this.handleTagClose(index);
157
+ };
158
+
155
159
  if ((0, _isFunction2.default)(renderTagItem)) {
156
160
  return showIconHandler ? /*#__PURE__*/_react.default.createElement("div", {
157
161
  className: itemWrapperCls,
158
162
  key: elementKey
159
- }, /*#__PURE__*/_react.default.createElement(DragHandle, null), renderTagItem(value, index)) : renderTagItem(value, index);
163
+ }, /*#__PURE__*/_react.default.createElement(DragHandle, null), renderTagItem(value, index, onClose)) : renderTagItem(value, index, onClose);
160
164
  } else {
161
165
  return /*#__PURE__*/_react.default.createElement(_tag.default, {
162
166
  className: tagCls,
163
167
  color: "white",
164
168
  size: size === 'small' ? 'small' : 'large',
165
169
  type: "light",
166
- onClose: () => {
167
- !disabled && this.handleTagClose(index);
168
- },
170
+ onClose: onClose,
169
171
  closable: !disabled,
170
172
  key: elementKey,
171
173
  visible: true,
@@ -152,6 +152,7 @@ declare class Transfer extends BaseComponent<TransferProps, TransferState> {
152
152
  static getDerivedStateFromProps(props: TransferProps, state: TransferState): TransferState;
153
153
  get adapter(): TransferAdapter<TransferProps, TransferState>;
154
154
  onInputChange(value: string): void;
155
+ search(value: string): void;
155
156
  onSelectOrRemove(item: ResolvedDataItem): void;
156
157
  onSortEnd(callbackProps: OnSortEndProps): void;
157
158
  renderFilter(locale: Locale['Transfer']): JSX.Element;
@@ -155,7 +155,13 @@ class Transfer extends _baseComponent.default {
155
155
  }
156
156
 
157
157
  onInputChange(value) {
158
- this.foundation.handleInputChange(value);
158
+ this.foundation.handleInputChange(value, true);
159
+ }
160
+
161
+ search(value) {
162
+ // The search method is used to provide the user with a manually triggered search
163
+ // Since the method is manually called by the user, setting the second parameter to false does not trigger the onSearch callback to notify the user
164
+ this.foundation.handleInputChange(value, false);
159
165
  }
160
166
 
161
167
  onSelectOrRemove(item) {
@@ -11,7 +11,7 @@ import { BaseFormProps, FormApi } from './interface';
11
11
  interface BaseFormState {
12
12
  formId: string;
13
13
  }
14
- declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
14
+ declare class Form<Values extends Record<string, any> = any> extends BaseComponent<BaseFormProps<Values>, BaseFormState> {
15
15
  static propTypes: {
16
16
  'aria-label': PropTypes.Requireable<string>;
17
17
  onSubmit: PropTypes.Requireable<(...args: any[]) => any>;
@@ -148,11 +148,11 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
148
148
  static InputGroup: typeof FormInputGroup;
149
149
  static Label: typeof Label;
150
150
  static Section: typeof Section;
151
- formApi: FormApi;
152
- constructor(props: BaseFormProps);
151
+ formApi: FormApi<Values>;
152
+ constructor(props: BaseFormProps<Values>);
153
153
  componentDidMount(): void;
154
154
  componentWillUnmount(): void;
155
- get adapter(): BaseFormAdapter<BaseFormProps, BaseFormState>;
155
+ get adapter(): BaseFormAdapter<BaseFormProps<Values>, BaseFormState, Values>;
156
156
  get content(): React.ReactNode;
157
157
  submit(e: React.FormEvent<HTMLFormElement>): void;
158
158
  reset(e: React.FormEvent<HTMLFormElement>): void;
@@ -1,6 +1,7 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- export declare type ReactFieldError = Array<any> | React.ReactNode;
3
+ import type { BasicFieldError } from '@douyinfe/semi-foundation/lib/es/form/interface';
4
+ export declare type ReactFieldError = BasicFieldError | React.ReactNode;
4
5
  export interface ErrorMessageProps {
5
6
  error?: ReactFieldError;
6
7
  className?: string;
@@ -1,2 +1,3 @@
1
- declare function useFormState(): import("@douyinfe/semi-foundation/lib/es/form/interface").FormState<any>;
1
+ import { FormState } from '@douyinfe/semi-foundation/lib/es/form/interface';
2
+ declare function useFormState<T extends Record<string, any> = any>(): FormState<T>;
2
3
  export default useFormState;
@@ -1,16 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { Subtract } from 'utility-types';
3
3
  import type { RuleItem } from 'async-validator';
4
- import { Options as scrollIntoViewOptions } from 'scroll-into-view-if-needed';
5
- import { BaseFormApi as FormApi, FormState, WithFieldOption } from '@douyinfe/semi-foundation/lib/es/form/interface';
6
- import { SelectProps } from '../select/index';
4
+ import type { Options as scrollIntoViewOptions } from 'scroll-into-view-if-needed';
5
+ import type { BaseFormApi as FormApi, FormState, WithFieldOption, AllErrors } from '@douyinfe/semi-foundation/lib/es/form/interface';
6
+ import type { SelectProps } from '../select/index';
7
7
  import Option from '../select/option';
8
8
  import OptGroup from '../select/optionGroup';
9
- import { CheckboxProps } from '../checkbox/index';
10
- import { RadioProps } from '../radio/index';
9
+ import type { CheckboxProps } from '../checkbox/index';
10
+ import type { RadioProps } from '../radio/index';
11
11
  import { ReactFieldError as FieldError } from './errorMessage';
12
- import { LabelProps } from './label';
13
- export { FormState, FormApi, WithFieldOption, RuleItem };
12
+ import type { LabelProps } from './label';
13
+ export type { FormState, FormApi, WithFieldOption, RuleItem };
14
14
  export declare type CommonFieldProps = {
15
15
  /** Field is required (except Form. Checkbox within the Group, Form. Radio) */
16
16
  field: string;
@@ -81,19 +81,19 @@ export interface FormFCChild<K extends Record<string, any> = any> {
81
81
  values: K;
82
82
  formApi: FormApi<K>;
83
83
  }
84
- export interface BaseFormProps extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'children' | 'onChange'> {
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: Record<string, any>) => void;
87
- onSubmitFail?: (errors: Record<string, FieldError>, values: any) => void;
86
+ onSubmit?: (values: Values) => void;
87
+ onSubmitFail?: (errors: Record<keyof Values, FieldError>, values: Partial<Values>) => void;
88
88
  onReset?: () => void;
89
- onValueChange?: (values: Record<string, any>, changedValue: Record<string, any>) => void;
90
- onChange?: (formState: FormState) => void;
91
- validateFields?: (values: Record<string, any>) => string | Record<string, any>;
89
+ onValueChange?: (values: Values, changedValue: Partial<Values>) => void;
90
+ onChange?: (formState: FormState<Values>) => void;
91
+ validateFields?: (values: Values) => string | Partial<AllErrors<Values>>;
92
92
  /** Use this if you want to populate the form with initial values. */
93
- initValues?: Record<string, any>;
93
+ initValues?: Values;
94
94
  id?: string;
95
95
  /** getFormApi will be call once when Form mounted, u can save formApi reference in your component */
96
- getFormApi?: (formApi: FormApi) => void;
96
+ getFormApi?: (formApi: FormApi<Values>) => void;
97
97
  style?: React.CSSProperties;
98
98
  className?: string;
99
99
  layout?: 'horizontal' | 'vertical';
@@ -1,4 +1,5 @@
1
1
  import _isObject from "lodash/isObject";
2
+ import _isBoolean from "lodash/isBoolean";
2
3
 
3
4
  /* eslint-disable jsx-a11y/click-events-have-key-events */
4
5
 
@@ -131,6 +132,16 @@ export default class Image extends BaseComponent {
131
132
  willUpdateStates.loadStatus = "loading";
132
133
  }
133
134
 
135
+ if (_isObject(props.preview)) {
136
+ const {
137
+ visible
138
+ } = props.preview;
139
+
140
+ if (_isBoolean(visible)) {
141
+ willUpdateStates.previewVisible = visible;
142
+ }
143
+ }
144
+
134
145
  return willUpdateStates;
135
146
  }
136
147
 
@@ -60,7 +60,7 @@ export interface PreviewProps extends BaseProps {
60
60
  onPrev?: (index: number) => void;
61
61
  onNext?: (index: number) => void;
62
62
  onRatioChange?: (type: RatioType) => void;
63
- onRotateChange?: (angle: number) => void;
63
+ onRotateLeft?: (angle: number) => void;
64
64
  onDownload?: (src: string, index: number) => void;
65
65
  }
66
66
  export interface MenuProps {
@@ -44,8 +44,8 @@ export default class Preview extends BaseComponent<PreviewProps, PreviewState> {
44
44
  onPrev: PropTypes.Requireable<(...args: any[]) => any>;
45
45
  onNext: PropTypes.Requireable<(...args: any[]) => any>;
46
46
  onDownload: PropTypes.Requireable<(...args: any[]) => any>;
47
+ onRotateLeft: PropTypes.Requireable<(...args: any[]) => any>;
47
48
  onRatioChange: PropTypes.Requireable<(...args: any[]) => any>;
48
- onRotateChange: PropTypes.Requireable<(...args: any[]) => any>;
49
49
  };
50
50
  static defaultProps: {
51
51
  src: any[];
@@ -220,8 +220,8 @@ Preview.propTypes = {
220
220
  onPrev: PropTypes.func,
221
221
  onNext: PropTypes.func,
222
222
  onDownload: PropTypes.func,
223
- onRatioChange: PropTypes.func,
224
- onRotateChange: PropTypes.func
223
+ onRotateLeft: PropTypes.func,
224
+ onRatioChange: PropTypes.func
225
225
  };
226
226
  Preview.defaultProps = {
227
227
  src: [],
@@ -13,7 +13,7 @@ export default class PreviewImage extends BaseComponent<PreviewImageProps, Previ
13
13
  zoomStep: PropTypes.Requireable<number>;
14
14
  zoom: PropTypes.Requireable<number>;
15
15
  ratio: PropTypes.Requireable<string>;
16
- disableDownload: PropTypes.Requireable<number>;
16
+ disableDownload: PropTypes.Requireable<boolean>;
17
17
  clickZoom: PropTypes.Requireable<number>;
18
18
  setRatio: PropTypes.Requireable<(...args: any[]) => any>;
19
19
  onZoom: PropTypes.Requireable<(...args: any[]) => any>;
@@ -223,7 +223,7 @@ PreviewImage.propTypes = {
223
223
  zoomStep: PropTypes.number,
224
224
  zoom: PropTypes.number,
225
225
  ratio: PropTypes.string,
226
- disableDownload: PropTypes.number,
226
+ disableDownload: PropTypes.bool,
227
227
  clickZoom: PropTypes.number,
228
228
  setRatio: PropTypes.func,
229
229
  onZoom: PropTypes.func,
@@ -45,7 +45,7 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
45
45
  onNext: PropTypes.Requireable<(...args: any[]) => any>;
46
46
  onDownload: PropTypes.Requireable<(...args: any[]) => any>;
47
47
  onRatioChange: PropTypes.Requireable<(...args: any[]) => any>;
48
- onRotateChange: PropTypes.Requireable<(...args: any[]) => any>;
48
+ onRotateLeft: PropTypes.Requireable<(...args: any[]) => any>;
49
49
  };
50
50
  static defaultProps: {
51
51
  showTooltip: boolean;