@castlabs/ui 7.23.0 → 7.23.1
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.common.js +2 -2
- package/dist/castlabs-ui.common.js.map +1 -1
- package/dist/castlabs-ui.core.js +41 -19
- package/dist/castlabs-ui.css +1 -1
- package/dist/castlabs-ui.module.d.ts +3 -3
- package/dist/castlabs-ui.module.js +41 -19
- package/dist/castlabs-ui.umd.js +3 -3
- package/dist/castlabs-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/text/ClCopy/style.scss +1 -3
- package/src/styles/layout/helper.scss +4 -3
- package/src/styles/layout/meta.scss +1 -1
- package/types/castlabs-ui.module.d.ts +3 -3
- package/types/index.d.ts +3 -3
package/dist/castlabs-ui.core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @castlabs/ui v7.23.
|
|
1
|
+
/* @castlabs/ui v7.23.1 */
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* Bootstrap v5.3.8 (https://getbootstrap.com/)
|
|
@@ -256,7 +256,7 @@ function clTableSetResizeListeners (resizer, auto = false) {
|
|
|
256
256
|
document.addEventListener('mousemove', mousemove)
|
|
257
257
|
document.addEventListener('mouseup', mouseup)
|
|
258
258
|
if (auto) {
|
|
259
|
-
|
|
259
|
+
resizer.addEventListener('click', mouseclick)
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
|
|
@@ -308,9 +308,10 @@ const mouseup = mouseup => {
|
|
|
308
308
|
|
|
309
309
|
const mouseclick = click => {
|
|
310
310
|
if (click.detail === 2) {
|
|
311
|
+
const table = click.target?.closest('table')
|
|
312
|
+
if (!table) return
|
|
311
313
|
click.preventDefault()
|
|
312
314
|
|
|
313
|
-
const table = click.target?.closest('table')
|
|
314
315
|
const id = table?.id ?? 'unknown'
|
|
315
316
|
const th = click.target?.closest('th')
|
|
316
317
|
const colIndex = Array.from(th.parentElement.children).indexOf(th)
|
|
@@ -1164,9 +1165,11 @@ function clFormFieldReset (ref, oldValue) {
|
|
|
1164
1165
|
* Will autofocus the first wrong input (if any).
|
|
1165
1166
|
*
|
|
1166
1167
|
* @param {string} id ID of form.
|
|
1168
|
+
* @param {string[]} moreSelectors Optional additional classes that mark invalid fields.
|
|
1169
|
+
* @param {string[]} moreTriggers Optional additional classes mark elements that should be focused & blurred to trigger validation.
|
|
1167
1170
|
* @return {boolean} True if form is OK.
|
|
1168
1171
|
*/
|
|
1169
|
-
function clFormIsValid (id) {
|
|
1172
|
+
function clFormIsValid (id, moreSelectors = [], moreTriggers = []) {
|
|
1170
1173
|
const form = document.querySelector(`#${id}`)
|
|
1171
1174
|
if (!form) {
|
|
1172
1175
|
// not a form at all
|
|
@@ -1177,16 +1180,18 @@ function clFormIsValid (id) {
|
|
|
1177
1180
|
// force trigger validation
|
|
1178
1181
|
// as some inputs like the ace editor do custom validation based on events,
|
|
1179
1182
|
// we fire various event/element/class combinations to make sure custom handlers run.
|
|
1180
|
-
document
|
|
1181
|
-
input.
|
|
1182
|
-
|
|
1183
|
-
|
|
1183
|
+
document
|
|
1184
|
+
.querySelectorAll(clSubselectorQuery(`#${id}`, ['input', '.form-control', ...moreTriggers]))
|
|
1185
|
+
.forEach(input => {
|
|
1186
|
+
input.focus()
|
|
1187
|
+
input.blur()
|
|
1188
|
+
})
|
|
1184
1189
|
|
|
1185
1190
|
if (
|
|
1186
1191
|
form.checkValidity() === false ||
|
|
1187
|
-
document.querySelector(`#${id} :invalid,
|
|
1192
|
+
document.querySelector(clSubselectorQuery(`#${id}`, [':invalid', '.invalid', ...moreSelectors]))
|
|
1188
1193
|
) {
|
|
1189
|
-
clFormFieldFocusFirstInvalid(id)
|
|
1194
|
+
clFormFieldFocusFirstInvalid(id, moreSelectors)
|
|
1190
1195
|
return false
|
|
1191
1196
|
}
|
|
1192
1197
|
|
|
@@ -1199,9 +1204,11 @@ function clFormIsValid (id) {
|
|
|
1199
1204
|
* Useful for complicated inputs like ACE editor.
|
|
1200
1205
|
*
|
|
1201
1206
|
* @param {string} id ID of form.
|
|
1207
|
+
* @param {string[]} moreSelectors Optional additional classes that mark invalid fields.
|
|
1208
|
+
* @param {string[]} moreTriggers Optional additional classes mark elements that should be focused & blurred to trigger validation.
|
|
1202
1209
|
* @return {boolean} Promise of true if form is OK.
|
|
1203
1210
|
*/
|
|
1204
|
-
async function clFormIsValidAsync (id) {
|
|
1211
|
+
async function clFormIsValidAsync (id, moreSelectors = [], moreTriggers = []) {
|
|
1205
1212
|
const form = document.getElementById(id)
|
|
1206
1213
|
if (!form) {
|
|
1207
1214
|
// not a form at all
|
|
@@ -1212,10 +1219,12 @@ async function clFormIsValidAsync (id) {
|
|
|
1212
1219
|
// force trigger validation
|
|
1213
1220
|
// as some inputs like the ace editor do custom validation based on events,
|
|
1214
1221
|
// we fire various event/element/class combinations to make sure custom handlers run.
|
|
1215
|
-
document
|
|
1216
|
-
input.
|
|
1217
|
-
|
|
1218
|
-
|
|
1222
|
+
document
|
|
1223
|
+
.querySelectorAll(clSubselectorQuery(`#${id}`, ['input', '.form-control', ...moreTriggers]))
|
|
1224
|
+
.forEach(input => {
|
|
1225
|
+
input.focus()
|
|
1226
|
+
input.blur()
|
|
1227
|
+
})
|
|
1219
1228
|
document.querySelectorAll(`#${id} .ace_editor`).forEach(input => {
|
|
1220
1229
|
input.click()
|
|
1221
1230
|
})
|
|
@@ -1225,9 +1234,11 @@ async function clFormIsValidAsync (id) {
|
|
|
1225
1234
|
setTimeout(() => {
|
|
1226
1235
|
if (
|
|
1227
1236
|
form.checkValidity() === false ||
|
|
1228
|
-
document.querySelector(
|
|
1237
|
+
document.querySelector(
|
|
1238
|
+
clSubselectorQuery(`#${id}`, [':invalid', '.invalid', ...moreSelectors])
|
|
1239
|
+
)
|
|
1229
1240
|
) {
|
|
1230
|
-
clFormFieldFocusFirstInvalid(id)
|
|
1241
|
+
clFormFieldFocusFirstInvalid(id, moreSelectors)
|
|
1231
1242
|
resolve(false)
|
|
1232
1243
|
return
|
|
1233
1244
|
}
|
|
@@ -1252,12 +1263,23 @@ function clFormAutofocus (formId) {
|
|
|
1252
1263
|
* Set the focus in the first invalid field of the given form (if any).
|
|
1253
1264
|
*
|
|
1254
1265
|
* @param {string} formId HTML ID of form.
|
|
1266
|
+
* @param {string[]} moreSelectors Optional additional classes that mark invalid fields.
|
|
1255
1267
|
*/
|
|
1256
|
-
function clFormFieldFocusFirstInvalid (formId) {
|
|
1257
|
-
const invalid = document.querySelector(
|
|
1268
|
+
function clFormFieldFocusFirstInvalid (formId, moreSelectors = []) {
|
|
1269
|
+
const invalid = document.querySelector(
|
|
1270
|
+
clSubselectorQuery(`#${formId}`, [':invalid', '.invalid', ...moreSelectors])
|
|
1271
|
+
)
|
|
1258
1272
|
invalid?.focus()
|
|
1259
1273
|
}
|
|
1260
1274
|
|
|
1275
|
+
function clSubselectorQuery (main, subselectors) {
|
|
1276
|
+
const selectors = []
|
|
1277
|
+
for (const subselector of subselectors) {
|
|
1278
|
+
selectors.push(`${main} ${subselector}`)
|
|
1279
|
+
}
|
|
1280
|
+
return selectors.join(', ')
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1261
1283
|
// -----------------------------------------------------------------------------
|
|
1262
1284
|
// --- formatters --------------------------------------------------------------
|
|
1263
1285
|
// -----------------------------------------------------------------------------
|