@content-blocks/js 0.7.3 → 0.7.5
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/dist/cjs/content-accordion_11.cjs.entry.js +8 -3
- package/dist/cjs/content-accordion_11.cjs.entry.js.map +1 -1
- package/dist/cjs/content-navigation-block.cjs.entry.js +15 -9
- package/dist/cjs/content-navigation-block.cjs.entry.js.map +1 -1
- package/dist/collection/components/content-navigation-block/content-navigation-block.js +15 -9
- package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +1 -1
- package/dist/collection/components/content-overlay/content-overlay.js +1 -1
- package/dist/collection/components/content-overlay/content-overlay.js.map +1 -1
- package/dist/collection/elements/content-button/content-button.js +7 -2
- package/dist/collection/elements/content-button/content-button.js.map +1 -1
- package/dist/components/content-button.js +7 -2
- package/dist/components/content-button.js.map +1 -1
- package/dist/components/content-navigation-block.js +15 -9
- package/dist/components/content-navigation-block.js.map +1 -1
- package/dist/components/content-overlay.js +1 -1
- package/dist/components/content-overlay.js.map +1 -1
- package/dist/content-blocks/content-blocks.esm.js +1 -1
- package/dist/content-blocks/{p-39788531.entry.js → p-1c7435ea.entry.js} +2 -2
- package/dist/content-blocks/p-1c7435ea.entry.js.map +1 -0
- package/dist/content-blocks/p-d9e20abf.entry.js +2 -0
- package/dist/content-blocks/p-d9e20abf.entry.js.map +1 -0
- package/dist/esm/content-accordion_11.entry.js +8 -3
- package/dist/esm/content-accordion_11.entry.js.map +1 -1
- package/dist/esm/content-navigation-block.entry.js +15 -9
- package/dist/esm/content-navigation-block.entry.js.map +1 -1
- package/package.json +1 -1
- package/dist/content-blocks/p-0131bfdf.entry.js +0 -2
- package/dist/content-blocks/p-0131bfdf.entry.js.map +0 -1
- package/dist/content-blocks/p-39788531.entry.js.map +0 -1
|
@@ -26,6 +26,8 @@ const ContentNavigationBlock = class {
|
|
|
26
26
|
this.contentSlot = undefined;
|
|
27
27
|
}
|
|
28
28
|
componentWillLoad() {
|
|
29
|
+
this.hasOpenButton = !!this.hostElement.querySelector('[slot="openButton"]');
|
|
30
|
+
this.hasCloseButton = !!this.hostElement.querySelector('[slot="closeButton"]');
|
|
29
31
|
windowResizeService.WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {
|
|
30
32
|
this.hamburger = newValue;
|
|
31
33
|
this.bodyToggle = this.hamburger === 'fixed';
|
|
@@ -36,8 +38,6 @@ const ContentNavigationBlock = class {
|
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
componentDidLoad() {
|
|
39
|
-
this.hasOpenButton = !!this.hostElement.querySelector('[slot="openButton"]');
|
|
40
|
-
this.hasCloseButton = !!this.hostElement.querySelector('content-navigation-block-close');
|
|
41
41
|
this.openButton.onclick = () => {
|
|
42
42
|
this.openMenu();
|
|
43
43
|
};
|
|
@@ -54,25 +54,31 @@ const ContentNavigationBlock = class {
|
|
|
54
54
|
document.body.classList.add('content-navigation-block-open');
|
|
55
55
|
}
|
|
56
56
|
this.focusTrap = focusTrap_esm.createFocusTrap(this.contentSlot.parentElement, {
|
|
57
|
+
initialFocus: this.contentSlot,
|
|
57
58
|
fallbackFocus: this.hostElement,
|
|
58
59
|
clickOutsideDeactivates: true,
|
|
59
60
|
onDeactivate: () => {
|
|
60
61
|
this.closeMenu();
|
|
62
|
+
this.focusTrap = null;
|
|
63
|
+
this.ariaExpanded = 'false';
|
|
64
|
+
document.body.classList.remove('content-navigation-block-open');
|
|
65
|
+
setTimeout(() => this.openButton.focus(), 1);
|
|
61
66
|
},
|
|
62
67
|
});
|
|
63
|
-
|
|
68
|
+
this.focusTrap.activate();
|
|
64
69
|
}
|
|
65
70
|
closeMenu() {
|
|
66
71
|
if (this.focusTrap) {
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
try {
|
|
73
|
+
this.focusTrap.deactivate();
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.log(e);
|
|
77
|
+
}
|
|
69
78
|
}
|
|
70
|
-
this.ariaExpanded = 'false';
|
|
71
|
-
document.body.classList.remove('content-navigation-block-open');
|
|
72
|
-
setTimeout(() => this.openButton.focus(), 1);
|
|
73
79
|
}
|
|
74
80
|
render() {
|
|
75
|
-
return (index.h(index.Host, { class: this.classString, "aria-expanded": this.ariaExpanded }, index.h("div", { class: "content-navigation-block__skip-content" }, index.h("slot", { name: "skipContent" })), index.h("div", { ref: el => (this.openButton = el), class: "content-navigation__open" }, !this.hasOpenButton && (index.h("button", null, index.h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" })))), index.h("slot", { name: "openButton" })), index.h("div", { class: "content-navigation__content-wrapper" }, index.h("div", { ref: el => (this.closeButton = el), class: "content-navigation__close" }, !this.hasCloseButton && (index.h("button", null, index.h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" }))))), index.h("div", { class: "content-navigation__content", ref: el => (this.contentSlot = el) }, index.h("slot", { name: "
|
|
81
|
+
return (index.h(index.Host, { class: this.classString, "aria-expanded": this.ariaExpanded }, index.h("div", { class: "content-navigation-block__skip-content" }, index.h("slot", { name: "skipContent" })), index.h("div", { ref: el => (this.openButton = el), class: "content-navigation__open" }, !this.hasOpenButton && (index.h("button", null, index.h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" })))), index.h("slot", { name: "openButton" })), index.h("div", { class: "content-navigation__content-wrapper" }, index.h("div", { ref: el => (this.closeButton = el), class: "content-navigation__close" }, !this.hasCloseButton && (index.h("button", null, index.h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" })))), index.h("slot", { name: "closeButton" })), index.h("div", { class: "content-navigation__content", ref: el => (this.contentSlot = el) }, index.h("slot", { name: "content" }), index.h("slot", null)))));
|
|
76
82
|
}
|
|
77
83
|
get hostElement() { return index.getElement(this); }
|
|
78
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"content-navigation-block.entry.cjs.js","mappings":";;;;;;;;;;AAAA,MAAM,yBAAyB,GAAG,+kGAA+kG;;MCiBpmG,sBAAsB;;;yBAcH,YAAY;;;4BAaV,OAAO;0BACR,KAAK;;6BAGF,KAAK;8BACJ,KAAK;;;;;IAMxC,iBAAiB;QACfA,uCAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ;YACjE,IAAI,CAAC,SAAS,GAAG,QAAkB,CAAC;YACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC;YAC7C,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC;SACjE,CAAC,CAAC;QACHA,uCAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ;YAC/D,IAAI,CAAC,WAAW,GAAG,QAAkB,CAAC;SACvC,CAAC,CAAC;KACJ;IAED,gBAAgB;QACd,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CA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izeService","createFocusTrap","h","Host"],"sources":["src/components/content-navigation-block/content-navigation-block.scss?tag=content-navigation-block","src/components/content-navigation-block/content-navigation-block.tsx"],"sourcesContent":["body.content-navigation-block-open {\n overflow: hidden;\n}\ncontent-navigation-block {\n button {\n appearance: none;\n border: none;\n background: transparent;\n cursor: pointer;\n }\n \n .content-navigation-block__skip-content a, .content-navigation-block__skip-content button, .content-navigation-block__skip-content a:visited, .content-navigation-block__skip-content button:visited{\n border: 2px solid rgba(0,0,0, 1);\n border-radius: 2px;\n color: purple;\n cursor: pointer;\n display: inline-block;\n font-size: 14px;\n line-height: 20px;\n margin: 6px 11px;\n min-height: 32px;\n text-decoration: underline;\n text-align: center;\n width: 106px;\n z-index: 1000;\n }\n .content-navigation-block__skip-content:not(:focus-within) {\n position: absolute;\n // z-index: -1;\n\n clip: rect(1px,1px,1px,1px);\n overflow: hidden;\n padding: 0;\n }\n\n svg.default-icon {\n display: inline-block;\n width: 32px;\n }\n &[hamburger=\"fixed\"],\n &[hamburger=\"absolute\"],\n &[hamburger=\"static\"] {\n display: inline-block;\n &[aria-expanded=\"false\"] {\n .content-navigation__close {\n display: none;\n }\n }\n .content-navigation__open,\n .content-navigation__close {\n cursor: pointer;\n }\n \n .content-navigation__content-wrapper {\n display: none;\n &[hidden=\"false\"] {\n display: block;\n }\n }\n }\n\n &[hamburger=\"fixed\"] {\n .content-navigation__content-wrapper {\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"sticky\"] {\n .content-navigation__content-wrapper {\n position: sticky;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"absolute\"] {\n .content-navigation__content-wrapper {\n position: absolute;\n z-index: 100;\n }\n }\n &[hamburger=\"static\"] {\n .content-navigation__content-wrapper {\n position: static;\n }\n }\n \n &[hamburger=\"none\"] {\n display: block;\n .content-navigation__open,\n .content-navigation__close {\n display: none;\n }\n }\n\n &[aria-expanded=\"true\"] {\n .content-navigation__content-wrapper {\n display: block;\n }\n }\n}","import { Component, Prop, Host, h, State, Element } from '@stencil/core';\nimport { HTMLStencilElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\nimport { createFocusTrap } from 'focus-trap';\n\n/**\n * @slot openButton - This slot will expand the navigation when clicked.\n * @slot closeButton - This slot will close the navigation when clicked.\n * @slot skipContent - This slot is a keyboard-focus link that lets a screen-reader or keyboard user skip the navigation block and scroll to the end.\n * @slot content - Default slot\n */\n@Component({\n tag: 'content-navigation-block',\n styleUrl: 'content-navigation-block.scss',\n shadow: false,\n})\nexport class ContentNavigationBlock {\n /**\n * @type Select\n * @responsive\n * @options fixed\n * @options absolute\n * @options sticky\n * @options static\n * @options none\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n hamburger: ResponsiveString = 'fixed|none';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n @State() classString;\n @Element() hostElement: HTMLStencilElement;\n @State() ariaExpanded: string = 'false';\n @State() bodyToggle: boolean = false;\n @State() skipAccessibilityMessage: HTMLElement;\n\n @State() hasOpenButton: boolean = false;\n @State() hasCloseButton: boolean = false;\n\n @State() openButton: HTMLElement;\n @State() closeButton: HTMLElement;\n @State() contentSlot: HTMLElement;\n focusTrap;\n componentWillLoad() {\n WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {\n this.hamburger = newValue as string;\n this.bodyToggle = this.hamburger === 'fixed';\n document.body.classList.remove('content-navigation-block-open');\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n componentDidLoad() {\n this.hasOpenButton = !!this.hostElement.querySelector('[slot=\"openButton\"]');\n this.hasCloseButton = !!this.hostElement.querySelector('content-navigation-block-close');\n this.openButton.onclick = () => {\n this.openMenu();\n };\n this.closeButton.onclick = () => {\n this.closeMenu();\n };\n }\n\n openMenu() {\n this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';\n if (this.ariaExpanded === 'false') {\n document.body.classList.remove('content-navigation-block-open');\n } else if (this.bodyToggle) {\n document.body.classList.add('content-navigation-block-open');\n }\n this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {\n fallbackFocus: this.hostElement,\n clickOutsideDeactivates: true,\n onDeactivate: () => {\n this.closeMenu();\n },\n });\n\n setTimeout(() => this.closeButton.focus(), 1);\n }\n closeMenu() {\n if (this.focusTrap) {\n this.focusTrap.deactivate();\n this.focusTrap = null;\n }\n this.ariaExpanded = 'false';\n document.body.classList.remove('content-navigation-block-open');\n setTimeout(() => this.openButton.focus(), 1);\n }\n\n render() {\n return (\n <Host class={this.classString} aria-expanded={this.ariaExpanded}>\n <div class=\"content-navigation-block__skip-content\">\n <slot name=\"skipContent\"></slot>\n </div>\n <div ref={el => (this.openButton = el)} class=\"content-navigation__open\">\n {!this.hasOpenButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5\" />\n </svg>\n </button>\n )}\n <slot name=\"openButton\"></slot>\n </div>\n <div class=\"content-navigation__content-wrapper\">\n <div ref={el => (this.closeButton = el)} class=\"content-navigation__close\">\n {!this.hasCloseButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n </div>\n <div class=\"content-navigation__content\" ref={el => (this.contentSlot = el)}>\n <slot name=\"closeButton\"></slot>\n <slot name=\"content\"></slot>\n <slot></slot>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K,EAAC,0BAA0B,IACrE,CAAC,IAAI,CAAC,aAAa,KAClBA,wBACEA,iBAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,kBAAc,KAAK,EAAC,MAAM,EAAC,cAAc,IACnIA,oCAAqB,OAAO,qBAAiB,OAAO,EAAC,CAAC,EAAC,8CAA8C,GAAG,CACpG,CACC,CACV,EACDA,kBAAM,IAAI,EAAC,YAAY,GAAQ,CAC3B,EACNA,iBAAK,KAAK,EAAC,qCAAqC,IAC9CA,iBAAK,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,EAAE,KAAK,EAAC,2BAA2B,IACvE,CAAC,IAAI,CAAC,cAAc,KACnBA,wBACEA,iBAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,kBAAc,KAAK,EAAC,MAAM,EAAC,cAAc,IACnIA,oCAAqB,OAAO,qBAAiB,OAAO,EAAC,CAAC,EAAC,sBAAsB,GAAG,CAC5E,CACC,CACV,EACDA,kBAAM,IAAI,EAAC,aAAa,GAAQ,CAC5B,EACNA,iBAAK,KAAK,EAAC,6BAA6B,EAAC,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,IACzEA,kBAAM,IAAI,EAAC,SAAS,GAAQ,EAC5BA,qBAAa,CACT,CACF,CACD,EACP;KACH;;;;;;;","names":["WindowResizeService","createFocusTrap","h","Host"],"sources":["src/components/content-navigation-block/content-navigation-block.scss?tag=content-navigation-block","src/components/content-navigation-block/content-navigation-block.tsx"],"sourcesContent":["body.content-navigation-block-open {\n overflow: hidden;\n}\ncontent-navigation-block {\n button {\n appearance: none;\n border: none;\n background: transparent;\n cursor: pointer;\n }\n \n .content-navigation-block__skip-content a, .content-navigation-block__skip-content button, .content-navigation-block__skip-content a:visited, .content-navigation-block__skip-content button:visited{\n border: 2px solid rgba(0,0,0, 1);\n border-radius: 2px;\n color: purple;\n cursor: pointer;\n display: inline-block;\n font-size: 14px;\n line-height: 20px;\n margin: 6px 11px;\n min-height: 32px;\n text-decoration: underline;\n text-align: center;\n width: 106px;\n z-index: 1000;\n }\n .content-navigation-block__skip-content:not(:focus-within) {\n position: absolute;\n // z-index: -1;\n\n clip: rect(1px,1px,1px,1px);\n overflow: hidden;\n padding: 0;\n }\n\n svg.default-icon {\n display: inline-block;\n width: 32px;\n }\n &[hamburger=\"fixed\"],\n &[hamburger=\"absolute\"],\n &[hamburger=\"static\"] {\n display: inline-block;\n &[aria-expanded=\"false\"] {\n .content-navigation__close {\n display: none;\n }\n }\n .content-navigation__open,\n .content-navigation__close {\n cursor: pointer;\n }\n \n .content-navigation__content-wrapper {\n display: none;\n &[hidden=\"false\"] {\n display: block;\n }\n }\n }\n\n &[hamburger=\"fixed\"] {\n .content-navigation__content-wrapper {\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"sticky\"] {\n .content-navigation__content-wrapper {\n position: sticky;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"absolute\"] {\n .content-navigation__content-wrapper {\n position: absolute;\n z-index: 100;\n }\n }\n &[hamburger=\"static\"] {\n .content-navigation__content-wrapper {\n position: static;\n }\n }\n \n &[hamburger=\"none\"] {\n display: block;\n .content-navigation__open,\n .content-navigation__close {\n display: none;\n }\n }\n\n &[aria-expanded=\"true\"] {\n .content-navigation__content-wrapper {\n display: block;\n }\n }\n}","import { Component, Prop, Host, h, State, Element } from '@stencil/core';\nimport { HTMLStencilElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\nimport { createFocusTrap } from 'focus-trap';\n\n/**\n * @slot openButton - This slot will expand the navigation when clicked.\n * @slot closeButton - This slot will close the navigation when clicked.\n * @slot skipContent - This slot is a keyboard-focus link that lets a screen-reader or keyboard user skip the navigation block and scroll to the end.\n * @slot content - Default slot\n */\n@Component({\n tag: 'content-navigation-block',\n styleUrl: 'content-navigation-block.scss',\n shadow: false,\n})\nexport class ContentNavigationBlock {\n /**\n * @type Select\n * @responsive\n * @options fixed\n * @options absolute\n * @options sticky\n * @options static\n * @options none\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n hamburger: ResponsiveString = 'fixed|none';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n @State() classString;\n @Element() hostElement: HTMLStencilElement;\n @State() ariaExpanded: string = 'false';\n @State() bodyToggle: boolean = false;\n @State() skipAccessibilityMessage: HTMLElement;\n\n @State() hasOpenButton: boolean = false;\n @State() hasCloseButton: boolean = false;\n\n @State() openButton: HTMLElement;\n @State() closeButton: HTMLElement;\n @State() contentSlot: HTMLElement;\n focusTrap;\n componentWillLoad() {\n this.hasOpenButton = !!this.hostElement.querySelector('[slot=\"openButton\"]');\n this.hasCloseButton = !!this.hostElement.querySelector('[slot=\"closeButton\"]');\n WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {\n this.hamburger = newValue as string;\n this.bodyToggle = this.hamburger === 'fixed';\n document.body.classList.remove('content-navigation-block-open');\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n componentDidLoad() {\n this.openButton.onclick = () => {\n this.openMenu();\n };\n this.closeButton.onclick = () => {\n this.closeMenu();\n };\n }\n\n openMenu() {\n this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';\n if (this.ariaExpanded === 'false') {\n document.body.classList.remove('content-navigation-block-open');\n } else if (this.bodyToggle) {\n document.body.classList.add('content-navigation-block-open');\n }\n this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {\n initialFocus: this.contentSlot,\n fallbackFocus: this.hostElement,\n clickOutsideDeactivates: true,\n onDeactivate: () => {\n this.closeMenu();\n this.focusTrap = null;\n this.ariaExpanded = 'false';\n document.body.classList.remove('content-navigation-block-open');\n setTimeout(() => this.openButton.focus(), 1);\n },\n });\n\n this.focusTrap.activate();\n }\n closeMenu() {\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n render() {\n return (\n <Host class={this.classString} aria-expanded={this.ariaExpanded}>\n <div class=\"content-navigation-block__skip-content\">\n <slot name=\"skipContent\"></slot>\n </div>\n <div ref={el => (this.openButton = el)} class=\"content-navigation__open\">\n {!this.hasOpenButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5\" />\n </svg>\n </button>\n )}\n <slot name=\"openButton\"></slot>\n </div>\n <div class=\"content-navigation__content-wrapper\">\n <div ref={el => (this.closeButton = el)} class=\"content-navigation__close\">\n {!this.hasCloseButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n <slot name=\"closeButton\"></slot>\n </div>\n <div class=\"content-navigation__content\" ref={el => (this.contentSlot = el)}>\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -22,6 +22,8 @@ export class ContentNavigationBlock {
|
|
|
22
22
|
this.contentSlot = undefined;
|
|
23
23
|
}
|
|
24
24
|
componentWillLoad() {
|
|
25
|
+
this.hasOpenButton = !!this.hostElement.querySelector('[slot="openButton"]');
|
|
26
|
+
this.hasCloseButton = !!this.hostElement.querySelector('[slot="closeButton"]');
|
|
25
27
|
WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {
|
|
26
28
|
this.hamburger = newValue;
|
|
27
29
|
this.bodyToggle = this.hamburger === 'fixed';
|
|
@@ -32,8 +34,6 @@ export class ContentNavigationBlock {
|
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
componentDidLoad() {
|
|
35
|
-
this.hasOpenButton = !!this.hostElement.querySelector('[slot="openButton"]');
|
|
36
|
-
this.hasCloseButton = !!this.hostElement.querySelector('content-navigation-block-close');
|
|
37
37
|
this.openButton.onclick = () => {
|
|
38
38
|
this.openMenu();
|
|
39
39
|
};
|
|
@@ -50,25 +50,31 @@ export class ContentNavigationBlock {
|
|
|
50
50
|
document.body.classList.add('content-navigation-block-open');
|
|
51
51
|
}
|
|
52
52
|
this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {
|
|
53
|
+
initialFocus: this.contentSlot,
|
|
53
54
|
fallbackFocus: this.hostElement,
|
|
54
55
|
clickOutsideDeactivates: true,
|
|
55
56
|
onDeactivate: () => {
|
|
56
57
|
this.closeMenu();
|
|
58
|
+
this.focusTrap = null;
|
|
59
|
+
this.ariaExpanded = 'false';
|
|
60
|
+
document.body.classList.remove('content-navigation-block-open');
|
|
61
|
+
setTimeout(() => this.openButton.focus(), 1);
|
|
57
62
|
},
|
|
58
63
|
});
|
|
59
|
-
|
|
64
|
+
this.focusTrap.activate();
|
|
60
65
|
}
|
|
61
66
|
closeMenu() {
|
|
62
67
|
if (this.focusTrap) {
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
try {
|
|
69
|
+
this.focusTrap.deactivate();
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
console.log(e);
|
|
73
|
+
}
|
|
65
74
|
}
|
|
66
|
-
this.ariaExpanded = 'false';
|
|
67
|
-
document.body.classList.remove('content-navigation-block-open');
|
|
68
|
-
setTimeout(() => this.openButton.focus(), 1);
|
|
69
75
|
}
|
|
70
76
|
render() {
|
|
71
|
-
return (h(Host, { class: this.classString, "aria-expanded": this.ariaExpanded }, h("div", { class: "content-navigation-block__skip-content" }, h("slot", { name: "skipContent" })), h("div", { ref: el => (this.openButton = el), class: "content-navigation__open" }, !this.hasOpenButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" })))), h("slot", { name: "openButton" })), h("div", { class: "content-navigation__content-wrapper" }, h("div", { ref: el => (this.closeButton = el), class: "content-navigation__close" }, !this.hasCloseButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" }))))), h("div", { class: "content-navigation__content", ref: el => (this.contentSlot = el) }, h("slot", { name: "
|
|
77
|
+
return (h(Host, { class: this.classString, "aria-expanded": this.ariaExpanded }, h("div", { class: "content-navigation-block__skip-content" }, h("slot", { name: "skipContent" })), h("div", { ref: el => (this.openButton = el), class: "content-navigation__open" }, !this.hasOpenButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" })))), h("slot", { name: "openButton" })), h("div", { class: "content-navigation__content-wrapper" }, h("div", { ref: el => (this.closeButton = el), class: "content-navigation__close" }, !this.hasCloseButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" })))), h("slot", { name: "closeButton" })), h("div", { class: "content-navigation__content", ref: el => (this.contentSlot = el) }, h("slot", { name: "content" }), h("slot", null)))));
|
|
72
78
|
}
|
|
73
79
|
static get is() { return "content-navigation-block"; }
|
|
74
80
|
static get originalStyleUrls() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-navigation-block.js","sourceRoot":"","sources":["../../../../src/components/content-navigation-block/content-navigation-block.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;GAKG;AAMH,MAAM,OAAO,sBAAsB;;yBAcH,YAAY;;;4BAaV,OAAO;0BACR,KAAK;;6BAGF,KAAK;8BACJ,KAAK;;;;;IAMxC,iBAAiB;QACf,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YACpE,IAAI,CAAC,SAAS,GAAG,QAAkB,CAAC;YACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC;YAC7C,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QACH,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YAClE,IAAI,CAAC,WAAW,GAAG,QAAkB,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"content-navig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AAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;oBACzE,YAAM,IAAI,EAAC,SAAS,GAAQ;oBAC5B,eAAa,CACT,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Host, h, State, Element } from '@stencil/core';\nimport { HTMLStencilElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\nimport { createFocusTrap } from 'focus-trap';\n\n/**\n * @slot openButton - This slot will expand the navigation when clicked.\n * @slot closeButton - This slot will close the navigation when clicked.\n * @slot skipContent - This slot is a keyboard-focus link that lets a screen-reader or keyboard user skip the navigation block and scroll to the end.\n * @slot content - Default slot\n */\n@Component({\n tag: 'content-navigation-block',\n styleUrl: 'content-navigation-block.scss',\n shadow: false,\n})\nexport class ContentNavigationBlock {\n /**\n * @type Select\n * @responsive\n * @options fixed\n * @options absolute\n * @options sticky\n * @options static\n * @options none\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n hamburger: ResponsiveString = 'fixed|none';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n @State() classString;\n @Element() hostElement: HTMLStencilElement;\n @State() ariaExpanded: string = 'false';\n @State() bodyToggle: boolean = false;\n @State() skipAccessibilityMessage: HTMLElement;\n\n @State() hasOpenButton: boolean = false;\n @State() hasCloseButton: boolean = false;\n\n @State() openButton: HTMLElement;\n @State() closeButton: HTMLElement;\n @State() contentSlot: HTMLElement;\n focusTrap;\n componentWillLoad() {\n this.hasOpenButton = !!this.hostElement.querySelector('[slot=\"openButton\"]');\n this.hasCloseButton = !!this.hostElement.querySelector('[slot=\"closeButton\"]');\n WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {\n this.hamburger = newValue as string;\n this.bodyToggle = this.hamburger === 'fixed';\n document.body.classList.remove('content-navigation-block-open');\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n componentDidLoad() {\n this.openButton.onclick = () => {\n this.openMenu();\n };\n this.closeButton.onclick = () => {\n this.closeMenu();\n };\n }\n\n openMenu() {\n this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';\n if (this.ariaExpanded === 'false') {\n document.body.classList.remove('content-navigation-block-open');\n } else if (this.bodyToggle) {\n document.body.classList.add('content-navigation-block-open');\n }\n this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {\n initialFocus: this.contentSlot,\n fallbackFocus: this.hostElement,\n clickOutsideDeactivates: true,\n onDeactivate: () => {\n this.closeMenu();\n this.focusTrap = null;\n this.ariaExpanded = 'false';\n document.body.classList.remove('content-navigation-block-open');\n setTimeout(() => this.openButton.focus(), 1);\n },\n });\n\n this.focusTrap.activate();\n }\n closeMenu() {\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n render() {\n return (\n <Host class={this.classString} aria-expanded={this.ariaExpanded}>\n <div class=\"content-navigation-block__skip-content\">\n <slot name=\"skipContent\"></slot>\n </div>\n <div ref={el => (this.openButton = el)} class=\"content-navigation__open\">\n {!this.hasOpenButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5\" />\n </svg>\n </button>\n )}\n <slot name=\"openButton\"></slot>\n </div>\n <div class=\"content-navigation__content-wrapper\">\n <div ref={el => (this.closeButton = el)} class=\"content-navigation__close\">\n {!this.hasCloseButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n <slot name=\"closeButton\"></slot>\n </div>\n <div class=\"content-navigation__content\" ref={el => (this.contentSlot = el)}>\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -57,7 +57,7 @@ export class ContentOverlay {
|
|
|
57
57
|
this.originalMarkup = this.contentSlot.innerHTML;
|
|
58
58
|
}
|
|
59
59
|
if (this.target) {
|
|
60
|
-
let targetElement = document.querySelector(this.target);
|
|
60
|
+
let targetElement = this.target === '#' ? this.hostElement.parentElement : document.querySelector(this.target);
|
|
61
61
|
if (targetElement) {
|
|
62
62
|
targetElement.classList.add('content-block-overlay-container');
|
|
63
63
|
targetElement.appendChild(this.hostElement);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-overlay.js","sourceRoot":"","sources":["../../../../src/components/content-overlay/content-overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,KAAK,EAAoC,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC;;;;GAIG;AAMH,MAAM,OAAO,cAAc;;;oBAgBC,OAAO;0BASD,MAAM;;0BAmBI,QAAQ;wBAYZ,QAAQ;0BAMjB,eAAe;wBAaf,OAAO;wBACP,KAAK;2BACH,EAAE;2BACF,EAAE;;4BAW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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Listen, Element } from '@stencil/core';\nimport { Event, EventEmitter, HTMLStencilElement, Method } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ContentLineTextAlignOptions, ContentVerticalAlignments, ResponsiveBoolean, ResponsiveString } from '../../typings';\nimport * as focusTrap from 'focus-trap';\nimport './libraries/aria-utilities';\nimport './libraries/aria-dialog';\n/**\n * @slot closeButton - Contents of the overlay close button.\n * @slot header - This is adjacent to the close button, usually a header or title for the overlay.\n * @slot content - Contents that sit inside the overlay.\n */\n@Component({\n tag: 'content-overlay',\n styleUrl: 'content-overlay.scss',\n shadow: false,\n})\nexport class ContentOverlay {\n @Element() hostElement: HTMLStencilElement;\n /**\n * @type String\n * @responsive\n */\n @Prop() target: string;\n\n /**\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n open: ResponsiveBoolean = 'false';\n /**\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n fullScreen: ResponsiveBoolean = 'true';\n /**\n * @type String\n * @responsive\n */\n @Prop() classes: ResponsiveString;\n /**\n * A pipe delimited setting for horizontal alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options default\n * @options left\n * @options center\n * @options right\n * @responsive\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n horizontal: ContentLineTextAlignOptions = 'center';\n /**\n * A pipe delimited setting for vertical alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options top\n * @options center\n * @options bottom\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n vertical: ContentVerticalAlignments = 'center';\n\n /**\n * Title attribute value for the close button.\n * @type String\n */\n @Prop() closeTitle: string = 'Close Overlay';\n /**\n * Position of the overlay.\n * @type Select\n * @options absolute\n * @options fixed\n * @options static\n * @options sticky\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n position: ResponsiveString = 'fixed';\n @State() isActive: boolean = false;\n @State() activeClass: string = '';\n @State() classString: string = '';\n @Event({\n bubbles: true,\n })\n contentOverlayActivated: EventEmitter<HTMLElement>;\n\n @State() contentSlot: HTMLElement;\n\n dialogElement: HTMLDivElement;\n contentElement: HTMLDivElement;\n\n @State() isFullScreen: boolean = false;\n @State() hasCloseButton: boolean = false;\n @State() originalMarkup: string;\n ariaDialog;\n focusTrap;\n @Listen('toggle')\n onContentBlockToggle(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n if (!this.isActive) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n }\n }\n @Listen('open')\n onContentBlockActivated(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n this.openOverlay();\n }\n }\n @Listen('close')\n onContentBlockDeactivated(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n this.closeOverlay();\n }\n }\n\n @Method()\n async openOverlay() {\n this.isActive = true;\n document.body.classList.add('content-overlay-open');\n document.body.classList.remove('content-overlay-close');\n if (!this.originalMarkup) {\n this.originalMarkup = this.contentSlot.innerHTML;\n }\n if (this.target) {\n let targetElement = document.querySelector(this.target);\n if (targetElement) {\n targetElement.classList.add('content-block-overlay-container');\n targetElement.appendChild(this.hostElement);\n }\n // } else if (this.isFullScreen) {\n // if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {\n // document.body.appendChild(this.hostElement);\n // }\n }\n\n if (this.originalMarkup) {\n this.contentSlot.innerHTML = this.originalMarkup;\n if (this.contentSlot.children[0] === this.contentSlot.querySelector('script[slot=\"content\"][type=\"text/template\"]')) {\n this.contentSlot.innerHTML = this.contentSlot.children[0].innerHTML;\n }\n this.setComputedActiveClass();\n this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {\n fallbackFocus: this.hostElement,\n allowOutsideClick: true,\n clickOutsideDeactivates: true,\n onDeactivate: () => {\n this.isActive = false;\n document.body.classList.add('content-overlay-close');\n document.body.classList.remove('content-overlay-open');\n this.activeClass = '';\n this.setComputedActiveClass();\n this.contentSlot.innerHTML = '';\n },\n });\n }\n this.contentOverlayActivated.emit(this.hostElement);\n }\n\n @Method()\n async closeOverlay() {\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n setComputedActiveClass() {\n this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${this.position}`;\n }\n\n componentWillLoad() {\n WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));\n WindowResizeService.registerProp(this.position).subscribe(newValue => (this.position = newValue as string));\n WindowResizeService.registerProp(this.horizontal).subscribe(newValue => this.hostElement.setAttribute('horizontal', newValue as ContentLineTextAlignOptions));\n WindowResizeService.registerProp(this.vertical).subscribe(newValue => this.hostElement.setAttribute('vertical', newValue as ContentVerticalAlignments));\n WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {\n this.fullScreen = newValue as string;\n this.isFullScreen = (newValue as string) === 'true';\n });\n WindowResizeService.registerProp(this.open).subscribe(newValue => {\n this.hostElement.setAttribute('open', newValue as string);\n });\n this.hasCloseButton = !!this.hostElement.querySelector('[slot=\"closeButton\"]');\n }\n\n closeOverlayButtonClicked(event) {\n event.preventDefault();\n this.closeOverlay();\n }\n\n render() {\n return (\n <Host class={`${this.activeClass} ${this.classString}`} position={this.position}>\n <div class=\"content-block-overlay-container\">\n <div class={`content-overlay-background ${this.isActive ? 'active' : ''}`}>\n <div ref={element => (this.dialogElement = element)} role=\"dialog\" aria-modal=\"true\" class={this.isActive ? 'active' : 'hidden'} aria-expanded={this.isActive}>\n <div class=\"content-overlay__header\">\n <button\n onClick={e => {\n this.closeOverlayButtonClicked(e);\n }}\n class=\"content-overlay__close\"\n title={this.closeTitle}\n >\n {!this.hasCloseButton && (\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n )}\n <slot name=\"closeButton\"></slot>\n </button>\n <slot name=\"header\"></slot>\n </div>\n <div class=\"content-overlay__content\" ref={(el: HTMLDivElement) => (this.contentSlot = el)}>\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidRender() {\n if (this.open === 'true') {\n this.openOverlay();\n }\n if (this.isActive && this.focusTrap && !this.focusTrap.active) {\n try {\n this.focusTrap.activate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"content-overlay.js","sourceRoot":"","sources":["../../../../src/components/content-overlay/content-overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,KAAK,EAAoC,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,4BAA4B,CAAC;AACpC,OAAO,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IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAC9D,IAAI,CAAC;gBACH,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YAC5B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Listen, Element } from '@stencil/core';\nimport { Event, EventEmitter, HTMLStencilElement, Method } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ContentLineTextAlignOptions, ContentVerticalAlignments, ResponsiveBoolean, ResponsiveString } from '../../typings';\nimport * as focusTrap from 'focus-trap';\nimport './libraries/aria-utilities';\nimport './libraries/aria-dialog';\n/**\n * @slot closeButton - Contents of the overlay close button.\n * @slot header - This is adjacent to the close button, usually a header or title for the overlay.\n * @slot content - Contents that sit inside the overlay.\n */\n@Component({\n tag: 'content-overlay',\n styleUrl: 'content-overlay.scss',\n shadow: false,\n})\nexport class ContentOverlay {\n @Element() hostElement: HTMLStencilElement;\n /**\n * @type String\n * @responsive\n */\n @Prop() target: string;\n\n /**\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n open: ResponsiveBoolean = 'false';\n /**\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n fullScreen: ResponsiveBoolean = 'true';\n /**\n * @type String\n * @responsive\n */\n @Prop() classes: ResponsiveString;\n /**\n * A pipe delimited setting for horizontal alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options default\n * @options left\n * @options center\n * @options right\n * @responsive\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n horizontal: ContentLineTextAlignOptions = 'center';\n /**\n * A pipe delimited setting for vertical alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options top\n * @options center\n * @options bottom\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n vertical: ContentVerticalAlignments = 'center';\n\n /**\n * Title attribute value for the close button.\n * @type String\n */\n @Prop() closeTitle: string = 'Close Overlay';\n /**\n * Position of the overlay.\n * @type Select\n * @options absolute\n * @options fixed\n * @options static\n * @options sticky\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n position: ResponsiveString = 'fixed';\n @State() isActive: boolean = false;\n @State() activeClass: string = '';\n @State() classString: string = '';\n @Event({\n bubbles: true,\n })\n contentOverlayActivated: EventEmitter<HTMLElement>;\n\n @State() contentSlot: HTMLElement;\n\n dialogElement: HTMLDivElement;\n contentElement: HTMLDivElement;\n\n @State() isFullScreen: boolean = false;\n @State() hasCloseButton: boolean = false;\n @State() originalMarkup: string;\n ariaDialog;\n focusTrap;\n @Listen('toggle')\n onContentBlockToggle(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n if (!this.isActive) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n }\n }\n @Listen('open')\n onContentBlockActivated(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n this.openOverlay();\n }\n }\n @Listen('close')\n onContentBlockDeactivated(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n this.closeOverlay();\n }\n }\n\n @Method()\n async openOverlay() {\n this.isActive = true;\n document.body.classList.add('content-overlay-open');\n document.body.classList.remove('content-overlay-close');\n if (!this.originalMarkup) {\n this.originalMarkup = this.contentSlot.innerHTML;\n }\n if (this.target) {\n let targetElement = this.target === '#' ? this.hostElement.parentElement : document.querySelector(this.target);\n if (targetElement) {\n targetElement.classList.add('content-block-overlay-container');\n targetElement.appendChild(this.hostElement);\n }\n // } else if (this.isFullScreen) {\n // if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {\n // document.body.appendChild(this.hostElement);\n // }\n }\n\n if (this.originalMarkup) {\n this.contentSlot.innerHTML = this.originalMarkup;\n if (this.contentSlot.children[0] === this.contentSlot.querySelector('script[slot=\"content\"][type=\"text/template\"]')) {\n this.contentSlot.innerHTML = this.contentSlot.children[0].innerHTML;\n }\n this.setComputedActiveClass();\n this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {\n fallbackFocus: this.hostElement,\n allowOutsideClick: true,\n clickOutsideDeactivates: true,\n onDeactivate: () => {\n this.isActive = false;\n document.body.classList.add('content-overlay-close');\n document.body.classList.remove('content-overlay-open');\n this.activeClass = '';\n this.setComputedActiveClass();\n this.contentSlot.innerHTML = '';\n },\n });\n }\n this.contentOverlayActivated.emit(this.hostElement);\n }\n\n @Method()\n async closeOverlay() {\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n setComputedActiveClass() {\n this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${this.position}`;\n }\n\n componentWillLoad() {\n WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));\n WindowResizeService.registerProp(this.position).subscribe(newValue => (this.position = newValue as string));\n WindowResizeService.registerProp(this.horizontal).subscribe(newValue => this.hostElement.setAttribute('horizontal', newValue as ContentLineTextAlignOptions));\n WindowResizeService.registerProp(this.vertical).subscribe(newValue => this.hostElement.setAttribute('vertical', newValue as ContentVerticalAlignments));\n WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {\n this.fullScreen = newValue as string;\n this.isFullScreen = (newValue as string) === 'true';\n });\n WindowResizeService.registerProp(this.open).subscribe(newValue => {\n this.hostElement.setAttribute('open', newValue as string);\n });\n this.hasCloseButton = !!this.hostElement.querySelector('[slot=\"closeButton\"]');\n }\n\n closeOverlayButtonClicked(event) {\n event.preventDefault();\n this.closeOverlay();\n }\n\n render() {\n return (\n <Host class={`${this.activeClass} ${this.classString}`} position={this.position}>\n <div class=\"content-block-overlay-container\">\n <div class={`content-overlay-background ${this.isActive ? 'active' : ''}`}>\n <div ref={element => (this.dialogElement = element)} role=\"dialog\" aria-modal=\"true\" class={this.isActive ? 'active' : 'hidden'} aria-expanded={this.isActive}>\n <div class=\"content-overlay__header\">\n <button\n onClick={e => {\n this.closeOverlayButtonClicked(e);\n }}\n class=\"content-overlay__close\"\n title={this.closeTitle}\n >\n {!this.hasCloseButton && (\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n )}\n <slot name=\"closeButton\"></slot>\n </button>\n <slot name=\"header\"></slot>\n </div>\n <div class=\"content-overlay__content\" ref={(el: HTMLDivElement) => (this.contentSlot = el)}>\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidRender() {\n if (this.open === 'true') {\n this.openOverlay();\n }\n if (this.isActive && this.focusTrap && !this.focusTrap.active) {\n try {\n this.focusTrap.activate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n}\n"]}
|
|
@@ -37,15 +37,20 @@ export class ContentButton {
|
|
|
37
37
|
ev.preventDefault();
|
|
38
38
|
// ev.stopPropagation();
|
|
39
39
|
this.activatedContent.dispatchEvent(new CustomEvent('open', { detail: this.activatedContent }));
|
|
40
|
-
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
this.activatedContent.scrollIntoView({ behavior: 'smooth' });
|
|
42
|
+
}, 0);
|
|
41
43
|
}
|
|
42
44
|
else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {
|
|
43
45
|
let element = document.getElementById(this.href.substring(1));
|
|
46
|
+
ev.preventDefault();
|
|
44
47
|
if (element) {
|
|
45
48
|
ev.preventDefault();
|
|
46
49
|
// ev.stopPropagation();
|
|
47
50
|
element.dispatchEvent(new CustomEvent('open', { detail: element }));
|
|
48
|
-
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
element.scrollIntoView({ behavior: 'smooth' });
|
|
53
|
+
}, 0);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-button.js","sourceRoot":"","sources":["../../../../src/elements/content-button/content-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,OAAO,EAAmC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAG3E;;;;GAIG;AAMH,MAAM,OAAO,aAAa;;;;uBAmBN,EAAE;2BACG,EAAE;8BAIS,KAAK;;;;;;;IAmCvC,iBAAiB;QACf,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAAC;QACpF,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;QACpD,2EAA2E;QAC3E,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QACpC,CAAC;QAED,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YACpE,IAAI,CAAC,SAAS,GAAG,QAAkB,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YAClE,IAAI,CAAC,WAAW,GAAG,QAAkB,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kBAAkB,CAAC,EAAE;QACnB,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,EAAE,CAAC,cAAc,EAAE,CAAC;YACpB,wBAAwB;YACxB,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;YAChG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"content-button.js","sourceRoot":"","sources":["../../../../src/elements/content-button/content-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,OAAO,EAAmC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAG3E;;;;GAIG;AAMH,MAAM,OAAO,aAAa;;;;uBAmBN,EAAE;2BACG,EAAE;8BAIS,KAAK;;;;;;;IAmCvC,iBAAiB;QACf,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAAC;QACpF,IAAI,CAAC,oBAAoB,GAAG,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Prop } from '@stencil/core';\nimport { Element, HostElement, HTMLStencilElement, State } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\n\n/**\n * @slot content - Inner contents of the button, usually plaintext.\n * @slot - Default slot, same as content slot.\n * @slot activatedContent - If this slot is used, the content in this will be scrolled to and triggered.\n */\n@Component({\n tag: 'content-button',\n styleUrl: 'content-button.scss',\n shadow: false,\n})\nexport class ContentButton {\n @Element() hostElement: HostElement;\n /**\n * @type URL\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n href: string;\n /**\n * @type String\n */\n @Prop() target: string;\n /**\n * The classes for the button.\n * @type String\n * @responsive\n */\n @Prop() classes = '';\n @State() classString = '';\n /**\n * @type Boolean\n */\n @Prop() clickableBlock: boolean = false;\n /**\n * @type Boolean\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n expanded: string;\n /**\n\n /**\n * Aria-controls value\n * @type Target\n */\n @Prop() controls: string;\n\n /**\n * @type String\n * @responsive\n */\n @Prop() linkLabel: ResponsiveString;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n linkClass: ResponsiveString;\n @State() hasContentToActivate: boolean;\n\n public activatedContent: HTMLDivElement;\n\n componentWillLoad() {\n this.activatedContent = this.hostElement.querySelector('[slot=\"activatedContent\"]');\n this.hasContentToActivate = !!this.activatedContent;\n // If this is a clickable block, forcefully add a # to force an anchor link\n if (!this.href || this.href === '#') {\n this.href = 'javascript:void(0);';\n }\n\n WindowResizeService.registerProp(this.linkClass).subscribe(newValue => {\n this.linkClass = newValue as string;\n });\n\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n onHandleClickEvent(ev) {\n if (this.hasContentToActivate) {\n ev.preventDefault();\n // ev.stopPropagation();\n this.activatedContent.dispatchEvent(new CustomEvent('open', { detail: this.activatedContent }));\n setTimeout(() => {\n this.activatedContent.scrollIntoView({ behavior: 'smooth' });\n }, 0);\n } else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {\n let element = document.getElementById(this.href.substring(1));\n ev.preventDefault();\n if (element) {\n ev.preventDefault();\n // ev.stopPropagation();\n element.dispatchEvent(new CustomEvent('open', { detail: element }));\n setTimeout(() => {\n element.scrollIntoView({ behavior: 'smooth' });\n }, 0);\n }\n }\n }\n\n render() {\n return (\n <Host class={this.classString}>\n <a\n aria-label={this.linkLabel}\n class={this.linkClass}\n role={this.href === 'javascript:void(0);' ? 'button' : ''}\n onClick={ev => this.onHandleClickEvent(ev)}\n aria-expanded={this.expanded}\n aria-controls={this.controls}\n href={this.href}\n target={this.target}\n >\n {!this.clickableBlock ? (\n <span>\n <slot name=\"content\"></slot>\n <slot></slot>\n </span>\n ) : (\n <div class=\"content-button__clickable-content\">\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n )}\n </a>\n <slot name=\"activatedContent\"></slot>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -37,15 +37,20 @@ const ContentButton$1 = /*@__PURE__*/ proxyCustomElement(class ContentButton ext
|
|
|
37
37
|
ev.preventDefault();
|
|
38
38
|
// ev.stopPropagation();
|
|
39
39
|
this.activatedContent.dispatchEvent(new CustomEvent('open', { detail: this.activatedContent }));
|
|
40
|
-
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
this.activatedContent.scrollIntoView({ behavior: 'smooth' });
|
|
42
|
+
}, 0);
|
|
41
43
|
}
|
|
42
44
|
else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {
|
|
43
45
|
let element = document.getElementById(this.href.substring(1));
|
|
46
|
+
ev.preventDefault();
|
|
44
47
|
if (element) {
|
|
45
48
|
ev.preventDefault();
|
|
46
49
|
// ev.stopPropagation();
|
|
47
50
|
element.dispatchEvent(new CustomEvent('open', { detail: element }));
|
|
48
|
-
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
element.scrollIntoView({ behavior: 'smooth' });
|
|
53
|
+
}, 0);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"content-button.js","mappings":";;;AAAA,MAAM,gBAAgB,GAAG,knBAAknB;;MCe9nBA,eAAa;;;;;;uBAmBN,EAAE;2BACG,EAAE;8BAIS,KAAK;;;;;;;IAmCvC,iBAAiB;QACf,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAAC;QACpF,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;;QAEpD,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE;YACnC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;SACnC;QAED,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ;YACjE,IAAI,CAAC,SAAS,GAAG,QAAkB,CAAC;SACrC,CAAC,CAAC;QAEH,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ;YAC/D,IAAI,CAAC,WAAW,GAAG,QAAkB,CAAC;SACvC,CAAC,CAAC;KACJ;IAED,kBAAkB,CAAC,EAAE;QACnB,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC7B,EAAE,CAAC,cAAc,EAAE,CAAC;;YAEpB,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;YAChG,IAAI,C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ACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["ContentButton"],"sources":["src/elements/content-button/content-button.scss?tag=content-button","src/elements/content-button/content-button.tsx"],"sourcesContent":["content-button {\n display: inline-block;\n > a, > button {\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n }\n > button {\n appearance: none;\n background: inherit;\n cursor: pointer;\n }\n\n &[clickable-block=\"true\"] {\n display: block;\n width: 100%;\n height: 100%;\n > a,\n > button {\n height: 100%;\n width: 100%;\n > * {\n display: block;\n width: 100%;\n }\n }\n .content-button__clickable-content {\n width: 100%;\n height: 100%;\n }\n }\n\n}","import { Component, h, Host, Prop } from '@stencil/core';\nimport { Element, HostElement, HTMLStencilElement, State } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\n\n/**\n * @slot content - Inner contents of the button, usually plaintext.\n * @slot - Default slot, same as content slot.\n * @slot activatedContent - If this slot is used, the content in this will be scrolled to and triggered.\n */\n@Component({\n tag: 'content-button',\n styleUrl: 'content-button.scss',\n shadow: false,\n})\nexport class ContentButton {\n @Element() hostElement: HostElement;\n /**\n * @type URL\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n href: string;\n /**\n * @type String\n */\n @Prop() target: string;\n /**\n * The classes for the button.\n * @type String\n * @responsive\n */\n @Prop() classes = '';\n @State() classString = '';\n /**\n * @type Boolean\n */\n @Prop() clickableBlock: boolean = false;\n /**\n * @type Boolean\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n expanded: string;\n /**\n\n /**\n * Aria-controls value\n * @type Target\n */\n @Prop() controls: string;\n\n /**\n * @type String\n * @responsive\n */\n @Prop() linkLabel: ResponsiveString;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n linkClass: ResponsiveString;\n @State() hasContentToActivate: boolean;\n\n public activatedContent: HTMLDivElement;\n\n componentWillLoad() {\n this.activatedContent = this.hostElement.querySelector('[slot=\"activatedContent\"]');\n this.hasContentToActivate = !!this.activatedContent;\n // If this is a clickable block, forcefully add a # to force an anchor link\n if (!this.href || this.href === '#') {\n this.href = 'javascript:void(0);';\n }\n\n WindowResizeService.registerProp(this.linkClass).subscribe(newValue => {\n this.linkClass = newValue as string;\n });\n\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n onHandleClickEvent(ev) {\n if (this.hasContentToActivate) {\n ev.preventDefault();\n // ev.stopPropagation();\n this.activatedContent.dispatchEvent(new CustomEvent('open', { detail: this.activatedContent }));\n setTimeout(() => {\n this.activatedContent.scrollIntoView({ behavior: 'smooth' });\n }, 0);\n } else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {\n let element = document.getElementById(this.href.substring(1));\n ev.preventDefault();\n if (element) {\n ev.preventDefault();\n // ev.stopPropagation();\n element.dispatchEvent(new CustomEvent('open', { detail: element }));\n setTimeout(() => {\n element.scrollIntoView({ behavior: 'smooth' });\n }, 0);\n }\n }\n }\n\n render() {\n return (\n <Host class={this.classString}>\n <a\n aria-label={this.linkLabel}\n class={this.linkClass}\n role={this.href === 'javascript:void(0);' ? 'button' : ''}\n onClick={ev => this.onHandleClickEvent(ev)}\n aria-expanded={this.expanded}\n aria-controls={this.controls}\n href={this.href}\n target={this.target}\n >\n {!this.clickableBlock ? (\n <span>\n <slot name=\"content\"></slot>\n <slot></slot>\n </span>\n ) : (\n <div class=\"content-button__clickable-content\">\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n )}\n </a>\n <slot name=\"activatedContent\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -21,6 +21,8 @@ const ContentNavigationBlock$1 = /*@__PURE__*/ proxyCustomElement(class ContentN
|
|
|
21
21
|
this.contentSlot = undefined;
|
|
22
22
|
}
|
|
23
23
|
componentWillLoad() {
|
|
24
|
+
this.hasOpenButton = !!this.hostElement.querySelector('[slot="openButton"]');
|
|
25
|
+
this.hasCloseButton = !!this.hostElement.querySelector('[slot="closeButton"]');
|
|
24
26
|
WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {
|
|
25
27
|
this.hamburger = newValue;
|
|
26
28
|
this.bodyToggle = this.hamburger === 'fixed';
|
|
@@ -31,8 +33,6 @@ const ContentNavigationBlock$1 = /*@__PURE__*/ proxyCustomElement(class ContentN
|
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
componentDidLoad() {
|
|
34
|
-
this.hasOpenButton = !!this.hostElement.querySelector('[slot="openButton"]');
|
|
35
|
-
this.hasCloseButton = !!this.hostElement.querySelector('content-navigation-block-close');
|
|
36
36
|
this.openButton.onclick = () => {
|
|
37
37
|
this.openMenu();
|
|
38
38
|
};
|
|
@@ -49,25 +49,31 @@ const ContentNavigationBlock$1 = /*@__PURE__*/ proxyCustomElement(class ContentN
|
|
|
49
49
|
document.body.classList.add('content-navigation-block-open');
|
|
50
50
|
}
|
|
51
51
|
this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {
|
|
52
|
+
initialFocus: this.contentSlot,
|
|
52
53
|
fallbackFocus: this.hostElement,
|
|
53
54
|
clickOutsideDeactivates: true,
|
|
54
55
|
onDeactivate: () => {
|
|
55
56
|
this.closeMenu();
|
|
57
|
+
this.focusTrap = null;
|
|
58
|
+
this.ariaExpanded = 'false';
|
|
59
|
+
document.body.classList.remove('content-navigation-block-open');
|
|
60
|
+
setTimeout(() => this.openButton.focus(), 1);
|
|
56
61
|
},
|
|
57
62
|
});
|
|
58
|
-
|
|
63
|
+
this.focusTrap.activate();
|
|
59
64
|
}
|
|
60
65
|
closeMenu() {
|
|
61
66
|
if (this.focusTrap) {
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
try {
|
|
68
|
+
this.focusTrap.deactivate();
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
console.log(e);
|
|
72
|
+
}
|
|
64
73
|
}
|
|
65
|
-
this.ariaExpanded = 'false';
|
|
66
|
-
document.body.classList.remove('content-navigation-block-open');
|
|
67
|
-
setTimeout(() => this.openButton.focus(), 1);
|
|
68
74
|
}
|
|
69
75
|
render() {
|
|
70
|
-
return (h(Host, { class: this.classString, "aria-expanded": this.ariaExpanded }, h("div", { class: "content-navigation-block__skip-content" }, h("slot", { name: "skipContent" })), h("div", { ref: el => (this.openButton = el), class: "content-navigation__open" }, !this.hasOpenButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" })))), h("slot", { name: "openButton" })), h("div", { class: "content-navigation__content-wrapper" }, h("div", { ref: el => (this.closeButton = el), class: "content-navigation__close" }, !this.hasCloseButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" }))))), h("div", { class: "content-navigation__content", ref: el => (this.contentSlot = el) }, h("slot", { name: "
|
|
76
|
+
return (h(Host, { class: this.classString, "aria-expanded": this.ariaExpanded }, h("div", { class: "content-navigation-block__skip-content" }, h("slot", { name: "skipContent" })), h("div", { ref: el => (this.openButton = el), class: "content-navigation__open" }, !this.hasOpenButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" })))), h("slot", { name: "openButton" })), h("div", { class: "content-navigation__content-wrapper" }, h("div", { ref: el => (this.closeButton = el), class: "content-navigation__close" }, !this.hasCloseButton && (h("button", null, h("svg", { class: "default-icon", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" })))), h("slot", { name: "closeButton" })), h("div", { class: "content-navigation__content", ref: el => (this.contentSlot = el) }, h("slot", { name: "content" }), h("slot", null)))));
|
|
71
77
|
}
|
|
72
78
|
get hostElement() { return this; }
|
|
73
79
|
static get style() { return contentNavigationBlockCss; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"content-navigation-block.js","mappings":";;;;AAAA,MAAM,yBAAyB,GAAG,+kGAA+kG;;MCiBpmGA,wBAAsB;;;;yBAcH,YAAY;;;4BAaV,OAAO;0BACR,KAAK;;6BAGF,KAAK;8BACJ,KAAK;;;;;IAMxC,iBAAiB;QACf,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ;YACjE,IAAI,CAAC,SAAS,GAAG,QAAkB,CAAC;YACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC;YAC7C,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC;SACjE,CAAC,CAAC;QACH,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ;YAC/D,IAAI,CAAC,WAAW,GAAG,QAAkB,CAAC;SACvC,CAAC,CAAC;KACJ;IAED,gBAAgB;QACd,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,gCAAgC,CAAC,CAAC;QACzF,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG;YACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjB,CAA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C,wCAAwC,IACjD,YAAM,IAAI,EAAC,aAAa,GAAQ,CAC5B,EACN,WAAK,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,KAAK,EAAC,0BAA0B,IACrE,CAAC,IAAI,CAAC,aAAa,KAClB,kBACE,WAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,kBAAc,KAAK,EAAC,MAAM,EAAC,cAAc,IACnI,8BAAqB,OAAO,qBAAiB,OAAO,EAAC,CAAC,EAAC,8CAA8C,GAAG,CACpG,CACC,CACV,EACD,YAAM,IAAI,EAAC,YAAY,GAAQ,CAC3B,EACN,WAAK,KAAK,EAAC,qCAAqC,IAC9C,WAAK,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,EAAE,KAAK,EAAC,2BAA2B,IACvE,CAAC,IAAI,CAAC,cAAc,KACnB,kBACE,WAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,kBAAc,KAAK,EAAC,MAAM,EAAC,cAAc,IACnI,8BAAqB,OAAO,qBAAiB,OAAO,EAAC,CAAC,EAAC,sBAAsB,GAAG,CAC5E,CACC,CACV,CACG,EACN,WAAK,KAAK,EAAC,6BAA6B,EAAC,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,IACzE,YAAM,IAAI,EAAC,aAAa,GAAQ,EAChC,YAAM,IAAI,EAAC,SAAS,GAAQ,EAC5B,eAAa,CACT,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["ContentNavigationBlock"],"sources":["src/components/content-navigation-block/content-navigation-block.scss?tag=content-navigation-block","src/components/content-navigation-block/content-navigation-block.tsx"],"sourcesContent":["body.content-navigation-block-open {\n overflow: hidden;\n}\ncontent-navigation-block {\n button {\n appearance: none;\n border: none;\n background: transparent;\n cursor: pointer;\n }\n \n .content-navigation-block__skip-content a, .content-navigation-block__skip-content button, .content-navigation-block__skip-content a:visited, .content-navigation-block__skip-content button:visited{\n border: 2px solid rgba(0,0,0, 1);\n border-radius: 2px;\n color: purple;\n cursor: pointer;\n display: inline-block;\n font-size: 14px;\n line-height: 20px;\n margin: 6px 11px;\n min-height: 32px;\n text-decoration: underline;\n text-align: center;\n width: 106px;\n z-index: 1000;\n }\n .content-navigation-block__skip-content:not(:focus-within) {\n position: absolute;\n // z-index: -1;\n\n clip: rect(1px,1px,1px,1px);\n overflow: hidden;\n padding: 0;\n }\n\n svg.default-icon {\n display: inline-block;\n width: 32px;\n }\n &[hamburger=\"fixed\"],\n &[hamburger=\"absolute\"],\n &[hamburger=\"static\"] {\n display: inline-block;\n &[aria-expanded=\"false\"] {\n .content-navigation__close {\n display: none;\n }\n }\n .content-navigation__open,\n .content-navigation__close {\n cursor: pointer;\n }\n \n .content-navigation__content-wrapper {\n display: none;\n &[hidden=\"false\"] {\n display: block;\n }\n }\n }\n\n &[hamburger=\"fixed\"] {\n .content-navigation__content-wrapper {\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"sticky\"] {\n .content-navigation__content-wrapper {\n position: sticky;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"absolute\"] {\n .content-navigation__content-wrapper {\n position: absolute;\n z-index: 100;\n }\n }\n &[hamburger=\"static\"] {\n .content-navigation__content-wrapper {\n position: static;\n }\n }\n \n &[hamburger=\"none\"] {\n display: block;\n .content-navigation__open,\n .content-navigation__close {\n display: none;\n }\n }\n\n &[aria-expanded=\"true\"] {\n .content-navigation__content-wrapper {\n display: block;\n }\n }\n}","import { Component, Prop, Host, h, State, Element } from '@stencil/core';\nimport { HTMLStencilElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\nimport { createFocusTrap } from 'focus-trap';\n\n/**\n * @slot openButton - This slot will expand the navigation when clicked.\n * @slot closeButton - This slot will close the navigation when clicked.\n * @slot skipContent - This slot is a keyboard-focus link that lets a screen-reader or keyboard user skip the navigation block and scroll to the end.\n * @slot content - Default slot\n */\n@Component({\n tag: 'content-navigation-block',\n styleUrl: 'content-navigation-block.scss',\n shadow: false,\n})\nexport class ContentNavigationBlock {\n /**\n * @type Select\n * @responsive\n * @options fixed\n * @options absolute\n * @options sticky\n * @options static\n * @options none\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n hamburger: ResponsiveString = 'fixed|none';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n @State() classString;\n @Element() hostElement: HTMLStencilElement;\n @State() ariaExpanded: string = 'false';\n @State() bodyToggle: boolean = false;\n @State() skipAccessibilityMessage: HTMLElement;\n\n @State() hasOpenButton: boolean = false;\n @State() hasCloseButton: boolean = false;\n\n @State() openButton: HTMLElement;\n @State() closeButton: HTMLElement;\n @State() contentSlot: HTMLElement;\n focusTrap;\n componentWillLoad() {\n WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {\n this.hamburger = newValue as string;\n this.bodyToggle = this.hamburger === 'fixed';\n document.body.classList.remove('content-navigation-block-open');\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n componentDidLoad() {\n this.hasOpenButton = !!this.hostElement.querySelector('[slot=\"openButton\"]');\n this.hasCloseButton = !!this.hostElement.querySelector('content-navigation-block-close');\n this.openButton.onclick = () => {\n this.openMenu();\n };\n this.closeButton.onclick = () => {\n this.closeMenu();\n };\n }\n\n openMenu() {\n this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';\n if (this.ariaExpanded === 'false') {\n document.body.classList.remove('content-navigation-block-open');\n } else if (this.bodyToggle) {\n document.body.classList.add('content-navigation-block-open');\n }\n this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {\n fallbackFocus: this.hostElement,\n clickOutsideDeactivates: true,\n onDeactivate: () => {\n this.closeMenu();\n },\n });\n\n setTimeout(() => this.closeButton.focus(), 1);\n }\n closeMenu() {\n if (this.focusTrap) {\n this.focusTrap.deactivate();\n this.focusTrap = null;\n }\n this.ariaExpanded = 'false';\n document.body.classList.remove('content-navigation-block-open');\n setTimeout(() => this.openButton.focus(), 1);\n }\n\n render() {\n return (\n <Host class={this.classString} aria-expanded={this.ariaExpanded}>\n <div class=\"content-navigation-block__skip-content\">\n <slot name=\"skipContent\"></slot>\n </div>\n <div ref={el => (this.openButton = el)} class=\"content-navigation__open\">\n {!this.hasOpenButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5\" />\n </svg>\n </button>\n )}\n <slot name=\"openButton\"></slot>\n </div>\n <div class=\"content-navigation__content-wrapper\">\n <div ref={el => (this.closeButton = el)} class=\"content-navigation__close\">\n {!this.hasCloseButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n </div>\n <div class=\"content-navigation__content\" ref={el => (this.contentSlot = el)}>\n <slot name=\"closeButton\"></slot>\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"content-navigation-block.js","mappings":";;;;AAAA,MAAM,yBAAyB,GAAG,+kGAA+kG;;MCiBpm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AW,kBAAc,KAAK,EAAC,MAAM,EAAC,cAAc,IACnI,8BAAqB,OAAO,qBAAiB,OAAO,EAAC,CAAC,EAAC,8CAA8C,GAAG,CACpG,CACC,CACV,EACD,YAAM,IAAI,EAAC,YAAY,GAAQ,CAC3B,EACN,WAAK,KAAK,EAAC,qCAAqC,IAC9C,WAAK,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,EAAE,KAAK,EAAC,2BAA2B,IACvE,CAAC,IAAI,CAAC,cAAc,KACnB,kBACE,WAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,kBAAc,KAAK,EAAC,MAAM,EAAC,cAAc,IACnI,8BAAqB,OAAO,qBAAiB,OAAO,EAAC,CAAC,EAAC,sBAAsB,GAAG,CAC5E,CACC,CACV,EACD,YAAM,IAAI,EAAC,aAAa,GAAQ,CAC5B,EACN,WAAK,KAAK,EAAC,6BAA6B,EAAC,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,IACzE,YAAM,IAAI,EAAC,SAAS,GAAQ,EAC5B,eAAa,CACT,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["ContentNavigationBlock"],"sources":["src/components/content-navigation-block/content-navigation-block.scss?tag=content-navigation-block","src/components/content-navigation-block/content-navigation-block.tsx"],"sourcesContent":["body.content-navigation-block-open {\n overflow: hidden;\n}\ncontent-navigation-block {\n button {\n appearance: none;\n border: none;\n background: transparent;\n cursor: pointer;\n }\n \n .content-navigation-block__skip-content a, .content-navigation-block__skip-content button, .content-navigation-block__skip-content a:visited, .content-navigation-block__skip-content button:visited{\n border: 2px solid rgba(0,0,0, 1);\n border-radius: 2px;\n color: purple;\n cursor: pointer;\n display: inline-block;\n font-size: 14px;\n line-height: 20px;\n margin: 6px 11px;\n min-height: 32px;\n text-decoration: underline;\n text-align: center;\n width: 106px;\n z-index: 1000;\n }\n .content-navigation-block__skip-content:not(:focus-within) {\n position: absolute;\n // z-index: -1;\n\n clip: rect(1px,1px,1px,1px);\n overflow: hidden;\n padding: 0;\n }\n\n svg.default-icon {\n display: inline-block;\n width: 32px;\n }\n &[hamburger=\"fixed\"],\n &[hamburger=\"absolute\"],\n &[hamburger=\"static\"] {\n display: inline-block;\n &[aria-expanded=\"false\"] {\n .content-navigation__close {\n display: none;\n }\n }\n .content-navigation__open,\n .content-navigation__close {\n cursor: pointer;\n }\n \n .content-navigation__content-wrapper {\n display: none;\n &[hidden=\"false\"] {\n display: block;\n }\n }\n }\n\n &[hamburger=\"fixed\"] {\n .content-navigation__content-wrapper {\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"sticky\"] {\n .content-navigation__content-wrapper {\n position: sticky;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n z-index: 100;\n }\n }\n &[hamburger=\"absolute\"] {\n .content-navigation__content-wrapper {\n position: absolute;\n z-index: 100;\n }\n }\n &[hamburger=\"static\"] {\n .content-navigation__content-wrapper {\n position: static;\n }\n }\n \n &[hamburger=\"none\"] {\n display: block;\n .content-navigation__open,\n .content-navigation__close {\n display: none;\n }\n }\n\n &[aria-expanded=\"true\"] {\n .content-navigation__content-wrapper {\n display: block;\n }\n }\n}","import { Component, Prop, Host, h, State, Element } from '@stencil/core';\nimport { HTMLStencilElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\nimport { createFocusTrap } from 'focus-trap';\n\n/**\n * @slot openButton - This slot will expand the navigation when clicked.\n * @slot closeButton - This slot will close the navigation when clicked.\n * @slot skipContent - This slot is a keyboard-focus link that lets a screen-reader or keyboard user skip the navigation block and scroll to the end.\n * @slot content - Default slot\n */\n@Component({\n tag: 'content-navigation-block',\n styleUrl: 'content-navigation-block.scss',\n shadow: false,\n})\nexport class ContentNavigationBlock {\n /**\n * @type Select\n * @responsive\n * @options fixed\n * @options absolute\n * @options sticky\n * @options static\n * @options none\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n hamburger: ResponsiveString = 'fixed|none';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n @State() classString;\n @Element() hostElement: HTMLStencilElement;\n @State() ariaExpanded: string = 'false';\n @State() bodyToggle: boolean = false;\n @State() skipAccessibilityMessage: HTMLElement;\n\n @State() hasOpenButton: boolean = false;\n @State() hasCloseButton: boolean = false;\n\n @State() openButton: HTMLElement;\n @State() closeButton: HTMLElement;\n @State() contentSlot: HTMLElement;\n focusTrap;\n componentWillLoad() {\n this.hasOpenButton = !!this.hostElement.querySelector('[slot=\"openButton\"]');\n this.hasCloseButton = !!this.hostElement.querySelector('[slot=\"closeButton\"]');\n WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {\n this.hamburger = newValue as string;\n this.bodyToggle = this.hamburger === 'fixed';\n document.body.classList.remove('content-navigation-block-open');\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n componentDidLoad() {\n this.openButton.onclick = () => {\n this.openMenu();\n };\n this.closeButton.onclick = () => {\n this.closeMenu();\n };\n }\n\n openMenu() {\n this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';\n if (this.ariaExpanded === 'false') {\n document.body.classList.remove('content-navigation-block-open');\n } else if (this.bodyToggle) {\n document.body.classList.add('content-navigation-block-open');\n }\n this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {\n initialFocus: this.contentSlot,\n fallbackFocus: this.hostElement,\n clickOutsideDeactivates: true,\n onDeactivate: () => {\n this.closeMenu();\n this.focusTrap = null;\n this.ariaExpanded = 'false';\n document.body.classList.remove('content-navigation-block-open');\n setTimeout(() => this.openButton.focus(), 1);\n },\n });\n\n this.focusTrap.activate();\n }\n closeMenu() {\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n render() {\n return (\n <Host class={this.classString} aria-expanded={this.ariaExpanded}>\n <div class=\"content-navigation-block__skip-content\">\n <slot name=\"skipContent\"></slot>\n </div>\n <div ref={el => (this.openButton = el)} class=\"content-navigation__open\">\n {!this.hasOpenButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5\" />\n </svg>\n </button>\n )}\n <slot name=\"openButton\"></slot>\n </div>\n <div class=\"content-navigation__content-wrapper\">\n <div ref={el => (this.closeButton = el)} class=\"content-navigation__close\">\n {!this.hasCloseButton && (\n <button>\n <svg class=\"default-icon\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n <slot name=\"closeButton\"></slot>\n </div>\n <div class=\"content-navigation__content\" ref={el => (this.contentSlot = el)}>\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -490,7 +490,7 @@ const ContentOverlay$1 = /*@__PURE__*/ proxyCustomElement(class ContentOverlay e
|
|
|
490
490
|
this.originalMarkup = this.contentSlot.innerHTML;
|
|
491
491
|
}
|
|
492
492
|
if (this.target) {
|
|
493
|
-
let targetElement = document.querySelector(this.target);
|
|
493
|
+
let targetElement = this.target === '#' ? this.hostElement.parentElement : document.querySelector(this.target);
|
|
494
494
|
if (targetElement) {
|
|
495
495
|
targetElement.classList.add('content-block-overlay-container');
|
|
496
496
|
targetElement.appendChild(this.hostElement);
|