@asantemedia-org/edwardsvacuum-design-system 1.6.31 → 1.6.32
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 +36 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -36
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useCallback, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useCallback, useMemo, useEffect } from 'react';
|
|
2
2
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
3
|
import { faChevronDown, faChevronRight, faArrowRight } from '@fortawesome/pro-solid-svg-icons';
|
|
4
4
|
import { v4 } from 'uuid';
|
|
@@ -589,48 +589,46 @@ var AlgoliaDynamicSearch = function (_a, useScopedStyles, styles) {
|
|
|
589
589
|
placeholder = _a.placeholder,
|
|
590
590
|
analytics = _a.analytics,
|
|
591
591
|
facets = _a.facets;
|
|
592
|
-
var _g = useState(isLoading),
|
|
593
|
-
isLoadingState = _g[0],
|
|
594
|
-
setIsLoadingState = _g[1];
|
|
595
|
-
useEffect(function () {
|
|
596
|
-
if (isLoading !== isLoadingState) {
|
|
597
|
-
setIsLoadingState(isLoading);
|
|
598
|
-
}
|
|
599
|
-
}, [isLoading]);
|
|
600
592
|
// Helper to resolve CSS module class names properly
|
|
601
|
-
var getClass = function (suffix) {
|
|
593
|
+
var getClass = useCallback(function (suffix) {
|
|
602
594
|
var fullClassName = "cmpAlgoliaDynamicSearchWidget".concat(suffix);
|
|
603
595
|
return useScopedStyles && styles ? styles[fullClassName] : fullClassName;
|
|
604
|
-
};
|
|
596
|
+
}, [useScopedStyles, styles]);
|
|
605
597
|
// Helper for modifier classes (without the base prefix)
|
|
606
|
-
var getModifierClass = function (modifier) {
|
|
598
|
+
var getModifierClass = useCallback(function (modifier) {
|
|
607
599
|
return useScopedStyles && styles ? styles[modifier] : modifier;
|
|
608
|
-
};
|
|
609
|
-
//
|
|
610
|
-
var
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
600
|
+
}, [useScopedStyles, styles]);
|
|
601
|
+
// Memoize background styling to prevent re-renders
|
|
602
|
+
var widgetStyleProps = useMemo(function () {
|
|
603
|
+
var backgroundStyles = {
|
|
604
|
+
"dark-grey": {
|
|
605
|
+
buttonStyle: "outlineWhite",
|
|
606
|
+
containerBackground: getModifierClass('hasStyleGreyBackground'),
|
|
607
|
+
textColour: "white"
|
|
608
|
+
},
|
|
609
|
+
"silver": {
|
|
610
|
+
buttonStyle: "primary",
|
|
611
|
+
containerBackground: getModifierClass('hasStyleSilverGradientBackground'),
|
|
612
|
+
textColour: "black"
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
return backgroundStyles[backgroundColour.toLowerCase()] || {
|
|
617
616
|
buttonStyle: "primary",
|
|
618
|
-
containerBackground:
|
|
617
|
+
containerBackground: "",
|
|
619
618
|
textColour: "black"
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
var widgetStyleProps = backgroundStyles[backgroundColour.toLowerCase()] || {
|
|
623
|
-
buttonStyle: "primary",
|
|
624
|
-
containerBackground: ""};
|
|
619
|
+
};
|
|
620
|
+
}, [backgroundColour, getModifierClass]);
|
|
625
621
|
if (!hits || hits.length === 0) {
|
|
626
622
|
return null;
|
|
627
623
|
}
|
|
628
624
|
var baseClass = getClass('');
|
|
629
|
-
//
|
|
630
|
-
var wrapperClasses =
|
|
625
|
+
// Memoize wrapper class names
|
|
626
|
+
var wrapperClasses = useMemo(function () {
|
|
627
|
+
return [baseClass, widgetStyleProps.containerBackground, isLoading ? getModifierClass('isLoading') : '', queryType === 'content' ? getModifierClass('isQueryContent') : ''].filter(Boolean).join(' ');
|
|
628
|
+
}, [baseClass, widgetStyleProps.containerBackground, isLoading, queryType, getModifierClass]);
|
|
631
629
|
return /*#__PURE__*/React.createElement("div", {
|
|
632
630
|
className: wrapperClasses
|
|
633
|
-
},
|
|
631
|
+
}, isLoading && /*#__PURE__*/React.createElement("div", {
|
|
634
632
|
className: getClass('__placeholder')
|
|
635
633
|
}, /*#__PURE__*/React.createElement("div", {
|
|
636
634
|
className: getClass('__placeholder__loading')
|
|
@@ -702,6 +700,13 @@ var AlgoliaDynamicSearch = function (_a, useScopedStyles, styles) {
|
|
|
702
700
|
default:
|
|
703
701
|
return null;
|
|
704
702
|
}
|
|
703
|
+
// Only create onClick handler if analytics is provided
|
|
704
|
+
var handleClick = analytics ? function () {
|
|
705
|
+
var objectID = hit.objectID,
|
|
706
|
+
__position = hit.__position,
|
|
707
|
+
__queryID = hit.__queryID;
|
|
708
|
+
analytics(objectID, __queryID, __position);
|
|
709
|
+
} : undefined;
|
|
705
710
|
return /*#__PURE__*/React.createElement(Component, {
|
|
706
711
|
key: hit.objectID || index,
|
|
707
712
|
className: cardClassName,
|
|
@@ -720,13 +725,7 @@ var AlgoliaDynamicSearch = function (_a, useScopedStyles, styles) {
|
|
|
720
725
|
cardLink: cardLink,
|
|
721
726
|
city: hit.city,
|
|
722
727
|
country: hit.country,
|
|
723
|
-
onClick:
|
|
724
|
-
if (!analytics) return;
|
|
725
|
-
var objectID = hit.objectID,
|
|
726
|
-
__position = hit.__position,
|
|
727
|
-
__queryID = hit.__queryID;
|
|
728
|
-
analytics(objectID, __queryID, __position);
|
|
729
|
-
}
|
|
728
|
+
onClick: handleClick
|
|
730
729
|
});
|
|
731
730
|
}))));
|
|
732
731
|
};
|