@dargmuesli/nuxt-cookie-control 3.0.0-beta.3 → 3.0.0-beta.5

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
@@ -154,6 +154,9 @@ isAcceptNecessaryButtonEnabled: true
154
154
  // Switch to toggle the button that opens the configuration modal.
155
155
  isControlButtonEnabled: true,
156
156
 
157
+ // Switch to toggle the concatenation of target cookie ids to the cookie description.
158
+ isCookieIdVisible: false,
159
+
157
160
  // Switch to toggle the inclusion of this module's css.
158
161
  // If css is set to false, you will still be able to access your color variables.
159
162
  isCssEnabled: true,
package/dist/module.d.ts CHANGED
@@ -39,6 +39,7 @@ interface ModuleOptions {
39
39
  cookieNameCookiesEnabledIds: string;
40
40
  isAcceptNecessaryButtonEnabled?: boolean;
41
41
  isControlButtonEnabled?: boolean;
42
+ isCookieIdVisible?: boolean;
42
43
  isCssEnabled?: boolean;
43
44
  isCssPolyfillEnabled?: boolean;
44
45
  isDashInDescriptionEnabled?: boolean;
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "configKey": "cookieControl",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.0.0"
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { resolve } from 'node:path';
2
2
  import { createResolver, defineNuxtModule, addPlugin, addImports, addTemplate, extendWebpackConfig, resolvePath } from '@nuxt/kit';
3
3
 
4
4
  const name = "@dargmuesli/nuxt-cookie-control";
5
- const version = "3.0.0-beta.3";
5
+ const version = "3.0.0-beta.5";
6
6
 
7
7
  const en = {
8
8
  acceptAll: "Accept all",
@@ -60,6 +60,7 @@ const DEFAULTS = {
60
60
  cookieNameCookiesEnabledIds: "cookie_control_cookies_enabled_ids",
61
61
  isAcceptNecessaryButtonEnabled: true,
62
62
  isControlButtonEnabled: true,
63
+ isCookieIdVisible: false,
63
64
  isCssEnabled: true,
64
65
  isCssPolyfillEnabled: true,
65
66
  isDashInDescriptionEnabled: true,
@@ -103,7 +103,12 @@
103
103
  <span v-if="cookie.description">
104
104
  {{ getDescription(cookie.description) }}
105
105
  </span>
106
- <span v-if="cookie.targetCookieIds">
106
+ <span
107
+ v-if="
108
+ moduleOptions.isCookieIdVisible &&
109
+ cookie.targetCookieIds
110
+ "
111
+ >
107
112
  {{
108
113
  ' IDs: ' +
109
114
  cookie.targetCookieIds
@@ -209,9 +214,14 @@ const acceptNecessary = () => {
209
214
  })
210
215
  }
211
216
  const acceptPartial = () => {
217
+ const localCookiesEnabledIds = getCookieIds(localCookiesEnabled.value)
218
+
212
219
  setCookies({
213
220
  isConsentGiven: true,
214
- cookiesOptionalEnabled: localCookiesEnabled.value,
221
+ cookiesOptionalEnabled: [
222
+ ...moduleOptions.cookies?.necessary,
223
+ ...moduleOptions.cookies.optional,
224
+ ].filter((cookie) => localCookiesEnabledIds.includes(getCookieId(cookie))),
215
225
  })
216
226
  }
217
227
  const declineAll = () => {
@@ -221,13 +231,14 @@ const declineAll = () => {
221
231
  })
222
232
  }
223
233
  const toogleCookie = (cookie: Cookie) => {
224
- if (!localCookiesEnabled.value.includes(cookie)) {
234
+ const cookieIndex = getCookieIds(localCookiesEnabled.value).indexOf(
235
+ getCookieId(cookie)
236
+ )
237
+
238
+ if (cookieIndex < 0) {
225
239
  localCookiesEnabled.value.push(cookie)
226
240
  } else {
227
- localCookiesEnabled.value.splice(
228
- localCookiesEnabled.value.indexOf(cookie),
229
- 1
230
- )
241
+ localCookiesEnabled.value.splice(cookieIndex, 1)
231
242
  }
232
243
  }
233
244
  const getDescription = (description: Translatable) =>
@@ -305,6 +316,8 @@ onBeforeMount(async () => {
305
316
  watch(
306
317
  () => cookiesEnabled.value,
307
318
  (current, _previous) => {
319
+ localCookiesEnabled.value = [...(current || [])]
320
+
308
321
  if (isConsentGiven.value) {
309
322
  Cookies.set(
310
323
  moduleOptions.cookieNameCookiesEnabledIds,
@@ -42,6 +42,7 @@ export interface ModuleOptions {
42
42
  cookieNameCookiesEnabledIds: string;
43
43
  isAcceptNecessaryButtonEnabled?: boolean;
44
44
  isControlButtonEnabled?: boolean;
45
+ isCookieIdVisible?: boolean;
45
46
  isCssEnabled?: boolean;
46
47
  isCssPolyfillEnabled?: boolean;
47
48
  isDashInDescriptionEnabled?: boolean;
@@ -42,6 +42,7 @@ export const DEFAULTS = {
42
42
  cookieNameCookiesEnabledIds: "cookie_control_cookies_enabled_ids",
43
43
  isAcceptNecessaryButtonEnabled: true,
44
44
  isControlButtonEnabled: true,
45
+ isCookieIdVisible: false,
45
46
  isCssEnabled: true,
46
47
  isCssPolyfillEnabled: true,
47
48
  isDashInDescriptionEnabled: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "Nuxt Cookies Control Module",
5
5
  "author": "Dario Ferderber <dario.ferderber@broj42.com>",
6
6
  "maintainers": [