@newlogic-digital/ui 3.5.0 → 3.7.5
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 +11 -1
- package/package.json +29 -22
- package/src/data/main.json +23 -8
- package/src/emails/styles/main/+.css +3 -0
- package/src/emails/styles/main/Base/+.css +2 -0
- package/src/emails/styles/main/Base/config.css +22 -0
- package/src/emails/styles/main/Components/+.css +1 -0
- package/src/emails/styles/main/Components/Card.css +12 -0
- package/src/emails/styles/main/Ui/+.css +3 -0
- package/src/emails/styles/main/Ui/Btn.css +78 -0
- package/src/emails/styles/main/Ui/Heading.css +8 -0
- package/src/emails/styles/main/Ui/Text.css +12 -0
- package/src/emails/styles/main.css +92 -0
- package/src/emails/templates.test/Layout.latte +16 -4
- package/src/emails/templates.test/Sections/Footer.latte +22 -0
- package/src/emails/templates.test/Sections/Header.latte +37 -0
- package/src/emails/templates.test/Sections/Text.latte +24 -0
- package/src/icons.svg +28 -28
- package/src/scripts/Components/+.js +2 -1
- package/src/scripts/Components/Drawer.js +60 -0
- package/src/scripts/Components/Popover.js +65 -0
- package/src/scripts/Layout/+.js +0 -1
- package/src/scripts/Layout/Header.js +14 -26
- package/src/scripts/Libraries/+.js +3 -5
- package/src/scripts/Libraries/CookieConsent.js +65 -52
- package/src/scripts/Libraries/Dialog.js +19 -38
- package/src/scripts/Libraries/Form.js +6 -19
- package/src/scripts/Libraries/Naja.js +22 -18
- package/src/scripts/Libraries/ReCaptcha.js +9 -26
- package/src/scripts/Libraries/Reveal.js +32 -0
- package/src/scripts/Libraries/Ripple.js +3 -3
- package/src/scripts/Libraries/Stimulus.js +50 -5
- package/src/scripts/Libraries/Swup.js +44 -59
- package/src/scripts/Libraries/Toaster.js +55 -0
- package/src/scripts/Ui/Check.js +3 -3
- package/src/scripts/Ui/Control.js +42 -34
- package/src/scripts/Ui/ControlSelect.js +6 -5
- package/src/scripts/Ui/Text.js +6 -6
- package/src/scripts/Utils/+.js +3 -3
- package/src/scripts/Utils/cdn.js +0 -1
- package/src/scripts/Utils/initAfter.js +11 -0
- package/src/scripts/Utils/naja.js +41 -0
- package/src/scripts/Utils/utilities.js +8 -0
- package/src/scripts/main.js +2 -1
- package/src/styles/Components/+.css +3 -2
- package/src/styles/Components/Dialog/+.css +2 -0
- package/src/styles/Components/Dialog/Content.css +2 -0
- package/src/styles/Components/Dialog/CookieConsent.css +17 -0
- package/src/styles/Components/Dialog/Default.css +2 -26
- package/src/styles/Components/Drawer.css +18 -0
- package/src/styles/Components/Field.css +1 -1
- package/src/styles/Components/Popover.css +1 -0
- package/src/styles/Components/Toaster.css +2 -0
- package/src/styles/Layout/Header.css +7 -39
- package/src/styles/Layout/Main.css +9 -6
- package/src/styles/Layout/Nav.css +6 -30
- package/src/styles/Libraries/+.css +0 -5
- package/src/styles/Ui/+.css +0 -1
- package/src/styles/Ui/Badge.css +1 -0
- package/src/styles/Ui/Btn.css +6 -5
- package/src/styles/Ui/Check.css +1 -1
- package/src/styles/Ui/Control.css +14 -4
- package/src/styles/Ui/ControlSelect.css +10 -19
- package/src/styles/Ui/Group.css +1 -1
- package/src/styles/Ui/Heading.css +1 -0
- package/src/styles/Ui/Image.css +1 -1
- package/src/styles/Ui/Info.css +1 -1
- package/src/styles/Ui/Label.css +1 -1
- package/src/styles/Ui/Link.css +7 -1
- package/src/styles/Ui/Notice.css +9 -1
- package/src/styles/Ui/Progress.css +1 -1
- package/src/styles/Ui/Switch.css +1 -1
- package/src/styles/Ui/Text.css +1 -8
- package/src/styles/Ui/Title.css +1 -4
- package/src/styles/Utils/+.css +1 -3
- package/src/styles/Utils/config.css +14 -3
- package/src/styles/Utils/default.css +11 -4
- package/src/styles/Utils/theme/+.css +1 -1
- package/src/styles/Utils/theme/main.css +27 -13
- package/src/styles/Utils/utilities.css +42 -0
- package/src/styles/main.css +1 -4
- package/src/templates/Components/Dialog/Basic.latte +24 -0
- package/src/templates/Components/Dialog/CookieConsent.latte +27 -0
- package/src/templates/Components/Form/CookieConsent.latte +47 -0
- package/src/templates/Layout/Header.latte +31 -33
- package/src/templates/Layout/Main.latte +39 -28
- package/src/templates/Sections/CookieConsent.latte +69 -0
- package/src/templates/Sections/Site.latte +80 -8
- package/src/templates/Sections/Text.latte +64 -0
- package/src/templates/Sections/Ui/Docs/@intro.html +5 -5
- package/src/templates/Sections/Ui/Docs/@nav.html +50 -60
- package/src/templates/Sections/Ui/Docs/@styles.html +1 -1
- package/src/templates/Sections/Ui/Docs/Default.latte +86 -166
- package/src/templates/Sections/Ui/Icons.html +1 -1
- package/src/templates/Sections/Ui/Intro.html +33 -79
- package/src/templates/Ui/ControlDate.latte +1 -1
- package/src/templates/Ui/ControlTime.latte +1 -1
- package/src/views/dialog/basic.json.latte +1 -1
- package/src/views/email/email.latte +2 -2
- package/src/views/email/email.test.latte +2 -2
- package/src/views/gdpr.json +6 -4
- package/src/views/popover/info.json.latte +15 -0
- package/vite.config.js +17 -10
- package/src/emails/styles/email.css +0 -77
- package/src/emails/templates.test/Content.latte +0 -24
- package/src/emails/templates.test/Header.latte +0 -14
- package/src/scripts/Components/CookieConsent.js +0 -78
- package/src/scripts/Layout/Main.js +0 -50
- package/src/scripts/Libraries/Drawer.js +0 -42
- package/src/scripts/Libraries/Script.js +0 -18
- package/src/scripts/Libraries/Slider.js +0 -160
- package/src/scripts/Libraries/Tippy.js +0 -117
- package/src/scripts/Utils/Functions/+.js +0 -7
- package/src/scripts/Utils/Functions/importScript.js +0 -17
- package/src/scripts/Utils/Functions/importStyle.js +0 -18
- package/src/scripts/Utils/Functions/inputStep.js +0 -9
- package/src/scripts/Utils/Functions/inputValidity.js +0 -57
- package/src/scripts/Utils/Functions/loadStimulus.js +0 -42
- package/src/scripts/Utils/Functions/replaceScript.js +0 -4
- package/src/scripts/Utils/Functions/replaceTag.js +0 -8
- package/src/scripts/Utils/global.js +0 -15
- package/src/styles/Components/CookieConsent.css +0 -68
- package/src/styles/Components/Dropdown/+.css +0 -1
- package/src/styles/Components/Dropdown/Default.css +0 -8
- package/src/styles/Libraries/Dialog.css +0 -1
- package/src/styles/Libraries/Drawer.css +0 -64
- package/src/styles/Libraries/Hint.css +0 -186
- package/src/styles/Libraries/Ripple.css +0 -1
- package/src/styles/Libraries/Tippy.css +0 -73
- package/src/styles/Ui/Dot.css +0 -22
- package/src/styles/Utils/icons.css +0 -5
- package/src/styles/Utils/tailwind.css +0 -50
- package/src/templates/Components/CookieConsent.latte +0 -28
- package/src/templates/Components/Dialogs/Basic.latte +0 -22
- package/src/templates/Components/Items/.gitkeep +0 -0
- package/src/templates/Sections/Gdpr.latte +0 -127
- package/src/views/dropdown/tippy.json.latte +0 -19
- /package/src/{styles/Utils/print.css → emails/styles/main/Base/font.css} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
|
|
2
|
+
import { showDrawer, closeDrawer, scrollDrawer } from 'winduum/src/components/drawer/index.js'
|
|
3
|
+
|
|
4
|
+
LibStimulus.register('c-drawer', class extends Controller {
|
|
5
|
+
static values = {
|
|
6
|
+
inertMatch: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: ':where(.c-drawer, .l-header)'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
connect() {
|
|
13
|
+
this.scrollReset()
|
|
14
|
+
this.element.addEventListener('click', ({ target }) => {
|
|
15
|
+
if (target === this.element) this.close()
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
scrollReset() {
|
|
20
|
+
this.element.scroll({ left: this.element.scrollWidth, behavior: 'instant' })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
scroll({ target }) {
|
|
24
|
+
scrollDrawer(target)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
inert(inert) {
|
|
28
|
+
[...document.body.children].forEach((element) => {
|
|
29
|
+
if (!element.matches(this.inertMatchValue)) (element.inert = inert)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
show() {
|
|
34
|
+
this.scrollReset()
|
|
35
|
+
this.element.classList.add('active')
|
|
36
|
+
showDrawer(this.element)
|
|
37
|
+
this.inert(true)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
close() {
|
|
41
|
+
closeDrawer(this.element)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
toggle({ currentTarget }) {
|
|
45
|
+
this.activeButton = currentTarget
|
|
46
|
+
|
|
47
|
+
if (!currentTarget.classList.contains('active')) {
|
|
48
|
+
currentTarget.classList.add('active')
|
|
49
|
+
this.show()
|
|
50
|
+
} else {
|
|
51
|
+
this.close()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
dismiss() {
|
|
56
|
+
this.element.classList.remove('active')
|
|
57
|
+
this.activeButton?.classList?.remove('active')
|
|
58
|
+
this.inert(false)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Controller, LibStimulus } from '../Libraries/Stimulus.js'
|
|
2
|
+
import { dataset, fetchJson } from '@newlogic-digital/utils-js'
|
|
3
|
+
import initAfter from '../Utils/initAfter.js'
|
|
4
|
+
|
|
5
|
+
LibStimulus.register('c-popover', class extends Controller {
|
|
6
|
+
static values = {
|
|
7
|
+
url: String,
|
|
8
|
+
insertTo: String,
|
|
9
|
+
manual: Boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async toggle({ currentTarget, params }) {
|
|
13
|
+
const { togglePopover } = await import('winduum/src/components/popover/index.js')
|
|
14
|
+
const hasUrlValue = this.hasUrlValue && !this.popoverTarget
|
|
15
|
+
|
|
16
|
+
if (hasUrlValue) await this.fetch()
|
|
17
|
+
|
|
18
|
+
this.popoverTarget = document.getElementById(currentTarget.getAttribute('popovertarget'))
|
|
19
|
+
|
|
20
|
+
if (hasUrlValue) initAfter(this.popoverTarget)
|
|
21
|
+
|
|
22
|
+
await togglePopover(currentTarget, params)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async hide() {
|
|
26
|
+
if (this.popoverActionTarget.ariaExpanded !== 'true') return
|
|
27
|
+
|
|
28
|
+
const { hidePopover } = await import('winduum/src/components/popover/index.js')
|
|
29
|
+
|
|
30
|
+
await hidePopover(this.popoverActionTarget)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async dismiss({ target }) {
|
|
34
|
+
if (this.popoverActionTarget.ariaExpanded !== 'true') return
|
|
35
|
+
|
|
36
|
+
if (!this.popoverTarget.contains(target) && !this.popoverActionTarget.isEqualNode(target) && this.popoverActionTarget.ariaExpanded === 'true') {
|
|
37
|
+
await this.hide()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async fetch() {
|
|
42
|
+
this.popoverActionTarget.classList.add('loading', 'cursor-wait')
|
|
43
|
+
|
|
44
|
+
const { content } = await fetchJson(this.urlValue)
|
|
45
|
+
|
|
46
|
+
this.popoverActionTarget.classList.remove('loading', 'cursor-wait')
|
|
47
|
+
|
|
48
|
+
const insertElement = !this.hasInsertToValue ? this.popoverActionTarget : document.querySelector(this.insertToValue)
|
|
49
|
+
insertElement.insertAdjacentHTML(!this.hasInsertToValue ? 'afterend' : 'beforeend', content)
|
|
50
|
+
|
|
51
|
+
return content
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
connect() {
|
|
55
|
+
this.popoverActionTarget = this.element.querySelector('[popovertargetaction]')
|
|
56
|
+
|
|
57
|
+
if (!this.popoverActionTarget) return
|
|
58
|
+
|
|
59
|
+
;(!this.hasManualValue || !this.manualValue) && dataset(this.popoverActionTarget, 'action').add(
|
|
60
|
+
`click->c-popover#${this.popoverActionTarget.getAttribute('popovertargetaction')}:prevent`,
|
|
61
|
+
'keydown.esc@window->c-popover#hide',
|
|
62
|
+
'click@window->c-popover#dismiss'
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
})
|
package/src/scripts/Layout/+.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import { LibStimulus, Controller
|
|
1
|
+
import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
|
|
2
2
|
|
|
3
|
-
LibStimulus.register('l-header',
|
|
4
|
-
|
|
5
|
-
class extends Controller {
|
|
6
|
-
connect () {
|
|
7
|
-
if (document.querySelector('#l-nav') === null) {
|
|
8
|
-
this.element.insertAdjacentHTML('afterend', `
|
|
9
|
-
<div id="l-nav" class="lib-drawer" data-controller="lib-drawer" data-action="scroll->lib-drawer#scroll" inert>
|
|
10
|
-
<div class="l_nav">
|
|
11
|
-
<div class="l_nav_head"></div>
|
|
12
|
-
<div class="l_nav_body"></div>
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
`)
|
|
3
|
+
LibStimulus.register('l-header', class extends Controller {
|
|
4
|
+
static targets = ['logo', 'nav']
|
|
16
5
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
connect() {
|
|
7
|
+
if (!document.querySelector('.l-nav')) {
|
|
8
|
+
this.element.insertAdjacentHTML('afterend', `
|
|
9
|
+
<div class="l-nav c-drawer" data-controller="c-drawer" data-action="scroll->c-drawer#scroll c-drawer:close->c-drawer#dismiss" inert>
|
|
10
|
+
<div class="c-drawer-content"></div>
|
|
11
|
+
</div>
|
|
12
|
+
`)
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
layoutNav.querySelector('.l_nav_body').insertAdjacentHTML('beforeend', nav)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
14
|
+
const drawerContentElement = document.querySelector('.l-nav .c-drawer-content')
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const LibDrawer = getController(document.querySelector('[data-controller~="lib-drawer"]'), 'lib-drawer')
|
|
29
|
-
LibDrawer.show()
|
|
16
|
+
drawerContentElement.insertAdjacentHTML('beforeend', this.logoTarget.outerHTML)
|
|
17
|
+
drawerContentElement.insertAdjacentHTML('beforeend', this.navTarget.outerHTML)
|
|
30
18
|
}
|
|
31
19
|
}
|
|
32
|
-
)
|
|
20
|
+
})
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import './CookieConsent.js'
|
|
2
2
|
import './Dialog.js'
|
|
3
|
-
import './Drawer.js'
|
|
4
3
|
import './Form.js'
|
|
5
4
|
import './Naja.js'
|
|
6
5
|
import './ReCaptcha.js'
|
|
6
|
+
import './Reveal.js'
|
|
7
7
|
import './Ripple.js'
|
|
8
|
-
import './Script.js'
|
|
9
|
-
import './Slider.js'
|
|
10
8
|
import './Stimulus.js'
|
|
11
9
|
export { default as Swup } from './Swup.js'
|
|
12
|
-
|
|
10
|
+
import './Toaster.js'
|
|
@@ -1,67 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
},
|
|
5
|
-
getItem: (key) => {
|
|
6
|
-
return localStorage.getItem(key)
|
|
7
|
-
},
|
|
8
|
-
init: () => {
|
|
9
|
-
const type = LibCookieConsent.getItem('lib-cookieconsent')
|
|
1
|
+
import { LibStimulus, Controller } from './Stimulus.js'
|
|
2
|
+
import { appendCookieConsent, setCookieConsent } from '@newlogic-digital/cookieconsent-js'
|
|
3
|
+
import { showDialog, closeDialog } from 'winduum/src/components/dialog/index.js'
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
export const getCookieConsentItem = (key = 'cookieconsent-js') => localStorage.getItem(key)
|
|
6
|
+
|
|
7
|
+
export const initCookieConsent = (element = document, type = getCookieConsentItem() ?? []) => {
|
|
8
|
+
element.querySelectorAll('[data-lib-cookieconsent]').forEach((element) => {
|
|
9
|
+
if (type.includes(element.getAttribute('data-lib-cookieconsent'))) {
|
|
10
|
+
appendCookieConsent(element, {
|
|
11
|
+
ignoreAttributeName: /(type|data-lib-cookieconsent)/
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
LibStimulus.register('c-dialog-cookieconsent', class extends Controller {
|
|
18
|
+
async connect() {
|
|
19
|
+
initCookieConsent()
|
|
20
|
+
|
|
21
|
+
if (document.querySelector('.c-form-cookieconsent')) {
|
|
22
|
+
return
|
|
13
23
|
}
|
|
14
|
-
},
|
|
15
|
-
set: (type) => {
|
|
16
|
-
LibCookieConsent.setItem('lib-cookieconsent', JSON.stringify(type))
|
|
17
|
-
LibCookieConsent.setItem('lib-cookieconsent-expire', (Date.now() + 31556926 * 1000).toString())
|
|
18
24
|
|
|
19
|
-
if (
|
|
20
|
-
|
|
25
|
+
if (!getCookieConsentItem() || parseInt(getCookieConsentItem('cookieconsent-js-expire')) < Date.now()) {
|
|
26
|
+
setTimeout(async () => {
|
|
27
|
+
await showDialog(this.element, { closable: false })
|
|
28
|
+
}, 1500)
|
|
21
29
|
} else {
|
|
22
|
-
|
|
23
|
-
LibCookieConsent.remove()
|
|
30
|
+
this.element.remove()
|
|
24
31
|
}
|
|
25
|
-
}
|
|
26
|
-
remove: () => {
|
|
27
|
-
document.cookie.split(';').forEach(c => {
|
|
28
|
-
document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/')
|
|
29
|
-
})
|
|
30
|
-
},
|
|
31
|
-
append: (type) => {
|
|
32
|
-
document.querySelectorAll('[data-lib-cookieconsent]').forEach(elm => {
|
|
33
|
-
if (type === 'all' || elm.getAttribute('data-lib-cookieconsent') === type) {
|
|
34
|
-
const script = document.createElement('script')
|
|
35
|
-
let delay = 0
|
|
32
|
+
}
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
script.setAttribute(attribute.name, attribute.value)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
})
|
|
34
|
+
async approve() {
|
|
35
|
+
await this.hide(['performance', 'marketing'])
|
|
36
|
+
}
|
|
44
37
|
|
|
45
|
-
|
|
38
|
+
async decline() {
|
|
39
|
+
await this.hide([])
|
|
40
|
+
}
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
async hide(type) {
|
|
43
|
+
await setCookieConsent(type)
|
|
44
|
+
initCookieConsent(document, type)
|
|
45
|
+
await closeDialog(this.element, { remove: true })
|
|
46
|
+
}
|
|
47
|
+
})
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} else if (elm.closest('head') !== null) {
|
|
55
|
-
document.head.appendChild(script)
|
|
56
|
-
}
|
|
49
|
+
LibStimulus.register('c-form-cookieconsent', class extends Controller {
|
|
50
|
+
connect() {
|
|
51
|
+
document.querySelector('.c-dialog-cookieconsent')?.close()
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
this.element.querySelectorAll('input:not([disabled])').forEach((input) => {
|
|
54
|
+
input.checked = false
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
JSON.parse(getCookieConsentItem())?.forEach((type) => {
|
|
58
|
+
if (this.element.querySelector(`input[value="${type}"]`) !== null) {
|
|
59
|
+
this.element.querySelector(`input[value="${type}"]`).checked = true
|
|
60
60
|
}
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
|
-
}
|
|
64
63
|
|
|
65
|
-
|
|
64
|
+
async update() {
|
|
65
|
+
const type = []
|
|
66
|
+
|
|
67
|
+
this.element.querySelectorAll('input:not([disabled])').forEach((input) => {
|
|
68
|
+
input.checked && type.push(input.value)
|
|
69
|
+
})
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
await setCookieConsent(type)
|
|
72
|
+
location.reload()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
disconnect() {
|
|
76
|
+
if ((!getCookieConsentItem() || parseInt(getCookieConsentItem('cookieconsent-js-expire')) < Date.now())) {
|
|
77
|
+
document.querySelector('.c-dialog-cookieconsent')?.showModal()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
})
|
|
@@ -1,47 +1,28 @@
|
|
|
1
|
-
import { Controller, LibStimulus
|
|
2
|
-
import { insertDialog, closeDialog,
|
|
3
|
-
import
|
|
1
|
+
import { Controller, LibStimulus } from './../Libraries/Stimulus.js'
|
|
2
|
+
import { insertDialog, closeDialog, dialogSelector } from 'winduum/src/components/dialog/index.js'
|
|
3
|
+
import initAfter from '../Utils/initAfter.js'
|
|
4
|
+
import { fetchJson } from '@newlogic-digital/utils-js'
|
|
4
5
|
|
|
5
6
|
LibStimulus.register('lib-dialog', class extends Controller {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
async show({ currentTarget, params }) {
|
|
8
|
+
const loadingClasses = (params.loadingClass ?? 'loading cursor-wait').split(' ')
|
|
9
|
+
|
|
10
|
+
currentTarget.classList.add(...loadingClasses)
|
|
11
|
+
|
|
12
|
+
await this.fetch(params.url, params)
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
if (this.hasOpenValue) {
|
|
13
|
-
if (this.hasUrlValue) {
|
|
14
|
-
await fetchDialog({
|
|
15
|
-
url: this.urlValue, insertOptions: { remove: true }
|
|
16
|
-
})
|
|
17
|
-
} else {
|
|
18
|
-
await insertDialog(document.querySelector(this.openValue).innerHTML, {
|
|
19
|
-
remove: true
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
loadStimulus(dialogSelector('.lib-dialog'))
|
|
24
|
-
}
|
|
14
|
+
currentTarget.classList.remove(...loadingClasses)
|
|
25
15
|
}
|
|
26
16
|
|
|
27
|
-
async
|
|
28
|
-
currentTarget.
|
|
29
|
-
|
|
30
|
-
await fetchDialog({
|
|
31
|
-
url: params.url,
|
|
32
|
-
insertOptions: {
|
|
33
|
-
remove: params.remove ?? true,
|
|
34
|
-
append: params.append ?? false
|
|
35
|
-
}
|
|
36
|
-
}).then(() => {
|
|
37
|
-
loadStimulus(dialogSelector('.lib-dialog'))
|
|
38
|
-
replaceScript(dialogSelector('.lib-dialog'))
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
currentTarget.classList.remove('loading', 'cursor-wait')
|
|
17
|
+
async close({ currentTarget, params }) {
|
|
18
|
+
await closeDialog(currentTarget.closest('dialog'), { remove: params.remove ?? true })
|
|
42
19
|
}
|
|
43
20
|
|
|
44
|
-
async
|
|
45
|
-
|
|
21
|
+
async fetch(url, options) {
|
|
22
|
+
const { content } = await fetchJson(url)
|
|
23
|
+
|
|
24
|
+
await insertDialog(content, options)
|
|
25
|
+
|
|
26
|
+
initAfter(dialogSelector('.c-dialog'))
|
|
46
27
|
}
|
|
47
28
|
})
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import { LibStimulus, Controller } from './Stimulus.js'
|
|
2
|
-
import {
|
|
2
|
+
import { validateForm } from 'winduum/src/components/form/index.js'
|
|
3
3
|
|
|
4
4
|
LibStimulus.register('lib-form', class extends Controller {
|
|
5
|
-
connect
|
|
6
|
-
this.element.
|
|
7
|
-
this.element.addEventListener('submit',
|
|
5
|
+
connect() {
|
|
6
|
+
this.element.noValidate = true
|
|
7
|
+
this.element.addEventListener('submit', this.validate)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
e.preventDefault()
|
|
13
|
-
e.stopPropagation()
|
|
14
|
-
|
|
15
|
-
this.element.querySelector(':invalid').scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
16
|
-
this.element.querySelector(':invalid').focus()
|
|
17
|
-
} else {
|
|
18
|
-
this.element.querySelector('[type="submit"]').classList.add('loading')
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
this.element.querySelectorAll('.ui-control, .ui-check, .ui-switch').forEach(element => {
|
|
22
|
-
console.log(element)
|
|
23
|
-
inputValidity(element, { message: true })
|
|
24
|
-
})
|
|
10
|
+
async validate(event) {
|
|
11
|
+
validateForm(event)
|
|
25
12
|
}
|
|
26
13
|
})
|
|
@@ -1,33 +1,37 @@
|
|
|
1
|
+
import { Controller, LibStimulus, initStimulus } from './Stimulus.js'
|
|
2
|
+
import { initCookieConsent } from './CookieConsent.js'
|
|
3
|
+
import {
|
|
4
|
+
initNaja,
|
|
5
|
+
NajaRecaptchaExtension,
|
|
6
|
+
NajaFormValidityExtension
|
|
7
|
+
} from '../Utils/naja.js'
|
|
1
8
|
import naja from 'naja'
|
|
2
|
-
import
|
|
9
|
+
import LibSwup from './Swup.js'
|
|
3
10
|
|
|
4
11
|
LibStimulus.register('lib-naja', class extends Controller {
|
|
5
|
-
async
|
|
6
|
-
naja.uiHandler.
|
|
7
|
-
const element = detail.element
|
|
12
|
+
async initialize() {
|
|
13
|
+
naja.uiHandler.selector = '[data-naja]'
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
await initNaja(this.element, false)
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
if (naja.initialized) return
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
19
|
+
naja.uiHandler.addEventListener('interaction', ({ detail }) => {
|
|
20
|
+
detail.element.dispatchEvent(new CustomEvent('naja:interaction', { bubbles: true, cancelable: true }))
|
|
16
21
|
})
|
|
17
22
|
|
|
18
23
|
naja.snippetHandler.addEventListener('afterUpdate', ({ detail }) => {
|
|
19
|
-
detail
|
|
24
|
+
detail.snippet.dispatchEvent(new CustomEvent('naja:afterUpdate', { bubbles: true, cancelable: true }))
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
initStimulus(detail.snippet)
|
|
27
|
+
initNaja(detail.snippet)
|
|
28
|
+
initCookieConsent(detail.snippet)
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
naja.initialize({
|
|
26
|
-
history: false
|
|
30
|
+
LibSwup.cache.clear()
|
|
27
31
|
})
|
|
28
|
-
}
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
naja.registerExtension(NajaRecaptchaExtension)
|
|
34
|
+
naja.registerExtension(NajaFormValidityExtension)
|
|
35
|
+
naja.initialize()
|
|
32
36
|
}
|
|
33
37
|
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LibStimulus, Controller } from './Stimulus.js'
|
|
2
|
-
import
|
|
3
|
-
import importScript from '../Utils/Functions/importScript.js'
|
|
2
|
+
import { importScript } from '@newlogic-digital/utils-js'
|
|
4
3
|
import cdn from '../Utils/cdn.js'
|
|
5
4
|
|
|
6
5
|
LibStimulus.register('lib-recaptcha', class extends Controller {
|
|
@@ -9,34 +8,18 @@ LibStimulus.register('lib-recaptcha', class extends Controller {
|
|
|
9
8
|
action: String
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
connect
|
|
11
|
+
connect() {
|
|
13
12
|
importScript(cdn.recaptcha.replace('{apikey}', this.apiValue))
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
15
|
+
execute(event) {
|
|
16
|
+
if (event?.detail?.recaptchaExecuted) return
|
|
17
|
+
|
|
18
|
+
window.grecaptcha.enterprise.ready(() => {
|
|
19
|
+
window.grecaptcha.enterprise.execute(this.apiValue, { action: this.actionValue ?? 'form' }).then((token) => {
|
|
20
|
+
this.element.gtoken.value = token
|
|
21
|
+
this.element.dispatchEvent(new CustomEvent('submit', { cancelable: true, detail: { recaptchaExecuted: true } }))
|
|
23
22
|
})
|
|
24
23
|
})
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
async submit ({ params }) {
|
|
28
|
-
if (this.element.reportValidity() === false) {
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
arguments[0].preventDefault()
|
|
33
|
-
|
|
34
|
-
await this.execute()
|
|
35
|
-
|
|
36
|
-
if (!params.naja) {
|
|
37
|
-
this.element.submit()
|
|
38
|
-
} else {
|
|
39
|
-
await naja.makeRequest(this.element.method, this.element.action, new FormData(this.element), { history: 'replace' })
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
25
|
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Controller, LibStimulus } from './Stimulus.js'
|
|
2
|
+
import { dataset } from '@newlogic-digital/utils-js'
|
|
3
|
+
|
|
4
|
+
LibStimulus.register('lib-reveal', class extends Controller {
|
|
5
|
+
static targets = ['item']
|
|
6
|
+
|
|
7
|
+
intersectionObserver() {
|
|
8
|
+
this.observer = new IntersectionObserver((entries, observer) => {
|
|
9
|
+
entries.forEach((entry) => {
|
|
10
|
+
if (entry.intersectionRatio > 0.1 && !entry.target.classList.contains('in')) {
|
|
11
|
+
entry.target.classList.add('in')
|
|
12
|
+
|
|
13
|
+
if (entry.target.dataset.controllerNameParam) {
|
|
14
|
+
dataset(entry.target, 'controller').add(entry.target.dataset.controllerNameParam)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
}, {
|
|
19
|
+
threshold: 0.1
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
itemTargetConnected(element) {
|
|
24
|
+
if (!this.observer) this.intersectionObserver()
|
|
25
|
+
|
|
26
|
+
this.observer?.observe(element)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
itemTargetDisconnected(element) {
|
|
30
|
+
this.observer?.unobserve(element)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Controller, LibStimulus } from './Stimulus.js'
|
|
2
|
-
import { showRipple } from 'winduum/src/
|
|
2
|
+
import { showRipple } from 'winduum/src/utilities/ripple/index.js'
|
|
3
3
|
|
|
4
4
|
LibStimulus.register('lib-ripple', class extends Controller {
|
|
5
|
-
async show
|
|
6
|
-
showRipple(
|
|
5
|
+
async show(event) {
|
|
6
|
+
showRipple(event)
|
|
7
7
|
}
|
|
8
8
|
})
|
|
@@ -1,11 +1,56 @@
|
|
|
1
1
|
import { Application, Controller } from '@hotwired/stimulus'
|
|
2
|
-
import
|
|
2
|
+
import { dataset } from '@newlogic-digital/utils-js'
|
|
3
|
+
|
|
4
|
+
function initActions(parent, selectors) {
|
|
5
|
+
if (!parent) return
|
|
6
|
+
|
|
7
|
+
selectors.forEach(([selector, action]) => {
|
|
8
|
+
parent.querySelectorAll(selector).forEach((element) => {
|
|
9
|
+
dataset(element, 'action').add(action)
|
|
10
|
+
})
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function initControllers(parent, selectors) {
|
|
15
|
+
if (!parent) return
|
|
16
|
+
|
|
17
|
+
selectors.forEach((selector) => {
|
|
18
|
+
[...parent.getElementsByClassName(selector)].forEach((element) => {
|
|
19
|
+
dataset(element, 'controller').add(selector)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function initStimulus(element, { controllers, actions } = {
|
|
25
|
+
controllers: ['ui-control', 'ui-text', 'ui-check'],
|
|
26
|
+
actions: [['.ui-btn', 'click->lib-ripple#show'], ['.ui-check', 'change->ui-check#validate']]
|
|
27
|
+
}) {
|
|
28
|
+
initControllers(element, controllers)
|
|
29
|
+
initActions(element, actions)
|
|
30
|
+
}
|
|
3
31
|
|
|
4
32
|
const LibStimulus = new Application(document.documentElement)
|
|
5
|
-
const getController = (element, identifier) => LibStimulus.getControllerForElementAndIdentifier(element, identifier)
|
|
6
33
|
|
|
7
|
-
|
|
34
|
+
const getController = (...arg) => LibStimulus.getControllerForElementAndIdentifier(...arg)
|
|
35
|
+
|
|
36
|
+
const delegateController = (name, method, event = {}, selector) => {
|
|
37
|
+
const controller = getController(document.querySelector(selector || `.${name}`), name)
|
|
38
|
+
|
|
39
|
+
if (controller) return method ? controller[method](event) : controller
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
LibStimulus.start().then(() => initStimulus(document.body))
|
|
43
|
+
|
|
44
|
+
LibStimulus.register('controller', class extends Controller {
|
|
45
|
+
delegate(event) {
|
|
46
|
+
delegateController(event.params.name, event.params.method, event, event.params.selector)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
load({ currentTarget, params }) {
|
|
50
|
+
dataset(currentTarget, 'controller').add(params.name)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
8
53
|
|
|
9
|
-
window.LibStimulus = { default: LibStimulus, Controller,
|
|
54
|
+
window.LibStimulus = { default: LibStimulus, Controller, initStimulus, delegateController }
|
|
10
55
|
|
|
11
|
-
export { LibStimulus, Controller,
|
|
56
|
+
export { LibStimulus, Controller, initStimulus, getController, delegateController }
|