@newlogic-digital/ui 3.0.3 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +20 -22
  2. package/package.json +25 -14
  3. package/src/{main.json → data/main.json} +13 -11
  4. package/src/emails/email.css +3 -3
  5. package/src/emails/email.twig +1 -1
  6. package/src/icons.svg +32 -0
  7. package/src/scripts/Components/+.js +1 -2
  8. package/src/scripts/Components/CookieConsent.js +68 -64
  9. package/src/scripts/Layout/+.js +2 -1
  10. package/src/scripts/Layout/Header.js +18 -0
  11. package/src/scripts/Layout/Main.js +49 -45
  12. package/src/scripts/Libraries/+.js +13 -10
  13. package/src/scripts/Libraries/Anchor.js +18 -43
  14. package/src/scripts/Libraries/CookieConsent.js +42 -57
  15. package/src/scripts/Libraries/Dialog.js +56 -55
  16. package/src/scripts/Libraries/Drawer.js +23 -23
  17. package/src/scripts/Libraries/Form.js +37 -0
  18. package/src/scripts/Libraries/NativeSlider.js +86 -86
  19. package/src/scripts/Libraries/ReCaptcha.js +20 -18
  20. package/src/scripts/Libraries/Ripple.js +16 -32
  21. package/src/scripts/Libraries/Script.js +19 -0
  22. package/src/scripts/Libraries/Stimulus.js +30 -34
  23. package/src/scripts/Libraries/Swup.js +45 -55
  24. package/src/scripts/Libraries/Tabs.js +12 -18
  25. package/src/scripts/Libraries/Tippy.js +118 -0
  26. package/src/scripts/Ui/+.js +5 -3
  27. package/src/scripts/Ui/Checkbox.js +19 -0
  28. package/src/scripts/Ui/Input.js +188 -161
  29. package/src/scripts/Ui/Radio.js +23 -0
  30. package/src/scripts/Ui/Select.js +64 -37
  31. package/src/scripts/Ui/Text.js +25 -0
  32. package/src/scripts/Utils/+.js +3 -0
  33. package/src/scripts/Utils/Functions/+.js +6 -6
  34. package/src/scripts/Utils/Functions/dataValue.js +28 -25
  35. package/src/scripts/Utils/Functions/importScript.js +9 -11
  36. package/src/scripts/Utils/Functions/importStyle.js +18 -5
  37. package/src/scripts/Utils/Functions/inView.js +19 -21
  38. package/src/scripts/Utils/Functions/loadStimulus.js +22 -20
  39. package/src/scripts/Utils/Functions/replaceTag.js +12 -0
  40. package/src/scripts/Utils/cdn.js +6 -4
  41. package/src/scripts/Utils/global.js +10 -33
  42. package/src/scripts/main.js +6 -6
  43. package/src/styles/Components/CookieConsent.css +40 -179
  44. package/src/styles/Components/Dialog/Default.css +12 -15
  45. package/src/styles/Components/Form/CookieConsent.css +7 -12
  46. package/src/styles/Layout/+.css +2 -0
  47. package/src/styles/Layout/Header.css +54 -0
  48. package/src/styles/Layout/Main.css +28 -63
  49. package/src/styles/Layout/Nav.css +43 -0
  50. package/src/styles/Libraries/+.css +1 -1
  51. package/src/styles/Libraries/Datepicker.css +85 -39
  52. package/src/styles/Libraries/Dialog.css +6 -5
  53. package/src/styles/Libraries/Drawer.css +15 -14
  54. package/src/styles/Libraries/Hint.css +29 -23
  55. package/src/styles/Libraries/Lazysizes.css +2 -1
  56. package/src/styles/Libraries/NativeSlider.css +19 -18
  57. package/src/styles/Libraries/Ripple.css +8 -5
  58. package/src/styles/Libraries/Tabs.css +4 -4
  59. package/src/styles/Libraries/Tippy.css +87 -0
  60. package/src/styles/Ui/+.css +5 -1
  61. package/src/styles/Ui/Badge.css +33 -19
  62. package/src/styles/Ui/Btn.css +80 -53
  63. package/src/styles/Ui/Checkbox.css +80 -41
  64. package/src/styles/Ui/Dropdown.css +5 -0
  65. package/src/styles/Ui/Heading.css +12 -12
  66. package/src/styles/Ui/Icon.css +27 -8
  67. package/src/styles/Ui/Image.css +23 -0
  68. package/src/styles/Ui/Input.css +295 -220
  69. package/src/styles/Ui/Label.css +14 -0
  70. package/src/styles/Ui/Link.css +3 -3
  71. package/src/styles/Ui/Notice.css +14 -16
  72. package/src/styles/Ui/Progress.css +10 -21
  73. package/src/styles/Ui/Radio.css +3 -8
  74. package/src/styles/Ui/Select.css +63 -112
  75. package/src/styles/Ui/Switch.css +70 -0
  76. package/src/styles/Ui/{Wsw.css → Text.css} +61 -80
  77. package/src/styles/Ui/Title.css +8 -4
  78. package/src/styles/Utils/+.css +9 -0
  79. package/src/styles/Utils/default.css +75 -67
  80. package/src/styles/Utils/icons.css +9 -0
  81. package/src/styles/Utils/keyframes.css +182 -0
  82. package/src/styles/Utils/normalize.css +223 -0
  83. package/src/styles/Utils/print.css +1 -1
  84. package/src/styles/Utils/tailwind/+.css +2 -0
  85. package/src/styles/Utils/tailwind/base.css +15 -0
  86. package/src/styles/Utils/tailwind/gutters.css +264 -263
  87. package/src/styles/Utils/theme/+.css +1 -0
  88. package/src/styles/Utils/theme/main.css +24 -21
  89. package/src/styles/Utils/vars.css +58 -35
  90. package/src/styles/Utils/vendor.css +1 -2
  91. package/src/styles/main.css +8 -3
  92. package/src/templates/Components/CookieConsent.twig +30 -0
  93. package/src/templates/Components/Dialogs/Basic.twig +7 -3
  94. package/src/templates/Layout/Header.twig +42 -0
  95. package/src/templates/Layout/Main.twig +52 -67
  96. package/src/templates/Sections/Gdpr.twig +64 -0
  97. package/src/templates/Sections/Ui.twig +2093 -0
  98. package/src/views/dialog-basic.json.twig +3 -0
  99. package/src/views/gdpr.json +11 -0
  100. package/src/views/index.json +12 -0
  101. package/src/views/json-tippy.json.twig +16 -0
  102. package/src/views/ui.json +11 -0
  103. package/vite.config.js +6 -0
  104. package/CHANGELOG +0 -231
  105. package/gulpfile.js +0 -192
  106. package/src/icons/iconfont.css +0 -171
  107. package/src/icons/selection.json +0 -1
  108. package/src/icons/variables.css +0 -31
  109. package/src/scripts/Components/Form.js +0 -26
  110. package/src/scripts/Ui/Wsw.js +0 -25
  111. package/src/scripts/Utils/Functions/bodyLoaded.js +0 -12
  112. package/src/styles/Libraries/Animate.css +0 -184
  113. package/src/styles/Utils/reference.css +0 -2
  114. package/src/styles/Utils/tailwind/content.css +0 -24
  115. package/src/styles/Utils/theme/vars.css +0 -19
  116. package/src/styles/preload.css +0 -29
  117. package/src/styles/tailwind.css +0 -5
  118. package/src/templates/Sections/.gitkeep +0 -0
  119. package/src/templates/dialog-basic.twig +0 -3
  120. package/src/templates/index.json +0 -6
