@thecb/components 7.7.8-beta.1 → 7.7.8-beta.11
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 +79 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +79 -25
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/highlight-tab-row/HighlightTabRow.js +1 -1
- package/src/components/molecules/module/Module.js +22 -13
- package/src/util/index.js +3 -1
- package/src/util/useCheckElementsInViewport.js +31 -26
- package/src/util/useGetViewportOnResize.js +47 -0
package/dist/index.esm.js
CHANGED
|
@@ -24458,43 +24458,85 @@ 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
|
|
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
|
-
|
|
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
|
|
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
|
|
24481
|
-
|
|
24482
|
-
|
|
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();
|
|
24484
24493
|
|
|
24485
|
-
|
|
24486
|
-
|
|
24487
|
-
|
|
24488
|
-
|
|
24489
|
-
|
|
24490
|
-
|
|
24494
|
+
if (domEl !== null) {
|
|
24495
|
+
if (boundingBox.top < 0 || boundingBox.left < 0 || boundingBox.right > viewportWidth || boundingBox.bottom > viewportHeight) {
|
|
24496
|
+
return false;
|
|
24497
|
+
}
|
|
24498
|
+
}
|
|
24499
|
+
}
|
|
24500
|
+
|
|
24501
|
+
return true;
|
|
24502
|
+
};
|
|
24503
|
+
|
|
24504
|
+
/*
|
|
24505
|
+
Hook that adds a resize listener to the window and updates viewport size via
|
|
24506
|
+
a provided handler function
|
|
24507
|
+
|
|
24508
|
+
(Object: {width: Number, height: Number}, Function) => undefined;
|
|
24509
|
+
|
|
24510
|
+
Provide the current value of the user's viewport and a handler function to receive updated values
|
|
24511
|
+
|
|
24512
|
+
Best used in combination with a useState hook in your component to receive updated values
|
|
24513
|
+
*/
|
|
24514
|
+
|
|
24515
|
+
var useGetViewportOnResize = function useGetViewportOnResize(viewport, updateViewport) {
|
|
24516
|
+
var timeoutID = false;
|
|
24517
|
+
var delay = 250;
|
|
24491
24518
|
|
|
24492
|
-
|
|
24493
|
-
|
|
24519
|
+
var updateViewportValues = function updateViewportValues() {
|
|
24520
|
+
clearTimeout(timeoutID);
|
|
24521
|
+
timeoutID = setTimeout(function () {
|
|
24522
|
+
var newWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
24523
|
+
var newHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
24524
|
+
|
|
24525
|
+
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) {
|
|
24526
|
+
updateViewport({
|
|
24527
|
+
width: newWidth,
|
|
24528
|
+
height: newHeight
|
|
24529
|
+
});
|
|
24494
24530
|
}
|
|
24495
|
-
});
|
|
24496
|
-
}
|
|
24497
|
-
|
|
24531
|
+
}, delay);
|
|
24532
|
+
};
|
|
24533
|
+
|
|
24534
|
+
useEffect$1(function () {
|
|
24535
|
+
window.addEventListener("resize", updateViewportValues);
|
|
24536
|
+
return function () {
|
|
24537
|
+
clearTimeout(timeoutID);
|
|
24538
|
+
};
|
|
24539
|
+
}, []);
|
|
24498
24540
|
};
|
|
24499
24541
|
|
|
24500
24542
|
|
|
@@ -24506,7 +24548,8 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
24506
24548
|
theme: themeUtils,
|
|
24507
24549
|
useFocusInvalidInput: useFocusInvalidInput,
|
|
24508
24550
|
useOutsideClick: useOutsideClickHook,
|
|
24509
|
-
useCheckElementsInViewport: useCheckElementsInViewport
|
|
24551
|
+
useCheckElementsInViewport: useCheckElementsInViewport,
|
|
24552
|
+
useGetViewportOnResize: useGetViewportOnResize
|
|
24510
24553
|
});
|
|
24511
24554
|
|
|
24512
24555
|
var hoverColor$4 = "#116285";
|
|
@@ -40322,6 +40365,8 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
|
|
|
40322
40365
|
useOrderedList: useOrderedList,
|
|
40323
40366
|
useUnorderedList: useUnorderedList
|
|
40324
40367
|
}, repeat( /*#__PURE__*/React.createElement(Box, null), boxesBefore), tabs.map(function (t, i) {
|
|
40368
|
+
var _t$toLowerCase;
|
|
40369
|
+
|
|
40325
40370
|
return /*#__PURE__*/React.createElement(Box, {
|
|
40326
40371
|
key: t,
|
|
40327
40372
|
borderSize: "3px",
|
|
@@ -40336,7 +40381,7 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
|
|
|
40336
40381
|
color: themeValues.textColor,
|
|
40337
40382
|
weight: FONT_WEIGHT_SEMIBOLD,
|
|
40338
40383
|
extraStyles: "display: block; white-space: nowrap;",
|
|
40339
|
-
id: "".concat(t, "-tab-text")
|
|
40384
|
+
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")
|
|
40340
40385
|
}, t));
|
|
40341
40386
|
}), repeat( /*#__PURE__*/React.createElement(Box, null), boxesAfter))));
|
|
40342
40387
|
};
|
|
@@ -45530,19 +45575,28 @@ var Module = function Module(_ref) {
|
|
|
45530
45575
|
variant = _ref$variant === void 0 ? "default" : _ref$variant,
|
|
45531
45576
|
fontSize = _ref.fontSize,
|
|
45532
45577
|
as = _ref.as,
|
|
45578
|
+
_ref$titleID = _ref.titleID,
|
|
45579
|
+
titleID = _ref$titleID === void 0 ? "" : _ref$titleID,
|
|
45580
|
+
rightTitleContent = _ref.rightTitleContent,
|
|
45533
45581
|
children = _ref.children;
|
|
45534
45582
|
var themedFontSize = variant === "small" ? "1.25rem" : variant === "default" ? "1.375rem" : "2rem";
|
|
45535
45583
|
var computedFontSize = fontSize || themedFontSize;
|
|
45536
45584
|
var themedElemType = variant === "small" ? "h6" : variant === "default" ? "h5" : "h2";
|
|
45537
45585
|
var computedElemType = as || themedElemType;
|
|
45538
|
-
|
|
45586
|
+
var headingText = /*#__PURE__*/React.createElement(Title$1, {
|
|
45539
45587
|
weight: themeValues.fontWeight,
|
|
45540
45588
|
color: themeValues.fontColor,
|
|
45541
45589
|
margin: "".concat(spacing, " 0 ").concat(themeValues.titleSpacing, " 0"),
|
|
45542
45590
|
textAlign: themeValues.textAlign,
|
|
45543
45591
|
as: computedElemType,
|
|
45544
|
-
extraStyles: "font-size: ".concat(computedFontSize, ";")
|
|
45545
|
-
|
|
45592
|
+
extraStyles: "font-size: ".concat(computedFontSize, ";"),
|
|
45593
|
+
id: titleID
|
|
45594
|
+
}, heading);
|
|
45595
|
+
return /*#__PURE__*/React.createElement(Fragment$1, null, heading && !rightTitleContent && headingText, heading && rightTitleContent && /*#__PURE__*/React.createElement(Cluster, {
|
|
45596
|
+
justify: "space-between",
|
|
45597
|
+
align: "center",
|
|
45598
|
+
nowrap: true
|
|
45599
|
+
}, headingText, rightTitleContent), /*#__PURE__*/React.createElement(Box, {
|
|
45546
45600
|
padding: "0 0 ".concat(spacingBottom)
|
|
45547
45601
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
45548
45602
|
padding: padding,
|