@dargmuesli/nuxt-cookie-control 4.5.0 → 4.6.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
@@ -4,38 +4,49 @@
4
4
  ![Nuxt Cookie Control](https://drive.google.com/a/broj42.com/uc?id=1FGQVyj2s0OT-gpTYxH_FuQhe6oU9iejW)
5
5
 
6
6
 
7
- Continuing Dario Ferderber's work on [gitlab.com/broj42/nuxt-cookie-control](https://gitlab.com/broj42/nuxt-cookie-control).
7
+ Translated for: ar, az, cs, da, de, en, es, fr, hr, hu, it, ja, ko, lt, nl, no, pt, ru, sk, tr and uk
8
8
 
9
- 🚩 **Make sure to read the Migration instructions for all major version updates like [v2.0.0](https://github.com/dargmuesli/nuxt-cookie-control/releases/tag/2.0.0), [v3.0.0](https://github.com/dargmuesli/nuxt-cookie-control/releases/tag/3.0.0) and following!**
9
+ Vue 3 support
10
+
11
+ ✅ Components and composables are [auto-imported](https://nuxt.com/docs/guide/concepts/auto-imports)
12
+
13
+ 🚩 API changes since continuing Dario Ferderber's work on [gitlab.com/broj42/nuxt-cookie-control](https://gitlab.com/broj42/nuxt-cookie-control), make sure to read the README!
14
+
15
+
16
+ ## 🚀 Getting Started
10
17
 
11
18
  [![Stackblitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/dargmuesli/nuxt-cookie-control?file=playground%2Fapp.vue)
12
19
 
13
- ## 🚀 Usage
20
+ ### Installation
14
21
  ```bash
15
22
  npm i -D @dargmuesli/nuxt-cookie-control
16
23
  yarn add -D @dargmuesli/nuxt-cookie-control
17
24
  pnpm i -D @dargmuesli/nuxt-cookie-control
18
25
  ```
19
26
 
20
-
27
+ ### Configuration
21
28
  ```javascript
22
29
  // nuxt.config.js
23
30
 
24
31
  modules: [
25
32
  '@dargmuesli/nuxt-cookie-control'
26
- ]
33
+ ],
34
+ cookieControl: {
35
+ // typed module options
36
+ }
37
+
27
38
  // or
39
+
28
40
  modules: [
29
41
  ['@dargmuesli/nuxt-cookie-control', {
30
- // module options
42
+ // untyped module options
31
43
  }]
32
44
  ]
33
45
  ```
34
46
 
35
- Components and composables are [auto-imported](https://nuxt.com/docs/guide/concepts/auto-imports)!
36
-
47
+ ### Usage
37
48
  ```html
38
- <!-- component.vue -->
49
+ <!-- app.vue -->
39
50
 
40
51
  <template>
41
52
  <CookieControl locale="en" />
@@ -49,62 +60,39 @@ const {
49
60
  isModalActive,
50
61
  moduleOptions
51
62
  } = useCookieControl()
63
+
64
+ // example: react to a cookie being accepted
65
+ watch(
66
+ () => cookiesEnabledIds.value,
67
+ (current, previous) => {
68
+ if (
69
+ (!previous?.includes('google-analytics') &&
70
+ current?.includes('google-analytics'))
71
+ ) {
72
+ // cookie with id `google-analytics` got added
73
+ window.location.reload() // placeholder for your custom change handler
74
+ }
75
+ },
76
+ { deep: true }
77
+ )
52
78
  </script>
53
79
  ```
54
- ## Component Slots
55
- ### Bar
56
- ```html
57
- <CookieControl>
58
- <template #bar>
59
- <h3>Bar title</h3>
60
- <p>Bar description (you can use $cookies.text.barDescription)</p>
61
- <n-link>Go somewhere</n-link>
62
- </template>
63
- </CookieControl>
64
- ```
65
- ### Modal
66
- ```html
67
- <template #modal>
68
- <h3>Modal title</h3>
69
- <p>Modal description</p>
70
- </template>
71
- ```
72
- ### Cookie
73
- ```html
74
- <template #cookie="{config}">
75
- <span v-for="c in config" :key="c.id" v-text="c.cookies"/>
76
- </template>
77
- ```
78
80
 
79
- ## Props
80
- - locale: `['en']`
81
- ```html
82
- <CookieControl locale="de"/>
81
+ ```ts
82
+ // plugins/analytics.client.ts
83
+
84
+ // example: initialization based on enabled cookies
85
+ const cookieControl = useCookieControl()
86
+
87
+ if (cookieControl.cookiesEnabledIds.value.includes('google-analytics')) {
88
+ initGoogleAnalytics() // placeholder for your custom initialization
89
+ }
83
90
  ```
84
91
 
85
- Currently available:
86
- - ar
87
- - az
88
- - cs
89
- - da
90
- - de
91
- - en
92
- - es
93
- - fr
94
- - hr
95
- - hu
96
- - it
97
- - ja
98
- - ko
99
- - lt
100
- - nl
101
- - no
102
- - pt
103
- - ru
104
- - sk
105
- - uk
106
-
107
- ## Module Options
92
+
93
+ ## API
94
+
95
+ ### Module Options
108
96
 
109
97
  ```javascript
110
98
  // Position of cookie bar.
@@ -197,7 +185,7 @@ localeTexts: {
197
185
  }
198
186
  ```
199
187
 
200
- ### Cookies
188
+ #### Cookies
201
189
 
202
190
  Every property the includes a `{ en: ... }` value is a translatable property that could instead only specify a string (`'...'`) or other locales as well (`{ de: ..., uk: ... }`).
203
191
 
@@ -215,6 +203,40 @@ Every property the includes a `{ en: ... }` value is a translatable property tha
215
203
  }
216
204
  ```
217
205
 
206
+ ### Component Slots
207
+
208
+ #### Bar
209
+ ```html
210
+ <CookieControl>
211
+ <template #bar>
212
+ <h3>Bar title</h3>
213
+ <p>Bar description (you can use $cookies.text.barDescription)</p>
214
+ <n-link>Go somewhere</n-link>
215
+ </template>
216
+ </CookieControl>
217
+ ```
218
+
219
+ #### Modal
220
+ ```html
221
+ <template #modal>
222
+ <h3>Modal title</h3>
223
+ <p>Modal description</p>
224
+ </template>
225
+ ```
226
+
227
+ #### Cookie
228
+ ```html
229
+ <template #cookie="{config}">
230
+ <span v-for="c in config" :key="c.id" v-text="c.cookies"/>
231
+ </template>
232
+ ```
233
+
234
+ ### Props
235
+ - locale: `['en']`
236
+ ```html
237
+ <CookieControl locale="de"/>
238
+ ```
239
+
218
240
 
219
241
  <!-- Badges -->
220
242
  [npm-version-src]: https://badgen.net/npm/v/@dargmuesli/nuxt-cookie-control/latest
package/dist/module.d.ts CHANGED
@@ -48,7 +48,7 @@ interface ModuleOptions {
48
48
  initialState: boolean;
49
49
  };
50
50
  locales: Locale[];
51
- localeTexts: PartialRecord<Locale, LocaleStrings>;
51
+ localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>;
52
52
  }
53
53
 
54
54
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "4.5.0",
3
+ "version": "4.6.1",
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 = "4.5.0";
5
+ const version = "4.6.1";
6
6
 
7
7
  const en = {
8
8
  accept: "Accept",
@@ -150,7 +150,10 @@ const loadLocales = async (moduleOptions) => {
150
150
  if (!text)
151
151
  throw new Error(`Could not import text for locale ${locale}`);
152
152
  moduleOptions.locales.push(locale);
153
- moduleOptions.localeTexts[locale] = text;
153
+ moduleOptions.localeTexts[locale] = {
154
+ ...text,
155
+ ...moduleOptions.localeTexts[locale]
156
+ };
154
157
  }
155
158
  };
156
159
  const pushCss = (moduleOptions, nuxt) => {
@@ -0,0 +1,3 @@
1
+ import { LocaleStrings } from '../types';
2
+ declare const _default: LocaleStrings;
3
+ export default _default;
@@ -0,0 +1,17 @@
1
+ export default {
2
+ accept: "Kabul etmek",
3
+ acceptAll: "T\xFCm\xFCn\xFC kabul et",
4
+ bannerDescription: "Bu web sitesini do\u011Fru bir \u015Fekilde g\xF6r\xFCnt\xFCleyebilmek ve teklifimizi geli\u015Ftirmek i\xE7in bu web sitesinin nas\u0131l kullan\u0131ld\u0131\u011F\u0131n\u0131 daha iyi anlayabilmek i\xE7in kendi ve \xFC\xE7\xFCnc\xFC taraf \xE7erezlerimizi kullan\u0131yoruz. \xC7erez kullanma izni ile ilgili karar, bu banner \xFCzerinde bir se\xE7im yap\u0131ld\u0131ktan sonra g\xF6r\xFCnen \xE7erez d\xFC\u011Fmesi arac\u0131l\u0131\u011F\u0131yla herhangi bir zamanda de\u011Fi\u015Ftirilebilir.",
5
+ bannerTitle: "\xC7erezler",
6
+ close: "Kapat",
7
+ cookiesFunctional: "\u0130\u015Flevsel \xE7erezler",
8
+ cookiesNecessary: "Gerekli \xE7erezler",
9
+ cookiesOptional: "\u0130ste\u011Fe ba\u011Fl\u0131 \xE7erezler",
10
+ decline: "Reddetmek",
11
+ declineAll: "T\xFCm\xFCn\xFC reddet",
12
+ here: "here",
13
+ iframeBlocked: "Bunu g\xF6rmek i\xE7in l\xFCtfen i\u015Flevsel \xE7erezleri etkinle\u015Ftirin",
14
+ manageCookies: "\xC7erezleri y\xF6net",
15
+ save: "Kaydet",
16
+ settingsUnsaved: "Kaydedilmemi\u015F ayarlar mevcut"
17
+ };
@@ -51,7 +51,7 @@ export interface ModuleOptions {
51
51
  initialState: boolean;
52
52
  };
53
53
  locales: Locale[];
54
- localeTexts: PartialRecord<Locale, LocaleStrings>;
54
+ localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>;
55
55
  }
56
56
  export declare const DEFAULTS: Required<ModuleOptions>;
57
57
  export interface State {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-cookie-control",
3
- "version": "4.5.0",
3
+ "version": "4.6.1",
4
4
  "description": "Nuxt Cookies Control Module",
5
5
  "author": "Dario Ferderber <dario.ferderber@broj42.com>",
6
6
  "maintainers": [