@dargmuesli/nuxt-cookie-control 8.6.1 → 9.0.0

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/dist/module.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "8.6.1",
3
+ "version": "9.0.0",
4
4
  "configKey": "cookieControl",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.0.0"
7
7
  },
8
8
  "builder": {
9
- "@nuxt/module-builder": "0.8.4",
9
+ "@nuxt/module-builder": "1.0.0",
10
10
  "unbuild": "unknown"
11
11
  }
12
12
  }
package/dist/module.mjs CHANGED
@@ -16,8 +16,7 @@ const execSrcReplacements = (src, replacements) => {
16
16
  throw new TypeError(
17
17
  "[vite-plugin-replace]: The replacement option 'to' is not of type 'string' or 'Function'"
18
18
  );
19
- } else
20
- src = src.replace(replacement.from, replacement.to);
19
+ } else src = src.replace(replacement.from, replacement.to);
21
20
  }
22
21
  return src;
23
22
  };
@@ -105,7 +104,7 @@ const DEFAULTS = {
105
104
  };
106
105
 
107
106
  const name = "@dargmuesli/nuxt-cookie-control";
108
- const version = "8.6.1";
107
+ const version = "9.0.0";
109
108
 
110
109
  const resolver = createResolver(import.meta.url);
111
110
  const runtimeDir = resolver.resolve("./runtime");
