@thecb/components 7.7.8-beta.4 → 7.7.8-beta.6

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/dist/index.cjs.js CHANGED
@@ -24466,14 +24466,11 @@ var useOutsideClickHook = function useOutsideClickHook(handler) {
24466
24466
  Hook that determines whether every element in an array of DOM selectors is fully present
24467
24467
  within the user's current viewport.
24468
24468
 
24469
- (elements: Array<String>, Function) => undefined;
24469
+ (elements: Array<String>) => Boolean;
24470
24470
 
24471
24471
  Takes an array of strings that correspond to DOM selectors. Examples:
24472
24472
  "#submit-button", ".module-small", "h2.alert-title"
24473
24473
 
24474
- Also takes a handler function (such as a useState updater) to receive the Boolean
24475
- that the hook generates
24476
-
24477
24474
  The document query function will return the *first* element in the document that matches
24478
24475
  the string given.
24479
24476
 
@@ -24483,13 +24480,10 @@ var useOutsideClickHook = function useOutsideClickHook(handler) {
24483
24480
  This will return the first element that matches *any* of the provided selectors
24484
24481
 
24485
24482
  If every element in the array is fully within the viewport, function returns true
24486
-
24487
- Calls the provided handler function with the Boolean result
24488
24483
  */
24489
24484
 
24490
24485
  var useCheckElementsInViewport = function useCheckElementsInViewport() {
24491
24486
  var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
24492
- var handler = arguments.length > 1 ? arguments[1] : undefined;
24493
24487
 
24494
24488
  var _useState = React.useState(false),
24495
24489
  _useState2 = _slicedToArray(_useState, 2),
@@ -24500,15 +24494,17 @@ var useCheckElementsInViewport = function useCheckElementsInViewport() {
24500
24494
  var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
24501
24495
  React.useEffect(function () {
24502
24496
  elements.forEach(function (element) {
24497
+ console.log("element is", element);
24503
24498
  var domEl = document.querySelector(element);
24504
- var boundingBox = domEl.getBoundingClientRect();
24499
+ console.log("domEl is", domEl);
24500
+ var boundingBox = domEl === null || domEl === void 0 ? void 0 : domEl.getBoundingClientRect();
24505
24501
 
24506
- if (boundingBox.top >= 0 && boundingBox.left >= 0 && boundingBox.right <= viewportWidth && boundingBox.bottom <= viewportHeight) {
24502
+ if ((boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.top) >= 0 && (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.left) >= 0 && (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.right) <= viewportWidth && (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.bottom) <= viewportHeight) {
24507
24503
  setElementsVisible(true);
24508
24504
  }
24509
24505
  });
24510
24506
  }, [elements, viewportWidth, viewportHeight]);
24511
- handler(elementsVisible);
24507
+ return elementsVisible;
24512
24508
  };
24513
24509
 
24514
24510