@content-blocks/js 0.7.0 → 0.7.2

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.
Files changed (113) hide show
  1. package/dist/cjs/content-accordion_11.cjs.entry.js +45 -1545
  2. package/dist/cjs/content-accordion_11.cjs.entry.js.map +1 -1
  3. package/dist/cjs/content-blocks.cjs.js +1 -1
  4. package/dist/cjs/content-carousel.cjs.entry.js +6 -5
  5. package/dist/cjs/content-carousel.cjs.entry.js.map +1 -1
  6. package/dist/cjs/content-navigation-block.cjs.entry.js +41 -24
  7. package/dist/cjs/content-navigation-block.cjs.entry.js.map +1 -1
  8. package/dist/cjs/focus-trap.esm-a1e3774c.js +1509 -0
  9. package/dist/cjs/focus-trap.esm-a1e3774c.js.map +1 -0
  10. package/dist/cjs/index-f38d389e.js +5224 -0
  11. package/dist/cjs/index-f38d389e.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/{swiper-4fade542.js → swiper-e5a68ae2.js} +68 -469
  14. package/dist/cjs/swiper-e5a68ae2.js.map +1 -0
  15. package/dist/cjs/utils-c04e978e.js +457 -0
  16. package/dist/cjs/utils-c04e978e.js.map +1 -0
  17. package/dist/cjs/window-resize-service-ac5c2012.js.map +1 -1
  18. package/dist/collection/components/content-carousel/content-carousel.js +5 -4
  19. package/dist/collection/components/content-carousel/content-carousel.js.map +1 -1
  20. package/dist/collection/components/content-navigation-block/content-navigation-block.css +55 -13
  21. package/dist/collection/components/content-navigation-block/content-navigation-block.js +51 -24
  22. package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +1 -1
  23. package/dist/collection/components/content-overlay/content-overlay.css +11 -6
  24. package/dist/collection/components/content-overlay/content-overlay.js +69 -34
  25. package/dist/collection/components/content-overlay/content-overlay.js.map +1 -1
  26. package/dist/collection/elements/content-image/content-image.js +4 -4
  27. package/dist/collection/elements/content-image/content-image.js.map +1 -1
  28. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.css +4 -3
  29. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js +37 -0
  30. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js.map +1 -1
  31. package/dist/collection/formatters/content-spacer/content-spacer.css +3 -4
  32. package/dist/collection/formatters/content-spacer/content-spacer.js +13 -5
  33. package/dist/collection/formatters/content-spacer/content-spacer.js.map +1 -1
  34. package/dist/collection/services/window-resize-service.js.map +1 -1
  35. package/dist/collection/stories/ContentNavigationBlock.stories.js +1 -1
  36. package/dist/collection/stories/ContentNavigationBlock.stories.js.map +1 -1
  37. package/dist/collection/stories/ContentTextBlock.stories.js +5 -5
  38. package/dist/collection/stories/ContentTextBlock.stories.js.map +1 -1
  39. package/dist/collection/stories/FullPageExample.stories.js +164 -214
  40. package/dist/collection/stories/FullPageExample.stories.js.map +1 -1
  41. package/dist/components/content-carousel.js +5 -4
  42. package/dist/components/content-carousel.js.map +1 -1
  43. package/dist/components/content-grid-formatter2.js +9 -1
  44. package/dist/components/content-grid-formatter2.js.map +1 -1
  45. package/dist/components/content-image.js +4 -4
  46. package/dist/components/content-image.js.map +1 -1
  47. package/dist/components/content-navigation-block.js +48 -25
  48. package/dist/components/content-navigation-block.js.map +1 -1
  49. package/dist/components/content-overlay.js +32 -1538
  50. package/dist/components/content-overlay.js.map +1 -1
  51. package/dist/components/content-spacer.js +3 -3
  52. package/dist/components/content-spacer.js.map +1 -1
  53. package/dist/components/focus-trap.esm.js +1507 -0
  54. package/dist/components/focus-trap.esm.js.map +1 -0
  55. package/dist/components/index2.js +5200 -0
  56. package/dist/components/index2.js.map +1 -0
  57. package/dist/components/swiper.js +1 -402
  58. package/dist/components/swiper.js.map +1 -1
  59. package/dist/components/utils2.js +433 -0
  60. package/dist/components/utils2.js.map +1 -0
  61. package/dist/components/window-resize-service.js.map +1 -1
  62. package/dist/content-blocks/content-blocks.esm.js +1 -1
  63. package/dist/content-blocks/content-blocks.esm.js.map +1 -1
  64. package/dist/content-blocks/p-75ac85e9.js +2 -0
  65. package/dist/content-blocks/p-75ac85e9.js.map +1 -0
  66. package/dist/content-blocks/p-7ff352fe.entry.js +2 -0
  67. package/dist/content-blocks/p-7ff352fe.entry.js.map +1 -0
  68. package/dist/content-blocks/p-878dc806.js +10 -0
  69. package/dist/content-blocks/p-878dc806.js.map +1 -0
  70. package/dist/content-blocks/p-97c4ca9d.js +2 -0
  71. package/dist/content-blocks/p-97c4ca9d.js.map +1 -0
  72. package/dist/content-blocks/{p-271fb304.entry.js → p-cbc1dd73.entry.js} +2 -2
  73. package/dist/content-blocks/p-cbc1dd73.entry.js.map +1 -0
  74. package/dist/content-blocks/p-cfb4593f.js.map +1 -1
  75. package/dist/content-blocks/p-e2907508.js +2 -0
  76. package/dist/content-blocks/p-e2907508.js.map +1 -0
  77. package/dist/content-blocks/p-ef45f146.entry.js +2 -0
  78. package/dist/content-blocks/p-ef45f146.entry.js.map +1 -0
  79. package/dist/esm/content-accordion_11.entry.js +45 -1545
  80. package/dist/esm/content-accordion_11.entry.js.map +1 -1
  81. package/dist/esm/content-blocks.js +1 -1
  82. package/dist/esm/content-carousel.entry.js +6 -5
  83. package/dist/esm/content-carousel.entry.js.map +1 -1
  84. package/dist/esm/content-navigation-block.entry.js +41 -24
  85. package/dist/esm/content-navigation-block.entry.js.map +1 -1
  86. package/dist/esm/focus-trap.esm-49c9613c.js +1507 -0
  87. package/dist/esm/focus-trap.esm-49c9613c.js.map +1 -0
  88. package/dist/esm/index-d9f353de.js +5200 -0
  89. package/dist/esm/index-d9f353de.js.map +1 -0
  90. package/dist/esm/loader.js +1 -1
  91. package/dist/esm/{swiper-3e7be625.js → swiper-3394f7fd.js} +2 -403
  92. package/dist/esm/swiper-3394f7fd.js.map +1 -0
  93. package/dist/esm/utils-075121ec.js +433 -0
  94. package/dist/esm/utils-075121ec.js.map +1 -0
  95. package/dist/esm/window-resize-service-f40ec51c.js.map +1 -1
  96. package/dist/types/components/content-carousel/content-carousel.d.ts +3 -3
  97. package/dist/types/components/content-navigation-block/content-navigation-block.d.ts +11 -0
  98. package/dist/types/components/content-overlay/content-overlay.d.ts +9 -0
  99. package/dist/types/components.d.ts +34 -2
  100. package/dist/types/formatters/content-grid-formatter/content-grid-formatter.d.ts +8 -1
  101. package/dist/types/formatters/content-spacer/content-spacer.d.ts +2 -1
  102. package/dist/types/stories/ContentNavigationBlock.stories.d.ts +1 -3
  103. package/dist/types/stories/ContentTextBlock.stories.d.ts +1 -7
  104. package/package.json +2 -2
  105. package/dist/cjs/swiper-4fade542.js.map +0 -1
  106. package/dist/content-blocks/p-10819bfa.js +0 -2
  107. package/dist/content-blocks/p-10819bfa.js.map +0 -1
  108. package/dist/content-blocks/p-24657e66.entry.js +0 -10
  109. package/dist/content-blocks/p-24657e66.entry.js.map +0 -1
  110. package/dist/content-blocks/p-271fb304.entry.js.map +0 -1
  111. package/dist/content-blocks/p-6a177aef.entry.js +0 -2
  112. package/dist/content-blocks/p-6a177aef.entry.js.map +0 -1
  113. package/dist/esm/swiper-3e7be625.js.map +0 -1
