@newlogic-digital/ui 3.4.2 → 3.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +21 -15
  2. package/package.json +32 -24
  3. package/src/data/main.json +25 -15
  4. package/src/emails/styles/main/+.css +3 -0
  5. package/src/emails/styles/main/Base/+.css +2 -0
  6. package/src/emails/styles/main/Base/config.css +22 -0
  7. package/src/emails/styles/main/Components/+.css +1 -0
  8. package/src/emails/styles/main/Components/Card.css +12 -0
  9. package/src/emails/styles/main/Ui/+.css +3 -0
  10. package/src/emails/styles/main/Ui/Btn.css +78 -0
  11. package/src/emails/styles/main/Ui/Heading.css +8 -0
  12. package/src/emails/styles/main/Ui/Text.css +12 -0
  13. package/src/emails/styles/main.css +92 -0
  14. package/src/emails/{templates/Layout.twig → templates.test/Layout.latte} +17 -5
  15. package/src/emails/templates.test/Sections/Footer.latte +22 -0
  16. package/src/emails/templates.test/Sections/Header.latte +37 -0
  17. package/src/emails/templates.test/Sections/Text.latte +24 -0
  18. package/src/icons.svg +27 -21
  19. package/src/scripts/Components/+.js +2 -1
  20. package/src/scripts/Components/Drawer.js +60 -0
  21. package/src/scripts/Components/Popover.js +65 -0
  22. package/src/scripts/Layout/+.js +0 -1
  23. package/src/scripts/Layout/Header.js +14 -24
  24. package/src/scripts/Libraries/+.js +4 -8
  25. package/src/scripts/Libraries/CookieConsent.js +65 -52
  26. package/src/scripts/Libraries/Dialog.js +19 -36
  27. package/src/scripts/Libraries/Form.js +5 -25
  28. package/src/scripts/Libraries/Naja.js +22 -20
  29. package/src/scripts/Libraries/ReCaptcha.js +8 -30
  30. package/src/scripts/Libraries/Reveal.js +32 -0
  31. package/src/scripts/Libraries/Ripple.js +6 -22
  32. package/src/scripts/Libraries/Stimulus.js +49 -5
  33. package/src/scripts/Libraries/Swup.js +45 -32
  34. package/src/scripts/Libraries/Toaster.js +55 -0
  35. package/src/scripts/Ui/+.js +3 -3
  36. package/src/scripts/Ui/Check.js +8 -0
  37. package/src/scripts/Ui/Control.js +194 -0
  38. package/src/scripts/Ui/ControlSelect.js +25 -0
  39. package/src/scripts/Ui/Text.js +9 -11
  40. package/src/scripts/Utils/+.js +3 -3
  41. package/src/scripts/Utils/cdn.js +1 -3
  42. package/src/scripts/Utils/initAfter.js +11 -0
  43. package/src/scripts/Utils/naja.js +41 -0
  44. package/src/scripts/Utils/utilities.js +8 -0
  45. package/src/scripts/main.js +2 -1
  46. package/src/styles/Components/+.css +4 -3
  47. package/src/styles/Components/Dialog/+.css +2 -0
  48. package/src/styles/Components/Dialog/Content.css +2 -0
  49. package/src/styles/Components/Dialog/CookieConsent.css +17 -0
  50. package/src/styles/Components/Dialog/Default.css +2 -43
  51. package/src/styles/Components/Drawer.css +18 -0
  52. package/src/styles/Components/Field.css +1 -0
  53. package/src/styles/Components/Popover.css +1 -0
  54. package/src/styles/Components/Toaster.css +2 -0
  55. package/src/styles/Layout/Header.css +9 -45
  56. package/src/styles/Layout/Main.css +11 -75
  57. package/src/styles/Layout/Nav.css +13 -33
  58. package/src/styles/Libraries/+.css +1 -7
  59. package/src/styles/Libraries/Datepicker.css +38 -229
  60. package/src/styles/Libraries/Pickr.css +13 -0
  61. package/src/styles/Ui/+.css +5 -5
  62. package/src/styles/Ui/Badge.css +8 -82
  63. package/src/styles/Ui/Btn.css +14 -226
  64. package/src/styles/Ui/Check.css +1 -0
  65. package/src/styles/Ui/Control.css +57 -0
  66. package/src/styles/Ui/ControlSelect.css +57 -0
  67. package/src/styles/Ui/Group.css +1 -0
  68. package/src/styles/Ui/Heading.css +4 -22
  69. package/src/styles/Ui/Image.css +1 -17
  70. package/src/styles/Ui/Info.css +1 -0
  71. package/src/styles/Ui/Label.css +1 -14
  72. package/src/styles/Ui/Link.css +6 -39
  73. package/src/styles/Ui/Notice.css +5 -43
  74. package/src/styles/Ui/Progress.css +1 -56
  75. package/src/styles/Ui/Switch.css +1 -70
  76. package/src/styles/Ui/Text.css +1 -254
  77. package/src/styles/Ui/Title.css +4 -15
  78. package/src/styles/Utils/+.css +6 -10
  79. package/src/styles/Utils/breakpoints.css +1 -9
  80. package/src/styles/Utils/config.css +16 -0
  81. package/src/styles/Utils/default.css +15 -26
  82. package/src/styles/Utils/keyframes.css +1 -182
  83. package/src/styles/Utils/theme/+.css +1 -1
  84. package/src/styles/Utils/theme/main.css +28 -23
  85. package/src/styles/Utils/utilities.css +42 -0
  86. package/src/styles/main.css +16 -14
  87. package/src/styles/tinymce.css +34 -0
  88. package/src/templates/Components/Dialog/Basic.latte +24 -0
  89. package/src/templates/Components/Dialog/CookieConsent.latte +27 -0
  90. package/src/templates/Components/Form/CookieConsent.latte +47 -0
  91. package/src/templates/Layout/Header.latte +38 -0
  92. package/src/templates/Layout/Main.latte +73 -0
  93. package/src/templates/Sections/CookieConsent.latte +69 -0
  94. package/src/templates/Sections/Site.latte +213 -0
  95. package/src/templates/Sections/Text.latte +64 -0
  96. package/src/templates/Sections/Ui/Docs/@intro.html +16 -65
  97. package/src/templates/Sections/Ui/Docs/@nav.html +68 -129
  98. package/src/templates/Sections/Ui/Docs/@styles.html +3 -7
  99. package/src/templates/Sections/Ui/Docs/Default.latte +979 -0
  100. package/src/templates/Sections/Ui/Icons.html +11 -9
  101. package/src/templates/Sections/Ui/Intro.html +62 -79
  102. package/src/templates/Sections/Ui.latte +8 -0
  103. package/src/templates/Ui/+.latte +5 -0
  104. package/src/templates/Ui/Check.latte +7 -0
  105. package/src/templates/Ui/Control.latte +9 -0
  106. package/src/templates/Ui/ControlDate.latte +14 -0
  107. package/src/templates/Ui/ControlSelect.latte +9 -0
  108. package/src/templates/Ui/ControlTime.latte +14 -0
  109. package/src/templates/Utils/sections.latte +3 -0
  110. package/src/views/dialog/basic.json.latte +5 -0
  111. package/src/views/email/email.latte +6 -0
  112. package/src/views/email/email.test.latte +6 -0
  113. package/src/views/gdpr.json +6 -4
  114. package/src/views/index.json +1 -1
  115. package/src/views/popover/info.json.latte +15 -0
  116. package/src/views/site.json +11 -0
  117. package/src/views/ui-icons.json +1 -1
  118. package/src/views/ui.json +1 -1
  119. package/vite.config.js +17 -16
  120. package/src/emails/styles/email.css +0 -77
  121. package/src/emails/templates/Content.twig +0 -16
  122. package/src/emails/templates/Header.twig +0 -14
  123. package/src/scripts/Components/CookieConsent.js +0 -83
  124. package/src/scripts/Layout/Main.js +0 -47
  125. package/src/scripts/Libraries/Anchor.js +0 -35
  126. package/src/scripts/Libraries/Drawer.js +0 -45
  127. package/src/scripts/Libraries/NativeSlider.js +0 -138
  128. package/src/scripts/Libraries/Script.js +0 -19
  129. package/src/scripts/Libraries/Tabs.js +0 -16
  130. package/src/scripts/Libraries/Tippy.js +0 -120
  131. package/src/scripts/Ui/Checkbox.js +0 -10
  132. package/src/scripts/Ui/Input.js +0 -259
  133. package/src/scripts/Ui/Select.js +0 -53
  134. package/src/scripts/Utils/Functions/+.js +0 -6
  135. package/src/scripts/Utils/Functions/checkValidity.js +0 -44
  136. package/src/scripts/Utils/Functions/dataValue.js +0 -52
  137. package/src/scripts/Utils/Functions/importScript.js +0 -17
  138. package/src/scripts/Utils/Functions/importStyle.js +0 -18
  139. package/src/scripts/Utils/Functions/loadStimulus.js +0 -42
  140. package/src/scripts/Utils/Functions/replaceTag.js +0 -12
  141. package/src/scripts/Utils/global.js +0 -15
  142. package/src/styles/Components/CookieConsent.css +0 -71
  143. package/src/styles/Components/Dropdown/+.css +0 -1
  144. package/src/styles/Components/Dropdown/Default.css +0 -5
  145. package/src/styles/Components/Form/+.css +0 -1
  146. package/src/styles/Components/Form/CookieConsent.css +0 -31
  147. package/src/styles/Libraries/Dialog.css +0 -35
  148. package/src/styles/Libraries/Drawer.css +0 -70
  149. package/src/styles/Libraries/Hint.css +0 -201
  150. package/src/styles/Libraries/NativeSlider.css +0 -60
  151. package/src/styles/Libraries/Ripple.css +0 -16
  152. package/src/styles/Libraries/Tabs.css +0 -19
  153. package/src/styles/Libraries/Tippy.css +0 -87
  154. package/src/styles/Ui/Checkbox.css +0 -150
  155. package/src/styles/Ui/Icon.css +0 -33
  156. package/src/styles/Ui/Input.css +0 -467
  157. package/src/styles/Ui/Radio.css +0 -4
  158. package/src/styles/Ui/Select.css +0 -137
  159. package/src/styles/Utils/icons.css +0 -9
  160. package/src/styles/Utils/normalize.css +0 -223
  161. package/src/styles/Utils/tailwind/+.css +0 -3
  162. package/src/styles/Utils/tailwind/base.css +0 -3
  163. package/src/styles/Utils/tailwind/gutters.css +0 -346
  164. package/src/styles/Utils/tailwind/utilities.css +0 -48
  165. package/src/styles/Utils/vars.css +0 -91
  166. package/src/styles/Utils/vendor.css +0 -2
  167. package/src/templates/Components/CookieConsent.twig +0 -30
  168. package/src/templates/Components/Dialogs/Basic.twig +0 -22
  169. package/src/templates/Layout/Header.twig +0 -42
  170. package/src/templates/Layout/Main.twig +0 -49
  171. package/src/templates/Sections/Gdpr.twig +0 -64
  172. package/src/templates/Sections/Ui/Docs/Default.twig +0 -1600
  173. package/src/templates/Sections/Ui.twig +0 -8
  174. package/src/templates/Utils/sections.twig +0 -3
  175. package/src/views/dialog/basic.json.twig +0 -3
  176. package/src/views/dropdown/tippy.json.twig +0 -16
  177. package/src/views/email/email.twig +0 -6
  178. /package/src/{styles/Utils/print.css → emails/styles/main/Base/font.css} +0 -0
  179. /package/src/{templates/Components/Items → emails/templates}/.gitkeep +0 -0
  180. /package/src/templates/Layout/{Footer.twig → Footer.latte} +0 -0
