optimized-react-component-library-xyz123 0.1.111 → 0.1.112
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.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +66 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1915,6 +1915,60 @@ var useInputMethodDetection = ({
|
|
|
1915
1915
|
}, [mouseClassName, keyboardToggleKey]);
|
|
1916
1916
|
};
|
|
1917
1917
|
|
|
1918
|
+
// src/NewHelpMethodsStandard/useCookieConsent/useCookieConsent.ts
|
|
1919
|
+
import { useCallback as useCallback2, useEffect as useEffect9, useMemo as useMemo2, useState as useState6 } from "react";
|
|
1920
|
+
var useCookieConsent = ({
|
|
1921
|
+
cookieName,
|
|
1922
|
+
choiceKey,
|
|
1923
|
+
expiryYears = 1,
|
|
1924
|
+
onConsentChange
|
|
1925
|
+
}) => {
|
|
1926
|
+
const {
|
|
1927
|
+
acceptCookies,
|
|
1928
|
+
rejectCookies,
|
|
1929
|
+
areCookiesAccepted,
|
|
1930
|
+
hasChoiceBeenMade,
|
|
1931
|
+
clearChoiceFromSession
|
|
1932
|
+
} = useMemo2(
|
|
1933
|
+
() => createCookieConsent({
|
|
1934
|
+
cookieName,
|
|
1935
|
+
choiceKey,
|
|
1936
|
+
expiryYears
|
|
1937
|
+
}),
|
|
1938
|
+
[cookieName, choiceKey, expiryYears]
|
|
1939
|
+
);
|
|
1940
|
+
const [showBanner, setShowBanner] = useState6(false);
|
|
1941
|
+
const handleCookieStateChange = useCallback2(() => {
|
|
1942
|
+
const cookiesNowAccepted = areCookiesAccepted();
|
|
1943
|
+
if (onConsentChange) {
|
|
1944
|
+
onConsentChange(cookiesNowAccepted);
|
|
1945
|
+
}
|
|
1946
|
+
setShowBanner(false);
|
|
1947
|
+
}, [areCookiesAccepted, onConsentChange]);
|
|
1948
|
+
useEffect9(() => {
|
|
1949
|
+
const cookiesAccepted = areCookiesAccepted();
|
|
1950
|
+
const choiceMade = hasChoiceBeenMade();
|
|
1951
|
+
setShowBanner(!cookiesAccepted && !choiceMade);
|
|
1952
|
+
if (cookiesAccepted && onConsentChange) {
|
|
1953
|
+
onConsentChange(true);
|
|
1954
|
+
}
|
|
1955
|
+
const handleShowBannerEvent = () => {
|
|
1956
|
+
clearChoiceFromSession();
|
|
1957
|
+
setShowBanner(true);
|
|
1958
|
+
};
|
|
1959
|
+
window.addEventListener("showCookieBanner", handleShowBannerEvent);
|
|
1960
|
+
return () => {
|
|
1961
|
+
window.removeEventListener("showCookieBanner", handleShowBannerEvent);
|
|
1962
|
+
};
|
|
1963
|
+
}, [areCookiesAccepted, hasChoiceBeenMade, clearChoiceFromSession, onConsentChange]);
|
|
1964
|
+
return {
|
|
1965
|
+
showBanner,
|
|
1966
|
+
handleCookieStateChange,
|
|
1967
|
+
acceptCookies,
|
|
1968
|
+
rejectCookies
|
|
1969
|
+
};
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1918
1972
|
// src/NewRenderFormComponentStandard/RenderQuestion/RenderQuestion.tsx
|
|
1919
1973
|
import { Fragment as Fragment12, jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1920
1974
|
var RenderQuestion = ({
|
|
@@ -2674,7 +2728,7 @@ var Header = ({
|
|
|
2674
2728
|
var HeaderStandard_default = Header;
|
|
2675
2729
|
|
|
2676
2730
|
// src/NewTextComponentStandard/InfoOnlyStandard/InfoOnlyStandard.tsx
|
|
2677
|
-
import { useEffect as
|
|
2731
|
+
import { useEffect as useEffect10 } from "react";
|
|
2678
2732
|
import DOMPurify4 from "dompurify";
|
|
2679
2733
|
import { Fragment as Fragment14, jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2680
2734
|
var cleanText = (text) => DOMPurify4.sanitize(text, { ADD_ATTR: ["target", "class"] });
|
|
@@ -2688,7 +2742,7 @@ var InfoOnly = ({
|
|
|
2688
2742
|
tabIndex = -1,
|
|
2689
2743
|
activatedLanguage = "sv"
|
|
2690
2744
|
}) => {
|
|
2691
|
-
|
|
2745
|
+
useEffect10(() => {
|
|
2692
2746
|
handleSeenText(questionObject);
|
|
2693
2747
|
}, []);
|
|
2694
2748
|
const handleSeenText = (questionObject2) => {
|
|
@@ -3214,6 +3268,7 @@ export {
|
|
|
3214
3268
|
makeQuestionsSelectors,
|
|
3215
3269
|
removeScriptById,
|
|
3216
3270
|
toggleScriptByConsent,
|
|
3271
|
+
useCookieConsent,
|
|
3217
3272
|
useFormStatusModal,
|
|
3218
3273
|
useInputMethodDetection,
|
|
3219
3274
|
usePTSPageTitle
|