@@ -6,44 +6,86 @@ body.content-navigation-block-open {
6
6
  overflow: hidden;
7
7
  }
8
8
 
9
+ content-navigation-block button {
10
+ appearance: none;
11
+ border: none;
12
+ background: transparent;
13
+ cursor: pointer;
14
+ }
15
+ content-navigation-block .content-navigation-block__skip-content a, content-navigation-block .content-navigation-block__skip-content button, content-navigation-block .content-navigation-block__skip-content a:visited, content-navigation-block .content-navigation-block__skip-content button:visited {
16
+ border: 2px solid rgb(0, 0, 0);
17
+ border-radius: 2px;
18
+ color: purple;
19
+ cursor: pointer;
20
+ display: inline-block;
21
+ font-size: 14px;
22
+ line-height: 20px;
23
+ margin: 6px 11px;
24
+ min-height: 32px;
25
+ text-decoration: underline;
26
+ text-align: center;
27
+ width: 106px;
28
+ z-index: 1000;
29
+ }
30
+ content-navigation-block .content-navigation-block__skip-content a:not(:focus), content-navigation-block .content-navigation-block__skip-content button:not(:focus), content-navigation-block .content-navigation-block__skip-content a:visited:not(:focus), content-navigation-block .content-navigation-block__skip-content button:visited:not(:focus) {
31
+ position: absolute;
32
+ clip: rect(1px, 1px, 1px, 1px);
33
+ overflow: hidden;
34
+ padding: 0;
35
+ }
36
+ content-navigation-block svg.default-icon {
37
+ display: inline-block;
38
+ width: 32px;
39
+ }
9
40
  content-navigation-block[hamburger=fixed], content-navigation-block[hamburger=absolute], content-navigation-block[hamburger=static] {
10
41
  display: inline-block;
11
42
  }
