@budibase/bbui 2.1.40-alpha.4 → 2.1.40-alpha.6
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/bbui.es.js +3 -3
- package/dist/bbui.es.js.map +1 -1
- package/package.json +3 -3
- package/src/Actions/click_outside.js +46 -11
- package/src/DetailSummary/DetailSummary.svelte +16 -7
- package/src/Form/Core/DatePicker.svelte +10 -0
- package/src/Icon/Icon.svelte +1 -1
- package/src/Table/Table.svelte +141 -139
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/bbui",
|
|
3
3
|
"description": "A UI solution used in the different Budibase projects.",
|
|
4
|
-
"version": "2.1.40-alpha.
|
|
4
|
+
"version": "2.1.40-alpha.6",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"svelte": "src/index.js",
|
|
7
7
|
"module": "dist/bbui.es.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
|
|
41
|
-
"@budibase/string-templates": "2.1.40-alpha.
|
|
41
|
+
"@budibase/string-templates": "2.1.40-alpha.6",
|
|
42
42
|
"@spectrum-css/actionbutton": "^1.0.1",
|
|
43
43
|
"@spectrum-css/actiongroup": "^1.0.1",
|
|
44
44
|
"@spectrum-css/avatar": "^3.0.2",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"resolutions": {
|
|
89
89
|
"loader-utils": "1.4.1"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "bd527a02929f9749d7cfd085cdeaf7a0c3d6d427"
|
|
92
92
|
}
|
|
@@ -1,18 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const ignoredClasses = [".flatpickr-calendar", ".modal-container"]
|
|
2
|
+
let clickHandlers = []
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Handle a body click event
|
|
6
|
+
*/
|
|
7
|
+
const handleClick = event => {
|
|
8
|
+
// Ignore click if needed
|
|
9
|
+
for (let className of ignoredClasses) {
|
|
10
|
+
if (event.target.closest(className)) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Process handlers
|
|
16
|
+
clickHandlers.forEach(handler => {
|
|
17
|
+
if (!handler.element.contains(event.target)) {
|
|
18
|
+
handler.callback?.(event)
|
|
5
19
|
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
document.documentElement.addEventListener("click", handleClick, true)
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Adds or updates a click handler
|
|
26
|
+
*/
|
|
27
|
+
const updateHandler = (id, element, callback) => {
|
|
28
|
+
let existingHandler = clickHandlers.find(x => x.id === id)
|
|
29
|
+
if (!existingHandler) {
|
|
30
|
+
clickHandlers.push({ id, element, callback })
|
|
31
|
+
} else {
|
|
32
|
+
existingHandler.callback = callback
|
|
6
33
|
}
|
|
34
|
+
}
|
|
7
35
|
|
|
8
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Removes a click handler
|
|
38
|
+
*/
|
|
39
|
+
const removeHandler = id => {
|
|
40
|
+
clickHandlers = clickHandlers.filter(x => x.id !== id)
|
|
41
|
+
}
|
|
9
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Svelte action to apply a click outside handler for a certain element
|
|
45
|
+
*/
|
|
46
|
+
export default (element, callback) => {
|
|
47
|
+
const id = Math.random()
|
|
48
|
+
updateHandler(id, element, callback)
|
|
10
49
|
return {
|
|
11
|
-
update(
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
destroy() {
|
|
15
|
-
document.body.removeEventListener("click", onClick, true)
|
|
16
|
-
},
|
|
50
|
+
update: newCallback => updateHandler(id, element, newCallback),
|
|
51
|
+
destroy: () => removeHandler(id),
|
|
17
52
|
}
|
|
18
53
|
}
|
|
@@ -19,13 +19,19 @@
|
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<div class="property-group-container">
|
|
22
|
-
|
|
23
|
-
<div class="name"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
{#if name}
|
|
23
|
+
<div class="property-group-name" on:click={onHeaderClick}>
|
|
24
|
+
<div class="name">{name}</div>
|
|
25
|
+
{#if collapsible}
|
|
26
|
+
<Icon size="S" name={show ? "Remove" : "Add"} />
|
|
27
|
+
{/if}
|
|
28
|
+
</div>
|
|
29
|
+
{/if}
|
|
30
|
+
<div
|
|
31
|
+
class="property-panel"
|
|
32
|
+
class:show={show || !collapsible}
|
|
33
|
+
class:no-title={!name}
|
|
34
|
+
>
|
|
29
35
|
<slot />
|
|
30
36
|
</div>
|
|
31
37
|
</div>
|
|
@@ -72,6 +78,9 @@
|
|
|
72
78
|
padding: var(--spacing-s) var(--spacing-xl) var(--spacing-xl)
|
|
73
79
|
var(--spacing-xl);
|
|
74
80
|
}
|
|
81
|
+
.property-panel.no-title {
|
|
82
|
+
padding: var(--spacing-xl);
|
|
83
|
+
}
|
|
75
84
|
|
|
76
85
|
.show {
|
|
77
86
|
display: flex;
|
|
@@ -23,6 +23,15 @@
|
|
|
23
23
|
let open = false
|
|
24
24
|
let flatpickr, flatpickrOptions
|
|
25
25
|
|
|
26
|
+
// Another classic flatpickr issue. Errors were randomly being thrown due to
|
|
27
|
+
// flatpickr internal code. Making sure that "destroy" is a valid function
|
|
28
|
+
// fixes it. The sooner we remove flatpickr the better.
|
|
29
|
+
$: {
|
|
30
|
+
if (flatpickr && !flatpickr.destroy) {
|
|
31
|
+
flatpickr.destroy = () => {}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
const resolveTimeStamp = timestamp => {
|
|
27
36
|
let maskedDate = new Date(`0-${timestamp}`)
|
|
28
37
|
|
|
@@ -252,6 +261,7 @@
|
|
|
252
261
|
width: 100vw;
|
|
253
262
|
height: 100vh;
|
|
254
263
|
z-index: 999;
|
|
264
|
+
max-height: 100%;
|
|
255
265
|
}
|
|
256
266
|
:global(.flatpickr-calendar) {
|
|
257
267
|
font-family: "Source Sans Pro", sans-serif;
|
package/src/Icon/Icon.svelte
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
transition: color var(--spectrum-global-animation-duration-100, 130ms);
|
|
65
65
|
}
|
|
66
66
|
svg.hoverable:hover {
|
|
67
|
-
color: var(--spectrum-alias-icon-color-selected-hover);
|
|
67
|
+
color: var(--spectrum-alias-icon-color-selected-hover) !important;
|
|
68
68
|
cursor: pointer;
|
|
69
69
|
}
|
|
70
70
|
|
package/src/Table/Table.svelte
CHANGED
|
@@ -275,157 +275,159 @@
|
|
|
275
275
|
}
|
|
276
276
|
</script>
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
<
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
{
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
<div
|
|
297
|
-
class:noBorderHeader={!showHeaderBorder}
|
|
298
|
-
class="spectrum-Table-headCell spectrum-Table-headCell--divider spectrum-Table-headCell--edit"
|
|
299
|
-
>
|
|
300
|
-
{#if allowSelectRows}
|
|
301
|
-
<Checkbox
|
|
302
|
-
bind:value={checkboxStatus}
|
|
303
|
-
on:change={toggleSelectAll}
|
|
304
|
-
/>
|
|
305
|
-
{:else}
|
|
306
|
-
Edit
|
|
307
|
-
{/if}
|
|
308
|
-
</div>
|
|
309
|
-
{/if}
|
|
310
|
-
{#each fields as field}
|
|
311
|
-
<div
|
|
312
|
-
class="spectrum-Table-headCell"
|
|
313
|
-
class:noBorderHeader={!showHeaderBorder}
|
|
314
|
-
class:spectrum-Table-headCell--alignCenter={schema[field]
|
|
315
|
-
.align === "Center"}
|
|
316
|
-
class:spectrum-Table-headCell--alignRight={schema[field].align ===
|
|
317
|
-
"Right"}
|
|
318
|
-
class:is-sortable={schema[field].sortable !== false}
|
|
319
|
-
class:is-sorted-desc={sortColumn === field &&
|
|
320
|
-
sortOrder === "Descending"}
|
|
321
|
-
class:is-sorted-asc={sortColumn === field &&
|
|
322
|
-
sortOrder === "Ascending"}
|
|
323
|
-
on:click={() => sortBy(schema[field])}
|
|
324
|
-
>
|
|
325
|
-
<div class="title">{getDisplayName(schema[field])}</div>
|
|
326
|
-
{#if schema[field]?.autocolumn}
|
|
327
|
-
<svg
|
|
328
|
-
class="spectrum-Icon spectrum-Table-autoIcon"
|
|
329
|
-
focusable="false"
|
|
330
|
-
>
|
|
331
|
-
<use xlink:href="#spectrum-icon-18-MagicWand" />
|
|
332
|
-
</svg>
|
|
333
|
-
{/if}
|
|
334
|
-
{#if sortColumn === field}
|
|
335
|
-
<svg
|
|
336
|
-
class="spectrum-Icon spectrum-UIIcon-ArrowDown100 spectrum-Table-sortedIcon"
|
|
337
|
-
focusable="false"
|
|
338
|
-
aria-hidden="true"
|
|
339
|
-
>
|
|
340
|
-
<use xlink:href="#spectrum-css-icon-Arrow100" />
|
|
341
|
-
</svg>
|
|
342
|
-
{/if}
|
|
343
|
-
{#if allowEditColumns && schema[field]?.editable !== false}
|
|
344
|
-
<svg
|
|
345
|
-
class="spectrum-Icon spectrum-Table-editIcon"
|
|
346
|
-
focusable="false"
|
|
347
|
-
on:click={e => editColumn(e, field)}
|
|
348
|
-
>
|
|
349
|
-
<use xlink:href="#spectrum-icon-18-Edit" />
|
|
350
|
-
</svg>
|
|
351
|
-
{/if}
|
|
352
|
-
</div>
|
|
353
|
-
{/each}
|
|
354
|
-
</div>
|
|
355
|
-
{/if}
|
|
356
|
-
{#if sortedRows?.length}
|
|
357
|
-
{#each sortedRows as row, idx}
|
|
358
|
-
<div class="spectrum-Table-row">
|
|
278
|
+
{#key fields?.length}
|
|
279
|
+
<div
|
|
280
|
+
class="wrapper"
|
|
281
|
+
class:wrapper--quiet={quiet}
|
|
282
|
+
class:wrapper--compact={compact}
|
|
283
|
+
bind:offsetHeight={height}
|
|
284
|
+
style={`--row-height: ${rowHeight}px; --header-height: ${headerHeight}px;`}
|
|
285
|
+
>
|
|
286
|
+
{#if loading}
|
|
287
|
+
<div class="loading" style={heightStyle}>
|
|
288
|
+
<slot name="loadingIndicator">
|
|
289
|
+
<ProgressCircle />
|
|
290
|
+
</slot>
|
|
291
|
+
</div>
|
|
292
|
+
{:else}
|
|
293
|
+
<div class="spectrum-Table" style={`${heightStyle}${gridStyle}`}>
|
|
294
|
+
{#if fields.length}
|
|
295
|
+
<div class="spectrum-Table-head">
|
|
359
296
|
{#if showEditColumn}
|
|
360
297
|
<div
|
|
361
|
-
class:
|
|
362
|
-
class="spectrum-Table-
|
|
363
|
-
on:click={e => {
|
|
364
|
-
toggleSelectRow(row)
|
|
365
|
-
e.stopPropagation()
|
|
366
|
-
}}
|
|
298
|
+
class:noBorderHeader={!showHeaderBorder}
|
|
299
|
+
class="spectrum-Table-headCell spectrum-Table-headCell--divider spectrum-Table-headCell--edit"
|
|
367
300
|
>
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
/>
|
|
301
|
+
{#if allowSelectRows}
|
|
302
|
+
<Checkbox
|
|
303
|
+
bind:value={checkboxStatus}
|
|
304
|
+
on:change={toggleSelectAll}
|
|
305
|
+
/>
|
|
306
|
+
{:else}
|
|
307
|
+
Edit
|
|
308
|
+
{/if}
|
|
377
309
|
</div>
|
|
378
310
|
{/if}
|
|
379
311
|
{#each fields as field}
|
|
380
312
|
<div
|
|
381
|
-
class="spectrum-Table-
|
|
382
|
-
class:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
313
|
+
class="spectrum-Table-headCell"
|
|
314
|
+
class:noBorderHeader={!showHeaderBorder}
|
|
315
|
+
class:spectrum-Table-headCell--alignCenter={schema[field]
|
|
316
|
+
.align === "Center"}
|
|
317
|
+
class:spectrum-Table-headCell--alignRight={schema[field]
|
|
318
|
+
.align === "Right"}
|
|
319
|
+
class:is-sortable={schema[field].sortable !== false}
|
|
320
|
+
class:is-sorted-desc={sortColumn === field &&
|
|
321
|
+
sortOrder === "Descending"}
|
|
322
|
+
class:is-sorted-asc={sortColumn === field &&
|
|
323
|
+
sortOrder === "Ascending"}
|
|
324
|
+
on:click={() => sortBy(schema[field])}
|
|
390
325
|
>
|
|
391
|
-
<
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
326
|
+
<div class="title">{getDisplayName(schema[field])}</div>
|
|
327
|
+
{#if schema[field]?.autocolumn}
|
|
328
|
+
<svg
|
|
329
|
+
class="spectrum-Icon spectrum-Table-autoIcon"
|
|
330
|
+
focusable="false"
|
|
331
|
+
>
|
|
332
|
+
<use xlink:href="#spectrum-icon-18-MagicWand" />
|
|
333
|
+
</svg>
|
|
334
|
+
{/if}
|
|
335
|
+
{#if sortColumn === field}
|
|
336
|
+
<svg
|
|
337
|
+
class="spectrum-Icon spectrum-UIIcon-ArrowDown100 spectrum-Table-sortedIcon"
|
|
338
|
+
focusable="false"
|
|
339
|
+
aria-hidden="true"
|
|
340
|
+
>
|
|
341
|
+
<use xlink:href="#spectrum-css-icon-Arrow100" />
|
|
342
|
+
</svg>
|
|
343
|
+
{/if}
|
|
344
|
+
{#if allowEditColumns && schema[field]?.editable !== false}
|
|
345
|
+
<svg
|
|
346
|
+
class="spectrum-Icon spectrum-Table-editIcon"
|
|
347
|
+
focusable="false"
|
|
348
|
+
on:click={e => editColumn(e, field)}
|
|
349
|
+
>
|
|
350
|
+
<use xlink:href="#spectrum-icon-18-Edit" />
|
|
351
|
+
</svg>
|
|
352
|
+
{/if}
|
|
401
353
|
</div>
|
|
402
354
|
{/each}
|
|
403
355
|
</div>
|
|
404
|
-
{/
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
356
|
+
{/if}
|
|
357
|
+
{#if sortedRows?.length}
|
|
358
|
+
{#each sortedRows as row, idx}
|
|
359
|
+
<div class="spectrum-Table-row">
|
|
360
|
+
{#if showEditColumn}
|
|
361
|
+
<div
|
|
362
|
+
class:noBorderCheckbox={!showHeaderBorder}
|
|
363
|
+
class="spectrum-Table-cell spectrum-Table-cell--divider spectrum-Table-cell--edit"
|
|
364
|
+
on:click={e => {
|
|
365
|
+
toggleSelectRow(row)
|
|
366
|
+
e.stopPropagation()
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
369
|
+
<SelectEditRenderer
|
|
370
|
+
data={row}
|
|
371
|
+
selected={selectedRows.findIndex(
|
|
372
|
+
selectedRow => selectedRow._id === row._id
|
|
373
|
+
) !== -1}
|
|
374
|
+
onEdit={e => editRow(e, row)}
|
|
375
|
+
{allowSelectRows}
|
|
376
|
+
{allowEditRows}
|
|
377
|
+
/>
|
|
378
|
+
</div>
|
|
379
|
+
{/if}
|
|
380
|
+
{#each fields as field}
|
|
381
|
+
<div
|
|
382
|
+
class="spectrum-Table-cell"
|
|
383
|
+
class:spectrum-Table-cell--divider={!!schema[field].divider}
|
|
384
|
+
style={cellStyles[field]}
|
|
385
|
+
on:click={() => {
|
|
386
|
+
if (!schema[field]?.preventSelectRow) {
|
|
387
|
+
dispatch("click", row)
|
|
388
|
+
toggleSelectRow(row)
|
|
389
|
+
}
|
|
390
|
+
}}
|
|
391
|
+
>
|
|
392
|
+
<CellRenderer
|
|
393
|
+
{customRenderers}
|
|
394
|
+
{row}
|
|
395
|
+
schema={schema[field]}
|
|
396
|
+
value={deepGet(row, field)}
|
|
397
|
+
on:clickrelationship
|
|
398
|
+
on:buttonclick
|
|
399
|
+
>
|
|
400
|
+
<slot />
|
|
401
|
+
</CellRenderer>
|
|
402
|
+
</div>
|
|
403
|
+
{/each}
|
|
422
404
|
</div>
|
|
423
|
-
{/
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
405
|
+
{/each}
|
|
406
|
+
{:else}
|
|
407
|
+
<div
|
|
408
|
+
class="placeholder"
|
|
409
|
+
class:placeholder--custom={customPlaceholder}
|
|
410
|
+
class:placeholder--no-fields={!fields?.length}
|
|
411
|
+
>
|
|
412
|
+
{#if customPlaceholder}
|
|
413
|
+
<slot name="placeholder" />
|
|
414
|
+
{:else}
|
|
415
|
+
<div class="placeholder-content">
|
|
416
|
+
<svg
|
|
417
|
+
class="spectrum-Icon spectrum-Icon--sizeXXL"
|
|
418
|
+
focusable="false"
|
|
419
|
+
>
|
|
420
|
+
<use xlink:href="#spectrum-icon-18-Table" />
|
|
421
|
+
</svg>
|
|
422
|
+
<div>{placeholderText}</div>
|
|
423
|
+
</div>
|
|
424
|
+
{/if}
|
|
425
|
+
</div>
|
|
426
|
+
{/if}
|
|
427
|
+
</div>
|
|
428
|
+
{/if}
|
|
429
|
+
</div>
|
|
430
|
+
{/key}
|
|
429
431
|
|
|
430
432
|
<style>
|
|
431
433
|
/* Wrapper */
|