@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
@@ -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/utilities/ripple/index.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(event) {
6
+ showRipple(event)
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,12 +1,56 @@
1
1
  import { Application, Controller } from '@hotwired/stimulus'
2
- import loadStimulus from '../Utils/Functions/loadStimulus.js'
2
+ import { dataset } from '@newlogic-digital/utils-js'
3
+
4
+ function initActions(parent, selectors) {
5
+ if (!parent) return
6
+
7
+ selectors.forEach(([selector, action]) => {
8
+ parent.querySelectorAll(selector).forEach((element) => {
9
+ dataset(element, 'action').add(action)
10
+ })
11
+ })
12
+ }
13
+
14
+ function initControllers(parent, selectors) {
15
+ if (!parent) return
16
+
17
+ selectors.forEach((selector) => {
18
+ [...parent.getElementsByClassName(selector)].forEach((element) => {
19
+ dataset(element, 'controller').add(selector)
20
+ })
21
+ })
22
+ }
23
+
24
+ function initStimulus(element, { controllers, actions } = {
25
+ controllers: ['ui-control', 'ui-text', 'ui-check'],
26
+ actions: [['.ui-btn', 'click->lib-ripple#show'], ['.ui-check', 'change->ui-check#validate']]
27
+ }) {
28
+ initControllers(element, controllers)
29
+ initActions(element, actions)
30
+ }
3
31
 
4
32
  const LibStimulus = new Application(document.documentElement)
5
33
 
6
- const getController = (element, identifier) => LibStimulus.getControllerForElementAndIdentifier(element, identifier)
34
+ const getController = (...arg) => LibStimulus.getControllerForElementAndIdentifier(...arg)
35
+
36
+ const delegateController = (name, method, event = {}, selector) => {
37
+ const controller = getController(document.querySelector(selector || `.${name}`), name)
38
+
39
+ if (controller) return method ? controller[method](event) : controller
40
+ }
41
+
42
+ LibStimulus.start().then(() => initStimulus(document.body))
43
+
44
+ LibStimulus.register('controller', class extends Controller {
45
+ delegate(event) {
46
+ delegateController(event.params.name, event.params.method, event, event.params.selector)
47
+ }
7
48
 
8
- LibStimulus.start().then(() => loadStimulus(document.body))
49
+ load({ currentTarget, params }) {
50
+ dataset(currentTarget, 'controller').add(params.name)
51
+ }
52
+ })
9
53
 
10
- window.LibStimulus = { default: LibStimulus, Controller, loadStimulus }
54
+ window.LibStimulus = { default: LibStimulus, Controller, initStimulus, delegateController }
11
55
 
12
- export { LibStimulus, Controller, loadStimulus, getController }
56
+ export { LibStimulus, Controller, initStimulus, getController, delegateController }
@@ -1,35 +1,25 @@
1
+ import { dialogSelector } from 'winduum/src/components/dialog/index.js'
2
+ import { delegateController } from './Stimulus.js'
1
3
  import Swup from 'swup'
2
- import { getController, loadStimulus } from './Stimulus.js'
3
- import { closeDialog } from 'winduum/src/libraries/dialog.js'
4
- import LibAnchor from './Anchor.js'
5
- import LibCookieConsent from './CookieConsent.js'
6
- import replaceTag from '../Utils/Functions/replaceTag.js'
4
+ import initAfter from '../Utils/initAfter.js'
7
5
 
8
6
  const LibSwup = new Swup({
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"])`
7
+ containers: ['.l-main', '.l-header'].filter(element => document.querySelector(element)),
8
+ ignoreVisit: (url, { el }) => el?.closest('[data-no-swup], [data-naja]'),
9
+ animationSelector: '.swup-transition'
11
10
  })
12
11
 
13
- LibSwup.on('clickLink', async({ target }) => {
12
+ LibSwup.hooks.on('animation:out:start', async () => {
14
13
  document.body.classList.remove('overflow-hidden')
15
14
 
16
- if (document.querySelector('.lib-drawer[data-state~="active"]') !== null) {
17
- /** @type {LibDrawer} */
18
- const LibDrawer = getController(document.body, 'lib-drawer')
19
- LibDrawer.hide()
20
- }
21
-
22
- if (document.querySelector('.lib-dialog') !== null) {
23
- await closeDialog()
24
- }
25
-
26
- if (window.location.href === target.closest('a').href) {
27
- document.documentElement.scroll({ top: 0 })
28
- }
15
+ delegateController('c-drawer', 'close')
16
+ delegateController('lib-dialog', 'close', {
17
+ currentTarget: dialogSelector('.c-dialog')
18
+ }, 'body')
29
19
  })
30
20
 
31
- LibSwup.on('animationOutDone', () => {
32
- document.documentElement.scroll({ top: 0, behavior: 'instant' })
21
+ LibSwup.hooks.before('scroll:top', (visit, { options }) => {
22
+ if (visit.from.url !== visit.to.url) (options.behavior = 'instant')
33
23
  })
34
24
 
35
25
  /** @var {Array} dataLayer */
@@ -39,26 +29,49 @@ LibSwup.on('animationOutDone', () => {
39
29
  /** @var {Object} retargetingConf */
40
30
  /** @var {Object} conversionConf */
41
31
  /** @var {Function} fbq */
42
- LibSwup.on('contentReplaced', () => {
43
- const content = new DOMParser().parseFromString(LibSwup.cache.getCurrentPage().originalContent, 'text/html')
32
+ LibSwup.hooks.on('content:replace', (visit, { page }) => {
33
+ const content = new DOMParser().parseFromString(page.html, 'text/html')
44
34
 
45
- replaceTag(content)
35
+ content.querySelectorAll('[data-lib-replace-tag]').forEach((element) => {
36
+ const replaceTag = document.querySelector(`[data-lib-replace-tag="${element.dataset.libReplaceTag}"]`)
37
+ const placement = element.closest('head') ? document.head : replaceTag.parentElement
46
38
 
47
- LibAnchor.init()
48
- LibCookieConsent.init()
39
+ replaceTag ? (replaceTag.outerHTML = element.outerHTML) : placement.insertAdjacentHTML('beforeend', element.outerHTML)
40
+ })
49
41
 
50
- LibSwup.options.containers.forEach(selector => {
51
- loadStimulus(document.querySelector(selector))
42
+ LibSwup.options.containers.forEach((selector) => {
43
+ initAfter(document.querySelector(selector))
52
44
  })
53
45
 
54
46
  window.dataLayer && window.dataLayer.push({
55
47
  event: 'page_view'
56
48
  })
57
49
 
58
- window.rc?.retargetingHit && window.rc.retargetingHit(window.retargetingConf)
59
- window.rc?.conversionHit && window.rc.conversionHit(window.conversionConf)
50
+ window.rc?.retargetingHit && window.rc.retargetingHit(window.retargetingConf ?? {})
51
+ window.rc?.conversionHit && window.rc.conversionHit(window.conversionConf ?? {})
60
52
 
61
53
  window.fbq && window.fbq('track', 'PageView')
62
54
  })
63
55
 
56
+ LibSwup.hooks.on('cache:set', (visit, { page }) => {
57
+ LibSwup.cache.update(page.url, { created: Date.now(), ttl: 1000 * 60 })
58
+ })
59
+
60
+ LibSwup.hooks.before('page:load', () => {
61
+ // noinspection JSCheckFunctionSignatures
62
+ LibSwup.cache.prune((url, { created, ttl }) => Date.now() > created + ttl)
63
+ })
64
+
65
+ document.addEventListener('click', ({ target }) => {
66
+ const noSwup = target.closest('[data-no-swup]')
67
+
68
+ if (!noSwup) return
69
+
70
+ if (noSwup.classList.contains('ui-btn')) {
71
+ noSwup.classList.add('loading')
72
+ } else {
73
+ noSwup.classList.add('cursor-wait')
74
+ }
75
+ })
76
+
64
77
  export default LibSwup
@@ -0,0 +1,55 @@
1
+ import { Controller, LibStimulus } from '../Libraries/Stimulus.js'
2
+
3
+ export const insertToaster = async (element, options) => {
4
+ if (!document.querySelector('.c-toaster')) {
5
+ element.insertAdjacentHTML('beforeend', `<ol class="c-toaster ${options?.classes ?? ''}" data-lib-toaster-target="toaster"></ol>`)
6
+ }
7
+ }
8
+
9
+ export const insertToast = async (element, options) => {
10
+ const { showToast } = await import('winduum/src/components/toaster/index.js')
11
+
12
+ element.insertAdjacentHTML('beforeend', `
13
+ <li class="c-toast ${options.classes ?? ''}" role="status" aria-live="assertive" aria-atomic="true" data-controller="c-toast">
14
+ <div class="c-toast-content border-main/10">
15
+ <div class="flex-col gap-0.5">
16
+ <div class="ui-title empty:hidden">${options.title ?? ''}</div>
17
+ <div class="ui-title sm font-normal empty:hidden text-main/70">${options.text ?? ''}</div>
18
+ </div>
19
+ <button class="ui-btn sm circle muted ml-auto accent-main -mr-1" data-action="c-toast#close">
20
+ <svg class="size-4">
21
+ <use href="#icon-x-mark"></use>
22
+ </svg>
23
+ </button>
24
+ </div>
25
+ </li>
26
+ `)
27
+
28
+ await showToast(element.children[element.children.length - 1], {
29
+ autoHide: false,
30
+ ...options?.show
31
+ })
32
+ }
33
+
34
+ LibStimulus.register('lib-toaster', class extends Controller {
35
+ static targets = ['toaster', 'show']
36
+
37
+ async show({ params }) {
38
+ await insertToaster(document.querySelector('dialog[open]') || document.body)
39
+ await insertToast(this.toasterTarget, params)
40
+ }
41
+
42
+ async showTargetConnected(element) {
43
+ await this.show({
44
+ params: JSON.parse(element.innerHTML)
45
+ })
46
+ }
47
+ })
48
+
49
+ LibStimulus.register('c-toast', class extends Controller {
50
+ async close() {
51
+ const { closeToast } = await import('winduum/src/components/toaster/index.js')
52
+
53
+ await closeToast(this.element)
54
+ }
55
+ })
@@ -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 { validateField } from 'winduum/src/components/form/index.js'
3
+
4
+ LibStimulus.register('ui-check', class extends Controller {
5
+ async validate({ currentTarget }) {
6
+ validateField(currentTarget)
7
+ }
8
+ })
@@ -0,0 +1,194 @@
1
+ import cdn from '../Utils/cdn.js'
2
+ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
3
+ import { importStyle } from '@newlogic-digital/utils-js'
4
+ import { validateField } from 'winduum/src/components/form/index.js'
5
+
6
+ LibStimulus.register('ui-control', class extends Controller {
7
+ static targets = ['number']
8
+
9
+ static values = {
10
+ dateOptions: {
11
+ default: {},
12
+ type: Object
13
+ },
14
+ dateDisabled: {
15
+ default: [],
16
+ type: Array
17
+ }
18
+ }
19
+
20
+ async connect() {
21
+ validateField(this.element, { validate: false })
22
+
23
+ this.element.addEventListener('change', () => validateField(this.element))
24
+
25
+ if (this.element.querySelector('select')) {
26
+ return
27
+ }
28
+
29
+ this.typeNumber()
30
+
31
+ await this.typeDate()
32
+
33
+ await this.typeColor()
34
+ }
35
+
36
+ async typeDate() {
37
+ const input = this.element.querySelector('[type^="date"], [type="month"]')
38
+
39
+ if (input) {
40
+ const AirDatepicker = (await import('air-datepicker')).default
41
+ const localeUrl = cdn.datepickerLang
42
+ const locale = (await import(/* @vite-ignore */ localeUrl)).default.default
43
+ const minDate = input.min ?? ''
44
+ const maxDate = input.max ?? ''
45
+ const timepicker = input.type === 'datetime-local'
46
+ const monthView = input.type === 'month'
47
+ ? {
48
+ view: 'months',
49
+ minView: 'months',
50
+ dateFormat: 'MMMM yyyy',
51
+ altFieldDateFormat: 'yyyy-MM'
52
+ }
53
+ : {}
54
+
55
+ const attributes = [...input.attributes].filter(({ name }) => name.match(/(required|placeholder)/)).map(({ name, value }) => `${name}="${value}"`).join(' ')
56
+
57
+ input.setAttribute('type', 'hidden')
58
+
59
+ input.insertAdjacentHTML('afterend', `<input type="text" inputmode="none" ${attributes}>`)
60
+
61
+ const inputText = this.element.querySelector('[type="text"]')
62
+
63
+ if (input.id) {
64
+ inputText.id = input.id + '-datepicker'
65
+ }
66
+
67
+ inputText.addEventListener('keydown', (e) => {
68
+ const key = e.key.toLowerCase()
69
+
70
+ if (key !== 'backspace' && key !== 'tab') {
71
+ e.preventDefault()
72
+ } else if (key === 'backspace') {
73
+ this.datepicker.clear()
74
+ inputText.dispatchEvent(new Event('change', { bubbles: true }))
75
+ }
76
+ })
77
+
78
+ this.datepicker = new AirDatepicker(inputText, {
79
+ locale,
80
+ timepicker,
81
+ minDate,
82
+ maxDate,
83
+ startDate: input.value,
84
+ selectedDates: input.value,
85
+ altField: input,
86
+ autoClose: true,
87
+ container: this.element,
88
+ minutesStep: 5,
89
+ altFieldDateFormat: 'yyyy-MM-dd',
90
+ buttons: ['today', 'clear'],
91
+ ...monthView,
92
+ ...this.dateOptionsValue,
93
+ onRenderCell: ({ date, cellType }) => {
94
+ if (cellType === 'day' && this.dateDisabledValue.includes(this.datepicker.formatDate(date, 'yyyy-MM-dd'))) {
95
+ return {
96
+ disabled: true
97
+ }
98
+ }
99
+ },
100
+ onShow: () => {
101
+ this.datepicker.$datepicker.querySelectorAll('.air-datepicker-button').forEach((element) => {
102
+ element.setAttribute('type', 'button')
103
+ element.setAttribute('tabindex', '-1')
104
+ })
105
+ },
106
+ onSelect: ({ date }) => {
107
+ input.dispatchEvent(new Event('change', { bubbles: true }))
108
+ }
109
+ })
110
+ }
111
+ }
112
+
113
+ async typeColor() {
114
+ if (this.element.querySelector('[type="color"]') !== null) {
115
+ const Pickr = (await import('@simonwep/pickr')).default
116
+ const input = this.element.querySelector('input')
117
+
118
+ await importStyle(cdn.pickrCss)
119
+
120
+ input.setAttribute('inputmode', 'none')
121
+ input.setAttribute('type', 'text')
122
+ input.setAttribute('maxlength', '9')
123
+ input.setAttribute('pattern', '^#?([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$')
124
+
125
+ this.element.insertAdjacentHTML('afterbegin', '<div class="me-auto"><div class="color"></div></div>')
126
+
127
+ const pickr = new Pickr({
128
+ el: input,
129
+ useAsButton: true,
130
+ theme: 'nano',
131
+ position: 'bottom-start',
132
+ components: {
133
+ preview: true,
134
+ opacity: true,
135
+ hue: true,
136
+ interaction: {
137
+ hex: true,
138
+ rgba: true,
139
+ input: true
140
+ }
141
+ }
142
+ }).on('init', (pickr) => {
143
+ pickr.setColor(input.value)
144
+ }).on('change', (color) => {
145
+ input.value = color.toHEXA().toString()
146
+ this.element.querySelector('.color').style['background-color'] = color.toHEXA().toString()
147
+ }).on('hide', (pickr) => {
148
+ pickr.applyColor()
149
+ input.dispatchEvent(new Event('change', { bubbles: true }))
150
+ })
151
+
152
+ input.addEventListener('change', ({ target }) => {
153
+ pickr.setColor(target.value)
154
+ })
155
+ }
156
+ }
157
+
158
+ typeNumber() {
159
+ if (this.element.querySelector('[type="number"]') && !this.hasNumberTarget) {
160
+ if (!this.element.querySelector('.ms-auto')) {
161
+ this.element.insertAdjacentHTML('beforeend', '<div class="ms-auto"></div>')
162
+ }
163
+
164
+ this.element.querySelector('.ms-auto').insertAdjacentHTML('beforeend', `
165
+ <div class="flex flex-col gap-0 justify-center -space-y-1 -me-0.5" data-ui-control-target="number">
166
+ <button class="focus-visible:text-accent" type="button" data-action="click->ui-control#stepUp">
167
+ <svg class="size-4"><use href="#icon-angle-up-solid"></use></svg>
168
+ </button>
169
+ <button class="focus-visible:text-accent" type="button" data-action="click->ui-control#stepDown">
170
+ <svg class="size-4"><use href="#icon-angle-down-solid"></use></svg>
171
+ </button>
172
+ </div>
173
+ `)
174
+ }
175
+ }
176
+
177
+ stepUp() {
178
+ this.element.querySelector('input:not([hidden])').stepUp()
179
+ this.element.querySelector('input:not([hidden])').dispatchEvent(new Event('change', { bubbles: true }))
180
+ }
181
+
182
+ stepDown() {
183
+ this.element.querySelector('input:not([hidden])').stepDown()
184
+ this.element.querySelector('input:not([hidden])').dispatchEvent(new Event('change', { bubbles: true }))
185
+ }
186
+
187
+ showPicker() {
188
+ this.element.querySelector('input:not([hidden])').showPicker()
189
+ }
190
+
191
+ showDatepicker() {
192
+ this.datepicker.$el.focus()
193
+ }
194
+ })
@@ -0,0 +1,25 @@
1
+ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
2
+ import { dataset } from '@newlogic-digital/utils-js'
3
+
4
+ LibStimulus.register('ui-control-select', class extends Controller {
5
+ connect() {
6
+ this.select = this.element.querySelector('select')
7
+ const option = this.element.querySelectorAll('[data-option]')
8
+
9
+ if (option[0]) {
10
+ option.forEach((option) => {
11
+ if (option.dataset.disabled) {
12
+ return
13
+ }
14
+
15
+ dataset(option, 'action').add('click->ui-control-select#choose', 'keydown.enter->ui-control-select#choose')
16
+ })
17
+ }
18
+ }
19
+
20
+ choose({ currentTarget }) {
21
+ this.select.value = currentTarget.dataset.option
22
+ this.select.dispatchEvent(new Event('change', { bubbles: true }))
23
+ document.activeElement.blur()
24
+ }
25
+ })
@@ -2,22 +2,20 @@ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
2
2
 
3
3
  LibStimulus.register('ui-text', class extends Controller {
4
4
  connect() {
5
- this.element.querySelectorAll('table').forEach(table => {
6
- this.wrap(table, new DOMParser().parseFromString('<div class="elm_text_table"></div>', 'text/html').body.firstChild)
5
+ function wrap(element, wrapper) {
6
+ element.parentNode.insertBefore(wrapper, element)
7
+ wrapper.appendChild(element)
8
+ }
9
+
10
+ this.element.querySelectorAll('table').forEach((table) => {
11
+ wrap(table, new DOMParser().parseFromString('<div class="overflow-x-auto max-w-full"></div>', 'text/html').body.firstChild)
7
12
  })
8
13
 
9
- this.element.querySelectorAll('iframe').forEach(iframe => {
10
- if (iframe.src.match(/youtube\.com/i)) {
11
- this.wrap(iframe, new DOMParser().parseFromString(`<div class="elm_text_video" style="max-width: ${iframe.width.includes('%') ? iframe.width : iframe.width + 'px'}"></div>`, 'text/html').body.firstChild)
12
- } else if (iframe.width && iframe.style.aspectRatio !== 'undefined') {
14
+ this.element.querySelectorAll('iframe').forEach((iframe) => {
15
+ if (iframe.width && iframe.height) {
13
16
  iframe.style.aspectRatio = iframe.width + '/' + iframe.height
14
17
  iframe.style.height = 'auto'
15
18
  }
16
19
  })
17
20
  }
18
-
19
- wrap(el, wrapper) {
20
- el.parentNode.insertBefore(wrapper, el)
21
- wrapper.appendChild(el)
22
- }
23
21
  })
@@ -1,3 +1,3 @@
1
- import './Functions/+.js'
2
- export { default as cdn } from './cdn.js'
3
- import './global.js'
1
+ export { default as cdn } from './cdn.js'
2
+ export { default as initAfter } from './initAfter.js'
3
+ import './utilities.js'
@@ -1,7 +1,5 @@
1
1
  export default {
2
2
  recaptcha: 'https://www.google.com/recaptcha/enterprise.js?render={apikey}',
3
3
  pickrCss: 'https://cdn.jsdelivr.net/npm/@simonwep/pickr@1.8.2/dist/themes/nano.min.css',
4
- tippy: 'https://cdn.jsdelivr.net/combine/npm/tippy.js@6.3.7/dist/tippy.css,npm/tippy.js@6.3.1/dist/svg-arrow.css,npm/tippy.js@6.3.7/themes/light-border.css,npm/tippy.js@6.3.7/animations/scale.css',
5
- datepicker: 'https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.3.3/dist/css/datepicker.min.css',
6
- datepickerLang: 'https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.3.3/js/i18n/locales/{lang}.min.js'
4
+ datepickerLang: `https://cdn.jsdelivr.net/npm/air-datepicker@3.3.5/locale/${document.documentElement.lang}.js/+esm`
7
5
  }
@@ -0,0 +1,11 @@
1
+ import { replaceScripts } from '@newlogic-digital/utils-js'
2
+ import { initStimulus } from '../Libraries/Stimulus.js'
3
+ import { initCookieConsent } from '../Libraries/CookieConsent.js'
4
+ import { initNaja } from './naja.js'
5
+
6
+ export default function initAfter(element) {
7
+ initStimulus(element)
8
+ initNaja(element)
9
+ replaceScripts(element)
10
+ initCookieConsent(element)
11
+ }
@@ -0,0 +1,41 @@
1
+ import naja from 'naja'
2
+
3
+ export const initNaja = (element, bindUI = true, selectors = 'button, [role="button"]') => {
4
+ bindUI && naja.uiHandler.bindUI(element)
5
+
6
+ element.querySelectorAll(`:where(${selectors})${naja.uiHandler.selector}`).forEach((element) => {
7
+ if (element.form && element.type === 'submit') return
8
+
9
+ element.addEventListener('click', (event) => {
10
+ naja.uiHandler.processInteraction(element, element.dataset.najaMethod ?? 'GET', element.dataset.najaUrl, element.dataset.najaData, {}, event)
11
+ })
12
+ })
13
+ }
14
+
15
+ export const NajaFormValidityExtension = {
16
+ initialize(naja) {
17
+ naja.uiHandler.addEventListener('interaction', (event) => {
18
+ const { element } = event.detail
19
+
20
+ if (element?.form && !element.form.reportValidity()) {
21
+ event.preventDefault()
22
+ }
23
+ })
24
+ }
25
+ }
26
+
27
+ export const NajaRecaptchaExtension = {
28
+ initialize(naja) {
29
+ naja.uiHandler.addEventListener('interaction', (event) => {
30
+ const { element } = event.detail
31
+
32
+ if (
33
+ (element.form ?? element)?.dataset?.controller?.includes('lib-recaptcha')
34
+ && !event.detail?.originalEvent?.detail?.recaptchaExecuted
35
+ ) {
36
+ event.preventDefault()
37
+ return false
38
+ }
39
+ })
40
+ }
41
+ }
@@ -0,0 +1,8 @@
1
+ import { Controller, LibStimulus } from '../Libraries/Stimulus.js'
2
+
3
+ LibStimulus.register('utils', class extends Controller {
4
+ darkMode() {
5
+ document.documentElement.classList.toggle('dark')
6
+ localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light'
7
+ }
8
+ })
@@ -1,6 +1,7 @@
1
- import './Utils/global.js'
2
1
  import './Libraries/+.js'
3
2
  import './Layout/+.js'
4
3
  import './Sections/+.js'
5
4
  import './Components/+.js'
6
5
  import './Ui/+.js'
6
+ import './Utils/utilities.js'
7
+ import.meta.glob('/src/assets/**')
@@ -1,4 +1,5 @@
1
- @import "CookieConsent.css";
2
1
  @import "Dialog/+.css";
3
- @import "Dropdown/+.css";
4
- @import "Form/+.css";
2
+ @import "Drawer.css";
3
+ @import "Field.css";
4
+ @import "Popover.css";
5
+ @import "Toaster.css";
@@ -1 +1,3 @@
1
+ @import "Content.css";
2
+ @import "CookieConsent.css";
1
3
  @import "Default.css";
@@ -0,0 +1,2 @@
1
+ @import "winduum/src/components/dialog/content.css";
2
+ @import "winduum/src/components/dialog/content-props.css";
@@ -0,0 +1,17 @@
1
+ .c-dialog-cookieconsent {
2
+ .c-dialog-content {
3
+ max-width: 32rem;
4
+ }
5
+
6
+ &.center {
7
+ .c-dialog-content {
8
+ max-width: 26rem;
9
+ text-align: center;
10
+
11
+ & .ui-image {
12
+ margin-left: auto;
13
+ margin-right: auto;
14
+ }
15
+ }
16
+ }
17
+ }