package/src/icons.svg CHANGED
@@ -1,32 +1,38 @@
1
- <svg hidden="">
2
- <symbol id="icon-chevron-left" fill="none" viewBox="0 0 24 24" stroke="currentColor">
3
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
1
+ <svg class="hidden">
2
+ <symbol id="icon-chevron-left" viewBox="0 0 24 24">
3
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
4
4
  </symbol>
5
- <symbol id="icon-chevron-right" fill="none" viewBox="0 0 24 24" stroke="currentColor">
6
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
5
+ <symbol id="icon-chevron-right" viewBox="0 0 24 24">
6
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
7
7
  </symbol>
8
- <symbol id="icon-angle-down" fill="currentColor" viewBox="0 0 24 24" stroke="currentColor">
9
- <path d="M10.998 15.467c.491.71 1.513.71 2.004 0l3.767-5.453c.581-.843 0-2.013-1.002-2.014H8.234C7.232 8 6.65 9.17 7.231 10.014z" />
8
+ <symbol id="icon-exclamation-circle" viewBox="0 0 24 24">
9
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
10
10
  </symbol>
11
- <symbol id="icon-angle-up" fill="currentColor" viewBox="0 0 24 24" stroke="currentColor">
12
- <path d="M10.998 15.467c.491.71 1.513.71 2.004 0l3.767-5.453c.581-.843 0-2.013-1.002-2.014H8.234C7.232 8 6.65 9.17 7.231 10.014z" style="transform: scaleY(-1) translateY(1px); transform-origin: 50% 50%;" />
11
+ <symbol id="icon-x-mark" viewBox="0 0 24 24">
12
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
13
+ </symbol>
14
+ <symbol id="icon-bars-3" viewBox="0 0 24 24">
15
+ <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
13
16
  </symbol>