@@ -216,8 +215,7 @@ const loadLocales = async (moduleOptions) => {
216
215
  moduleOptions.locales = [];
217
216
  for (const locale of locales) {
218
217
  const text = await import(pathToFileURL(await resolvePath(resolve(runtimeDir, "locale", locale))).href).then((r) => r.default || r);
219
- if (!text)
220
- throw new Error(`Could not import text for locale ${locale}`);
218
+ if (!text) throw new Error(`Could not import text for locale ${locale}`);
221
219
  moduleOptions.locales.push(locale);
222
220
  moduleOptions.localeTexts[locale] = {
223
221
  ...text,
@@ -5,9 +5,8 @@
5
5
  </ClientOnly>
6
6
  </template>
7
7
 
8
- <script setup lang="ts">
9
- import { useRuntimeConfig } from '#app'
10
-
11
- const runtimeConfig = useRuntimeConfig()
12
- const isPrerendered = runtimeConfig.public.cookieControl._isPrerendered
8
+ <script setup>
9
+ import { useRuntimeConfig } from "#app";
10
+ const runtimeConfig = useRuntimeConfig();
11
+ const isPrerendered = runtimeConfig.public.cookieControl._isPrerendered;
13
12
  </script>
@@ -0,0 +1,19 @@
1
+ declare const isPrerendered: any;
2
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
3
+ declare var __VLS_1: {}, __VLS_8: {};
4
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
5
+ default?: (props: typeof __VLS_1) => any;
6
+ } & {
7
+ default?: (props: typeof __VLS_8) => any;
8
+ }>;
9
+ declare const __VLS_self: import("vue").DefineComponent<{}, {
10
+ isPrerendered: typeof isPrerendered;
11
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
14
+ export default _default;
15
+ type __VLS_WithSlots<T, S> = T & {
16
+ new (): {
17
+ $slots: S;
18
+ };
19
+ };
@@ -16,13 +16,13 @@
16
16
  <div class="cookieControl__BarButtons">
17
17
  <button
18
18
  type="button"
19
- @click="accept()"
19
+ @click="acceptAll()"
20
20
  v-text="localeStrings?.accept"
21
21
  />
22
22
  <button
23
23
  v-if="moduleOptions.isAcceptNecessaryButtonEnabled"
24
24
  type="button"
25
- @click="decline()"
25
+ @click="acceptNecessary()"
26
26
  v-text="localeStrings?.decline"
27
27
  />
28
28
  <button
@@ -76,11 +76,8 @@
76
76
  <template v-if="moduleOptions.cookies[cookieType].length">
77
77
  <h2
78
78
  v-text="
79
- localeStrings &&
80
- (cookieType === CookieType.NECESSARY
81
- ? localeStrings.cookiesNecessary
82
- : localeStrings.cookiesOptional)
83
- "
79
+ localeStrings && (cookieType === CookieType.NECESSARY ? localeStrings.cookiesNecessary : localeStrings.cookiesOptional)
80
+ "
84
81
  />
85
82
  <ul>
86
83
  <li
@@ -91,25 +88,22 @@
91
88
  <div class="cookieControl__ModalInputWrapper">
92
89
  <input
93
90
  v-if="
94
- cookieType === CookieType.NECESSARY &&
95
- cookie.name !== 'functional'
96
- "
97
- :id="resolveTranslatable(cookie.name, props.locale)"
91
+ cookieType === CookieType.NECESSARY && cookie.name !== 'functional'
92
+ "
93
+ :id="resolveTranslatable(cookie.name, locale)"
98
94
  type="checkbox"
99
95
  disabled
100
96
  checked
101
97
  />
102
98
  <input
103
99
  v-else
104
- :id="resolveTranslatable(cookie.name, props.locale)"
100
+ :id="resolveTranslatable(cookie.name, locale)"
105
101
  type="checkbox"
106
102
  :checked="
107
- isConsentGiven === undefined
108
- ? cookie.isPreselected
109
- : getCookieIds(localCookiesEnabled).includes(
110
- cookie.id,
111
- )
112
- "
103
+ isConsentGiven === void 0 ? cookie.isPreselected : getCookieIds(localCookiesEnabled).includes(
104
+ cookie.id
105
+ )
106
+ "
113
107
  @change="toogleCookie(cookie)"
114
108
  />
115
109
  <button type="button" @click="toggleButton($event)">
@@ -117,9 +111,7 @@
117
111
  </button>
118
112
  <label
119
113
  class="cookieControl__ModalCookieName"
120
- :for="
121
- resolveTranslatable(cookie.name, props.locale)
122
- "
114
+ :for="resolveTranslatable(cookie.name, locale)"
123
115
  tabindex="0"
124
116
  @keydown="toggleLabel($event)"
125
117
  >
@@ -129,16 +121,12 @@
129
121
  </span>
130
122
  <span
131
123
  v-if="
132
- moduleOptions.isCookieIdVisible &&
133
- cookie.targetCookieIds
134
- "
124
+ moduleOptions.isCookieIdVisible && cookie.targetCookieIds
125
+ "
135
126
  >
136
127
  <br />
137
128
  {{
138
- 'IDs: ' +
139
- cookie.targetCookieIds
140
- .map((id) => `"${id}"`)
141
- .join(', ')
129
+ "IDs: " + cookie.targetCookieIds.map((id) => `"${id}"`).join(", ")
142
130
  }}
143
131
  </span>
144
132
  <template
@@ -146,18 +134,16 @@
146
134
  >
147
135
  <span
148
136
  v-for="entry in Object.entries(
149
- cookie.links || {},
150
- )"
137
+ cookie.links || {}
138
+ )"
151
139
  :key="entry[0]"
152
140
  >
153
141
  <br />
154
142
  <NuxtLink
155
143
  :to="entry[0]"
156
144
  @click="
157
- !entry[0].toLowerCase().startsWith('http')
158
- ? (isModalActive = false)
159
- : null
160
- "
145
+ !entry[0].toLowerCase().startsWith('http') ? isModalActive = false : null
146
+ "
161
147
  >
162
148
  {{ entry[1] || entry[0] }}
163
149
  </NuxtLink>
@@ -174,32 +160,32 @@
174
160
  <button
175
161
  type="button"
176
162
  @click="
177
- () => {
178
- acceptPartial()
179
- isModalActive = false
180
- }
181
- "
163
+ () => {
164
+ acceptPartial();
165
+ isModalActive = false;
166
+ }
167
+ "
182
168
  v-text="localeStrings?.save"
183
169
  />
184
170
  <button
185
171
  type="button"
186
172
  @click="
187
- () => {
188
- accept()
189
- isModalActive = false
190
- }
191
- "
173
+ () => {
174
+ acceptNecessary();
175
+ isModalActive = false;
176
+ }
177
+ "
192
178
  v-text="localeStrings?.acceptAll"
193
179
  />
194
180
  <button
195
181
  v-if="!moduleOptions.isModalForced"
196
182
  type="button"
197
183
  @click="
198
- () => {
199
- declineAll()
200
- isModalActive = false
201
- }
202
- "
184
+ () => {
185
+ acceptNone();
186
+ isModalActive = false;
187
+ }
188
+ "
203
189
  v-text="localeStrings?.declineAll"
204
190
  />
205
191
  </div>
@@ -211,243 +197,186 @@
211
197
  </ClientOnlyPrerender>
212
198
  </template>
213
199
 
214
- <script setup lang="ts">
215
- import { ref, computed, onBeforeMount, watch } from 'vue'
216
-
217
- import ClientOnlyPrerender from '#cookie-control/components/ClientOnlyPrerender.vue'
218
- import { COOKIE_ID_SEPARATOR } from '#cookie-control/constants'
200
+ <script setup>
201
+ import { ref, computed, onBeforeMount, watch } from "vue";
202
+ import { COOKIE_ID_SEPARATOR } from "#cookie-control/constants";
219
203
  import {
220
204
  getAllCookieIdsString,
221
205
  getCookieIds,
222
206
  removeCookie,
223
- resolveTranslatable,
224
- } from '#cookie-control/methods'
225
- import setCssVariables from '#cookie-control/set-vars'
226
- import {
227
- type Cookie,
228
- CookieType,
229
- type Locale,
230
- type Translatable,
231
- } from '#cookie-control/types'
232
- import { useCookieControl, useCookie, useNuxtApp } from '#imports'
233
-
234
- interface Props {
235
- locale?: Locale
236
- }
237
- const props = withDefaults(defineProps<Props>(), {
238
- locale: 'en',
239
- })
240
-
207
+ resolveTranslatable
208
+ } from "#cookie-control/methods";
209
+ import setCssVariables from "#cookie-control/set-vars";
210
+ import { useCookieControl, useCookie, useNuxtApp } from "#imports";
211
+ const { locale = "en" } = defineProps({
212
+ locale: {
213
+ type: String,
214
+ required: false
215
+ }
216
+ });
241
217
  const {
242
218
  cookiesEnabled,
243
219
  cookiesEnabledIds,
244
220
  isConsentGiven,
245
221
  isModalActive,
246
- moduleOptions,
247
- } = useCookieControl()
248
- const nuxtApp = useNuxtApp()
249
-
250
- // data
251
- const expires = new Date(Date.now() + moduleOptions.cookieExpiryOffsetMs)
252
- const localCookiesEnabled = ref([...(cookiesEnabled.value || [])])
253
- const allCookieIdsString = getAllCookieIdsString(moduleOptions)
222
+ moduleOptions
223
+ } = useCookieControl();
224
+ const nuxtApp = useNuxtApp();
225
+ const expires = new Date(Date.now() + moduleOptions.cookieExpiryOffsetMs);
226
+ const localCookiesEnabled = ref([...cookiesEnabled.value || []]);
227
+ const allCookieIdsString = getAllCookieIdsString(moduleOptions);
254
228
  const cookieIsConsentGiven = useCookie(moduleOptions.cookieNameIsConsentGiven, {
255
229
  expires,
256
- ...moduleOptions.cookieOptions,
257
- })
258
-
230
+ ...moduleOptions.cookieOptions
231
+ });
259
232
  const cookieCookiesEnabledIds = useCookie(
260
233
  moduleOptions.cookieNameCookiesEnabledIds,
261
234
  {
262
235
  expires,
263
- ...moduleOptions.cookieOptions,
264
- },
265
- )
266
-
267
- // computations
236
+ ...moduleOptions.cookieOptions
237
+ }
238
+ );
268
239
  const isSaved = computed(
269
- () =>
270
- getCookieIds(cookiesEnabled.value || [])
271
- .sort()
272
- .join(COOKIE_ID_SEPARATOR) !==
273
- getCookieIds(localCookiesEnabled.value).sort().join(COOKIE_ID_SEPARATOR),
274
- )
275
- const localeStrings = computed(() => moduleOptions.localeTexts[props.locale])
276
-
277
- // methods
278
- const accept = () => {
240
+ () => getCookieIds(cookiesEnabled.value || []).sort().join(COOKIE_ID_SEPARATOR) !== getCookieIds(localCookiesEnabled.value).sort().join(COOKIE_ID_SEPARATOR)
241
+ );
242
+ const localeStrings = computed(() => moduleOptions.localeTexts[locale]);
243
+ const acceptAll = () => {
279
244
  setCookies({
280
245
  isConsentGiven: true,
281
- cookiesOptionalEnabled: moduleOptions.cookies.optional,
282
- })
283
- }
246
+ cookiesOptionalEnabled: moduleOptions.cookies.optional
247
+ });
248
+ };
284
249
  const acceptPartial = () => {
285
- const localCookiesEnabledIds = getCookieIds(localCookiesEnabled.value)
286
-
250
+ const localCookiesEnabledIds = getCookieIds(localCookiesEnabled.value);
287
251
  setCookies({
288
252
  isConsentGiven: true,
289
253
  cookiesOptionalEnabled: [
290
254
  ...moduleOptions.cookies.necessary,
291
- ...moduleOptions.cookies.optional,
292
- ].filter((cookie) => localCookiesEnabledIds.includes(cookie.id)),
293
- })
294
- }
295
- const decline = () => {
255
+ ...moduleOptions.cookies.optional
256
+ ].filter((cookie) => localCookiesEnabledIds.includes(cookie.id))
257
+ });
258
+ };
259
+ const acceptNecessary = () => {
296
260
  setCookies({
297
261
  isConsentGiven: true,
298
- cookiesOptionalEnabled: moduleOptions.cookies.necessary,
299
- })
300
- }
301
- const declineAll = () => {
262
+ cookiesOptionalEnabled: moduleOptions.cookies.necessary
263
+ });
264
+ };
265
+ const acceptNone = () => {
302
266
  setCookies({
303
267
  isConsentGiven: false,
304
- cookiesOptionalEnabled: [],
305
- })
306
- }
307
- const getDescription = (description: Translatable) =>
308
- `${
309
- moduleOptions.isDashInDescriptionEnabled === false ? '' : '-'
310
- } ${resolveTranslatable(description, props.locale)}`
311
- const getName = (name: Translatable) => {
312
- return name === 'functional'
313
- ? localeStrings.value?.cookiesFunctional
314
- : resolveTranslatable(name, props.locale)
315
- }
268
+ cookiesOptionalEnabled: []
269
+ });
270
+ };
271
+ const getDescription = (description) => `${moduleOptions.isDashInDescriptionEnabled === false ? "" : "-"} ${resolveTranslatable(description, locale)}`;
272
+ const getName = (name) => {
273
+ return name === "functional" ? localeStrings.value?.cookiesFunctional : resolveTranslatable(name, locale);
274
+ };
316
275
  const init = () => {
317
- nuxtApp.$cookies.locale.value = props.locale
318
- }
276
+ nuxtApp.$cookies.locale.value = locale;
277
+ };
319
278
  const onModalClick = () => {
320
279
  if (moduleOptions.closeModalOnClickOutside) {
321
- isModalActive.value = false
280
+ isModalActive.value = false;
322
281
  }
323
- }
282
+ };
324
283
  const setCookies = ({
325
284
  cookiesOptionalEnabled: cookiesOptionalEnabledNew,
326
- isConsentGiven: isConsentGivenNew,
327
- }: {
328
- cookiesOptionalEnabled: Cookie[]
329
- isConsentGiven: boolean
285
+ isConsentGiven: isConsentGivenNew
330
286
  }) => {
331
- isConsentGiven.value = isConsentGivenNew // must come before an update to `cookiesEnabled`
332
- cookiesEnabled.value = isConsentGivenNew
333
- ? [
334
- ...moduleOptions.cookies.necessary,
335
- ...moduleOptions.cookies.optional.filter((cookieOptional: Cookie) =>
336
- cookiesOptionalEnabledNew.includes(cookieOptional),
337
- ),
338
- ]
339
- : []
340
- cookiesEnabledIds.value = isConsentGivenNew
341
- ? getCookieIds(cookiesEnabled.value)
342
- : []
343
- }
344
- const toggleButton = ($event: MouseEvent) => {
345
- ;(
346
- ($event.target as HTMLButtonElement | null)
347
- ?.nextSibling as HTMLLabelElement | null
348
- )?.click()
349
- }
350
- const toogleCookie = (cookie: Cookie) => {
351
- const cookieIndex = getCookieIds(localCookiesEnabled.value).indexOf(cookie.id)
352
-
287
+ isConsentGiven.value = isConsentGivenNew;
288
+ cookiesEnabled.value = isConsentGivenNew ? [
289
+ ...moduleOptions.cookies.necessary,
290
+ ...moduleOptions.cookies.optional.filter(
291
+ (cookieOptional) => cookiesOptionalEnabledNew.includes(cookieOptional)
292
+ )
293
+ ] : [];
294
+ cookiesEnabledIds.value = isConsentGivenNew ? getCookieIds(cookiesEnabled.value) : [];
295
+ };
296
+ const toggleButton = ($event) => {
297
+ ;
298
+ $event.target?.nextSibling?.click();
299
+ };
300
+ const toogleCookie = (cookie) => {
301
+ const cookieIndex = getCookieIds(localCookiesEnabled.value).indexOf(cookie.id);
353
302
  if (cookieIndex < 0) {
354
- localCookiesEnabled.value.push(cookie)
303
+ localCookiesEnabled.value.push(cookie);
355
304
  } else {
356
- localCookiesEnabled.value.splice(cookieIndex, 1)
305
+ localCookiesEnabled.value.splice(cookieIndex, 1);
357
306
  }
358
- }
359
- const toggleLabel = ($event: KeyboardEvent) => {
360
- if ($event.key === ' ') ($event.target as HTMLLabelElement | null)?.click()
361
- }
362
-
363
- // lifecycle
307
+ };
308
+ const toggleLabel = ($event) => {
309
+ if ($event.key === " ") $event.target?.click();
310
+ };
364
311
  onBeforeMount(() => {
365
312
  if (moduleOptions.colors) {
366
- const variables: Record<string, string> = {}
367
-
313
+ const variables = {};
368
314
  for (const key in moduleOptions.colors) {
369
- variables[`cookie-control-${key}`] = `${moduleOptions.colors[key]}`
315
+ variables[`cookie-control-${key}`] = `${moduleOptions.colors[key]}`;
370
316
  }
371
-
372
- setCssVariables(variables)
317
+ setCssVariables(variables);
373
318
  }
374
-
375
319
  if (moduleOptions.isModalForced && !isConsentGiven.value) {
376
- isModalActive.value = true
320
+ isModalActive.value = true;
377
321
  }
378
- })
322
+ });
379
323
  watch(
380
324
  () => cookiesEnabled.value,
381
325
  (current, _previous) => {
382
- localCookiesEnabled.value = [...(current || [])]
383
-
326
+ localCookiesEnabled.value = [...current || []];
384
327
  if (isConsentGiven.value) {
385
328
  cookieCookiesEnabledIds.value = getCookieIds(current || []).join(
386
- COOKIE_ID_SEPARATOR,
387
- )
388
-
329
+ COOKIE_ID_SEPARATOR
330
+ );
389
331
  for (const cookieEnabled of current || []) {
390
- if (!cookieEnabled.src) continue
391
-
392
- const script = document.createElement('script')
393
- script.src = cookieEnabled.src
394
-
395
- const headElement = document.getElementsByTagName('head')[0]
396
- if (!headElement) return
397
-
398
- headElement.appendChild(script)
332
+ if (!cookieEnabled.src) continue;
333
+ const script = document.createElement("script");
334
+ script.src = cookieEnabled.src;
335
+ const headElement = document.getElementsByTagName("head")[0];
336
+ if (!headElement) return;
337
+ headElement.appendChild(script);
399
338
  }
400
339
  } else {
401
- cookieCookiesEnabledIds.value = undefined
340
+ cookieCookiesEnabledIds.value = void 0;
402
341
  }
403
-
404
- // delete formerly enabled cookies that are now disabled
405
342
  const cookiesOptionalDisabled = moduleOptions.cookies.optional.filter(
406
- (cookieOptional) => !(current || []).includes(cookieOptional),
407
- )
408
-
343
+ (cookieOptional) => !(current || []).includes(cookieOptional)
344
+ );
409
345
  for (const cookieOptionalDisabled of cookiesOptionalDisabled) {
410
- if (!cookieOptionalDisabled.targetCookieIds) continue
411
-
346
+ if (!cookieOptionalDisabled.targetCookieIds) continue;
412
347
  for (const cookieOptionalDisabledId of cookieOptionalDisabled.targetCookieIds) {
413
- removeCookie(cookieOptionalDisabledId)
348
+ removeCookie(cookieOptionalDisabledId);
414
349
  }
415
-
416
350
  if (cookieOptionalDisabled.src) {
417
351
  for (const script of [
418
352
  ...document.head.querySelectorAll(
419
- `script[src="${cookieOptionalDisabled.src}"]`,
420
- ),
353
+ `script[src="${cookieOptionalDisabled.src}"]`
354
+ )
421
355
  ]) {
422
- script.parentNode?.removeChild(script)
356
+ script.parentNode?.removeChild(script);
423
357
  }
424
358
  }
