@rc-component/trigger 1.6.2 → 1.7.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.
package/README.md CHANGED
@@ -2,7 +2,12 @@
2
2
 
3
3
  React Trigger Component
4
4
 
5
- [![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url]
5
+ [![NPM version][npm-image]][npm-url]
6
+ [![npm download][download-image]][download-url]
7
+ [![build status][github-actions-image]][github-actions-url]
8
+ [![Test coverage][codecov-image]][codecov-url]
9
+ [![bundle size][bundlephobia-image]][bundlephobia-url]
10
+ [![dumi][dumi-image]][dumi-url]
6
11
 
7
12
  [npm-image]: http://img.shields.io/npm/v/@rc-component/trigger.svg?style=flat-square
8
13
  [npm-url]: http://npmjs.org/package/@rc-component/trigger
@@ -10,8 +15,8 @@ React Trigger Component
10
15
  [github-actions-url]: https://github.com/react-component/trigger/actions
11
16
  [circleci-image]: https://img.shields.io/circleci/react-component/trigger/master?style=flat-square
12
17
  [circleci-url]: https://circleci.com/gh/react-component/trigger
13
- [coveralls-image]: https://img.shields.io/coveralls/react-component/trigger.svg?style=flat-square
14
- [coveralls-url]: https://coveralls.io/r/react-component/trigger?branch=master
18
+ [codecov-image]: https://img.shields.io/codecov/c/github/react-component/trigger/master.svg?style=flat-square
19
+ [codecov-url]: https://app.codecov.io/gh/react-component/trigger
15
20
  [david-url]: https://david-dm.org/react-component/trigger
16
21
  [david-image]: https://david-dm.org/react-component/trigger/status.svg?style=flat-square
17
22
  [david-dev-url]: https://david-dm.org/react-component/trigger?type=dev
@@ -223,7 +223,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
223
223
  }
224
224
  var originIntersectionVisibleArea = getIntersectionVisibleArea(nextOffsetX, nextOffsetY);
225
225
 
226
- // ================ Overflow =================
226
+ // ========================== Overflow ===========================
227
227
  var targetAlignPointTL = getAlignPoint(targetRect, ['t', 'l']);
228
228
  var popupAlignPointTL = getAlignPoint(popupRect, ['t', 'l']);
229
229
  var targetAlignPointBR = getAlignPoint(targetRect, ['b', 'r']);
@@ -240,9 +240,20 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
240
240
  return val >= 0;
241
241
  };
242
242
 
243
+ // Prepare position
244
+ var nextPopupY;
245
+ var nextPopupBottom;
246
+ var nextPopupX;
247
+ var nextPopupRight;
248
+ function syncNextPopupPosition() {
249
+ nextPopupY = popupRect.y + nextOffsetY;
250
+ nextPopupBottom = nextPopupY + popupHeight;
251
+ nextPopupX = popupRect.x + nextOffsetX;
252
+ nextPopupRight = nextPopupX + popupWidth;
253
+ }
254
+ syncNextPopupPosition();
255
+
243
256
  // >>>>>>>>>> Top & Bottom
244
- var nextPopupY = popupRect.y + nextOffsetY;
245
- var nextPopupBottom = nextPopupY + popupHeight;
246
257
  var needAdjustY = supportAdjust(adjustY);
247
258
  var sameTB = popupPoints[0] === targetPoints[0];
248
259
 
@@ -275,8 +286,6 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
275
286
  }
276
287
 
277
288
  // >>>>>>>>>> Left & Right
278
- var nextPopupX = popupRect.x + nextOffsetX;
279
- var nextPopupRight = nextPopupX + popupWidth;
280
289
  var needAdjustX = supportAdjust(adjustX);
281
290
 
282
291
  // >>>>> Flip
@@ -310,7 +319,8 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
310
319
  }
311
320
  }
312
321
 
313
- // >>>>> Shift
322
+ // ============================ Shift ============================
323
+ syncNextPopupPosition();
314
324
  var numShiftX = shiftX === true ? 0 : shiftX;
315
325
  if (typeof numShiftX === 'number') {
316
326
  // Left
@@ -348,6 +358,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
348
358
  }
349
359
  }
350
360
 
361
+ // ============================ Arrow ============================
351
362
  // Arrow center align
352
363
  var popupLeft = popupRect.x + nextOffsetX;
353
364
  var popupRight = popupLeft + popupWidth;
