@el7ven/cookie-kit 0.2.18 → 0.2.20
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/package.json +1 -1
- package/src/core/index.js +112 -5
- package/src/index.js +3 -0
- package/src/vue/CookieConsent.vue +14 -25
- package/src/vue/index.js +2 -1
package/package.json
CHANGED
package/src/core/index.js
CHANGED
|
@@ -1,13 +1,120 @@
|
|
|
1
1
|
import { VERSION, getVersion, getVersionInfo, logVersion } from './version.js'
|
|
2
2
|
|
|
3
3
|
const DEFAULT_CONFIG = {
|
|
4
|
-
|
|
4
|
+
// Version and revision for consent invalidation
|
|
5
|
+
version: 'v2',
|
|
6
|
+
revision: 0,
|
|
7
|
+
|
|
8
|
+
// GDPR compliance
|
|
5
9
|
consentExpireDays: 365,
|
|
10
|
+
auditLog: false,
|
|
11
|
+
|
|
12
|
+
// Storage
|
|
13
|
+
storageKey: 'cookie_consent',
|
|
14
|
+
storageType: 'localStorage', // 'localStorage' | 'cookie' | 'both'
|
|
15
|
+
|
|
16
|
+
// Mode
|
|
17
|
+
mode: 'gdpr', // 'gdpr' | 'essential'
|
|
18
|
+
|
|
19
|
+
// Auto show
|
|
20
|
+
autoShow: true,
|
|
21
|
+
|
|
22
|
+
// Debug
|
|
23
|
+
debug: false,
|
|
24
|
+
|
|
25
|
+
// Region (optional)
|
|
26
|
+
region: null, // 'EU' | 'US' | 'OTHER'
|
|
27
|
+
|
|
28
|
+
// Categories
|
|
6
29
|
categories: {
|
|
7
|
-
necessary: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
30
|
+
necessary: {
|
|
31
|
+
id: 'necessary',
|
|
32
|
+
label: 'Necesare',
|
|
33
|
+
description: 'Cookie-uri esențiale pentru funcționarea site-ului',
|
|
34
|
+
required: true,
|
|
35
|
+
locked: true,
|
|
36
|
+
enabled: true
|
|
37
|
+
},
|
|
38
|
+
analytics: {
|
|
39
|
+
id: 'analytics',
|
|
40
|
+
label: 'Analiză',
|
|
41
|
+
description: 'Cookie-uri pentru analiza traficului și comportamentului utilizatorilor',
|
|
42
|
+
required: false,
|
|
43
|
+
locked: false,
|
|
44
|
+
enabled: true
|
|
45
|
+
},
|
|
46
|
+
marketing: {
|
|
47
|
+
id: 'marketing',
|
|
48
|
+
label: 'Marketing',
|
|
49
|
+
description: 'Cookie-uri pentru publicitate personalizată',
|
|
50
|
+
required: false,
|
|
51
|
+
locked: false,
|
|
52
|
+
enabled: true
|
|
53
|
+
},
|
|
54
|
+
preferences: {
|
|
55
|
+
id: 'preferences',
|
|
56
|
+
label: 'Preferințe',
|
|
57
|
+
description: 'Cookie-uri pentru salvarea preferințelor utilizatorului',
|
|
58
|
+
required: false,
|
|
59
|
+
locked: false,
|
|
60
|
+
enabled: true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
// Texts
|
|
65
|
+
texts: {
|
|
66
|
+
essential: {
|
|
67
|
+
title: '🍪 Файлы Cookie',
|
|
68
|
+
message: 'Мы используем необходимые файлы cookie для работы сайта. Никакой аналитики и маркетинга.',
|
|
69
|
+
button: 'Принять'
|
|
70
|
+
},
|
|
71
|
+
gdpr: {
|
|
72
|
+
title: 'Preferințe Cookie-uri',
|
|
73
|
+
message: 'Folosim cookie-uri pentru a-ți oferi cea mai bună experiență. Alege ce tipuri de cookie-uri accepți.',
|
|
74
|
+
buttons: {
|
|
75
|
+
acceptAll: 'Acceptă toate',
|
|
76
|
+
rejectAll: 'Respinge toate',
|
|
77
|
+
acceptSelection: 'Acceptă selecția',
|
|
78
|
+
settings: 'Setări'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
settings: {
|
|
82
|
+
title: 'Setări Cookie-uri',
|
|
83
|
+
tabs: {
|
|
84
|
+
privacy: 'Confidențialitate'
|
|
85
|
+
},
|
|
86
|
+
buttons: {
|
|
87
|
+
acceptAll: 'Acceptă toate',
|
|
88
|
+
rejectAll: 'Respinge toate',
|
|
89
|
+
acceptSelection: 'Salvează selecția'
|
|
90
|
+
},
|
|
91
|
+
links: {
|
|
92
|
+
moreInfo: 'Mai multe informații',
|
|
93
|
+
cookieDetails: 'Detalii cookie-uri'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// Policy links
|
|
99
|
+
policies: {
|
|
100
|
+
privacy: '/privacy-policy',
|
|
101
|
+
cookies: '/cookie-policy'
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
// Display options
|
|
105
|
+
display: {
|
|
106
|
+
position: 'bottom-right', // 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'center'
|
|
107
|
+
backdrop: true,
|
|
108
|
+
closeOnBackdrop: true
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
// Analytics providers (optional)
|
|
112
|
+
analytics: null,
|
|
113
|
+
|
|
114
|
+
// Script blocking (optional)
|
|
115
|
+
scriptBlocking: {
|
|
116
|
+
enabled: true,
|
|
117
|
+
strategy: 'data-category' // 'data-category' | 'type-rewrite'
|
|
11
118
|
}
|
|
12
119
|
}
|
|
13
120
|
|
package/src/index.js
CHANGED
|
@@ -22,6 +22,9 @@ export * from './react/index.js'
|
|
|
22
22
|
// Vue components
|
|
23
23
|
export * from './vue/index.js'
|
|
24
24
|
|
|
25
|
+
// Vue composable
|
|
26
|
+
export { useCookieConsent } from './vue/composables/useCookieConsent.js'
|
|
27
|
+
|
|
25
28
|
// Version info
|
|
26
29
|
export { VERSION, getVersion, getVersionInfo, logVersion } from './core/version.js'
|
|
27
30
|
|
|
@@ -24,42 +24,33 @@
|
|
|
24
24
|
|
|
25
25
|
<script setup>
|
|
26
26
|
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
|
|
27
|
-
import {
|
|
27
|
+
import { useCookieKitVue, DEFAULT_CONFIG } from './index.js'
|
|
28
28
|
import CookieDrawer from './CookieDrawer.vue'
|
|
29
29
|
|
|
30
30
|
// Props for customization
|
|
31
31
|
const props = defineProps({
|
|
32
32
|
config: {
|
|
33
33
|
type: Object,
|
|
34
|
-
default: () =>
|
|
35
|
-
categories: {
|
|
36
|
-
necessary: { required: true, enabled: true, name: 'Essential Cookies' },
|
|
37
|
-
analytics: { required: false, enabled: true, name: 'Analytics Cookies' },
|
|
38
|
-
marketing: { required: false, enabled: false, name: 'Marketing Cookies' }
|
|
39
|
-
},
|
|
40
|
-
consentExpireDays: 365,
|
|
41
|
-
version: '0.2.0',
|
|
42
|
-
theme: 'light'
|
|
43
|
-
})
|
|
34
|
+
default: () => DEFAULT_CONFIG
|
|
44
35
|
}
|
|
45
36
|
})
|
|
46
37
|
|
|
47
|
-
// Use the
|
|
38
|
+
// Use the Vue composable
|
|
48
39
|
const {
|
|
49
40
|
consent,
|
|
50
41
|
acceptAll,
|
|
51
42
|
rejectAll,
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
acceptSelected,
|
|
44
|
+
hasConsented,
|
|
54
45
|
hasCategoryConsent
|
|
55
|
-
} =
|
|
46
|
+
} = useCookieKitVue(props.config)
|
|
56
47
|
|
|
57
48
|
// Local state
|
|
58
|
-
const isVisible = computed(() => !
|
|
49
|
+
const isVisible = computed(() => !hasConsented.value)
|
|
59
50
|
const isSettingsMode = ref(false)
|
|
60
51
|
const currentTab = ref('privacy')
|
|
61
|
-
const categories =
|
|
62
|
-
const consentVersion = computed(() => props.config.version || '0.
|
|
52
|
+
const categories = computed(() => consent.value?.categories || props.config.categories)
|
|
53
|
+
const consentVersion = computed(() => props.config.version || '1.0.0')
|
|
63
54
|
const capabilities = computed(() => ({}))
|
|
64
55
|
const isV2 = computed(() => true)
|
|
65
56
|
const theme = computed(() => props.config.theme || 'light')
|
|
@@ -89,13 +80,11 @@ const closeSettings = () => {
|
|
|
89
80
|
}
|
|
90
81
|
|
|
91
82
|
const acceptSelection = () => {
|
|
92
|
-
//
|
|
93
|
-
Object.keys(categories.value)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
})
|
|
83
|
+
// Get selected category IDs
|
|
84
|
+
const selectedIds = Object.keys(categories.value)
|
|
85
|
+
.filter(id => categories.value[id]?.enabled)
|
|
86
|
+
|
|
87
|
+
acceptSelected(selectedIds)
|
|
99
88
|
}
|
|
100
89
|
|
|
101
90
|
const selectTab = (tabId) => {
|
package/src/vue/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { computed, ref } from 'vue'
|
|
2
2
|
import { createCookieKit, DEFAULT_CONFIG } from '../core/index.js'
|
|
3
3
|
import { VERSION, getVersion, getVersionInfo, logVersion } from './version.js'
|
|
4
|
+
import { useCookieConsent } from './composables/useCookieConsent.js'
|
|
4
5
|
|
|
5
|
-
export { createCookieKit, DEFAULT_CONFIG, VERSION, getVersion, getVersionInfo, logVersion }
|
|
6
|
+
export { createCookieKit, DEFAULT_CONFIG, VERSION, getVersion, getVersionInfo, logVersion, useCookieConsent }
|
|
6
7
|
|
|
7
8
|
export function useCookieKitVue(userConfig = {}) {
|
|
8
9
|
const core = createCookieKit(userConfig)
|