@@ -1,60 +1,35 @@
1
1
  const LibAnchor = {
2
2
  animation: (element) => {
3
- let offset;
4
- let attr = "data-offset";
3
+ const offset = parseInt(window.getComputedStyle(document.documentElement).getPropertyValue('scroll-padding-top'))
5
4
 
6
- if (window.innerWidth > 960) {
7
- offset = 0;
8
- if (element.getAttribute(attr) !== null) {
9
- if (isNaN(parseInt(element.getAttribute(attr)))) {
10
- offset = document.querySelector(element.getAttribute(attr)).offsetHeight;
11
- } else {
12
- offset = parseInt(element.getAttribute(attr));
13
- }
14
- }
15
- }
16
-
17
- document.documentElement.scroll({top: element.offsetTop - offset, behavior: "smooth"});
5
+ document.documentElement.scroll({ top: element.offsetTop - offset, behavior: 'smooth' })
18
6
  },
19
7
  action: (element) => {
20
- let href = element.getAttribute("href");
21
-
22
- if (href === null) {
23
- href = element.getAttribute("data-action-href");
24
- }
25
-
26
- let id = document.querySelector("[id=" + href.replace('#', '') + "]");
27
- let options = element.getAttribute("data-action-options");
8
+ const href = element.href ? element.getAttribute('href') : element.getAttribute('data-action-href')
9
+ const data = element.dataset.libAnhor ? element.dataset.libAnhor : ''
10
+ const target = document.querySelector(`[id="${href.replace('#', '')}"]`)
28
11
 
29
- if (options === null) {
30
- options = "";
31
- }
32
-
33
- if (id !== null) {
34
- if (!(options.indexOf("mobile") > -1 && window.innerWidth > 960)) {
35
-
36
- LibAnchor.animation(id);
12
+ if (target !== null) {
13
+ if (!(data.includes('mobile') && window.innerWidth > 960)) {
14
+ LibAnchor.animation(target)
15
+ }
37
16
 
38
- if (options.indexOf("hash") > -1) {
39
- window.location.hash = id;
40
- }
17
+ if (!data.includes('silent')) {
18
+ window.location.hash = target.id
41
19
  }
42
20
  }
43
21
  },
44
22
  init: () => {
45
- let selector = [...document.querySelectorAll("[id]")];
23
+ const selector = document.querySelectorAll('[id]')
46
24
 
47
25
  if (selector[0] !== null) {
48
-
49
- selector.forEach((element) => {
50
- if (window.location.hash && element.getAttribute("id") === window.location.hash.replace('#', '')) {
51
- LibAnchor.animation(element);
26
+ selector.forEach(element => {
27
+ if (window.location.hash && element.getAttribute('id') === window.location.hash.replace('#', '')) {
28
+ LibAnchor.animation(element)
52
29
  }
53
- });
30
+ })
54
31
  }
55
32
  }
56
- };
57
-
58
- LibAnchor.init();
33
+ }
59
34
 
60
- export default LibAnchor;
35
+ export default LibAnchor
@@ -1,82 +1,67 @@
1
1
  const LibCookieConsent = {
2
+ setItem: (key, value) => {
3
+ localStorage.setItem(key, value)
4
+ },
5
+ getItem: (key) => {
6
+ return localStorage.getItem(key)
7
+ },
2
8
  init: () => {
3
- if (localStorage.getItem('cookieconsent') === "approve") {
4
- let type = localStorage.getItem('cookieconsent_type');
5
- if (type !== null) {
6
- if (type === "performance") {
7
- LibCookieConsent.append("performance");
8
- } else if (type === "marketing") {
9
- LibCookieConsent.append("all");
10
- }
11
- } else {
12
- LibCookieConsent.append("all");
13
- }
14
- } else if (localStorage.getItem('cookieconsent') === null) {
15
- LibCookieConsent.append("all");
9
+ const type = LibCookieConsent.getItem('lib-cookieconsent')
10
+
11
+ if (type !== null) {
12
+ JSON.parse(type).forEach(type => LibCookieConsent.append(type))
16
13
  }
17
14
  },
18
- set: (type, callback) => {
19
- if (type === "approve") {
20
- localStorage.setItem("cookieconsent", "approve");
21
- LibCookieConsent.append("all");
22
-
23
- } else if (type === "performance") {
24
- localStorage.setItem("cookieconsent", "approve");
25
- localStorage.setItem("cookieconsent_type", "performance");
26
- LibCookieConsent.append("performance");
15
+ set: (type) => {
16
+ LibCookieConsent.setItem('lib-cookieconsent', JSON.stringify(type))
17
+ LibCookieConsent.setItem('lib-cookieconsent-expire', (Date.now() + 31556926 * 1000).toString())
27
18
 
28
- } else if (type === "marketing") {
29
- localStorage.setItem("cookieconsent", "approve");
30
- localStorage.setItem("cookieconsent_type", "marketing");
31
- LibCookieConsent.append("all");
32
-
33
- } else if (type === "decline") {
34
- localStorage.setItem("cookieconsent", "decline");
35
- localStorage.removeItem("cookieconsent_type");
36
- LibCookieConsent.remove();
37
-
38
- if (callback) {
39
- callback();
40
- }
19
+ if (type.length > 0) {
20
+ type.forEach(type => LibCookieConsent.append(type))
21
+ } else {
22
+ LibCookieConsent.setItem('lib-cookieconsent', JSON.stringify([]))
23
+ LibCookieConsent.remove()
41
24
  }
42
25
  },
43
26
  remove: () => {
44
- document.cookie.split(";").forEach(function(c) {
45
- document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/");
46
- });
27
+ document.cookie.split(';').forEach(c => {
28
+ document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/')
29
+ })
47
30
  },
48
31
  append: (type) => {
49
- [...document.querySelectorAll("[data-lib-cookieconsent]")].map((elm) => {
50
- if (type === "all" || elm.getAttribute("data-lib-cookieconsent") === type) {
51
- let script = document.createElement("script");
52
- let delay = 0;
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
53
36
 
54
- [...elm.attributes].forEach((attribute) => {
37
+ ;[...elm.attributes].forEach((attribute) => {
55
38
  if (attribute.specified) {
56
- if (attribute.name.indexOf("data-lib-cookieconsent") === -1 && attribute.name.indexOf("type") === -1) {
57
- script.setAttribute(attribute.name, attribute.value);
39
+ if (attribute.name.indexOf('data-lib-cookieconsent') === -1 && attribute.name.indexOf('type') === -1) {
40
+ script.setAttribute(attribute.name, attribute.value)
58
41
  }
59
42
  }
60
- });
43
+ })
61
44
 
62
- script.innerHTML = elm.innerHTML;
45
+ script.innerHTML = elm.innerHTML
63
46
 
64
- if (elm.getAttribute("data-lib-cookieconsent-delay")) {
65
- delay = parseInt(elm.getAttribute("data-lib-cookieconsent-delay"));
47
+ if (elm.getAttribute('data-lib-cookieconsent-delay')) {
48
+ delay = parseInt(elm.getAttribute('data-lib-cookieconsent-delay'))
66
49
  }
67
50
 
68
51
  setTimeout(() => {
69
- if (elm.closest("body") !== null) {
70
- document.body.appendChild(script);
71
- } else if (elm.closest("head") !== null) {
72
- document.head.appendChild(script);
52
+ if (elm.closest('body') !== null) {
53
+ document.body.appendChild(script)
54
+ } else if (elm.closest('head') !== null) {
55
+ document.head.appendChild(script)
73
56
  }
74
57
 
75
- elm.remove();
76
- }, delay);
58
+ elm.remove()
59
+ }, delay)
77
60
  }
78
61
  })
79
62
  }
80
- };
63
+ }
64
+
65
+ LibCookieConsent.init()
81
66
 
82
- export default LibCookieConsent;
67
+ export default LibCookieConsent
@@ -1,74 +1,75 @@
1
+ import { loadStimulus } from './Stimulus.js'
2
+
1
3
  const LibDialog = {
2
- show: (content, callback) => {
3
- if (document.querySelector(".lib-dialog > [class^='c-dialog']") !== null) {
4
- document.querySelector(".lib-dialog > [class^='c-dialog']").remove();
5
- }
4
+ show: async(content) => {
5
+ return new Promise(resolve => {
6
+ if (document.querySelector('.lib-dialog > [class^="c-dialog"]') !== null) {
7
+ document.querySelector('.lib-dialog > [class^="c-dialog"]').remove()
8
+ }
6
9
 
7
- if (document.querySelector(".lib-dialog") === null) {
8
- document.body.insertAdjacentHTML("beforeend", `<div class="lib-dialog"></div>`);
9
- }
10
+ if (document.querySelector('.lib-dialog') === null) {
11
+ document.body.insertAdjacentHTML('beforeend', '<div class="lib-dialog"></div>')
12
+ }
10
13
 
11
- document.querySelector(".lib-dialog").insertAdjacentHTML("beforeend", content);
12
- document.querySelector(".lib-dialog").style["display"] = "flex";
14
+ document.querySelector('.lib-dialog').insertAdjacentHTML('beforeend', content)
15
+ document.querySelector('.lib-dialog').style.display = 'flex'
13
16
 
14
- function outerHeight(el) {
15
- return el.offsetHeight + parseInt(getComputedStyle(el).marginTop) + parseInt(getComputedStyle(el).marginBottom);
16
- }
17
+ function outerHeight(el) {
18
+ return el.offsetHeight + parseInt(getComputedStyle(el).marginTop) + parseInt(getComputedStyle(el).marginBottom)
19
+ }
17
20
 
18
- if (outerHeight(document.querySelector(".lib-dialog > [class^='c-dialog']")) > window.innerHeight) {
19
- let offset = window.innerWidth - document.body.clientWidth;
21
+ if (outerHeight(document.querySelector('.lib-dialog > [class^="c-dialog"]')) > window.innerHeight) {
22
+ const offset = window.innerWidth - document.body.clientWidth
20
23
 
21
- document.documentElement.style["padding-right"] = offset;
22
- document.documentElement.classList.add("is-overflow-hidden");
24
+ document.documentElement.style.paddingRight = `${offset}px`
25
+ document.documentElement.classList.add('overflow-hidden')
23
26
 
24
- if (document.querySelector("#l-header") !== null) {
25
- document.querySelector("#l-header").style["right"] = offset;
27
+ if (document.querySelector('#l-header') !== null) {
28
+ document.querySelector('#l-header').style.right = `${offset}px`
29
+ }
26
30
  }
27
- }
28
31
 
29
- if (callback) {
30
- callback();
31
- }
32
+ loadStimulus(document.querySelector('.lib-dialog'))
32
33
 
33
- document.querySelector(".lib-dialog").addEventListener("mousedown", (e) => {
34
- if (e.target.classList.contains("lib-dialog")) {
35
- document.documentElement.addEventListener("mouseup", function e() {
36
- LibDialog.hide();
37
- document.documentElement.removeEventListener("mouseup", e);
38
- });
39
- }
40
- }, true);
34
+ resolve()
35
+
36
+ document.querySelector('.lib-dialog').addEventListener('mousedown', e => {
37
+ if (e.target.classList.contains('lib-dialog')) {
38
+ document.documentElement.addEventListener('mouseup', function e() {
39
+ LibDialog.hide()
40
+ document.documentElement.removeEventListener('mouseup', e)
41
+ })
42
+ }
43
+ }, true)
44
+ })
41
45
  },
42
- hide: (callback) => {
43
- if (document.querySelector(".lib-dialog") !== null) {
44
- document.querySelector(".lib-dialog")._addDataValue("state", "hiding");
45
- }
46
+ hide: async() => {
47
+ return new Promise(resolve => {
48
+ if (document.querySelector('.lib-dialog') !== null) {
49
+ document.querySelector('.lib-dialog')._addDataValue('state', 'hiding')
50
+ }
46
51
 
47
- setTimeout(function () {
48
- if (document.querySelector(".lib-dialog") !== null) {
49
- document.querySelector(".lib-dialog").style["display"] = "none";
50
- document.documentElement.classList.remove("is-overflow-hidden");
52
+ setTimeout(() => {
53
+ if (document.querySelector('.lib-dialog') !== null) {
54
+ document.querySelector('.lib-dialog').style.display = 'none'
55
+ document.documentElement.classList.remove('overflow-hidden')
51
56
 
52
- if (document.querySelector("#l-header") !== null) {
53
- document.querySelector("#l-header").style["right"] = "";
54
- }
57
+ if (document.querySelector('#l-header') !== null) {
58
+ document.querySelector('#l-header').style.right = ''
59
+ }
55
60
 
56
- document.querySelector(".lib-dialog").remove();
57
- }
61
+ document.querySelector('.lib-dialog').remove()
62
+ }
58
63
 
59
- if (callback) {
60
- callback();
61
- }
62
- }, 300);
64
+ resolve()
65
+ }, 300)
66
+ })
63
67
  },
64
- action: (element, url, callback) => {
65
- fetch(url, {headers: {'X-Requested-With': 'XMLHttpRequest'}}).then((response) => {
66
- return response.json();
68
+ action: async(element, url) => {
69
+ fetch(url, { headers: { 'X-Requested-With': 'XMLHttpRequest' } }).then(response => response.json()).then(({ dialog }) => {
70
+ LibDialog.show(dialog)
67
71
  })
68
- .then((data) => {
69
- LibDialog.show(data["dialog"], callback);
70
- });
71
72
  }
72
- };
73
+ }
73
74
 
74
- export default LibDialog;
75
+ export default LibDialog
@@ -1,39 +1,39 @@
1
- import { LibStimulus, Controller } from "./Stimulus.js";
1
+ import { LibStimulus, Controller } from './Stimulus.js'
2
2
 
3
- LibStimulus.register("lib-drawer", class extends Controller {
3
+ LibStimulus.register('lib-drawer', class extends Controller {
4
4
  init() {
5
- setTimeout(() => this.queryTarget("nav").classList.add("is-transition"), 50);
6
- this.queryTarget("nav").addEventListener("click", (e) => {
7
- if (e.target === this.queryTarget("nav")) {
8
- this.hide();
5
+ setTimeout(() => this.queryTarget('nav').classList.add('is-transition'), 50)
6
+ this.queryTarget('nav').addEventListener('click', ({ target }) => {
7
+ if (target === this.queryTarget('nav')) {
8
+ this.hide()
9
9
  }
10
10
  })
11
11
  }
12
12
 
13
13
  show() {
14
- this.queryTarget("nav").scrollLeft = 0;
15
- this.queryTarget("nav").style.setProperty('--drawerOpacity', `1`);
16
- this.queryTarget("nav").classList.add("is-opacity");
17
- this.queryTarget("nav")._addDataValue("state", "active");
18
- document.documentElement.classList.add("is-lib-drawer-active");
14
+ this.queryTarget('nav').scrollLeft = 0
15
+ this.queryTarget('nav').style.setProperty('--lib-drawer-opacity', '1')
16
+ this.queryTarget('nav').classList.add('is-opacity')
17
+ this.queryTarget('nav')._addDataValue('state', 'active')
18
+ document.documentElement.classList.add('overflow-hidden')
19
19
  }
20
20
 
21
21
  hide() {
22
- this.queryTarget("nav")._removeDataValue("state", "active");
23
- this.queryTarget("nav").classList.add("is-opacity");
24
- this.queryTarget("nav").style.setProperty('--drawerOpacity', `0`);
25
- document.documentElement.classList.remove("is-lib-drawer-active");
22
+ this.queryTarget('nav')._removeDataValue('state', 'active')
23
+ this.queryTarget('nav').classList.add('is-opacity')
24
+ this.queryTarget('nav').style.setProperty('--lib-drawer-opacity', '0')
25
+ document.documentElement.classList.remove('overflow-hidden')
26
26
  }
27
27
 
28
- scroll(e) {
29
- if (e.target.scrollLeft > 1) {
30
- this.queryTarget("nav").classList.remove("is-opacity");
31
- this.queryTarget("nav").style.setProperty('--drawerOpacity', `${Math.abs((e.target.scrollLeft / this.queryTarget("nav").children[0].clientWidth) - 1)}`);
28
+ scroll({ target }) {
29
+ if (target.scrollLeft > 1) {
30
+ this.queryTarget('nav').classList.remove('is-opacity')
31
+ this.queryTarget('nav').style.setProperty('--lib-drawer-opacity', `${Math.abs((target.scrollLeft / this.queryTarget('nav').children[0].clientWidth) - 1)}`)
32
32
  }
33
33
 
34
- if (e.target.scrollLeft === this.queryTarget("nav").children[0].clientWidth) {
35
- this.queryTarget("nav")._removeDataValue("state", "active");
36
- document.documentElement.classList.remove("is-lib-drawer-active");
34
+ if (target.scrollLeft === this.queryTarget('nav').children[0].clientWidth) {
35
+ this.queryTarget('nav')._removeDataValue('state', 'active')
36
+ document.documentElement.classList.remove('overflow-hidden')
37
37
  }
38
38
  }
39
- });
39
+ })
@@ -0,0 +1,37 @@
1
+ import { LibStimulus, Controller, getController } from './Stimulus.js'
2
+
3
+ LibStimulus.register('lib-form', class extends Controller {
4
+ connect() {
5
+ this.element.setAttribute('novalidate', '')
6
+ this.element.addEventListener('submit', e => this.validate(this.element, e))
7
+ }
8
+
9
+ validate(element, e) {
10
+ if (element.reportValidity() === false) {
11
+ e.preventDefault()
12
+ e.stopPropagation()
13
+ }
14
+
15
+ element.querySelectorAll('.ui-input').forEach(element => {
16
+ getController(element, 'ui-input').validate(element, true)
17
+ })
18
+
19
+ element.querySelectorAll('.ui-select:not([data-state*="active"]) select[required]').forEach(select => {
20
+ getController(select.parentNode, 'ui-select').validate(select.parentNode, select)
21
+ })
22
+
23
+ element.querySelectorAll('[data-controller="ui-checkbox"] input:not([type="hidden"])').forEach(input => {
24
+ input.parentNode._removeDataValue('state', 'valid invalid')
25
+
26
+ if (input.checkValidity()) {
27
+ input.parentNode._addDataValue('state', 'valid')
28
+ } else {
29
+ input.parentNode._addDataValue('state', 'invalid')
30
+ }
31
+ })
32
+ }
33
+
34
+ submitForm({ currentTarget }) {
35
+ currentTarget.form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
36
+ }
37
+ })