@newlogic-digital/ui 3.0.4 → 3.1.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 (109) hide show
  1. package/README.md +6 -10
  2. package/gulpfile.js +17 -168
  3. package/package.json +13 -8
  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/main.json +12 -10
  8. package/src/scripts/Components/+.js +2 -2
  9. package/src/scripts/Components/CookieConsent.js +66 -64
  10. package/src/scripts/Components/Form.js +28 -21
  11. package/src/scripts/Layout/+.js +2 -1
  12. package/src/scripts/Layout/Header.js +18 -0
  13. package/src/scripts/Layout/Main.js +49 -45
  14. package/src/scripts/Libraries/+.js +12 -10
  15. package/src/scripts/Libraries/Anchor.js +18 -43
  16. package/src/scripts/Libraries/CookieConsent.js +37 -58
  17. package/src/scripts/Libraries/Dialog.js +56 -55
  18. package/src/scripts/Libraries/Drawer.js +23 -23
  19. package/src/scripts/Libraries/NativeSlider.js +86 -86
  20. package/src/scripts/Libraries/ReCaptcha.js +20 -18
  21. package/src/scripts/Libraries/Ripple.js +16 -32
  22. package/src/scripts/Libraries/Stimulus.js +30 -34
  23. package/src/scripts/Libraries/Swup.js +47 -50
  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/Functions/+.js +6 -6
  33. package/src/scripts/Utils/Functions/dataValue.js +28 -25
  34. package/src/scripts/Utils/Functions/importScript.js +9 -11
  35. package/src/scripts/Utils/Functions/importStyle.js +18 -5
  36. package/src/scripts/Utils/Functions/inView.js +19 -21
  37. package/src/scripts/Utils/Functions/loadStimulus.js +22 -20
  38. package/src/scripts/Utils/cdn.js +6 -4
  39. package/src/scripts/Utils/global.js +10 -33
  40. package/src/scripts/main.js +6 -6
  41. package/src/styles/Components/CookieConsent.css +40 -179
  42. package/src/styles/Components/Dialog/Default.css +12 -15
  43. package/src/styles/Components/Form/CookieConsent.css +7 -12
  44. package/src/styles/Layout/+.css +2 -0
  45. package/src/{templates/Sections/.gitkeep → styles/Layout/Header.css} +0 -0
  46. package/src/styles/Layout/Main.css +28 -63
  47. package/src/styles/Layout/Nav.css +43 -0
  48. package/src/styles/Libraries/+.css +1 -1
  49. package/src/styles/Libraries/Datepicker.css +85 -39
  50. package/src/styles/Libraries/Dialog.css +6 -5
  51. package/src/styles/Libraries/Drawer.css +15 -14
  52. package/src/styles/Libraries/Hint.css +29 -23
  53. package/src/styles/Libraries/Lazysizes.css +2 -1
  54. package/src/styles/Libraries/NativeSlider.css +18 -17
  55. package/src/styles/Libraries/Ripple.css +8 -5
  56. package/src/styles/Libraries/Tabs.css +4 -4
  57. package/src/styles/Libraries/Tippy.css +87 -0
  58. package/src/styles/Ui/+.css +5 -1
  59. package/src/styles/Ui/Badge.css +33 -19
  60. package/src/styles/Ui/Btn.css +80 -53
  61. package/src/styles/Ui/Checkbox.css +80 -41
  62. package/src/styles/Ui/Dropdown.css +5 -0
  63. package/src/styles/Ui/Heading.css +12 -12
  64. package/src/styles/Ui/Icon.css +27 -8
  65. package/src/styles/Ui/Image.css +23 -0
  66. package/src/styles/Ui/Input.css +295 -220
  67. package/src/styles/Ui/Label.css +14 -0
  68. package/src/styles/Ui/Link.css +3 -3
  69. package/src/styles/Ui/Notice.css +14 -16
  70. package/src/styles/Ui/Progress.css +10 -21
  71. package/src/styles/Ui/Radio.css +3 -8
  72. package/src/styles/Ui/Select.css +63 -112
  73. package/src/styles/Ui/Switch.css +70 -0
  74. package/src/styles/Ui/{Wsw.css → Text.css} +61 -80
  75. package/src/styles/Ui/Title.css +8 -4
  76. package/src/styles/Utils/default.css +75 -67
  77. package/src/styles/Utils/icons.css +9 -0
  78. package/src/styles/Utils/keyframes.css +182 -0
  79. package/src/styles/Utils/normalize.css +223 -0
  80. package/src/styles/Utils/print.css +1 -1
  81. package/src/styles/Utils/tailwind/base.css +15 -0
  82. package/src/styles/Utils/tailwind/gutters.css +264 -263
  83. package/src/styles/Utils/theme/main.css +24 -21
  84. package/src/styles/Utils/vars.css +58 -35
  85. package/src/styles/Utils/vendor.css +1 -2
  86. package/src/styles/main.css +6 -3
  87. package/src/styles/tailwind.css +1 -4
  88. package/src/templates/Components/CookieConsent.twig +30 -0
  89. package/src/templates/Components/Dialogs/Basic.twig +7 -3
  90. package/src/templates/Layout/Header.twig +42 -0
  91. package/src/templates/Layout/Main.twig +52 -67
  92. package/src/templates/Sections/Gdpr.twig +64 -0
  93. package/src/templates/Sections/Ui.twig +2104 -0
  94. package/src/templates/dialog-basic.twig +2 -2
  95. package/src/templates/gdpr.json +11 -0
  96. package/src/templates/index.json +8 -2
  97. package/src/templates/json-tippy.twig +16 -0
  98. package/src/templates/ui.json +11 -0
  99. package/CHANGELOG +0 -231
  100. package/src/icons/iconfont.css +0 -171
  101. package/src/icons/selection.json +0 -1
  102. package/src/icons/variables.css +0 -31
  103. package/src/scripts/Ui/Wsw.js +0 -25
  104. package/src/scripts/Utils/Functions/bodyLoaded.js +0 -12
  105. package/src/styles/Libraries/Animate.css +0 -184
  106. package/src/styles/Utils/reference.css +0 -2
  107. package/src/styles/Utils/tailwind/content.css +0 -24
  108. package/src/styles/Utils/theme/vars.css +0 -19
  109. package/src/styles/preload.css +0 -29
