@thecb/components 7.7.8-beta.0 → 7.7.8-beta.10

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.esm.js CHANGED
@@ -24458,43 +24458,86 @@ var useOutsideClickHook = function useOutsideClickHook(handler) {
24458
24458
  Hook that determines whether every element in an array of DOM selectors is fully present
24459
24459
  within the user's current viewport.
24460
24460
 
24461
- (elements: Array<String>) => Boolean;
24461
+ (elements: Array<String>, Number, Number) => Boolean;
24462
+ (["#submit-button", "#.module-small", "h2.alert-title"], 1024, 768) => true;
24462
24463
 
24463
24464
  Takes an array of strings that correspond to DOM selectors. Examples:
24464
24465
  "#submit-button", ".module-small", "h2.alert-title"
24465
24466
 
24467
+ Also takes numbers that represent the current viewport width and height.
24468
+ You can either calculate these once in your application before running this hook
24469
+ (so that they only update when the component running the hook re-renders), or you can
24470
+ use the useGetViewportOnResize hook to calculate them when the browser window is resized
24471
+
24466
24472
  The document query function will return the *first* element in the document that matches
24467
24473
  the string given.
24468
24474
 
24469
- A combination string of multiple selectors can also be provided, e.g.:
24470
- ".alert-info, .alert-warning, .alert-error"
24475
+ A combination string of multiple selectors can also be provided as an item in the array, e.g.:
24476
+ ".alert-info, .alert-warning, .alert-error". This will return the first element that matches *any* of the provided selectors.
24471
24477
 
24472
- This will return the first element that matches *any* of the provided selectors
24478
+ If the element is present in the DOM (domEL !== null), the function examines the element's bounding box
24479
+ to determine if the element is within the viewport. If any portion of the element is outside of
24480
+ the viewport, the function returns false.
24473
24481
 
24474
- If every element in the array is fully within the viewport, function returns true
24482
+ If all elements that exist are within the viewport, the function returns true.
24475
24483
  */
24476
24484
 
24477
24485
  var useCheckElementsInViewport = function useCheckElementsInViewport() {
24478
24486
  var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
24487
+ var viewportWidth = arguments.length > 1 ? arguments[1] : undefined;
24488
+ var viewportHeight = arguments.length > 2 ? arguments[2] : undefined;
24479
24489
 
24480
- var _useState = useState(false),
24481
- _useState2 = _slicedToArray(_useState, 2),
24482
- elementsVisible = _useState2[0],
24483
- setElementsVisible = _useState2[1];
24490
+ for (var i = 0; i < elements.length; i++) {
24491
+ var domEl = document.querySelector(elements[i]);
24492
+ var boundingBox = domEl === null || domEl === void 0 ? void 0 : domEl.getBoundingClientRect();
24493
+ timesRun++;
24484
24494
 
24485
- var viewportWidth = window.innerWidth || document.documentElement.clientWidth;
24486
- var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
24487
- useEffect$1(function () {
24488
- elements.forEach(function (element) {
24489
- var domEl = document.querySelector(element);
24490
- var boundingBox = domEl.getBoundingClientRect();
24495
+ if (domEl !== null) {
24496
+ if (boundingBox.top < 0 || boundingBox.left < 0 || boundingBox.right > viewportWidth || boundingBox.bottom > viewportHeight) {
24497
+ return false;
24498
+ }
24499
+ }
24500
+ }
24501
+
24502
+ return true;
24503
+ };
24504
+
24505
+ /*
24506
+ Hook that adds a resize listener to the window and updates viewport size via
24507
+ a provided handler function
24508
+
24509
+ (Object: {width: Number, height: Number}, Function) => undefined;
24510
+
24511
+ Provide the current value of the user's viewport and a handler function to receive updated values
24512
+
24513
+ Best used in combination with a useState hook in your component to receive updated values
24514
+ */
24515
+
24516
+ var useGetViewportOnResize = function useGetViewportOnResize(viewport, updateViewport) {
24517
+ var timeoutID = false;
24518
+ var delay = 250;
24491
24519
 
24492
- if (boundingBox.top >= 0 && boundingBox.left >= 0 && boundingBox.right <= viewportWidth && boundingBox.bottom <= viewportHeight) {
24493
- setElementsVisible(true);
24520
+ var updateViewportValues = function updateViewportValues() {
24521
+ clearTimeout(timeoutID);
24522
+ timeoutID = setTimeout(function () {
24523
+ var newWidth = window.innerWidth || document.documentElement.clientWidth;
24524
+ var newHeight = window.innerHeight || document.documentElement.clientHeight;
24525
+
24526
+ if (viewport !== null && viewport !== void 0 && viewport.width && (viewport === null || viewport === void 0 ? void 0 : viewport.width) !== newWidth || viewport !== null && viewport !== void 0 && viewport.height && (viewport === null || viewport === void 0 ? void 0 : viewport.height) !== newHeight) {
24527
+ updateViewport({
24528
+ width: newWidth,
24529
+ height: newHeight
24530
+ });
24494
24531
  }
24495
- });
24496
- }, [elements]);
24497
- return elementsVisible;
24532
+ }, delay);
24533
+ };
24534
+
24535
+ useEffect$1(function () {
24536
+ window.addEventListener("resize", updateViewportValues);
24537
+ return function () {
24538
+ clearTimeout(timeoutID);
24539
+ };
24540
+ }, []);
24498
24541
  };
24499
24542
 
24500
24543
 
@@ -24506,7 +24549,8 @@ var index$4 = /*#__PURE__*/Object.freeze({
24506
24549
  theme: themeUtils,
24507
24550
  useFocusInvalidInput: useFocusInvalidInput,
24508
24551
  useOutsideClick: useOutsideClickHook,
24509
- useCheckElementsInViewport: useCheckElementsInViewport
24552
+ useCheckElementsInViewport: useCheckElementsInViewport,
24553
+ useGetViewportOnResize: useGetViewportOnResize
24510
24554
  });
24511
24555
 
24512
24556
  var hoverColor$4 = "#116285";
@@ -40322,6 +40366,8 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
40322
40366
  useOrderedList: useOrderedList,
40323
40367
  useUnorderedList: useUnorderedList
40324
40368
  }, repeat( /*#__PURE__*/React.createElement(Box, null), boxesBefore), tabs.map(function (t, i) {
40369
+ var _t$toLowerCase;
40370
+
40325
40371
  return /*#__PURE__*/React.createElement(Box, {
40326
40372
  key: t,
40327
40373
  borderSize: "3px",
@@ -40335,7 +40381,8 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
40335
40381
  textAlign: "center",
40336
40382
  color: themeValues.textColor,
40337
40383
  weight: FONT_WEIGHT_SEMIBOLD,
40338
- extraStyles: "display: block; white-space: nowrap;"
40384
+ extraStyles: "display: block; white-space: nowrap;",
40385
+ id: "".concat(t === null || t === void 0 ? void 0 : (_t$toLowerCase = t.toLowerCase()) === null || _t$toLowerCase === void 0 ? void 0 : _t$toLowerCase.replace(/\s/g, "-"), "-tab-text")
40339
40386
  }, t));
40340
40387
  }), repeat( /*#__PURE__*/React.createElement(Box, null), boxesAfter))));
