@douyinfe/semi-foundation 2.51.3 → 2.51.4

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.
@@ -15,7 +15,8 @@ import {
15
15
  normalizedArr,
16
16
  isValid,
17
17
  calcMergeType,
18
- getKeysByValuePath
18
+ getKeysByValuePath,
19
+ getKeyByPos
19
20
  } from './util';
20
21
  import { strings } from './constants';
21
22
  import isEnterPress from '../utils/isEnterPress';
@@ -56,6 +57,8 @@ export interface BasicEntity {
56
57
  parentKey?: string;
57
58
  /* key path */
58
59
  path: Array<string>;
60
+ /* pos in treeData */
61
+ pos: string;
59
62
  /* value path */
60
63
  valuePath: Array<string>
61
64
  }
@@ -1026,17 +1029,20 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
1026
1029
  this._adapter.notifyListScroll(e, { panelIndex: ind, activeNode: data });
1027
1030
  }
1028
1031
 
1029
- handleTagRemove(e: any, tagValuePath: string[]) {
1032
+ handleTagRemoveByKey = (key: string) => {
1030
1033
  const { keyEntities } = this.getStates();
1031
1034
  const { disabled } = this.getProps();
1032
1035
  if (disabled) {
1033
1036
  /* istanbul ignore next */
1034
1037
  return;
1035
1038
  }
1036
- const removedItem = (Object.values(keyEntities) as BasicEntity[])
1037
- .filter(item => isEqual(item.valuePath, tagValuePath))[0];
1038
- !isEmpty(removedItem) &&
1039
- !removedItem.data.disabled &&
1040
- this._handleMultipleSelect(removedItem);
1039
+ const removedItem = keyEntities[key] ?? {};
1040
+ !removedItem?.data?.disable && this._handleMultipleSelect(removedItem);
1041
+ }
1042
+
1043
+ handleTagRemoveInTrigger = (pos: string) => {
1044
+ const { treeData } = this.getStates();
1045
+ const key = getKeyByPos(pos, treeData);
1046
+ this.handleTagRemoveByKey(key);
1041
1047
  }
1042
1048
  }
package/cascader/util.ts CHANGED
@@ -31,10 +31,12 @@ function traverseDataNodes(treeNodes: any, callback: any) {
31
31
  // Process node if is not root
32
32
  if (node) {
33
33
  const key = parent ? `${parent.key}${VALUE_SPLIT}${node.value}` : node.value;
34
+ const pos = parent ? getPosition(parent.pos, ind) : `${ind}`;
34
35
  item = {
35
36
  data: { ...node },
36
37
  ind,
37
38
  key,
39
+ pos,
38
40
  level: parent ? parent.level + 1 : 0,
39
41
  parentKey: parent ? parent.key : null,
40
42
  path: parent ? [...parent.path, key] : [key],
@@ -74,6 +76,17 @@ export function getValuePathByKey(key: string) {
74
76
  return key.split(VALUE_SPLIT);
75
77
  }
76
78
 
79
+ export function getKeyByPos(pos: string, treeData: any) {
80
+ const posArr = pos.split('-').map(item => Number(item));
81
+ let resultData = treeData;
82
+ let valuePath = [];
83
+ posArr.forEach((item, index) => {
84
+ resultData = index === 0 ? resultData[item] : resultData?.children?.[item];
85
+ valuePath.push(resultData?.value);
86
+ });
87
+ return getKeyByValuePath(valuePath);
88
+ }
89
+
77
90
  export function convertDataToEntities(dataNodes: any) {
78
91
  const keyEntities: any = {};
79
92
 
@@ -18,6 +18,7 @@ import type { Type, DateInputFoundationProps, InsetInputValue } from './inputFou
18
18
  import type { MonthsGridFoundationProps } from './monthsGridFoundation';
19
19
  import type { WeekStartNumber } from './_utils/getMonthTable';
20
20
  import isValidTimeZone from './_utils/isValidTimeZone';
21
+ import warning from '../utils/warning';
21
22
 
22
23
  export type ValidateStatus = ArrayElement<typeof strings.STATUS>;
23
24
  export type InputSize = ArrayElement<typeof strings.SIZE_SET>;
@@ -291,6 +292,8 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
291
292
  parsedV = zonedTimeToUtc(parsedV, prevTimeZone);
292
293
  }
293
294
  result.push(isValidTimeZone(timeZone) ? utcToZonedTime(parsedV, timeZone) : parsedV);
295
+ } else {
296
+ warning(true, `[Semi DatePicker] value cannot be parsed, value: ${String(v)}`);
294
297
  }
295
298
  }
296
299
  }
