@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.js
CHANGED
|
@@ -14549,6 +14549,36 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14549
14549
|
index = _ref$index === void 0 ? undefined : _ref$index,
|
|
14550
14550
|
_ref$isTitle = _ref.isTitle,
|
|
14551
14551
|
isTitle = _ref$isTitle === void 0 ? false : _ref$isTitle;
|
|
14552
|
+
var getScrollableParent = function getScrollableParent(element) {
|
|
14553
|
+
if (!element) return null;
|
|
14554
|
+
var isScrollable = function isScrollable(el) {
|
|
14555
|
+
var style = getComputedStyle(el);
|
|
14556
|
+
return style.overflowY === "auto" || style.overflowY === "scroll";
|
|
14557
|
+
};
|
|
14558
|
+
var parent = element.parentElement;
|
|
14559
|
+
while (parent) {
|
|
14560
|
+
if (isScrollable(parent)) {
|
|
14561
|
+
return parent;
|
|
14562
|
+
}
|
|
14563
|
+
parent = parent.parentElement;
|
|
14564
|
+
}
|
|
14565
|
+
return document.documentElement; // Fallback to document
|
|
14566
|
+
};
|
|
14567
|
+
|
|
14568
|
+
var scrollToCenter = function scrollToCenter(element) {
|
|
14569
|
+
var scrollableParent = getScrollableParent(element);
|
|
14570
|
+
if (!scrollableParent) return;
|
|
14571
|
+
var parentRect = scrollableParent.getBoundingClientRect();
|
|
14572
|
+
var elementRect = element.getBoundingClientRect();
|
|
14573
|
+
var elementCenterY = elementRect.top + elementRect.height / 2;
|
|
14574
|
+
var parentCenterY = parentRect.top + parentRect.height / 2;
|
|
14575
|
+
var scrollOptions = {
|
|
14576
|
+
top: elementCenterY - parentCenterY + scrollableParent.scrollTop,
|
|
14577
|
+
behavior: "smooth"
|
|
14578
|
+
};
|
|
14579
|
+
scrollableParent.scrollTo(scrollOptions);
|
|
14580
|
+
};
|
|
14581
|
+
|
|
14552
14582
|
// This function is used as the click handler for "Link" and "Button" elements in the to highlight the element
|
|
14553
14583
|
var handleClick = function handleClick(event) {
|
|
14554
14584
|
event.preventDefault();
|
|
@@ -14561,14 +14591,14 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14561
14591
|
// If the element is inside an accordion, open the accordion and scroll to the element
|
|
14562
14592
|
if (isPresent(index)) {
|
|
14563
14593
|
if (!accordion) return;
|
|
14564
|
-
accordion.scrollIntoView({
|
|
14565
|
-
behavior: "smooth",
|
|
14566
|
-
block: "nearest"
|
|
14567
|
-
});
|
|
14568
14594
|
accordion.classList.add("open-accordion__".concat(index));
|
|
14569
14595
|
setTimeout(function () {
|
|
14570
14596
|
element = document.querySelector("[data-element-id=".concat(id, "]"));
|
|
14571
14597
|
if (!element) return;
|
|
14598
|
+
element.scrollIntoView({
|
|
14599
|
+
behavior: "smooth",
|
|
14600
|
+
block: "center"
|
|
14601
|
+
});
|
|
14572
14602
|
element.classList.add("highlight-element");
|
|
14573
14603
|
element.focus();
|
|
14574
14604
|
}, 350);
|
|
@@ -14582,10 +14612,7 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14582
14612
|
if (!(element && card)) return;
|
|
14583
14613
|
var inputWrapper = card.querySelector(".neeto-ui-input");
|
|
14584
14614
|
if (!inputWrapper) return;
|
|
14585
|
-
card
|
|
14586
|
-
behavior: "smooth",
|
|
14587
|
-
block: "nearest"
|
|
14588
|
-
});
|
|
14615
|
+
scrollToCenter(card);
|
|
14589
14616
|
card.classList.add("highlight-element");
|
|
14590
14617
|
inputWrapper.classList.add("highlight-element");
|
|
14591
14618
|
element.focus();
|
|
@@ -14609,15 +14636,12 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14609
14636
|
// If the element is inside an accordion, open the accordion and scroll to the element
|
|
14610
14637
|
if (isPresent(index)) {
|
|
14611
14638
|
if (!accordion) return;
|
|
14612
|
-
accordion.scrollIntoView({
|
|
14613
|
-
behavior: "smooth",
|
|
14614
|
-
block: "nearest"
|
|
14615
|
-
});
|
|
14616
14639
|
accordion.classList.add("open-accordion__".concat(index));
|
|
14617
14640
|
setTimeout(function () {
|
|
14618
14641
|
var _element2;
|
|
14619
14642
|
element = document.querySelector("[data-element-id=".concat(id, "]"));
|
|
14620
14643
|
if (!element) return;
|
|
14644
|
+
scrollToCenter(element);
|
|
14621
14645
|
if (!isTitle) inputWrapper = element;
|
|
14622
14646
|
card === null || card === void 0 ? void 0 : card.classList.add("highlight-element");
|
|
14623
14647
|
(_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.classList.add("highlight-element");
|
|
@@ -14635,10 +14659,7 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14635
14659
|
inputWrapper = _element3;
|
|
14636
14660
|
}
|
|
14637
14661
|
if (!(_element3 && card && inputWrapper)) return;
|
|
14638
|
-
|
|
14639
|
-
behavior: "smooth",
|
|
14640
|
-
block: "nearest"
|
|
14641
|
-
});
|
|
14662
|
+
scrollToCenter(inputWrapper);
|
|
14642
14663
|
inputWrapper.classList.add("highlight-element");
|
|
14643
14664
|
card.classList.add("highlight-element");
|
|
14644
14665
|
_element3.focus();
|
|
@@ -14659,14 +14680,11 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14659
14680
|
if (isPresent(index)) {
|
|
14660
14681
|
var accordion = document.querySelector("[data-accordion-id=".concat(id === null || id === void 0 ? void 0 : id.replace(/-[^-]+$/, ""), "]"));
|
|
14661
14682
|
if (!accordion) return;
|
|
14662
|
-
accordion.scrollIntoView({
|
|
14663
|
-
behavior: "smooth",
|
|
14664
|
-
block: "nearest"
|
|
14665
|
-
});
|
|
14666
14683
|
accordion.classList.add("open-accordion__".concat(index));
|
|
14667
14684
|
setTimeout(function () {
|
|
14668
14685
|
var imageWrapper = document.querySelector("[data-highlight-id=".concat(id, "]"));
|
|
14669
14686
|
if (!imageWrapper) return;
|
|
14687
|
+
scrollToCenter(imageWrapper);
|
|
14670
14688
|
imageWrapper.classList.add("highlight-element");
|
|
14671
14689
|
}, 350);
|
|
14672
14690
|
setTimeout(function () {
|
|
@@ -14677,10 +14695,7 @@ var useElementClick = function useElementClick(_ref) {
|
|
|
14677
14695
|
} else {
|
|
14678
14696
|
var imageWrapper = document.querySelector("[data-highlight-id=".concat(id, "]"));
|
|
14679
14697
|
if (!imageWrapper) return;
|
|
14680
|
-
imageWrapper
|
|
14681
|
-
behavior: "smooth",
|
|
14682
|
-
block: "nearest"
|
|
14683
|
-
});
|
|
14698
|
+
scrollToCenter(imageWrapper);
|
|
14684
14699
|
setTimeout(function () {
|
|
14685
14700
|
imageWrapper.classList.add("highlight-element");
|
|
14686
14701
|
}, 350);
|