@castlabs/ui 7.22.0 → 7.23.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.common.js +3 -3
- package/dist/castlabs-ui.common.js.map +1 -1
- package/dist/castlabs-ui.core.js +63 -19
- package/dist/castlabs-ui.css +1 -1
- package/dist/castlabs-ui.module.d.ts +12 -11
- package/dist/castlabs-ui.module.js +63 -19
- package/dist/castlabs-ui.umd.js +4 -4
- package/dist/castlabs-ui.umd.js.map +1 -1
- package/package.json +13 -13
- package/src/components/form/ClFieldGroup/style.scss +15 -2
- package/src/components/form/ClFieldInput/style.scss +13 -0
- package/src/components/table/ClTable/style.scss +6 -2
- package/src/components/table/ClTableCel/Code/style.scss +2 -0
- package/src/components/table/ClTableCel/Currency/style.scss +1 -0
- package/src/components/table/ClTableCel/ID/style.scss +1 -0
- package/src/components/table/ClTableCel/Links/style.scss +4 -0
- package/src/components/table/ClTableCel/Time/style.scss +2 -0
- package/src/components/table/ClTableCel/style.variables.scss +0 -6
- package/src/styles/layout/meta.scss +1 -1
- package/src/styles/themes/dark.scss +11 -0
- package/types/castlabs-ui.module.d.ts +12 -11
- package/types/index.d.ts +13 -7
- package/dist/select-disabled-dark.1065ea4c.svg +0 -1
package/dist/castlabs-ui.core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @castlabs/ui v7.
|
|
1
|
+
/* @castlabs/ui v7.23.0 */
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* Bootstrap v5.3.8 (https://getbootstrap.com/)
|
|
@@ -216,9 +216,9 @@ function clMatomoSetup (siteId = 1, domain = 'castlabs.com') {
|
|
|
216
216
|
})()
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
function clTableSetupResize (id) {
|
|
219
|
+
function clTableSetupResize (id, auto = false) {
|
|
220
220
|
document.querySelectorAll(`#${id} .cl-resizer`).forEach(resizer => {
|
|
221
|
-
clTableSetResizeListeners(resizer)
|
|
221
|
+
clTableSetResizeListeners(resizer, auto)
|
|
222
222
|
})
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -249,12 +249,15 @@ function clTableSortStatic (id, col) {
|
|
|
249
249
|
let lastX = 0
|
|
250
250
|
let nextCol = null
|
|
251
251
|
|
|
252
|
-
function clTableSetResizeListeners (resizer) {
|
|
252
|
+
function clTableSetResizeListeners (resizer, auto = false) {
|
|
253
253
|
lastX = 0
|
|
254
254
|
nextCol = null
|
|
255
255
|
resizer.addEventListener('mousedown', mousedown)
|
|
256
256
|
document.addEventListener('mousemove', mousemove)
|
|
257
257
|
document.addEventListener('mouseup', mouseup)
|
|
258
|
+
if (auto) {
|
|
259
|
+
document.addEventListener('click', mouseclick)
|
|
260
|
+
}
|
|
258
261
|
}
|
|
259
262
|
|
|
260
263
|
const mousedown = mousedown => {
|
|
@@ -269,28 +272,25 @@ const mousemove = mousemove => {
|
|
|
269
272
|
const delta = mousemove.pageX - lastX
|
|
270
273
|
lastX = mousemove.pageX
|
|
271
274
|
|
|
272
|
-
const colIndex = getColIndex(nextCol)
|
|
275
|
+
const colIndex = getColIndex(nextCol) - 1
|
|
273
276
|
const id = mousemove.target?.closest('table')?.id ?? 'unknown'
|
|
274
277
|
const nowrap = !!document.querySelector(`#${id}.cl-table-nowrap`) // are we in nowrap mode?
|
|
275
278
|
if (nowrap) {
|
|
276
|
-
// in nowrap mode we only adjust the
|
|
277
|
-
document
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
)
|
|
281
|
-
.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
cel.style.width = (width > 32 ? width : 32) + 'px'
|
|
285
|
-
cel.style.maxWidth = (width > 32 ? width : 32) + 'px'
|
|
286
|
-
})
|
|
279
|
+
// in nowrap mode we only adjust the thead col
|
|
280
|
+
document.querySelectorAll(`#${id} tr th:nth-child(${colIndex})`).forEach(cel => {
|
|
281
|
+
const width =
|
|
282
|
+
(cel.style.maxWidth === '' ? cel.offsetWidth : parseInt(cel.style.maxWidth)) + delta
|
|
283
|
+
cel.style.width = (width > 32 ? width : 32) + 'px'
|
|
284
|
+
cel.style.maxWidth = (width > 32 ? width : 32) + 'px'
|
|
285
|
+
cel.clWidth = 0
|
|
286
|
+
})
|
|
287
287
|
} else {
|
|
288
288
|
// in regular mode we shrink one and enlarge the other col
|
|
289
|
-
document.querySelectorAll(`#${id} tr td:nth-child(${colIndex
|
|
289
|
+
document.querySelectorAll(`#${id} tr td:nth-child(${colIndex})`).forEach(cel => {
|
|
290
290
|
const width = cel.offsetWidth + delta
|
|
291
291
|
cel.style.width = (width > 32 ? width : 32) + 'px'
|
|
292
292
|
})
|
|
293
|
-
document.querySelectorAll(`#${id} tr td:nth-child(${colIndex})`).forEach(cel => {
|
|
293
|
+
document.querySelectorAll(`#${id} tr td:nth-child(${colIndex + 1})`).forEach(cel => {
|
|
294
294
|
const width = cel.offsetWidth - delta
|
|
295
295
|
cel.style.width = (width > 32 ? width : 32) + 'px'
|
|
296
296
|
})
|
|
@@ -306,8 +306,52 @@ const mouseup = mouseup => {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
+
const mouseclick = click => {
|
|
310
|
+
if (click.detail === 2) {
|
|
311
|
+
click.preventDefault()
|
|
312
|
+
|
|
313
|
+
const table = click.target?.closest('table')
|
|
314
|
+
const id = table?.id ?? 'unknown'
|
|
315
|
+
const th = click.target?.closest('th')
|
|
316
|
+
const colIndex = Array.from(th.parentElement.children).indexOf(th)
|
|
317
|
+
|
|
318
|
+
// set all to something small so scrollWidth is correct for all-smaller items (head only)
|
|
319
|
+
document.querySelectorAll(`#${id} th:nth-child(${colIndex})`).forEach(cel => {
|
|
320
|
+
cel.style.width = '1px'
|
|
321
|
+
cel.style.maxWidth = '1px'
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
// iterate over all rows and col index (thead + tbody), find max cel width
|
|
325
|
+
let maxCellWidth = 0
|
|
326
|
+
document
|
|
327
|
+
.querySelectorAll(`#${id} th:nth-child(${colIndex}), #${id} td:nth-child(${colIndex})`)
|
|
328
|
+
.forEach(cel => {
|
|
329
|
+
if ((cel.colSpan ?? 1) === 1) {
|
|
330
|
+
const cellWidth = cel.scrollWidth
|
|
331
|
+
maxCellWidth = cellWidth > maxCellWidth ? cellWidth : maxCellWidth
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
// set all outer width to inner (head only)
|
|
336
|
+
document.querySelectorAll(`#${id} th:nth-child(${colIndex})`).forEach(cel => {
|
|
337
|
+
if (cel.clWidth === maxCellWidth) {
|
|
338
|
+
// revert to un-maximized
|
|
339
|
+
cel.clWidth = 0
|
|
340
|
+
cel.style.removeProperty('width')
|
|
341
|
+
cel.style.removeProperty('max-width')
|
|
342
|
+
} else {
|
|
343
|
+
// maximize
|
|
344
|
+
const padding = 8 * 2
|
|
345
|
+
cel.clWidth = maxCellWidth
|
|
346
|
+
cel.style.width = `${cel.clWidth + padding}px`
|
|
347
|
+
cel.style.maxWidth = `${cel.clWidth + padding}px`
|
|
348
|
+
}
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
309
353
|
function getColIndex (col) {
|
|
310
|
-
// calculate index of a col in a row
|
|
354
|
+
// calculate index of a col in a row, 1-based
|
|
311
355
|
let colNo = 0
|
|
312
356
|
while (col) {
|
|
313
357
|
colNo++
|