425
359
  }
426
360
  },
427
- { deep: true },
428
- )
429
-
361
+ { deep: true }
362
+ );
430
363
  watch(isConsentGiven, (current, _previous) => {
431
- if (current === undefined) {
432
- cookieIsConsentGiven.value = undefined
364
+ if (current === void 0) {
365
+ cookieIsConsentGiven.value = void 0;
433
366
  } else {
434
- cookieIsConsentGiven.value = current ? allCookieIdsString : '0'
367
+ cookieIsConsentGiven.value = current ? allCookieIdsString : "0";
435
368
  }
436
- })
437
-
369
+ });
438
370
  watch(
439
- () => props.locale,
440
- (locale) => {
441
- nuxtApp.$cookies.locale.value = locale
442
- },
443
- )
444
-
445
- // initialization
446
- init()
447
-
371
+ () => locale,
372
+ (locale2) => {
373
+ nuxtApp.$cookies.locale.value = locale2;
374
+ }
375
+ );
376
+ init();
448
377
  defineExpose({
449
- accept,
378
+ accept: acceptAll,
450
379
  acceptPartial,
451
- decline,
452
- })
380
+ decline: acceptNecessary
381
+ });
453
382
  </script>
@@ -0,0 +1,223 @@
1
+ import ClientOnlyPrerender from '#cookie-control/components/ClientOnlyPrerender.vue';
2
+ import { getCookieIds, resolveTranslatable } from '#cookie-control/methods';
3
+ import { type Cookie, CookieType, type Locale, type Translatable } from '#cookie-control/types';
4
+ type __VLS_Props = {
5
+ locale?: Locale;
6
+ };
7
+ declare const isConsentGiven: import("vue").Ref<boolean | undefined, boolean | undefined>, isModalActive: import("vue").Ref<boolean, boolean>, moduleOptions: import("#cookie-control/types").ModuleOptions;
8
+ declare const localCookiesEnabled: import("vue").Ref<{
9
+ description?: string | {
10
+ ar?: string | undefined;
11
+ az?: string | undefined;
12
+ be?: string | undefined;
13
+ bg?: string | undefined;
14
+ ca?: string | undefined;
15
+ cs?: string | undefined;
16
+ da?: string | undefined;
17
+ de?: string | undefined;
18
+ en?: string | undefined;
19
+ es?: string | undefined;
20
+ fi?: string | undefined;
21
+ fr?: string | undefined;
22
+ hr?: string | undefined;
23
+ hu?: string | undefined;
24
+ id?: string | undefined;
25
+ it?: string | undefined;
26
+ ja?: string | undefined;
27
+ km?: string | undefined;
28
+ ko?: string | undefined;
29
+ lt?: string | undefined;
30
+ nl?: string | undefined;
31
+ no?: string | undefined;
32
+ oc?: string | undefined;
33
+ pt?: string | undefined;
34
+ pl?: string | undefined;
35
+ ro?: string | undefined;
36
+ rs?: string | undefined;
37
+ ru?: string | undefined;
38
+ sk?: string | undefined;
39
+ sl?: string | undefined;
40
+ sv?: string | undefined;
41
+ tr?: string | undefined;
42
+ uk?: string | undefined;
43
+ "zh-CN"?: string | undefined;
44
+ } | undefined;
45
+ id: string;
46
+ isPreselected?: boolean | undefined;
47
+ name: string | {
48
+ ar?: string | undefined;
49
+ az?: string | undefined;
50
+ be?: string | undefined;
51
+ bg?: string | undefined;
52
+ ca?: string | undefined;
53
+ cs?: string | undefined;
54
+ da?: string | undefined;
55
+ de?: string | undefined;
56
+ en?: string | undefined;
57
+ es?: string | undefined;
58
+ fi?: string | undefined;
59
+ fr?: string | undefined;
60
+ hr?: string | undefined;
61
+ hu?: string | undefined;
62
+ id?: string | undefined;
63
+ it?: string | undefined;
64
+ ja?: string | undefined;
65
+ km?: string | undefined;
66
+ ko?: string | undefined;
67
+ lt?: string | undefined;
68
+ nl?: string | undefined;
69
+ no?: string | undefined;
70
+ oc?: string | undefined;
71
+ pt?: string | undefined;
72
+ pl?: string | undefined;
73
+ ro?: string | undefined;
74
+ rs?: string | undefined;
75
+ ru?: string | undefined;
76
+ sk?: string | undefined;
77
+ sl?: string | undefined;
78
+ sv?: string | undefined;
79
+ tr?: string | undefined;
80
+ uk?: string | undefined;
81
+ "zh-CN"?: string | undefined;
82
+ };
83
+ links?: Record<string, string | null> | undefined;
84
+ src?: string | undefined;
85
+ targetCookieIds?: string[] | undefined;
86
+ }[], Cookie[] | {
87
+ description?: string | {
88
+ ar?: string | undefined;
89
+ az?: string | undefined;
90
+ be?: string | undefined;
91
+ bg?: string | undefined;
92
+ ca?: string | undefined;
93
+ cs?: string | undefined;
94
+ da?: string | undefined;
95
+ de?: string | undefined;
96
+ en?: string | undefined;
97
+ es?: string | undefined;
98
+ fi?: string | undefined;
99
+ fr?: string | undefined;
100
+ hr?: string | undefined;
101
+ hu?: string | undefined;
102
+ id?: string | undefined;
103
+ it?: string | undefined;
104
+ ja?: string | undefined;
105
+ km?: string | undefined;
106
+ ko?: string | undefined;
107
+ lt?: string | undefined;
108
+ nl?: string | undefined;
109
+ no?: string | undefined;
110
+ oc?: string | undefined;
111
+ pt?: string | undefined;
112
+ pl?: string | undefined;
113
+ ro?: string | undefined;
114
+ rs?: string | undefined;
115
+ ru?: string | undefined;
116
+ sk?: string | undefined;
117
+ sl?: string | undefined;
118
+ sv?: string | undefined;
119
+ tr?: string | undefined;
120
+ uk?: string | undefined;
121
+ "zh-CN"?: string | undefined;
122
+ } | undefined;
123
+ id: string;
124
+ isPreselected?: boolean | undefined;
125
+ name: string | {
126
+ ar?: string | undefined;
127
+ az?: string | undefined;
128
+ be?: string | undefined;
129
+ bg?: string | undefined;
130
+ ca?: string | undefined;
131
+ cs?: string | undefined;
132
+ da?: string | undefined;
133
+ de?: string | undefined;
134
+ en?: string | undefined;
135
+ es?: string | undefined;
136
+ fi?: string | undefined;
137
+ fr?: string | undefined;
138
+ hr?: string | undefined;
139
+ hu?: string | undefined;
140
+ id?: string | undefined;
141
+ it?: string | undefined;
142
+ ja?: string | undefined;
143
+ km?: string | undefined;
144
+ ko?: string | undefined;
145
+ lt?: string | undefined;
146
+ nl?: string | undefined;
147
+ no?: string | undefined;
148
+ oc?: string | undefined;
149
+ pt?: string | undefined;
150
+ pl?: string | undefined;
151
+ ro?: string | undefined;
152
+ rs?: string | undefined;
153
+ ru?: string | undefined;
154
+ sk?: string | undefined;
155
+ sl?: string | undefined;
156
+ sv?: string | undefined;
157
+ tr?: string | undefined;
158
+ uk?: string | undefined;
159
+ "zh-CN"?: string | undefined;
160
+ };
161
+ links?: Record<string, string | null> | undefined;
162
+ src?: string | undefined;
163
+ targetCookieIds?: string[] | undefined;
164
+ }[]>;
165
+ declare const isSaved: import("vue").ComputedRef<boolean>;
166
+ declare const localeStrings: import("vue").ComputedRef<Partial<import("#cookie-control/types").LocaleStrings> | undefined>;
167
+ declare const acceptAll: () => void;
168
+ declare const acceptPartial: () => void;
169
+ declare const acceptNecessary: () => void;
170
+ declare const acceptNone: () => void;
171
+ declare const getDescription: (description: Translatable) => string;
172
+ declare const getName: (name: Translatable) => string | undefined;
173
+ declare const onModalClick: () => void;
174
+ declare const toggleButton: ($event: MouseEvent) => void;
175
+ declare const toogleCookie: (cookie: Cookie) => void;
176
+ declare const toggleLabel: ($event: KeyboardEvent) => void;
177
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
178
+ declare var __VLS_9: {}, __VLS_11: {}, __VLS_17: {}, __VLS_19: {
179
+ cookie: any;
180
+ };
181
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
182
+ bar?: (props: typeof __VLS_9) => any;
183
+ } & {
184
+ controlButton?: (props: typeof __VLS_11) => any;
185
+ } & {
186
+ modal?: (props: typeof __VLS_17) => any;
187
+ } & {
188
+ cookie?: (props: typeof __VLS_19) => any;
189
+ }>;
190
+ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
191
+ ClientOnlyPrerender: typeof ClientOnlyPrerender;
192
+ getCookieIds: typeof getCookieIds;
193
+ resolveTranslatable: typeof resolveTranslatable;
194
+ CookieType: typeof CookieType;
195
+ isConsentGiven: typeof isConsentGiven;
196
+ isModalActive: typeof isModalActive;
197
+ moduleOptions: typeof moduleOptions;
198
+ localCookiesEnabled: typeof localCookiesEnabled;
199
+ isSaved: typeof isSaved;
200
+ localeStrings: typeof localeStrings;
201
+ acceptAll: typeof acceptAll;
202
+ acceptPartial: typeof acceptPartial;
203
+ acceptNecessary: typeof acceptNecessary;
204
+ acceptNone: typeof acceptNone;
205
+ getDescription: typeof getDescription;
206
+ getName: typeof getName;
207
+ onModalClick: typeof onModalClick;
208
+ toggleButton: typeof toggleButton;
209
+ toogleCookie: typeof toogleCookie;
210
+ toggleLabel: typeof toggleLabel;
211
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
212
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
213
+ accept: () => void;
214
+ acceptPartial: () => void;
215
+ decline: () => void;
216
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
217
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
218
+ export default _default;
219
+ type __VLS_WithSlots<T, S> = T & {
220
+ new (): {
221
+ $slots: S;
222
+ };
223
+ };
@@ -20,24 +20,17 @@
20
20
  </ClientOnlyPrerender>