14
- <symbol id="icon-exclamation-circle" fill="none" viewBox="0 0 24 24" stroke="currentColor">
15
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
17
+ <symbol id="icon-moon" viewBox="0 0 24 24">
18
+ <path stroke-linecap="round" stroke-linejoin="round" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
16
19
  </symbol>
17
- <symbol id="icon-x" fill="none" viewBox="0 0 24 24" stroke="currentColor">
18
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M6 18L18 6M6 6l12 12" />
20
+ <symbol id="icon-sun" viewBox="0 0 24 24">
21
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
19
22
  </symbol>
20
- <symbol id="icon-menu" fill="none" viewBox="0 0 24 24" stroke="currentColor">
21
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
23
+ <symbol id="icon-at-symbol" viewBox="0 0 24 24">
24
+ <path stroke-linecap="round" stroke-linejoin="round" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207" />
22
25
  </symbol>
23
- <symbol id="icon-moon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
24
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
26
+ <symbol id="icon-calendar" viewBox="0 0 24 24">
27
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5" />
25
28
  </symbol>
26
- <symbol id="icon-sun" fill="none" viewBox="0 0 24 24" stroke="currentColor">
27
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
29
+ <symbol id="icon-clock" viewBox="0 0 24 24">
30
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
28
31
  </symbol>
