@newlogic-digital/ui 3.1.0 → 3.3.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 (97) hide show
  1. package/.eslintrc +13 -0
  2. package/.stylelintrc +18 -0
  3. package/README.md +15 -17
  4. package/package.json +29 -15
  5. package/public/sw.js +30 -0
  6. package/src/{main.json → data/main.json} +6 -1
  7. package/src/emails/email.prod.html +6 -0
  8. package/src/emails/email.twig.html +6 -0
  9. package/src/emails/{email.css → styles/email.css} +1 -1
  10. package/src/emails/templates/Content.twig +16 -0
  11. package/src/emails/templates/Header.twig +14 -0
  12. package/src/emails/templates/Layout.twig +23 -0
  13. package/src/emails/templates.prod/.gitkeep +0 -0
  14. package/src/scripts/Components/+.js +0 -1
  15. package/src/scripts/Components/CookieConsent.js +16 -14
  16. package/src/scripts/Layout/Main.js +3 -3
  17. package/src/scripts/Libraries/+.js +2 -1
  18. package/src/scripts/Libraries/CookieConsent.js +10 -4
  19. package/src/scripts/Libraries/Dialog.js +8 -1
  20. package/src/scripts/Libraries/Drawer.js +16 -14
  21. package/src/scripts/Libraries/Form.js +31 -0
  22. package/src/scripts/Libraries/NativeSlider.js +2 -1
  23. package/src/scripts/Libraries/ReCaptcha.js +9 -4
  24. package/src/scripts/Libraries/Script.js +19 -0
  25. package/src/scripts/Libraries/Stimulus.js +1 -31
  26. package/src/scripts/Libraries/Swup.js +7 -10
  27. package/src/scripts/Libraries/Tabs.js +5 -5
  28. package/src/scripts/Libraries/Tippy.js +3 -1
  29. package/src/scripts/Ui/+.js +0 -1
  30. package/src/scripts/Ui/Checkbox.js +4 -13
  31. package/src/scripts/Ui/Input.js +23 -69
  32. package/src/scripts/Ui/Select.js +11 -39
  33. package/src/scripts/Ui/Text.js +2 -4
  34. package/src/scripts/Utils/+.js +3 -0
  35. package/src/scripts/Utils/Functions/+.js +2 -1
  36. package/src/scripts/Utils/Functions/checkValidity.js +44 -0
  37. package/src/scripts/Utils/Functions/inView.js +7 -8
  38. package/src/scripts/Utils/Functions/replaceTag.js +12 -0
  39. package/src/scripts/Utils/cdn.js +1 -1
  40. package/src/scripts/Utils/global.js +6 -8
  41. package/src/styles/Components/+.css +1 -1
  42. package/src/styles/Components/Dropdown/+.css +1 -0
  43. package/src/styles/{Ui/Dropdown.css → Components/Dropdown/Default.css} +1 -1
  44. package/src/styles/Layout/Header.css +54 -0
  45. package/src/styles/Libraries/+.css +0 -1
  46. package/src/styles/Libraries/Drawer.css +1 -1
  47. package/src/styles/Libraries/Hint.css +4 -3
  48. package/src/styles/Libraries/NativeSlider.css +9 -1
  49. package/src/styles/Libraries/Tippy.css +1 -1
  50. package/src/styles/Ui/+.css +0 -1
  51. package/src/styles/Ui/Badge.css +1 -1
  52. package/src/styles/Ui/Btn.css +24 -6
  53. package/src/styles/Ui/Checkbox.css +28 -2
  54. package/src/styles/Ui/Heading.css +2 -1
  55. package/src/styles/Ui/Icon.css +2 -2
  56. package/src/styles/Ui/Image.css +1 -7
  57. package/src/styles/Ui/Input.css +65 -18
  58. package/src/styles/Ui/Label.css +2 -2
  59. package/src/styles/Ui/Link.css +12 -5
  60. package/src/styles/Ui/Notice.css +1 -1
  61. package/src/styles/Ui/Select.css +3 -5
  62. package/src/styles/Ui/Text.css +13 -4
  63. package/src/styles/Ui/Title.css +3 -2
  64. package/src/styles/Utils/+.css +9 -0
  65. package/src/styles/Utils/default.css +0 -7
  66. package/src/styles/Utils/keyframes.css +4 -4
  67. package/src/styles/Utils/tailwind/+.css +2 -0
  68. package/src/styles/Utils/tailwind/base.css +25 -0
  69. package/src/styles/Utils/theme/+.css +1 -0
  70. package/src/styles/Utils/vars.css +32 -8
  71. package/src/styles/main.css +2 -0
  72. package/src/templates/Components/CookieConsent.twig +2 -2
  73. package/src/templates/Layout/Main.twig +1 -7
  74. package/src/templates/Sections/Ui/Docs/@intro.html +97 -0
  75. package/src/templates/Sections/Ui/Docs/@nav.html +195 -0
  76. package/src/templates/Sections/Ui/Docs/@styles.html +100 -0
  77. package/src/templates/Sections/Ui/Docs/Default.twig +1600 -0
  78. package/src/templates/Sections/Ui/Icons.html +28 -0
  79. package/src/templates/Sections/Ui/Intro.html +136 -0
  80. package/src/templates/Sections/Ui.twig +5 -2101
  81. package/src/templates/Utils/sections.twig +2 -2
  82. package/src/views/dialog/basic.json.twig +3 -0
  83. package/src/{templates/json-tippy.twig → views/dropdown/tippy.json.twig} +3 -3
  84. package/src/views/gdpr.json +12 -0
  85. package/src/{templates → views}/index.json +2 -2
  86. package/src/{templates/ui.json → views/ui-icons.json} +3 -2
  87. package/src/{templates/gdpr.json → views/ui.json} +1 -1
  88. package/tailwind.config.cjs +69 -0
  89. package/vite.config.js +10 -0
  90. package/gulpfile.js +0 -41
  91. package/src/emails/email.twig +0 -60
  92. package/src/scripts/Components/Form.js +0 -33
  93. package/src/scripts/Ui/Radio.js +0 -23
  94. package/src/styles/Components/Item/+.css +0 -1
  95. package/src/styles/Libraries/Lazysizes.css +0 -9
  96. package/src/styles/tailwind.css +0 -2
  97. package/src/templates/dialog-basic.twig +0 -3
