@castlabs/ui 7.24.2 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/castlabs-ui-editor.common.js +17 -17
- package/dist/castlabs-ui-editor.common.js.map +1 -1
- package/dist/castlabs-ui-editor.umd.js +17 -17
- package/dist/castlabs-ui-editor.umd.js.map +1 -1
- package/dist/castlabs-ui.common.js +3 -3
- package/dist/castlabs-ui.common.js.map +1 -1
- package/dist/castlabs-ui.core.js +26 -113
- package/dist/castlabs-ui.css +1 -1
- package/dist/castlabs-ui.module.d.ts +1 -0
- package/dist/castlabs-ui.module.js +26 -113
- package/dist/castlabs-ui.umd.js +4 -4
- package/dist/castlabs-ui.umd.js.map +1 -1
- package/package.json +25 -24
- package/src/components/ClPagination/style.scss +1 -1
- package/src/components/ClToggle/style.scss +1 -1
- package/src/components/form/ClFieldCheck/style.scss +9 -0
- package/src/components/navigation/ClNavSide/style.scss +17 -0
- package/src/styles/abstracts/color.scss +2 -14
- package/src/styles/layout/color.scss +21 -29
- package/src/styles/layout/meta.scss +1 -1
- package/src/styles/ui.scss +0 -1
- package/types/castlabs-ui.module.d.ts +1 -0
- package/types/index.d.ts +1 -2
- package/plugins/matomo/README.md +0 -5
- package/plugins/matomo/index.ts +0 -93
- package/plugins/matomo/vue-matomo.d.ts +0 -1
- package/src/components/widget/ClCookieBanner/style.scss +0 -48
|
@@ -9,6 +9,7 @@ declare module '@castlabs/ui/dist/castlabs-ui.module.js' {
|
|
|
9
9
|
export function clModalShow (id: string, value?: any): void
|
|
10
10
|
export function clModalValue (id: string): any
|
|
11
11
|
export function clModalIsShown (id?: string): boolean
|
|
12
|
+
export function clModalWasShown (): boolean
|
|
12
13
|
export function clModalBack (to: any): boolean
|
|
13
14
|
|
|
14
15
|
export function clPaginate (array: any[], pageNo?: number, pageSize?: number): any[]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @castlabs/ui
|
|
1
|
+
/* @castlabs/ui v8.1.0 */
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* Bootstrap v5.3.8 (https://getbootstrap.com/)
|
|
@@ -112,110 +112,6 @@ function clSidenavInitiallyOpen () {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
const cookieName = 'cl_banner_nok'
|
|
116
|
-
|
|
117
|
-
export function clCookieBannerSetup (siteId = 1, forced = false) {
|
|
118
|
-
if (
|
|
119
|
-
!window.location.hostname.match(/castlabs.com$/) &&
|
|
120
|
-
!window.location.search.match('mtm=DEBUG') &&
|
|
121
|
-
!forced
|
|
122
|
-
) {
|
|
123
|
-
console.info(`skipping cookie banner on ${window.location.hostname ?? 'unknown domain'}`)
|
|
124
|
-
return
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
clMatomoSetup(siteId)
|
|
128
|
-
let show = true
|
|
129
|
-
for (const cookie of document?.cookie?.split(/; */) ?? []) {
|
|
130
|
-
const [name, value] = cookie.split('=')
|
|
131
|
-
if (name === cookieName && ['-mtm', '+mtm'].includes(value)) {
|
|
132
|
-
show = false
|
|
133
|
-
break // for
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (show) clCookieBannerShow()
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function clCookieBannerHide () {
|
|
140
|
-
const banner = document.querySelector('div.cl-cookie-banner')
|
|
141
|
-
banner.classList.add('cl-fade-away')
|
|
142
|
-
setTimeout(() => {
|
|
143
|
-
banner.parentNode.removeChild(banner)
|
|
144
|
-
}, 500)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function clCookieBannerAccept () {
|
|
148
|
-
document.cookie = `cl_banner_nok=+mtm; max-age=${60 * 60 * 24 * 395}; domain=.castlabs.com; path=/; SameSite=Lax;`
|
|
149
|
-
clCookieBannerHide()
|
|
150
|
-
|
|
151
|
-
const _paq = (window._paq = window._paq || [])
|
|
152
|
-
_paq.push(['rememberCookieConsentGiven', 9480])
|
|
153
|
-
_paq.push(['trackPageView'])
|
|
154
|
-
_paq.push(['enableLinkTracking'])
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function clCookieBannerDecline () {
|
|
158
|
-
document.cookie = `cl_banner_nok=-mtm; max-age=${60 * 60 * 24 * 395}; domain=.castlabs.com; path=/; SameSite=Lax;`
|
|
159
|
-
clCookieBannerHide()
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function clCookieBannerShow (accept = clCookieBannerAccept, decline = clCookieBannerDecline) {
|
|
163
|
-
const banner = document.createElement('div')
|
|
164
|
-
banner.classList.add('card', 'cl-card', 'cl-cookie-banner')
|
|
165
|
-
banner.innerHTML = `
|
|
166
|
-
<div class="card-body">
|
|
167
|
-
<p class="cl-p-small">
|
|
168
|
-
For our services to work, we use essential cookies which we control.
|
|
169
|
-
We'd also like to include others to analyze how our site is used to help
|
|
170
|
-
improve it - but only if you accept. Learn more in our
|
|
171
|
-
<a
|
|
172
|
-
class="cl-a-text"
|
|
173
|
-
href="https://castlabs.com/privacy-cookie-policy/"
|
|
174
|
-
>privacy policy</a>.
|
|
175
|
-
</p>
|
|
176
|
-
|
|
177
|
-
<div class="cl-spacing-box cl-spread">
|
|
178
|
-
<button
|
|
179
|
-
id="cl-button-cookie-decline"
|
|
180
|
-
type="button"
|
|
181
|
-
class="btn btn-sm cl-color-night it-cancel"
|
|
182
|
-
>
|
|
183
|
-
Decline
|
|
184
|
-
</button>
|
|
185
|
-
<button
|
|
186
|
-
id="cl-button-cookie-accept"
|
|
187
|
-
type="button"
|
|
188
|
-
class="btn btn-sm cl-color-red it-ok"
|
|
189
|
-
>
|
|
190
|
-
Accept
|
|
191
|
-
</button>
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
`
|
|
195
|
-
document.body.appendChild(banner)
|
|
196
|
-
document.getElementById('cl-button-cookie-accept').addEventListener('click', accept)
|
|
197
|
-
document.getElementById('cl-button-cookie-decline').addEventListener('click', decline)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function clMatomoSetup (siteId = 1, domain = 'castlabs.com') {
|
|
201
|
-
const _paq = (window._paq = window._paq || [])
|
|
202
|
-
_paq.push(['requireCookieConsent'])
|
|
203
|
-
_paq.push(['setDocumentTitle', document.domain + '/' + document.title])
|
|
204
|
-
_paq.push(['setCookieDomain', `*.${domain}`])
|
|
205
|
-
_paq.push(['setDomains', [`*.${domain}`]])
|
|
206
|
-
_paq.push(['trackPageView'])
|
|
207
|
-
_paq.push(['enableLinkTracking'])
|
|
208
|
-
;(function () {
|
|
209
|
-
_paq.push(['setTrackerUrl', 'https://castlabs.matomo.cloud/matomo.php'])
|
|
210
|
-
_paq.push(['setSiteId', `${siteId}`])
|
|
211
|
-
const g = document.createElement('script')
|
|
212
|
-
const s = document.getElementsByTagName('script')[0]
|
|
213
|
-
g.async = true
|
|
214
|
-
g.src = '//cdn.matomo.cloud/castlabs.matomo.cloud/matomo.js'
|
|
215
|
-
s.parentNode.insertBefore(g, s)
|
|
216
|
-
})()
|
|
217
|
-
}
|
|
218
|
-
|
|
219
115
|
export function clTableSetupResize (id, auto = false) {
|
|
220
116
|
document.querySelectorAll(`#${id} .cl-resizer`).forEach(resizer => {
|
|
221
117
|
clTableSetResizeListeners(resizer, auto)
|
|
@@ -1022,6 +918,14 @@ function getDomain () {
|
|
|
1022
918
|
// -----------------------------------------------------------------------------
|
|
1023
919
|
|
|
1024
920
|
let modal = null // the open modal (if any)
|
|
921
|
+
let modalDelay = null // a just-closed modal to circumvent unlucky event order
|
|
922
|
+
|
|
923
|
+
function setModalDelay (newModal) {
|
|
924
|
+
modal = newModal
|
|
925
|
+
setTimeout(function () {
|
|
926
|
+
modalDelay = newModal
|
|
927
|
+
}, 10)
|
|
928
|
+
}
|
|
1025
929
|
|
|
1026
930
|
/**
|
|
1027
931
|
* Hide a bootstrap modal via it's ID.
|
|
@@ -1032,7 +936,7 @@ let modal = null // the open modal (if any)
|
|
|
1032
936
|
*/
|
|
1033
937
|
export function clModalHide () {
|
|
1034
938
|
modal?.hide()
|
|
1035
|
-
|
|
939
|
+
setModalDelay(null)
|
|
1036
940
|
}
|
|
1037
941
|
|
|
1038
942
|
/**
|
|
@@ -1049,10 +953,11 @@ export function clModalShow (id, value) {
|
|
|
1049
953
|
// find & show the modal
|
|
1050
954
|
const element = document.getElementById(id)
|
|
1051
955
|
if (element) {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
956
|
+
const newModal = new bootstrap.Modal(element, { backdrop: 'static' })
|
|
957
|
+
newModal.value = value
|
|
958
|
+
newModal.id = id
|
|
959
|
+
newModal.show()
|
|
960
|
+
setModalDelay(newModal)
|
|
1056
961
|
|
|
1057
962
|
// focus the first auto-focus field in the Modal
|
|
1058
963
|
const autofocus = document.querySelector(`#${id} [autofocus]`)
|
|
@@ -1077,8 +982,16 @@ export function clModalValue (id) {
|
|
|
1077
982
|
*/
|
|
1078
983
|
export function clModalIsShown (modalId) {
|
|
1079
984
|
if (!modal) return false
|
|
1080
|
-
if (
|
|
1081
|
-
return modal.id === modalId
|
|
985
|
+
if (modal._isShown) return true
|
|
986
|
+
return modal.id === modalId
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Determine if a modal is/was open. It considers modal a few more ms as open, as
|
|
991
|
+
* sometimes browser/bootstrap events might fire in unlucky orders.
|
|
992
|
+
*/
|
|
993
|
+
export function clModalWasShown () {
|
|
994
|
+
return !!modalDelay
|
|
1082
995
|
}
|
|
1083
996
|
|
|
1084
997
|
/**
|
|
@@ -1269,7 +1182,7 @@ export function clFormFieldFocusFirstInvalid (formId, moreSelectors = []) {
|
|
|
1269
1182
|
const invalid = document.querySelector(
|
|
1270
1183
|
clSubselectorQuery(`#${formId}`, [':invalid', '.invalid', ...moreSelectors])
|
|
1271
1184
|
)
|
|
1272
|
-
invalid?.focus()
|
|
1185
|
+
invalid?.focus({ focusVisible: true })
|
|
1273
1186
|
}
|
|
1274
1187
|
|
|
1275
1188
|
export function clSubselectorQuery (main, subselectors) {
|