@bigbinary/neeto-site-blocks 1.8.20 → 1.8.21
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 +39 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +39 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -14595,6 +14595,36 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14595
14595
|
index = _ref$index === void 0 ? undefined : _ref$index,
|
|
14596
14596
|
_ref$isTitle = _ref.isTitle,
|
|
14597
14597
|
isTitle = _ref$isTitle === void 0 ? false : _ref$isTitle;
|
|
14598
|
+
var getScrollableParent = function getScrollableParent(element) {
|
|
14599
|
+
if (!element) return null;
|
|
14600
|
+
var isScrollable = function isScrollable(el) {
|
|
14601
|
+
var style = getComputedStyle(el);
|
|
14602
|
+
return style.overflowY === "auto" || style.overflowY === "scroll";
|
|
14603
|
+
};
|
|
14604
|
+
var parent = element.parentElement;
|
|
14605
|
+
while (parent) {
|
|
14606
|
+
if (isScrollable(parent)) {
|
|
14607
|
+
return parent;
|
|
14608
|
+
}
|
|
14609
|
+
parent = parent.parentElement;
|
|
14610
|
+
}
|
|
14611
|
+
return document.documentElement; // Fallback to document
|
|
14612
|
+
};
|
|
14613
|
+
|
|
14614
|
+
var scrollToCenter = function scrollToCenter(element) {
|
|
14615
|
+
var scrollableParent = getScrollableParent(element);
|
|
14616
|
+
if (!scrollableParent) return;
|
|
14617
|
+
var parentRect = scrollableParent.getBoundingClientRect();
|
|
14618
|
+
var elementRect = element.getBoundingClientRect();
|
|
14619
|
+
var elementCenterY = elementRect.top + elementRect.height / 2;
|
|
14620
|
+
var parentCenterY = parentRect.top + parentRect.height / 2;
|
|
14621
|
+
var scrollOptions = {
|
|
14622
|
+
top: elementCenterY - parentCenterY + scrollableParent.scrollTop,
|
|
14623
|
+
behavior: "smooth"
|
|
14624
|
+
};
|
|
14625
|
+
scrollableParent.scrollTo(scrollOptions);
|
|
14626
|
+
};
|
|
14627
|
+
|
|
14598
14628
|
// This function is used as the click handler for "Link" and "Button" elements in the to highlight the element
|
|
14599
14629
|
var handleClick = function handleClick(event) {
|
|
14600
14630
|
event.preventDefault();
|
|
@@ -14607,14 +14637,14 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14607
14637
|
// If the element is inside an accordion, open the accordion and scroll to the element
|
|
14608
14638
|
if (neetoCist.isPresent(index)) {
|
|
14609
14639
|
if (!accordion) return;
|
|
14610
|
-
accordion.scrollIntoView({
|
|
14611
|
-
behavior: "smooth",
|
|
14612
|
-
block: "nearest"
|
|
14613
|
-
});
|
|
14614
14640
|
accordion.classList.add("open-accordion__".concat(index));
|
|
14615
14641
|
setTimeout(function () {
|
|
14616
14642
|
element = document.querySelector("[data-element-id=".concat(id, "]"));
|
|
14617
14643
|
if (!element) return;
|
|
14644
|
+
element.scrollIntoView({
|
|
14645
|
+
behavior: "smooth",
|
|
14646
|
+
block: "center"
|
|
14647
|
+
});
|
|
14618
14648
|
element.classList.add("highlight-element");
|
|
14619
14649
|
element.focus();
|
|
14620
14650
|
}, 350);
|
|
@@ -14628,10 +14658,7 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14628
14658
|
if (!(element && card)) return;
|
|
14629
14659
|
var inputWrapper = card.querySelector(".neeto-ui-input");
|
|
14630
14660
|
if (!inputWrapper) return;
|
|
14631
|
-
card
|
|
14632
|
-
behavior: "smooth",
|
|
14633
|
-
block: "nearest"
|
|
14634
|
-
});
|
|
14661
|
+
scrollToCenter(card);
|
|
14635
14662
|
card.classList.add("highlight-element");
|
|
14636
14663
|
inputWrapper.classList.add("highlight-element");
|
|
14637
14664
|
element.focus();
|
|
@@ -14655,15 +14682,12 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14655
14682
|
// If the element is inside an accordion, open the accordion and scroll to the element
|
|
14656
14683
|
if (neetoCist.isPresent(index)) {
|
|
14657
14684
|
if (!accordion) return;
|
|
14658
|
-
accordion.scrollIntoView({
|
|
14659
|
-
behavior: "smooth",
|
|
14660
|
-
block: "nearest"
|
|
14661
|
-
});
|
|
14662
14685
|
accordion.classList.add("open-accordion__".concat(index));
|
|
14663
14686
|
setTimeout(function () {
|
|
14664
14687
|
var _element2;
|
|
14665
14688
|
element = document.querySelector("[data-element-id=".concat(id, "]"));
|
|
14666
14689
|
if (!element) return;
|
|
14690
|
+
scrollToCenter(element);
|
|
14667
14691
|
if (!isTitle) inputWrapper = element;
|
|
14668
14692
|
card === null || card === void 0 ? void 0 : card.classList.add("highlight-element");
|
|
14669
14693
|
(_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.classList.add("highlight-element");
|
|
@@ -14681,10 +14705,7 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14681
14705
|
inputWrapper = _element3;
|
|
14682
14706
|
}
|
|
14683
14707
|
if (!(_element3 && card && inputWrapper)) return;
|
|
14684
|
-
|
|
14685
|
-
behavior: "smooth",
|
|
14686
|
-
block: "nearest"
|
|
14687
|
-
});
|
|
14708
|
+
scrollToCenter(inputWrapper);
|
|
14688
14709
|
inputWrapper.classList.add("highlight-element");
|
|
14689
14710
|
card.classList.add("highlight-element");
|
|
14690
14711
|
_element3.focus();
|
|
@@ -14705,14 +14726,11 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14705
14726
|
if (neetoCist.isPresent(index)) {
|
|
14706
14727
|
var accordion = document.querySelector("[data-accordion-id=".concat(id === null || id === void 0 ? void 0 : id.replace(/-[^-]+$/, ""), "]"));
|
|
14707
14728
|
if (!accordion) return;
|
|
14708
|
-
accordion.scrollIntoView({
|
|
14709
|
-
behavior: "smooth",
|
|
14710
|
-
block: "nearest"
|
|
14711
|
-
});
|
|
14712
14729
|
accordion.classList.add("open-accordion__".concat(index));
|
|
14713
14730
|
setTimeout(function () {
|
|
14714
14731
|
var imageWrapper = document.querySelector("[data-highlight-id=".concat(id, "]"));
|
|
14715
14732
|
if (!imageWrapper) return;
|
|
14733
|
+
scrollToCenter(imageWrapper);
|
|
14716
14734
|
imageWrapper.classList.add("highlight-element");
|
|
14717
14735
|
}, 350);
|
|
14718
14736
|
setTimeout(function () {
|
|
@@ -14723,10 +14741,7 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14723
14741
|
} else {
|
|
14724
14742
|
var imageWrapper = document.querySelector("[data-highlight-id=".concat(id, "]"));
|
|
14725
14743
|
if (!imageWrapper) return;
|
|
14726
|
-
imageWrapper
|
|
14727
|
-
behavior: "smooth",
|
|
14728
|
-
block: "nearest"
|
|
14729
|
-
});
|
|
14744
|
+
scrollToCenter(imageWrapper);
|
|
14730
14745
|
setTimeout(function () {
|
|
14731
14746
|
imageWrapper.classList.add("highlight-element");
|
|
14732
14747
|
}, 350);
|