video-privacy 1.0.3 → 1.1.0-beta.1

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.
Files changed (2) hide show
  1. package/dist/index.js +31 -2
  2. package/package.json +5 -1
package/dist/index.js CHANGED
@@ -1,7 +1,22 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
2
  import React, { useState } from 'react';
3
+ import Cookies from 'js-cookie';
3
4
  import { jsx, jsxs } from 'react/jsx-runtime';
4
5
 
6
+ function HandleAcknowledge(_ref) {
7
+ var setAcknowledged = _ref.setAcknowledged,
8
+ cookie = _ref.cookie,
9
+ cookieName = _ref.cookieName,
10
+ cookieExpires = _ref.cookieExpires;
11
+ setAcknowledged(true);
12
+ if (cookie) {
13
+ Cookies.set(cookieName, true, cookieExpires && {
14
+ expires: cookieExpires
15
+ });
16
+ }
17
+ return null;
18
+ }
19
+
5
20
  function styleInject(css, ref) {
6
21
  if ( ref === void 0 ) ref = {};
7
22
  var insertAt = ref.insertAt;
@@ -34,9 +49,18 @@ var styles = {"vidprivContainer":"video-privacy-module_vidprivContainer__z9I5r",
34
49
  styleInject(css_248z);
35
50
 
36
51
  function VideoPrivacy(props) {
52
+ // Cookie option active?
53
+
54
+ var initialState = false;
55
+ var cookieName = props.cookieName || "video-privacy-acknowledged";
56
+ var cookieExpires = props.cookieExpires || null;
57
+ if (props.cookie) {
58
+ initialState = Cookies.get(cookieName);
59
+ }
60
+
37
61
  // State to determine if the user has acknowledged the privacy notice
38
62
 
39
- var _useState = useState(false),
63
+ var _useState = useState(initialState),
40
64
  _useState2 = _slicedToArray(_useState, 2),
41
65
  acknowledged = _useState2[0],
42
66
  setAcknowledged = _useState2[1];
@@ -79,7 +103,12 @@ function VideoPrivacy(props) {
79
103
  }), /*#__PURE__*/jsx("button", {
80
104
  className: props.customButtonClass || styles.vidprivButton,
81
105
  onClick: function onClick() {
82
- return setAcknowledged(true);
106
+ return HandleAcknowledge({
107
+ setAcknowledged: setAcknowledged,
108
+ cookie: props.cookie,
109
+ cookieName: cookieName,
110
+ cookieExpires: cookieExpires
111
+ });
83
112
  },
84
113
  children: buttonText
85
114
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "video-privacy",
3
- "version": "1.0.3",
3
+ "version": "1.1.0-beta.1",
4
4
  "scripts": {
5
5
  "rollup": "node_modules/rollup/dist/rollup.js",
6
6
  "dev": "next dev",
@@ -45,6 +45,7 @@
45
45
  "eslint": "^8",
46
46
  "eslint-config-next": "14.2.12",
47
47
  "eslint-plugin-storybook": "^0.8.0",
48
+ "next": "^14.2.13",
48
49
  "rollup": "^4.21.3",
49
50
  "rollup-plugin-postcss": "^4.0.2",
50
51
  "semantic-release": "^24.1.1",
@@ -54,5 +55,8 @@
54
55
  "next": "^14.2",
55
56
  "react": "^18",
56
57
  "react-dom": "^18"
58
+ },
59
+ "dependencies": {
60
+ "js-cookie": "^3.0.5"
57
61
  }
58
62
  }