@newlogic-digital/ui 3.4.2 → 3.5.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 (144) hide show
  1. package/README.md +10 -14
  2. package/package.json +12 -11
  3. package/src/data/main.json +2 -7
  4. package/src/emails/{templates/Content.twig → templates.test/Content.latte} +10 -2
  5. package/src/emails/{templates/Header.twig → templates.test/Header.latte} +1 -1
  6. package/src/emails/{templates/Layout.twig → templates.test/Layout.latte} +1 -1
  7. package/src/icons.svg +34 -28
  8. package/src/scripts/Components/CookieConsent.js +22 -27
  9. package/src/scripts/Layout/Header.js +15 -13
  10. package/src/scripts/Layout/Main.js +28 -25
  11. package/src/scripts/Libraries/+.js +2 -4
  12. package/src/scripts/Libraries/Dialog.js +11 -9
  13. package/src/scripts/Libraries/Drawer.js +21 -24
  14. package/src/scripts/Libraries/Form.js +7 -14
  15. package/src/scripts/Libraries/Naja.js +5 -7
  16. package/src/scripts/Libraries/ReCaptcha.js +7 -12
  17. package/src/scripts/Libraries/Ripple.js +6 -22
  18. package/src/scripts/Libraries/Script.js +1 -2
  19. package/src/scripts/Libraries/Slider.js +160 -0
  20. package/src/scripts/Libraries/Stimulus.js +0 -1
  21. package/src/scripts/Libraries/Swup.js +38 -10
  22. package/src/scripts/Libraries/Tippy.js +17 -20
  23. package/src/scripts/Ui/+.js +3 -3
  24. package/src/scripts/Ui/Check.js +8 -0
  25. package/src/scripts/Ui/Control.js +186 -0
  26. package/src/scripts/Ui/ControlSelect.js +24 -0
  27. package/src/scripts/Ui/Text.js +8 -10
  28. package/src/scripts/Utils/Functions/+.js +3 -2
  29. package/src/scripts/Utils/Functions/importScript.js +1 -1
  30. package/src/scripts/Utils/Functions/importStyle.js +1 -1
  31. package/src/scripts/Utils/Functions/inputStep.js +9 -0
  32. package/src/scripts/Utils/Functions/inputValidity.js +57 -0
  33. package/src/scripts/Utils/Functions/loadStimulus.js +10 -10
  34. package/src/scripts/Utils/Functions/replaceScript.js +4 -0
  35. package/src/scripts/Utils/Functions/replaceTag.js +1 -5
  36. package/src/scripts/Utils/cdn.js +1 -2
  37. package/src/scripts/Utils/global.js +1 -1
  38. package/src/styles/Components/+.css +1 -1
  39. package/src/styles/Components/CookieConsent.css +22 -25
  40. package/src/styles/Components/Dialog/Default.css +8 -25
  41. package/src/styles/Components/Dropdown/Default.css +6 -3
  42. package/src/styles/Components/Field.css +1 -0
  43. package/src/styles/Layout/Header.css +13 -17
  44. package/src/styles/Layout/Main.css +8 -75
  45. package/src/styles/Layout/Nav.css +31 -27
  46. package/src/styles/Libraries/+.css +1 -2
  47. package/src/styles/Libraries/Datepicker.css +38 -229
  48. package/src/styles/Libraries/Dialog.css +1 -35
  49. package/src/styles/Libraries/Drawer.css +15 -21
  50. package/src/styles/Libraries/Hint.css +86 -101
  51. package/src/styles/Libraries/Pickr.css +13 -0
  52. package/src/styles/Libraries/Ripple.css +1 -16
  53. package/src/styles/Libraries/Tippy.css +25 -39
  54. package/src/styles/Ui/+.css +6 -5
  55. package/src/styles/Ui/Badge.css +7 -82
  56. package/src/styles/Ui/Btn.css +13 -226
  57. package/src/styles/Ui/Check.css +1 -0
  58. package/src/styles/Ui/Control.css +47 -0
  59. package/src/styles/Ui/ControlSelect.css +66 -0
  60. package/src/styles/Ui/Dot.css +22 -0
  61. package/src/styles/Ui/Group.css +1 -0
  62. package/src/styles/Ui/Heading.css +3 -22
  63. package/src/styles/Ui/Image.css +1 -17
  64. package/src/styles/Ui/Info.css +1 -0
  65. package/src/styles/Ui/Label.css +1 -14
  66. package/src/styles/Ui/Link.css +2 -41
  67. package/src/styles/Ui/Notice.css +1 -47
  68. package/src/styles/Ui/Progress.css +1 -56
  69. package/src/styles/Ui/Switch.css +1 -70
  70. package/src/styles/Ui/Text.css +4 -250
  71. package/src/styles/Ui/Title.css +5 -13
  72. package/src/styles/Utils/+.css +8 -10
  73. package/src/styles/Utils/breakpoints.css +1 -9
  74. package/src/styles/Utils/config.css +5 -0
  75. package/src/styles/Utils/default.css +8 -26
  76. package/src/styles/Utils/icons.css +3 -7
  77. package/src/styles/Utils/keyframes.css +1 -182
  78. package/src/styles/Utils/{tailwind/utilities.css → tailwind.css} +32 -30
  79. package/src/styles/Utils/theme/main.css +14 -23
  80. package/src/styles/main.css +19 -14
  81. package/src/styles/tinymce.css +34 -0
  82. package/src/templates/Components/CookieConsent.latte +28 -0
  83. package/src/templates/Components/Dialogs/{Basic.twig → Basic.latte} +9 -9
  84. package/src/templates/Layout/Footer.latte +0 -0
  85. package/src/templates/Layout/{Header.twig → Header.latte} +15 -17
  86. package/src/templates/Layout/Main.latte +62 -0
  87. package/src/templates/Sections/Gdpr.latte +127 -0
  88. package/src/templates/Sections/Site.latte +141 -0
  89. package/src/templates/Sections/Ui/Docs/@intro.html +13 -62
  90. package/src/templates/Sections/Ui/Docs/@nav.html +41 -92
  91. package/src/templates/Sections/Ui/Docs/@styles.html +2 -6
  92. package/src/templates/Sections/Ui/Docs/Default.latte +1059 -0
  93. package/src/templates/Sections/Ui/Icons.html +11 -9
  94. package/src/templates/Sections/Ui/Intro.html +66 -37
  95. package/src/templates/Sections/Ui.latte +8 -0
  96. package/src/templates/Ui/+.latte +5 -0
  97. package/src/templates/Ui/Check.latte +7 -0
  98. package/src/templates/Ui/Control.latte +9 -0
  99. package/src/templates/Ui/ControlDate.latte +14 -0
  100. package/src/templates/Ui/ControlSelect.latte +9 -0
  101. package/src/templates/Ui/ControlTime.latte +14 -0
  102. package/src/templates/Utils/sections.latte +3 -0
  103. package/src/views/dialog/basic.json.latte +5 -0
  104. package/src/views/dropdown/{tippy.json.twig → tippy.json.latte} +7 -4
  105. package/src/views/email/email.latte +6 -0
  106. package/src/views/email/email.test.latte +6 -0
  107. package/src/views/gdpr.json +1 -1
  108. package/src/views/index.json +1 -1
  109. package/src/views/site.json +11 -0
  110. package/src/views/ui-icons.json +1 -1
  111. package/src/views/ui.json +1 -1
  112. package/vite.config.js +2 -8
  113. package/src/scripts/Libraries/Anchor.js +0 -35
  114. package/src/scripts/Libraries/NativeSlider.js +0 -138
  115. package/src/scripts/Libraries/Tabs.js +0 -16
  116. package/src/scripts/Ui/Checkbox.js +0 -10
  117. package/src/scripts/Ui/Input.js +0 -259
  118. package/src/scripts/Ui/Select.js +0 -53
  119. package/src/scripts/Utils/Functions/checkValidity.js +0 -44
  120. package/src/scripts/Utils/Functions/dataValue.js +0 -52
  121. package/src/styles/Components/Form/+.css +0 -1
  122. package/src/styles/Components/Form/CookieConsent.css +0 -31
  123. package/src/styles/Libraries/NativeSlider.css +0 -60
  124. package/src/styles/Libraries/Tabs.css +0 -19
  125. package/src/styles/Ui/Checkbox.css +0 -150
  126. package/src/styles/Ui/Icon.css +0 -33
  127. package/src/styles/Ui/Input.css +0 -467
  128. package/src/styles/Ui/Radio.css +0 -4
  129. package/src/styles/Ui/Select.css +0 -137
  130. package/src/styles/Utils/normalize.css +0 -223
  131. package/src/styles/Utils/tailwind/+.css +0 -3
  132. package/src/styles/Utils/tailwind/base.css +0 -3
  133. package/src/styles/Utils/tailwind/gutters.css +0 -346
  134. package/src/styles/Utils/vars.css +0 -91
  135. package/src/styles/Utils/vendor.css +0 -2
  136. package/src/templates/Components/CookieConsent.twig +0 -30
  137. package/src/templates/Layout/Main.twig +0 -49
  138. package/src/templates/Sections/Gdpr.twig +0 -64
  139. package/src/templates/Sections/Ui/Docs/Default.twig +0 -1600
  140. package/src/templates/Sections/Ui.twig +0 -8
  141. package/src/templates/Utils/sections.twig +0 -3
  142. package/src/views/dialog/basic.json.twig +0 -3
  143. package/src/views/email/email.twig +0 -6
  144. /package/src/{templates/Layout/Footer.twig → emails/templates/.gitkeep} +0 -0
