@dargmuesli/nuxt-cookie-control 5.8.4 → 5.9.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/README.md +1 -1
- package/dist/module.d.ts +59 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +167 -4
- package/dist/runtime/composables.d.ts +2 -0
- package/dist/runtime/composables.mjs +2 -0
- package/dist/runtime/constants.d.ts +2 -0
- package/dist/runtime/constants.mjs +1 -0
- package/dist/runtime/locale/ar.d.ts +3 -0
- package/dist/runtime/locale/ar.mjs +17 -0
- package/dist/runtime/locale/az.d.ts +3 -0
- package/dist/runtime/locale/az.mjs +17 -0
- package/dist/runtime/locale/bg.d.ts +3 -0
- package/dist/runtime/locale/bg.mjs +17 -0
- package/dist/runtime/locale/cs.d.ts +3 -0
- package/dist/runtime/locale/cs.mjs +17 -0
- package/dist/runtime/locale/da.d.ts +3 -0
- package/dist/runtime/locale/da.mjs +17 -0
- package/dist/runtime/locale/de.d.ts +3 -0
- package/dist/runtime/locale/de.mjs +17 -0
- package/dist/runtime/locale/en.d.ts +3 -0
- package/dist/runtime/locale/en.mjs +17 -0
- package/dist/runtime/locale/es.d.ts +3 -0
- package/dist/runtime/locale/es.mjs +17 -0
- package/dist/runtime/locale/fi.d.ts +3 -0
- package/dist/runtime/locale/fi.mjs +17 -0
- package/dist/runtime/locale/fr.d.ts +3 -0
- package/dist/runtime/locale/fr.mjs +17 -0
- package/dist/runtime/locale/hr.d.ts +3 -0
- package/dist/runtime/locale/hr.mjs +17 -0
- package/dist/runtime/locale/hu.d.ts +3 -0
- package/dist/runtime/locale/hu.mjs +17 -0
- package/dist/runtime/locale/index.d.ts +1 -0
- package/dist/runtime/locale/index.mjs +56 -0
- package/dist/runtime/locale/it.d.ts +3 -0
- package/dist/runtime/locale/it.mjs +17 -0
- package/dist/runtime/locale/ja.d.ts +3 -0
- package/dist/runtime/locale/ja.mjs +17 -0
- package/dist/runtime/locale/ko.d.ts +3 -0
- package/dist/runtime/locale/ko.mjs +17 -0
- package/dist/runtime/locale/lt.d.ts +3 -0
- package/dist/runtime/locale/lt.mjs +17 -0
- package/dist/runtime/locale/nl.d.ts +3 -0
- package/dist/runtime/locale/nl.mjs +17 -0
- package/dist/runtime/locale/no.d.ts +3 -0
- package/dist/runtime/locale/no.mjs +17 -0
- package/dist/runtime/locale/oc.d.ts +3 -0
- package/dist/runtime/locale/oc.mjs +17 -0
- package/dist/runtime/locale/pl.d.ts +3 -0
- package/dist/runtime/locale/pl.mjs +17 -0
- package/dist/runtime/locale/pt.d.ts +3 -0
- package/dist/runtime/locale/pt.mjs +17 -0
- package/dist/runtime/locale/rs.d.ts +3 -0
- package/dist/runtime/locale/rs.mjs +17 -0
- package/dist/runtime/locale/ru.d.ts +3 -0
- package/dist/runtime/locale/ru.mjs +17 -0
- package/dist/runtime/locale/sk.d.ts +3 -0
- package/dist/runtime/locale/sk.mjs +17 -0
- package/dist/runtime/locale/sv.d.ts +3 -0
- package/dist/runtime/locale/sv.mjs +17 -0
- package/dist/runtime/locale/tr.d.ts +3 -0
- package/dist/runtime/locale/tr.mjs +17 -0
- package/dist/runtime/locale/uk.d.ts +3 -0
- package/dist/runtime/locale/uk.mjs +17 -0
- package/dist/runtime/methods.d.ts +9 -0
- package/dist/runtime/methods.mjs +25 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.mjs +40 -0
- package/dist/runtime/set-vars/native.d.ts +1 -0
- package/dist/runtime/set-vars/{native.ts → native.mjs} +2 -2
- package/dist/runtime/set-vars/ponyfill.d.ts +1 -0
- package/dist/runtime/set-vars/ponyfill.mjs +4 -0
- package/dist/runtime/types.d.ts +66 -0
- package/dist/runtime/types.mjs +57 -0
- package/dist/types.d.ts +1 -15
- package/package.json +5 -8
- package/dist/runtime/composables.ts +0 -5
- package/dist/runtime/constants.ts +0 -3
- package/dist/runtime/locale/ar.ts +0 -20
- package/dist/runtime/locale/az.ts +0 -20
- package/dist/runtime/locale/bg.ts +0 -21
- package/dist/runtime/locale/cs.ts +0 -20
- package/dist/runtime/locale/da.ts +0 -20
- package/dist/runtime/locale/de.ts +0 -21
- package/dist/runtime/locale/en.ts +0 -20
- package/dist/runtime/locale/es.ts +0 -20
- package/dist/runtime/locale/fi.ts +0 -21
- package/dist/runtime/locale/fr.ts +0 -20
- package/dist/runtime/locale/hr.ts +0 -21
- package/dist/runtime/locale/hu.ts +0 -21
- package/dist/runtime/locale/index.ts +0 -55
- package/dist/runtime/locale/it.ts +0 -20
- package/dist/runtime/locale/ja.ts +0 -20
- package/dist/runtime/locale/ko.ts +0 -20
- package/dist/runtime/locale/lt.ts +0 -20
- package/dist/runtime/locale/nl.ts +0 -21
- package/dist/runtime/locale/no.ts +0 -21
- package/dist/runtime/locale/oc.ts +0 -20
- package/dist/runtime/locale/pl.ts +0 -21
- package/dist/runtime/locale/pt.ts +0 -21
- package/dist/runtime/locale/ru.ts +0 -20
- package/dist/runtime/locale/sk.ts +0 -20
- package/dist/runtime/locale/sv.ts +0 -21
- package/dist/runtime/locale/tr.ts +0 -20
- package/dist/runtime/locale/uk.ts +0 -20
- package/dist/runtime/methods.ts +0 -49
- package/dist/runtime/plugin.ts +0 -51
- package/dist/runtime/set-vars/ponyfill.ts +0 -5
- package/dist/runtime/types.ts +0 -156
package/dist/runtime/methods.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import Cookies from 'js-cookie'
|
|
2
|
-
import slugify from '@sindresorhus/slugify'
|
|
3
|
-
|
|
4
|
-
import { LOCALE_DEFAULT } from './constants'
|
|
5
|
-
import { Cookie, ModuleOptions, Translatable } from './types'
|
|
6
|
-
|
|
7
|
-
export const getAllCookieIdsString = (moduleOptions: ModuleOptions) =>
|
|
8
|
-
getCookieIds([
|
|
9
|
-
...moduleOptions.cookies.necessary,
|
|
10
|
-
...moduleOptions.cookies.optional,
|
|
11
|
-
]).join('')
|
|
12
|
-
|
|
13
|
-
export const getCookie = (name: string) => Cookies.get(name)
|
|
14
|
-
|
|
15
|
-
export const getCookieId = (cookie: Cookie) =>
|
|
16
|
-
cookie.id || slugify(resolveTranslatable(cookie.name))
|
|
17
|
-
|
|
18
|
-
export const getCookieIds = (cookies: Cookie[]) =>
|
|
19
|
-
cookies.map((cookie) => getCookieId(cookie))
|
|
20
|
-
|
|
21
|
-
export const removeCookie = (name: string) => Cookies.remove(name)
|
|
22
|
-
|
|
23
|
-
export const resolveTranslatable = (
|
|
24
|
-
translatable: Translatable,
|
|
25
|
-
locale = LOCALE_DEFAULT
|
|
26
|
-
) => {
|
|
27
|
-
if (typeof translatable === 'string') return translatable
|
|
28
|
-
|
|
29
|
-
if (!locale)
|
|
30
|
-
throw new Error('No locale given for translatable that is not a string.')
|
|
31
|
-
|
|
32
|
-
const result = translatable[locale]
|
|
33
|
-
|
|
34
|
-
if (!result)
|
|
35
|
-
throw new Error(`Could not get translation for locale ${locale}.`)
|
|
36
|
-
|
|
37
|
-
return result
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const setCookie = (
|
|
41
|
-
name: string,
|
|
42
|
-
value: string,
|
|
43
|
-
options: Cookies.CookieAttributes
|
|
44
|
-
) => Cookies.set(name, value, { sameSite: 'Strict', ...options })
|
|
45
|
-
|
|
46
|
-
export const useResolveTranslatable = (locale = LOCALE_DEFAULT) => {
|
|
47
|
-
return (translatable: Translatable) =>
|
|
48
|
-
resolveTranslatable(translatable, locale)
|
|
49
|
-
}
|
package/dist/runtime/plugin.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import Cookies from 'js-cookie'
|
|
2
|
-
import { ref } from 'vue'
|
|
3
|
-
|
|
4
|
-
import { getAllCookieIdsString, getCookieId } from './methods'
|
|
5
|
-
import { Cookie, State } from './types'
|
|
6
|
-
|
|
7
|
-
import { defineNuxtPlugin } from '#imports'
|
|
8
|
-
import moduleOptions from '#build/cookie-control-options'
|
|
9
|
-
|
|
10
|
-
export default defineNuxtPlugin((_nuxtApp) => {
|
|
11
|
-
const cookieIsConsentGiven = Cookies.get(
|
|
12
|
-
moduleOptions.cookieNameIsConsentGiven
|
|
13
|
-
)
|
|
14
|
-
const cookieCookiesEnabledIds = Cookies.get(
|
|
15
|
-
moduleOptions.cookieNameCookiesEnabledIds
|
|
16
|
-
)?.split('|')
|
|
17
|
-
|
|
18
|
-
const isConsentGiven = ref<boolean | undefined>(
|
|
19
|
-
cookieIsConsentGiven === undefined
|
|
20
|
-
? undefined
|
|
21
|
-
: cookieIsConsentGiven === getAllCookieIdsString(moduleOptions)
|
|
22
|
-
)
|
|
23
|
-
const cookiesEnabled = ref<Cookie[] | undefined>(
|
|
24
|
-
cookieCookiesEnabledIds === undefined
|
|
25
|
-
? undefined
|
|
26
|
-
: [
|
|
27
|
-
...moduleOptions.cookies.necessary.filter((cookieNecessary) =>
|
|
28
|
-
cookieCookiesEnabledIds.includes(getCookieId(cookieNecessary))
|
|
29
|
-
),
|
|
30
|
-
...moduleOptions.cookies.optional.filter((cookieOptional) =>
|
|
31
|
-
cookieCookiesEnabledIds.includes(getCookieId(cookieOptional))
|
|
32
|
-
),
|
|
33
|
-
]
|
|
34
|
-
)
|
|
35
|
-
const cookiesEnabledIds = ref<string[] | undefined>(cookieCookiesEnabledIds)
|
|
36
|
-
const isModalActive = ref<boolean>()
|
|
37
|
-
|
|
38
|
-
const state = {
|
|
39
|
-
isConsentGiven,
|
|
40
|
-
cookiesEnabled,
|
|
41
|
-
cookiesEnabledIds,
|
|
42
|
-
isModalActive,
|
|
43
|
-
moduleOptions,
|
|
44
|
-
} as State
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
provide: {
|
|
48
|
-
cookies: state,
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
})
|
package/dist/runtime/types.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue'
|
|
2
|
-
|
|
3
|
-
import en from './locale/en'
|
|
4
|
-
|
|
5
|
-
export type Locale =
|
|
6
|
-
| 'ar'
|
|
7
|
-
| 'az'
|
|
8
|
-
| 'bg'
|
|
9
|
-
| 'cs'
|
|
10
|
-
| 'da'
|
|
11
|
-
| 'de'
|
|
12
|
-
| 'en'
|
|
13
|
-
| 'es'
|
|
14
|
-
| 'fi'
|
|
15
|
-
| 'fr'
|
|
16
|
-
| 'hr'
|
|
17
|
-
| 'hu'
|
|
18
|
-
| 'it'
|
|
19
|
-
| 'ja'
|
|
20
|
-
| 'ko'
|
|
21
|
-
| 'lt'
|
|
22
|
-
| 'nl'
|
|
23
|
-
| 'no'
|
|
24
|
-
| 'oc'
|
|
25
|
-
| 'pt'
|
|
26
|
-
| 'pl'
|
|
27
|
-
| 'ru'
|
|
28
|
-
| 'sk'
|
|
29
|
-
| 'sv'
|
|
30
|
-
| 'tr'
|
|
31
|
-
| 'uk'
|
|
32
|
-
|
|
33
|
-
export type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>
|
|
34
|
-
|
|
35
|
-
export type Translatable = string | PartialRecord<Locale, string>
|
|
36
|
-
|
|
37
|
-
export enum CookieType {
|
|
38
|
-
NECESSARY = 'necessary',
|
|
39
|
-
OPTIONAL = 'optional',
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface Cookie {
|
|
43
|
-
description?: Translatable
|
|
44
|
-
id?: string
|
|
45
|
-
name: Translatable
|
|
46
|
-
links?: Record<string, string | null>
|
|
47
|
-
src?: string
|
|
48
|
-
targetCookieIds?: string[]
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface LocaleStrings {
|
|
52
|
-
accept: string
|
|
53
|
-
acceptAll: string
|
|
54
|
-
bannerDescription: string
|
|
55
|
-
bannerTitle: string
|
|
56
|
-
close: string
|
|
57
|
-
cookiesFunctional: string
|
|
58
|
-
cookiesNecessary: string
|
|
59
|
-
cookiesOptional: string
|
|
60
|
-
iframeBlocked: string
|
|
61
|
-
decline: string
|
|
62
|
-
declineAll: string
|
|
63
|
-
here: string
|
|
64
|
-
manageCookies: string
|
|
65
|
-
save: string
|
|
66
|
-
settingsUnsaved: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface ModuleOptions {
|
|
70
|
-
barPosition:
|
|
71
|
-
| 'top-left'
|
|
72
|
-
| 'top-right'
|
|
73
|
-
| 'top-full'
|
|
74
|
-
| 'bottom-left'
|
|
75
|
-
| 'bottom-right'
|
|
76
|
-
| 'bottom-full'
|
|
77
|
-
closeModalOnClickOutside: boolean
|
|
78
|
-
colors: false | Record<string, any>
|
|
79
|
-
cookieExpiryOffsetMs: number
|
|
80
|
-
cookieNameCookiesEnabledIds: string
|
|
81
|
-
cookieNameIsConsentGiven: string
|
|
82
|
-
cookies: {
|
|
83
|
-
necessary: Cookie[]
|
|
84
|
-
optional: Cookie[]
|
|
85
|
-
}
|
|
86
|
-
domain: string
|
|
87
|
-
isAcceptNecessaryButtonEnabled: boolean
|
|
88
|
-
isControlButtonEnabled: boolean
|
|
89
|
-
isCookieIdVisible: boolean
|
|
90
|
-
isCssEnabled: boolean
|
|
91
|
-
isCssPonyfillEnabled: boolean
|
|
92
|
-
isDashInDescriptionEnabled: boolean
|
|
93
|
-
isIframeBlocked: boolean | { initialState: boolean }
|
|
94
|
-
isModalForced: boolean
|
|
95
|
-
locales: Locale[]
|
|
96
|
-
localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const DEFAULTS: Required<ModuleOptions> = {
|
|
100
|
-
barPosition: 'bottom-full',
|
|
101
|
-
closeModalOnClickOutside: false,
|
|
102
|
-
colors: {
|
|
103
|
-
barBackground: '#000',
|
|
104
|
-
barButtonBackground: '#fff',
|
|
105
|
-
barButtonColor: '#000',
|
|
106
|
-
barButtonHoverBackground: '#333',
|
|
107
|
-
barButtonHoverColor: '#fff',
|
|
108
|
-
barTextColor: '#fff',
|
|
109
|
-
checkboxActiveBackground: '#000',
|
|
110
|
-
checkboxActiveCircleBackground: '#fff',
|
|
111
|
-
checkboxDisabledBackground: '#ddd',
|
|
112
|
-
checkboxDisabledCircleBackground: '#fff',
|
|
113
|
-
checkboxInactiveBackground: '#000',
|
|
114
|
-
checkboxInactiveCircleBackground: '#fff',
|
|
115
|
-
controlButtonBackground: '#fff',
|
|
116
|
-
controlButtonHoverBackground: '#000',
|
|
117
|
-
controlButtonIconColor: '#000',
|
|
118
|
-
controlButtonIconHoverColor: '#fff',
|
|
119
|
-
focusRingColor: '#808080',
|
|
120
|
-
modalBackground: '#fff',
|
|
121
|
-
modalButtonBackground: '#000',
|
|
122
|
-
modalButtonColor: '#fff',
|
|
123
|
-
modalButtonHoverBackground: '#333',
|
|
124
|
-
modalButtonHoverColor: '#fff',
|
|
125
|
-
modalOverlay: '#000',
|
|
126
|
-
modalOverlayOpacity: 0.8,
|
|
127
|
-
modalTextColor: '#000',
|
|
128
|
-
modalUnsavedColor: '#fff',
|
|
129
|
-
},
|
|
130
|
-
cookies: {
|
|
131
|
-
necessary: [],
|
|
132
|
-
optional: [],
|
|
133
|
-
},
|
|
134
|
-
cookieExpiryOffsetMs: 1000 * 60 * 60 * 24 * 365, // one year
|
|
135
|
-
cookieNameIsConsentGiven: 'ncc_c',
|
|
136
|
-
cookieNameCookiesEnabledIds: 'ncc_e',
|
|
137
|
-
isAcceptNecessaryButtonEnabled: true,
|
|
138
|
-
isControlButtonEnabled: true,
|
|
139
|
-
isCookieIdVisible: false,
|
|
140
|
-
isCssEnabled: true,
|
|
141
|
-
isCssPonyfillEnabled: false,
|
|
142
|
-
isDashInDescriptionEnabled: true,
|
|
143
|
-
isIframeBlocked: false,
|
|
144
|
-
isModalForced: false,
|
|
145
|
-
domain: '',
|
|
146
|
-
locales: ['en'],
|
|
147
|
-
localeTexts: { en },
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export interface State {
|
|
151
|
-
cookiesEnabled: Ref<Cookie[] | undefined>
|
|
152
|
-
cookiesEnabledIds: Ref<string[] | undefined>
|
|
153
|
-
isConsentGiven: Ref<boolean | undefined>
|
|
154
|
-
isModalActive: Ref<boolean>
|
|
155
|
-
moduleOptions: ModuleOptions
|
|
156
|
-
}
|