@douyinfe/semi-ui 2.57.0-beta.0 → 2.57.1-alpha.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 (40) hide show
  1. package/README.md +1 -1
  2. package/dist/css/semi.css +21 -3
  3. package/dist/css/semi.min.css +1 -1
  4. package/dist/umd/semi-ui.js +99 -87
  5. package/dist/umd/semi-ui.js.map +1 -1
  6. package/dist/umd/semi-ui.min.js +1 -1
  7. package/dist/umd/semi-ui.min.js.map +1 -1
  8. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
  9. package/lib/cjs/form/baseForm.d.ts +2 -2
  10. package/lib/cjs/form/field.d.ts +2 -2
  11. package/lib/cjs/form/hoc/withField.js +11 -4
  12. package/lib/cjs/image/image.js +7 -3
  13. package/lib/cjs/image/interface.d.ts +2 -0
  14. package/lib/cjs/input/index.js +3 -3
  15. package/lib/cjs/input/textarea.js +4 -2
  16. package/lib/cjs/modal/confirm.d.ts +9 -9
  17. package/lib/cjs/slider/index.js +4 -2
  18. package/lib/cjs/table/Body/BaseRow.js +1 -1
  19. package/lib/cjs/table/interface.d.ts +1 -1
  20. package/lib/cjs/tagInput/index.js +8 -3
  21. package/lib/cjs/tooltip/index.js +10 -1
  22. package/lib/cjs/treeSelect/index.js +44 -39
  23. package/lib/cjs/typography/title.d.ts +1 -1
  24. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  25. package/lib/es/form/baseForm.d.ts +2 -2
  26. package/lib/es/form/field.d.ts +2 -2
  27. package/lib/es/form/hoc/withField.js +11 -4
  28. package/lib/es/image/image.js +7 -3
  29. package/lib/es/image/interface.d.ts +2 -0
  30. package/lib/es/input/index.js +3 -3
  31. package/lib/es/input/textarea.js +4 -2
  32. package/lib/es/modal/confirm.d.ts +9 -9
  33. package/lib/es/slider/index.js +4 -2
  34. package/lib/es/table/Body/BaseRow.js +1 -1
  35. package/lib/es/table/interface.d.ts +1 -1
  36. package/lib/es/tagInput/index.js +8 -3
  37. package/lib/es/tooltip/index.js +11 -2
  38. package/lib/es/treeSelect/index.js +44 -39
  39. package/lib/es/typography/title.d.ts +1 -1
  40. package/package.json +8 -8
@@ -23,6 +23,8 @@ export interface ImageProps extends BaseProps {
23
23
  children?: ReactNode;
24
24
  imageID?: number;
25
25
  setDownloadName?: (src: string) => string;
26
+ imgStyle?: React.CSSProperties;
27
+ imgCls?: string;
26
28
  }