@@ -1,13 +1,13 @@
1
1
  import { LibStimulus, Controller } from './Stimulus.js'
2
- import { checkValidity } from '../Utils/Functions/+.js'
2
+ import { inputValidity } from '../Utils/Functions/+.js'
3
3
 
4
4
  LibStimulus.register('lib-form', class extends Controller {
5
- connect() {
5
+ connect () {
6
6
  this.element.setAttribute('novalidate', '')
7
7
  this.element.addEventListener('submit', e => this.validation(e))
8
8
  }
9
9
 
10
- validation(e) {
10
+ validation (e) {
11
11
  if (this.element.checkValidity() === false) {
12
12
  e.preventDefault()
13
13
  e.stopPropagation()
@@ -15,19 +15,12 @@ LibStimulus.register('lib-form', class extends Controller {
15
15
  this.element.querySelector(':invalid').scrollIntoView({ behavior: 'smooth', block: 'center' })
16
16
  this.element.querySelector(':invalid').focus()
17
17
  } else {
18
- this.element.querySelector('[type="submit"]')._addDataValue('state', 'loading')
18
+ this.element.querySelector('[type="submit"]').classList.add('loading')
19
19
  }
20
20
 
21
- this.element.querySelectorAll('.ui-input, [data-controller="ui-checkbox"], [data-controller="ui-radio"]').forEach(element => {
22
- checkValidity(element, { message: true })
21
+ this.element.querySelectorAll('.ui-control, .ui-check, .ui-switch').forEach(element => {
22
+ console.log(element)
23
+ inputValidity(element, { message: true })
23
24
  })
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 }))
32
25
  }
33
26
  })
@@ -2,13 +2,13 @@ import naja from 'naja'
2
2
  import { Controller, LibStimulus, loadStimulus } from './Stimulus.js'
3
3
 
4
4
  LibStimulus.register('lib-naja', class extends Controller {
5
- async connect() {
5
+ async connect () {
6
6
  naja.uiHandler.addEventListener('interaction', ({ detail }) => {
7
7
  const element = detail.element
8
8
 
9
9
  detail.options.target = element
10
10
 
11
- element.dispatchEvent(new CustomEvent('naja-interaction', { bubbles: true, cancelable: true }))
11
+ element.dispatchEvent(new CustomEvent('naja:interaction', { bubbles: true, cancelable: true }))
12
12
 
13
13
  if (element?.form && !element.form.reportValidity()) {
14
14
  arguments[0].preventDefault()
@@ -16,7 +16,7 @@ LibStimulus.register('lib-naja', class extends Controller {
16
16
  })
17
17
 
18
18
  naja.snippetHandler.addEventListener('afterUpdate', ({ detail }) => {
19
- detail?.options.target.dispatchEvent(new CustomEvent('naja-afterUpdate', { bubbles: true, cancelable: true }))
19
+ detail?.options.target.dispatchEvent(new CustomEvent('naja:afterUpdate', { bubbles: true, cancelable: true }))
20
20
 
21
21
  loadStimulus(document.body, false)
22
22
  })
@@ -27,9 +27,7 @@ LibStimulus.register('lib-naja', class extends Controller {
27
27
  })
28
28
  }
29
29
 
30
- async fetch({ currentTarget }) {
31
- arguments[0].preventDefault()
32
-
33
- await naja.makeRequest('GET', currentTarget.dataset.actionUrl, null, { history: false })
30
+ async get ({ params }) {
31
+ await naja.makeRequest('GET', params.url, params.data ? JSON.parse(params.data) : null, { history: params.history ?? false })
34
32
  }
35
33
  })
@@ -9,11 +9,11 @@ LibStimulus.register('lib-recaptcha', class extends Controller {
9
9
  action: String
10
10
  }
11
11
 
12
- connect() {
12
+ connect () {
13
13
  importScript(cdn.recaptcha.replace('{apikey}', this.apiValue))
14
14
  }
15
15
 
16
- async execute() {
16
+ async execute () {
17
17
  return new Promise(resolve => {
18
18
  window.grecaptcha.enterprise.ready(() => {
19
19
  window.grecaptcha.enterprise.execute(this.apiValue, { action: this.actionValue ?? 'form' }).then(token => {
@@ -24,7 +24,7 @@ LibStimulus.register('lib-recaptcha', class extends Controller {
24
24
  })
25
25
  }
26
26
 
27
- async submit() {
27
+ async submit ({ params }) {
28
28
  if (this.element.reportValidity() === false) {
29
29
  return false
30
30
  }
@@ -32,16 +32,11 @@ LibStimulus.register('lib-recaptcha', class extends Controller {
32
32
  arguments[0].preventDefault()
33
33
 
34
34
  await this.execute()
35
- this.element.submit()
36
- }
37
35
 
38
- async submitFetch() {
39
- if (this.element.reportValidity() === false) {
40
- return false
36
+ if (!params.naja) {
37
+ this.element.submit()
38
+ } else {
39
+ await naja.makeRequest(this.element.method, this.element.action, new FormData(this.element), { history: 'replace' })
41
40
  }
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
41
  }
47
42
  })
@@ -1,24 +1,8 @@
1
- const LibRipple = ({ currentTarget, layerX, layerY }) => {
2
- const container = currentTarget
1
+ import { Controller, LibStimulus } from './Stimulus.js'
2
+ import { showRipple } from 'winduum/src/libraries/ripple.js'
3
3
 
4
- if (container.querySelector('.lib-ripple') === null) {
5
- container.insertAdjacentHTML('beforeend', "<div class='lib-ripple'></div>")
4
+ LibStimulus.register('lib-ripple', class extends Controller {
5
+ async show (e) {
6
+ showRipple(e)
6
7
  }
7
-
8
- const ink = container.querySelector('.lib-ripple')
9
-
10
- ink.classList.remove('animation')
11
-
12
- if (ink.clientWidth === 0 && ink.clientHeight === 0) {
13
- const d = Math.max(container.offsetWidth, container.offsetHeight)
14
-
15
- ink.style.width = d + 'px'
16
- ink.style.height = d + 'px'
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')
22
- }
23
-
24
- export default LibRipple
8
+ })
@@ -1,7 +1,7 @@
1
1
  import { LibStimulus, Controller } from './Stimulus.js'
2
2
 
3
3
  LibStimulus.register('lib-script', class extends Controller {
4
- connect() {
4
+ connect () {
5
5
  const element = this.element
6
6
  const script = document.createElement('script')
7
7
 
@@ -12,7 +12,6 @@ LibStimulus.register('lib-script', class extends Controller {
12
12
  })
13
13
 
14
14
  script.innerHTML = element.innerHTML
15
-
16
15
  element.parentElement.appendChild(script)
17
16
  element.remove()
18
17
  }
@@ -0,0 +1,160 @@
1
+ const defaultOptions = {
2
+ behavior: 'smooth',
3
+ init: {
4
+ pauseSelector: [],
5
+ paginationSelector: null,
6
+ paginationItemClass: null,
7
+ progressSelector: null,
8
+ counterMinSelector: null,
9
+ counterMaxSelector: null,
10
+ autoplay: false
11
+ }
12
+ }
13
+
14
+ export const prevSlide = (selector) => {
15
+ selector.scroll({ left: selector.scrollLeft - selector.children[0].clientWidth, behavior: defaultOptions.behavior })
16
+ }
17
+
18
+ export const nextSlide = (selector) => {
19
+ selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth, behavior: defaultOptions.behavior })
20
+ }
21
+
22
+ export const selectSlide = (selector, selected = 0) => {
23
+ const position = selector.scrollLeft / selector.children[0].clientWidth
24
+
25
+ if (position - selected <= 0) {
26
+ selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth * (selected - 1 - position), behavior: defaultOptions.behavior })
27
+ } else {
28
+ selector.scroll({ left: selector.scrollLeft - selector.children[0].clientWidth * (position - selected + 1), behavior: defaultOptions.behavior })
29
+ }
30
+ }
31
+
32
+ export const initSlider = (selector, options = defaultOptions.init) => {
33
+ let isDown; let paused; let startX; let scrollLeft = null
34
+
35
+ function isElementInViewport (element) {
36
+ const rect = element.getBoundingClientRect()
37
+ const sliderRect = selector.getBoundingClientRect()
38
+
39
+ return (
40
+ rect.left >= sliderRect.left &&
41
+ rect.right <= sliderRect.right
42
+ )
43
+ }
44
+
45
+ function setProgressValue () {
46
+ if (options.progressSelector) {
47
+ options.progressSelector.value = ((selector.scrollLeft + selector.clientWidth) / selector.scrollWidth * 100).toFixed(2)
48
+ }
49
+ }
50
+
51
+ if (!selector.classList.contains('is-fade')) {
52
+ const grabbing = () => {
53
+ isDown = false
54
+ paused = false
55
+ selector.classList.remove('is-grabbing')
56
+ selector.scrollLeft = selector.scrollLeft - 1
57
+ }
58
+
59
+ selector.addEventListener('mouseleave', grabbing)
60
+
61
+ selector.addEventListener('mouseup', grabbing)
62
+
63
+ selector.addEventListener('mousedown', ({ pageX }) => {
64
+ isDown = true
65
+ paused = true
66
+ startX = pageX - selector.offsetLeft
67
+ scrollLeft = selector.scrollLeft
68
+ })
69
+
70
+ selector.addEventListener('mousemove', e => {
71
+ if (!isDown) return
72
+ e.preventDefault()
73
+ const x = e.pageX - selector.offsetLeft
74
+ const walk = (x - startX) * 1.25
75
+
76
+ selector.classList.add('is-grabbing')
77
+ selector.scrollLeft = scrollLeft - walk
78
+
79
+ selector.ondragstart = dragEvent => dragEvent.preventDefault()
80
+ })
81
+ }
82
+
83
+ const itemsCount = selector.clientWidth > selector.children[0].clientWidth
84
+ ? [...selector.children].reduce((item, children) =>
85
+ (selector.scrollWidth - selector.clientWidth > item.itemsWidth + children.clientWidth / 2)
86
+ ? { itemsWidth: item.itemsWidth + children.clientWidth, count: item.count + 1 }
87
+ : item, { itemsWidth: 0, count: 0 }).count + 1
88
+ : Math.ceil((selector.scrollWidth) / selector.children[0].clientWidth)
89
+
90
+ if (options.counterMinSelector) {
91
+ options.counterMinSelector.textContent = 1
92
+ }
93
+
94
+ if (options.counterMaxSelector) {
95
+ options.counterMaxSelector.textContent = itemsCount
96
+ }
97
+
98
+ if (options.paginationSelector) {
99
+ options.paginationSelector.insertAdjacentHTML('beforeend', [...Array(itemsCount)].map((_, i) => `
100
+ <div class="${options.paginationItemClass ?? ''}${i === 0 ? ' active' : ''}"></div>
101
+ `).join(''))
102
+
103
+ ;[...options.paginationSelector.children].forEach((children) => {
104
+ children.addEventListener('click', ({ currentTarget }) => {
105
+ selectSlide(selector, [...options.paginationSelector.children].indexOf(currentTarget) + 1)
106
+ })
107
+ })
108
+ }
109
+
110
+ setProgressValue()
111
+
112
+ selector.addEventListener('scroll', () => {
113
+ const activeSlide = parseInt((selector.scrollLeft / selector.children[0].clientWidth).toFixed(0))
114
+
115
+ for (const children of [...selector.children]) {
116
+ if (isElementInViewport(children)) {
117
+ children.classList.add('active')
118
+ } else {
119
+ children.classList.remove('active')
120
+ }
121
+ }
122
+
123
+ if (options.paginationSelector) {
124
+ [...options.paginationSelector.children].forEach(children => children.classList.remove('active'))
125
+
126
+ options.paginationSelector.children[activeSlide].classList.add('active')
127
+ }
128
+
129
+ setProgressValue()
130
+
131
+ if (options.counterMinSelector) {
132
+ options.counterMinSelector.textContent = activeSlide + 1
133
+ }
134
+ }, { passive: true })
135
+
136
+ if (options.progressSelector) {
137
+ options.progressSelector.addEventListener('click', ({ clientX, target }) => {
138
+ selector.scrollLeft = (selector.scrollWidth / 100) * (clientX - target.offsetLeft) / target.clientWidth * 100
139
+ })
140
+ }
141
+
142
+ ;[...options.pauseSelector, options.progressSelector, options.paginationSelector, selector].forEach(element => {
143
+ if (typeof element !== 'undefined' && element !== null) {
144
+ element.addEventListener('mouseenter', () => (paused = true))
145
+ element.addEventListener('mouseleave', () => (paused = false))
146
+ }
147
+ })
148
+
149
+ if (options.autoplay && !isNaN(options.autoplay)) {
150
+ setInterval(() => {
151
+ if (!paused) {
152
+ if (selector.scrollLeft < selector.children[0].clientWidth * (selector.children.length - 1)) {
153
+ selector.scroll({ left: selector.scrollLeft + selector.children[0].clientWidth, behavior: self.behavior })
154
+ } else {
155
+ selector.scroll({ left: 0, behavior: options.behavior })
156
+ }
157
+ }
158
+ }, options.autoplay)
159
+ }
160
+ }
@@ -2,7 +2,6 @@ import { Application, Controller } from '@hotwired/stimulus'
2
2
  import loadStimulus from '../Utils/Functions/loadStimulus.js'
3
3
 
4
4
  const LibStimulus = new Application(document.documentElement)
5
-
6
5
  const getController = (element, identifier) => LibStimulus.getControllerForElementAndIdentifier(element, identifier)
7
6
 
8
7
  LibStimulus.start().then(() => loadStimulus(document.body))
@@ -1,30 +1,50 @@
1
1
  import Swup from 'swup'
2
- import { getController, loadStimulus } from './Stimulus.js'
3
2
  import { closeDialog } from 'winduum/src/libraries/dialog.js'
4
- import LibAnchor from './Anchor.js'
3
+ import { hideTippy } from './Tippy.js'
4
+ import { getController, loadStimulus } from './Stimulus.js'
5
5
  import LibCookieConsent from './CookieConsent.js'
6
- import replaceTag from '../Utils/Functions/replaceTag.js'
6
+ import { replaceTag, replaceScript } from '../Utils/Functions/+.js'
7
+
8
+ document.addEventListener('click', ({ target }) => {
9
+ const noSwup = target.closest('[data-no-swup]')
10
+
11
+ if (!noSwup) {
12
+ return
13
+ }
14
+
15
+ if (noSwup.classList.contains('ui-btn')) {
16
+ noSwup.classList.add('loading')
17
+ } else {
18
+ noSwup.classList.add('cursor-wait')
19
+ }
20
+ })
7
21
 
8
22
  const LibSwup = new Swup({
9
23
  containers: ['#l-main', '#l-header'].filter(element => document.querySelector(element)),
10
24
  linkSelector: `:is(a[href^="${window.location.origin}"], a[href^="/"]):not([data-no-swup], [data-naja], [target="_blank"])`
11
25
  })
12
26
 
13
- LibSwup.on('clickLink', async({ target }) => {
27
+ LibSwup.on('clickLink', async ({ target }) => {
14
28
  document.body.classList.remove('overflow-hidden')
15
29
 
16
- if (document.querySelector('.lib-drawer[data-state~="active"]') !== null) {
30
+ const LibDrawerSelector = document.querySelector('.lib-drawer.active')
31
+ const LibDialogSelector = document.querySelector('.lib-dialog')
32
+
33
+ hideTippy()
34
+
35
+ if (LibDrawerSelector) {
17
36
  /** @type {LibDrawer} */
18
- const LibDrawer = getController(document.body, 'lib-drawer')
37
+ const LibDrawer = getController(LibDrawerSelector, 'lib-drawer')
38
+
19
39
  LibDrawer.hide()
20
40
  }
21
41
 
22
- if (document.querySelector('.lib-dialog') !== null) {
23
- await closeDialog()
42
+ if (LibDialogSelector) {
43
+ await closeDialog(LibDialogSelector)
24
44
  }
25
45
 
26
46
  if (window.location.href === target.closest('a').href) {
27
- document.documentElement.scroll({ top: 0 })
47
+ document.documentElement.scroll({ top: 0, behavior: 'smooth' })
28
48
  }
29
49
  })
30
50
 
@@ -44,11 +64,15 @@ LibSwup.on('contentReplaced', () => {
44
64
 
45
65
  replaceTag(content)
46
66
 
47
- LibAnchor.init()
67
+ if (window.location.hash) {
68
+ document.documentElement.scroll({ top: document.querySelector(`${window.location.hash}`)?.offsetTop, behavior: 'smooth' })
69
+ }
70
+
48
71
  LibCookieConsent.init()
49
72
 
50
73
  LibSwup.options.containers.forEach(selector => {
51
74
  loadStimulus(document.querySelector(selector))
75
+ replaceScript(document.querySelector(selector))
52
76
  })
53
77
 
54
78
  window.dataLayer && window.dataLayer.push({
@@ -61,4 +85,8 @@ LibSwup.on('contentReplaced', () => {
61
85
  window.fbq && window.fbq('track', 'PageView')
62
86
  })
63
87
 
88
+ LibSwup.options.cache && setInterval(() => {
89
+ LibSwup.cache.empty()
90
+ }, 90 * 1000)
91
+
64
92
  export default LibSwup
@@ -2,7 +2,7 @@ import { loadStimulus, importStyle } from '../Utils/Functions/+.js'
2
2
  import cdn from '../Utils/cdn.js'
3
3
 
4
4
  export default class LibTippy {
5
- async init(element, options, template) {
5
+ async init (element, options, template) {
6
6
  const tippy = (await import('tippy.js')).default
7
7
  const { roundArrow } = await import('tippy.js')
8
8
 
@@ -14,7 +14,6 @@ export default class LibTippy {
14
14
 
15
15
  if (this.type.includes('dropdown')) {
16
16
  this.options.placement = 'bottom-end'
17
- this.options.arrow = false
18
17
  this.options.maxWidth = 'none'
19
18
  }
20
19
 
@@ -28,7 +27,7 @@ export default class LibTippy {
28
27
  } else {
29
28
  options.content = `
30
29
  <div class="c-dropdown">
31
- <div class="wrp_dropdown_body">
30
+ <div class="c_dropdown_body">
32
31
  ${element.getAttribute('aria-label')}
33
32
  </div>
34
33
  </div>
@@ -36,16 +35,16 @@ export default class LibTippy {
36
35
  }
37
36
  }
38
37
 
39
- if (typeof element.dataset.libTippySlot !== 'undefined') {
38
+ if (element.dataset.libTippySlot) {
40
39
  for (const [key, value] of Object.entries(JSON.parse(element.dataset.libTippySlot))) {
41
- options.content = options.content.replaceAll(`{${key}}`, value).replaceAll(`%7B${key}%7B`, value)
40
+ options.content = options.content.replaceAll(`{${key}}`, value.toString()).replaceAll(`%7B${key}%7B`, value.toString())
42
41
  }
43
42
  }
44
43
 
45
44
  tippy(element, options)
46
45
  }
47
46
 
48
- constructor(element, attributes = ['tooltip', '']) {
47
+ constructor (element, attributes = ['tooltip', '']) {
49
48
  const self = this
50
49
 
51
50
  this.options = {
@@ -55,29 +54,22 @@ export default class LibTippy {
55
54
  interactive: true,
56
55
  appendTo: 'parent',
57
56
  arrow: false,
58
- theme: 'light-border',
59
57
  animation: 'scale',
60
58
  inertia: true,
61
59
  allowHTML: true,
62
60
  onShow: (instance) => {
63
- let name = this.template
64
-
65
61
  if (this.type.includes('-full')) {
66
62
  instance.popper.classList.add('is-full')
67
- document.documentElement.classList.add('m:is-body-overlay')
68
- }
69
-
70
- if (typeof name === 'undefined') {
71
- name = this.type
63
+ document.documentElement.classList.add('max-md:is-body-overlay')
72
64
  }
73
65
 
74
- instance.popper.querySelector('.tippy-box').setAttribute('data-name', name)
66
+ instance.popper.querySelector('.tippy-box').setAttribute('data-name', this.template ?? this.type)
75
67
 
76
68
  loadStimulus(instance.popper.querySelector('.tippy-content'))
77
69
  },
78
70
  onHide: () => {
79
71
  if (this.type.includes('-full')) {
80
- setTimeout(() => document.documentElement.classList.remove('m:is-body-overlay'), 50)
72
+ setTimeout(() => document.documentElement.classList.remove('max-md:is-body-overlay'), 50)
81
73
  }
82
74
  }
83
75
  }
@@ -96,17 +88,18 @@ export default class LibTippy {
96
88
  this.options.showOnCreate = true
97
89
 
98
90
  this.options.trigger !== 'manual' && this.options.trigger.split(' ').forEach(event => {
99
- element.addEventListener(event, async function e() {
91
+ element.addEventListener(event, async function e () {
100
92
  if (self.template.startsWith('/') && self.options.content === '') {
101
93
  element.style.cursor = 'wait'
102
- element._addDataValue('state', 'loading')
94
+ element.classList.add('loading')
103
95
 
104
96
  fetch(self.template, { headers: { 'X-Requested-With': 'XMLHttpRequest' } }).then(response => {
105
97
  return response.json()
106
- }).then(async(data) => {
98
+ }).then(async data => {
107
99
  self.options.content = data.content
108
100
  element.style.cursor = ''
109
- element._removeDataValue('state', 'loading')
101
+ element.classList.remove('loading')
102
+
110
103
  await self.init(element, self.options, self.template)
111
104
  element.removeEventListener(event, e)
112
105
  })
@@ -118,3 +111,7 @@ export default class LibTippy {
118
111
  })
119
112
  }
120
113
  }
114
+
115
+ export function hideTippy () {
116
+ document.querySelectorAll('[data-controller~="lib-tippy"][aria-expanded="true"]').forEach(element => element?._tippy?.hide())
117
+ }
@@ -1,4 +1,4 @@
1
- import './Checkbox.js'
2
- import './Input.js'
3
- import './Select.js'
1
+ import './Check.js'
2
+ import './Control.js'
3
+ import './ControlSelect.js'
4
4
  import './Text.js'
@@ -0,0 +1,8 @@
1
+ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
2
+ import { inputValidity } from '../Utils/Functions/+.js'
3
+
4
+ LibStimulus.register('ui-check', class extends Controller {
5
+ validity ({ currentTarget }) {
6
+ inputValidity(currentTarget)
7
+ }
8
+ })