@el7ven/cookie-kit 0.2.18 → 0.2.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@el7ven/cookie-kit",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "module": "./src/index.js",
@@ -24,42 +24,33 @@
24
24
 
25
25
  <script setup>
26
26
  import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
27
- import { useCookieKit } from './index.js'
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 new composable
38
+ // Use the Vue composable
48
39
  const {
49
40
  consent,
50
41
  acceptAll,
51
42
  rejectAll,
52
- acceptCategory,
53
- hasConsent,
43
+ acceptSelected,
44
+ hasConsented,
54
45
  hasCategoryConsent
55
- } = useCookieKit(props.config)
46
+ } = useCookieKitVue(props.config)
56
47
 
57
48
  // Local state
58
- const isVisible = computed(() => !consent.value?.hasConsented)
49
+ const isVisible = computed(() => !hasConsented.value)
59
50
  const isSettingsMode = ref(false)
60
51
  const currentTab = ref('privacy')
61
- const categories = ref(props.config.categories)
62
- const consentVersion = computed(() => props.config.version || '0.2.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
- // Save current category states
93
- Object.keys(categories.value).forEach(id => {
94
- const isEnabled = categories.value[id]?.enabled
95
- if (isEnabled !== undefined) {
96
- acceptCategory(id, isEnabled)
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) => {