21
21
  </template>
22
22
 
23
- <script setup lang="ts">
24
- import { computed } from 'vue'
25
-
26
- import type { Cookie } from '#cookie-control/types'
27
- import ClientOnlyPrerender from '#cookie-control/components/ClientOnlyPrerender.vue'
28
- import { useNuxtApp, useCookieControl } from '#imports'
29
-
30
- const { cookiesEnabled, isModalActive, moduleOptions } = useCookieControl()
31
- const nuxtApp = useNuxtApp()
32
-
33
- // computations
23
+ <script setup>
24
+ import { computed } from "vue";
25
+ import { useNuxtApp, useCookieControl } from "#imports";
26
+ const { cookiesEnabled, isModalActive, moduleOptions } = useCookieControl();
27
+ const nuxtApp = useNuxtApp();
34
28
  const isCookieFunctionalEnabled = computed(
35
- () =>
36
- (cookiesEnabled.value || []).filter(
37
- (cookieEnabled: Cookie) => cookieEnabled.name === 'functional',
38
- ).length > 0,
39
- )
29
+ () => (cookiesEnabled.value || []).filter(
30
+ (cookieEnabled) => cookieEnabled.name === "functional"
31
+ ).length > 0
32
+ );
40
33
  const localeStrings = computed(
41
- () => moduleOptions.localeTexts[nuxtApp.$cookies.locale.value],
42
- )
34
+ () => moduleOptions.localeTexts[nuxtApp.$cookies.locale.value]
35
+ );
43
36
  </script>
