@thecb/components 7.7.8-beta.2 → 7.7.8-beta.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.
package/dist/index.cjs.js CHANGED
@@ -24466,24 +24466,30 @@ 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>) => Boolean;
24469
+ (elements: Array<String>, Function) => undefined;
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
+
24474
24477
  The document query function will return the *first* element in the document that matches
24475
24478
  the string given.
24476
24479
 
24477
- A combination string of multiple selectors can also be provided, e.g.:
24480
+ A combination string of multiple selectors can also be provided as an item in the array, e.g.:
24478
24481
  ".alert-info, .alert-warning, .alert-error"
24479
24482
 
24480
24483
  This will return the first element that matches *any* of the provided selectors
24481
24484
 
24482
24485
  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
24483
24488
  */
24484
24489
 
24485
24490
  var useCheckElementsInViewport = function useCheckElementsInViewport() {
24486
24491
  var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
24492
+ var handler = arguments.length > 1 ? arguments[1] : undefined;
24487
24493
 
24488
24494
  var _useState = React.useState(false),
24489
24495
  _useState2 = _slicedToArray(_useState, 2),
@@ -24501,8 +24507,8 @@ var useCheckElementsInViewport = function useCheckElementsInViewport() {
24501
24507
  setElementsVisible(true);
24502
24508
  }
24503
24509
  });
24504
- }, [elements]);
24505
- return elementsVisible;
24510
+ }, [elements, viewportWidth, viewportHeight]);
24511
+ handler(elementsVisible);
24506
24512
  };
24507
24513
 
24508
24514