29
- <symbol id="icon-at-symbol" fill="none" viewBox="0 0 24 24" stroke="currentColor">
30
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207" />
32
+ <symbol id="icon-angle-down-solid" viewBox="0 0 24 24">
33
+ <path d="M10.998 15.467c.491.71 1.513.71 2.004 0l3.767-5.453c.581-.843 0-2.013-1.002-2.014H8.234C7.232 8 6.65 9.17 7.231 10.014z" />
34
+ </symbol>
35
+ <symbol id="icon-angle-up-solid" viewBox="0 0 24 24">
36
+ <path d="M10.998 15.467c.491.71 1.513.71 2.004 0l3.767-5.453c.581-.843 0-2.013-1.002-2.014H8.234C7.232 8 6.65 9.17 7.231 10.014z" style="transform: scaleY(-1) translateY(1px); transform-origin: 50% 50%;" />
31
37
  </symbol>
32
38
  </svg>
@@ -1 +1,2 @@
1
- import './CookieConsent.js'
1
+ import './Drawer.js'
2
+ import './Popover.js'
@@ -0,0 +1,60 @@
1
+ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
2
+ import { showDrawer, closeDrawer, scrollDrawer } from 'winduum/src/components/drawer/index.js'
3
+
4
+ LibStimulus.register('c-drawer', class extends Controller {
5
+ static values = {
6
+ inertMatch: {
7
+ type: String,
8
+ default: ':where(.c-drawer, .l-header)'
9
+ }
10
+ }
11
+
12
+ connect() {
13
+ this.scrollReset()
14
+ this.element.addEventListener('click', ({ target }) => {
15
+ if (target === this.element) this.close()
16
+ })
17
+ }
18
+
19
+ scrollReset() {
20
+ this.element.scroll({ left: this.element.scrollWidth, behavior: 'instant' })
21
+ }
22
+
23
+ scroll({ target }) {
24
+ scrollDrawer(target)
25
+ }
26
+
27
+ inert(inert) {
28
+ [...document.body.children].forEach((element) => {
29
+ if (!element.matches(this.inertMatchValue)) (element.inert = inert)
30
+ })
31
+ }
32
+
33
+ show() {
34
+ this.scrollReset()
35
+ this.element.classList.add('active')
36
+ showDrawer(this.element)
37
+ this.inert(true)
38
+ }
39
+
40
+ close() {
41
+ closeDrawer(this.element)
42
+ }
43
+
44
+ toggle({ currentTarget }) {
45
+ this.activeButton = currentTarget
46
+
47
+ if (!currentTarget.classList.contains('active')) {
48
+ currentTarget.classList.add('active')
49
+ this.show()
50
+ } else {
51
+ this.close()
52
+ }
53
+ }
54
+
55
+ dismiss() {
56
+ this.element.classList.remove('active')
57
+ this.activeButton?.classList?.remove('active')
58
+ this.inert(false)
59
+ }
60
+ })
@@ -0,0 +1,65 @@
1
+ import { Controller, LibStimulus } from '../Libraries/Stimulus.js'
2
+ import { dataset, fetchJson } from '@newlogic-digital/utils-js'
3
+ import initAfter from '../Utils/initAfter.js'
4
+
5
+ LibStimulus.register('c-popover', class extends Controller {
6
+ static values = {
7
+ url: String,
8
+ insertTo: String,
9
+ manual: Boolean
10
+ }
11
+
12
+ async toggle({ currentTarget, params }) {
13
+ const { togglePopover } = await import('winduum/src/components/popover/index.js')
14
+ const hasUrlValue = this.hasUrlValue && !this.popoverTarget
15
+
16
+ if (hasUrlValue) await this.fetch()
17
+
18
+ this.popoverTarget = document.getElementById(currentTarget.getAttribute('popovertarget'))
19
+
20
+ if (hasUrlValue) initAfter(this.popoverTarget)
21
+
22
+ await togglePopover(currentTarget, params)
23
+ }
24
+
25
+ async hide() {
26
+ if (this.popoverActionTarget.ariaExpanded !== 'true') return
27
+
28
+ const { hidePopover } = await import('winduum/src/components/popover/index.js')
29
+
30
+ await hidePopover(this.popoverActionTarget)
31
+ }
32
+
33
+ async dismiss({ target }) {
34
+ if (this.popoverActionTarget.ariaExpanded !== 'true') return
35
+
36
+ if (!this.popoverTarget.contains(target) && !this.popoverActionTarget.isEqualNode(target) && this.popoverActionTarget.ariaExpanded === 'true') {
37
+ await this.hide()
38
+ }
39
+ }
40
+
41
+ async fetch() {
42
+ this.popoverActionTarget.classList.add('loading', 'cursor-wait')
43
+
44
+ const { content } = await fetchJson(this.urlValue)
45
+
46
+ this.popoverActionTarget.classList.remove('loading', 'cursor-wait')
47
+
48
+ const insertElement = !this.hasInsertToValue ? this.popoverActionTarget : document.querySelector(this.insertToValue)
49
+ insertElement.insertAdjacentHTML(!this.hasInsertToValue ? 'afterend' : 'beforeend', content)
50
+
51
+ return content
52
+ }
53
+
54
+ connect() {
55
+ this.popoverActionTarget = this.element.querySelector('[popovertargetaction]')
56
+
57
+ if (!this.popoverActionTarget) return
58
+
59
+ ;(!this.hasManualValue || !this.manualValue) && dataset(this.popoverActionTarget, 'action').add(
60
+ `click->c-popover#${this.popoverActionTarget.getAttribute('popovertargetaction')}:prevent`,
61
+ 'keydown.esc@window->c-popover#hide',
62
+ 'click@window->c-popover#dismiss'
63
+ )
64
+ }
65
+ })
@@ -1,2 +1 @@
1
1
  import './Header.js'