27
29
  export interface PreviewProps extends BaseProps {
28
30
  visible?: boolean;
@@ -63,9 +63,10 @@ class Input extends BaseComponent {
63
63
  this.handlePreventMouseDown = e => {
64
64
  this.foundation.handlePreventMouseDown(e);
65
65
  };
66
+ const initValue = 'value' in props ? props.value : props.defaultValue;
66
67
  this.state = {
67
- value: '',
68
- cachedValue: null,
68
+ value: initValue,
69
+ cachedValue: props.value,
69
70
  disabled: false,
70
71
  props: {},
71
72
  isFocus: false,
@@ -138,7 +139,6 @@ class Input extends BaseComponent {
138
139
  componentDidMount() {
139
140
  // autofocus is changed from the original support of input to the support of manually calling the focus method,
140
141
  // so that preventScroll can still take effect under the setting of autofocus
141
- this.foundation.init();
142
142
  const {
143
143
  disabled,
144
144
  autoFocus,
@@ -39,12 +39,14 @@ class TextArea extends BaseComponent {
39
39
  forwardRef.current = node;
40
40
  }
41
41
  };
42
+ const initValue = 'value' in props ? props.value : props.defaultValue;
42
43
  this.state = {
43
- value: '',
44
+ value: initValue,
44
45
  isFocus: false,
45
46
  isHover: false,
46
47
  height: 0,
47
- minLength: props.minLength
48
+ minLength: props.minLength,
49
+ cachedValue: props.value
48
50
  };
49
51
  this.focusing = false;
50
52
  this.foundation = new TextAreaFoundation(this.adapter);
@@ -146,19 +146,19 @@ export declare function withWarning(props: ModalReactProps): {
146
146
  type: "warning";
147
147
  };
148
148
  export declare function withError(props: ModalReactProps): {
149
- title?: React.ReactNode;
150
149
  children?: React.ReactNode;
151
- size?: import("@douyinfe/semi-foundation/lib/es/modal/modalFoundation").Size;
152
150
  style?: React.CSSProperties;
153
151
  className?: string;
154
- motion?: boolean;
155
152
  getPopupContainer?: () => HTMLElement;
156
153
  footer?: React.ReactNode;
157
154
  header?: React.ReactNode;
155
+ title?: React.ReactNode;
158
156
  direction?: any;
159
157
  mask?: boolean;
160
158
  visible?: boolean;
161
159
  zIndex?: number;
160
+ size?: import("@douyinfe/semi-foundation/lib/es/modal/modalFoundation").Size;
161
+ motion?: boolean;
162
162
  width?: string | number;
163
163
  height?: string | number;
164
164
  content?: React.ReactNode;
@@ -209,13 +209,10 @@ export declare function withError(props: ModalReactProps): {
209
209
  onMouseEnter?: React.MouseEventHandler<HTMLButtonElement>;
210
210
  onMouseLeave?: React.MouseEventHandler<HTMLButtonElement>;
211
211
  'aria-label'?: string;
212
- title?: string;
213
- name?: string;
214
212
  value?: string | number | readonly string[];
215
- onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
216
- onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
217
213
  form?: string;
218
214
  slot?: string;
215
+ title?: string;
219
216
  prefix?: string;
220
217
  dangerouslySetInnerHTML?: {
221
218
  __html: string | TrustedHTML;
@@ -370,7 +367,9 @@ export declare function withError(props: ModalReactProps): {
370
367
  onScrollCapture?: React.UIEventHandler<HTMLButtonElement>;
371
368
  onWheel?: React.WheelEventHandler<HTMLButtonElement>;
372
369
  onWheelCapture?: React.WheelEventHandler<HTMLButtonElement>;
370
+ onAnimationStart?: React.AnimationEventHandler<HTMLButtonElement>;
373
371
  onAnimationStartCapture?: React.AnimationEventHandler<HTMLButtonElement>;
372
+ onAnimationEnd?: React.AnimationEventHandler<HTMLButtonElement>;
374
373
  onAnimationEndCapture?: React.AnimationEventHandler<HTMLButtonElement>;
375
374
  onAnimationIteration?: React.AnimationEventHandler<HTMLButtonElement>;
376
375
  onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement>;
@@ -384,6 +383,7 @@ export declare function withError(props: ModalReactProps): {
384
383
  suppressHydrationWarning?: boolean;
385
384
  accessKey?: string;
386
385
  autoFocus?: boolean;
386
+ name?: string;
387
387
  contextMenu?: string;
388
388
  dir?: string;
389
389
  draggable?: boolean | "true" | "false";
@@ -391,7 +391,7 @@ export declare function withError(props: ModalReactProps): {
391
391
  translate?: "no" | "yes";
392
392
  role?: React.AriaRole;
393
393
  contentEditable?: "inherit" | (boolean | "true" | "false");
394
- inputMode?: "search" | "none" | "text" | "email" | "tel" | "url" | "numeric" | "decimal";
394
+ inputMode?: "search" | "text" | "none" | "email" | "tel" | "url" | "numeric" | "decimal";
395
395
  nonce?: string;
396
396
  tabIndex?: number;
397
397
  content?: string;
@@ -425,7 +425,7 @@ export declare function withError(props: ModalReactProps): {
425
425
  is?: string;
426
426
  'aria-activedescendant'?: string;
427
427
  'aria-atomic'?: boolean | "true" | "false";
428
- 'aria-autocomplete'?: "both" | "none" | "list" | "inline";
428
+ 'aria-autocomplete'?: "none" | "list" | "both" | "inline";
429
429
  'aria-busy'?: boolean | "true" | "false";
430
430
  'aria-checked'?: boolean | "true" | "false" | "mixed";
431
431
  'aria-colcount'?: number;
@@ -385,11 +385,13 @@ export default class Slider extends BaseComponent {
385
385
  var _this = this;
386
386
  return Object.assign(Object.assign({}, super.adapter), {
387
387
  getSliderLengths: () => {
388
+ var _a;
388
389
  if (this.sliderEl && this.sliderEl.current) {
389
390
  const rect = this.sliderEl.current.getBoundingClientRect();
391
+ const offsetParentRect = (_a = this.sliderEl.current.offsetParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
390
392
  const offset = {
391
- x: this.sliderEl.current.offsetLeft,
392
- y: this.sliderEl.current.offsetTop
393
+ x: offsetParentRect ? rect.left - offsetParentRect.left : this.sliderEl.current.offsetLeft,
394
+ y: offsetParentRect ? rect.top - offsetParentRect.top : this.sliderEl.current.offsetTop
393
395
  };
394
396
  return {
395
397
  sliderX: offset.x,
@@ -271,7 +271,7 @@ export default class TableRow extends BaseComponent {
271
271
  rowProps = __rest(_a, ["className", "style"]);
272
272
  this.adapter.setCache('customRowProps', Object.assign({}, rowProps));
273
273
  const baseRowStyle = Object.assign(Object.assign({}, style), customStyle);
274
- const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? replaceClassName : classnames(className, `${prefixCls}-row`, {
274
+ const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? classnames(replaceClassName, customClassName) : classnames(className, `${prefixCls}-row`, {
275
275
  [`${prefixCls}-row-selected`]: selected,
276
276
  [`${prefixCls}-row-expanded`]: expanded,
277
277
  [`${prefixCls}-row-hovered`]: hovered,
@@ -173,7 +173,7 @@ export interface OnRowReturnObject extends Omit<React.DetailedHTMLProps<React.HT
173
173
  style?: React.CSSProperties;
174
174
  onClick?: (e: React.MouseEvent) => void;
175
175
  }
176
- export interface OnGroupedRowReturnObject extends Omit<React.HTMLAttributes<HTMLTableRowElement>, 'className'> {
176
+ export interface OnGroupedRowReturnObject extends React.HTMLAttributes<HTMLTableRowElement> {
177
177
  [x: string]: any;
178
178
  style?: React.CSSProperties;
179
179
  onClick?: (e: React.MouseEvent) => void;
@@ -441,9 +441,12 @@ class TagInput extends BaseComponent {
441
441
  className,
442
442
  disabled,
443
443
  placeholder,
444
- validateStatus
444
+ validateStatus,
445
+ prefix,
446
+ insetLabel,
447
+ suffix
445
448
  } = _a,
446
- rest = __rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus"]);
449
+ rest = __rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus", "prefix", "insetLabel", "suffix"]);
447
450
  const {
448
451
  focusing,
449
452
  hovering,
@@ -458,7 +461,9 @@ class TagInput extends BaseComponent {
458
461
  [`${prefixCls}-error`]: validateStatus === 'error',
459
462
  [`${prefixCls}-warning`]: validateStatus === 'warning',
460
463
  [`${prefixCls}-small`]: size === 'small',
461
- [`${prefixCls}-large`]: size === 'large'
464
+ [`${prefixCls}-large`]: size === 'large',
465
+ [`${prefixCls}-with-prefix`]: !!prefix || !!insetLabel,
466
+ [`${prefixCls}-with-suffix`]: !!suffix
462
467
  });
463
468
  const inputCls = cls(`${prefixCls}-wrapper-input`, `${prefixCls}-wrapper-input-${size}`);
464
469
  const wrapperCls = cls(`${prefixCls}-wrapper`);
@@ -15,7 +15,7 @@ var __rest = this && this.__rest || function (s, e) {
15
15
  return t;
16
16
  };
17
17
  import React, { isValidElement, cloneElement } from 'react';
18
- import ReactDOM from 'react-dom';
18
+ import ReactDOM, { findDOMNode } from 'react-dom';
19
19
  import classNames from 'classnames';
20
20
  import PropTypes from 'prop-types';
21
21
  import { BASE_CLASS_PREFIX } from '@douyinfe/semi-foundation/lib/es/base/constants';
@@ -28,7 +28,7 @@ import { getUuidShort } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
28
28
  import '@douyinfe/semi-foundation/lib/es/tooltip/tooltip.css';
29
29
  import BaseComponent from '../_base/baseComponent';
30
30
  import { isHTMLElement } from '../_base/reactUtils';
31
- import { getActiveElement, getDefaultPropsFromGlobalConfig, getFocusableElements, stopPropagation } from '../_utils';
31
+ import { getActiveElement, getDefaultPropsFromGlobalConfig, getFocusableElements, runAfterTicks, stopPropagation } from '../_utils';
32
32
  import Portal from '../_portal/index';
33
33
  import ConfigContext from '../configProvider/context';
34
34
  import TriangleArrow from './TriangleArrow';
@@ -536,6 +536,15 @@ export default class Tooltip extends BaseComponent {
536
536
  this.mounted = true;
537
537
  this.getPopupContainer = this.props.getPopupContainer || this.context.getPopupContainer || defaultGetContainer;
538
538
  this.foundation.init();
539
+ runAfterTicks(() => {
540
+ let triggerEle = this.triggerEl.current;
541
+ if (triggerEle) {
542
+ if (!(triggerEle instanceof HTMLElement)) {
543
+ triggerEle = findDOMNode(triggerEle);
544
+ }
545
+ }
546
+ this.foundation.updateStateIfCursorOnTrigger(triggerEle);
547
+ }, 1);
539
548
  }
540
549
  componentWillUnmount() {
541
550
  this.mounted = false;
@@ -358,15 +358,17 @@ class TreeSelect extends BaseComponent {
358
358
  leafOnly,
359
359
  searchPosition,
360
360
  triggerRender,
361
- borderless
361
+ borderless,
362
+ checkRelation
362
363
  } = _a,
363
- rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless"]);
364
+ rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless", "checkRelation"]);
364
365
  const {
365
366
  inputValue,
366
367
  selectedKeys,
367
368
  checkedKeys,
368
369
  keyEntities,
369
- isFocus
370
+ isFocus,
371
+ realCheckedKeys
370
372
  } = this.state;
371
373
  const filterable = Boolean(filterTreeNode);
372
374
  const useCustomTrigger = typeof triggerRender === 'function';
@@ -394,31 +396,45 @@ class TreeSelect extends BaseComponent {
394
396
  [`${prefixcls}-with-suffix`]: suffix,
395
397
  [`${prefixcls}-with-suffix`]: suffix
396
398
  }, className);
397
- const triggerRenderKeys = multiple ? normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true) : selectedKeys;
398
- const inner = useCustomTrigger ? /*#__PURE__*/React.createElement(Trigger, {
399
- inputValue: inputValue,
400
- value: triggerRenderKeys.map(key => _get(keyEntities, [key, 'data'])),
401
- disabled: disabled,
402
- placeholder: placeholder,
403
- onClear: this.handleClear,
404
- componentName: 'TreeSelect',
405
- triggerRender: triggerRender,
406
- componentProps: Object.assign({}, this.props),
407
- onSearch: this.search,
408
- onRemove: this.removeTag
409
- }) : [/*#__PURE__*/React.createElement(Fragment, {
410
- key: 'prefix'
411
- }, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/React.createElement(Fragment, {
412
- key: 'selection'
413
- }, /*#__PURE__*/React.createElement("div", {
414
- className: `${prefixcls}-selection`
415
- }, this.renderSelectContent())), /*#__PURE__*/React.createElement(Fragment, {
416
- key: 'suffix'
417
- }, suffix ? this.renderSuffix() : null), /*#__PURE__*/React.createElement(Fragment, {
418
- key: 'clearBtn'
419
- }, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/React.createElement(Fragment, {
420
- key: 'arrow'
421
- }, this.renderArrow())];
399
+ let inner;
400
+ if (useCustomTrigger) {
401
+ let triggerRenderKeys = [];
402
+ if (multiple) {
403
+ if (checkRelation === 'related') {
404
+ triggerRenderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true);
405
+ } else if (checkRelation === 'unRelated') {
406
+ triggerRenderKeys = [...realCheckedKeys];
407
+ }
408
+ } else {
409
+ triggerRenderKeys = selectedKeys;
410
+ }
411
+ inner = /*#__PURE__*/React.createElement(Trigger, {
412
+ inputValue: inputValue,
413
+ value: triggerRenderKeys.map(key => _get(keyEntities, [key, 'data'])),
414
+ disabled: disabled,
415
+ placeholder: placeholder,
416
+ onClear: this.handleClear,
417
+ componentName: 'TreeSelect',
418
+ triggerRender: triggerRender,
419
+ componentProps: Object.assign({}, this.props),
420
+ onSearch: this.search,
421
+ onRemove: this.removeTag
422
+ });
423
+ } else {
424
+ inner = [/*#__PURE__*/React.createElement(Fragment, {
425
+ key: 'prefix'
426
+ }, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/React.createElement(Fragment, {
427
+ key: 'selection'
428
+ }, /*#__PURE__*/React.createElement("div", {
429
+ className: `${prefixcls}-selection`
430
+ }, this.renderSelectContent())), /*#__PURE__*/React.createElement(Fragment, {
431
+ key: 'suffix'
432
+ }, suffix ? this.renderSuffix() : null), /*#__PURE__*/React.createElement(Fragment, {
433
+ key: 'clearBtn'
434
+ }, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/React.createElement(Fragment, {
435
+ key: 'arrow'
436
+ }, this.renderArrow())];
437
+ }
422
438
  const tabIndex = disabled ? null : 0;
423
439
  /**
424
440
  * Reasons for disabling the a11y eslint rule:
@@ -882,7 +898,6 @@ class TreeSelect extends BaseComponent {
882
898
  };
883
899
  }
884
900
  static getDerivedStateFromProps(props, prevState) {
885
- var _a;
886
901
  const {
887
902
  prevProps,
888
903
  rePosKey
@@ -945,16 +960,6 @@ class TreeSelect extends BaseComponent {
945
960
  newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
946
961
  } else if (!prevProps && props.value) {
947
962
  newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
948
- } else if (!isExpandControlled && needUpdateTreeData && props.value) {
949
- // 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
950
- // 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
951
- // 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
952
- // When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
953
- // If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
954
- // So there is no need to recalculate expandedKeys at this time, because the expanded item has been added to expandedKeys when the expand button is clicked
955
- if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
956
- newState.expandedKeys = calcExpandedKeysForValues(props.value, keyEntities, props.multiple, valueEntities);
957
- }
958
963
  }
959
964
  if (!newState.expandedKeys) {
960
965
  delete newState.expandedKeys;
@@ -60,7 +60,7 @@ export default class Title extends PureComponent<TitleProps> {
60
60
  underline: PropTypes.Requireable<boolean>;
61
61
  strong: PropTypes.Requireable<boolean>;
62
62
  type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
63
- heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 5 | 6>;
63
+ heading: PropTypes.Requireable<4 | 2 | 1 | 3 | 5 | 6>;
64
64
  style: PropTypes.Requireable<object>;
65
65
  className: PropTypes.Requireable<string>;
66
66
  component: PropTypes.Requireable<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.57.0-beta.0",
3
+ "version": "2.57.1-alpha.0",
4
4
  "description": "A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -20,12 +20,12 @@
20
20
  "@dnd-kit/core": "^6.0.8",
21
21
  "@dnd-kit/sortable": "^7.0.2",
22
22
  "@dnd-kit/utilities": "^3.2.1",
23
- "@douyinfe/semi-animation": "2.57.0-beta.0",
24
- "@douyinfe/semi-animation-react": "2.57.0-beta.0",
25
- "@douyinfe/semi-foundation": "2.57.0-beta.0",
26
- "@douyinfe/semi-icons": "2.57.0-beta.0",
27
- "@douyinfe/semi-illustrations": "2.57.0-beta.0",
28
- "@douyinfe/semi-theme-default": "2.57.0-beta.0",
23
+ "@douyinfe/semi-animation": "2.57.1-alpha.0",
24
+ "@douyinfe/semi-animation-react": "2.57.1-alpha.0",
25
+ "@douyinfe/semi-foundation": "2.57.1-alpha.0",
26
+ "@douyinfe/semi-icons": "2.57.1-alpha.0",
27
+ "@douyinfe/semi-illustrations": "2.57.1-alpha.0",
28
+ "@douyinfe/semi-theme-default": "2.57.1-alpha.0",
29
29
  "async-validator": "^3.5.0",
30
30
  "classnames": "^2.2.6",
31
31
  "copy-text-to-clipboard": "^2.1.1",
@@ -75,7 +75,7 @@
75
75
  ],
76
76
  "author": "",
77
77
  "license": "MIT",
78
- "gitHead": "416d798f9c062670475631c9ffce2172e7abfd60",
78
+ "gitHead": "d911c08d3b5e459aa328fa56a426526e05ef3ce8",
79
79
  "devDependencies": {
80
80
  "@babel/plugin-proposal-decorators": "^7.15.8",
81
81
  "@babel/plugin-transform-runtime": "^7.15.8",