@@ -1,76 +1,80 @@
1
- import {LibStimulus, Controller, loadStimulus} from "../Libraries/Stimulus.js";
2
- import {bodyLoaded, importScript} from "../Utils/Functions/+.js";
3
- import LibRipple from "../Libraries/Ripple.js";
4
- import LibAnchor from "../Libraries/Anchor.js";
5
- import LibDialog from "../Libraries/Dialog.js";
6
- import LibTabs from "../Libraries/Tabs.js";
7
- import LibNativeSlider from "../Libraries/NativeSlider.js";
8
- import cdn from "../Utils/cdn.js";
1
+ import { LibStimulus, Controller, loadStimulus } from '../Libraries/Stimulus.js'
2
+ import { importScript } from '../Utils/Functions/+.js'
3
+ import LibRipple from '../Libraries/Ripple.js'
4
+ import LibAnchor from '../Libraries/Anchor.js'
5
+ import LibDialog from '../Libraries/Dialog.js'
6
+ import LibTippy from '../Libraries/Tippy.js'
7
+ import LibTabs from '../Libraries/Tabs.js'
8
+ import LibNativeSlider from '../Libraries/NativeSlider.js'
9
+ import cdn from '../Utils/cdn.js'
10
+
11
+ LibStimulus.register('lib', class extends Controller {
12
+ connect() {
13
+ if (!('scrollBehavior' in document.documentElement.style)) {
14
+ importScript(cdn.seamless).then(() => window.seamless.polyfill())
15
+ }
16
+ }
9
17
 
10
- LibStimulus.register("lib", class extends Controller {
11
18
  ripple(e) {
12
- LibRipple(e.currentTarget, e)
19
+ LibRipple(e)
13
20
  }
14
21
 
15
22
  anchor(e) {
16
- e.preventDefault();
23
+ e.preventDefault()
17
24
  LibAnchor.action(e.currentTarget)
18
25
  }
19
26
 
20
- darkMode(e) {
21
- let currentTarget = e.currentTarget;
22
-
27
+ darkMode() {
23
28
  if (document.documentElement.classList.contains('dark')) {
24
- localStorage.theme = 'light';
25
- document.documentElement.classList.remove('dark');
26
- currentTarget.classList.remove("icon-light");
29
+ localStorage.theme = 'light'
30
+ document.documentElement.classList.remove('dark')
27
31
  } else {
28
- localStorage.theme = 'dark';
29
- document.documentElement.classList.add('dark');
30
- currentTarget.classList.add("icon-light");
32
+ localStorage.theme = 'dark'
33
+ document.documentElement.classList.add('dark')
31
34
  }
32
35
  }
33
- });
36
+ })
34
37
 
35
- LibStimulus.register("lib-dialog", class extends Controller {
36
- connect() {
37
- let element = this.element;
38
-
39
- if (typeof element.dataset.libDialogOpen !== "undefined") {
40
- let url = element.getAttribute("data-action-url");
38
+ LibStimulus.register('lib-dialog', class extends Controller {
39
+ async connect() {
40
+ if (this.element.getAttribute('data-lib-dialog-open')) {
41
+ const url = this.element.getAttribute('data-action-url')
41
42
 
42
43
  if (url) {
43
- LibDialog.action(element, url, () => loadStimulus(document.querySelector(".lib-dialog")) );
44
+ await LibDialog.action(this.element, url, () => loadStimulus(document.querySelector('.lib-dialog')))
44
45
  } else {
45
- LibDialog.show(document.querySelector(element.dataset.libDialogOpen).innerHTML, () => loadStimulus(document.querySelector(".lib-dialog")));
46
+ await LibDialog.show(document.querySelector(this.element.getAttribute('data-lib-dialog-open')).innerHTML, () => loadStimulus(document.querySelector('.lib-dialog')))
46
47
  }
47
48
  }
48
49
  }
49
50
 
50
- show(e) {
51
- let element = e.currentTarget;
52
- let url = element.getAttribute("data-action-url");
51
+ async show({ currentTarget }) {
52
+ const url = currentTarget.getAttribute('data-action-url')
53
53
 
54
- LibDialog.action(element, url, () => loadStimulus(document.querySelector(".lib-dialog")));
54
+ await LibDialog.action(currentTarget, url)
55
55
  }
56
56
 
57
- hide() {
58
- LibDialog.hide();
57
+ async hide() {
58
+ await LibDialog.hide()
59
59
  }
60
- });
60
+ })
61
61
 
62
- LibStimulus.register("lib-tabs", class extends Controller {
62
+ LibStimulus.register('lib-tabs', class extends Controller {
63
63
  connect() {
64
- LibTabs(this.element);
64
+ LibTabs(this.element)
65
65
  }
66
- });
66
+ })
67
67
 
68
- LibStimulus.register("lib-ns", class extends Controller {
68
+ LibStimulus.register('lib-ns', class extends Controller {
69
69
  connect() {
70
- if (!('scrollBehavior' in document.documentElement.style)) {
71
- importScript(cdn.seamless).then(() => window.seamless.polyfill())
72
- }
70
+ LibNativeSlider(this.element.querySelector('[data-lib-ns]'), this.element)
71
+ }
72
+ })
73
+
74
+ LibStimulus.register('lib-tippy', class extends Controller {
75
+ connect() {
76
+ const attributes = this.element.getAttribute('data-lib-tippy')
73
77
 
74
- bodyLoaded(() => LibNativeSlider(this.element.querySelector("[data-lib-ns]"), this.element))
78
+ new LibTippy(this.element, attributes !== null ? attributes.replace(/\s/g, '').split(',') : undefined)
75
79
  }
76
- });
80
+ })
@@ -1,10 +1,12 @@
1
- export { default as Anchor } from './Anchor.js';
2
- export { default as CookieConsent } from './CookieConsent.js';
3
- export { default as Dialog } from './Dialog.js';
4
- import './Drawer.js';
5
- export { default as NativeSlider } from './NativeSlider.js';
6
- import './ReCaptcha.js';
7
- export { default as Ripple } from './Ripple.js';
8
- import './Stimulus.js';
9
- export { default as Swup } from './Swup.js';
10
- export { default as Tabs } from './Tabs.js';
1
+ export { default as Anchor } from './Anchor.js'
2
+ export { default as CookieConsent } from './CookieConsent.js'
3
+ export { default as Dialog } from './Dialog.js'
4
+ import './Drawer.js'
5
+ import './Fetch.js'
6
+ export { default as NativeSlider } from './NativeSlider.js'
7
+ import './ReCaptcha.js'
8
+ export { default as Ripple } from './Ripple.js'
9
+ import './Stimulus.js'
10
+ export { default as Swup } from './Swup.js'
11
+ export { default as Tabs } from './Tabs.js'
12
+ export { default as Tippy } from './Tippy.js'
@@ -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,61 @@
1
1
  const LibCookieConsent = {
2
2
  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");
3
+ const type = localStorage.getItem('lib-cookieconsent')
4
+
5
+ if (type !== null) {
6
+ JSON.parse(type).forEach(type => LibCookieConsent.append(type))
16
7
  }
17
8
  },
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");
27
-
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
- }
9
+ set: (type) => {
10
+ localStorage.setItem('lib-cookieconsent', JSON.stringify(type))
11
+ localStorage.setItem('lib-cookieconsent-expire', (Date.now() + 31556926 * 1000).toString())
12
+
13
+ if (type.length > 0) {
14
+ type.forEach(type => LibCookieConsent.append(type))
15
+ } else {
16
+ localStorage.setItem('lib-cookieconsent', JSON.stringify([]))
17
+ LibCookieConsent.remove()
41
18
  }
42
19
  },
43
20
  remove: () => {
44
- document.cookie.split(";").forEach(function(c) {
45
- document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/");
46
- });
21
+ document.cookie.split(';').forEach(c => {
22
+ document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/')
23
+ })
47
24
  },
48
25
  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;
26
+ document.querySelectorAll('[data-lib-cookieconsent]').forEach(elm => {
27
+ if (type === 'all' || elm.getAttribute('data-lib-cookieconsent') === type) {
28
+ const script = document.createElement('script')
29
+ let delay = 0
53
30
 
54
- [...elm.attributes].forEach((attribute) => {
31
+ ;[...elm.attributes].forEach((attribute) => {
55
32
  if (attribute.specified) {
56
- if (attribute.name.indexOf("data-lib-cookieconsent") === -1 && attribute.name.indexOf("type") === -1) {
57
- script.setAttribute(attribute.name, attribute.value);
33
+ if (attribute.name.indexOf('data-lib-cookieconsent') === -1 && attribute.name.indexOf('type') === -1) {
34
+ script.setAttribute(attribute.name, attribute.value)
58
35
  }
59
36
  }
60
- });
37
+ })
61
38
 
62
- script.innerHTML = elm.innerHTML;
39
+ script.innerHTML = elm.innerHTML
63
40
 
64
- if (elm.getAttribute("data-lib-cookieconsent-delay")) {
65
- delay = parseInt(elm.getAttribute("data-lib-cookieconsent-delay"));
41
+ if (elm.getAttribute('data-lib-cookieconsent-delay')) {
42
+ delay = parseInt(elm.getAttribute('data-lib-cookieconsent-delay'))
66
43
  }
67
44
 
68
45
  setTimeout(() => {
69
- if (elm.closest("body") !== null) {
70
- document.body.appendChild(script);
71
- } else if (elm.closest("head") !== null) {
72
- document.head.appendChild(script);
46
+ if (elm.closest('body') !== null) {
47
+ document.body.appendChild(script)
48
+ } else if (elm.closest('head') !== null) {
49
+ document.head.appendChild(script)
73
50
  }
74
51
 
75
- elm.remove();
76
- }, delay);
52
+ elm.remove()
53
+ }, delay)
77
54
  }
78
55
  })
79
56
  }
80
- };
57
+ }
58
+
59
+ LibCookieConsent.init()
81
60
 
82
- export default LibCookieConsent;
61
+ 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
+ })