40341
40388
  };
@@ -45529,19 +45576,28 @@ var Module = function Module(_ref) {
45529
45576
  variant = _ref$variant === void 0 ? "default" : _ref$variant,
45530
45577
  fontSize = _ref.fontSize,
45531
45578
  as = _ref.as,
45579
+ _ref$titleID = _ref.titleID,
45580
+ titleID = _ref$titleID === void 0 ? "" : _ref$titleID,
45581
+ rightTitleContent = _ref.rightTitleContent,
45532
45582
  children = _ref.children;
45533
45583
  var themedFontSize = variant === "small" ? "1.25rem" : variant === "default" ? "1.375rem" : "2rem";
45534
45584
  var computedFontSize = fontSize || themedFontSize;
45535
45585
  var themedElemType = variant === "small" ? "h6" : variant === "default" ? "h5" : "h2";
45536
45586
  var computedElemType = as || themedElemType;
45537
- return /*#__PURE__*/React.createElement(Fragment$1, null, heading && /*#__PURE__*/React.createElement(Title$1, {
45587
+ var headingText = /*#__PURE__*/React.createElement(Title$1, {
45538
45588
  weight: themeValues.fontWeight,
45539
45589
  color: themeValues.fontColor,
45540
45590
  margin: "".concat(spacing, " 0 ").concat(themeValues.titleSpacing, " 0"),
45541
45591
  textAlign: themeValues.textAlign,
45542
45592
  as: computedElemType,
45543
- extraStyles: "font-size: ".concat(computedFontSize, ";")
45544
- }, heading), /*#__PURE__*/React.createElement(Box, {
45593
+ extraStyles: "font-size: ".concat(computedFontSize, ";"),
45594
+ id: titleID
45595
+ }, heading);
45596
+ return /*#__PURE__*/React.createElement(Fragment$1, null, heading && !rightTitleContent && headingText, heading && rightTitleContent && /*#__PURE__*/React.createElement(Cluster, {
45597
+ justify: "space-between",
45598
+ align: "center",
45599
+ nowrap: true
45600
+ }, headingText, rightTitleContent), /*#__PURE__*/React.createElement(Box, {
45545
45601
  padding: "0 0 ".concat(spacingBottom)
45546
45602
  }, /*#__PURE__*/React.createElement(Box, {
45547
45603
  padding: padding,