@newlogic-digital/ui 3.0.3 → 3.2.0

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 (120) hide show
  1. package/README.md +20 -22
  2. package/package.json +25 -14
  3. package/src/{main.json → data/main.json} +13 -11
  4. package/src/emails/email.css +3 -3
  5. package/src/emails/email.twig +1 -1
  6. package/src/icons.svg +32 -0
  7. package/src/scripts/Components/+.js +1 -2
  8. package/src/scripts/Components/CookieConsent.js +68 -64
  9. package/src/scripts/Layout/+.js +2 -1
  10. package/src/scripts/Layout/Header.js +18 -0
  11. package/src/scripts/Layout/Main.js +49 -45
  12. package/src/scripts/Libraries/+.js +13 -10
  13. package/src/scripts/Libraries/Anchor.js +18 -43
  14. package/src/scripts/Libraries/CookieConsent.js +42 -57
  15. package/src/scripts/Libraries/Dialog.js +56 -55
  16. package/src/scripts/Libraries/Drawer.js +23 -23
  17. package/src/scripts/Libraries/Form.js +37 -0
  18. package/src/scripts/Libraries/NativeSlider.js +86 -86
  19. package/src/scripts/Libraries/ReCaptcha.js +20 -18
  20. package/src/scripts/Libraries/Ripple.js +16 -32
  21. package/src/scripts/Libraries/Script.js +19 -0
  22. package/src/scripts/Libraries/Stimulus.js +30 -34
  23. package/src/scripts/Libraries/Swup.js +45 -55
  24. package/src/scripts/Libraries/Tabs.js +12 -18
  25. package/src/scripts/Libraries/Tippy.js +118 -0
  26. package/src/scripts/Ui/+.js +5 -3
  27. package/src/scripts/Ui/Checkbox.js +19 -0
  28. package/src/scripts/Ui/Input.js +188 -161
  29. package/src/scripts/Ui/Radio.js +23 -0
  30. package/src/scripts/Ui/Select.js +64 -37
  31. package/src/scripts/Ui/Text.js +25 -0
  32. package/src/scripts/Utils/+.js +3 -0
  33. package/src/scripts/Utils/Functions/+.js +6 -6
  34. package/src/scripts/Utils/Functions/dataValue.js +28 -25
  35. package/src/scripts/Utils/Functions/importScript.js +9 -11
  36. package/src/scripts/Utils/Functions/importStyle.js +18 -5
  37. package/src/scripts/Utils/Functions/inView.js +19 -21
  38. package/src/scripts/Utils/Functions/loadStimulus.js +22 -20
  39. package/src/scripts/Utils/Functions/replaceTag.js +12 -0
  40. package/src/scripts/Utils/cdn.js +6 -4
  41. package/src/scripts/Utils/global.js +10 -33
  42. package/src/scripts/main.js +6 -6
  43. package/src/styles/Components/CookieConsent.css +40 -179
  44. package/src/styles/Components/Dialog/Default.css +12 -15
  45. package/src/styles/Components/Form/CookieConsent.css +7 -12
  46. package/src/styles/Layout/+.css +2 -0
  47. package/src/styles/Layout/Header.css +54 -0
  48. package/src/styles/Layout/Main.css +28 -63
  49. package/src/styles/Layout/Nav.css +43 -0
  50. package/src/styles/Libraries/+.css +1 -1
  51. package/src/styles/Libraries/Datepicker.css +85 -39
  52. package/src/styles/Libraries/Dialog.css +6 -5
  53. package/src/styles/Libraries/Drawer.css +15 -14
  54. package/src/styles/Libraries/Hint.css +29 -23
  55. package/src/styles/Libraries/Lazysizes.css +2 -1
  56. package/src/styles/Libraries/NativeSlider.css +19 -18
  57. package/src/styles/Libraries/Ripple.css +8 -5
  58. package/src/styles/Libraries/Tabs.css +4 -4
  59. package/src/styles/Libraries/Tippy.css +87 -0
  60. package/src/styles/Ui/+.css +5 -1
  61. package/src/styles/Ui/Badge.css +33 -19
  62. package/src/styles/Ui/Btn.css +80 -53
  63. package/src/styles/Ui/Checkbox.css +80 -41
  64. package/src/styles/Ui/Dropdown.css +5 -0
  65. package/src/styles/Ui/Heading.css +12 -12
  66. package/src/styles/Ui/Icon.css +27 -8
  67. package/src/styles/Ui/Image.css +23 -0
  68. package/src/styles/Ui/Input.css +295 -220
  69. package/src/styles/Ui/Label.css +14 -0
  70. package/src/styles/Ui/Link.css +3 -3
  71. package/src/styles/Ui/Notice.css +14 -16
  72. package/src/styles/Ui/Progress.css +10 -21
  73. package/src/styles/Ui/Radio.css +3 -8
  74. package/src/styles/Ui/Select.css +63 -112
  75. package/src/styles/Ui/Switch.css +70 -0
  76. package/src/styles/Ui/{Wsw.css → Text.css} +61 -80
  77. package/src/styles/Ui/Title.css +8 -4
  78. package/src/styles/Utils/+.css +9 -0
  79. package/src/styles/Utils/default.css +75 -67
  80. package/src/styles/Utils/icons.css +9 -0
  81. package/src/styles/Utils/keyframes.css +182 -0
  82. package/src/styles/Utils/normalize.css +223 -0
  83. package/src/styles/Utils/print.css +1 -1
  84. package/src/styles/Utils/tailwind/+.css +2 -0
  85. package/src/styles/Utils/tailwind/base.css +15 -0
  86. package/src/styles/Utils/tailwind/gutters.css +264 -263
  87. package/src/styles/Utils/theme/+.css +1 -0
  88. package/src/styles/Utils/theme/main.css +24 -21
  89. package/src/styles/Utils/vars.css +58 -35
  90. package/src/styles/Utils/vendor.css +1 -2
  91. package/src/styles/main.css +8 -3
  92. package/src/templates/Components/CookieConsent.twig +30 -0
  93. package/src/templates/Components/Dialogs/Basic.twig +7 -3
  94. package/src/templates/Layout/Header.twig +42 -0
  95. package/src/templates/Layout/Main.twig +52 -67
  96. package/src/templates/Sections/Gdpr.twig +64 -0
  97. package/src/templates/Sections/Ui.twig +2093 -0
  98. package/src/views/dialog-basic.json.twig +3 -0
  99. package/src/views/gdpr.json +11 -0
  100. package/src/views/index.json +12 -0
  101. package/src/views/json-tippy.json.twig +16 -0
  102. package/src/views/ui.json +11 -0
  103. package/vite.config.js +6 -0
  104. package/CHANGELOG +0 -231
  105. package/gulpfile.js +0 -192
  106. package/src/icons/iconfont.css +0 -171
  107. package/src/icons/selection.json +0 -1
  108. package/src/icons/variables.css +0 -31
  109. package/src/scripts/Components/Form.js +0 -26
  110. package/src/scripts/Ui/Wsw.js +0 -25
  111. package/src/scripts/Utils/Functions/bodyLoaded.js +0 -12
  112. package/src/styles/Libraries/Animate.css +0 -184
  113. package/src/styles/Utils/reference.css +0 -2
  114. package/src/styles/Utils/tailwind/content.css +0 -24
  115. package/src/styles/Utils/theme/vars.css +0 -19
  116. package/src/styles/preload.css +0 -29
  117. package/src/styles/tailwind.css +0 -5
  118. package/src/templates/Sections/.gitkeep +0 -0
  119. package/src/templates/dialog-basic.twig +0 -3
  120. package/src/templates/index.json +0 -6
