@fremtind/jkl-cookie-consent-react
Advanced tools
Comparing version 10.2.10 to 10.2.11
@@ -89,7 +89,3 @@ "use strict"; | ||
const requirement = (0, import_react.useMemo)( | ||
() => ({ | ||
marketing: marketing != null ? marketing : false, | ||
functional: functional != null ? functional : false, | ||
statistics: statistics != null ? statistics : false | ||
}), | ||
() => (0, import_cookieConsentUtils.buildRequirementsObject)({ marketing, functional, statistics }), | ||
[marketing, functional, statistics] | ||
@@ -96,0 +92,0 @@ ); |
@@ -21,2 +21,3 @@ "use strict"; | ||
__export(cookieConsentUtils_exports, { | ||
buildRequirementsObject: () => buildRequirementsObject, | ||
convertBooleanConsentObjectToConsentObject: () => convertBooleanConsentObjectToConsentObject, | ||
@@ -127,2 +128,9 @@ convertBooleanToConsentValue: () => convertBooleanToConsentValue, | ||
}; | ||
const buildRequirementsObject = ({ marketing, functional, statistics }) => { | ||
return { | ||
...marketing && { marketing }, | ||
...functional && { functional }, | ||
...statistics && { statistics } | ||
}; | ||
}; | ||
//# sourceMappingURL=cookieConsentUtils.js.map |
@@ -19,1 +19,6 @@ import type { Consent, ConsentRequirement, ConsentState } from "./types"; | ||
export declare const convertBooleanConsentObjectToConsentObject: (consent: Partial<Record<keyof Consent, boolean | undefined>>) => Consent; | ||
export declare const buildRequirementsObject: ({ marketing, functional, statistics }: ConsentRequirement) => { | ||
statistics?: true | undefined; | ||
functional?: true | undefined; | ||
marketing?: true | undefined; | ||
}; |
import React, { useEffect, useMemo } from "react"; | ||
import { shouldShowConsentDialog, getConsentCookie } from "./cookieConsentUtils"; | ||
import { shouldShowConsentDialog, getConsentCookie, buildRequirementsObject } from "./cookieConsentUtils"; | ||
const DEFAULT_COOKIE_NAME = "fremtind-cookie-consent"; | ||
@@ -53,7 +53,3 @@ const CookieConsentContext = React.createContext(void 0); | ||
const requirement = useMemo( | ||
() => ({ | ||
marketing: marketing != null ? marketing : false, | ||
functional: functional != null ? functional : false, | ||
statistics: statistics != null ? statistics : false | ||
}), | ||
() => buildRequirementsObject({ marketing, functional, statistics }), | ||
[marketing, functional, statistics] | ||
@@ -60,0 +56,0 @@ ); |
@@ -97,3 +97,11 @@ const getCookie = (name) => { | ||
}; | ||
const buildRequirementsObject = ({ marketing, functional, statistics }) => { | ||
return { | ||
...marketing && { marketing }, | ||
...functional && { functional }, | ||
...statistics && { statistics } | ||
}; | ||
}; | ||
export { | ||
buildRequirementsObject, | ||
convertBooleanConsentObjectToConsentObject, | ||
@@ -100,0 +108,0 @@ convertBooleanToConsentValue, |
export type ConsentState = null | "denied" | "accepted"; | ||
export type ConsentRequirement = Record<keyof Consent, boolean>; | ||
export type ConsentRequirement = Partial<Record<keyof Consent, boolean>>; | ||
export interface Consent { | ||
marketing: ConsentState; | ||
functional: ConsentState; | ||
statistics: ConsentState; | ||
marketing?: ConsentState; | ||
functional?: ConsentState; | ||
statistics?: ConsentState; | ||
} | ||
@@ -8,0 +8,0 @@ export type AcceptConsentCallback = (consent: Consent) => void; |
{ | ||
"name": "@fremtind/jkl-cookie-consent-react", | ||
"version": "10.2.10", | ||
"version": "10.2.11", | ||
"publishConfig": { | ||
@@ -61,3 +61,3 @@ "access": "public" | ||
}, | ||
"gitHead": "83065ef6a8c64cd824bd94025f40c2444b52d469" | ||
"gitHead": "3b21a6e38dc9f335b28bfd6e345904ebaeceb2e6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124618
1267