@@ -24,6 +24,7 @@ export interface BasicEntity {
24
24
  parent?: BasicEntity;
25
25
  parentKey?: string;
26
26
  path: Array<string>;
27
+ pos: string;
27
28
  valuePath: Array<string>;
28
29
  }
29
30
  export interface BasicCascaderData {
@@ -239,16 +240,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
239
240
  * @param {boolean} curCheckedStatus checked status of node
240
241
  */
241
242
  calcCheckedKeys(key: string, curCheckedStatus: boolean): {
242
- checkedKeys: Set<string>; /**
243
- * If selectedKeys does not meet the update conditions,
244
- * and state.selectedKeys is the same as selectedKeys
245
- * at this time, state.selectedKeys should be cleared.
246
- * A typical scenario is:
247
- * The originally selected node is the leaf node, but
248
- * after props.treeData is dynamically updated, the node
249
- * is a non-leaf node. At this point, selectedKeys should
250
- * be cleared.
251
- */
243
+ checkedKeys: Set<string>;
252
244
  halfCheckedKeys: Set<string>;
253
245
  };
254
246
  handleInputChange(sugInput: string): void;
@@ -260,5 +252,6 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
260
252
  getRenderData(): BasicEntity[] | BasicData[];
261
253
  getFilteredData(): BasicData[];
262
254
  handleListScroll(e: any, ind: number): void;
263
- handleTagRemove(e: any, tagValuePath: string[]): void;
255
+ handleTagRemoveByKey: (key: string) => void;
256
+ handleTagRemoveInTrigger: (pos: string) => void;
264
257
  }
@@ -29,6 +29,28 @@ class CascaderFoundation extends _foundation.default {
29
29
  isSearching: false
30
30
  });
31
31
  };
32
+ this.handleTagRemoveByKey = key => {
33
+ var _a, _b;
34
+ const {
35
+ keyEntities
36
+ } = this.getStates();
37
+ const {
38
+ disabled
39
+ } = this.getProps();
40
+ if (disabled) {
41
+ /* istanbul ignore next */
42
+ return;
43
+ }
44
+ const removedItem = (_a = keyEntities[key]) !== null && _a !== void 0 ? _a : {};
45
+ !((_b = removedItem === null || removedItem === void 0 ? void 0 : removedItem.data) === null || _b === void 0 ? void 0 : _b.disable) && this._handleMultipleSelect(removedItem);
46
+ };
47
+ this.handleTagRemoveInTrigger = pos => {
48
+ const {
49
+ treeData
50
+ } = this.getStates();
51
+ const key = (0, _util.getKeyByPos)(pos, treeData);
52
+ this.handleTagRemoveByKey(key);
53
+ };
32
54
  }
33
55
  init() {
34
56
  const isOpen = this.getProp('open') || this.getProp('defaultOpen');
@@ -862,19 +884,5 @@ class CascaderFoundation extends _foundation.default {
862
884
  activeNode: data
863
885
  });
864
886
  }
865
- handleTagRemove(e, tagValuePath) {
866
- const {
867
- keyEntities
868
- } = this.getStates();
869
- const {
870
- disabled
871
- } = this.getProps();
872
- if (disabled) {
873
- /* istanbul ignore next */
874
- return;
875
- }
876
- const removedItem = Object.values(keyEntities).filter(item => (0, _isEqual2.default)(item.valuePath, tagValuePath))[0];
877
- !(0, _isEmpty2.default)(removedItem) && !removedItem.data.disabled && this._handleMultipleSelect(removedItem);
878
- }
879
887
  }
880
888
  exports.default = CascaderFoundation;
@@ -3,5 +3,6 @@ export declare function normalizedArr(val: any): any[];
3
3
  export declare function getKeysByValuePath(valuePath: (string | number)[][] | (string | number)[]): string[];
4
4
  export declare function getKeyByValuePath(valuePath: (string | number)[]): string;
5
5
  export declare function getValuePathByKey(key: string): string[];
6
+ export declare function getKeyByPos(pos: string, treeData: any): string;
6
7
  export declare function convertDataToEntities(dataNodes: any): any;
