@el7ven/cookie-kit 0.3.2 → 0.3.3

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.3.2",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "module": "./src/index.js",
package/src/core/index.js CHANGED
@@ -225,7 +225,7 @@ export class CookieKitCore {
225
225
  const next = {}
226
226
  Object.keys(this.config.categories).forEach(id => {
227
227
  const category = this.config.categories[id]
228
- if (category?.enabled !== false) {
228
+ if (category?.enabled === true) {
229
229
  next[id] = !!category.required
230
230
  }
231
231
  })
@@ -270,7 +270,7 @@ export class CookieKitCore {
270
270
  acceptAll(source = 'banner') {
271
271
  const categories = {}
272
272
  Object.keys(this.config.categories).forEach(id => {
273
- if (this.config.categories[id]?.enabled !== false) {
273
+ if (this.config.categories[id]?.enabled === true) {
274
274
  categories[id] = true
275
275
  }
276
276
  })
@@ -281,7 +281,7 @@ export class CookieKitCore {
281
281
  const categories = {}
282
282
  Object.keys(this.config.categories).forEach(id => {
283
283
  const category = this.config.categories[id]
284
- if (category?.enabled !== false) {
284
+ if (category?.enabled === true) {
285
285
  categories[id] = !!category.required
286
286
  }
287
287
  })
@@ -293,7 +293,7 @@ export class CookieKitCore {
293
293
  const categories = {}
294
294
  Object.keys(this.config.categories).forEach(id => {
295
295
  const category = this.config.categories[id]
296
- if (category?.enabled !== false) {
296
+ if (category?.enabled === true) {
297
297
  categories[id] = selectedSet.has(id) || !!category.required
298
298
  }
299
299
  })
@@ -42,7 +42,7 @@ const mergedConfig = computed(() => deepMerge(DEFAULT_CONFIG, props.config))
42
42
  const {
43
43
  core,
44
44
  consent,
45
- categories: coreCategories,
45
+ categories,
46
46
  acceptAll,
47
47
  rejectAll,
48
48
  acceptSelected,
@@ -57,9 +57,6 @@ const isSettingsMode = ref(false)
57
57
  const currentTab = ref('privacy')
58
58
  const drawerRef = ref(null)
59
59
 
60
- // Category state (reactive, for toggles)
61
- const categories = ref(buildCategoryState(mergedConfig.value.categories))
62
-
63
60
  // Computed
64
61
  const consentVersion = computed(() => mergedConfig.value.version || 'v2')
65
62
  const capabilities = computed(() => mergedConfig.value.capabilities || {})
@@ -207,7 +204,9 @@ const handleSelectTab = (tabId) => {
207
204
  const handleToggleCategory = (categoryId) => {
208
205
  const cat = mergedConfig.value.categories[categoryId]
209
206
  if (cat && !cat.disabled && !cat.required) {
210
- categories.value[categoryId] = !categories.value[categoryId]
207
+ // Toggle the category state
208
+ const current = categories.value[categoryId]
209
+ categories.value[categoryId] = !current
211
210
  }
212
211
  }
213
212
 
@@ -245,13 +244,6 @@ defineExpose({
245
244
  })
246
245
 
247
246
  // Helpers
248
- function buildCategoryState(cats) {
249
- if (!cats) return {}
250
- return Object.fromEntries(
251
- Object.keys(cats).map(id => [id, !!cats[id].enabled])
252
- )
253
- }
254
-
255
247
  function deepMerge(target, source) {
256
248
  const result = { ...target }
257
249
  for (const key of Object.keys(source)) {