@dargmuesli/nuxt-cookie-control 6.4.5 → 6.5.3

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 (41) hide show
  1. package/README.md +17 -7
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +2 -2
  4. package/dist/runtime/components/CookieControl.vue +69 -58
  5. package/dist/runtime/components/CookieIframe.vue +1 -1
  6. package/dist/runtime/composables.d.ts +1 -1
  7. package/dist/runtime/constants.d.ts +1 -1
  8. package/dist/runtime/locale/ar.d.ts +1 -1
  9. package/dist/runtime/locale/az.d.ts +1 -1
  10. package/dist/runtime/locale/bg.d.ts +1 -1
  11. package/dist/runtime/locale/ca.d.ts +1 -1
  12. package/dist/runtime/locale/cs.d.ts +1 -1
  13. package/dist/runtime/locale/da.d.ts +1 -1
  14. package/dist/runtime/locale/de.d.ts +1 -1
  15. package/dist/runtime/locale/en.d.ts +1 -1
  16. package/dist/runtime/locale/es.d.ts +1 -1
  17. package/dist/runtime/locale/fi.d.ts +1 -1
  18. package/dist/runtime/locale/fr.d.ts +1 -1
  19. package/dist/runtime/locale/hr.d.ts +1 -1
  20. package/dist/runtime/locale/hu.d.ts +1 -1
  21. package/dist/runtime/locale/it.d.ts +1 -1
  22. package/dist/runtime/locale/ja.d.ts +1 -1
  23. package/dist/runtime/locale/ko.d.ts +1 -1
  24. package/dist/runtime/locale/lt.d.ts +1 -1
  25. package/dist/runtime/locale/nl.d.ts +1 -1
  26. package/dist/runtime/locale/no.d.ts +1 -1
  27. package/dist/runtime/locale/oc.d.ts +1 -1
  28. package/dist/runtime/locale/pl.d.ts +1 -1
  29. package/dist/runtime/locale/pt.d.ts +1 -1
  30. package/dist/runtime/locale/ro.d.ts +1 -1
  31. package/dist/runtime/locale/rs.d.ts +1 -1
  32. package/dist/runtime/locale/ru.d.ts +1 -1
  33. package/dist/runtime/locale/sk.d.ts +1 -1
  34. package/dist/runtime/locale/sv.d.ts +1 -1
  35. package/dist/runtime/locale/tr.d.ts +1 -1
  36. package/dist/runtime/locale/uk.d.ts +1 -1
  37. package/dist/runtime/methods.d.ts +2 -2
  38. package/dist/runtime/methods.mjs +2 -2
  39. package/dist/runtime/plugin.d.ts +2 -2
  40. package/dist/runtime/types.d.ts +2 -2
  41. package/package.json +14 -13
package/README.md CHANGED
@@ -237,18 +237,28 @@ Every property that includes a `{ en: ... }` value is a translatable property th
237
237
  #### Modal
238
238
 
239
239
  ```html
240
- <template #modal>
241
- <h3>Modal title</h3>
242
- <p>Modal description</p>
243
- </template>
240
+ <CookieControl>
241
+ <template #modal>
242
+ <h3>Modal title</h3>
243
+ <p>Modal description</p>
244
+ </template>
245
+ </CookieControl>
244
246
  ```
245
247
 
246
248
  #### Cookie
247
249
 
248
250
  ```html
249
- <template #cookie="{config}">
250
- <span v-for="c in config" :key="c.id" v-text="c.cookies" />
251
- </template>
251
+ <CookieControl>
252
+ <template #cookie="{ cookie }">
253
+ <h3 v-text="cookie.name" />
254
+ <span v-html="cookie.description" />
255
+
256
+ <div v-if="cookie.targetCookieIds">
257
+ <b>Cookie ids: </b>
258
+ <span v-text="cookie?.targetCookieIds?.join(', ')" />
259
+ </div>
260
+ </template>
261
+ </CookieControl>
252
262
  ```
253
263
 
