@formily-design/shared 1.0.6 → 1.0.8

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.
package/esm/array.d.ts CHANGED
@@ -33,5 +33,5 @@ export declare function includes<T extends string>(val: T, searchElement: string
33
33
  export declare function includes<T>(val: T[], searchElement: T, revert?: boolean): boolean;
34
34
  export declare function includesWith<T extends string>(val: T, search: (item: string) => boolean): boolean;
35
35
  export declare function includesWith<T>(val: T[], search: (item: T) => boolean): boolean;
36
- export declare const flat: <T>(array: (T | T[])[]) => T[];
36
+ export declare const flat: <T>(array: Array<T | T[]>) => T[];
37
37
  export {};
package/esm/scroller.d.ts CHANGED
@@ -5,6 +5,6 @@ export interface IAutoScrollBasicInfo {
5
5
  speedFactor: number;
6
6
  speed: number;
7
7
  }
8
- export declare const calcAutoScrollBasicInfo: (point: IPoint, axis: 'x' | 'y', viewport: DOMRect, maxSpeed?: number) => IAutoScrollBasicInfo | null;
9
- export declare const updateScrollValue: (element: HTMLElement | Window, axis: 'x' | 'y', value: number, callback?: (scrollValue: number) => void) => void;
10
- export declare const scrollAnimate: (element: HTMLElement | Window, axis: 'x' | 'y', direction: 'begin' | 'end', speed: number, callback?: (scrollValue: number) => void) => () => void;
8
+ export declare const calcAutoScrollBasicInfo: (point: IPoint, axis: "x" | "y", viewport: DOMRect, maxSpeed?: number) => IAutoScrollBasicInfo | null;
9
+ export declare const updateScrollValue: (element: HTMLElement | Window, axis: "x" | "y", value: number, callback?: (scrollValue: number) => void) => void;
10
+ export declare const scrollAnimate: (element: HTMLElement | Window, axis: "x" | "y", direction: "begin" | "end", speed: number, callback?: (scrollValue: number) => void) => () => void;
package/lib/array.d.ts CHANGED
@@ -33,5 +33,5 @@ export declare function includes<T extends string>(val: T, searchElement: string
33
33
  export declare function includes<T>(val: T[], searchElement: T, revert?: boolean): boolean;
34
34
  export declare function includesWith<T extends string>(val: T, search: (item: string) => boolean): boolean;
35
35
  export declare function includesWith<T>(val: T[], search: (item: T) => boolean): boolean;
36
- export declare const flat: <T>(array: (T | T[])[]) => T[];
36
+ export declare const flat: <T>(array: Array<T | T[]>) => T[];
37
37
  export {};
package/lib/array.js CHANGED
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flat = exports.includesWith = exports.includes = exports.find = exports.findIndex = exports.some = exports.every = exports.reduce = exports.map = exports.each = exports.toArr = void 0;
3
+ exports.flat = exports.toArr = void 0;
4
+ exports.each = each;
5
+ exports.map = map;
6
+ exports.reduce = reduce;
7
+ exports.every = every;
8
+ exports.some = some;
9
+ exports.findIndex = findIndex;
10
+ exports.find = find;
11
+ exports.includes = includes;
12
+ exports.includesWith = includesWith;
4
13
  const types_1 = require("./types");
5
14
  const toArr = (val) => ((0, types_1.isArr)(val) ? val : val ? [val] : []);
6
15
  exports.toArr = toArr;
@@ -32,7 +41,6 @@ function each(val, iterator, revert) {
32
41
  }
33
42
  }
34
43
  }
