@newlogic-digital/ui 3.2.0 → 3.4.2
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.
- package/README.md +1 -5
- package/package.json +21 -14
- package/src/data/main.json +5 -1
- package/src/emails/{email.css → styles/email.css} +1 -1
- package/src/emails/templates/Content.twig +16 -0
- package/src/emails/templates/Header.twig +14 -0
- package/src/emails/templates/Layout.twig +23 -0
- package/src/scripts/Components/CookieConsent.js +0 -1
- package/src/scripts/Layout/Header.js +23 -11
- package/src/scripts/Layout/Main.js +6 -39
- package/src/scripts/Libraries/+.js +2 -1
- package/src/scripts/Libraries/Dialog.js +35 -65
- package/src/scripts/Libraries/Drawer.js +21 -15
- package/src/scripts/Libraries/Form.js +14 -18
- package/src/scripts/Libraries/Naja.js +35 -0
- package/src/scripts/Libraries/NativeSlider.js +3 -2
- package/src/scripts/Libraries/ReCaptcha.js +24 -4
- package/src/scripts/Libraries/Stimulus.js +1 -31
- package/src/scripts/Libraries/Swup.js +24 -32
- package/src/scripts/Libraries/Tabs.js +5 -5
- package/src/scripts/Libraries/Tippy.js +3 -1
- package/src/scripts/Ui/+.js +0 -1
- package/src/scripts/Ui/Checkbox.js +4 -13
- package/src/scripts/Ui/Input.js +19 -65
- package/src/scripts/Ui/Select.js +11 -39
- package/src/scripts/Ui/Text.js +2 -4
- package/src/scripts/Utils/Functions/+.js +1 -1
- package/src/scripts/Utils/Functions/checkValidity.js +44 -0
- package/src/scripts/Utils/Functions/loadStimulus.js +4 -1
- package/src/scripts/Utils/cdn.js +3 -3
- package/src/scripts/Utils/global.js +6 -8
- package/src/styles/Components/+.css +1 -1
- package/src/styles/Components/Dialog/Default.css +17 -52
- package/src/styles/Components/Dropdown/+.css +1 -0
- package/src/styles/{Ui/Dropdown.css → Components/Dropdown/Default.css} +1 -1
- package/src/styles/Layout/Main.css +4 -20
- package/src/styles/Libraries/+.css +0 -1
- package/src/styles/Libraries/Dialog.css +23 -7
- package/src/styles/Libraries/Drawer.css +3 -9
- package/src/styles/Libraries/Hint.css +4 -3
- package/src/styles/Libraries/NativeSlider.css +8 -0
- package/src/styles/Libraries/Ripple.css +4 -17
- package/src/styles/Libraries/Tippy.css +1 -1
- package/src/styles/Ui/+.css +0 -1
- package/src/styles/Ui/Badge.css +1 -1
- package/src/styles/Ui/Btn.css +24 -6
- package/src/styles/Ui/Checkbox.css +28 -3
- package/src/styles/Ui/Heading.css +2 -1
- package/src/styles/Ui/Icon.css +2 -2
- package/src/styles/Ui/Image.css +1 -7
- package/src/styles/Ui/Input.css +65 -18
- package/src/styles/Ui/Label.css +2 -2
- package/src/styles/Ui/Link.css +13 -6
- package/src/styles/Ui/Notice.css +1 -1
- package/src/styles/Ui/Select.css +3 -5
- package/src/styles/Ui/Text.css +18 -4
- package/src/styles/Ui/Title.css +3 -2
- package/src/styles/Utils/+.css +1 -0
- package/src/styles/Utils/breakpoints.css +9 -0
- package/src/styles/Utils/default.css +12 -115
- package/src/styles/Utils/tailwind/+.css +1 -0
- package/src/styles/Utils/tailwind/base.css +0 -12
- package/src/styles/Utils/tailwind/utilities.css +48 -0
- package/src/styles/Utils/vars.css +28 -39
- package/src/styles/Utils/vendor.css +2 -1
- package/src/styles/main.css +2 -3
- package/src/templates/Components/Dialogs/Basic.twig +15 -17
- package/src/templates/Layout/Main.twig +0 -6
- package/src/templates/Sections/Ui/Docs/@intro.html +97 -0
- package/src/templates/Sections/Ui/Docs/@nav.html +195 -0
- package/src/templates/Sections/Ui/Docs/@styles.html +100 -0
- package/src/templates/Sections/Ui/Docs/Default.twig +1600 -0
- package/src/templates/Sections/Ui/Icons.html +28 -0
- package/src/templates/Sections/Ui/Intro.html +136 -0
- package/src/templates/Sections/Ui.twig +5 -2090
- package/src/templates/Utils/sections.twig +2 -2
- package/src/views/{dialog-basic.json.twig → dialog/basic.json.twig} +1 -1
- package/src/views/{json-tippy.json.twig → dropdown/tippy.json.twig} +3 -3
- package/src/views/email/email.twig +6 -0
- package/src/views/gdpr.json +2 -1
- package/src/views/index.json +2 -2
- package/src/views/ui-icons.json +12 -0
- package/src/views/ui.json +2 -2
- package/vite.config.js +24 -4
- package/src/emails/email.twig +0 -60
- package/src/scripts/Ui/Radio.js +0 -23
- package/src/scripts/Utils/Functions/inView.js +0 -25
- package/src/styles/Components/Item/+.css +0 -1
- package/src/styles/Libraries/Lazysizes.css +0 -9
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
import { Application, Controller
|
|
1
|
+
import { Application, Controller } from '@hotwired/stimulus'
|
|
2
2
|
import loadStimulus from '../Utils/Functions/loadStimulus.js'
|
|
3
3
|
|
|
4
4
|
const LibStimulus = new Application(document.documentElement)
|
|
5
5
|
|
|
6
6
|
const getController = (element, identifier) => LibStimulus.getControllerForElementAndIdentifier(element, identifier)
|
|
7
7
|
|
|
8
|
-
class Controller extends DefaultController {
|
|
9
|
-
getValue(value) {
|
|
10
|
-
return this[`${value}Value`]
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
setValue(type, value) {
|
|
14
|
-
this[`${type}Value`] = value
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
hasValue(value) {
|
|
18
|
-
return this.data.has(`${value}Value`)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
getClass(value) {
|
|
22
|
-
return this.data.get(`${value}Class`)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
queryTarget(target) {
|
|
26
|
-
return this.targets.find(target)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
queryTargetAll(targets) {
|
|
30
|
-
return this.targets.findAll(targets)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
hasTarget(target) {
|
|
34
|
-
return this.targets.has(target)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
8
|
LibStimulus.start().then(() => loadStimulus(document.body))
|
|
39
9
|
|
|
40
10
|
window.LibStimulus = { default: LibStimulus, Controller, loadStimulus }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Swup from 'swup'
|
|
2
2
|
import { getController, loadStimulus } from './Stimulus.js'
|
|
3
|
+
import { closeDialog } from 'winduum/src/libraries/dialog.js'
|
|
3
4
|
import LibAnchor from './Anchor.js'
|
|
4
|
-
import LibDialog from './Dialog.js'
|
|
5
5
|
import LibCookieConsent from './CookieConsent.js'
|
|
6
6
|
import replaceTag from '../Utils/Functions/replaceTag.js'
|
|
7
7
|
|
|
@@ -10,15 +10,21 @@ const LibSwup = new Swup({
|
|
|
10
10
|
linkSelector: `:is(a[href^="${window.location.origin}"], a[href^="/"]):not([data-no-swup], [data-naja], [target="_blank"])`
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
LibSwup.on('clickLink', async() => {
|
|
13
|
+
LibSwup.on('clickLink', async({ target }) => {
|
|
14
14
|
document.body.classList.remove('overflow-hidden')
|
|
15
15
|
|
|
16
16
|
if (document.querySelector('.lib-drawer[data-state~="active"]') !== null) {
|
|
17
|
-
|
|
17
|
+
/** @type {LibDrawer} */
|
|
18
|
+
const LibDrawer = getController(document.body, 'lib-drawer')
|
|
19
|
+
LibDrawer.hide()
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
if (document.querySelector('.lib-dialog') !== null) {
|
|
21
|
-
await
|
|
23
|
+
await closeDialog()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (window.location.href === target.closest('a').href) {
|
|
27
|
+
document.documentElement.scroll({ top: 0 })
|
|
22
28
|
}
|
|
23
29
|
})
|
|
24
30
|
|
|
@@ -26,47 +32,33 @@ LibSwup.on('animationOutDone', () => {
|
|
|
26
32
|
document.documentElement.scroll({ top: 0, behavior: 'instant' })
|
|
27
33
|
})
|
|
28
34
|
|
|
35
|
+
/** @var {Array} dataLayer */
|
|
36
|
+
/** @var {Function} rc */
|
|
37
|
+
/** @var {Function} retargetingHit */
|
|
38
|
+
/** @var {Function} conversionHit */
|
|
39
|
+
/** @var {Object} retargetingConf */
|
|
40
|
+
/** @var {Object} conversionConf */
|
|
41
|
+
/** @var {Function} fbq */
|
|
29
42
|
LibSwup.on('contentReplaced', () => {
|
|
30
43
|
const content = new DOMParser().parseFromString(LibSwup.cache.getCurrentPage().originalContent, 'text/html')
|
|
31
44
|
|
|
32
45
|
replaceTag(content)
|
|
33
46
|
|
|
34
47
|
LibAnchor.init()
|
|
48
|
+
LibCookieConsent.init()
|
|
35
49
|
|
|
36
50
|
LibSwup.options.containers.forEach(selector => {
|
|
37
51
|
loadStimulus(document.querySelector(selector))
|
|
38
52
|
})
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (typeof gtag !== 'undefined') {
|
|
45
|
-
const configs = []
|
|
46
|
-
window.dataLayer.forEach(function(config) {
|
|
47
|
-
if (config[0] === 'config') {
|
|
48
|
-
if (typeof config[1] !== 'undefined' && !configs.includes(config[1])) {
|
|
49
|
-
configs.push(config[1])
|
|
50
|
-
window.gtag('config', config[1], {
|
|
51
|
-
page_title: document.title,
|
|
52
|
-
page_path: window.location.pathname + window.location.search
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
}
|
|
54
|
+
window.dataLayer && window.dataLayer.push({
|
|
55
|
+
event: 'page_view'
|
|
56
|
+
})
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
event: 'VirtualPageview',
|
|
62
|
-
virtualPageURL: window.location.pathname + window.location.search,
|
|
63
|
-
virtualPageTitle: document.title
|
|
64
|
-
})
|
|
65
|
-
}
|
|
58
|
+
window.rc?.retargetingHit && window.rc.retargetingHit(window.retargetingConf)
|
|
59
|
+
window.rc?.conversionHit && window.rc.conversionHit(window.conversionConf)
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
LibCookieConsent.init()
|
|
69
|
-
}
|
|
61
|
+
window.fbq && window.fbq('track', 'PageView')
|
|
70
62
|
})
|
|
71
63
|
|
|
72
64
|
export default LibSwup
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export default function LibTabs(element) {
|
|
2
2
|
element.querySelector('[data-lib-tabs-nav]').querySelectorAll('[data-lib-tabs-item="nav"]').forEach((selector, index) => {
|
|
3
|
-
selector.addEventListener('click',
|
|
4
|
-
|
|
3
|
+
selector.addEventListener('click', () => {
|
|
4
|
+
arguments[0].preventDefault()
|
|
5
5
|
|
|
6
|
-
selector.closest('[data-lib-tabs-nav]').querySelectorAll('[data-lib-tabs-item="nav"]').forEach(
|
|
6
|
+
selector.closest('[data-lib-tabs-nav]').querySelectorAll('[data-lib-tabs-item="nav"]').forEach(element => element._removeDataValue('state', 'active'))
|
|
7
7
|
selector._addDataValue('state', 'active')
|
|
8
8
|
|
|
9
|
-
;[...element.querySelector('[data-lib-tabs-area]').children].forEach(
|
|
10
|
-
|
|
9
|
+
;[...element.querySelector('[data-lib-tabs-area]').children].forEach(element => {
|
|
10
|
+
element._removeDataValue('state', 'active')
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
element.querySelector('[data-lib-tabs-area]').children[index]._addDataValue('state', 'active')
|
|
@@ -27,7 +27,7 @@ export default class LibTippy {
|
|
|
27
27
|
options.content = document.querySelector('#' + template).innerHTML
|
|
28
28
|
} else {
|
|
29
29
|
options.content = `
|
|
30
|
-
<div class="
|
|
30
|
+
<div class="c-dropdown">
|
|
31
31
|
<div class="wrp_dropdown_body">
|
|
32
32
|
${element.getAttribute('aria-label')}
|
|
33
33
|
</div>
|
|
@@ -99,12 +99,14 @@ export default class LibTippy {
|
|
|
99
99
|
element.addEventListener(event, async function e() {
|
|
100
100
|
if (self.template.startsWith('/') && self.options.content === '') {
|
|
101
101
|
element.style.cursor = 'wait'
|
|
102
|
+
element._addDataValue('state', 'loading')
|
|
102
103
|
|
|
103
104
|
fetch(self.template, { headers: { 'X-Requested-With': 'XMLHttpRequest' } }).then(response => {
|
|
104
105
|
return response.json()
|
|
105
106
|
}).then(async(data) => {
|
|
106
107
|
self.options.content = data.content
|
|
107
108
|
element.style.cursor = ''
|
|
109
|
+
element._removeDataValue('state', 'loading')
|
|
108
110
|
await self.init(element, self.options, self.template)
|
|
109
111
|
element.removeEventListener(event, e)
|
|
110
112
|
})
|
package/src/scripts/Ui/+.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
|
|
2
|
+
import { checkValidity } from '../Utils/Functions/+.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
validate(element) {
|
|
5
|
-
element.parentNode._removeDataValue('state', 'valid invalid')
|
|
6
|
-
|
|
7
|
-
if (element.checkValidity()) {
|
|
8
|
-
element.parentNode._addDataValue('state', 'valid')
|
|
9
|
-
} else {
|
|
10
|
-
element.parentNode._addDataValue('state', 'invalid')
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
4
|
+
['ui-checkbox', 'ui-radio'].forEach(identifier => LibStimulus.register(identifier, class extends Controller {
|
|
14
5
|
connect() {
|
|
15
6
|
const input = this.element.querySelector('input:not([type="hidden"])')
|
|
16
7
|
|
|
17
|
-
input.addEventListener('change', () => this.
|
|
8
|
+
input.addEventListener('change', () => checkValidity(this.element))
|
|
18
9
|
}
|
|
19
|
-
})
|
|
10
|
+
}))
|
package/src/scripts/Ui/Input.js
CHANGED
|
@@ -1,62 +1,20 @@
|
|
|
1
1
|
import cdn from '../Utils/cdn.js'
|
|
2
2
|
import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
|
|
3
|
-
import { importStyle } from '../Utils/Functions/+.js'
|
|
3
|
+
import { importStyle, checkValidity } from '../Utils/Functions/+.js'
|
|
4
4
|
|
|
5
5
|
LibStimulus.register('ui-input', class extends Controller {
|
|
6
6
|
async connect() {
|
|
7
|
-
|
|
7
|
+
checkValidity(this.element, { validate: false })
|
|
8
8
|
|
|
9
|
-
this.
|
|
9
|
+
this.element.addEventListener('change', () => checkValidity(this.element))
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
this.validate(element, true)
|
|
13
|
-
})
|
|
11
|
+
this.typeNumber(this.element)
|
|
14
12
|
|
|
15
|
-
this.
|
|
13
|
+
this.typeFile(this.element)
|
|
16
14
|
|
|
17
|
-
this.
|
|
15
|
+
await this.typeDatetime(this.element)
|
|
18
16
|
|
|
19
|
-
await this.
|
|
20
|
-
|
|
21
|
-
await this.typeColor(element)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
validate(element, validate) {
|
|
25
|
-
const input = element.querySelectorAll('input, textarea')
|
|
26
|
-
|
|
27
|
-
input.forEach(input => {
|
|
28
|
-
let validationMessage = input.validationMessage
|
|
29
|
-
|
|
30
|
-
if (typeof input.dataset.validationMessage !== 'undefined') {
|
|
31
|
-
validationMessage = input.dataset.validationMessage
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (input.outerHTML.match(/(data-novalidate|readonly|hidden|data-state="invalid")/) === null && validate) {
|
|
35
|
-
element._removeDataValue('state', 'valid invalid active')
|
|
36
|
-
|
|
37
|
-
if (element.querySelector('[class^="icon"][class*="valid"]') !== null) {
|
|
38
|
-
element.querySelector('[class^="icon"][class*="valid"]').remove()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (input.checkValidity()) {
|
|
42
|
-
element._addDataValue('state', 'valid')
|
|
43
|
-
} else {
|
|
44
|
-
element._addDataValue('state', 'invalid')
|
|
45
|
-
|
|
46
|
-
if (element.querySelector('[class^="icon"][class*="valid"]') === null) {
|
|
47
|
-
const icon = element.querySelector('.icon-r')
|
|
48
|
-
const elm = icon || element
|
|
49
|
-
const where = icon ? 'afterend' : 'beforeend'
|
|
50
|
-
|
|
51
|
-
elm.insertAdjacentHTML(where, `<div class="icon-r icon-invalid text-error lib-hint-top lib-hint-error" tabindex="0" aria-label="${validationMessage}"><svg><use href="#icon-exclamation-circle"></use></svg></div>`)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (input.value !== '') {
|
|
57
|
-
element._addDataValue('state', 'active')
|
|
58
|
-
}
|
|
59
|
-
})
|
|
17
|
+
await this.typeColor(this.element)
|
|
60
18
|
}
|
|
61
19
|
|
|
62
20
|
typeNumber(element) {
|
|
@@ -80,7 +38,7 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
80
38
|
const num = parseInt(input.value === '' ? 0 : input.value) + parseInt(input.step === '' ? 1 : input.step)
|
|
81
39
|
|
|
82
40
|
if (num <= input.max || input.max === '') {
|
|
83
|
-
input.value = num
|
|
41
|
+
input.value = num.toString()
|
|
84
42
|
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
85
43
|
}
|
|
86
44
|
})
|
|
@@ -90,7 +48,7 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
90
48
|
const num = parseInt(input.value) - parseInt(input.step === '' ? 1 : input.step)
|
|
91
49
|
|
|
92
50
|
if (num >= input.min || input.min === '') {
|
|
93
|
-
input.value = num
|
|
51
|
+
input.value = num.toString()
|
|
94
52
|
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
95
53
|
}
|
|
96
54
|
})
|
|
@@ -101,7 +59,7 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
101
59
|
const date = element.querySelector('[type^="date"]')
|
|
102
60
|
|
|
103
61
|
if (date !== null && !document.documentElement.classList.contains('mobile')) {
|
|
104
|
-
const lang = await import(
|
|
62
|
+
const lang = await import(/* @vite-ignore */ cdn.datepickerLang.replace('{lang}', document.documentElement.lang === 'en' ? 'cs' : document.documentElement.lang))
|
|
105
63
|
const { Datepicker } = await import('vanillajs-datepicker')
|
|
106
64
|
|
|
107
65
|
await importStyle(cdn.datepicker)
|
|
@@ -119,7 +77,7 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
119
77
|
const hidden = element.querySelector('[type="hidden"]')
|
|
120
78
|
|
|
121
79
|
if (datetime && hidden.value.indexOf(':') !== -1) {
|
|
122
|
-
hidden.setAttribute('data-time', hidden.value.
|
|
80
|
+
hidden.setAttribute('data-time', hidden.value.substring(hidden.value.indexOf(':') - 2, hidden.value.length))
|
|
123
81
|
}
|
|
124
82
|
|
|
125
83
|
const datepicker = new Datepicker(element.querySelector('[type="text"]'), Object.assign({
|
|
@@ -205,7 +163,7 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
205
163
|
datepicker.element.focus()
|
|
206
164
|
})
|
|
207
165
|
|
|
208
|
-
footer.querySelector('[data-ok]').addEventListener('click',
|
|
166
|
+
footer.querySelector('[data-ok]').addEventListener('click', () => {
|
|
209
167
|
if (hidden.value === '') {
|
|
210
168
|
footer.querySelector('.today-btn').click()
|
|
211
169
|
}
|
|
@@ -236,20 +194,16 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
236
194
|
|
|
237
195
|
async typeColor(element) {
|
|
238
196
|
if (element.querySelector('[type="color"]') !== null) {
|
|
197
|
+
const Pickr = (await import('@simonwep/pickr')).default
|
|
198
|
+
const input = element.querySelector('input')
|
|
199
|
+
|
|
200
|
+
await importStyle(cdn.pickrCss)
|
|
201
|
+
|
|
239
202
|
element.setAttribute('data-type', 'color')
|
|
240
203
|
element.querySelector('[type="color"]').setAttribute('inputmode', 'none')
|
|
241
204
|
element.querySelector('[type="color"]').setAttribute('type', 'text')
|
|
242
205
|
element.insertAdjacentHTML('afterbegin', '<span class="color"></span>')
|
|
243
206
|
|
|
244
|
-
await importStyle(cdn.pickr_css)
|
|
245
|
-
|
|
246
|
-
let Pickr = (await import('@simonwep/pickr')).default
|
|
247
|
-
|
|
248
|
-
if (typeof Pickr.default !== 'undefined') {
|
|
249
|
-
Pickr = Pickr.default
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const input = element.querySelector('input')
|
|
253
207
|
input.setAttribute('maxlength', '9')
|
|
254
208
|
input.setAttribute('pattern', '^#?([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$')
|
|
255
209
|
|
|
@@ -278,8 +232,8 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
278
232
|
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
279
233
|
})
|
|
280
234
|
|
|
281
|
-
input.addEventListener('change',
|
|
282
|
-
pickr.setColor(
|
|
235
|
+
input.addEventListener('change', ({ target }) => {
|
|
236
|
+
pickr.setColor(target.value)
|
|
283
237
|
})
|
|
284
238
|
}
|
|
285
239
|
}
|
package/src/scripts/Ui/Select.js
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
1
|
import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
|
|
2
|
+
import { checkValidity } from '../Utils/Functions/+.js'
|
|
2
3
|
|
|
3
4
|
LibStimulus.register('ui-select', class extends Controller {
|
|
4
|
-
validate(element, select) {
|
|
5
|
-
element._removeDataValue('state', 'invalid valid focus')
|
|
6
|
-
|
|
7
|
-
if (element.querySelector('[class^="icon"][class*="valid"]') !== null) {
|
|
8
|
-
element.querySelector('[class^="icon"][class*="valid"]').remove()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let validationMessage = select.validationMessage
|
|
12
|
-
|
|
13
|
-
if (typeof select.dataset.validationMessage !== 'undefined') {
|
|
14
|
-
validationMessage = select.dataset.validationMessage
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (select.checkValidity()) {
|
|
18
|
-
element._addDataValue('state', 'valid')
|
|
19
|
-
} else {
|
|
20
|
-
element._addDataValue('state', 'invalid')
|
|
21
|
-
|
|
22
|
-
if (element.querySelector('[class^="icon"][class*="valid"]') === null) {
|
|
23
|
-
const icon = element.querySelector('.icon-r')
|
|
24
|
-
const elm = icon || element
|
|
25
|
-
const where = icon ? 'afterend' : 'beforeend'
|
|
26
|
-
|
|
27
|
-
elm.insertAdjacentHTML(where, `<div class="icon-r icon-invalid text-error lib-hint-top lib-hint-error" tabindex="0" aria-label="${validationMessage}"><svg><use href="#icon-exclamation-circle"></use></svg></div>`)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
5
|
connect() {
|
|
33
6
|
const element = this.element
|
|
34
7
|
const select = element.querySelector('select')
|
|
@@ -44,8 +17,8 @@ LibStimulus.register('ui-select', class extends Controller {
|
|
|
44
17
|
element.addEventListener('blur', function e() {
|
|
45
18
|
element._removeDataValue('state', 'focus')
|
|
46
19
|
element.removeEventListener('blur', e)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
20
|
+
})
|
|
21
|
+
})
|
|
49
22
|
|
|
50
23
|
element.addEventListener('click', e => {
|
|
51
24
|
if ((element._hasDataValue('state', 'focus') && e.timeStamp === 0) || e.target.tagName === 'OPTION') {
|
|
@@ -54,13 +27,8 @@ LibStimulus.register('ui-select', class extends Controller {
|
|
|
54
27
|
})
|
|
55
28
|
|
|
56
29
|
select.addEventListener('change', () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (select.value === '') {
|
|
60
|
-
element._removeDataValue('state', 'active')
|
|
61
|
-
} else {
|
|
62
|
-
element._addDataValue('state', 'active')
|
|
63
|
-
}
|
|
30
|
+
checkValidity(element)
|
|
31
|
+
this.valueCheck(select)
|
|
64
32
|
})
|
|
65
33
|
|
|
66
34
|
if (option[0] !== null) {
|
|
@@ -72,10 +40,14 @@ LibStimulus.register('ui-select', class extends Controller {
|
|
|
72
40
|
})
|
|
73
41
|
}
|
|
74
42
|
|
|
43
|
+
this.valueCheck(select)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
valueCheck(select) {
|
|
75
47
|
if (select.value === '') {
|
|
76
|
-
element._removeDataValue('state', 'active')
|
|
48
|
+
this.element._removeDataValue('state', 'active')
|
|
77
49
|
} else {
|
|
78
|
-
element._addDataValue('state', 'active')
|
|
50
|
+
this.element._addDataValue('state', 'active')
|
|
79
51
|
}
|
|
80
52
|
}
|
|
81
53
|
})
|
package/src/scripts/Ui/Text.js
CHANGED
|
@@ -2,13 +2,11 @@ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
|
|
|
2
2
|
|
|
3
3
|
LibStimulus.register('ui-text', class extends Controller {
|
|
4
4
|
connect() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Array.from(element.querySelectorAll('table')).forEach(table => {
|
|
5
|
+
this.element.querySelectorAll('table').forEach(table => {
|
|
8
6
|
this.wrap(table, new DOMParser().parseFromString('<div class="elm_text_table"></div>', 'text/html').body.firstChild)
|
|
9
7
|
})
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
this.element.querySelectorAll('iframe').forEach(iframe => {
|
|
12
10
|
if (iframe.src.match(/youtube\.com/i)) {
|
|
13
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)
|
|
14
12
|
} else if (iframe.width && iframe.style.aspectRatio !== 'undefined') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
export { default as checkValidity } from './checkValidity.js'
|
|
1
2
|
import './dataValue.js'
|
|
2
3
|
export { default as importScript } from './importScript.js'
|
|
3
4
|
export { default as importStyle } from './importStyle.js'
|
|
4
|
-
export { default as inView } from './inView.js'
|
|
5
5
|
export { default as loadStimulus } from './loadStimulus.js'
|
|
6
6
|
export { default as replaceTag } from './replaceTag.js'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default function checkValidity(element, options = {}) {
|
|
2
|
+
const { validate, message } = Object.assign({ validate: true, message: false }, options)
|
|
3
|
+
const selectors = element.querySelectorAll('input, textarea, select')
|
|
4
|
+
|
|
5
|
+
selectors.forEach(selector => {
|
|
6
|
+
const isInput = element.classList.contains('ui-input')
|
|
7
|
+
const isSelect = element.classList.contains('ui-select')
|
|
8
|
+
const validationMessage = selector.dataset.validationMessage ?? selector.validationMessage
|
|
9
|
+
const validityElement = element.closest('.ui-input-group')?.querySelector('em') ?? element.querySelector('em')
|
|
10
|
+
|
|
11
|
+
if (!selector.outerHTML.match(/(data-novalidate|readonly|hidden)/) && validate) {
|
|
12
|
+
element._removeDataValue('state', 'valid invalid active')
|
|
13
|
+
|
|
14
|
+
if ((isInput || isSelect) && element.querySelector('[class^="icon"][class*="valid"]') !== null) {
|
|
15
|
+
element.querySelector('[class^="icon"][class*="valid"]').remove()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (selector.checkValidity()) {
|
|
19
|
+
element._addDataValue('state', 'valid')
|
|
20
|
+
|
|
21
|
+
if (validityElement) {
|
|
22
|
+
validityElement.remove()
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
element._addDataValue('state', 'invalid')
|
|
26
|
+
|
|
27
|
+
if (!validityElement && message) {
|
|
28
|
+
(element.closest('.ui-input-group') ?? element).insertAdjacentHTML('beforeend', `<em>${validationMessage}</em>`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if ((isInput || isSelect) && element.querySelector('[class^="icon"][class*="valid"]') === null) {
|
|
32
|
+
const icon = element.querySelector('.icon-r')
|
|
33
|
+
const where = icon || element
|
|
34
|
+
|
|
35
|
+
where.insertAdjacentHTML(icon ? 'afterend' : 'beforeend', `<div class="icon-r icon-invalid text-error lib-hint-top lib-hint-error" tabindex="0" aria-label="${validationMessage}"><svg><use href="#icon-exclamation-circle"></use></svg></div>`)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (isInput && selector.value !== '') {
|
|
41
|
+
element._addDataValue('state', 'active')
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import naja from 'naja'
|
|
2
|
+
|
|
1
3
|
const dynamicControllers = ['ui-input', 'ui-select', 'ui-text', 'ui-checkbox', 'ui-radio', 'c-cookieconsent', 'c-form-cookieconsent']
|
|
2
4
|
const dynamicActions = [['.ui-btn', 'click->lib#ripple']]
|
|
3
5
|
|
|
@@ -33,7 +35,8 @@ function loadActions(parent, selectors) {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
export default function loadStimulus(selector) {
|
|
38
|
+
export default function loadStimulus(selector, najaLoad = true) {
|
|
37
39
|
loadControllers(selector, dynamicControllers)
|
|
38
40
|
loadActions(selector, dynamicActions)
|
|
41
|
+
najaLoad && naja.uiHandler.bindUI(selector)
|
|
39
42
|
}
|
package/src/scripts/Utils/cdn.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
recaptcha: 'https://www.google.com/recaptcha/enterprise.js?render={apikey}',
|
|
3
|
-
|
|
4
|
-
pickr_css: 'https://cdn.jsdelivr.net/npm/@simonwep/pickr@1.8.0/dist/themes/nano.min.css',
|
|
3
|
+
pickrCss: 'https://cdn.jsdelivr.net/npm/@simonwep/pickr@1.8.2/dist/themes/nano.min.css',
|
|
5
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',
|
|
6
|
-
datepicker: 'https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.
|
|
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'
|
|
7
7
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
!CSS.supports('selector(:has(*))') && (async() => (await import('css-has-pseudo/browser')).default(document))()
|
|
2
|
+
|
|
1
3
|
if ('serviceWorker' in navigator && location.protocol === 'https:') {
|
|
2
4
|
window.addEventListener('load', () => {
|
|
3
5
|
if (!document.documentElement.classList.contains('no-sw')) {
|
|
4
|
-
navigator.serviceWorker.register('/sw.js').catch(e =>
|
|
5
|
-
console.error('Error during service worker registration:', e)
|
|
6
|
-
})
|
|
6
|
+
navigator.serviceWorker.register('/sw.js').catch(e => console.error(e))
|
|
7
7
|
} else {
|
|
8
|
-
navigator.serviceWorker.getRegistrations().then(registrations => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
registration.unregister()
|
|
12
|
-
}
|
|
8
|
+
navigator.serviceWorker.getRegistrations().then(async registrations => {
|
|
9
|
+
for (const registration of registrations) {
|
|
10
|
+
await registration.unregister()
|
|
13
11
|
}
|
|
14
12
|
})
|
|
15
13
|
}
|