@thecb/components 7.7.8-beta.1 → 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.cjs.js +80 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +80 -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 +33 -27
- package/src/util/useGetViewportOnResize.js +47 -0
package/dist/index.cjs.js
CHANGED
|
@@ -24466,43 +24466,86 @@ 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
|
|
24469
|
+
(elements: Array<String>, Number, Number) => Boolean;
|
|
24470
|
+
(["#submit-button", "#.module-small", "h2.alert-title"], 1024, 768) => true;
|
|
24470
24471
|
|
|
24471
24472
|
Takes an array of strings that correspond to DOM selectors. Examples:
|
|
24472
24473
|
"#submit-button", ".module-small", "h2.alert-title"
|
|
24473
24474
|
|
|
24475
|
+
Also takes numbers that represent the current viewport width and height.
|
|
24476
|
+
You can either calculate these once in your application before running this hook
|
|
24477
|
+
(so that they only update when the component running the hook re-renders), or you can
|
|
24478
|
+
use the useGetViewportOnResize hook to calculate them when the browser window is resized
|
|
24479
|
+
|
|
24474
24480
|
The document query function will return the *first* element in the document that matches
|
|
24475
24481
|
the string given.
|
|
24476
24482
|
|
|
24477
|
-
A combination string of multiple selectors can also be provided, e.g.:
|
|
24478
|
-
".alert-info, .alert-warning, .alert-error"
|
|
24483
|
+
A combination string of multiple selectors can also be provided as an item in the array, e.g.:
|
|
24484
|
+
".alert-info, .alert-warning, .alert-error". This will return the first element that matches *any* of the provided selectors.
|
|
24479
24485
|
|
|
24480
|
-
|
|
24486
|
+
If the element is present in the DOM (domEL !== null), the function examines the element's bounding box
|
|
24487
|
+
to determine if the element is within the viewport. If any portion of the element is outside of
|
|
24488
|
+
the viewport, the function returns false.
|
|
24481
24489
|
|
|
24482
|
-
If
|
|
24490
|
+
If all elements that exist are within the viewport, the function returns true.
|
|
24483
24491
|
*/
|
|
24484
24492
|
|
|
24485
24493
|
var useCheckElementsInViewport = function useCheckElementsInViewport() {
|
|
24486
24494
|
var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
24495
|
+
var viewportWidth = arguments.length > 1 ? arguments[1] : undefined;
|
|
24496
|
+
var viewportHeight = arguments.length > 2 ? arguments[2] : undefined;
|
|
24487
24497
|
|
|
24488
|
-
var
|
|
24489
|
-
|
|
24490
|
-
|
|
24491
|
-
|
|
24498
|
+
for (var i = 0; i < elements.length; i++) {
|
|
24499
|
+
var domEl = document.querySelector(elements[i]);
|
|
24500
|
+
var boundingBox = domEl === null || domEl === void 0 ? void 0 : domEl.getBoundingClientRect();
|
|
24501
|
+
timesRun++;
|
|
24492
24502
|
|
|
24493
|
-
|
|
24494
|
-
|
|
24495
|
-
|
|
24496
|
-
|
|
24497
|
-
|
|
24498
|
-
|
|
24503
|
+
if (domEl !== null) {
|
|
24504
|
+
if (boundingBox.top < 0 || boundingBox.left < 0 || boundingBox.right > viewportWidth || boundingBox.bottom > viewportHeight) {
|
|
24505
|
+
return false;
|
|
24506
|
+
}
|
|
24507
|
+
}
|
|
24508
|
+
}
|
|
24509
|
+
|
|
24510
|
+
return true;
|
|
24511
|
+
};
|
|
24512
|
+
|
|
24513
|
+
/*
|
|
24514
|
+
Hook that adds a resize listener to the window and updates viewport size via
|
|
24515
|
+
a provided handler function
|
|
24516
|
+
|
|
24517
|
+
(Object: {width: Number, height: Number}, Function) => undefined;
|
|
24518
|
+
|
|
24519
|
+
Provide the current value of the user's viewport and a handler function to receive updated values
|
|
24520
|
+
|
|
24521
|
+
Best used in combination with a useState hook in your component to receive updated values
|
|
24522
|
+
*/
|
|
24523
|
+
|
|
24524
|
+
var useGetViewportOnResize = function useGetViewportOnResize(viewport, updateViewport) {
|
|
24525
|
+
var timeoutID = false;
|
|
24526
|
+
var delay = 250;
|
|
24499
24527
|
|
|
24500
|
-
|
|
24501
|
-
|
|
24528
|
+
var updateViewportValues = function updateViewportValues() {
|
|
24529
|
+
clearTimeout(timeoutID);
|
|
24530
|
+
timeoutID = setTimeout(function () {
|
|
24531
|
+
var newWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
24532
|
+
var newHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
24533
|
+
|
|
24534
|
+
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) {
|
|
24535
|
+
updateViewport({
|
|
24536
|
+
width: newWidth,
|
|
24537
|
+
height: newHeight
|
|
24538
|
+
});
|
|
24502
24539
|
}
|
|
24503
|
-
});
|
|
24504
|
-
}
|
|
24505
|
-
|
|
24540
|
+
}, delay);
|
|
24541
|
+
};
|
|
24542
|
+
|
|
24543
|
+
React.useEffect(function () {
|
|
24544
|
+
window.addEventListener("resize", updateViewportValues);
|
|
24545
|
+
return function () {
|
|
24546
|
+
clearTimeout(timeoutID);
|
|
24547
|
+
};
|
|
24548
|
+
}, []);
|
|
24506
24549
|
};
|
|
24507
24550
|
|
|
24508
24551
|
|
|
@@ -24514,7 +24557,8 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
24514
24557
|
theme: themeUtils,
|
|
24515
24558
|
useFocusInvalidInput: useFocusInvalidInput,
|
|
24516
24559
|
useOutsideClick: useOutsideClickHook,
|
|
24517
|
-
useCheckElementsInViewport: useCheckElementsInViewport
|
|
24560
|
+
useCheckElementsInViewport: useCheckElementsInViewport,
|
|
24561
|
+
useGetViewportOnResize: useGetViewportOnResize
|
|
24518
24562
|
});
|
|
24519
24563
|
|
|
24520
24564
|
var hoverColor$4 = "#116285";
|
|
@@ -40330,6 +40374,8 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
|
|
|
40330
40374
|
useOrderedList: useOrderedList,
|
|
40331
40375
|
useUnorderedList: useUnorderedList
|
|
40332
40376
|
}, repeat( /*#__PURE__*/React__default.createElement(Box, null), boxesBefore), tabs.map(function (t, i) {
|
|
40377
|
+
var _t$toLowerCase;
|
|
40378
|
+
|
|
40333
40379
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
40334
40380
|
key: t,
|
|
40335
40381
|
borderSize: "3px",
|
|
@@ -40344,7 +40390,7 @@ var HighlightTabRow = function HighlightTabRow(_ref) {
|
|
|
40344
40390
|
color: themeValues.textColor,
|
|
40345
40391
|
weight: FONT_WEIGHT_SEMIBOLD,
|
|
40346
40392
|
extraStyles: "display: block; white-space: nowrap;",
|
|
40347
|
-
id: "".concat(t, "-tab-text")
|
|
40393
|
+
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")
|
|
40348
40394
|
}, t));
|
|
40349
40395
|
}), repeat( /*#__PURE__*/React__default.createElement(Box, null), boxesAfter))));
|
|
40350
40396
|
};
|
|
@@ -45538,19 +45584,28 @@ var Module = function Module(_ref) {
|
|
|
45538
45584
|
variant = _ref$variant === void 0 ? "default" : _ref$variant,
|
|
45539
45585
|
fontSize = _ref.fontSize,
|
|
45540
45586
|
as = _ref.as,
|
|
45587
|
+
_ref$titleID = _ref.titleID,
|
|
45588
|
+
titleID = _ref$titleID === void 0 ? "" : _ref$titleID,
|
|
45589
|
+
rightTitleContent = _ref.rightTitleContent,
|
|
45541
45590
|
children = _ref.children;
|
|
45542
45591
|
var themedFontSize = variant === "small" ? "1.25rem" : variant === "default" ? "1.375rem" : "2rem";
|
|
45543
45592
|
var computedFontSize = fontSize || themedFontSize;
|
|
45544
45593
|
var themedElemType = variant === "small" ? "h6" : variant === "default" ? "h5" : "h2";
|
|
45545
45594
|
var computedElemType = as || themedElemType;
|
|
45546
|
-
|
|
45595
|
+
var headingText = /*#__PURE__*/React__default.createElement(Title$1, {
|
|
45547
45596
|
weight: themeValues.fontWeight,
|
|
45548
45597
|
color: themeValues.fontColor,
|
|
45549
45598
|
margin: "".concat(spacing, " 0 ").concat(themeValues.titleSpacing, " 0"),
|
|
45550
45599
|
textAlign: themeValues.textAlign,
|
|
45551
45600
|
as: computedElemType,
|
|
45552
|
-
extraStyles: "font-size: ".concat(computedFontSize, ";")
|
|
45553
|
-
|
|
45601
|
+
extraStyles: "font-size: ".concat(computedFontSize, ";"),
|
|
45602
|
+
id: titleID
|
|
45603
|
+
}, heading);
|
|
45604
|
+
return /*#__PURE__*/React__default.createElement(React.Fragment, null, heading && !rightTitleContent && headingText, heading && rightTitleContent && /*#__PURE__*/React__default.createElement(Cluster, {
|
|
45605
|
+
justify: "space-between",
|
|
45606
|
+
align: "center",
|
|
45607
|
+
nowrap: true
|
|
45608
|
+
}, headingText, rightTitleContent), /*#__PURE__*/React__default.createElement(Box, {
|
|
45554
45609
|
padding: "0 0 ".concat(spacingBottom)
|
|
45555
45610
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
45556
45611
|
padding: padding,
|