package/.eslintrc ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "standard",
3
+ "rules": {
4
+ "indent": ["error", 4],
5
+ "no-new": "off",
6
+ "space-before-function-paren": ["error", "never"],
7
+ "import/extensions": ["error", "ignorePackages"]
8
+ },
9
+ "env": {
10
+ "browser": true
11
+ },
12
+ "ignorePatterns": ["**/+.js"]
13
+ }
package/.stylelintrc ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "stylelint-config-standard",
3
+ "rules": {
4
+ "at-rule-no-unknown": [true, {"ignoreAtRules": ["layer", "tailwind"]}],
5
+ "selector-list-comma-newline-after": "always-multi-line",
6
+ "string-quotes": "double",
7
+ "comment-empty-line-before": ["always", {"except": ["first-nested"], "ignore": ["stylelint-commands"], "ignoreComments": ["/^clean-css/"]}],
8
+ "length-zero-no-unit": [true, {"ignore": ["custom-properties"]}],
9
+ "value-keyword-case": ["lower", { "camelCaseSvgKeywords": true }],
10
+ "alpha-value-notation": "number",
11
+ "property-no-vendor-prefix": [true, { "ignoreProperties": "appearance" }],
12
+ "number-max-precision": [4, { "ignoreProperties": "letter-spacing" }],
13
+ "max-line-length": 140,
14
+ "selector-class-pattern": null,
15
+ "import-notation": "string"
16
+ },
17
+ "ignoreFiles": ["**/+.css", "src/styles/Utils/normalize.css"]
18
+ }
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <a href="https://ui.newlogic.cz/" target="_blank" rel="noopener noreferrer">
3
- <img width="180" src="https://ui.devlogic.cz/assets/favicons/android-chrome-192x192.png" alt="Logo">
3
+ <img width="180" src="https://ui.newlogic.cz/favicons/android-chrome-192x192.png" alt="Logo">
4
4
  </a>
5
5
  </p>
6
6
  <p align="center">
@@ -23,8 +23,9 @@ Newlogic UI is component framework with easy syntax. Modern approach of CSS prop
23
23
  Javascript implementation is mainly intended for use on backend rendered websites and applications such as with PHP