254
264
  ### Props
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "6.4.5",
3
+ "version": "6.5.3",
4
4
  "configKey": "cookieControl",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.0.0"
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { pathToFileURL } from 'node:url';
3
3
  import { createResolver, defineNuxtModule, addPlugin, addImports, addTemplate, extendWebpackConfig, extendViteConfig, resolvePath } from '@nuxt/kit';
4
4
 
5
5
  const name = "@dargmuesli/nuxt-cookie-control";
6
- const version = "6.4.5";
6
+ const version = "6.5.3";
7
7
 
8
8
  const en = {
9
9
  accept: "Accept",
@@ -152,7 +152,7 @@ const module = defineNuxtModule({
152
152
  addTemplate({
153
153
  filename: "cookie-control-options.ts",
154
154
  write: true,
155
- getContents: () => `import { ModuleOptions } from '#cookie-control/types'
155
+ getContents: () => `import type { ModuleOptions } from '#cookie-control/types'
156
156
 
157
157
  export default ${JSON.stringify(
158
158
  moduleOptions,
@@ -77,70 +77,76 @@
77
77
  v-for="cookie in moduleOptions.cookies[cookieType]"
78
78
  :key="cookie.id"
79
79
  >
80
- <div class="cookieControl__ModalInputWrapper">
81
- <input
82
- v-if="
83
- cookieType === CookieType.NECESSARY &&
84
- cookie.name !== 'functional'
85
- "
86
- :id="resolveTranslatable(cookie.name, props.locale)"
87
- type="checkbox"
88
- disabled
89
- checked
90
- />
91
- <input
92
- v-else
93
- :id="resolveTranslatable(cookie.name, props.locale)"
94
- type="checkbox"
95
- :checked="
96
- getCookieIds(localCookiesEnabled).includes(
97
- getCookieId(cookie),
98
- )
99
- "
100
- @change="toogleCookie(cookie)"
101
- />
102
- <button @click="toggleButton($event)">
103
- {{ getName(cookie.name) }}
104
- </button>
105
- <label
106
- class="cookieControl__ModalCookieName"
107
- :for="resolveTranslatable(cookie.name, props.locale)"
108
- tabindex="0"
109
- @keydown="toggleLabel($event)"
110
- >
111
- {{ getName(cookie.name) }}
112
- <span v-if="cookie.description">
113
- {{ getDescription(cookie.description) }}
114
- </span>
115
- <span
80
+ <slot name="cookie" v-bind="{ cookie }">
81
+ <div class="cookieControl__ModalInputWrapper">
82
+ <input
116
83
  v-if="
117
- moduleOptions.isCookieIdVisible &&
118
- cookie.targetCookieIds
84
+ cookieType === CookieType.NECESSARY &&
85
+ cookie.name !== 'functional'
119
86
  "
87
+ :id="resolveTranslatable(cookie.name, props.locale)"
88
+ type="checkbox"
89
+ disabled
90
+ checked
91
+ />
92
+ <input
93
+ v-else
94
+ :id="resolveTranslatable(cookie.name, props.locale)"
95
+ type="checkbox"
96
+ :checked="
97
+ getCookieIds(localCookiesEnabled).includes(
98
+ getCookieId(cookie),
99
+ )
100
+ "
101
+ @change="toogleCookie(cookie)"
102
+ />
103
+ <button @click="toggleButton($event)">
104
+ {{ getName(cookie.name) }}
105
+ </button>
106
+ <label
107
+ class="cookieControl__ModalCookieName"
108
+ :for="
109
+ resolveTranslatable(cookie.name, props.locale)
110
+ "
111
+ tabindex="0"
112
+ @keydown="toggleLabel($event)"
120
113
  >
121
- <br />
122
- {{
123
- 'IDs: ' +
124
- cookie.targetCookieIds
125
- .map((id: string) => `"${id}"`)
126
- .join(', ')
127
- }}
128
- </span>
129
- <template
130
- v-if="Object.entries(cookie.links || {}).length"
131
- >
114
+ {{ getName(cookie.name) }}
115
+ <span v-if="cookie.description">
116
+ {{ getDescription(cookie.description) }}
117
+ </span>
132
118
  <span
133
- v-for="entry in Object.entries(
134
- cookie.links || {},
135
- )"
136
- :key="entry[0]"
119
+ v-if="
120
+ moduleOptions.isCookieIdVisible &&
121
+ cookie.targetCookieIds
122
+ "
137
123
  >
138
124
  <br />
139
- <a :href="entry[0]">{{ entry[1] || entry[0] }}</a>
125
+ {{
126
+ 'IDs: ' +
127
+ cookie.targetCookieIds
128
+ .map((id: string) => `"${id}"`)
129
+ .join(', ')
130
+ }}
140
131
  </span>
141
- </template>
142
- </label>
143
- </div>
132
+ <template
133
+ v-if="Object.entries(cookie.links || {}).length"
134
+ >
135
+ <span
136
+ v-for="entry in Object.entries(
137
+ cookie.links || {},
138
+ )"
139
+ :key="entry[0]"
140
+ >
141
+ <br />
142
+ <a :href="entry[0]">{{
143
+ entry[1] || entry[0]
144
+ }}</a>
145
+ </span>
146
+ </template>
147
+ </label>
148
+ </div>
149
+ </slot>
144
150
  </li>
145
151
  </ul>
146
152
  </template>
@@ -188,7 +194,12 @@ import { ref, computed, onBeforeMount, watch } from 'vue'
188
194
 
189
195
  import { useNuxtApp } from '#app'
190
196
 
191
- import { Cookie, CookieType, Locale, Translatable } from '../types'
197
+ import {
198
+ type Cookie,
199
+ CookieType,
200
+ type Locale,
201
+ type Translatable,
202
+ } from '../types'
192
203
  import {
193
204
  getAllCookieIdsString,
194
205
  getCookieId,
@@ -23,7 +23,7 @@ import { computed } from 'vue'
23
23
 
24
24
  import { useNuxtApp } from '#app'
25
25
 
26
- import { Cookie } from '../types'
26
+ import type { Cookie } from '../types'
27
27
 
28
28
  import { useCookieControl } from '#imports'
29
29
 
@@ -1,2 +1,2 @@
1
- import { State } from './types';
1
+ import type { State } from './types';
2
2
  export declare const useCookieControl: () => State;
@@ -1,2 +1,2 @@
1
- import { Locale } from './types';
1
+ import type { Locale } from './types';
2
2
  export declare const LOCALE_DEFAULT: Locale;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { LocaleStrings } from '../types';
1
+ import type { LocaleStrings } from '../types';
2
2
  declare const _default: LocaleStrings;
3
3
  export default _default;
@@ -1,7 +1,7 @@
1
- import { Cookie, ModuleOptions, Translatable } from './types';
1
+ import type { Cookie, ModuleOptions, Translatable } from './types';
2
2
  export declare const getAllCookieIdsString: (moduleOptions: ModuleOptions) => string;
3
3
  export declare const getCookieId: (cookie: Cookie) => string;
4
4
  export declare const getCookieIds: (cookies: Cookie[]) => string[];
5
- export declare const removeCookie: (name: string) => string;
5
+ export declare const removeCookie: (name: string) => any;
6
6
  export declare const resolveTranslatable: (translatable: Translatable, locale?: import("./types").Locale) => string;
7
7
  export declare const useResolveTranslatable: (locale?: import("./types").Locale) => (translatable: Translatable) => string;
@@ -1,13 +1,13 @@
1
1
  import slugify from "@sindresorhus/slugify";
2
- import { serialize } from "cookie-es";
3
2
  import { LOCALE_DEFAULT } from "./constants.mjs";
3
+ import { useCookie } from "#imports";
4
4
  export const getAllCookieIdsString = (moduleOptions) => getCookieIds([
5
5
  ...moduleOptions.cookies.necessary,
6
6
  ...moduleOptions.cookies.optional
7
7
  ]).join("");
8
8
  export const getCookieId = (cookie) => cookie.id || slugify(resolveTranslatable(cookie.name));
9
9
  export const getCookieIds = (cookies) => cookies.map((cookie) => getCookieId(cookie));
10
- export const removeCookie = (name) => document.cookie = serialize(name, "", { expires: /* @__PURE__ */ new Date(0) });
10
+ export const removeCookie = (name) => useCookie(name, { expires: /* @__PURE__ */ new Date(0) });
11
11
  export const resolveTranslatable = (translatable, locale = LOCALE_DEFAULT) => {
12
12
  if (typeof translatable === "string")
13
13
  return translatable;
@@ -1,5 +1,5 @@
1
- import { Plugin } from '#app';
2
- import { State } from './types';
1
+ import type { Plugin } from '#app';
2
+ import type { State } from './types';
3
3
  declare const plugin: Plugin<{
4
4
  cookies: State;
5
5
  }>;
@@ -1,5 +1,5 @@
1
- import { Ref } from 'vue';
2
- import { CookieOptions } from 'nuxt/app';
1
+ import type { Ref } from 'vue';
2
+ import type { CookieOptions } from 'nuxt/app';
3
3
  export type Locale = 'ar' | 'az' | 'bg' | 'ca' | 'cs' | 'da' | 'de' | 'en' | 'es' | 'fi' | 'fr' | 'hr' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'nl' | 'no' | 'oc' | 'pt' | 'pl' | 'ro' | 'rs' | 'ru' | 'sk' | 'sv' | 'tr' | 'uk';
4
4
  export type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>;
5
5
  export type Translatable = string | PartialRecord<Locale, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "6.4.5",
3
+ "version": "6.5.3",
4
4
  "description": "Nuxt Cookie Control Module",
5
5
  "author": "Dario Ferderber <dario.ferderber@broj42.com>",
6
6
  "maintainers": [
@@ -21,7 +21,7 @@
21
21
  "engines": {
22
22
  "node": ">=16"
23
23
  },
24
- "packageManager": "pnpm@8.9.0",
24
+ "packageManager": "pnpm@8.9.2",
25
25
  "exports": {
26
26
  ".": {
27
27
  "import": "./dist/module.mjs",
@@ -37,36 +37,37 @@
37
37
  "src/locale"
38
38
  ],
39
39
  "scripts": {
40
- "build": "nuxt-module-build",
40
+ "build": "nuxt-module-build build",
41
41
  "lint": "eslint --ext .js,.ts,.vue . && nuxt typecheck",
42
42
  "lint:fix": "eslint --ext .js,.ts,.vue --fix . && nuxt typecheck --fix",
43
43
  "prepack": "pnpm build",
44
44
  "prepare": "husky install"
45
45
  },
46
46
  "dependencies": {
47
- "@nuxt/kit": "^3.7.3",
47
+ "@nuxt/kit": "^3.8.0",
48
48
  "@sindresorhus/slugify": "^2.2.1",
49
49
  "css-vars-ponyfill": "^2.4.8",
50
50
  "string-replace-loader": "^3.1.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@commitlint/cli": "17.7.2",
54
- "@commitlint/config-conventional": "17.7.0",
53
+ "@commitlint/cli": "18.0.0",
54
+ "@commitlint/config-conventional": "18.0.0",
55
55
  "@dargmuesli/nuxt-cookie-control": "link:",
56
56
  "@nuxt/module-builder": "0.5.2",
57
+ "@nuxt/schema": "3.8.0",
57
58
  "@nuxtjs/eslint-config-typescript": "12.1.0",
58
59
  "conventional-changelog-conventionalcommits": "7.0.2",
59
- "eslint": "8.51.0",
60
+ "eslint": "8.52.0",
60
61
  "eslint-config-prettier": "9.0.0",
61
- "eslint-plugin-prettier": "5.0.0",
62
+ "eslint-plugin-prettier": "5.0.1",
62
63
  "husky": "8.0.3",
63
- "lint-staged": "14.0.1",
64
- "nuxt": "3.7.4",
64
+ "lint-staged": "15.0.2",
65
+ "nuxt": "3.8.0",
65
66
  "prettier": "3.0.3",
66
67
  "typescript": "5.2.2",
67
- "vue": "3.3.4",
68
- "vue-tsc": "1.8.18",
69
- "webpack": "5.88.2"
68
+ "vue": "3.3.6",
69
+ "vue-tsc": "1.8.19",
70
+ "webpack": "5.89.0"
70
71
  },
71
72
  "publishConfig": {
72
73
  "access": "public"