@lu-development/ux-gdpr-consent
Advanced tools
Comparing version 1.0.8 to 1.0.9
# UX GDPR Consent Dialog | ||
## 1.0.9 | ||
- focus on first focusable element in the body when closed through button click | ||
## 1.0.8 | ||
@@ -4,0 +8,0 @@ |
@@ -82,2 +82,6 @@ 'use strict'; | ||
} | ||
async returnFocus() { | ||
const firstFocusable = document.body.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); | ||
await Promise.resolve().then(() => firstFocusable.focus()); | ||
} | ||
async grantConsentCookie() { | ||
@@ -87,2 +91,3 @@ document.cookie = `${this.cookieName}=true; max-age=${60 * 60 * 24 * 365};`; | ||
this.consentEmitter.emit({ isConsentGranted: true }); | ||
return this.returnFocus(); | ||
} | ||
@@ -93,2 +98,3 @@ async revokeConsentCookie() { | ||
this.consentEmitter.emit({ isConsentGranted: false }); | ||
return this.returnFocus(); | ||
} | ||
@@ -95,0 +101,0 @@ async resetConsentCookie() { |
@@ -75,2 +75,6 @@ import { h, Host } from "@stencil/core"; | ||
} | ||
async returnFocus() { | ||
const firstFocusable = document.body.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); | ||
await Promise.resolve().then(() => firstFocusable.focus()); | ||
} | ||
async grantConsentCookie() { | ||
@@ -80,2 +84,3 @@ document.cookie = `${this.cookieName}=true; max-age=${60 * 60 * 24 * 365};`; | ||
this.consentEmitter.emit({ isConsentGranted: true }); | ||
return this.returnFocus(); | ||
} | ||
@@ -86,2 +91,3 @@ async revokeConsentCookie() { | ||
this.consentEmitter.emit({ isConsentGranted: false }); | ||
return this.returnFocus(); | ||
} | ||
@@ -88,0 +94,0 @@ async resetConsentCookie() { |
@@ -131,2 +131,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
class_1.prototype.returnFocus = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var firstFocusable; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
firstFocusable = document.body.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); | ||
return [4 /*yield*/, Promise.resolve().then(function () { return firstFocusable.focus(); })]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
class_1.prototype.grantConsentCookie = function () { | ||
@@ -138,3 +153,3 @@ return __awaiter(this, void 0, void 0, function () { | ||
this.consentEmitter.emit({ isConsentGranted: true }); | ||
return [2 /*return*/]; | ||
return [2 /*return*/, this.returnFocus()]; | ||
}); | ||
@@ -149,3 +164,3 @@ }); | ||
this.consentEmitter.emit({ isConsentGranted: false }); | ||
return [2 /*return*/]; | ||
return [2 /*return*/, this.returnFocus()]; | ||
}); | ||
@@ -152,0 +167,0 @@ }); |
@@ -78,2 +78,6 @@ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './core-fab31531.js'; | ||
} | ||
async returnFocus() { | ||
const firstFocusable = document.body.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); | ||
await Promise.resolve().then(() => firstFocusable.focus()); | ||
} | ||
async grantConsentCookie() { | ||
@@ -83,2 +87,3 @@ document.cookie = `${this.cookieName}=true; max-age=${60 * 60 * 24 * 365};`; | ||
this.consentEmitter.emit({ isConsentGranted: true }); | ||
return this.returnFocus(); | ||
} | ||
@@ -89,2 +94,3 @@ async revokeConsentCookie() { | ||
this.consentEmitter.emit({ isConsentGranted: false }); | ||
return this.returnFocus(); | ||
} | ||
@@ -91,0 +97,0 @@ async resetConsentCookie() { |
@@ -17,2 +17,3 @@ import { EventEmitter } from "../../stencil.core"; | ||
parseConsentCookieValue(consentCookie: string): "granted" | "revoked" | "indeterminate"; | ||
returnFocus(): Promise<void>; | ||
grantConsentCookie(): Promise<void>; | ||
@@ -19,0 +20,0 @@ revokeConsentCookie(): Promise<void>; |
@@ -1,1 +0,1 @@ | ||
System.register(["./p-3f6f6132.system.js"],(function(){"use strict";var e,n;return{setters:[function(t){e=t.p;n=t.b}],execute:function(){e().then((function(e){return n([["p-3as1vwo9.system",[[1,"ux-gdpr-consent",{hidden:[32],grantConsentCookie:[64],revokeConsentCookie:[64],resetConsentCookie:[64]},[[4,"gdpr-consent-revoke","handleRevoke"],[4,"gdpr-consent-reset","handleReset"]]]]]],e)}))}}})); | ||
System.register(["./p-3f6f6132.system.js"],(function(){"use strict";var e,n;return{setters:[function(t){e=t.p;n=t.b}],execute:function(){e().then((function(e){return n([["p-drx8zau0.system",[[1,"ux-gdpr-consent",{hidden:[32],grantConsentCookie:[64],revokeConsentCookie:[64],resetConsentCookie:[64]},[[4,"gdpr-consent-revoke","handleRevoke"],[4,"gdpr-consent-reset","handleReset"]]]]]],e)}))}}})); |
@@ -1,1 +0,1 @@ | ||
import{p as e,b as o}from"./p-552631d0.js";e().then(e=>o([["p-7kl9iqut",[[1,"ux-gdpr-consent",{hidden:[32],grantConsentCookie:[64],revokeConsentCookie:[64],resetConsentCookie:[64]},[[4,"gdpr-consent-revoke","handleRevoke"],[4,"gdpr-consent-reset","handleReset"]]]]]],e)); | ||
import{p as e,b as o}from"./p-552631d0.js";e().then(e=>o([["p-15saonqj",[[1,"ux-gdpr-consent",{hidden:[32],grantConsentCookie:[64],revokeConsentCookie:[64],resetConsentCookie:[64]},[[4,"gdpr-consent-revoke","handleRevoke"],[4,"gdpr-consent-reset","handleReset"]]]]]],e)); |
{ | ||
"name": "@lu-development/ux-gdpr-consent", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "GDPR compliance plugin", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
780174
11871