@@ -1,137 +1,137 @@
1
- const LibNativeSlider = function(selector, parent) {
2
- let self = {
3
- behavior: "auto",
1
+ export default function LibNativeSlider(selector, parent) {
2
+ const self = {
3
+ behavior: 'auto',
4
4
  ref: {
5
- nav: parent.querySelector("[data-lib-ns-nav]"),
6
- select: parent.querySelectorAll("[data-lib-ns-nav-item]"),
7
- progress: parent.querySelector("[data-lib-ns-progress]"),
8
- counterMin: parent.querySelector(`[data-lib-ns-counter="min"]`),
9
- counterMax: parent.querySelector(`[data-lib-ns-counter="max"]`),
10
- prev: parent.querySelector("[data-lib-ns-prev]"),
11
- next: parent.querySelector("[data-lib-ns-next]")
5
+ nav: parent.querySelector('[data-lib-ns-nav]'),
6
+ select: parent.querySelectorAll('[data-lib-ns-nav-item]'),
7
+ progress: parent.querySelector('[data-lib-ns-progress]'),
8
+ counterMin: parent.querySelector('[data-lib-ns-counter="min"]'),
9
+ counterMax: parent.querySelector('[data-lib-ns-counter="max"]'),
10
+ prev: parent.querySelector('[data-lib-ns-prev]'),
11
+ next: parent.querySelector('[data-lib-ns-next]')
12
12
  }
13
13
  }
14
-
15
- if (!selector.classList.contains("is-fade")) {
16
- self.behavior = "smooth";
17
-
18
- let grabbing = () => {
19
- self.isDown = false;
20
- self.paused = false;
21
- selector.classList.remove('is-grabbing');
22
- selector.scrollLeft = selector.scrollLeft - 1;
23
- };
24
-
25
- selector.addEventListener('mouseleave', grabbing);
26
-
27
- selector.addEventListener('mouseup', grabbing);
28
-
29
- selector.addEventListener('mousedown', (e) => {
30
- self.isDown = true;
31
- self.startX = e.pageX - selector.offsetLeft;
32
- self.scrollLeft = selector.scrollLeft;
33
- self.paused = true;
34
- });
35
-
36
- selector.addEventListener('mousemove', (e) => {
37
- if(!self.isDown) return;
38
- e.preventDefault();
39
- const x = e.pageX - selector.offsetLeft;
40
- const walk = (x - self.startX) * 1.25;
41
- selector.classList.add('is-grabbing');
42
- selector.scrollLeft = self.scrollLeft - walk;
43
-
44
- selector.ondragstart = (dragEvent) => {
45
- dragEvent.preventDefault();
46
- };
47
- });
14
+
15
+ if (!selector.classList.contains('is-fade')) {
16
+ self.behavior = 'smooth'
17
+
18
+ if (!document.documentElement.classList.contains('safari')) {
19
+ const grabbing = () => {
20
+ self.isDown = false
21
+ self.paused = false
22
+ selector.classList.remove('is-grabbing')
23
+ selector.scrollLeft = selector.scrollLeft - 1
24
+ }
25
+
26
+ selector.addEventListener('mouseleave', grabbing)
27
+
28
+ selector.addEventListener('mouseup', grabbing)
29
+
30
+ selector.addEventListener('mousedown', e => {
31
+ self.isDown = true
32
+ self.startX = e.pageX - selector.offsetLeft
33
+ self.scrollLeft = selector.scrollLeft
34
+ self.paused = true
35
+ })
36
+
37
+ selector.addEventListener('mousemove', e => {
38
+ if (!self.isDown) return
39
+ e.preventDefault()
40
+ const x = e.pageX - selector.offsetLeft
41
+ const walk = (x - self.startX) * 1.25
42
+ selector.classList.add('is-grabbing')
43
+ selector.scrollLeft = self.scrollLeft - walk
44
+
45
+ selector.ondragstart = dragEvent => {
46
+ dragEvent.preventDefault()
47
+ }
48
+ })
49
+ }
48
50
  }
49
51
 
50
52
  if (self.ref.counterMax !== null) {
51
- self.counterMax = parseInt(((selector.scrollWidth - selector.clientWidth) / selector.children[0].clientWidth + 1).toFixed(0));
52
- self.ref.counterMax.textContent = self.counterMax;
53
+ self.counterMax = parseInt(((selector.scrollWidth - selector.clientWidth) / selector.children[0].clientWidth + 1).toFixed(0))
54
+ self.ref.counterMax.textContent = self.counterMax
53
55
  }
54
56
 
55
57
  if (self.ref.nav !== null) {
56
- self.ref.nav.insertAdjacentHTML("beforeend", [...Array(self.counterMax)].map((x,i) => `<div data-state="${i === 0 && 'active'}" aria-label="${i+1}" aria-current="step" data-lib-ns-nav-item="${i}"></div>`).join(""));
57
- self.ref.select = parent.querySelectorAll("[data-lib-ns-nav-item]");
58
+ self.ref.nav.insertAdjacentHTML('beforeend', [...Array(self.counterMax)].map((x, i) => `<div data-state="${i === 0 && 'active'}" aria-label="${i + 1}" aria-current="step" data-lib-ns-nav-item="${i}"></div>`).join(''))
59
+ self.ref.select = parent.querySelectorAll('[data-lib-ns-nav-item]')
58
60
  }
59
61
 
60
- if (typeof self.ref.select[0] !== "undefined") {
61
- self.ref.select.forEach((elm) => {
62
- elm.addEventListener("click", () => {
63
- if (!elm._hasDataValue("state", "active")) {
64
- let position = selector.scrollLeft / selector.children[0].clientWidth,
65
- selected = elm.dataset["libNsNavItem"];
62
+ if (typeof self.ref.select[0] !== 'undefined') {
63
+ self.ref.select.forEach(elm => {
64
+ elm.addEventListener('click', () => {
65
+ if (!elm._hasDataValue('state', 'active')) {
66
+ const position = selector.scrollLeft / selector.children[0].clientWidth
67
+ const selected = elm.dataset.libNsNavItem
66
68
 
67
69
  if (position - selected <= 0) {
68
- selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth * (selected - position), behavior: self.behavior });
70
+ selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth * (selected - position), behavior: self.behavior })
69
71
  } else {
70
- selector.scroll({ left: selector.scrollLeft - selector.children[0].clientWidth * (position - selected), behavior: self.behavior });
72
+ selector.scroll({ left: selector.scrollLeft - selector.children[0].clientWidth * (position - selected), behavior: self.behavior })
71
73
  }
72
74
  }
73
- });
74
- });
75
+ })
76
+ })
75
77
  }
76
78
 
77
- selector.addEventListener("scroll", () => {
79
+ selector.addEventListener('scroll', () => {
78
80
  if (self.ref.progress !== null) {
79
- self.ref.progress.value = ((selector.scrollLeft + selector.clientWidth) / selector.scrollWidth * 100).toFixed(2);
81
+ self.ref.progress.value = ((selector.scrollLeft + selector.clientWidth) / selector.scrollWidth * 100).toFixed(2)
80
82
  }
81
83
 
82
- let activeSlide = parseInt(((selector.scrollLeft / selector.children[0].clientWidth)+1).toFixed(0));
84
+ const activeSlide = parseInt(((selector.scrollLeft / selector.children[0].clientWidth) + 1).toFixed(0))
83
85
 
84
86
  if (self.ref.counterMin !== null) {
85
- self.ref.counterMin.textContent = activeSlide;
87
+ self.ref.counterMin.textContent = activeSlide
86
88
  }
87
89
 
88
- if (typeof self.ref.select[0] !== "undefined") {
89
- self.ref.select.forEach((elm) => elm._removeDataValue("state", "active"));
90
+ if (typeof self.ref.select[0] !== 'undefined') {
91
+ self.ref.select.forEach(elm => elm._removeDataValue('state', 'active'))
90
92
 
91
- self.ref.select[activeSlide-1]._addDataValue("state", "active");
93
+ self.ref.select[activeSlide - 1]._addDataValue('state', 'active')
92
94
  }
93
95
 
94
96
  if (Math.floor(selector.scrollLeft / selector.children[0].clientWidth) === selector.scrollLeft / selector.children[0].clientWidth) {
95
- [...selector.children].forEach((elm, index) => {
96
- elm._removeDataValue("state", "active");
97
+ [...selector.children].forEach(elm => {
98
+ elm._removeDataValue('state', 'active')
97
99
 
98
100
  if (selector.scrollLeft === elm.offsetLeft - elm.parentNode.offsetLeft) {
99
- elm._addDataValue("state", "active");
101
+ elm._addDataValue('state', 'active')
100
102
  }
101
- });
103
+ })
102
104
  }
103
- }, { passive: true });
105
+ }, { passive: true })
104
106
 
105
107
  if (self.ref.progress !== null) {
106
- self.ref.progress.addEventListener("click", (e) => {
107
- selector.scrollLeft = (selector.scrollWidth / 100) * (e.clientX - e.target["offsetLeft"]) / e.target["clientWidth"] * 100;
108
- });
108
+ self.ref.progress.addEventListener('click', e => {
109
+ selector.scrollLeft = (selector.scrollWidth / 100) * (e.clientX - e.target.offsetLeft) / e.target.clientWidth * 100
110
+ })
109
111
  }
110
112
 
111
113
  if (self.ref.prev !== null && self.ref.next !== null) {
112
- self.ref.prev.addEventListener("click", () => selector.scroll({ left: selector.scrollLeft - selector.children[0].clientWidth, behavior: self.behavior }));
114
+ self.ref.prev.addEventListener('click', () => selector.scroll({ left: selector.scrollLeft - selector.children[0].clientWidth, behavior: self.behavior }))
113
115
 
114
- self.ref.next.addEventListener("click", () => selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth, behavior: self.behavior }));
116
+ self.ref.next.addEventListener('click', () => selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth, behavior: self.behavior }))
115
117
  }