2
- import './Main.js'
@@ -1,30 +1,20 @@
1
- import { LibStimulus, Controller, getController } from '../Libraries/Stimulus.js'
1
+ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
2
2
 
3
- LibStimulus.register('l-header',
4
- /** @property {LibDrawer} libDrawerOutlet */
5
- class extends Controller {
6
- connect() {
7
- if (document.querySelector('#l-nav') === null) {
8
- this.element.insertAdjacentHTML('afterend', `
9
- <div id="l-nav" class="lib-drawer" data-lib-drawer-target="nav" data-action="scroll->lib-drawer#scroll" inert aria-hidden="true">
10
- <div class="wrp_nav">
11
- <div class="wrp_nav_head"></div>
12
- <div class="wrp_nav_body"></div>
13
- </div>
14
- </div>
15
- `)
3
+ LibStimulus.register('l-header', class extends Controller {
4
+ static targets = ['logo', 'nav']
16
5
 
17
- /** @type {LibDrawer} */
18
- const LibDrawer = getController(document.body, 'lib-drawer')
19
- LibDrawer.init()
6
+ connect() {
7
+ if (!document.querySelector('.l-nav')) {
8
+ this.element.insertAdjacentHTML('afterend', `
9
+ <div class="l-nav c-drawer" data-controller="c-drawer" data-action="scroll->c-drawer#scroll c-drawer:close->c-drawer#dismiss" inert>
10
+ <div class="c-drawer-content"></div>
11
+ </div>
12
+ `)
20
13
 
21
- const layoutNav = document.querySelector('#l-nav')
22
- const logo = this.element.querySelector('.elm_header_logo').outerHTML
23
- const nav = this.element.querySelector('.elm_header_nav').outerHTML
14
+ const drawerContentElement = document.querySelector('.l-nav .c-drawer-content')
24
15
 
25
- layoutNav.querySelector('.wrp_nav_head').insertAdjacentHTML('beforeend', logo)
26
- layoutNav.querySelector('.wrp_nav_body').insertAdjacentHTML('beforeend', nav)
27
- }
16
+ drawerContentElement.insertAdjacentHTML('beforeend', this.logoTarget.outerHTML)
17
+ drawerContentElement.insertAdjacentHTML('beforeend', this.navTarget.outerHTML)
28
18
  }
29
19
  }
30
- )
20
+ })
@@ -1,14 +1,10 @@
1
- export { default as Anchor } from './Anchor.js'
2
- export { default as CookieConsent } from './CookieConsent.js'
1
+ import './CookieConsent.js'
3
2
  import './Dialog.js'
4
- import './Drawer.js'
5
3
  import './Form.js'
6
4
  import './Naja.js'
7
- export { default as NativeSlider } from './NativeSlider.js'
8
5
  import './ReCaptcha.js'
9
- export { default as Ripple } from './Ripple.js'
10
- import './Script.js'
6
+ import './Reveal.js'
7
+ import './Ripple.js'
11
8
  import './Stimulus.js'
12
9
  export { default as Swup } from './Swup.js'
13
- export { default as Tabs } from './Tabs.js'
14
- export { default as Tippy } from './Tippy.js'
10
+ import './Toaster.js'
@@ -1,67 +1,80 @@
1
- const LibCookieConsent = {
2
- setItem: (key, value) => {
3
- localStorage.setItem(key, value)
4
- },
5
- getItem: (key) => {
6
- return localStorage.getItem(key)
7
- },
8
- init: () => {
9
- const type = LibCookieConsent.getItem('lib-cookieconsent')
1
+ import { LibStimulus, Controller } from './Stimulus.js'
2
+ import { appendCookieConsent, setCookieConsent } from '@newlogic-digital/cookieconsent-js'
3
+ import { showDialog, closeDialog } from 'winduum/src/components/dialog/index.js'
10
4
 
11
- if (type !== null) {
12
- JSON.parse(type).forEach(type => LibCookieConsent.append(type))
5
+ export const getCookieConsentItem = (key = 'cookieconsent-js') => localStorage.getItem(key)
6
+
7
+ export const initCookieConsent = (element = document, type = getCookieConsentItem() ?? []) => {
8
+ element.querySelectorAll('[data-lib-cookieconsent]').forEach((element) => {
9
+ if (type.includes(element.getAttribute('data-lib-cookieconsent'))) {
10
+ appendCookieConsent(element, {
11
+ ignoreAttributeName: /(type|data-lib-cookieconsent)/
12
+ })
13
+ }
14
+ })
15
+ }
16
+
17
+ LibStimulus.register('c-dialog-cookieconsent', class extends Controller {
18
+ async connect() {
19
+ initCookieConsent()
20
+
21
+ if (document.querySelector('.c-form-cookieconsent')) {
22
+ return
13
23
  }
14
- },
15
- set: (type) => {
16
- LibCookieConsent.setItem('lib-cookieconsent', JSON.stringify(type))
17
- LibCookieConsent.setItem('lib-cookieconsent-expire', (Date.now() + 31556926 * 1000).toString())
18
24
 
19
- if (type.length > 0) {
20
- type.forEach(type => LibCookieConsent.append(type))
25
+ if (!getCookieConsentItem() || parseInt(getCookieConsentItem('cookieconsent-js-expire')) < Date.now()) {
26
+ setTimeout(async () => {
27
+ await showDialog(this.element, { closable: false })
28
+ }, 1500)
21
29
  } else {
22
- LibCookieConsent.setItem('lib-cookieconsent', JSON.stringify([]))
23
- LibCookieConsent.remove()
30
+ this.element.remove()
24
31
  }
25
- },
26
- remove: () => {
27
- document.cookie.split(';').forEach(c => {
28
- document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/')
29
- })
30
- },
31
- append: (type) => {
32
- document.querySelectorAll('[data-lib-cookieconsent]').forEach(elm => {
33
- if (type === 'all' || elm.getAttribute('data-lib-cookieconsent') === type) {
34
- const script = document.createElement('script')
35
- let delay = 0
32
+ }
36
33
 
37
- ;[...elm.attributes].forEach((attribute) => {
38
- if (attribute.specified) {
39
- if (attribute.name.indexOf('data-lib-cookieconsent') === -1 && attribute.name.indexOf('type') === -1) {
40
- script.setAttribute(attribute.name, attribute.value)
41
- }
42
- }
43
- })
34
+ async approve() {
35
+ await this.hide(['performance', 'marketing'])
36
+ }
44
37
 
45
- script.innerHTML = elm.innerHTML
38
+ async decline() {
39
+ await this.hide([])
40
+ }
46
41
 
47
- if (elm.getAttribute('data-lib-cookieconsent-delay')) {
48
- delay = parseInt(elm.getAttribute('data-lib-cookieconsent-delay'))
49
- }
42
+ async hide(type) {
43
+ await setCookieConsent(type)
44
+ initCookieConsent(document, type)
45
+ await closeDialog(this.element, { remove: true })
46
+ }
47
+ })
50
48
 
51
- setTimeout(() => {
52
- if (elm.closest('body') !== null) {
53
- document.body.appendChild(script)
54
- } else if (elm.closest('head') !== null) {
55
- document.head.appendChild(script)
56
- }
49
+ LibStimulus.register('c-form-cookieconsent', class extends Controller {
50
+ connect() {
51
+ document.querySelector('.c-dialog-cookieconsent')?.close()
57
52
 
58
- elm.remove()
59
- }, delay)
53
+ this.element.querySelectorAll('input:not([disabled])').forEach((input) => {
54
+ input.checked = false
55
+ })
56
+
57
+ JSON.parse(getCookieConsentItem())?.forEach((type) => {
58
+ if (this.element.querySelector(`input[value="${type}"]`) !== null) {
59
+ this.element.querySelector(`input[value="${type}"]`).checked = true
60
60
  }
61
61
  })
62
62
  }
63
- }
64
63
 
65
- LibCookieConsent.init()
64
+ async update() {
65
+ const type = []
66
+
67
+ this.element.querySelectorAll('input:not([disabled])').forEach((input) => {
68
+ input.checked && type.push(input.value)
69
+ })
66
70
 
67
- export default LibCookieConsent
71
+ await setCookieConsent(type)
72
+ location.reload()
73
+ }
74
+
75
+ disconnect() {
76
+ if ((!getCookieConsentItem() || parseInt(getCookieConsentItem('cookieconsent-js-expire')) < Date.now())) {
77
+ document.querySelector('.c-dialog-cookieconsent')?.showModal()
78
+ }
79
+ }
80
+ })
@@ -1,45 +1,28 @@
1
- import { Controller, LibStimulus, loadStimulus } from './Stimulus.js'
2
- import { insertDialog, closeDialog, fetchDialog, dialogSelector } from 'winduum/src/libraries/dialog.js'
1
+ import { Controller, LibStimulus } from './../Libraries/Stimulus.js'
2
+ import { insertDialog, closeDialog, dialogSelector } from 'winduum/src/components/dialog/index.js'
3
+ import initAfter from '../Utils/initAfter.js'
4
+ import { fetchJson } from '@newlogic-digital/utils-js'
3
5
 
4
6
  LibStimulus.register('lib-dialog', class extends Controller {
5
- static values = {
6
- open: String,
7
- url: String
8
- }
7
+ async show({ currentTarget, params }) {
8
+ const loadingClasses = (params.loadingClass ?? 'loading cursor-wait').split(' ')
9
+
10
+ currentTarget.classList.add(...loadingClasses)
11
+
12
+ await this.fetch(params.url, params)
9
13
 
10
- async connect() {
11
- if (this.hasOpenValue) {
12
- if (this.hasUrlValue) {
13
- await fetchDialog({
14
- url: this.urlValue, insertOptions: { remove: true }
15
- })
16
- } else {
17
- await insertDialog(document.querySelector(this.openValue).innerHTML, {
18
- remove: true
19
- })
20
- }
21
-
22
- loadStimulus(dialogSelector('.lib-dialog'))
23
- }
14
+ currentTarget.classList.remove(...loadingClasses)
24
15
  }
25
16
 
26
- async show({ currentTarget, params }) {
27
- currentTarget._addDataValue('state', 'loading')
28
- currentTarget.classList.add('cursor-wait')
29
-
30
- await fetchDialog({
31
- url: params.url,
32
- insertOptions: {
33
- remove: params.remove ?? true,
34
- append: params.append ?? false
35
- }
36
- }).then(() => loadStimulus(dialogSelector('.lib-dialog')))
37
-
38
- currentTarget._removeDataValue('state', 'loading')
39
- currentTarget.classList.remove('cursor-wait')
17
+ async close({ currentTarget, params }) {
18
+ await closeDialog(currentTarget.closest('dialog'), { remove: params.remove ?? true })
40
19
  }
41
20
 
42
- async hide({ params }) {
43
- await closeDialog({ remove: params.remove ?? false })
21
+ async fetch(url, options) {
22
+ const { content } = await fetchJson(url)
23
+
24
+ await insertDialog(content, options)
25
+
26
+ initAfter(dialogSelector('.c-dialog'))
44
27
  }
45
28
  })
@@ -1,33 +1,13 @@
1
1
  import { LibStimulus, Controller } from './Stimulus.js'
2
- import { checkValidity } from '../Utils/Functions/+.js'
2
+ import { validateForm } from 'winduum/src/components/form/index.js'
3
3
 
4
4
  LibStimulus.register('lib-form', class extends Controller {
5
5
  connect() {
6
- this.element.setAttribute('novalidate', '')
7
- this.element.addEventListener('submit', e => this.validation(e))
6
+ this.element.noValidate = true
7
+ this.element.addEventListener('submit', this.validate)
8
8
  }
9
9
 
10
- validation(e) {
11
- if (this.element.checkValidity() === false) {
12
- e.preventDefault()
13
- e.stopPropagation()
14
-
15
- this.element.querySelector(':invalid').scrollIntoView({ behavior: 'smooth', block: 'center' })
16
- this.element.querySelector(':invalid').focus()
17
- } else {
18
- this.element.querySelector('[type="submit"]')._addDataValue('state', 'loading')
19
- }
20
-
21
- this.element.querySelectorAll('.ui-input, [data-controller="ui-checkbox"], [data-controller="ui-radio"]').forEach(element => {
22
- checkValidity(element, { message: true })
23
- })
24
-
25
- this.element.querySelectorAll('.ui-select:not([data-state*="active"]) select[required]').forEach(select => {
26
- checkValidity(select.closest('.ui-select'), { message: true })
27
- })
28
- }
29
-
30
- submitForm({ currentTarget }) {
31
- currentTarget.form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
10
+ async validate(event) {
11
+ validateForm(event)
32
12
  }
33
13
  })
@@ -1,35 +1,37 @@
1
+ import { Controller, LibStimulus, initStimulus } from './Stimulus.js'
2
+ import { initCookieConsent } from './CookieConsent.js'
3
+ import {
4
+ initNaja,
5
+ NajaRecaptchaExtension,
6
+ NajaFormValidityExtension
7
+ } from '../Utils/naja.js'
1
8
  import naja from 'naja'
2
- import { Controller, LibStimulus, loadStimulus } from './Stimulus.js'
9
+ import LibSwup from './Swup.js'
3
10
 
4
11
  LibStimulus.register('lib-naja', class extends Controller {
5
- async connect() {
6
- naja.uiHandler.addEventListener('interaction', ({ detail }) => {
7
- const element = detail.element
12
+ async initialize() {
13
+ naja.uiHandler.selector = '[data-naja]'
8
14
 
9
- detail.options.target = element
15
+ await initNaja(this.element, false)
10
16
 
11
- element.dispatchEvent(new CustomEvent('naja-interaction', { bubbles: true, cancelable: true }))
17
+ if (naja.initialized) return
12
18
 
13
- if (element?.form && !element.form.reportValidity()) {
14
- arguments[0].preventDefault()
15
- }
19
+ naja.uiHandler.addEventListener('interaction', ({ detail }) => {
20
+ detail.element.dispatchEvent(new CustomEvent('naja:interaction', { bubbles: true, cancelable: true }))
16
21
  })
17
22
 
18
23
  naja.snippetHandler.addEventListener('afterUpdate', ({ detail }) => {
19
- detail?.options.target.dispatchEvent(new CustomEvent('naja-afterUpdate', { bubbles: true, cancelable: true }))
24
+ detail.snippet.dispatchEvent(new CustomEvent('naja:afterUpdate', { bubbles: true, cancelable: true }))
20
25
 
21
- loadStimulus(document.body, false)
22
- })
26
+ initStimulus(detail.snippet)
27
+ initNaja(detail.snippet)
28
+ initCookieConsent(detail.snippet)
23
29
 
24
- naja.uiHandler.selector = '[data-naja]'
25
- naja.initialize({
26
- history: false
30
+ LibSwup.cache.clear()
27
31
  })
28
- }
29
-
30
- async fetch({ currentTarget }) {
31
- arguments[0].preventDefault()
32
32
 
33
- await naja.makeRequest('GET', currentTarget.dataset.actionUrl, null, { history: false })
33
+ naja.registerExtension(NajaRecaptchaExtension)
34
+ naja.registerExtension(NajaFormValidityExtension)
35
+ naja.initialize()
34
36
  }
35
37
  })
@@ -1,6 +1,5 @@
1
1
  import { LibStimulus, Controller } from './Stimulus.js'
2
- import naja from 'naja'
3
- import importScript from '../Utils/Functions/importScript.js'
2
+ import { importScript } from '@newlogic-digital/utils-js'
4
3
  import cdn from '../Utils/cdn.js'
5
4
 
6
5
  LibStimulus.register('lib-recaptcha', class extends Controller {
@@ -13,35 +12,14 @@ LibStimulus.register('lib-recaptcha', class extends Controller {
13
12
  importScript(cdn.recaptcha.replace('{apikey}', this.apiValue))
14
13
  }
15
14
 
16
- async execute() {
17
- return new Promise(resolve => {
18
- window.grecaptcha.enterprise.ready(() => {
19
- window.grecaptcha.enterprise.execute(this.apiValue, { action: this.actionValue ?? 'form' }).then(token => {
20
- this.element.querySelector('[name="gtoken"]').value = token
21
- resolve()
22
- })
15
+ execute(event) {
16
+ if (event?.detail?.recaptchaExecuted) return
17
+
18
+ window.grecaptcha.enterprise.ready(() => {
19
+ window.grecaptcha.enterprise.execute(this.apiValue, { action: this.actionValue ?? 'form' }).then((token) => {
20
+ this.element.gtoken.value = token
21
+ this.element.dispatchEvent(new CustomEvent('submit', { cancelable: true, detail: { recaptchaExecuted: true } }))
23
22
  })
24
23
  })
25
24
  }
26
-
27
- async submit() {
28
- if (this.element.reportValidity() === false) {
29
- return false
30
- }
31
-
32
- arguments[0].preventDefault()
33
-
34
- await this.execute()
35
- this.element.submit()
36
- }
37
-
38
- async submitFetch() {
39
- if (this.element.reportValidity() === false) {
40
- return false
41
- }
42
-
43
- arguments[0].preventDefault()
44
- await this.execute()
45
- await naja.makeRequest(this.element.method, this.element.action, new FormData(this.element), { history: 'replace' })
46
- }
47
25
  })
@@ -0,0 +1,32 @@
1
+ import { Controller, LibStimulus } from './Stimulus.js'
2
+ import { dataset } from '@newlogic-digital/utils-js'
3
+
4
+ LibStimulus.register('lib-reveal', class extends Controller {
5
+ static targets = ['item']
6
+
7
+ intersectionObserver() {
8
+ this.observer = new IntersectionObserver((entries, observer) => {
9
+ entries.forEach((entry) => {
10
+ if (entry.intersectionRatio > 0.1 && !entry.target.classList.contains('in')) {
11
+ entry.target.classList.add('in')
12
+
13
+ if (entry.target.dataset.controllerNameParam) {
14
+ dataset(entry.target, 'controller').add(entry.target.dataset.controllerNameParam)
15
+ }
16
+ }
17
+ })
18
+ }, {
19
+ threshold: 0.1
20
+ })
21
+ }
22
+
23
+ itemTargetConnected(element) {
24
+ if (!this.observer) this.intersectionObserver()
25
+
26
+ this.observer?.observe(element)
27
+ }
28
+
29
+ itemTargetDisconnected(element) {
30
+ this.observer?.unobserve(element)
31
+ }
32
+ })