@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.
- package/.eslintrc +13 -0
- package/.stylelintrc +18 -0
- package/README.md +15 -17
- package/package.json +29 -15
- package/public/sw.js +30 -0
- package/src/{main.json → data/main.json} +6 -1
- package/src/emails/email.prod.html +6 -0
- package/src/emails/email.twig.html +6 -0
- 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/emails/templates.prod/.gitkeep +0 -0
- package/src/scripts/Components/+.js +0 -1
- package/src/scripts/Components/CookieConsent.js +16 -14
- package/src/scripts/Layout/Main.js +3 -3
- package/src/scripts/Libraries/+.js +2 -1
- package/src/scripts/Libraries/CookieConsent.js +10 -4
- package/src/scripts/Libraries/Dialog.js +8 -1
- package/src/scripts/Libraries/Drawer.js +16 -14
- package/src/scripts/Libraries/Form.js +31 -0
- package/src/scripts/Libraries/NativeSlider.js +2 -1
- package/src/scripts/Libraries/ReCaptcha.js +9 -4
- package/src/scripts/Libraries/Script.js +19 -0
- package/src/scripts/Libraries/Stimulus.js +1 -31
- package/src/scripts/Libraries/Swup.js +7 -10
- 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 +23 -69
- package/src/scripts/Ui/Select.js +11 -39
- package/src/scripts/Ui/Text.js +2 -4
- package/src/scripts/Utils/+.js +3 -0
- package/src/scripts/Utils/Functions/+.js +2 -1
- package/src/scripts/Utils/Functions/checkValidity.js +44 -0
- package/src/scripts/Utils/Functions/inView.js +7 -8
- package/src/scripts/Utils/Functions/replaceTag.js +12 -0
- package/src/scripts/Utils/cdn.js +1 -1
- package/src/scripts/Utils/global.js +6 -8
- package/src/styles/Components/+.css +1 -1
- package/src/styles/Components/Dropdown/+.css +1 -0
- package/src/styles/{Ui/Dropdown.css → Components/Dropdown/Default.css} +1 -1
- package/src/styles/Layout/Header.css +54 -0
- package/src/styles/Libraries/+.css +0 -1
- package/src/styles/Libraries/Drawer.css +1 -1
- package/src/styles/Libraries/Hint.css +4 -3
- package/src/styles/Libraries/NativeSlider.css +9 -1
- 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 -2
- 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 +12 -5
- package/src/styles/Ui/Notice.css +1 -1
- package/src/styles/Ui/Select.css +3 -5
- package/src/styles/Ui/Text.css +13 -4
- package/src/styles/Ui/Title.css +3 -2
- package/src/styles/Utils/+.css +9 -0
- package/src/styles/Utils/default.css +0 -7
- package/src/styles/Utils/keyframes.css +4 -4
- package/src/styles/Utils/tailwind/+.css +2 -0
- package/src/styles/Utils/tailwind/base.css +25 -0
- package/src/styles/Utils/theme/+.css +1 -0
- package/src/styles/Utils/vars.css +32 -8
- package/src/styles/main.css +2 -0
- package/src/templates/Components/CookieConsent.twig +2 -2
- package/src/templates/Layout/Main.twig +1 -7
- 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 -2101
- package/src/templates/Utils/sections.twig +2 -2
- package/src/views/dialog/basic.json.twig +3 -0
- package/src/{templates/json-tippy.twig → views/dropdown/tippy.json.twig} +3 -3
- package/src/views/gdpr.json +12 -0
- package/src/{templates → views}/index.json +2 -2
- package/src/{templates/ui.json → views/ui-icons.json} +3 -2
- package/src/{templates/gdpr.json → views/ui.json} +1 -1
- package/tailwind.config.cjs +69 -0
- package/vite.config.js +10 -0
- package/gulpfile.js +0 -41
- package/src/emails/email.twig +0 -60
- package/src/scripts/Components/Form.js +0 -33
- package/src/scripts/Ui/Radio.js +0 -23
- package/src/styles/Components/Item/+.css +0 -1
- package/src/styles/Libraries/Lazysizes.css +0 -9
- package/src/styles/tailwind.css +0 -2
- package/src/templates/dialog-basic.twig +0 -3
|
@@ -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 }
|
|
@@ -3,13 +3,14 @@ import { getController, loadStimulus } from './Stimulus.js'
|
|
|
3
3
|
import LibAnchor from './Anchor.js'
|
|
4
4
|
import LibDialog from './Dialog.js'
|
|
5
5
|
import LibCookieConsent from './CookieConsent.js'
|
|
6
|
+
import replaceTag from '../Utils/Functions/replaceTag.js'
|
|
6
7
|
|
|
7
8
|
const LibSwup = new Swup({
|
|
8
9
|
containers: ['#l-main', '#l-header'].filter(element => document.querySelector(element)),
|
|
9
10
|
linkSelector: `:is(a[href^="${window.location.origin}"], a[href^="/"]):not([data-no-swup], [data-naja], [target="_blank"])`
|
|
10
11
|
})
|
|
11
12
|
|
|
12
|
-
LibSwup.on('clickLink', async() => {
|
|
13
|
+
LibSwup.on('clickLink', async({ target }) => {
|
|
13
14
|
document.body.classList.remove('overflow-hidden')
|
|
14
15
|
|
|
15
16
|
if (document.querySelector('.lib-drawer[data-state~="active"]') !== null) {
|
|
@@ -19,6 +20,10 @@ LibSwup.on('clickLink', async() => {
|
|
|
19
20
|
if (document.querySelector('.lib-dialog') !== null) {
|
|
20
21
|
await LibDialog.hide()
|
|
21
22
|
}
|
|
23
|
+
|
|
24
|
+
if (window.location.href === target.closest('a').href) {
|
|
25
|
+
document.documentElement.scroll({ top: 0 })
|
|
26
|
+
}
|
|
22
27
|
})
|
|
23
28
|
|
|
24
29
|
LibSwup.on('animationOutDone', () => {
|
|
@@ -28,15 +33,7 @@ LibSwup.on('animationOutDone', () => {
|
|
|
28
33
|
LibSwup.on('contentReplaced', () => {
|
|
29
34
|
const content = new DOMParser().parseFromString(LibSwup.cache.getCurrentPage().originalContent, 'text/html')
|
|
30
35
|
|
|
31
|
-
content
|
|
32
|
-
const tag = document.querySelector(`[data-lib-swup-replace=${element.dataset.libSwupReplace}]`)
|
|
33
|
-
|
|
34
|
-
if (tag !== null) {
|
|
35
|
-
tag.outerHTML = element.outerHTML
|
|
36
|
-
} else {
|
|
37
|
-
document.head.insertAdjacentHTML('beforeend', element.outerHTML)
|
|
38
|
-
}
|
|
39
|
-
})
|
|
36
|
+
replaceTag(content)
|
|
40
37
|
|
|
41
38
|
LibAnchor.init()
|
|
42
39
|
|
|
@@ -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) {
|
|
@@ -77,20 +35,20 @@ LibStimulus.register('ui-input', class extends Controller {
|
|
|
77
35
|
|
|
78
36
|
element.querySelector('[data-action="plus"]').addEventListener('click', () => {
|
|
79
37
|
const input = this.element.querySelector('input')
|
|
80
|
-
const num = parseInt(input.value === '' ? 0 : input.value) + parseInt(input.step)
|
|
38
|
+
const num = parseInt(input.value === '' ? 0 : input.value) + parseInt(input.step === '' ? 1 : input.step)
|
|
81
39
|
|
|
82
|
-
if (num <= input.max) {
|
|
83
|
-
input.value = num
|
|
40
|
+
if (num <= input.max || input.max === '') {
|
|
41
|
+
input.value = num.toString()
|
|
84
42
|
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
85
43
|
}
|
|
86
44
|
})
|
|
87
45
|
|
|
88
46
|
element.querySelector('[data-action="minus"]').addEventListener('click', () => {
|
|
89
47
|
const input = this.element.querySelector('input')
|
|
90
|
-
const num = parseInt(input.value) - parseInt(input.step)
|
|
48
|
+
const num = parseInt(input.value) - parseInt(input.step === '' ? 1 : input.step)
|
|
91
49
|
|
|
92
|
-
if (num >= input.min) {
|
|
93
|
-
input.value = num
|
|
50
|
+
if (num >= input.min || input.min === '') {
|
|
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(`/* @vite-ignore */https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.2.0/js/i18n/locales/${document.documentElement.lang === 'en' ? 'cs' : document.documentElement.lang}.min.js`)
|
|
62
|
+
const lang = await import(`/* @vite-ignore */ https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.2.0/js/i18n/locales/${document.documentElement.lang === 'en' ? 'cs' : document.documentElement.lang}.min.js`)
|
|
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,7 @@
|
|
|
1
|
+
export { default as checkValidity } from './checkValidity.js'
|
|
1
2
|
import './dataValue.js'
|
|
2
|
-
export { default as fetchHandler } from './fetchHandler.js'
|
|
3
3
|
export { default as importScript } from './importScript.js'
|
|
4
4
|
export { default as importStyle } from './importStyle.js'
|
|
5
5
|
export { default as inView } from './inView.js'
|
|
6
6
|
export { default as loadStimulus } from './loadStimulus.js'
|
|
7
|
+
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,4 +1,4 @@
|
|
|
1
|
-
export default function inView(element, options) {
|
|
1
|
+
export default function inView(element, options = {}) {
|
|
2
2
|
let inView = false
|
|
3
3
|
|
|
4
4
|
return new Promise((resolve) => {
|
|
@@ -7,19 +7,18 @@ export default function inView(element, options) {
|
|
|
7
7
|
return false
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
if (
|
|
11
|
-
options = {}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (typeof options.rootMargin === 'undefined') {
|
|
10
|
+
if (!options.rootMargin) {
|
|
15
11
|
options.rootMargin = '100px'
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
new IntersectionObserver(entries => {
|
|
14
|
+
const observer = new IntersectionObserver(entries => {
|
|
19
15
|
if (entries[0].isIntersecting && inView === false) {
|
|
20
16
|
inView = entries[0].isIntersecting
|
|
17
|
+
observer.disconnect()
|
|
21
18
|
resolve()
|
|
22
19
|
}
|
|
23
|
-
}, options)
|
|
20
|
+
}, options || {})
|
|
21
|
+
|
|
22
|
+
observer.observe(element)
|
|
24
23
|
})
|
|
25
24
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function replaceTag(documentElement) {
|
|
2
|
+
documentElement.querySelectorAll('[data-lib-replace-tag]').forEach(element => {
|
|
3
|
+
const replaceTag = document.querySelector(`[data-lib-replace-tag=${element.dataset.libReplaceTag}]`)
|
|
4
|
+
const placement = element.closest('head') ? document.head : replaceTag.parentElement
|
|
5
|
+
|
|
6
|
+
replaceTag ? (replaceTag.outerHTML = element.outerHTML) : placement.insertAdjacentHTML('beforeend', element.outerHTML)
|
|
7
|
+
|
|
8
|
+
if (element.tagName === 'SCRIPT') {
|
|
9
|
+
document.querySelector(`[data-lib-replace-tag=${element.dataset.libReplaceTag}]`)._addDataValue('controller', 'lib-script')
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
}
|
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
3
|
seamless: 'https://cdn.jsdelivr.net/npm/seamless-scroll-polyfill@2.1.6/lib/bundle.min.js',
|
|
4
|
-
|
|
4
|
+
pickrCss: 'https://cdn.jsdelivr.net/npm/@simonwep/pickr@1.8.0/dist/themes/nano.min.css',
|
|
5
5
|
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
6
|
datepicker: 'https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.2.0/dist/css/datepicker.min.css'
|
|
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
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "Default.css";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--l-header-height: 4rem;
|
|
3
|
+
--l-scroll-padding-top: calc(var(--l-header-height) + 1rem);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
#l-header {
|
|
7
|
+
z-index: var(--z-20);
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
right: 0;
|
|
12
|
+
padding: 0 2rem;
|
|
13
|
+
background-color: rgb(var(--color-dark));
|
|
14
|
+
color: rgb(var(--color-light));
|
|
15
|
+
|
|
16
|
+
@nest .dark & {
|
|
17
|
+
background-color: rgb(var(--color-background-100));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.is-l-header-normal {
|
|
21
|
+
& ~ #l-main {
|
|
22
|
+
padding-top: var(--l-header-height);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
& .wrp_header_body {
|
|
27
|
+
align-items: center;
|
|
28
|
+
height: var(--l-header-height);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
& .elm_header_logo {
|
|
32
|
+
font-size: 1.5rem;
|
|
33
|
+
margin-right: 3rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
& .elm_header_menu {
|
|
37
|
+
position: relative;
|
|
38
|
+
font-size: 1.75rem;
|
|
39
|
+
|
|
40
|
+
&::after {
|
|
41
|
+
position: absolute;
|
|
42
|
+
inset: -0.5rem;
|
|
43
|
+
content: "";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
& .elm_header_nav {
|
|
48
|
+
--gx: 2rem;
|
|
49
|
+
|
|
50
|
+
& .ui-link {
|
|
51
|
+
padding: 1.25rem 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|