@@ -0,0 +1,23 @@
1
+ import ClientOnlyPrerender from '#cookie-control/components/ClientOnlyPrerender.vue';
2
+ declare const isModalActive: import("vue").Ref<boolean, boolean>;
3
+ declare const isCookieFunctionalEnabled: import("vue").ComputedRef<boolean>;
4
+ declare const localeStrings: import("vue").ComputedRef<Partial<import("#cookie-control/types").LocaleStrings> | undefined>;
5
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
6
+ declare var __VLS_5: {};
7
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
8
+ iframe?: (props: typeof __VLS_5) => any;
9
+ }>;
10
+ declare const __VLS_self: import("vue").DefineComponent<{}, {
11
+ ClientOnlyPrerender: typeof ClientOnlyPrerender;
12
+ isModalActive: typeof isModalActive;
13
+ isCookieFunctionalEnabled: typeof isCookieFunctionalEnabled;
14
+ localeStrings: typeof localeStrings;
15
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
16
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
18
+ export default _default;
19
+ type __VLS_WithSlots<T, S> = T & {
20
+ new (): {
21
+ $slots: S;
22
+ };
23
+ };
@@ -1 +1 @@
1
- export declare const locales: import("../types").LocaleStrings[];
1
+ export declare const locales: import("../types.js").LocaleStrings[];
package/dist/types.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { NuxtModule } from '@nuxt/schema'
2
2
 
3
- import type { default as Module } from './module.js'
3
+ import type { default as Module } from './module.mjs'
4
4
 
5
5
  export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
6
 
7
- export { default } from './module.js'
7
+ export { default } from './module.mjs'
package/package.json CHANGED
@@ -14,24 +14,24 @@
14
14
  "@commitlint/cli": "19.8.0",
15
15
  "@commitlint/config-conventional": "19.8.0",
16
16
  "@dargmuesli/nuxt-cookie-control": "link:",
17
- "@nuxt/eslint-config": "1.2.0",
18
- "@nuxt/module-builder": "0.8.4",
19
- "@nuxt/schema": "3.16.1",
17
+ "@nuxt/eslint-config": "1.3.0",
18
+ "@nuxt/module-builder": "1.0.0",
19
+ "@nuxt/schema": "3.16.2",
20
20
  "@semantic-release/changelog": "6.0.3",
21
21
  "@semantic-release/commit-analyzer": "13.0.1",
22
22
  "@semantic-release/git": "10.0.1",
23
23
  "@semantic-release/github": "11.0.1",
24
24
  "@semantic-release/npm": "12.0.1",
25
25
  "@semantic-release/release-notes-generator": "14.0.3",
26
- "eslint": "9.23.0",
26
+ "eslint": "9.24.0",
27
27
  "eslint-config-prettier": "10.1.1",
28
- "eslint-plugin-prettier": "5.2.5",
28
+ "eslint-plugin-prettier": "5.2.6",
29
29
  "husky": "9.1.7",
30
30
  "lint-staged": "15.5.0",
31
- "nuxt": "3.16.1",
31
+ "nuxt": "3.16.2",
32
32
  "prettier": "3.5.3",
33
33
  "semantic-release": "24.2.3",
34
- "vite": "6.2.3",
34
+ "vite": "6.2.5",
35
35
  "vue": "3.5.13",
36
36
  "vue-tsc": "2.2.8",
37
37
  "webpack": "5.98.0"
@@ -41,15 +41,10 @@
41
41
  },