package/es/index.js CHANGED
@@ -124,7 +124,7 @@ export function generateTrigger() {
124
124
  var _childDOM$getRootNode, _popupEle$getRootNode;
125
125
  var childDOM = targetEle;
126
126
  return (childDOM === null || childDOM === void 0 ? void 0 : childDOM.contains(ele)) || (childDOM === null || childDOM === void 0 ? void 0 : (_childDOM$getRootNode = childDOM.getRootNode()) === null || _childDOM$getRootNode === void 0 ? void 0 : _childDOM$getRootNode.host) === ele || ele === childDOM || (popupEle === null || popupEle === void 0 ? void 0 : popupEle.contains(ele)) || (popupEle === null || popupEle === void 0 ? void 0 : (_popupEle$getRootNode = popupEle.getRootNode()) === null || _popupEle$getRootNode === void 0 ? void 0 : _popupEle$getRootNode.host) === ele || ele === popupEle || Object.values(subPopupElements.current).some(function (subPopupEle) {
127
- return subPopupEle.contains(ele) || ele === subPopupEle;
127
+ return (subPopupEle === null || subPopupEle === void 0 ? void 0 : subPopupEle.contains(ele)) || ele === subPopupEle;
128
128
  });
129
129
  });
130
130
 
@@ -231,7 +231,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
231
231
  }
232
232
  var originIntersectionVisibleArea = getIntersectionVisibleArea(nextOffsetX, nextOffsetY);
233
233
 
234
- // ================ Overflow =================
234
+ // ========================== Overflow ===========================
235
235
  var targetAlignPointTL = getAlignPoint(targetRect, ['t', 'l']);
236
236
  var popupAlignPointTL = getAlignPoint(popupRect, ['t', 'l']);
237
237
  var targetAlignPointBR = getAlignPoint(targetRect, ['b', 'r']);
@@ -248,9 +248,20 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
248
248
  return val >= 0;
249
249
  };
250
250
 
251
+ // Prepare position
252
+ var nextPopupY;
253
+ var nextPopupBottom;
254
+ var nextPopupX;
255
+ var nextPopupRight;
256
+ function syncNextPopupPosition() {
257
+ nextPopupY = popupRect.y + nextOffsetY;
258
+ nextPopupBottom = nextPopupY + popupHeight;
259
+ nextPopupX = popupRect.x + nextOffsetX;
260
+ nextPopupRight = nextPopupX + popupWidth;
261
+ }
262
+ syncNextPopupPosition();
263
+
251
264
  // >>>>>>>>>> Top & Bottom
252
- var nextPopupY = popupRect.y + nextOffsetY;
253
- var nextPopupBottom = nextPopupY + popupHeight;
254
265
  var needAdjustY = supportAdjust(adjustY);
255
266
  var sameTB = popupPoints[0] === targetPoints[0];
256
267
 
@@ -283,8 +294,6 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
283
294
  }
284
295
 
285
296
  // >>>>>>>>>> Left & Right
286
- var nextPopupX = popupRect.x + nextOffsetX;
287
- var nextPopupRight = nextPopupX + popupWidth;
288
297
  var needAdjustX = supportAdjust(adjustX);
289
298
 
290
299
  // >>>>> Flip
@@ -318,7 +327,8 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
318
327
  }
319
328
  }
320
329
 
321
- // >>>>> Shift
330
+ // ============================ Shift ============================
331
+ syncNextPopupPosition();
322
332
  var numShiftX = shiftX === true ? 0 : shiftX;
323
333
  if (typeof numShiftX === 'number') {
324
334
  // Left
@@ -356,6 +366,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
356
366
  }
357
367
  }
358
368
 
369
+ // ============================ Arrow ============================
359
370
  // Arrow center align
360
371
  var popupLeft = popupRect.x + nextOffsetX;
361
372
  var popupRight = popupLeft + popupWidth;
package/lib/index.js CHANGED
@@ -133,7 +133,7 @@ function generateTrigger() {
133
133
  var _childDOM$getRootNode, _popupEle$getRootNode;
134
134
  var childDOM = targetEle;
135
135
  return (childDOM === null || childDOM === void 0 ? void 0 : childDOM.contains(ele)) || (childDOM === null || childDOM === void 0 ? void 0 : (_childDOM$getRootNode = childDOM.getRootNode()) === null || _childDOM$getRootNode === void 0 ? void 0 : _childDOM$getRootNode.host) === ele || ele === childDOM || (popupEle === null || popupEle === void 0 ? void 0 : popupEle.contains(ele)) || (popupEle === null || popupEle === void 0 ? void 0 : (_popupEle$getRootNode = popupEle.getRootNode()) === null || _popupEle$getRootNode === void 0 ? void 0 : _popupEle$getRootNode.host) === ele || ele === popupEle || Object.values(subPopupElements.current).some(function (subPopupEle) {
136
- return subPopupEle.contains(ele) || ele === subPopupEle;
136
+ return (subPopupEle === null || subPopupEle === void 0 ? void 0 : subPopupEle.contains(ele)) || ele === subPopupEle;
137
137
  });
138
138
  });
139
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"