35
- exports.each = each;
36
44
  function map(val, iterator, revert) {
37
45
  const res = (0, types_1.isArr)(val) || (0, types_1.isStr)(val) ? [] : {};
38
46
  each(val, (item, key) => {
@@ -47,7 +55,6 @@ function map(val, iterator, revert) {
47
55
  }, revert);
48
56
  return res;
49
57
  }
50
- exports.map = map;
51
58
  function reduce(val, iterator, accumulator, revert) {
52
59
  let result = accumulator;
53
60
  each(val, (item, key) => {
@@ -55,7 +62,6 @@ function reduce(val, iterator, accumulator, revert) {
55
62
  }, revert);
56
63
  return result;
57
64
  }
58
- exports.reduce = reduce;
59
65
  function every(val, iterator, revert) {
60
66
  let res = true;
61
67
  each(val, (item, key) => {
@@ -66,7 +72,6 @@ function every(val, iterator, revert) {
66
72
  }, revert);
67
73
  return res;
68
74
  }
69
- exports.every = every;
70
75
  function some(val, iterator, revert) {
71
76
  let res = false;
72
77
  each(val, (item, key) => {
@@ -77,7 +82,6 @@ function some(val, iterator, revert) {
77
82
  }, revert);
78
83
  return res;
79
84
  }
80
- exports.some = some;
81
85
  function findIndex(val, iterator, revert) {
82
86
  let res = -1;
83
87
  each(val, (item, key) => {
@@ -88,7 +92,6 @@ function findIndex(val, iterator, revert) {
88
92
  }, revert);
89
93
  return res;
90
94
  }
91
- exports.findIndex = findIndex;
92
95
  function find(val, iterator, revert) {
93
96
  let res;
94
97
  each(val, (item, key) => {
@@ -99,13 +102,11 @@ function find(val, iterator, revert) {
99
102
  }, revert);
100
103
  return res;
101
104
  }
102
- exports.find = find;
103
105
  function includes(val, searchElement, revert) {
104
106
  if ((0, types_1.isStr)(val))
105
107
  return val.includes(searchElement);
106
108
  return some(val, (item) => item === searchElement, revert);
107
109
  }
108
- exports.includes = includes;
109
110
  function includesWith(val, search) {
110
111
  if ((0, types_1.isArr)(val)) {
111
112
  return val.some((item) => search(item));
@@ -114,7 +115,6 @@ function includesWith(val, search) {
114
115
  return false;
115
116
  }
116
117
  }
117
- exports.includesWith = includesWith;
118
118
  const flat = (array) => {
119
119
  return (0, exports.toArr)(array).reduce((buf, item) => {
120
120
  if ((0, types_1.isArr)(item))
package/lib/coordinate.js CHANGED
@@ -1,19 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calcClosestEdges = exports.calcCombineSnapLineSegment = exports.calcDistanceOfSnapLineToEdges = exports.calcOffsetOfSnapLineSegmentToEdge = exports.calcExtendsLineSegmentOfRect = exports.calcSpaceBlockOfRect = exports.calcRectOfAxisLineSegment = exports.calcEdgeLinesOfRect = exports.calcRectByStartEndPoint = exports.calcBoundingRect = exports.calcRelativeOfPointToRect = exports.isNearAfter = exports.calcDistancePointToEdge = exports.calcDistanceOfPointToRect = exports.calcQuadrantOfPointToRect = exports.isCrossRectInRect = exports.isRectInRect = exports.getRectPoints = exports.isEqualRect = exports.isPointInRect = exports.RectQuadrant = exports.LineSegment = exports.Rect = exports.Point = exports.isLineSegment = exports.isPoint = exports.isRect = void 0;
3
+ exports.RectQuadrant = exports.LineSegment = exports.Rect = exports.Point = void 0;
4
+ exports.isRect = isRect;
5
+ exports.isPoint = isPoint;
6
+ exports.isLineSegment = isLineSegment;
7
+ exports.isPointInRect = isPointInRect;
8
+ exports.isEqualRect = isEqualRect;
9
+ exports.getRectPoints = getRectPoints;
10
+ exports.isRectInRect = isRectInRect;
11
+ exports.isCrossRectInRect = isCrossRectInRect;
12
+ exports.calcQuadrantOfPointToRect = calcQuadrantOfPointToRect;
13
+ exports.calcDistanceOfPointToRect = calcDistanceOfPointToRect;
14
+ exports.calcDistancePointToEdge = calcDistancePointToEdge;
15
+ exports.isNearAfter = isNearAfter;
16
+ exports.calcRelativeOfPointToRect = calcRelativeOfPointToRect;
17
+ exports.calcBoundingRect = calcBoundingRect;
18
+ exports.calcRectByStartEndPoint = calcRectByStartEndPoint;
19
+ exports.calcEdgeLinesOfRect = calcEdgeLinesOfRect;
20
+ exports.calcRectOfAxisLineSegment = calcRectOfAxisLineSegment;
21
+ exports.calcSpaceBlockOfRect = calcSpaceBlockOfRect;
22
+ exports.calcExtendsLineSegmentOfRect = calcExtendsLineSegmentOfRect;
23
+ exports.calcOffsetOfSnapLineSegmentToEdge = calcOffsetOfSnapLineSegmentToEdge;
24
+ exports.calcDistanceOfSnapLineToEdges = calcDistanceOfSnapLineToEdges;
25
+ exports.calcCombineSnapLineSegment = calcCombineSnapLineSegment;
26
+ exports.calcClosestEdges = calcClosestEdges;
4
27
  const types_1 = require("./types");
5
28
  function isRect(rect) {
6
29
  return (rect === null || rect === void 0 ? void 0 : rect.x) && (rect === null || rect === void 0 ? void 0 : rect.y) && (rect === null || rect === void 0 ? void 0 : rect.width) && (rect === null || rect === void 0 ? void 0 : rect.height);
7
30
  }
8
- exports.isRect = isRect;
9
31
  function isPoint(val) {
10
32
  return (0, types_1.isValidNumber)(val === null || val === void 0 ? void 0 : val.x) && (0, types_1.isValidNumber)(val === null || val === void 0 ? void 0 : val.y);
11
33
  }
12
- exports.isPoint = isPoint;
13
34
  function isLineSegment(val) {
14
35
  return isPoint(val === null || val === void 0 ? void 0 : val.start) && isPoint(val === null || val === void 0 ? void 0 : val.end);
15
36
  }
16
- exports.isLineSegment = isLineSegment;
17
37
  class Point {
18
38
  constructor(x, y) {
19
39
  this.x = x;
@@ -80,14 +100,12 @@ function isPointInRect(point, rect, sensitive = true) {
80
100
  point.y >= rect.y + boundSensor(rect.height) &&
81
101
  point.y <= rect.y + rect.height - boundSensor(rect.height));
82
102
  }
83
- exports.isPointInRect = isPointInRect;
84
103
  function isEqualRect(target, source) {
85
104
  return ((target === null || target === void 0 ? void 0 : target.x) === (source === null || source === void 0 ? void 0 : source.x) &&
86
105
  target.y === source.y &&
87
106
  target.width === source.width &&
88
107
  target.height === source.height);
89
108
  }
90
- exports.isEqualRect = isEqualRect;
91
109
  function getRectPoints(source) {
92
110
  const p1 = new Point(source.x, source.y);
93
111
  const p2 = new Point(source.x + source.width, source.y);
@@ -95,7 +113,6 @@ function getRectPoints(source) {
95
113
  const p4 = new Point(source.x, source.y + source.height);
96
114
  return [p1, p2, p3, p4];
97
115
  }
98
- exports.getRectPoints = getRectPoints;
99
116
  function isRectInRect(target, source) {
100
117
  const [p1, p2, p3, p4] = getRectPoints(target);
101
118
  return (isPointInRect(p1, source, false) &&
@@ -103,7 +120,6 @@ function isRectInRect(target, source) {
103
120
  isPointInRect(p3, source, false) &&
104
121
  isPointInRect(p4, source, false));
105
122
  }
106
- exports.isRectInRect = isRectInRect;
107
123
  function isCrossRectInRect(target, source) {
108
124
  const targetCenterPoint = new Point(target.x + target.width / 2, target.y + target.height / 2);
109
125
  const sourceCenterPoint = new Point(source.x + source.width / 2, source.y + source.height / 2);
@@ -112,7 +128,6 @@ function isCrossRectInRect(target, source) {
112
128
  Math.abs(targetCenterPoint.y - sourceCenterPoint.y) <=
113
129
  target.height / 2 + source.height / 2);
114
130
  }
115
- exports.isCrossRectInRect = isCrossRectInRect;
116
131
  /**
117
132
  * 计算点在矩形的哪个象限
118
133
  * @param point
@@ -157,7 +172,6 @@ function calcQuadrantOfPointToRect(point, rect) {
157
172
  }
158
173
  }
159
174
  }
160
- exports.calcQuadrantOfPointToRect = calcQuadrantOfPointToRect;
161
175
  function calcDistanceOfPointToRect(point, rect) {
162
176
  let minX = Math.min(Math.abs(point.x - rect.x), Math.abs(point.x - (rect.x + rect.width)));
163
177
  let minY = Math.min(Math.abs(point.y - rect.y), Math.abs(point.y - (rect.y + rect.height)));
@@ -169,7 +183,6 @@ function calcDistanceOfPointToRect(point, rect) {
169
183
  }
170
184
  return Math.sqrt(minX ** 2 + minY ** 2);
171
185
  }
172
- exports.calcDistanceOfPointToRect = calcDistanceOfPointToRect;
173
186
  function calcDistancePointToEdge(point, rect) {
174
187
  const distanceTop = Math.abs(point.y - rect.y);
175
188
  const distanceBottom = Math.abs(point.y - (rect.y + rect.height));
@@ -177,7 +190,6 @@ function calcDistancePointToEdge(point, rect) {
177
190
  const distanceRight = Math.abs(point.x - (rect.x + rect.width));
178
191
  return Math.min(distanceTop, distanceBottom, distanceLeft, distanceRight);
179
192
  }
180
- exports.calcDistancePointToEdge = calcDistancePointToEdge;
181
193
  function isNearAfter(point, rect, inline = false) {
182
194
  if (inline) {
183
195
  return (Math.abs(point.x - rect.x) + Math.abs(point.y - rect.y) >
@@ -186,7 +198,6 @@ function isNearAfter(point, rect, inline = false) {
186
198
  }
187
199
  return Math.abs(point.y - rect.y) > Math.abs(point.y - (rect.y + rect.height));
188
200
  }
189
- exports.isNearAfter = isNearAfter;
190
201
  /**
191
202
  * 计算点鱼矩形的相对位置信息
192
203
  * @param point
@@ -200,7 +211,6 @@ function calcRelativeOfPointToRect(point, rect) {
200
211
  distance,
201
212
  };
202
213
  }
203
- exports.calcRelativeOfPointToRect = calcRelativeOfPointToRect;
204
214
  function calcBoundingRect(rects) {
205
215
  if (!(rects === null || rects === void 0 ? void 0 : rects.length))
206
216
  return;
@@ -227,7 +237,6 @@ function calcBoundingRect(rects) {
227
237
  });
228
238
  return new Rect(minLeft, minTop, maxRight - minLeft, maxBottom - minTop);
229
239
  }
230
- exports.calcBoundingRect = calcBoundingRect;
231
240
  function calcRectByStartEndPoint(startPoint, endPoint, scrollX = 0, scrollY = 0) {
232
241
  let drawStartX = 0, drawStartY = 0;
233
242
  if (endPoint.x + scrollX >= startPoint.x &&
@@ -258,7 +267,6 @@ function calcRectByStartEndPoint(startPoint, endPoint, scrollX = 0, scrollY = 0)
258
267
  return new Rect(drawStartX, drawStartY, Math.abs(endPoint.x - startPoint.x + scrollX), Math.abs(endPoint.y - startPoint.y + scrollY));
259
268
  }
260
269
  }
261
- exports.calcRectByStartEndPoint = calcRectByStartEndPoint;
262
270
  function calcEdgeLinesOfRect(rect) {
263
271
  return {
264
272
  v: [
@@ -273,14 +281,12 @@ function calcEdgeLinesOfRect(rect) {
273
281
  ],
274
282
  };
275
283
  }
276
- exports.calcEdgeLinesOfRect = calcEdgeLinesOfRect;
277
284
  function calcRectOfAxisLineSegment(line) {
278
285
  if (!isLineSegment(line))
279
286
  return;
280
287
  const isXAxis = line.start.x === line.end.x;
281
288
  return new Rect(line.start.x, line.start.y, isXAxis ? 0 : line.end.x - line.start.x, isXAxis ? line.end.y - line.start.y : 0);
282
289
  }
283
- exports.calcRectOfAxisLineSegment = calcRectOfAxisLineSegment;
284
290
  function calcSpaceBlockOfRect(target, source, type) {
285
291
  const targetRect = new Rect(target.x, target.y, target.width, target.height);
286
292
  const sourceRect = new Rect(source.x, source.y, source.width, source.height);
@@ -341,7 +347,6 @@ function calcSpaceBlockOfRect(target, source, type) {
341
347
  };
342
348
  }
343
349
  }
344
- exports.calcSpaceBlockOfRect = calcSpaceBlockOfRect;
345
350
  function calcExtendsLineSegmentOfRect(targetRect, referRect) {
346
351
  if (referRect.right < targetRect.right &&
347
352
  targetRect.left <= referRect.right) {
@@ -415,7 +420,6 @@ function calcExtendsLineSegmentOfRect(targetRect, referRect) {
415
420
  }
416
421
  }
417
422
  }
418
- exports.calcExtendsLineSegmentOfRect = calcExtendsLineSegmentOfRect;
419
423
  function calcOffsetOfSnapLineSegmentToEdge(line, current) {
420
424
  const edges = calcEdgeLinesOfRect(current);
421
425
  const isVerticalLine = line.start.x === line.end.x;
@@ -441,7 +445,6 @@ function calcOffsetOfSnapLineSegmentToEdge(line, current) {
441
445
  }
442
446
  return { x: 0, y: calcMinDistanceValue(edges.y, line.start.y) - current.y };
443
447
  }
444
- exports.calcOffsetOfSnapLineSegmentToEdge = calcOffsetOfSnapLineSegmentToEdge;
445
448
  function calcDistanceOfSnapLineToEdges(line, edges) {
446
449
  var _a, _b, _c, _d;
447
450
  let distance = Infinity;
@@ -466,14 +469,12 @@ function calcDistanceOfSnapLineToEdges(line, edges) {
466
469
  }
467
470
  return distance;
468
471
  }
469
- exports.calcDistanceOfSnapLineToEdges = calcDistanceOfSnapLineToEdges;
470
472
  function calcCombineSnapLineSegment(target, source) {
471
473
  if (target.start.x === target.end.x) {
472
474
  return new LineSegment(new Point(target.start.x, target.start.y > source.start.y ? source.start.y : target.start.y), new Point(target.start.x, target.end.y > source.end.y ? target.end.y : source.end.y));
473
475
  }
474
476
  return new LineSegment(new Point(target.start.x > source.start.x ? source.start.x : target.start.x, target.start.y), new Point(target.end.x > source.end.x ? target.end.x : source.end.x, target.end.y));
475
477
  }
476
- exports.calcCombineSnapLineSegment = calcCombineSnapLineSegment;
477
478
  function calcClosestEdges(line, edges) {
478
479
  var _a, _b, _c, _d;
479
480
  let result;
@@ -501,4 +502,3 @@ function calcClosestEdges(line, edges) {
501
502
  }
502
503
  return [distance, result];
503
504
  }
504
- exports.calcClosestEdges = calcClosestEdges;
package/lib/scroller.d.ts CHANGED
@@ -5,6 +5,6 @@ export interface IAutoScrollBasicInfo {
5
5
  speedFactor: number;
6
6
  speed: number;
7
7
  }
8
- export declare const calcAutoScrollBasicInfo: (point: IPoint, axis: 'x' | 'y', viewport: DOMRect, maxSpeed?: number) => IAutoScrollBasicInfo | null;
9
- export declare const updateScrollValue: (element: HTMLElement | Window, axis: 'x' | 'y', value: number, callback?: (scrollValue: number) => void) => void;
10
- export declare const scrollAnimate: (element: HTMLElement | Window, axis: 'x' | 'y', direction: 'begin' | 'end', speed: number, callback?: (scrollValue: number) => void) => () => void;
8
+ export declare const calcAutoScrollBasicInfo: (point: IPoint, axis: "x" | "y", viewport: DOMRect, maxSpeed?: number) => IAutoScrollBasicInfo | null;
9
+ export declare const updateScrollValue: (element: HTMLElement | Window, axis: "x" | "y", value: number, callback?: (scrollValue: number) => void) => void;
10
+ export declare const scrollAnimate: (element: HTMLElement | Window, axis: "x" | "y", direction: "begin" | "end", speed: number, callback?: (scrollValue: number) => void) => () => void;
package/lib/uid.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uid = void 0;
3
+ exports.uid = uid;
4
4
  let IDX = 36, HEX = '';
5
5
  while (IDX--)
6
6
  HEX += IDX.toString(36);
@@ -10,4 +10,3 @@ function uid(len) {
10
10
  str += HEX[(Math.random() * 36) | 0];
11
11
  return str;
12
12
  }
13
- exports.uid = uid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formily-design/shared",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "license": "MIT",
5
5
  "main": "lib",
6
6
  "types": "lib/index.d.ts",
@@ -28,5 +28,5 @@
28
28
  "dependencies": {
29
29
  "requestidlecallback": "^0.3.0"
30
30
  },
31
- "gitHead": "e5564cc16c767903c2509f925b95b21580d25865"
31
+ "gitHead": "3047a43b47fa5430fd3e7e2041492db4ed766558"
32
32
  }