42
42
  "exports": {
43
43
  ".": {
44
- "import": "./dist/module.mjs",
45
- "require": "./dist/module.cjs",
46
- "types": "./dist/types.d.ts"
44
+ "types": "./dist/types.d.mts",
45
+ "import": "./dist/module.mjs"
47
46
  },
48
- "./runtime/*": {
49
- "import": "./dist/runtime/*.js",
50
- "require": "./dist/runtime/*.js",
51
- "types": "./dist/runtime/*.d.ts"
52
- }
47
+ "./runtime/*": "./dist/runtime/*"
53
48
  },
54
49
  "files": [
55
50
  "dist/**/*"
@@ -64,38 +59,44 @@
64
59
  "nuxt gdpr consent"
65
60
  ],
66
61
  "license": "MIT",
67
- "main": "./dist/module.cjs",
68
62
  "maintainers": [
69
63
  "Jonas Thelemann"
70
64
  ],
71
65
  "name": "@dargmuesli/nuxt-cookie-control",
72
- "packageManager": "pnpm@10.7.0",
73
- "publishConfig": {
74
- "access": "public"
75
- },
66
+ "packageManager": "pnpm@10.7.1",
76
67
  "pnpm": {
77
68
  "ignoredBuiltDependencies": [
69
+ "@parcel/watcher",
78
70
  "esbuild"
79
71
  ],
80
72
  "overrides": {
81
73
  "typescript": "5.6.3"
82
74
  }
83
75
  },
