mirror of
				https://github.com/Mastermindzh/react-cookie-consent.git
				synced 2025-11-04 02:38:50 +01:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			6.4.0
			...
			9a0c974b2a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9a0c974b2a | |||
| c2f92ec130 | |||
| 7136086602 | 
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
 | 
			
		||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 | 
			
		||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 | 
			
		||||
 | 
			
		||||
## [[6.4.1](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.1))]
 | 
			
		||||
 | 
			
		||||
- Added missing typing
 | 
			
		||||
 | 
			
		||||
## [[6.4.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.0))]
 | 
			
		||||
 | 
			
		||||
- Added visible prop
 | 
			
		||||
 | 
			
		||||
## [[6.3.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.2.3))]
 | 
			
		||||
 | 
			
		||||
- Added the (optional) scrolling effect back in as it is declared legal in some countries now.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								build/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								build/index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -4,6 +4,7 @@ import Cookies from "js-cookie";
 | 
			
		||||
export interface CookieConsentProps {
 | 
			
		||||
  location?: "top" | "bottom" | "none";
 | 
			
		||||
  sameSite?: "strict" | "lax" | "none";
 | 
			
		||||
  visible?: "hidden" | "show" | "byCookieValue";
 | 
			
		||||
  cookieSecurity?: boolean;
 | 
			
		||||
  style?: object;
 | 
			
		||||
  buttonStyle?: object;
 | 
			
		||||
@@ -53,4 +54,17 @@ export default class CookieConsent extends React.Component<CookieConsentProps, {
 | 
			
		||||
 */
 | 
			
		||||
export function getCookieConsentValue(name?: string): string;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Reset the consent cookie
 | 
			
		||||
 * Remove the cookie on browser in order to allow user to change their consent
 | 
			
		||||
 * @param {*} name optional name of the cookie
 | 
			
		||||
 */
 | 
			
		||||
export function resetCookieConsentValue(name?: string);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the legacy cookie name by the regular cookie name
 | 
			
		||||
 * @param {string} name of cookie to get
 | 
			
		||||
 */
 | 
			
		||||
export function getLegacyCookieName(name: string);
 | 
			
		||||
 | 
			
		||||
export { Cookies };
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										156
									
								
								build/index.js
									
									
									
									
									
								
							
							
						
						
									
										156
									
								
								build/index.js
									
									
									
									
									
								
							@@ -179,16 +179,22 @@
 | 
			
		||||
          return l();
 | 
			
		||||
        },
 | 
			
		||||
        OPTIONS: function () {
 | 
			
		||||
          return O;
 | 
			
		||||
          return m;
 | 
			
		||||
        },
 | 
			
		||||
        SAME_SITE_OPTIONS: function () {
 | 
			
		||||
          return g;
 | 
			
		||||
        },
 | 
			
		||||
        VISIBLE_OPTIONS: function () {
 | 
			
		||||
          return S;
 | 
			
		||||
        },
 | 
			
		||||
        default: function () {
 | 
			
		||||
          return w;
 | 
			
		||||
          return B;
 | 
			
		||||
        },
 | 
			
		||||
        getCookieConsentValue: function () {
 | 
			
		||||
          return S;
 | 
			
		||||
          return C;
 | 
			
		||||
        },
 | 
			
		||||
        resetCookieConsentValue: function () {
 | 
			
		||||
          return k;
 | 
			
		||||
        },
 | 
			
		||||
      });
 | 
			
		||||
    const e = require("react");
 | 
			
		||||