24
24
 
25
25
  ## ⚙️ Under the hood
26
- * **[Newlogic Core](https://core.newlogic.cz/)** - set of tools that can be used to create modern web applications
27
- * **[ESM](https://tailwindcss.com/)** - completely written in modern JS syntax - ES8+, ES module, etc.
26
+ * **[Vituum](https://vituum.dev/)** - a small wrapper around Vite, adds support of template engines and more
27
+ * **[Newlogic Core](https://github.com/newlogic-digital/core)** - integration for Vituum, adds pre-defined config of integrations and more
28
+ * **[ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)** - completely written in modern JS syntax - ES8+, ES module, etc.
28
29
  * **[PostCSS](https://postcss.org/)** - completely written in modern CSS syntax - nesting, variables, etc.
29
30
  * **[Tailwind CSS](https://tailwindcss.com/)** - rich utility classes for everything
30
31
  * **[Stimulus](https://stimulus.hotwire.dev/)** - a modest JavaScript framework for the HTML you already have
@@ -32,49 +33,46 @@ Javascript implementation is mainly intended for use on backend rendered website
32
33
  * **Easy syntax** - .ui-btn (ui elements), .c-component (components), .c-section (sections) etc.
33
34
 
34
35
 
35
- The core of the Newlogic UI is Newlogic Core, which compiles modern JS and CSS syntax and contains other tools for web development. Source code can be used with any other tools or even different environment than NodeJS, eg. Deno and is written in W3C standards and should be runnable in current or future version of browsers. The framework is modular, and you can really use only what is needed for your project.
36
+ The core of the Newlogic UI is Vituum with Newlogic Core, which compiles modern JS and CSS syntax and contains other tools for web development. Source code can be used with any other tools or even different environment than NodeJS, eg. Deno and is written in W3C standards and should be runnable in current or future version of browsers. The framework is modular, and you can really use only what is needed for your project.
36
37
 
37
- ## 🪄 Instalation
38
+ ## 🪄 Get started
38
39
 
39
- Creating a new project (using Newlogic Core)
40
+ Creating a new project (using Vituum)
40
41
  ```sh
41
42
  $ git clone --depth 1 https://github.com/newlogic-digital/ui.git newlogic-ui-project
42
43
  $ cd newlogic-ui-project && npm i
43
44
  ```
44
45
  ```sh
45
- $ npx gulp serve
46
+ $ vite
46
47
  ```
47
48
  or
48
49
  ```sh
49
- $ npx gulp production
50
+ $ vituum build
50
51
  ```
51
52
  ___
52
53
  Or in any other environment
53
54
  ```sh
54
- $ npm i @newlogic-newlogic/ui
55
+ $ npm i @newlogic-digital/ui
55
56
  ```
56
57
 
57
58
  ```css
58
59
  /* main.css or individual modules */
59
- @import "node_modules/@newlogic/ui/src/styles/main.css"
60
+ @import "node_modules/@newlogic-digital/ui/src/styles/main.css"
60
61
  ```
61
62
 
62
63
  ```js
63
64
  /* main.js or individual modules */
64
- import "node_modules/@newlogic/ui/src/scripts/main.js"
65
+ import "node_modules/@newlogic-digital/ui/src/scripts/main.js"
65
66
  ```
66
67
 
67
68
  ### Requirements
68
69
 
69
- - [Node.js LTS (14.x)](https://nodejs.org/en/download/)
70
- - [NPM (7.x)](https://www.npmjs.com/package/npm) or [Yarn (2.x)](https://yarnpkg.com/)
70
+ - [Node.js LTS (16.x)](https://nodejs.org/en/download/)
71
+ - [NPM (7.x)](https://www.npmjs.com/package/npm) or any other package manager
71
72
 
72
73
  ### Config
73
74
 
74
- Each Newlogic Core project has to have config via `gulpfile.js`, docs - [core.newlogic.cz](https://core.newlogic.cz/)
75
-
76
- ## 📌 Future plans
77
- - performance optimization
75
+ Each Vituum project has to have config via `vite.config.js`, docs - [vituum.dev](https://vituum.dev)
78
76
 
79
77
  ## Licence
80
78
  GNU GPLv3
package/package.json CHANGED
@@ -1,36 +1,50 @@
1
1
  {
2
2
  "name": "@newlogic-digital/ui",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "type": "module",
5
- "main": "gulpfile.js",
5
+ "main": "vite.config.js",
6
6
  "author": "New Logic Studio s.r.o.",
7
7
  "description": "Lightweight, modern and modular CSS framework with the best principles",
8
8
  "license": "GNU GPLv3",
9
9
  "scripts": {
10
- "utils:eslint": "eslint 'src/scripts/**/*.js' --fix",
11
- "utils:stylelint": "stylelint 'src/styles/**/*.css' --fix"
10
+ "dev": "vite",
11
+ "preview": "vite preview",
12
+ "build": "vituum build",
13
+ "build:emails": "vituum build && vituum emails",
14
+ "build:headless": "vituum headless",
15
+ "emails": "vituum emails",
16
+ "cleanup": "vituum cleanup",
17
+ "eslint": "eslint 'src/scripts/**/*.js'",
18
+ "eslint:fix": "eslint 'src/scripts/**/*.js' --fix",
19
+ "stylelint": "stylelint 'src/styles/**/*.css'",
20
+ "stylelint:fix": "stylelint 'src/styles/**/*.css' --fix"
12
21
  },
13
- "imports": {},
14
22
  "dependencies": {
15
23
  "@simonwep/pickr": "^1.8.2",
16
- "@hotwired/stimulus": "3.0.1",
17
- "swup": "2.0.14",
24
+ "@hotwired/stimulus": "^3.1.1",
25
+ "swup": "^2.0.19",
18
26
  "tippy.js": "^6.3.7",
19
- "vanillajs-datepicker": "^1.2.0"
27
+ "vanillajs-datepicker": "^1.2.0",
28
+ "css-has-pseudo": "^4.0.1"
20
29
  },
21
30
  "devDependencies": {
22
- "@newlogic-digital/core": "~0.9.5",
23
- "eslint-config-standard": "^16.0.3",
24
- "stylelint-config-standard": "^24.0.0"
31
+ "@newlogic-digital/core": "^1.0.10",
32
+ "@types/grecaptcha": "^3.0.4",
33
+ "vituum": "^0.0.35",
34
+ "eslint-config-standard": "^17.0.0",
35
+ "stylelint-config-standard": "^29.0.0"
25
36
  },
26
37
  "files": [
27
38
  "src",
28
- "gulpfile.js"
39
+ "tailwind.config.cjs",
40
+ "vite.config.js",
41
+ ".eslintrc",
42
+ ".stylelintrc",
43
+ "public/sw.js"
29
44
  ],
30
45
  "engines": {
31
- "node": ">=14.0.0",
32
- "npm": ">=7.10.0",
33
- "yarn": ">=2.3.0"
46
+ "node": ">=16.0.0",
47
+ "npm": ">=7.10.0"
34
48
  },
35
49
  "repository": {
36
50
  "type": "git",
package/public/sw.js ADDED
@@ -0,0 +1,30 @@
1
+ const offlineUrl = '/offline'
2
+
3
+ self.addEventListener('install', function(event) {
4
+ const offlineRequest = new Request(offlineUrl)
5
+
6
+ event.waitUntil(
7
+ fetch(offlineRequest).then(function(response) {
8
+ return caches.open('offline').then(function(cache) {
9
+ console.log('[oninstall] Cached offline page', response.url)
10
+ return cache.put(offlineRequest, response)
11
+ })
12
+ })
13
+ )
14
+ })
15
+
16
+ self.addEventListener('fetch', function(event) {
17
+ const request = event.request
18
+
19
+ if (request.url.match(/\.(css|jpg|jpeg|png|gif|js|woff|woff2|ttf|svg|mp4|webp)$/) || request.url.indexOf(request.referrer) !== 0) {
20
+ } else if (request.method === 'GET') {
21
+ event.respondWith(
22
+ fetch(request).catch(function(error) {
23
+ console.log('[onfetch] Failed. Serving cached offline fallback ' + error)
24
+ return caches.open('offline').then(function(cache) {
25
+ return cache.match(offlineUrl)
26
+ })
27
+ })
28
+ )
29
+ }
30
+ })
@@ -1,4 +1,6 @@
1
1
  {
2
+ "lang": "en",
3
+ "template": "templates/Layout/Main.twig",
2
4
  "prefetch": [
3
5
  "https://cdn.jsdelivr.net",
4
6
  "https://fonts.gstatic.com",
@@ -21,7 +23,6 @@
21
23
  }
22
24
  },
23
25
  "layout": {
24
- "template": "Layout/Main.twig",
25
26
  "cookies": false,
26
27
  "nav": [
27
28
  {
@@ -31,6 +32,10 @@
31
32
  {
32
33
  "name": "Documentation",
33
34
  "url": "/ui"
35
+ },
36
+ {
37
+ "name": "Icons",
38
+ "url": "/ui-icons"
34
39
  }
35
40
  ]
36
41
  },
@@ -0,0 +1,6 @@
1
+ <extends src="templates/Layout.twig">
2
+ <block name="body">
3
+ <include src="templates/Header.twig"></include>
4
+ <include src="templates/Content.twig"></include>
5
+ </block>
6
+ </extends>
@@ -0,0 +1,6 @@
1
+ <extends src="templates/Layout.twig">
2
+ <block name="body">
3
+ <include src="templates/Header.twig"></include>
4
+ <include src="templates/Content.twig"></include>
5
+ </block>
6
+ </extends>
@@ -1,4 +1,4 @@
1
- @import "../styles/Utils/theme/main.css";
1
+ @import "../../styles/Utils/theme/main.css";
2
2
 
3
3
  :root {
4
4
  --width: 660px;
@@ -0,0 +1,16 @@
1
+ <tr class="nlm_content">
2
+ <td>
3
+ <table class="elm_inner_container">
4
+ <tr>
5
+ <td>
6
+ <br />
7
+ <div class="elm_content_heading">Thanks for your email:</div>
8
+ <br />
9
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vitae est dui. Vestibulum vehicula in mi in interdum. Aliquam quis tempor nibh. Duis tincidunt vel purus tincidunt iaculis. In bibendum leo justo, et elementum justo dapibus et. Aliquam eu elementum magna. Fusce egestas urna ac venenatis auctor. Phasellus felis leo, suscipit non est sit amet, lobortis pellentesque urna. Ut enim leo, posuere eget mauris vel, egestas pellentesque metus. Curabitur ut est ut orci blandit suscipit. Morbi lacinia sapien luctus lectus maximus, vitae gravida lectus aliquet. Vestibulum ut placerat diam. Fusce dapibus tincidunt justo, sed venenatis nisl porttitor vitae.</p>
10
+ <br />
11
+ <div class="elm_content_info"><a href="https://www.example.com"><span>www.example.com</span></a></div>
12
+ </td>
13
+ </tr>
14
+ </table>
15
+ </td>
16
+ </tr>
@@ -0,0 +1,14 @@
1
+ <tr class="elm_header">
2
+ <td>
3
+ <table class="elm_inner_container">
4
+ <tr>
5
+ <td>
6
+ <br />
7
+ <a href="#"><img src="https://via.placeholder.com/160x60" width="160" alt="" style="width: 160px" /></a>
8
+ <br />
9
+ <br />
10
+ </td>
11
+ </tr>
12
+ </table>
13
+ </td>
14
+ </tr>
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>Email Template</title>
6
+ <!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]-->
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <style type="text/css">
9
+ @import 'styles/email.css';
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <table class="elm_container_wrapper">
14
+ <tr>
15
+ <td>
16
+ <table class="elm_container">
17
+ <block name="body" with="locals"></block>
18
+ </table>
19
+ </td>
20
+ </tr>
21
+ </table>
22
+ </body>
23
+ </html>
File without changes
@@ -1,2 +1 @@
1
1
  import './CookieConsent.js'
2
- import './Form.js'
@@ -9,23 +9,20 @@ LibStimulus.register('c-cookieconsent', class extends Controller {
9
9
  return
10
10
  }
11
11
 
12
- if (localStorage.getItem('lib-cookieconsent') === null || parseInt(localStorage.getItem('lib-cookieconsent-expire')) < Date.now()) {
12
+ if (LibCookieConsent.getItem('lib-cookieconsent') === null || parseInt(LibCookieConsent.getItem('lib-cookieconsent-expire')) < Date.now()) {
13
13
  setTimeout(() => {
14
14
  selector._addDataValue('state', 'active')
15
15
  selector.classList.add('is-animate')
16
16
  }, 1500)
17
17
  }
18
18
 
19
- selector._hasDataValue('type', 'closable') &&
20
- selector.addEventListener('click', e => {
21
- if (e.target.closest('.c-cookieconsent > .wrp') === null) {
22
- this.hide([])
23
- }
24
- })
25
-
26
19
  selector.querySelector('[data-lib-cookieconsent-approve]').addEventListener('click', () => {
27
20
  this.hide(['performance', 'marketing'])
28
21
  })
22
+
23
+ selector.querySelector('[data-lib-cookieconsent-decline]').addEventListener('click', () => {
24
+ this.hide([])
25
+ })
29
26
  }
30
27
 
31
28
  hide(type) {
@@ -42,10 +39,13 @@ LibStimulus.register('c-cookieconsent', class extends Controller {
42
39
  LibStimulus.register('c-form-cookieconsent', class extends Controller {
43
40
  connect() {
44
41
  const selector = this.element
45
- const type = localStorage.getItem('lib-cookieconsent')
42
+ const type = LibCookieConsent.getItem('lib-cookieconsent')
43
+ const modal = document.querySelector('.c-cookieconsent')
46
44
 
47
- document.querySelector('.c-cookieconsent').classList.remove('is-animate')
48
- document.querySelector('.c-cookieconsent')._removeDataValue('state', 'active')
45
+ if (modal) {
46
+ modal.classList.remove('is-animate')
47
+ modal._removeDataValue('state', 'active')
48
+ }
49
49
 
50
50
  if (type !== null) {
51
51
  this.element.querySelectorAll('input:not([disabled])').forEach(input => {
@@ -74,9 +74,11 @@ LibStimulus.register('c-form-cookieconsent', class extends Controller {
74
74
  }
75
75
 
76
76
  disconnect() {
77
- if (localStorage.getItem('lib-cookieconsent') === null || parseInt(localStorage.getItem('lib-cookieconsent-expire')) < Date.now()) {
78
- document.querySelector('.c-cookieconsent')._addDataValue('state', 'active')
79
- document.querySelector('.c-cookieconsent').classList.add('is-animate')
77
+ const modal = document.querySelector('.c-cookieconsent')
78
+
79
+ if (modal && (LibCookieConsent.getItem('lib-cookieconsent') === null || parseInt(LibCookieConsent.getItem('lib-cookieconsent-expire')) < Date.now())) {
80
+ modal._addDataValue('state', 'active')
81
+ modal.classList.add('is-animate')
80
82
  }
81
83
  }
82
84
  })
@@ -19,9 +19,9 @@ LibStimulus.register('lib', class extends Controller {
19
19
  LibRipple(e)
20
20
  }
21
21
 
22
- anchor(e) {
23
- e.preventDefault()
24
- LibAnchor.action(e.currentTarget)
22
+ anchor({ currentTarget }) {
23
+ arguments[0].preventDefault()
24
+ LibAnchor.action(currentTarget)
25
25
  }
26
26
 
27
27
  darkMode() {
@@ -2,10 +2,11 @@ export { default as Anchor } from './Anchor.js'
2
2
  export { default as CookieConsent } from './CookieConsent.js'
3
3
  export { default as Dialog } from './Dialog.js'
4
4
  import './Drawer.js'
5
- import './Fetch.js'
5
+ import './Form.js'
6
6
  export { default as NativeSlider } from './NativeSlider.js'
7
7
  import './ReCaptcha.js'
8
8
  export { default as Ripple } from './Ripple.js'
9
+ import './Script.js'
9
10
  import './Stimulus.js'
10
11
  export { default as Swup } from './Swup.js'
11
12
  export { default as Tabs } from './Tabs.js'
@@ -1,19 +1,25 @@
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
- const type = localStorage.getItem('lib-cookieconsent')
9
+ const type = LibCookieConsent.getItem('lib-cookieconsent')
4
10
 
5
11
  if (type !== null) {
6
12
  JSON.parse(type).forEach(type => LibCookieConsent.append(type))
7
13
  }
8
14
  },
9
15
  set: (type) => {
10
- localStorage.setItem('lib-cookieconsent', JSON.stringify(type))
11
- localStorage.setItem('lib-cookieconsent-expire', (Date.now() + 31556926 * 1000).toString())
16
+ LibCookieConsent.setItem('lib-cookieconsent', JSON.stringify(type))
17
+ LibCookieConsent.setItem('lib-cookieconsent-expire', (Date.now() + 31556926 * 1000).toString())
12
18
 
13
19
  if (type.length > 0) {
14
20
  type.forEach(type => LibCookieConsent.append(type))
15
21
  } else {
16
- localStorage.setItem('lib-cookieconsent', JSON.stringify([]))
22
+ LibCookieConsent.setItem('lib-cookieconsent', JSON.stringify([]))
17
23
  LibCookieConsent.remove()
18
24
  }
19
25
  },
@@ -8,7 +8,7 @@ const LibDialog = {
8
8
  }
9
9
 
10
10
  if (document.querySelector('.lib-dialog') === null) {
11
- document.body.insertAdjacentHTML('beforeend', '<div class="lib-dialog"></div>')
11
+ document.body.insertAdjacentHTML('beforeend', '<div class="lib-dialog" tabindex="0"></div>')
12
12
  }
13
13
 
14
14
  document.querySelector('.lib-dialog').insertAdjacentHTML('beforeend', content)
@@ -31,6 +31,8 @@ const LibDialog = {
31
31
 
32
32
  loadStimulus(document.querySelector('.lib-dialog'))
33
33
 
34
+ document.querySelector('.lib-dialog').focus()
35
+
34
36
  resolve()
35
37
 
36
38
  document.querySelector('.lib-dialog').addEventListener('mousedown', e => {
@@ -66,8 +68,13 @@ const LibDialog = {
66
68
  })
67
69
  },
68
70
  action: async(element, url) => {
71
+ element._addDataValue('state', 'loading')
72
+ element.classList.add('cursor-wait')
73
+
69
74
  fetch(url, { headers: { 'X-Requested-With': 'XMLHttpRequest' } }).then(response => response.json()).then(({ dialog }) => {
70
75
  LibDialog.show(dialog)
76
+ element._removeDataValue('state', 'loading')
77
+ element.classList.remove('cursor-wait')
71
78
  })
72
79
  }
73
80
  }
@@ -1,38 +1,40 @@
1
1
  import { LibStimulus, Controller } from './Stimulus.js'
2
2
 
3
3
  LibStimulus.register('lib-drawer', class extends Controller {
4
+ static targets = ['nav']
5
+
4
6
  init() {
5
- setTimeout(() => this.queryTarget('nav').classList.add('is-transition'), 50)
6
- this.queryTarget('nav').addEventListener('click', ({ target }) => {
7
- if (target === this.queryTarget('nav')) {
7
+ setTimeout(() => this.navTarget.classList.add('is-transition'), 50)
8
+ this.navTarget.addEventListener('click', ({ target }) => {
9
+ if (target === this.navTarget) {
8
10
  this.hide()
9
11
  }
10
12
  })
11
13
  }
12
14
 
13
15
  show() {
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')
16
+ this.navTarget.scrollLeft = 0
17
+ this.navTarget.style.setProperty('--lib-drawer-opacity', '1')
18
+ this.navTarget.classList.add('is-opacity')
19
+ this.navTarget._addDataValue('state', 'active')
18
20
  document.documentElement.classList.add('overflow-hidden')
19
21
  }
20
22
 
21
23
  hide() {
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')
24
+ this.navTarget._removeDataValue('state', 'active')
25
+ this.navTarget.classList.add('is-opacity')
26
+ this.navTarget.style.setProperty('--lib-drawer-opacity', '0')
25
27
  document.documentElement.classList.remove('overflow-hidden')
26
28
  }
27
29
 
28
30
  scroll({ target }) {
29
31
  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
+ this.navTarget.classList.remove('is-opacity')
33
+ this.navTarget.style.setProperty('--lib-drawer-opacity', `${Math.abs((target.scrollLeft / this.navTarget.children[0].clientWidth) - 1)}`)
32
34
  }
33
35
 
34
- if (target.scrollLeft === this.queryTarget('nav').children[0].clientWidth) {
35
- this.queryTarget('nav')._removeDataValue('state', 'active')
36
+ if (target.scrollLeft === this.navTarget.children[0].clientWidth) {
37
+ this.navTarget._removeDataValue('state', 'active')
36
38
  document.documentElement.classList.remove('overflow-hidden')
37
39
  }
38
40
  }
@@ -0,0 +1,31 @@
1
+ import { LibStimulus, Controller } from './Stimulus.js'
2
+ import { checkValidity } from '../Utils/Functions/+.js'
3
+
4
+ LibStimulus.register('lib-form', class extends Controller {
5
+ connect() {
6
+ this.element.setAttribute('novalidate', '')
7
+ this.element.addEventListener('submit', e => this.validation(e))
8
+ }
9
+
10
+ validation(e) {
11
+ if (this.element.checkValidity() === false) {
12
+ e.preventDefault()
13
+ e.stopPropagation()
14
+
15
+ this.element.querySelector(':invalid').scrollIntoView({ behavior: 'smooth', block: 'center' })
16
+ this.element.querySelector(':invalid').focus()
17
+ }
18
+
19
+ this.element.querySelectorAll('.ui-input, [data-controller="ui-checkbox"], [data-controller="ui-radio"]').forEach(element => {
20
+ checkValidity(element, { message: true })
21
+ })
22
+
23
+ this.element.querySelectorAll('.ui-select:not([data-state*="active"]) select[required]').forEach(select => {
24
+ checkValidity(select.closest('.ui-select'), { message: true })
25
+ })
26
+ }
27
+
28
+ submitForm({ currentTarget }) {
29
+ currentTarget.form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
30
+ }
31
+ })
@@ -49,8 +49,9 @@ export default function LibNativeSlider(selector, parent) {
49
49
  }
50
50
  }
51
51
 
52
+ self.counterMax = parseInt(((selector.scrollWidth - selector.clientWidth) / selector.children[0].clientWidth + 1).toFixed(0))
53
+
52
54
  if (self.ref.counterMax !== null) {
53
- self.counterMax = parseInt(((selector.scrollWidth - selector.clientWidth) / selector.children[0].clientWidth + 1).toFixed(0))
54
55
  self.ref.counterMax.textContent = self.counterMax
55
56
  }
56
57
 
@@ -3,14 +3,19 @@ import importScript from '../Utils/Functions/importScript.js'
3
3
  import cdn from '../Utils/cdn.js'
4
4
 
5
5
  LibStimulus.register('lib-recaptcha', class extends Controller {
6
+ static values = {
7
+ api: String,
8
+ action: String
9
+ }
10
+
6
11
  connect() {
7
- importScript(cdn.recaptcha.replace('{apikey}', this.data.get('api')))
12
+ importScript(cdn.recaptcha.replace('{apikey}', this.apiValue))
8
13
  }
9
14
 
10
15
  async execute() {
11
16
  return new Promise(resolve => {
12
17
  window.grecaptcha.enterprise.ready(() => {
13
- window.grecaptcha.enterprise.execute(this.data.get('api'), { action: this.data.get('action') ? this.data.get('action') : 'form' }).then(token => {
18
+ window.grecaptcha.enterprise.execute(this.apiValue, { action: this.actionValue ?? 'form' }).then(token => {
14
19
  this.element.querySelector('[name="gtoken"]').value = token
15
20
  resolve()
16
21
  })
@@ -18,8 +23,8 @@ LibStimulus.register('lib-recaptcha', class extends Controller {
18
23
  })
19
24
  }
20
25
 
21
- async submit(e) {
22
- e.preventDefault()
26
+ async submit() {
27
+ arguments[0].preventDefault()
23
28
 
24
29
  await this.execute()
25
30
  this.element.submit()
@@ -0,0 +1,19 @@
1
+ import { LibStimulus, Controller } from './Stimulus.js'
2
+
3
+ LibStimulus.register('lib-script', class extends Controller {
4
+ connect() {
5
+ const element = this.element
6
+ const script = document.createElement('script')
7
+
8
+ ;[...element.attributes].forEach(attribute => {
9
+ if (attribute.specified && !attribute.name.includes('type') && !attribute.name.includes('data-controller')) {
10
+ script.setAttribute(attribute.name, attribute.value)
11
+ }
12
+ })
13
+
14
+ script.innerHTML = element.innerHTML
15
+
16
+ element.parentElement.appendChild(script)
17
+ element.remove()
18
+ }
19
+ })