76
+ "publishConfig": {
77
+ "access": "public"
78
+ },
84
79
  "repository": "https://github.com/dargmuesli/nuxt-cookie-control",
85
80
  "resolutions": {
86
- "@nuxt/kit": "3.16.1"
81
+ "@nuxt/kit": "3.16.2"
87
82
  },
88
83
  "scripts": {
89
84
  "build": "nuxt-module-build build",
90
85
  "dev": "pnpm --dir playground run dev",
91
86
  "lint": "pnpm run lint:js && pnpm run lint:ts",
92
- "lint:fix": "pnpm run lint:js --fix . && pnpm run lint:ts --fix",
87
+ "lint:fix": "pnpm run lint:js --fix .",
93
88
  "lint:js": "eslint --cache",
94
89
  "lint:ts": "vue-tsc --noEmit",
95
90
  "prepack": "pnpm build",
96
91
  "prepare": "husky && nuxt-module-build prepare"
97
92
  },
98
93
  "type": "module",
99
- "types": "./dist/types.d.ts",
100
- "version": "8.6.1"
94
+ "typesVersions": {
95
+ "*": {
96
+ ".": [
97
+ "./dist/types.d.mts"
98
+ ]
99
+ }
100
+ },
101
+ "version": "9.0.0"
101
102
  }
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
package/dist/module.d.ts DELETED
@@ -1,68 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { CookieOptions } from 'nuxt/app';
3
-
4
- type Locale = 'ar' | 'az' | 'be' | 'bg' | 'ca' | 'cs' | 'da' | 'de' | 'en' | 'es' | 'fi' | 'fr' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'km' | 'ko' | 'lt' | 'nl' | 'no' | 'oc' | 'pt' | 'pl' | 'ro' | 'rs' | 'ru' | 'sk' | 'sv' | 'tr' | 'uk' | 'zh-CN';
5
- type PartialRecord<K extends string | number | symbol, T> = Partial<Record<K, T>>;
6
- type Translatable = string | PartialRecord<Locale, string>;
7
- interface Cookie {
8
- description?: Translatable;
9
- id: string;
10
- isPreselected?: boolean;
11
- name: Translatable;
12
- links?: Record<string, string | null>;
13
- src?: string;
14
- targetCookieIds?: string[];
15
- }
16
- interface LocaleStrings {
17
- accept: string;
18
- acceptAll: string;
19
- bannerDescription: string;
20
- bannerTitle: string;
21
- close: string;
22
- cookiesFunctional: string;
23
- cookiesNecessary: string;
24
- cookiesOptional: string;
25
- iframeBlocked: string;
26
- decline: string;
27
- declineAll: string;
28
- here: string;
29
- manageCookies: string;
30
- save: string;
31
- settingsUnsaved: string;
32
- }
33
- interface ModuleOptions {
34
- _isPrerendered: boolean | undefined;
35
- barPosition: 'top-left' | 'top-right' | 'top-full' | 'bottom-left' | 'bottom-right' | 'bottom-full';
36
- closeModalOnClickOutside: boolean;
37
- colors: false | Record<string, unknown>;
38
- cookieExpiryOffsetMs: number;
39
- cookieNameCookiesEnabledIds: string;
40
- cookieNameIsConsentGiven: string;
41
- cookies: {
42
- necessary: Cookie[];
43
- optional: Cookie[];
44
- };
45
- cookieOptions: CookieOptions & {
46
- readonly?: false;
47
- };
48
- isAcceptNecessaryButtonEnabled: boolean;
49
- isControlButtonEnabled: boolean;
50
- isCookieIdVisible: boolean;
51
- isCssEnabled: boolean;
52
- isCssPonyfillEnabled: boolean;
53
- isDashInDescriptionEnabled: boolean;
54
- isIframeBlocked: boolean;
55
- isModalForced: boolean;
56
- locales: Locale[];
57
- localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>;
58
- }
59
-
60
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
61
-
62
- declare module '@nuxt/schema' {
63
- interface PublicRuntimeConfig {
64
- cookieControl: ModuleOptions;
65
- }
66
- }
67
-
68
- export { _default as default };
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module'