12
- content-navigation-block[hamburger=fixed][aria-expanded=false] [slot=closeButton], content-navigation-block[hamburger=absolute][aria-expanded=false] [slot=closeButton], content-navigation-block[hamburger=static][aria-expanded=false] [slot=closeButton] {
43
+ content-navigation-block[hamburger=fixed][aria-expanded=false] .content-navigation__close, content-navigation-block[hamburger=absolute][aria-expanded=false] .content-navigation__close, content-navigation-block[hamburger=static][aria-expanded=false] .content-navigation__close {
13
44
  display: none;
14
45
  }
15
- content-navigation-block[hamburger=fixed] [slot=openButton],
16
- content-navigation-block[hamburger=fixed] [slot=closeButton], content-navigation-block[hamburger=absolute] [slot=openButton],
17
- content-navigation-block[hamburger=absolute] [slot=closeButton], content-navigation-block[hamburger=static] [slot=openButton],
18
- content-navigation-block[hamburger=static] [slot=closeButton] {
46
+ content-navigation-block[hamburger=fixed] .content-navigation__open,
47
+ content-navigation-block[hamburger=fixed] .content-navigation__close, content-navigation-block[hamburger=absolute] .content-navigation__open,
48
+ content-navigation-block[hamburger=absolute] .content-navigation__close, content-navigation-block[hamburger=static] .content-navigation__open,
49
+ content-navigation-block[hamburger=static] .content-navigation__close {
19
50
  cursor: pointer;
20
51
  }
21
- content-navigation-block[hamburger=fixed] [slot=content], content-navigation-block[hamburger=absolute] [slot=content], content-navigation-block[hamburger=static] [slot=content] {
52
+ content-navigation-block[hamburger=fixed] .content-navigation__content-wrapper, content-navigation-block[hamburger=absolute] .content-navigation__content-wrapper, content-navigation-block[hamburger=static] .content-navigation__content-wrapper {
22
53
  display: none;
23
54
  background: white;
24
55
  }
25
- content-navigation-block[hamburger=fixed] [slot=content][hidden=false], content-navigation-block[hamburger=absolute] [slot=content][hidden=false], content-navigation-block[hamburger=static] [slot=content][hidden=false] {
56
+ content-navigation-block[hamburger=fixed] .content-navigation__content-wrapper[hidden=false], content-navigation-block[hamburger=absolute] .content-navigation__content-wrapper[hidden=false], content-navigation-block[hamburger=static] .content-navigation__content-wrapper[hidden=false] {
26
57
  display: block;
27
58
  }
28
- content-navigation-block[hamburger=fixed] [slot=content] {
59
+ content-navigation-block[hamburger=fixed] .content-navigation__content-wrapper {
29
60
  position: fixed;
30
61
  left: 0;
31
62
  top: 0;
32
63
  width: 100vw;
33
- height: 100%;
64
+ height: 100vh;
65
+ z-index: 100;
66
+ }
67
+ content-navigation-block[hamburger=sticky] .content-navigation__content-wrapper {
68
+ position: sticky;
69
+ left: 0;
70
+ top: 0;
71
+ width: 100vw;
72
+ height: 100vh;
34
73
  z-index: 100;
35
74
  }
36
- content-navigation-block[hamburger=absolute] [slot=content] {
75
+ content-navigation-block[hamburger=absolute] .content-navigation__content-wrapper {
37
76
  position: absolute;
38
77
  z-index: 100;
39
78
  }
40
- content-navigation-block[hamburger=static] [slot=content] {
79
+ content-navigation-block[hamburger=static] .content-navigation__content-wrapper {
41
80
  position: static;
42
81
  }
43
82
  content-navigation-block[hamburger=none] {
44
83
  display: block;
45
84
  }
46
- content-navigation-block[hamburger=none] [slot=openButton],
47
- content-navigation-block[hamburger=none] [slot=closeButton] {
85
+ content-navigation-block[hamburger=none] .content-navigation__open,
86
+ content-navigation-block[hamburger=none] .content-navigation__close {
48
87
  display: none;
88
+ }
89
+ content-navigation-block[aria-expanded=true] .content-navigation__content-wrapper {
90
+ display: block;
49
91
  }
@@ -1,8 +1,10 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { WindowResizeService } from "../../services/window-resize-service";
3
+ import { createFocusTrap } from "focus-trap";
3
4
  /**
4
5
  * @slot openButton - This slot will expand the navigation when clicked.
5
6
  * @slot closeButton - This slot will close the navigation when clicked.
7
+ * @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.
6
8
  * @slot content - Default slot
7
9
  */
8
10
  export class ContentNavigationBlock {
@@ -12,6 +14,12 @@ export class ContentNavigationBlock {
12
14
  this.classString = undefined;
13
15
  this.ariaExpanded = 'false';
14
16
  this.bodyToggle = false;
17
+ this.skipAccessibilityMessage = undefined;
18
+ this.hasOpenButton = false;
19
+ this.hasCloseButton = false;
20
+ this.openButton = undefined;
21
+ this.closeButton = undefined;
22
+ this.contentSlot = undefined;
15
23
  }
16
24
  componentWillLoad() {
17
25
  WindowResizeService.registerProp(this.hamburger).subscribe(newValue => {
@@ -24,33 +32,43 @@ export class ContentNavigationBlock {
24
32
  });
25
33
  }
26
34
  componentDidLoad() {
27
- let openButton = this.hostElement.querySelector('[slot="openButton"]');
28
- let closeButton = this.hostElement.querySelector('[slot="closeButton"]');
29
- let content = this.hostElement.querySelector('[slot="content"]');
30
- if (openButton) {
31
- openButton.onclick = () => {
32
- this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';
33
- content.setAttribute('hidden', this.ariaExpanded === 'false' ? 'true' : 'false');
34
- if (this.ariaExpanded === 'false') {
35
- document.body.classList.remove('content-navigation-block-open');
36
- }
37
- else if (this.bodyToggle) {
38
- document.body.classList.add('content-navigation-block-open');
39
- }
40
- setTimeout(() => closeButton.focus(), 1);
41
- };
35
+ this.hasOpenButton = !!this.hostElement.querySelector('[slot="openButton"]');
36
+ this.hasCloseButton = !!this.hostElement.querySelector('content-navigation-block-close');
37
+ this.openButton.onclick = () => {
38
+ this.openMenu();
39
+ };
40
+ this.closeButton.onclick = () => {
41
+ this.closeMenu();
42
+ };
43
+ }
44
+ openMenu() {
45
+ this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';
46
+ if (this.ariaExpanded === 'false') {
47
+ document.body.classList.remove('content-navigation-block-open');
42
48
  }
43
- if (closeButton) {
44
- closeButton.onclick = () => {
45
- this.ariaExpanded = 'false';
46
- content.setAttribute('hidden', 'true');
47
- document.body.classList.remove('content-navigation-block-open');
48
- setTimeout(() => openButton.focus(), 1);
49
- };
49
+ else if (this.bodyToggle) {
50
+ document.body.classList.add('content-navigation-block-open');
50
51
  }
52
+ this.focusTrap = createFocusTrap(this.contentSlot.parentElement, {
53
+ fallbackFocus: this.hostElement,
54
+ clickOutsideDeactivates: true,
55
+ onDeactivate: () => {
56
+ this.closeMenu();
57
+ },
58
+ });
59
+ setTimeout(() => this.closeButton.focus(), 1);
60
+ }
61
+ closeMenu() {
62
+ if (this.focusTrap) {
63
+ this.focusTrap.deactivate();
64
+ this.focusTrap = null;
65
+ }
66
+ this.ariaExpanded = 'false';
67
+ document.body.classList.remove('content-navigation-block-open');
68
+ setTimeout(() => this.openButton.focus(), 1);
51
69
  }
52
70
  render() {
53
- return (h(Host, { class: this.classString, "aria-expanded": this.ariaExpanded }, h("slot", { name: "openButton" }), h("slot", { name: "closeButton" }), h("div", { class: "content-navigation__menu" }, h("slot", { name: "content" }), h("slot", null))));
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: "closeButton" }), h("slot", { name: "content" }), h("slot", null)))));
54
72
  }
55
73
  static get is() { return "content-navigation-block"; }
56
74
  static get originalStyleUrls() {
@@ -94,6 +112,9 @@ export class ContentNavigationBlock {
94
112
  }, {
95
113
  "name": "options",
96
114
  "text": "absolute"
115
+ }, {
116
+ "name": "options",
117
+ "text": "sticky"
97
118
  }, {
98
119
  "name": "options",
99
120
  "text": "static"
@@ -142,7 +163,13 @@ export class ContentNavigationBlock {
142
163
  return {
143
164
  "classString": {},
144
165
  "ariaExpanded": {},
145
- "bodyToggle": {}
166
+ "bodyToggle": {},
167
+ "skipAccessibilityMessage": {},
168
+ "hasOpenButton": {},
169
+ "hasCloseButton": {},
170
+ "openButton": {},
171
+ "closeButton": {},
172
+ "contentSlot": {}
146
173
  };
147
174
  }
148
175
  static get elementRef() { return "hostElement"; }
@@ -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;AAG3E;;;;GAIG;AAMH,MAAM,OAAO,sBAAsB;;yBAaH,YAAY;;;4BAaV,OAAO;0BACR,KAAK;;IAEpC,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,C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G,GAAG,EAAE;gBACzB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;gBAC5B,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;gBACvC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC;gBAChE,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,IAAC,KAAK,EAAE,IAAI,CAAC,WAAW,mBAAiB,IAAI,CAAC,YAAY;YAC7D,YAAM,IAAI,EAAC,YAAY,GAAQ;YAC/B,YAAM,IAAI,EAAC,aAAa,GAAQ;YAChC,WAAK,KAAK,EAAC,0BAA0B;gBACnC,YAAM,IAAI,EAAC,SAAS,GAAQ;gBAC5B,eAAa,CACT,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';\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 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 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\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 let openButton = this.hostElement.querySelector('[slot=\"openButton\"]') as HTMLElement;\n let closeButton = this.hostElement.querySelector('[slot=\"closeButton\"]') as HTMLElement;\n let content = this.hostElement.querySelector('[slot=\"content\"]') as HTMLElement;\n if (openButton) {\n openButton.onclick = () => {\n this.ariaExpanded = this.ariaExpanded === 'true' ? 'false' : 'true';\n content.setAttribute('hidden', this.ariaExpanded === 'false' ? 'true' : 'false');\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 setTimeout(() => closeButton.focus(), 1);\n };\n }\n if (closeButton) {\n closeButton.onclick = () => {\n this.ariaExpanded = 'false';\n content.setAttribute('hidden', 'true');\n document.body.classList.remove('content-navigation-block-open');\n setTimeout(() => openButton.focus(), 1);\n };\n }\n }\n\n render() {\n return (\n <Host class={this.classString} aria-expanded={this.ariaExpanded}>\n <slot name=\"openButton\"></slot>\n <slot name=\"closeButton\"></slot>\n <div class=\"content-navigation__menu\">\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
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;A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il/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"]}
@@ -64,22 +64,21 @@ content-overlay .content-overlay__close {
64
64
  border: none;
65
65
  min-width: 16px;
66
66
  }
67
- content-overlay.content-overlay--fullscreen .content-overlay-background {
67
+ content-overlay[position=fixed] .content-overlay-background {
68
68
  position: fixed;
69
69
  }
70
- content-overlay.content-overlay--absolute {
70
+ content-overlay[position=absolute] {
71
71
  position: absolute;
72
72
  box-sizing: border-box;
73
73
  z-index: 100000;
74
74
  height: 100%;
75
75
  width: 100%;
76
- top: 0;
77
76
  left: 0;
78
77
  }
79
- content-overlay.content-overlay--absolute .content-overlay-background {
80
- position: absolute;
78
+ content-overlay[position=absolute] .content-overlay-background {
79
+ position: static;
81
80
  }
82
- content-overlay.content-overlay--absolute .content-overlay__content, content-overlay.content-overlay--fullscreen .content-overlay__content {
81
+ content-overlay[position=absolute] .content-overlay__content, content-overlay[position=fixed] .content-overlay__content {
83
82
  flex: 1;
84
83
  overflow: hidden;
85
84
  }
@@ -92,6 +91,12 @@ content-overlay [role=dialog] {
92
91
  content-overlay [role=dialog].hidden {
93
92
  display: none;
94
93
  }
94
+ content-overlay[full-screen=true] {
95
+ height: 100%;
96
+ }
97
+ content-overlay[full-screen=true] .content-overlay-background {
98
+ height: 100%;
99
+ }
95
100
 
96
101
  /* this is added to the body when a dialog is open */
97
102
  body.has-dialog {
@@ -17,6 +17,7 @@ export class ContentOverlay {
17
17
  this.horizontal = 'center';
18
18
  this.vertical = 'center';
19
19
  this.closeTitle = 'Close Overlay';
20
+ this.position = 'fixed';
20
21
  this.isActive = false;
21
22
  this.activeClass = '';
22
23
  this.classString = '';
@@ -27,6 +28,7 @@ export class ContentOverlay {
27
28
  }
28
29
  onContentBlockActivated(event) {
29
30
  if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {
31
+ console.log('activate');
30
32
  event.preventDefault();
31
33
  if (!this.isActive) {
32
34
  this.openOverlay();
@@ -37,37 +39,36 @@ export class ContentOverlay {
37
39
  }
38
40
  }
39
41
  async openOverlay() {
40
- // if (this.isActive) {
41
- // return false;
42
- // }
43
42
  this.isActive = true;
44
43
  if (!this.originalMarkup) {
45
- this.originalMarkup = this.contentSlot.querySelector('[slot="content"]').innerHTML;
44
+ this.originalMarkup = this.contentSlot.innerHTML;
46
45
  }
47
46
  if (this.target) {
48
- let targetElement = document.getElementById(this.target);
47
+ let targetElement = document.querySelector(this.target);
49
48
  if (targetElement) {
50
49
  targetElement.classList.add('content-block-overlay-container');
51
50
  targetElement.appendChild(this.hostElement);
52
51
  }
52
+ // } else if (this.isFullScreen) {
53
+ // if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {
54
+ // document.body.appendChild(this.hostElement);
55
+ // }
53
56
  }
54
- else if (this.isFullScreen) {
55
- if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {
56
- document.body.appendChild(this.hostElement);
57
- }
58
- }
59
- if (this.contentSlot) {
57
+ if (this.originalMarkup) {
60
58
  this.contentSlot.innerHTML = this.originalMarkup;
61
- this.setComputedActiveClass();
62
- if (this.isFullScreen) {
63
- this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {
64
- fallbackFocus: this.hostElement,
65
- onDeactivate: () => {
66
- this.isActive = false;
67
- this.setComputedActiveClass();
68
- },
69
- });
59
+ if (this.contentSlot.children[0] === this.contentSlot.querySelector('script[slot="content"][type="text/template"]')) {
60
+ this.contentSlot.innerHTML = this.contentSlot.children[0].innerHTML;
70
61
  }
62
+ this.setComputedActiveClass();
63
+ this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {
64
+ fallbackFocus: this.hostElement,
65
+ allowOutsideClick: true,
66
+ clickOutsideDeactivates: true,
67
+ onDeactivate: () => {
68
+ this.isActive = false;
69
+ this.setComputedActiveClass();
70
+ },
71
+ });
71
72
  }
72
73
  this.contentOverlayActivated.emit(this.hostElement);
73
74
  }
@@ -85,23 +86,16 @@ export class ContentOverlay {
85
86
  }
86
87
  }
87
88
  setComputedActiveClass() {
88
- let positioningValue = 'static';
89
- if (this.target) {
90
- positioningValue = 'absolute';
91
- }
92
- if (this.isFullScreen) {
93
- positioningValue = 'fullscreen';
94
- }
95
- this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${positioningValue}`;
89
+ this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${this.position}`;
96
90
  }
97
91
  componentWillLoad() {
98
- this.contentElement = this.hostElement.querySelector('.js-content-overlay-content');
99
92
  WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));
93
+ WindowResizeService.registerProp(this.position).subscribe(newValue => (this.position = newValue));
100
94
  WindowResizeService.registerProp(this.horizontal).subscribe(newValue => this.hostElement.setAttribute('horizontal', newValue));
101
95
  WindowResizeService.registerProp(this.vertical).subscribe(newValue => this.hostElement.setAttribute('vertical', newValue));
102
96
  WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {
103
- if (!this.target)
104
- this.isFullScreen = newValue === 'true';
97
+ this.fullScreen = newValue;
98
+ this.isFullScreen = newValue === 'true';
105
99
  });
106
100
  WindowResizeService.registerProp(this.open).subscribe(newValue => {
107
101
  this.hostElement.setAttribute('open', newValue);
@@ -113,7 +107,9 @@ export class ContentOverlay {
113
107
  this.closeOverlay();
114
108
  }
115
109
  render() {
116
- return (h(Host, { class: `${this.activeClass} ${this.classString}` }, h("div", { class: "content-block-overlay-container" }, h("div", { class: `content-overlay-background ${this.isActive ? 'active' : ''}` }, h("div", { ref: element => (this.dialogElement = element), role: "dialog", "aria-modal": "true", class: this.isActive ? 'active' : 'hidden', "aria-expanded": this.isActive }, h("div", { class: "content-overlay__header" }, h("button", { onClick: e => this.closeOverlayButtonClicked(e), class: "content-overlay__close", title: this.closeTitle }, !this.hasCloseButton && (h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "16", height: "16", 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("slot", { name: "header" })), h("div", { class: "content-overlay__content", ref: (el) => (this.contentSlot = el) }, h("slot", { name: "content" })))))));
110
+ return (h(Host, { class: `${this.activeClass} ${this.classString}`, position: this.position }, h("div", { class: "content-block-overlay-container" }, h("div", { class: `content-overlay-background ${this.isActive ? 'active' : ''}` }, h("div", { ref: element => (this.dialogElement = element), role: "dialog", "aria-modal": "true", class: this.isActive ? 'active' : 'hidden', "aria-expanded": this.isActive }, h("div", { class: "content-overlay__header" }, h("button", { onClick: e => {
111
+ this.closeOverlayButtonClicked(e);
112
+ }, class: "content-overlay__close", title: this.closeTitle }, !this.hasCloseButton && (h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "16", height: "16", 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("slot", { name: "header" })), h("div", { class: "content-overlay__content", ref: (el) => (this.contentSlot = el) }, h("slot", { name: "content" }), h("slot", null)))))));
117
113
  }
118
114
  componentDidRender() {
119
115
  if (this.open === 'true') {
@@ -196,7 +192,7 @@ export class ContentOverlay {
196
192
  },
197
193
  "fullScreen": {
198
194
  "type": "string",
199
- "mutable": false,
195
+ "mutable": true,
200
196
  "complexType": {
201
197
  "original": "ResponsiveBoolean",
202
198
  "resolved": "string",
@@ -221,7 +217,7 @@ export class ContentOverlay {
221
217
  "text": ""
222
218
  },
223
219
  "attribute": "full-screen",
224
- "reflect": false,
220
+ "reflect": true,
225
221
  "defaultValue": "'true'"
226
222
  },
227
223
  "classes": {
@@ -351,6 +347,45 @@ export class ContentOverlay {
351
347
  "attribute": "close-title",
352
348
  "reflect": false,
353
349
  "defaultValue": "'Close Overlay'"
350
+ },
351
+ "position": {
352
+ "type": "string",
353
+ "mutable": true,
354
+ "complexType": {
355
+ "original": "ResponsiveString",
356
+ "resolved": "string",
357
+ "references": {
358
+ "ResponsiveString": {
359
+ "location": "import",
360
+ "path": "../../typings",
361
+ "id": "src/typings.d.ts::ResponsiveString"
362
+ }
363
+ }
364
+ },
365
+ "required": false,
366
+ "optional": false,
367
+ "docs": {
368
+ "tags": [{
369
+ "name": "type",
370
+ "text": "Select"
371
+ }, {
372
+ "name": "options",
373
+ "text": "absolute"
374
+ }, {
375
+ "name": "options",
376
+ "text": "fixed"
377
+ }, {
378
+ "name": "options",
379
+ "text": "static"
380
+ }, {
381
+ "name": "options",
382
+ "text": "sticky"
383
+ }],
384
+ "text": "Position of the overlay."
385
+ },
386
+ "attribute": "position",
387
+ "reflect": true,
388
+ "defaultValue": "'fixed'"
354
389
  }
355
390
  };
356
391
  }
@@ -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,EAAS,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAG3E,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC;;;;GAIG;AAMH,MAAM,OAAO,cAAc;;;oBAgBC,OAAO;0BAKO,MAAM;;0BAmBJ,QAAQ;wBAYZ,QAAQ;0BAMjB,eAAe;wBAEf,KAAK;2BACH,EAAE;2BACF,EAAE;;4BAWA,KAAK;8BACH,KAAK;;;IAKxC,uBAAuB,CAAC,KAAkB;QACxC,IAAI,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5E,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,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CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,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, Watch } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ContentLineTextAlignOptions, ContentVerticalAlignments, ResponsiveBoolean, ResponsiveString } from '../../typings';\nimport { getCurrentValue } from '../../utils/utils';\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() 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 @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('contentBlockActivated')\n onContentBlockActivated(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\n @Method()\n async openOverlay() {\n // if (this.isActive) {\n // return false;\n // }\n this.isActive = true;\n if (!this.originalMarkup) {\n this.originalMarkup = this.contentSlot.querySelector('[slot=\"content\"]').innerHTML;\n }\n if (this.target) {\n let targetElement = document.getElementById(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 if (this.contentSlot) {\n this.contentSlot.innerHTML = this.originalMarkup;\n this.setComputedActiveClass();\n if (this.isFullScreen) {\n this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {\n fallbackFocus: this.hostElement,\n onDeactivate: () => {\n this.isActive = false;\n this.setComputedActiveClass();\n },\n });\n }\n }\n this.contentOverlayActivated.emit(this.hostElement);\n }\n\n @Method()\n async closeOverlay() {\n this.contentSlot.innerHTML = '';\n this.isActive = false;\n this.activeClass = '';\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n setComputedActiveClass() {\n let positioningValue = 'static';\n if (this.target) {\n positioningValue = 'absolute';\n }\n if (this.isFullScreen) {\n positioningValue = 'fullscreen';\n }\n this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${positioningValue}`;\n }\n\n componentWillLoad() {\n this.contentElement = this.hostElement.querySelector('.js-content-overlay-content');\n\n WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));\n\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 if (!this.target) 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}`}>\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 onClick={e => this.closeOverlayButtonClicked(e)} class=\"content-overlay__close\" title={this.closeTitle}>\n {!this.hasCloseButton && (\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" width=\"16\" height=\"16\" 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 </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,yBAAyB,CAAC;AACjC;;;;GAIG;AAMH,MAAM,OAAO,cAAc;;;oBAgBC,OAAO;0BASD,MAAM;;0BAmBI,QAAQ;wBAYZ,QAAQ;0BAMjB,eAAe;wBAaf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AAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;4BACxF,YAAM,IAAI,EAAC,SAAS,GAAQ;4BAC5B,eAAa,CACT,CACF,CACF,CACF,CACD,CACR,CAAC;IACJ,CAAC;IAED,kBAAkB;QAChB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,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('contentBlockActivated')\n onContentBlockActivated(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n console.log('activate');\n event.preventDefault();\n if (!this.isActive) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n }\n }\n\n @Method()\n async openOverlay() {\n this.isActive = true;\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 this.setComputedActiveClass();\n },\n });\n }\n this.contentOverlayActivated.emit(this.hostElement);\n }\n\n @Method()\n async closeOverlay() {\n this.contentSlot.innerHTML = '';\n this.isActive = false;\n this.activeClass = '';\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\" width=\"16\" height=\"16\" 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"]}
@@ -62,9 +62,9 @@ export class ContentImage {
62
62
  });
63
63
  }, {
64
64
  root: null,
65
- // rootMargin: `${Math.max(100, window.innerHeight * 0.95)}px`,
66
- rootMargin: `0px`,
67
- threshold: 0.1,
65
+ rootMargin: `${Math.max(100, window.innerHeight * 1)}px`,
66
+ // rootMargin: `0px`,
67
+ threshold: 0,
68
68
  });
69
69
  observer.observe(this.hostElement);
70
70
  }
@@ -82,7 +82,7 @@ export class ContentImage {
82
82
  }
83
83
  }
84
84
  render() {
85
- return (h(Host, { class: `${this.activeLazyLoadClass} ${this.classString}`, style: this.inlineStyle, content: this.showContent }, this.hasMediaContent && (h("div", { class: "content-image__media-content" }, h("slot", { name: "mediaContent" }))), this.showVideoAsGif ? (h("video", { autoplay: true, muted: true, loop: true, preload: "none", playsinline: true, width: this.width, height: this.height }, h("source", { src: this.lazyLoadIsComplete ? this.pictureImageSrc : null, type: this.videoType }))) : (h("img", { width: this.width, height: this.height, src: this.pictureImageSrc, alt: this.alt }))));
85
+ return (h(Host, { class: `${this.activeLazyLoadClass} ${this.classString}`, style: this.inlineStyle, content: this.showContent }, this.hasMediaContent && (h("div", { class: "content-image__media-content" }, h("slot", { name: "mediaContent" }))), this.showVideoAsGif && (h("video", { autoplay: true, muted: true, loop: true, preload: "none", playsinline: true, width: this.width, height: this.height }, h("source", { src: this.lazyLoadIsComplete ? this.pictureImageSrc : null, type: this.videoType }))), this.pictureImageSrc && !this.showVideoAsGif && h("img", { width: this.width, height: this.height, src: this.pictureImageSrc, alt: this.alt })));
86
86
  }
87
87
  static get is() { return "content-image"; }
88
88
  static get originalStyleUrls() {
@@ -1 +1 @@
1
- {"version":3,"file":"content-image.js","sourceRoot":"","sources":["../../../../src/elements/content-image/content-image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAoB,eAAe,EAAmB,MAAM,mBAAmB,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Element, Prop, State, Watch } from '@stencil/core';\nimport { HostElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveBoolean, ResponsiveNumber, ResponsiveString } from '../../typings';\nimport { breakpointValues, getCurrentValue, getValueAtIndex } from '../../utils/utils';\n\n/**\n * @slot mediaContent - Content displayed over media. If you want to reveal content on hover, use a tout block\n */\n@Component({\n tag: 'content-image',\n styleUrl: 'content-image.scss',\n shadow: false,\n})\nexport class ContentImage {\n @Element() hostElement: HostElement;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n /**\n * @type Boolean\n */\n @Prop() lazyLoad: boolean = true;\n /**\n * @type Media\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n src!: ResponsiveString;\n @State() activeSrc;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n alt: ResponsiveString;\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n width: ResponsiveNumber = '16';\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n height: ResponsiveNumber = '9';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n aspectRatio: ResponsiveString;\n /**\n * @type Select\n * @options image\n * @options video\n */\n @Prop() type?: 'image' | 'video' = 'image';\n\n /**\n * @type Select\n * @options video/mp4\n */\n @Prop() videoType?: string = 'video/mp4';\n\n /**\n * If true, the content in the mediaContent slot will be visible.\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n showContent: ResponsiveBoolean = 'false|true';\n\n @State() lazyLoadIsComplete: boolean = false;\n @State() showVideoAsGif: boolean = false;\n @State() activeLazyLoadClass = '';\n @State() classString = '';\n @State() inlineStyle?: { [key: string]: string } = {};\n @State() hasMediaContent: boolean = false;\n @State() pictureImageSrc: string;\n preloadImage(src) {\n return new Promise(r => {\n const image = new Image();\n image.onload = r;\n image.onerror = r;\n image.src = src;\n });\n }\n\n componentWillLoad() {\n this.hasMediaContent = !!this.hostElement.querySelector('[slot=\"mediaContent\"]');\n WindowResizeService.registerProp(this.aspectRatio).subscribe(newValue => {\n this.inlineStyle = { ...this.inlineStyle, '--aspect-ratio': `${newValue}` };\n });\n WindowResizeService.registerProp(this.alt).subscribe(newValue => {\n this.alt = newValue as string;\n });\n WindowResizeService.registerProp(this.height).subscribe(newValue => {\n this.height = newValue as string;\n });\n WindowResizeService.registerProp(this.showContent).subscribe(newValue => {\n this.showContent = newValue as string;\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = `${newValue}`;\n });\n }\n\n componentDidLoad() {\n let observer = new IntersectionObserver(\n entries => {\n entries.forEach(async entry => {\n if (entry.isIntersecting) {\n this.lazyLoadIsComplete = true;\n this.pictureImageSrc = getCurrentValue(this.src);\n this.showVideoAsGif = this.pictureImageSrc.indexOf('.mp4') >= 0 || getCurrentValue(this.type) === 'video';\n }\n });\n },\n {\n root: null,\n // rootMargin: `${Math.max(100, window.innerHeight * 0.95)}px`,\n rootMargin: `0px`,\n threshold: 0.1,\n },\n );\n observer.observe(this.hostElement);\n }\n\n @Watch('lazyLoadIsComplete')\n watchLazyLoadIsComplete(newValue: boolean) {\n if (newValue === true) {\n this.activeLazyLoadClass = 'content-image-loaded';\n } else {\n if (!this.lazyLoad) {\n this.activeLazyLoadClass = 'content-image-no-lazyload';\n } else {\n this.activeLazyLoadClass = 'content-image-loading';\n }\n }\n }\n\n render() {\n return (\n <Host class={`${this.activeLazyLoadClass} ${this.classString}`} style={this.inlineStyle} content={this.showContent}>\n {this.hasMediaContent && (\n <div class=\"content-image__media-content\">\n <slot name=\"mediaContent\"></slot>\n </div>\n )}\n {this.showVideoAsGif ? (\n <video autoplay muted loop preload=\"none\" playsinline width={this.width} height={this.height}>\n <source src={this.lazyLoadIsComplete ? this.pictureImageSrc : null} type={this.videoType} />\n </video>\n ) : (\n <img width={this.width} height={this.height} src={this.pictureImageSrc} alt={this.alt} />\n )}\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"content-image.js","sourceRoot":"","sources":["../../../../src/elements/content-image/content-image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAoB,eAAe,EAAmB,MAAM,mBAAmB,CAAC;AAEvF;;GAEG;AAMH,MAAM,OAAO,YAAY;;;wBAcK,IAAI;;;;qBA4BN,IAAI;sBASH,GAAG;;oBAgBK,OAAO;yBAMb,WAAW;2BAWP,YAAY;kCAEN,KAAK;8BACT,KAAK;mCACT,EAAE;2BACV,EAAE;2BAC0B,EAAE;+BACjB,KAAK;;;IAEzC,YAAY,CAAC,GAAG;QACd,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;YACrB,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;YAC1B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YACjB,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;YAClB,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;QACjF,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YACtE,IAAI,CAAC,WAAW,mCAAQ,IAAI,CAAC,WAAW,KAAE,gBAAgB,EAAE,GAAG,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I,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,WAAK,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,GAAI,CACrI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Element, Prop, State, Watch } from '@stencil/core';\nimport { HostElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveBoolean, ResponsiveNumber, ResponsiveString } from '../../typings';\nimport { breakpointValues, getCurrentValue, getValueAtIndex } from '../../utils/utils';\n\n/**\n * @slot mediaContent - Content displayed over media. If you want to reveal content on hover, use a tout block\n */\n@Component({\n tag: 'content-image',\n styleUrl: 'content-image.scss',\n shadow: false,\n})\nexport class ContentImage {\n @Element() hostElement: HostElement;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n /**\n * @type Boolean\n */\n @Prop() lazyLoad: boolean = true;\n /**\n * @type Media\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n src!: ResponsiveString;\n @State() activeSrc;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n alt: ResponsiveString;\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n width: ResponsiveNumber = '16';\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n height: ResponsiveNumber = '9';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n aspectRatio: ResponsiveString;\n /**\n * @type Select\n * @options image\n * @options video\n */\n @Prop() type?: 'image' | 'video' = 'image';\n\n /**\n * @type Select\n * @options video/mp4\n */\n @Prop() videoType?: string = 'video/mp4';\n\n /**\n * If true, the content in the mediaContent slot will be visible.\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n showContent: ResponsiveBoolean = 'false|true';\n\n @State() lazyLoadIsComplete: boolean = false;\n @State() showVideoAsGif: boolean = false;\n @State() activeLazyLoadClass = '';\n @State() classString = '';\n @State() inlineStyle?: { [key: string]: string } = {};\n @State() hasMediaContent: boolean = false;\n @State() pictureImageSrc: string;\n preloadImage(src) {\n return new Promise(r => {\n const image = new Image();\n image.onload = r;\n image.onerror = r;\n image.src = src;\n });\n }\n\n componentWillLoad() {\n this.hasMediaContent = !!this.hostElement.querySelector('[slot=\"mediaContent\"]');\n WindowResizeService.registerProp(this.aspectRatio).subscribe(newValue => {\n this.inlineStyle = { ...this.inlineStyle, '--aspect-ratio': `${newValue}` };\n });\n WindowResizeService.registerProp(this.alt).subscribe(newValue => {\n this.alt = newValue as string;\n });\n WindowResizeService.registerProp(this.height).subscribe(newValue => {\n this.height = newValue as string;\n });\n WindowResizeService.registerProp(this.showContent).subscribe(newValue => {\n this.showContent = newValue as string;\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = `${newValue}`;\n });\n }\n\n componentDidLoad() {\n let observer = new IntersectionObserver(\n entries => {\n entries.forEach(async entry => {\n if (entry.isIntersecting) {\n this.lazyLoadIsComplete = true;\n this.pictureImageSrc = getCurrentValue(this.src);\n this.showVideoAsGif = this.pictureImageSrc.indexOf('.mp4') >= 0 || getCurrentValue(this.type) === 'video';\n }\n });\n },\n {\n root: null,\n rootMargin: `${Math.max(100, window.innerHeight * 1)}px`,\n // rootMargin: `0px`,\n threshold: 0,\n },\n );\n observer.observe(this.hostElement);\n }\n\n @Watch('lazyLoadIsComplete')\n watchLazyLoadIsComplete(newValue: boolean) {\n if (newValue === true) {\n this.activeLazyLoadClass = 'content-image-loaded';\n } else {\n if (!this.lazyLoad) {\n this.activeLazyLoadClass = 'content-image-no-lazyload';\n } else {\n this.activeLazyLoadClass = 'content-image-loading';\n }\n }\n }\n\n render() {\n return (\n <Host class={`${this.activeLazyLoadClass} ${this.classString}`} style={this.inlineStyle} content={this.showContent}>\n {this.hasMediaContent && (\n <div class=\"content-image__media-content\">\n <slot name=\"mediaContent\"></slot>\n </div>\n )}\n {this.showVideoAsGif && (\n <video autoplay muted loop preload=\"none\" playsinline width={this.width} height={this.height}>\n <source src={this.lazyLoadIsComplete ? this.pictureImageSrc : null} type={this.videoType} />\n </video>\n )}\n {this.pictureImageSrc && !this.showVideoAsGif && <img width={this.width} height={this.height} src={this.pictureImageSrc} alt={this.alt} />}\n </Host>\n );\n }\n}\n"]}