116
118
 
117
- [self.ref.prev, self.ref.next, ...self.ref.select, self.ref.progress].map((elm) => {
118
- if (typeof elm !== "undefined" && elm !== null) {
119
- elm.addEventListener("mouseenter", () => self.paused = true);
120
- elm.addEventListener("mouseleave", () => self.paused = false);
119
+ [self.ref.prev, self.ref.next, ...self.ref.select, self.ref.progress].forEach(elm => {
120
+ if (typeof elm !== 'undefined' && elm !== null) {
121
+ elm.addEventListener('mouseenter', () => (self.paused = true))
122
+ elm.addEventListener('mouseleave', () => (self.paused = false))
121
123
  }
122
124
  })
123
125
 
124
- if (!isNaN(parseInt(selector.getAttribute("data-lib-ns")))) {
126
+ if (!isNaN(parseInt(selector.getAttribute('data-lib-ns')))) {
125
127
  setInterval(() => {
126
128
  if (!self.paused) {
127
129
  if (selector.scrollLeft <= selector.children[0].clientWidth) {
128
- selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth, behavior: self.behavior });
130
+ selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth, behavior: self.behavior })
129
131
  } else {
130
- selector.scroll({ left: 0, behavior: self.behavior });
132
+ selector.scroll({ left: 0, behavior: self.behavior })
131
133
  }
132
134
  }
133
- }, parseInt(selector.getAttribute("data-lib-ns")))
135
+ }, parseInt(selector.getAttribute('data-lib-ns')))
134
136
  }