7
8
  export declare function calcMergeType(autoMergeValue: boolean, leafOnly: boolean): string;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.calcMergeType = calcMergeType;
7
7
  exports.convertDataToEntities = convertDataToEntities;
8
+ exports.getKeyByPos = getKeyByPos;
8
9
  exports.getKeyByValuePath = getKeyByValuePath;
9
10
  exports.getKeysByValuePath = getKeysByValuePath;
10
11
  exports.getValuePathByKey = getValuePathByKey;
@@ -37,10 +38,12 @@ function traverseDataNodes(treeNodes, callback) {
37
38
  // Process node if is not root
38
39
  if (node) {
39
40
  const key = parent ? `${parent.key}${_constants.VALUE_SPLIT}${node.value}` : node.value;
41
+ const pos = parent ? getPosition(parent.pos, ind) : `${ind}`;
40
42
  item = {
41
43
  data: Object.assign({}, node),
42
44
  ind,
43
45
  key,
46
+ pos,
44
47
  level: parent ? parent.level + 1 : 0,
45
48
  parentKey: parent ? parent.key : null,
46
49
  path: parent ? [...parent.path, key] : [key],
@@ -73,6 +76,17 @@ function getKeyByValuePath(valuePath) {
73
76
  function getValuePathByKey(key) {
74
77
  return key.split(_constants.VALUE_SPLIT);
75
78
  }
79
+ function getKeyByPos(pos, treeData) {
80
+ const posArr = pos.split('-').map(item => Number(item));
81
+ let resultData = treeData;
82
+ let valuePath = [];
83
+ posArr.forEach((item, index) => {
84
+ var _a;
85
+ resultData = index === 0 ? resultData[item] : (_a = resultData === null || resultData === void 0 ? void 0 : resultData.children) === null || _a === void 0 ? void 0 : _a[item];
86
+ valuePath.push(resultData === null || resultData === void 0 ? void 0 : resultData.value);
87
+ });
88
+ return getKeyByValuePath(valuePath);
89
+ }
76
90
  function convertDataToEntities(dataNodes) {
77
91
  const keyEntities = {};
78
92
  traverseDataNodes(dataNodes, data => {
@@ -21,6 +21,7 @@ var _constants2 = require("../input/constants");
21
21
  var _getInsetInputFormatToken = _interopRequireDefault(require("./_utils/getInsetInputFormatToken"));
22
22
  var _getInsetInputValueFromInsetInputStr = _interopRequireDefault(require("./_utils/getInsetInputValueFromInsetInputStr"));
23
23
  var _isValidTimeZone = _interopRequireDefault(require("./_utils/isValidTimeZone"));
24
+ var _warning = _interopRequireDefault(require("../utils/warning"));
24
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
26
  /**
26
27
  * The datePicker foundation.js is responsible for maintaining the date value and the input box value, as well as the callback of both
@@ -125,6 +126,8 @@ class DatePickerFoundation extends _foundation.default {
125
126
  parsedV = (0, _dateFnsExtra.zonedTimeToUtc)(parsedV, prevTimeZone);
126
127
  }
127
128
  result.push((0, _isValidTimeZone.default)(timeZone) ? (0, _dateFnsExtra.utcToZonedTime)(parsedV, timeZone) : parsedV);
129
+ } else {
130
+ (0, _warning.default)(true, `[Semi DatePicker] value cannot be parsed, value: ${String(v)}`);
128
131
  }
129
132
  }
130
133
  }
@@ -427,6 +427,7 @@ class Tooltip extends _foundation.default {
427
427
  return null;
428
428
  }
429
429
  calcPosStyle(props) {
430
+ var _a;
430
431
  const {
431
432
  spacing,
432
433
  isOverFlow
@@ -477,6 +478,10 @@ class Tooltip extends _foundation.default {
477
478
  const isTriggerNearLeft = middleX - containerRect.left < containerRect.right - middleX;
478
479
  const isTriggerNearTop = middleY - containerRect.top < containerRect.bottom - middleY;
479
480
  const isWrapperWidthOverflow = wrapperRect.width > innerWidth;
481
+ const scaled = Math.abs((wrapperRect === null || wrapperRect === void 0 ? void 0 : wrapperRect.width) - ((_a = this._adapter.getContainer()) === null || _a === void 0 ? void 0 : _a.clientWidth)) > 1;
482
+ if (scaled) {
483
+ SPACING = SPACING * wrapperRect.width / this._adapter.getContainer().clientWidth;
484
+ }
480
485
  switch (position) {
481
486
  case 'top':
482
487
  // left = middleX;
@@ -593,6 +598,12 @@ class Tooltip extends _foundation.default {
593
598
  // Calculate container positioning relative to window
594
599
  left = left - containerRect.left;
595
600
  top = top - containerRect.top;
601
+ if (scaled) {
602
+ left /= wrapperRect.width / this._adapter.getContainer().clientWidth;
603
+ }
604
+ if (scaled) {
605
+ top /= wrapperRect.height / this._adapter.getContainer().clientHeight;
606
+ }
596
607
  /**
597
608
  * container为body时,如果position不为relative或absolute,这时trigger计算出的top/left会根据html定位(initial containing block)
598
609
  * 此时如果body有margin,则计算出的位置相对于body会有问题 fix issue #1368
@@ -24,6 +24,7 @@ export interface BasicEntity {
24
24
  parent?: BasicEntity;
25
25
  parentKey?: string;
26
26
  path: Array<string>;
27
+ pos: string;
27
28
  valuePath: Array<string>;
28
29
  }
29
30
  export interface BasicCascaderData {
@@ -239,16 +240,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
239
240
  * @param {boolean} curCheckedStatus checked status of node
240
241
  */
241
242
  calcCheckedKeys(key: string, curCheckedStatus: boolean): {
242
- checkedKeys: Set<string>; /**
243
- * If selectedKeys does not meet the update conditions,
244
- * and state.selectedKeys is the same as selectedKeys
245
- * at this time, state.selectedKeys should be cleared.
246
- * A typical scenario is:
247
- * The originally selected node is the leaf node, but
248
- * after props.treeData is dynamically updated, the node
249
- * is a non-leaf node. At this point, selectedKeys should
250
- * be cleared.
251
- */
243
+ checkedKeys: Set<string>;
252
244
  halfCheckedKeys: Set<string>;
253
245
  };
254
246
  handleInputChange(sugInput: string): void;
@@ -260,5 +252,6 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
260
252
  getRenderData(): BasicEntity[] | BasicData[];
261
253
  getFilteredData(): BasicData[];
262
254
  handleListScroll(e: any, ind: number): void;
263
- handleTagRemove(e: any, tagValuePath: string[]): void;
255
+ handleTagRemoveByKey: (key: string) => void;
256
+ handleTagRemoveInTrigger: (pos: string) => void;
264
257
  }
@@ -11,7 +11,7 @@ import _get from "lodash/get";
11
11
  import _isEqual from "lodash/isEqual";
12
12
  import BaseFoundation from '../base/foundation';
13
13
  import { filter, findAncestorKeys, calcCheckedKeysForUnchecked, calcCheckedKeysForChecked, calcCheckedKeys, findDescendantKeys, normalizeKeyList } from '../tree/treeUtil';
14
- import { convertDataToEntities, normalizedArr, isValid, calcMergeType, getKeysByValuePath } from './util';
14
+ import { convertDataToEntities, normalizedArr, isValid, calcMergeType, getKeysByValuePath, getKeyByPos } from './util';
15
15
  import { strings } from './constants';
16
16
  import isEnterPress from '../utils/isEnterPress';
17
17
  export default class CascaderFoundation extends BaseFoundation {
@@ -22,6 +22,28 @@ export default class CascaderFoundation extends BaseFoundation {
22
22
  isSearching: false
23
23
  });
24
24
  };
25
+ this.handleTagRemoveByKey = key => {
26
+ var _a, _b;
27
+ const {
28
+ keyEntities
29
+ } = this.getStates();
30
+ const {
31
+ disabled
32
+ } = this.getProps();
33
+ if (disabled) {
34
+ /* istanbul ignore next */
35
+ return;
36
+ }
37
+ const removedItem = (_a = keyEntities[key]) !== null && _a !== void 0 ? _a : {};
38
+ !((_b = removedItem === null || removedItem === void 0 ? void 0 : removedItem.data) === null || _b === void 0 ? void 0 : _b.disable) && this._handleMultipleSelect(removedItem);
39
+ };
40
+ this.handleTagRemoveInTrigger = pos => {
41
+ const {
42
+ treeData
43
+ } = this.getStates();
44
+ const key = getKeyByPos(pos, treeData);
45
+ this.handleTagRemoveByKey(key);
46
+ };
25
47
  }
26
48
  init() {
27
49
  const isOpen = this.getProp('open') || this.getProp('defaultOpen');
@@ -855,18 +877,4 @@ export default class CascaderFoundation extends BaseFoundation {
855
877
  activeNode: data
856
878
  });
857
879
  }
858
- handleTagRemove(e, tagValuePath) {
859
- const {
860
- keyEntities
861
- } = this.getStates();
862
- const {
863
- disabled
864
- } = this.getProps();
865
- if (disabled) {
866
- /* istanbul ignore next */
867
- return;
868
- }
869
- const removedItem = Object.values(keyEntities).filter(item => _isEqual(item.valuePath, tagValuePath))[0];
870
- !_isEmpty(removedItem) && !removedItem.data.disabled && this._handleMultipleSelect(removedItem);
871
- }
872
880
  }
@@ -3,5 +3,6 @@ export declare function normalizedArr(val: any): any[];
3
3
  export declare function getKeysByValuePath(valuePath: (string | number)[][] | (string | number)[]): string[];
4
4
  export declare function getKeyByValuePath(valuePath: (string | number)[]): string;
5
5
  export declare function getValuePathByKey(key: string): string[];
6
+ export declare function getKeyByPos(pos: string, treeData: any): string;
6
7
  export declare function convertDataToEntities(dataNodes: any): any;
7
8
  export declare function calcMergeType(autoMergeValue: boolean, leafOnly: boolean): string;
@@ -24,10 +24,12 @@ function traverseDataNodes(treeNodes, callback) {
24
24
  // Process node if is not root
25
25
  if (node) {
26
26
  const key = parent ? `${parent.key}${VALUE_SPLIT}${node.value}` : node.value;
27
+ const pos = parent ? getPosition(parent.pos, ind) : `${ind}`;
27
28
  item = {
28
29
  data: Object.assign({}, node),
29
30
  ind,
30
31
  key,
32
+ pos,
31
33
  level: parent ? parent.level + 1 : 0,
32
34
  parentKey: parent ? parent.key : null,
33
35
  path: parent ? [...parent.path, key] : [key],
@@ -60,6 +62,17 @@ export function getKeyByValuePath(valuePath) {
60
62
  export function getValuePathByKey(key) {
61
63
  return key.split(VALUE_SPLIT);
62
64
  }
65
+ export function getKeyByPos(pos, treeData) {
66
+ const posArr = pos.split('-').map(item => Number(item));
67
+ let resultData = treeData;
68
+ let valuePath = [];
69
+ posArr.forEach((item, index) => {
70
+ var _a;
71
+ resultData = index === 0 ? resultData[item] : (_a = resultData === null || resultData === void 0 ? void 0 : resultData.children) === null || _a === void 0 ? void 0 : _a[item];
72
+ valuePath.push(resultData === null || resultData === void 0 ? void 0 : resultData.value);
73
+ });
74
+ return getKeyByValuePath(valuePath);
75
+ }
63
76
  export function convertDataToEntities(dataNodes) {
64
77
  const keyEntities = {};
65
78
  traverseDataNodes(dataNodes, data => {
@@ -15,6 +15,7 @@ import { strings as inputStrings } from '../input/constants';
15
15
  import getInsetInputFormatToken from './_utils/getInsetInputFormatToken';
16
16
  import getInsetInputValueFromInsetInputStr from './_utils/getInsetInputValueFromInsetInputStr';
17
17
  import isValidTimeZone from './_utils/isValidTimeZone';
18
+ import warning from '../utils/warning';
18
19
  /**
19
20
  * The datePicker foundation.js is responsible for maintaining the date value and the input box value, as well as the callback of both
20
21
  * task 1. Accept the selected date change, update the date value, and update the input box value according to the date = > Notify the change
@@ -118,6 +119,8 @@ export default class DatePickerFoundation extends BaseFoundation {
118
119
  parsedV = zonedTimeToUtc(parsedV, prevTimeZone);
119
120
  }
120
121
  result.push(isValidTimeZone(timeZone) ? utcToZonedTime(parsedV, timeZone) : parsedV);
122
+ } else {
123
+ warning(true, `[Semi DatePicker] value cannot be parsed, value: ${String(v)}`);
121
124
  }
122
125
  }
123
126
  }
@@ -420,6 +420,7 @@ export default class Tooltip extends BaseFoundation {
420
420
  return null;
421
421
  }
422
422
  calcPosStyle(props) {
423
+ var _a;
423
424
  const {
424
425
  spacing,
425
426
  isOverFlow
@@ -470,6 +471,10 @@ export default class Tooltip extends BaseFoundation {
470
471
  const isTriggerNearLeft = middleX - containerRect.left < containerRect.right - middleX;
471
472
  const isTriggerNearTop = middleY - containerRect.top < containerRect.bottom - middleY;
472
473
  const isWrapperWidthOverflow = wrapperRect.width > innerWidth;
474
+ const scaled = Math.abs((wrapperRect === null || wrapperRect === void 0 ? void 0 : wrapperRect.width) - ((_a = this._adapter.getContainer()) === null || _a === void 0 ? void 0 : _a.clientWidth)) > 1;
475
+ if (scaled) {
476
+ SPACING = SPACING * wrapperRect.width / this._adapter.getContainer().clientWidth;
477
+ }
473
478
  switch (position) {
474
479
  case 'top':
475
480
  // left = middleX;
@@ -586,6 +591,12 @@ export default class Tooltip extends BaseFoundation {
586
591
  // Calculate container positioning relative to window
587
592
  left = left - containerRect.left;
588
593
  top = top - containerRect.top;
594
+ if (scaled) {
595
+ left /= wrapperRect.width / this._adapter.getContainer().clientWidth;
596
+ }
597
+ if (scaled) {
598
+ top /= wrapperRect.height / this._adapter.getContainer().clientHeight;
599
+ }
589
600
  /**
590
601
  * container为body时,如果position不为relative或absolute,这时trigger计算出的top/left会根据html定位(initial containing block)
591
602
  * 此时如果body有margin,则计算出的位置相对于body会有问题 fix issue #1368
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.51.3",
3
+ "version": "2.51.4",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.51.3",
10
+ "@douyinfe/semi-animation": "2.51.4",
11
11
  "async-validator": "^3.5.0",
12
12
  "classnames": "^2.2.6",
13
13
  "date-fns": "^2.29.3",
@@ -23,7 +23,7 @@
23
23
  "*.scss",
24
24
  "*.css"
25
25
  ],
26
- "gitHead": "d39b89cf05ae9bed8f2a18f6d73026b915db87a4",
26
+ "gitHead": "b8cad87796be9b6b10409a95d3a5b4cb8b9592e6",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
@@ -450,7 +450,10 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
450
450
  const isTriggerNearTop = middleY - containerRect.top < containerRect.bottom - middleY;
451
451
 
452
452
  const isWrapperWidthOverflow = wrapperRect.width > innerWidth;
453
-
453
+ const scaled = Math.abs(wrapperRect?.width - this._adapter.getContainer()?.clientWidth) > 1;
454
+ if (scaled) {
455
+ SPACING = SPACING * wrapperRect.width/this._adapter.getContainer().clientWidth;
456
+ }
454
457
  switch (position) {
455
458
  case 'top':
456
459
  // left = middleX;
@@ -570,6 +573,14 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
570
573
  left = left - containerRect.left;
571
574
  top = top - containerRect.top;
572
575
 
576
+ if (scaled) {
577
+ left /= wrapperRect.width/this._adapter.getContainer().clientWidth;
578
+ }
579
+
580
+ if (scaled) {
581
+ top /= wrapperRect.height/this._adapter.getContainer().clientHeight;
582
+ }
583
+
573
584
  /**
574
585
  * container为body时,如果position不为relative或absolute,这时trigger计算出的top/left会根据html定位(initial containing block)
575
586
  * 此时如果body有margin,则计算出的位置相对于body会有问题 fix issue #1368
@@ -828,7 +839,6 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
828
839
 
829
840
  const halfHeight = triggerRect.height / 2;
830
841
  const halfWidth = triggerRect.width / 2;
831
-
832
842
  // 视口, 原空间与反向空间是否都不足判断
833
843
  // Viewport, whether the original space and the reverse space are insufficient to judge
834
844
  const isViewYOverFlow = this.isOverFlow(clientTop - marginTop, restClientBottom - marginBottom, wrapperRect.height + spacing);