@antv/component 0.9.1 → 0.9.2

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 (41) hide show
  1. package/esm/slider/constant.d.ts +7 -5
  2. package/esm/slider/constant.js +7 -5
  3. package/esm/slider/constant.js.map +1 -1
  4. package/esm/slider/foreground.d.ts +8 -1
  5. package/esm/slider/foreground.js +13 -15
  6. package/esm/slider/foreground.js.map +1 -1
  7. package/esm/slider/slider.d.ts +13 -0
  8. package/esm/slider/slider.js +58 -39
  9. package/esm/slider/slider.js.map +1 -1
  10. package/esm/util/event.d.ts +2 -2
  11. package/esm/util/event.js +1 -2
  12. package/esm/util/event.js.map +1 -1
  13. package/esm/util/mask.js +0 -8
  14. package/esm/util/mask.js.map +1 -1
  15. package/esm/util/util.d.ts +4 -1
  16. package/esm/util/util.js +5 -2
  17. package/esm/util/util.js.map +1 -1
  18. package/lib/slider/constant.d.ts +7 -5
  19. package/lib/slider/constant.js +8 -6
  20. package/lib/slider/constant.js.map +1 -1
  21. package/lib/slider/foreground.d.ts +8 -1
  22. package/lib/slider/foreground.js +12 -14
  23. package/lib/slider/foreground.js.map +1 -1
  24. package/lib/slider/slider.d.ts +13 -0
  25. package/lib/slider/slider.js +56 -37
  26. package/lib/slider/slider.js.map +1 -1
  27. package/lib/util/event.d.ts +2 -2
  28. package/lib/util/event.js +1 -2
  29. package/lib/util/event.js.map +1 -1
  30. package/lib/util/mask.js +0 -8
  31. package/lib/util/mask.js.map +1 -1
  32. package/lib/util/util.d.ts +4 -1
  33. package/lib/util/util.js +7 -4
  34. package/lib/util/util.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/slider/constant.ts +7 -8
  37. package/src/slider/foreground.ts +14 -21
  38. package/src/slider/slider.ts +56 -35
  39. package/src/util/event.ts +2 -3
  40. package/src/util/mask.ts +1 -10
  41. package/src/util/util.ts +5 -2
package/src/util/mask.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BBox, IGroup, IShape, LooseObject, Point } from '@antv/g-base';
1
+ import { IGroup, IShape, LooseObject, Point } from '@antv/g-base';
2
2
 
3
3
  export function createMask(group: IGroup, maskType: string, maskAttrs: LooseObject) {
4
4
  const maskShape = group.addShape({
@@ -18,15 +18,6 @@ export function updateMask(shape: IShape, maskAttrs: LooseObject) {
18
18
  return shape;
19
19
  }
20
20
 
21
- // export function overBBoxLimit(bbox: BBox, curPoint: Point) {
22
- // const { minX, maxX, minY, maxY } = bbox;
23
- // const { x, y } = curPoint;
24
- // if (Math.min(minX, maxX) > x || Math.max(minX, maxX) < x || Math.min(minY, maxY) > y || Math.max(minY, maxY) < y) {
25
- // return true;
26
- // }
27
- // return false;
28
- // }
29
-
30
21
  export function getRectMaskAttrs(start: Point, end: Point) {
31
22
  const x = Math.min(start.x, end.x);
32
23
  const y = Math.min(start.y, end.y);
package/src/util/util.ts CHANGED
@@ -265,7 +265,10 @@ export function getTextWidth(text: string, font: string) {
265
265
  return width;
266
266
  }
267
267
 
268
- export function clipText(str: string, maxWidth: number, font: string) {
268
+ /**
269
+ * @description 文字超出最大宽度时,换行处理
270
+ */
271
+ export function clipTextTwoLines(str: string, maxWidth: number, font: string) {
269
272
  // 日期字段根据空格拆为两组:'2022-10-12 08:23' => ['2022-10-12', '08:23']
270
273
  if (Date.parse(str)) {
271
274
  return str.split(' ').join('\n');
@@ -274,7 +277,7 @@ export function clipText(str: string, maxWidth: number, font: string) {
274
277
  function mapStr(str: string, callback: (i: number) => void) {
275
278
  for (let i = 0; i < str.length; i++) {
276
279
  const curStr = str.slice(0, i + 1);
277
- const curWidth = getTextWidth(curStr, '12');
280
+ const curWidth = getTextWidth(curStr, font);
278
281
  if (curWidth > maxWidth) {
279
282
  callback(i);
280
283
  return;