135
- };
136
-
137
- export default LibNativeSlider;
137
+ }
@@ -1,25 +1,27 @@
1
- import { LibStimulus, Controller } from "./Stimulus.js";
2
- import importScript from "../Utils/Functions/importScript.js";
3
- import cdn from "../Utils/cdn.js";
1
+ import { LibStimulus, Controller } from './Stimulus.js'
2
+ import importScript from '../Utils/Functions/importScript.js'
3
+ import cdn from '../Utils/cdn.js'
4
4
 
5
- LibStimulus.register("lib-recaptcha", class extends Controller {
5
+ LibStimulus.register('lib-recaptcha', class extends Controller {
6
6
  connect() {
7
- setTimeout(() => this.captcha(), 2500);
8
-
9
- this.interval = setInterval(() => this.captcha(), 150000);
7
+ importScript(cdn.recaptcha.replace('{apikey}', this.data.get('api')))
10
8
  }
11
9
 
12
- captcha() {
13
- importScript(cdn.recaptcha.replace("{apikey}", this.data.get("api")).then(() => {
14
- window.grecaptcha.ready(function () {
15
- window.grecaptcha.execute(this.data.get("api"), {action: 'form'}).then(token => {
16
- this.element.querySelector(`[name="gtoken"]`).value = token;
17
- });
18
- });
19
- }))
10
+ async execute() {
11
+ return new Promise(resolve => {
12
+ window.grecaptcha.enterprise.ready(() => {
13
+ window.grecaptcha.enterprise.execute(this.data.get('api'), { action: this.data.get('action') ? this.data.get('action') : 'form' }).then(token => {
14
+ this.element.querySelector('[name="gtoken"]').value = token
15
+ resolve()
16
+ })
17
+ })
18
+ })
20
19
  }
21
20
 
22
- disconnect() {
23
- clearInterval(this.interval);
21
+ async submit(e) {
22
+ e.preventDefault()
23
+
24
+ await this.execute()
25
+ this.element.submit()
24
26
  }
25
- });
27
+ })
@@ -1,40 +1,24 @@
1
- function LibRipple(element, e) {
2
- const init = function (container) {
3
- if (container.querySelector(".lib-ripple-inner") === null) {
4
- container.insertAdjacentHTML("beforeend", `<div class='lib-ripple-inner'></div>`);
5
- }
1
+ const LibRipple = ({ currentTarget, layerX, layerY }) => {
2
+ const container = currentTarget
6
3
 
7
- let ink = container.querySelector(".lib-ripple-inner");
8
-
9
- ink.classList.remove("animation");
10
-
11
- if (ink.clientWidth === 0 && ink.clientHeight === 0) {
12
- let d = Math.max(element.offsetWidth, element.offsetHeight);
13
-
14
- ink.style["width"] = d + 'px';
15
- ink.style["height"] = d + 'px';
16
- }
4
+ if (container.querySelector('.lib-ripple') === null) {
5
+ container.insertAdjacentHTML('beforeend', "<div class='lib-ripple'></div>")
6
+ }
17
7
 
18
- let x, y;
8
+ const ink = container.querySelector('.lib-ripple')
19
9
 
20
- if (container === document.body) {
21
- x = e.clientX - container.offsetLeft - (ink.clientWidth / 2);
22
- y = e.clientY - container.offsetTop - (ink.clientHeight / 2);
23
- } else {
24
- x = e.pageX - container.offsetLeft - (ink.clientWidth / 2);
25
- y = e.pageY - container.offsetTop - (ink.clientHeight / 2);
26
- }
10
+ ink.classList.remove('animation')
27
11
 
28
- ink.style["top"] = y + 'px';
29
- ink.style["left"] = x + 'px';
30
- ink.classList.add("animation");
31
- };
12
+ if (ink.clientWidth === 0 && ink.clientHeight === 0) {
13
+ const d = Math.max(container.offsetWidth, container.offsetHeight)
32
14
 
33
- if (element.getAttribute("data-action-ripple") === "body") {
34
- init(document.body);
35
- } else {
36
- init(element);
15
+ ink.style.width = d + 'px'
16
+ ink.style.height = d + 'px'
37
17
  }
18
+
19
+ ink.style.top = layerY - (ink.clientHeight / 2) + 'px'
20
+ ink.style.left = layerX - (ink.clientWidth / 2) + 'px'
21
+ ink.classList.add('animation')
38
22
  }
39
23
 
40
- export default LibRipple;
24
+ export default LibRipple
@@ -0,0 +1,19 @@
1
+ import { LibStimulus, Controller } from './Stimulus.js'
2
+
3
+ LibStimulus.register('lib-script', class extends Controller {
4
+ connect() {
5
+ const element = this.element
6
+ const script = document.createElement('script')
7
+
8
+ ;[...element.attributes].forEach(attribute => {
9
+ if (attribute.specified && !attribute.name.includes('type') && !attribute.name.includes('data-controller')) {
10
+ script.setAttribute(attribute.name, attribute.value)
11
+ }
12
+ })
13
+
14
+ script.innerHTML = element.innerHTML
15
+
16
+ element.parentElement.appendChild(script)
17
+ element.remove()
18
+ }
19
+ })
@@ -1,46 +1,42 @@
1
- import { Application, Controller } from "stimulus";
2
- import loadStimulus from "../Utils/Functions/loadStimulus.js";
1
+ import { Application, Controller as DefaultController } from '@hotwired/stimulus'
2
+ import loadStimulus from '../Utils/Functions/loadStimulus.js'
3
3
 
4
- const LibStimulus = new Application(document.documentElement, {
5
- controllerAttribute: "data-controller",
6
- actionAttribute: "data-action",
7
- targetAttribute: "data-ref"
8
- });
4
+ const LibStimulus = new Application(document.documentElement)
9
5
 
10
- LibStimulus.getController = (element, identifier) => LibStimulus.getControllerForElementAndIdentifier(element, identifier);
6
+ const getController = (element, identifier) => LibStimulus.getControllerForElementAndIdentifier(element, identifier)
11
7
 
12
- Controller.prototype.getValue = function(value) {
13
- return this[`${value}Value`]
14
- };
8
+ class Controller extends DefaultController {
9
+ getValue(value) {
10
+ return this[`${value}Value`]
11
+ }
15
12
 
16
- Controller.prototype.setValue = function(type, value) {
17
- this[`${type}Value`] = value;
18
- };
13
+ setValue(type, value) {
14
+ this[`${type}Value`] = value
15
+ }
19
16
 
20
- Controller.prototype.hasValue = function(type, value) {
21
- return this.data.has(`${type}Value`, value);
22
- };
17
+ hasValue(value) {
18
+ return this.data.has(`${value}Value`)
19
+ }
23
20
 
24
- Controller.prototype.getClass = function(value) {
25
- return this.data.get(`${value}Class`)
26
- };
21
+ getClass(value) {
22
+ return this.data.get(`${value}Class`)
23
+ }
27
24
 
28
- Controller.prototype.queryTarget = function(target) {
29
- return this.targets.find(target)
30
- };
25
+ queryTarget(target) {
26
+ return this.targets.find(target)
27
+ }
31
28
 
32
- Controller.prototype.queryTargetAll = function(targets) {
33
- return this.targets.findAll(targets)
34
- };
29
+ queryTargetAll(targets) {
30
+ return this.targets.findAll(targets)
31
+ }
35
32
 
36
- Controller.prototype.hasTarget = function(target) {
37
- return this.targets.has(target)
38
- };
33
+ hasTarget(target) {
34
+ return this.targets.has(target)
35
+ }
36
+ }
39
37
 
40
- LibStimulus.start().then(() => {
41
- loadStimulus(document);
42
- });
38
+ LibStimulus.start().then(() => loadStimulus(document.body))
43
39
 
44
- window.LibStimulus = LibStimulus;
40
+ window.LibStimulus = { default: LibStimulus, Controller, loadStimulus }
45
41
 
46
- export { LibStimulus, Controller, loadStimulus };
42
+ export { LibStimulus, Controller, loadStimulus, getController }
@@ -1,82 +1,72 @@
1
- import Swup from 'swup';
2
- import {LibStimulus, loadStimulus} from "./Stimulus.js";
3
- import LibAnchor from "./Anchor.js";
4
- import LibDialog from "./Dialog.js";
5
- import LibCookieConsent from "./CookieConsent.js";
1
+ import Swup from 'swup'
2
+ import { getController, loadStimulus } from './Stimulus.js'
3
+ import LibAnchor from './Anchor.js'
4
+ import LibDialog from './Dialog.js'
5
+ import LibCookieConsent from './CookieConsent.js'
6
+ import replaceTag from '../Utils/Functions/replaceTag.js'
6
7
 
7
8
  const LibSwup = new Swup({
8
- containers: ['#l-main'],
9
- linkSelector: `a[href^="${window.location.origin}"]:not([data-no-swup]):not([target="_blank"]), a[href^="/"]:not([data-no-swup]):not([target="_blank"]), a[href^="#"]:not([data-no-swup])`
10
- });
9
+ containers: ['#l-main', '#l-header'].filter(element => document.querySelector(element)),
10
+ linkSelector: `:is(a[href^="${window.location.origin}"], a[href^="/"]):not([data-no-swup], [data-naja], [target="_blank"])`
11
+ })
11
12
 
12
- LibSwup.on('clickLink', () => {
13
- document.body.classList.remove("is-overflow-hidden");
13
+ LibSwup.on('clickLink', async() => {
14
+ document.body.classList.remove('overflow-hidden')
14
15
 
15
- if (document.querySelector(".is-lib-drawer-active") !== null) {
16
- LibStimulus.getController(document.body, "lib-drawer").hide()
16
+ if (document.querySelector('.lib-drawer[data-state~="active"]') !== null) {
17
+ getController(document.body, 'lib-drawer').hide()
17
18
  }
18
19
 
19
- if (document.querySelector(".lib-dialog") !== null) {
20
- LibDialog.hide();
20
+ if (document.querySelector('.lib-dialog') !== null) {
21
+ await LibDialog.hide()
21
22
  }
22
- });
23
+ })
23
24
 
24
25
  LibSwup.on('animationOutDone', () => {
25
- window.scrollTo(0, 0);
26
- });
26
+ document.documentElement.scroll({ top: 0, behavior: 'instant' })
27
+ })
27
28
 
28
29
  LibSwup.on('contentReplaced', () => {
29
- const content = new DOMParser().parseFromString(LibSwup.cache["getCurrentPage"]().originalContent, "text/html");
30
+ const content = new DOMParser().parseFromString(LibSwup.cache.getCurrentPage().originalContent, 'text/html')
30
31
 
31
- [...content.head.querySelectorAll("[data-lib-swup-replace]")].forEach(element => {
32
- let tag = document.querySelector(`[data-lib-swup-replace=${element.dataset.libSwupReplace}]`);
32
+ replaceTag(content)
33
33
 
34
- if (tag !== null) {
35
- tag.outerHTML = element.outerHTML
36
- } else {
37
- document.head.insertAdjacentHTML("beforeend", element.outerHTML);
38
- }
39
- });
34
+ LibAnchor.init()
40
35
 
41
- LibSwup.options.containers.forEach((selector) => {
42
- loadStimulus(document.querySelector(selector));
43
- });
36
+ LibSwup.options.containers.forEach(selector => {
37
+ loadStimulus(document.querySelector(selector))
38
+ })
44
39
 
45
- LibAnchor.init();
46
-
47
- if (typeof window.fbq !== "undefined") {
48
- window.fbq('track', 'PageView');
40
+ if (typeof window.fbq !== 'undefined') {
41
+ window.fbq('track', 'PageView')
49
42
  }
50
43
 
51
- if (typeof gtag !== "undefined") {
52
- let configs = [];
53
- window.dataLayer.forEach(function (config) {
54
- if (config[0] === "config") {
55
- if (typeof config[1] !== "undefined" && !configs.includes(config[1])) {
56
- configs.push(config[1]);
44
+ if (typeof gtag !== 'undefined') {
45
+ const configs = []
46
+ window.dataLayer.forEach(function(config) {
47
+ if (config[0] === 'config') {
48
+ if (typeof config[1] !== 'undefined' && !configs.includes(config[1])) {
49
+ configs.push(config[1])
57
50
  window.gtag('config', config[1], {
58
- 'page_title': document.title,
59
- 'page_path': window.location.pathname + window.location.search
60
- });
51
+ page_title: document.title,
52
+ page_path: window.location.pathname + window.location.search
53
+ })
61
54
  }
62
55
  }
63
- });
56
+ })
64
57
  }
65
58
 
66
- if (typeof window.dataLayer !== "undefined") {
59
+ if (typeof window.dataLayer !== 'undefined') {
67
60
  window.dataLayer.push({
68
- 'event': 'VirtualPageview',
69
- 'virtualPageURL': window.location.pathname + window.location.search,
70
- 'virtualPageTitle': document.title
71
- });
61
+ event: 'VirtualPageview',
62
+ virtualPageURL: window.location.pathname + window.location.search,
63
+ virtualPageTitle: document.title
64
+ })
72
65
  }
73
66
 
74
- if (typeof LibCookieConsent !== "undefined") {
75
- LibCookieConsent.init();
67
+ if (typeof LibCookieConsent !== 'undefined') {
68
+ LibCookieConsent.init()
76
69
  }
70
+ })
77
71
 
78
- document.body.classList.remove("is-body-preload");
79
- document.body.classList.add("is-body-loaded");
80
- });
81
-
82
- export default LibSwup;
72
+ export default LibSwup
@@ -1,22 +1,16 @@
1
- const LibTabs = function (element, callback) {
2
- [...element.querySelector(`[data-lib-tabs-nav]`).querySelectorAll(`[data-lib-tabs-item="nav"]`)].forEach((selector, index) => {
3
- selector.addEventListener("click", e => {
4
- e.preventDefault();
1
+ export default function LibTabs(element) {
2
+ element.querySelector('[data-lib-tabs-nav]').querySelectorAll('[data-lib-tabs-item="nav"]').forEach((selector, index) => {
3
+ selector.addEventListener('click', e => {
4
+ e.preventDefault()
5
5
 
6
- [...selector.closest(`[data-lib-tabs-nav]`).querySelectorAll(`[data-lib-tabs-item="nav"]`)].forEach(elm => elm._removeDataValue("state", "active"));
7
- selector._addDataValue("state", "active");
6
+ selector.closest('[data-lib-tabs-nav]').querySelectorAll('[data-lib-tabs-item="nav"]').forEach(elm => elm._removeDataValue('state', 'active'))
7
+ selector._addDataValue('state', 'active')
8
8
 
9
- [...element.querySelector(`[data-lib-tabs-area]`).children].forEach(elm => {
10
- elm._removeDataValue("state", "active");
11
- });
9
+ ;[...element.querySelector('[data-lib-tabs-area]').children].forEach(elm => {
10
+ elm._removeDataValue('state', 'active')
11
+ })
12
12
 
13
- element.querySelector(`[data-lib-tabs-area]`).children[index]._addDataValue("state", "active");
14
-
15
- if (callback) {
16
- callback(index);
17
- }
13
+ element.querySelector('[data-lib-tabs-area]').children[index]._addDataValue('state', 'active')
18
14
  })
19
- });
20
- };
21
-
22
- export default LibTabs;
15
+ })
16
+ }