@@ -278,8 +284,8 @@
 | 
			
		||||
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
 | 
			
		||||
      return e;
 | 
			
		||||
    }
 | 
			
		||||
    function m(e) {
 | 
			
		||||
      return (m = Object.setPrototypeOf
 | 
			
		||||
    function O(e) {
 | 
			
		||||
      return (O = Object.setPrototypeOf
 | 
			
		||||
        ? Object.getPrototypeOf
 | 
			
		||||
        : function (e) {
 | 
			
		||||
            return e.__proto__ || Object.getPrototypeOf(e);
 | 
			
		||||
@@ -298,24 +304,29 @@
 | 
			
		||||
        e
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
    var O = { TOP: "top", BOTTOM: "bottom", NONE: "none" },
 | 
			
		||||
    var m = { TOP: "top", BOTTOM: "bottom", NONE: "none" },
 | 
			
		||||
      g = { STRICT: "strict", LAX: "lax", NONE: "none" },
 | 
			
		||||
      S = function () {
 | 
			
		||||
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : k,
 | 
			
		||||
      S = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" },
 | 
			
		||||
      C = function () {
 | 
			
		||||
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : w,
 | 
			
		||||
          t = l().get(e);
 | 
			
		||||
        return void 0 === t && (t = l().get(C(e))), t;
 | 
			
		||||
        return void 0 === t && (t = l().get(x(e))), t;
 | 
			
		||||
      },
 | 
			
		||||
      C = function (e) {
 | 
			
		||||
      k = function () {
 | 
			
		||||
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : w;
 | 
			
		||||
        l().remove(e);
 | 
			
		||||
      },
 | 
			
		||||
      x = function (e) {
 | 
			
		||||
        return "".concat(e, "-legacy");
 | 
			
		||||
      },
 | 
			
		||||
      k = "CookieConsent",
 | 
			
		||||
      x = function (e) {
 | 
			
		||||
      w = "CookieConsent",
 | 
			
		||||
      j = function (e) {
 | 
			
		||||
        var t = e.condition,
 | 
			
		||||
          n = e.wrapper,
 | 
			
		||||
          o = e.children;
 | 
			
		||||
        return t ? n(o) : o;
 | 
			
		||||
      },
 | 
			
		||||
      j = (function (e) {
 | 
			
		||||
      T = (function (e) {
 | 
			
		||||
        !(function (e, t) {
 | 
			
		||||
          if ("function" != typeof t && null !== t)
 | 
			
		||||
            throw new TypeError("Super expression must either be null or a function");
 | 
			
		||||
@@ -344,9 +355,9 @@
 | 
			
		||||
            })()),
 | 
			
		||||
            function () {
 | 
			
		||||
              var e,
 | 
			
		||||
                t = m(r);
 | 
			
		||||
                t = O(r);
 | 
			
		||||
              if (i) {
 | 
			
		||||
                var n = m(this).constructor;
 | 
			
		||||
                var n = O(this).constructor;
 | 
			
		||||
                e = Reflect.construct(t, arguments, n);
 | 
			
		||||
              } else e = t.apply(this, arguments);
 | 
			
		||||
              return y(this, e);
 | 
			
		||||
@@ -474,21 +485,26 @@
 | 
			
		||||
                  c = this.props.cookieSecurity;
 | 
			
		||||
                void 0 === c && (c = !location || "https:" === location.protocol);
 | 
			
		||||
                var a = f(f({ expires: r }, o), {}, { sameSite: i, secure: c });
 | 
			
		||||
                i === g.NONE && l().set(C(e), t, a), l().set(e, t, a);
 | 
			
		||||
                i === g.NONE && l().set(x(e), t, a), l().set(e, t, a);
 | 
			
		||||
              },
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
              key: "getCookieValue",
 | 
			
		||||
              value: function () {
 | 
			
		||||
                var e = this.props.cookieName;
 | 
			
		||||
                return S(e);
 | 
			
		||||
                return C(e);
 | 
			
		||||
              },
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
              key: "render",
 | 
			
		||||
              value: function () {
 | 
			
		||||
                var e = this;
 | 
			
		||||
                if (!this.state.visible) return null;
 | 
			
		||||
                switch (this.props.visible) {
 | 
			
		||||
                  case S.HIDDEN:
 | 
			
		||||
                    return null;
 | 
			
		||||
                  case S.BY_COOKIE_VALUE:
 | 
			
		||||
                    if (!this.state.visible) return null;
 | 
			
		||||
                }
 | 
			
		||||
                var n = this.props,
 | 
			
		||||
                  o = n.location,
 | 
			
		||||
                  r = n.style,
 | 
			
		||||
@@ -502,57 +518,57 @@
 | 
			
		||||
                  b = n.contentClasses,
 | 
			
		||||
                  y = n.buttonClasses,
 | 
			
		||||
                  v = n.buttonWrapperClasses,
 | 
			
		||||
                  m = n.declineButtonClasses,
 | 
			
		||||
                  O = n.declineButtonClasses,
 | 
			
		||||
                  h = n.buttonId,
 | 
			
		||||
                  g = n.declineButtonId,
 | 
			
		||||
                  S = n.disableButtonStyles,
 | 
			
		||||
                  C = n.enableDeclineButton,
 | 
			
		||||
                  k = n.flipButtons,
 | 
			
		||||
                  j = n.ButtonComponent,
 | 
			
		||||
                  w = n.overlay,
 | 
			
		||||
                  T = n.overlayClasses,
 | 
			
		||||
                  B = n.overlayStyle,
 | 
			
		||||
                  C = n.disableButtonStyles,
 | 
			
		||||
                  k = n.enableDeclineButton,
 | 
			
		||||
                  x = n.flipButtons,
 | 
			
		||||
                  w = n.ButtonComponent,
 | 
			
		||||
                  T = n.overlay,
 | 
			
		||||
                  B = n.overlayClasses,
 | 
			
		||||
                  E = n.overlayStyle,
 | 
			
		||||
                  P = n.ariaAcceptLabel,
 | 
			
		||||
                  E = n.ariaDeclineLabel,
 | 
			
		||||
                  D = {},
 | 
			
		||||
                  D = n.ariaDeclineLabel,
 | 
			
		||||
                  I = {},
 | 
			
		||||
                  N = {},
 | 
			
		||||
                  _ = {},
 | 
			
		||||
                  R = {};
 | 
			
		||||
                  N = {},
 | 
			
		||||
                  A = {},
 | 
			
		||||
                  L = {};
 | 
			
		||||
                switch (
 | 
			
		||||
                  (a
 | 
			
		||||
                    ? ((D = u({}, r)),
 | 
			
		||||
                      (I = u({}, i)),
 | 
			
		||||
                    ? ((I = u({}, r)),
 | 
			
		||||
                      (_ = u({}, i)),
 | 
			
		||||
                      (N = u({}, c)),
 | 
			
		||||
                      (_ = u({}, l)),
 | 
			
		||||
                      (R = u({}, B)))
 | 
			
		||||
                    : ((D = u({}, f(f({}, this.state.style), r))),
 | 
			
		||||
                      (_ = u({}, f(f({}, this.state.contentStyle), l))),
 | 
			
		||||
                      (R = u({}, f(f({}, this.state.overlayStyle), B))),
 | 
			
		||||
                      S
 | 
			
		||||
                        ? ((I = u({}, i)), (N = u({}, c)))
 | 
			
		||||
                        : ((I = u({}, f(f({}, this.state.buttonStyle), i))),
 | 
			
		||||
                      (A = u({}, l)),
 | 
			
		||||
                      (L = u({}, E)))
 | 
			
		||||
                    : ((I = u({}, f(f({}, this.state.style), r))),
 | 
			
		||||
                      (A = u({}, f(f({}, this.state.contentStyle), l))),
 | 
			
		||||
                      (L = u({}, f(f({}, this.state.overlayStyle), E))),
 | 
			
		||||
                      C
 | 
			
		||||
                        ? ((_ = u({}, i)), (N = u({}, c)))
 | 
			
		||||
                        : ((_ = u({}, f(f({}, this.state.buttonStyle), i))),
 | 
			
		||||
                          (N = u({}, f(f({}, this.state.declineButtonStyle), c))))),
 | 
			
		||||
                  o)
 | 
			
		||||
                ) {
 | 
			
		||||
                  case O.TOP:
 | 
			
		||||
                    D.top = "0";
 | 
			
		||||
                  case m.TOP:
 | 
			
		||||
                    I.top = "0";
 | 
			
		||||
                    break;
 | 
			
		||||
                  case O.BOTTOM:
 | 
			
		||||
                    D.bottom = "0";
 | 
			
		||||
                  case m.BOTTOM:
 | 
			
		||||
                    I.bottom = "0";
 | 
			
		||||
                }
 | 
			
		||||
                var A = [];
 | 
			
		||||
                var R = [];
 | 
			
		||||
                return (
 | 
			
		||||
                  C &&
 | 
			
		||||
                    A.push(
 | 
			
		||||
                  k &&
 | 
			
		||||
                    R.push(
 | 
			
		||||
                      t().createElement(
 | 
			
		||||
                        j,
 | 
			
		||||
                        w,
 | 
			
		||||
                        {
 | 
			
		||||
                          key: "declineButton",
 | 
			
		||||
                          style: N,
 | 
			
		||||
                          className: m,
 | 
			
		||||
                          className: O,
 | 
			
		||||
                          id: g,
 | 
			
		||||
                          "aria-label": E,
 | 
			
		||||
                          "aria-label": D,
 | 
			
		||||
                          onClick: function () {
 | 
			
		||||
                            e.decline();
 | 
			
		||||
                          },
 | 
			
		||||
@@ -560,12 +576,12 @@
 | 
			
		||||
                        p
 | 
			
		||||
                      )
 | 
			
		||||
                    ),
 | 
			
		||||
                  A.push(
 | 
			
		||||
                  R.push(
 | 
			
		||||
                    t().createElement(
 | 
			
		||||
                      j,
 | 
			
		||||
                      w,
 | 
			
		||||
                      {
 | 
			
		||||
                        key: "acceptButton",
 | 
			
		||||
                        style: I,
 | 
			
		||||
                        style: _,
 | 
			
		||||
                        className: y,
 | 
			
		||||
                        id: h,
 | 
			
		||||
                        "aria-label": P,
 | 
			
		||||
@@ -576,23 +592,23 @@
 | 
			
		||||
                      s
 | 
			
		||||
                    )
 | 
			
		||||
                  ),
 | 
			
		||||
                  k && A.reverse(),
 | 
			
		||||
                  x && R.reverse(),
 | 
			
		||||
                  t().createElement(
 | 
			
		||||
                    x,
 | 
			
		||||
                    j,
 | 
			
		||||
                    {
 | 
			
		||||
                      condition: w,
 | 
			
		||||
                      condition: T,
 | 
			
		||||
                      wrapper: function (e) {
 | 
			
		||||
                        return t().createElement("div", { style: R, className: T }, e);
 | 
			
		||||
                        return t().createElement("div", { style: L, className: B }, e);
 | 
			
		||||
                      },
 | 
			
		||||
                    },
 | 
			
		||||
                    t().createElement(
 | 
			
		||||
                      "div",
 | 
			
		||||
                      { className: "".concat(d), style: D },
 | 
			
		||||
                      t().createElement("div", { style: _, className: b }, this.props.children),
 | 
			
		||||
                      { className: "".concat(d), style: I },
 | 
			
		||||
                      t().createElement("div", { style: A, className: b }, this.props.children),
 | 
			
		||||
                      t().createElement(
 | 
			
		||||
                        "div",
 | 
			
		||||
                        { className: "".concat(v) },
 | 
			
		||||
                        A.map(function (e) {
 | 
			
		||||
                        R.map(function (e) {
 | 
			
		||||
                          return e;
 | 
			
		||||
                        })
 | 
			
		||||
                      )
 | 
			
		||||
@@ -605,10 +621,15 @@
 | 
			
		||||
          a
 | 
			
		||||
        );
 | 
			
		||||
      })(e.Component);
 | 
			
		||||
    (j.propTypes = {
 | 
			
		||||
    (T.propTypes = {
 | 
			
		||||
      location: i().oneOf(
 | 
			
		||||
        Object.keys(O).map(function (e) {
 | 
			
		||||
          return O[e];
 | 
			
		||||
        Object.keys(m).map(function (e) {
 | 
			
		||||
          return m[e];
 | 
			
		||||
        })
 | 
			
		||||
      ),
 | 
			
		||||
      visible: i().oneOf(
 | 
			
		||||
        Object.keys(S).map(function (e) {
 | 
			
		||||
          return S[e];
 | 
			
		||||
        })
 | 
			
		||||
      ),
 | 
			
		||||
      sameSite: i().oneOf(
 | 
			
		||||
@@ -655,14 +676,15 @@
 | 
			
		||||
      acceptOnScroll: i().bool,
 | 
			
		||||
      acceptOnScrollPercentage: i().number,
 | 
			
		||||
    }),
 | 
			
		||||
      (j.defaultProps = {
 | 
			
		||||
      (T.defaultProps = {
 | 
			
		||||
        disableStyles: !1,
 | 
			
		||||
        hideOnAccept: !0,
 | 
			
		||||
        hideOnDecline: !0,
 | 
			
		||||
        location: O.BOTTOM,
 | 
			
		||||
        location: m.BOTTOM,
 | 
			
		||||
        visible: S.BY_COOKIE_VALUE,
 | 
			
		||||
        onAccept: function () {},
 | 
			
		||||
        onDecline: function () {},
 | 
			
		||||
        cookieName: k,
 | 
			
		||||
        cookieName: w,
 | 
			
		||||
        cookieValue: !0,
 | 
			
		||||
        declineCookieValue: !1,
 | 
			
		||||
        setDeclineCookie: !0,
 | 
			
		||||
@@ -715,7 +737,7 @@
 | 
			
		||||
        acceptOnScroll: !1,
 | 
			
		||||
        acceptOnScrollPercentage: 25,
 | 
			
		||||
      });
 | 
			
		||||
    const w = j;
 | 
			
		||||
    const B = T;
 | 
			
		||||
  })(),
 | 
			
		||||
    (module.exports = o);
 | 
			
		||||
})();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,11 +1,11 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "react-cookie-consent",
 | 
			
		||||
  "version": "6.3.0",
 | 
			
		||||
  "version": "6.4.1",
 | 
			
		||||
  "lockfileVersion": 2,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "version": "6.3.0",
 | 
			
		||||
      "version": "6.4.1",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "js-cookie": "^2.2.1",
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
    "name": "Rick van Lieshout",
 | 
			
		||||
    "email": "info@rickvanlieshout.com"
 | 
			
		||||
  },
 | 
			
		||||
  "version": "6.3.0",
 | 
			
		||||
  "version": "6.4.1",
 | 
			
		||||
  "description": "A small, simple and customizable cookie consent bar for use in React applications.",
 | 
			
		||||
  "main": "build/index.js",
 | 
			
		||||
  "types": "build/index.d.ts",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								src/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								src/index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -4,6 +4,7 @@ import Cookies from "js-cookie";
 | 
			
		||||
export interface CookieConsentProps {
 | 
			
		||||
  location?: "top" | "bottom" | "none";
 | 
			
		||||
  sameSite?: "strict" | "lax" | "none";
 | 
			
		||||
  visible?: "hidden" | "show" | "byCookieValue";
 | 
			
		||||
  cookieSecurity?: boolean;
 | 
			
		||||
  style?: object;
 | 
			
		||||
  buttonStyle?: object;
 | 
			
		||||
@@ -53,4 +54,17 @@ export default class CookieConsent extends React.Component<CookieConsentProps, {
 | 
			
		||||
 */
 | 
			
		||||
export function getCookieConsentValue(name?: string): string;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Reset the consent cookie
 | 
			
		||||
 * Remove the cookie on browser in order to allow user to change their consent
 | 
			
		||||
 * @param {*} name optional name of the cookie
 | 
			
		||||
 */
 | 
			
		||||
export function resetCookieConsentValue(name?: string);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the legacy cookie name by the regular cookie name
 | 
			
		||||
 * @param {string} name of cookie to get
 | 
			
		||||
 */
 | 
			
		||||
export function getLegacyCookieName(name: string);
 | 
			
		||||
 | 
			
		||||
export { Cookies };
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user