@castlabs/ui 8.4.0 → 8.5.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.map +1 -1
- package/dist/castlabs-ui-editor.umd.js.map +1 -1
- package/dist/castlabs-ui.common.js +70 -65
- package/dist/castlabs-ui.common.js.map +1 -1
- package/dist/castlabs-ui.core.js +68 -4
- package/dist/castlabs-ui.css +1 -1
- package/dist/castlabs-ui.module.js +68 -4
- package/dist/castlabs-ui.umd.js +85 -78
- package/dist/castlabs-ui.umd.js.map +1 -1
- package/dist/dist-e2259382.js +13 -0
- package/dist/dist-e2259382.js.map +1 -0
- package/package.json +12 -13
- package/src/styles/layout/meta.scss +1 -1
- package/types/index.d.ts +2 -2
- package/dist/magic-string.es-3690a1eb.js +0 -11
- package/dist/magic-string.es-3690a1eb.js.map +0 -1
package/dist/castlabs-ui.core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @castlabs/ui v8.
|
|
1
|
+
/* @castlabs/ui v8.5.0 */
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* Bootstrap v5.3.8 (https://getbootstrap.com/)
|
|
@@ -112,6 +112,8 @@ function clSidenavInitiallyOpen () {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
|
|
116
|
+
|
|
115
117
|
function clTableSetupResize (id, auto = false) {
|
|
116
118
|
document.querySelectorAll(`#${id} .cl-resizer`).forEach(resizer => {
|
|
117
119
|
clTableSetResizeListeners(resizer, auto)
|
|
@@ -145,6 +147,60 @@ function clTableSortStatic (id, col) {
|
|
|
145
147
|
let lastX = 0
|
|
146
148
|
let nextCol = null
|
|
147
149
|
|
|
150
|
+
function isNowrap (id) {
|
|
151
|
+
return !!document.querySelector(`#${id}.cl-table-nowrap`)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function clTableGetColWidthArray (id) {
|
|
155
|
+
const widths = []
|
|
156
|
+
document.querySelectorAll(`#${id} tr th`).forEach(cel => {
|
|
157
|
+
widths.push(parseInt('0' + cel.style.width)) // get manual width as int, or 0 if no manual width
|
|
158
|
+
})
|
|
159
|
+
while (widths[widths.length - 1] === 0) {
|
|
160
|
+
widths.pop() // remove trailing zeroes
|
|
161
|
+
}
|
|
162
|
+
return widths
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function saveColWidth (id) {
|
|
166
|
+
if (isNowrap(id)) {
|
|
167
|
+
// saving only works for nowrap tables that have a settings/save ID set
|
|
168
|
+
const tableId = document.querySelector(`#${id}`)?.closest('.cl-table-scroll')?.id
|
|
169
|
+
if (!tableId) return
|
|
170
|
+
|
|
171
|
+
const widths = clTableGetColWidthArray(id)
|
|
172
|
+
|
|
173
|
+
const settings = clGetSettingsTable(tableId) ?? {}
|
|
174
|
+
settings.w = widths
|
|
175
|
+
clSetSettingsTable(tableId, settings)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function clTableRestoreColWidths (id, override = undefined) {
|
|
180
|
+
if (isNowrap(id)) {
|
|
181
|
+
const tableId = document.querySelector(`#${id}`)?.closest('.cl-table-scroll')?.id
|
|
182
|
+
if (!tableId) return
|
|
183
|
+
|
|
184
|
+
const widths = override ? override : ((clGetSettingsTable(tableId) ?? {}).w ?? [])
|
|
185
|
+
for (
|
|
186
|
+
let colIndex = 1;
|
|
187
|
+
colIndex <= document.querySelectorAll(`#${id} tr th`).length;
|
|
188
|
+
colIndex++
|
|
189
|
+
) {
|
|
190
|
+
document.querySelectorAll(`#${id} tr th:nth-child(${colIndex})`).forEach(cel => {
|
|
191
|
+
const width = widths?.[colIndex - 1] ?? 0
|
|
192
|
+
if (width > 0) {
|
|
193
|
+
cel.style.width = (width > 32 ? width : 32) + 'px'
|
|
194
|
+
cel.style.maxWidth = (width > 32 ? width : 32) + 'px'
|
|
195
|
+
} else {
|
|
196
|
+
cel.style.width = null
|
|
197
|
+
cel.style.maxWidth = null
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
148
204
|
function clTableSetResizeListeners (resizer, auto = false) {
|
|
149
205
|
lastX = 0
|
|
150
206
|
nextCol = null
|
|
@@ -170,8 +226,7 @@ const mousemove = mousemove => {
|
|
|
170
226
|
|
|
171
227
|
const colIndex = getColIndex(nextCol) - 1
|
|
172
228
|
const id = mousemove.target?.closest('table')?.id ?? 'unknown'
|
|
173
|
-
|
|
174
|
-
if (nowrap) {
|
|
229
|
+
if (isNowrap(id)) {
|
|
175
230
|
// in nowrap mode we only adjust the thead col
|
|
176
231
|
document.querySelectorAll(`#${id} tr th:nth-child(${colIndex})`).forEach(cel => {
|
|
177
232
|
const width =
|
|
@@ -199,10 +254,15 @@ const mouseup = mouseup => {
|
|
|
199
254
|
mouseup.preventDefault()
|
|
200
255
|
lastX = 0
|
|
201
256
|
nextCol = null
|
|
257
|
+
|
|
258
|
+
// save col widths
|
|
259
|
+
const id = mouseup.target?.closest('table')?.id ?? 'unknown'
|
|
260
|
+
saveColWidth(id, 'mouseup')
|
|
202
261
|
}
|
|
203
262
|
}
|
|
204
263
|
|
|
205
264
|
const mouseclick = click => {
|
|
265
|
+
// doubleclick = autoresize
|
|
206
266
|
if (click.detail === 2) {
|
|
207
267
|
const table = click.target?.closest('table')
|
|
208
268
|
if (!table) return
|
|
@@ -244,6 +304,8 @@ const mouseclick = click => {
|
|
|
244
304
|
cel.style.maxWidth = `${cel.clWidth + padding}px`
|
|
245
305
|
}
|
|
246
306
|
})
|
|
307
|
+
|
|
308
|
+
saveColWidth(id, 'doubleclick')
|
|
247
309
|
}
|
|
248
310
|
}
|
|
249
311
|
|
|
@@ -1828,6 +1890,7 @@ function clSetUISettings (settings) {
|
|
|
1828
1890
|
} catch (e) {
|
|
1829
1891
|
e.ignore?.()
|
|
1830
1892
|
} // catch & storage or parsing issues
|
|
1893
|
+
return settings
|
|
1831
1894
|
}
|
|
1832
1895
|
|
|
1833
1896
|
function clGetSettingsTable (id) {
|
|
@@ -1836,10 +1899,11 @@ function clGetSettingsTable (id) {
|
|
|
1836
1899
|
}
|
|
1837
1900
|
|
|
1838
1901
|
function clSetSettingsTable (id, table) {
|
|
1902
|
+
if (!id) return undefined
|
|
1839
1903
|
const settings = clGetUISettings()
|
|
1840
1904
|
if (!settings.tables) settings.tables = {}
|
|
1841
1905
|
settings.tables[id] = table
|
|
1842
|
-
clSetUISettings(settings)
|
|
1906
|
+
return clSetUISettings(settings)
|
|
1843
1907
|
}
|
|
1844
1908
|
|
|
1845
1909
|
const NBSP = '✺' // non-breakable space for searching substrings
|