@dargmuesli/nuxt-cookie-control 2.2.3 → 3.0.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.
package/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Nuxt Cookie Control
2
+ [![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href]
3
+
4
+ ![Nuxt Cookie Control](https://drive.google.com/a/broj42.com/uc?id=1FGQVyj2s0OT-gpTYxH_FuQhe6oU9iejW)
5
+
2
6
 
3
7
  Continuing Dario Ferderber's work on [gitlab.com/broj42/nuxt-cookie-control](https://gitlab.com/broj42/nuxt-cookie-control).
4
8
 
5
- ![Nuxt Cookie Control](https://drive.google.com/a/broj42.com/uc?id=1FGQVyj2s0OT-gpTYxH_FuQhe6oU9iejW)
6
- ####
7
9
  Try it out here:
8
10
  [Nuxt.js Cookie Control](https://codesandbox.io/s/vkwqmm577)
9
11
 
@@ -13,8 +15,7 @@ npm i -D @dargmuesli/nuxt-cookie-control
13
15
  yarn add -D @dargmuesli/nuxt-cookie-control
14
16
  pnpm i -D @dargmuesli/nuxt-cookie-control
15
17
  ```
16
- [![npm version][npm-version-src]][npm-version-href]
17
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
18
+
18
19
 
19
20
  ```javascript
20
21
  // nuxt.config.js
@@ -49,7 +50,7 @@ const {
49
50
  } = useCookieControl()
50
51
  </script>
51
52
  ```
52
- ## Slot
53
+ ## Component Slots
53
54
  ### Bar
54
55
  ```html
55
56
  <CookieControl>
@@ -188,9 +189,9 @@ Every property the includes a `{ en: ... }` value is a translatable property tha
188
189
  description: {
189
190
  en: 'Used for cookie control.'
190
191
  },
191
- id: 'ga', // if unset, the slugified name will be used
192
+ id: 'ga', // if unset, `getCookieId(cookie)` returns the cookie's slugified name instead, which e.g. is used to fill the state's `enabledCookieIds` list
192
193
  name: {
193
- en: 'Google Analytics'
194
+ en: 'Google Analytics' // you always have to specify a cookie name (in English)
194
195
  },
195
196
  src: 'https://www.googletagmanager.com/gtag/js?id=<API-KEY>',
196
197
  targetCookieIds: ['cookie_control_consent', 'cookie_control_enabled_cookies']
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "2.2.3",
3
+ "version": "3.0.0-beta.1",
4
4
  "configKey": "cookieControl",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.0.0"
package/dist/module.mjs CHANGED
@@ -11,7 +11,7 @@ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
11
11
  const __dirname = __cjs_path__.dirname(__filename);
12
12
  const require = __cjs_mod__.createRequire(import.meta.url);
13
13
  const name = "@dargmuesli/nuxt-cookie-control";
14
- const version = "2.2.3";
14
+ const version = "3.0.0-beta.1";
15
15
 
16
16
  const en = {
17
17
  acceptAll: "Accept all",
@@ -3,7 +3,7 @@
3
3
  <section class="cookieControl">
4
4
  <transition :name="`cookieControl__Bar--${moduleOptions.barPosition}`">
5
5
  <div
6
- v-if="colorsSet && !isConsentGiven"
6
+ v-if="isColorsSet && !isConsentGiven"
7
7
  :class="`cookieControl__Bar cookieControl__Bar--${moduleOptions.barPosition}`"
8
8
  >
9
9
  <div class="cookieControl__BarContainer">
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
  <div class="cookieControl__BarButtons">
17
17
  <button
18
- @click="setConsent({ reload: false })"
18
+ @click="setConsent({})"
19
19
  v-text="localeStrings?.acceptAll"
20
20
  />
21
21
  <button
@@ -33,7 +33,7 @@
33
33
  </transition>
34
34
  <button
35
35
  v-if="
36
- moduleOptions.isControlButtonEnabled && colorsSet && isConsentGiven
36
+ moduleOptions.isControlButtonEnabled && isColorsSet && isConsentGiven
37
37
  "
38
38
  aria-label="Cookie control"
39
39
  class="cookieControl__ControlButton"
@@ -170,7 +170,7 @@ const resolveTranslatable = useResolveTranslatable(props.locale)
170
170
 
171
171
  // data
172
172
  const saved = ref(true)
173
- const colorsSet = ref(false)
173
+ const isColorsSet = ref(false)
174
174
 
175
175
  // computations
176
176
  const localeStrings = computed(() => moduleOptions.localeTexts[props.locale])
@@ -190,12 +190,10 @@ const toogleCookie = (cookie: Cookie) => {
190
190
  const setConsent = ({
191
191
  type = undefined,
192
192
  isConsentGiven = true,
193
- reload = true,
194
193
  declineAll = false,
195
194
  }: {
196
195
  type?: 'partial'
197
196
  isConsentGiven?: boolean
198
- reload?: boolean
199
197
  declineAll?: boolean
200
198
  }) => {
201
199
  const cookieIds = declineAll
@@ -215,12 +213,8 @@ const setConsent = ({
215
213
  expires: expirationDate,
216
214
  })
217
215
 
218
- if (reload) {
219
- window.location.reload()
220
- } else {
221
- setConsentFun()
222
- isModalActive.value = false
223
- }
216
+ setConsentFun()
217
+ isModalActive.value = false
224
218
  }
225
219
  const getDescription = (description: Translatable) =>
226
220
  `${
@@ -255,6 +249,8 @@ onBeforeMount(async () => {
255
249
  )
256
250
  }
257
251
  }
252
+
253
+ isColorsSet.value = true
258
254
  }
259
255
 
260
256
  const cookieControlConsent = getCookieControlConsent()
@@ -270,7 +266,5 @@ onBeforeMount(async () => {
270
266
  }
271
267
  }
272
268
  }
273
-
274
- colorsSet.value = true
275
269
  })
276
270
  </script>
@@ -4,10 +4,7 @@ import { useCookieControl } from "./composables.mjs";
4
4
  import { LOCALE_DEFAULT } from "./constants.mjs";
5
5
  export const useAcceptNecessary = () => {
6
6
  const { cookiesEnabled, moduleOptions } = useCookieControl();
7
- return () => acceptNecessary(
8
- cookiesEnabled,
9
- moduleOptions.cookies?.necessary
10
- );
7
+ return () => acceptNecessary(cookiesEnabled, moduleOptions.cookies?.necessary);
11
8
  };
12
9
  export const acceptNecessary = (cookiesEnabledRef, cookiesNecessary = []) => {
13
10
  const expires = new Date();
@@ -21,7 +18,6 @@ export const acceptNecessary = (cookiesEnabledRef, cookiesNecessary = []) => {
21
18
  expires
22
19
  });
23
20
  setHead(cookiesEnabledRef.value);
24
- window.location.reload();
25
21
  };
26
22
  export const useResolveTranslatable = (locale = LOCALE_DEFAULT) => {
27
23
  return (translatable) => resolveTranslatable(translatable, locale);
@@ -59,26 +55,23 @@ export const setConsent = ({
59
55
  if (isConsentGiven.value) {
60
56
  const enabledFromCookie = Cookies.get("cookie_control_enabled_cookies");
61
57
  cookiesEnabled.value.push(
62
- ...moduleOptions.cookies.optional.filter((cookieOptional) => {
63
- return enabledFromCookie?.includes(getCookieId(cookieOptional));
64
- })
58
+ ...moduleOptions.cookies.optional.filter(
59
+ (cookieOptional) => enabledFromCookie?.includes(getCookieId(cookieOptional))
60
+ )
65
61
  );
66
62
  }
67
63
  if (moduleOptions.cookies?.necessary)
68
64
  cookiesEnabled.value.push(
69
- ...moduleOptions.cookies.necessary.filter((cookieNecessary) => {
70
- return cookieNecessary.src;
71
- })
65
+ ...moduleOptions.cookies.necessary.filter(
66
+ (cookieNecessary) => cookieNecessary.src
67
+ )
72
68
  );
73
69
  cookiesEnabledIds.value = cookiesEnabled.value.map(
74
70
  (cookieEnabled) => getCookieId(cookieEnabled)
75
71
  );
76
72
  if (process.client && !isInit) {
77
73
  setHead(cookiesEnabled.value);
78
- clearCookies(
79
- cookiesEnabledIds.value,
80
- moduleOptions.cookies.optional
81
- );
74
+ clearCookies(cookiesEnabledIds.value, moduleOptions.cookies.optional);
82
75
  }
83
76
  };
84
77
  export const getCookieControlConsent = () => Cookies.get("cookie_control_consent");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "2.2.3",
3
+ "version": "3.0.0-beta.1",
4
4
  "description": "Nuxt Cookies Control Module",
5
5
  "author": "Dario Ferderber <dario.ferderber@broj42.com>",
6
6
  "maintainers": [
@@ -52,10 +52,10 @@
52
52
  "husky": "8.0.3",
53
53
  "lint-staged": "13.1.0",
54
54
  "nuxt": "3.0.0",
55
- "prettier": "2.8.1",
55
+ "prettier": "2.8.2",
56
56
  "typescript": "4.9.4",
57
57
  "vue": "3.2.45",
58
- "vue-tsc": "1.0.22",
58
+ "vue-tsc": "1.0.24",
59
59
  "webpack": "5.75.0"
60
60
  },
61
61
  "resolutions": {