@budibase/frontend-core 2.6.3 → 2.6.5
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/package.json +4 -4
- package/src/components/grid/cells/GutterCell.svelte +20 -2
- package/src/components/grid/controls/{DeleteButton.svelte → BulkDeleteHandler.svelte} +2 -27
- package/src/components/grid/controls/ColumnWidthButton.svelte +4 -3
- package/src/components/grid/controls/HideColumnsButton.svelte +22 -7
- package/src/components/grid/controls/RowHeightButton.svelte +4 -3
- package/src/components/grid/controls/SortButton.svelte +4 -3
- package/src/components/grid/layout/Grid.svelte +11 -6
- package/src/components/grid/layout/HeaderRow.svelte +18 -10
- package/src/components/grid/layout/NewRow.svelte +1 -1
- package/src/components/grid/lib/utils.js +3 -0
- package/src/components/grid/overlays/KeyboardManager.svelte +13 -6
- package/src/components/grid/stores/ui.js +10 -0
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
7
|
"svelte": "src/index.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@budibase/bbui": "^2.6.
|
|
10
|
-
"@budibase/shared-core": "^2.6.
|
|
9
|
+
"@budibase/bbui": "^2.6.5",
|
|
10
|
+
"@budibase/shared-core": "^2.6.5",
|
|
11
11
|
"dayjs": "^1.11.7",
|
|
12
12
|
"lodash": "^4.17.21",
|
|
13
13
|
"socket.io-client": "^4.6.1",
|
|
14
14
|
"svelte": "^3.46.2"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "df1d2f33515739050a3f5dee971dfa6c3d711a17"
|
|
17
17
|
}
|
|
@@ -70,7 +70,15 @@
|
|
|
70
70
|
</div>
|
|
71
71
|
{/if}
|
|
72
72
|
{/if}
|
|
73
|
-
{#if $config.
|
|
73
|
+
{#if rowSelected && $config.allowDeleteRows}
|
|
74
|
+
<div class="delete" on:click={() => dispatch("request-bulk-delete")}>
|
|
75
|
+
<Icon
|
|
76
|
+
name="Delete"
|
|
77
|
+
size="S"
|
|
78
|
+
color="var(--spectrum-global-color-red-400)"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
{:else if $config.allowExpandRows}
|
|
74
82
|
<div
|
|
75
83
|
class="expand"
|
|
76
84
|
class:visible={!disableExpand && (rowFocused || rowHovered)}
|
|
@@ -111,10 +119,13 @@
|
|
|
111
119
|
.number.visible {
|
|
112
120
|
display: flex;
|
|
113
121
|
}
|
|
122
|
+
.delete,
|
|
114
123
|
.expand {
|
|
115
|
-
opacity: 0;
|
|
116
124
|
margin-right: 4px;
|
|
117
125
|
}
|
|
126
|
+
.expand {
|
|
127
|
+
opacity: 0;
|
|
128
|
+
}
|
|
118
129
|
.expand :global(.spectrum-Icon) {
|
|
119
130
|
pointer-events: none;
|
|
120
131
|
}
|
|
@@ -124,4 +135,11 @@
|
|
|
124
135
|
.expand.visible :global(.spectrum-Icon) {
|
|
125
136
|
pointer-events: all;
|
|
126
137
|
}
|
|
138
|
+
|
|
139
|
+
.delete:hover {
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
}
|
|
142
|
+
.delete:hover :global(.spectrum-Icon) {
|
|
143
|
+
color: var(--spectrum-global-color-red-600) !important;
|
|
144
|
+
}
|
|
127
145
|
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { Modal, ModalContent,
|
|
2
|
+
import { Modal, ModalContent, notifications } from "@budibase/bbui"
|
|
3
3
|
import { getContext, onMount } from "svelte"
|
|
4
4
|
|
|
5
|
-
const { selectedRows, rows,
|
|
5
|
+
const { selectedRows, rows, subscribe } = getContext("grid")
|
|
6
6
|
|
|
7
7
|
let modal
|
|
8
8
|
|
|
@@ -27,20 +27,6 @@
|
|
|
27
27
|
onMount(() => subscribe("request-bulk-delete", () => modal?.show()))
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
|
-
{#if selectedRowCount}
|
|
31
|
-
<div class="delete-button" data-ignore-click-outside="true">
|
|
32
|
-
<Button
|
|
33
|
-
icon="Delete"
|
|
34
|
-
size="M"
|
|
35
|
-
on:click={modal.show}
|
|
36
|
-
disabled={!$config.allowEditRows}
|
|
37
|
-
cta
|
|
38
|
-
>
|
|
39
|
-
Delete {selectedRowCount} row{selectedRowCount === 1 ? "" : "s"}
|
|
40
|
-
</Button>
|
|
41
|
-
</div>
|
|
42
|
-
{/if}
|
|
43
|
-
|
|
44
30
|
<Modal bind:this={modal}>
|
|
45
31
|
<ModalContent
|
|
46
32
|
title="Delete rows"
|
|
@@ -53,14 +39,3 @@
|
|
|
53
39
|
row{selectedRowCount === 1 ? "" : "s"}?
|
|
54
40
|
</ModalContent>
|
|
55
41
|
</Modal>
|
|
56
|
-
|
|
57
|
-
<style>
|
|
58
|
-
.delete-button :global(.spectrum-Button:not(:disabled)) {
|
|
59
|
-
background-color: var(--spectrum-global-color-red-400);
|
|
60
|
-
border-color: var(--spectrum-global-color-red-400);
|
|
61
|
-
}
|
|
62
|
-
.delete-button :global(.spectrum-Button:not(:disabled):hover) {
|
|
63
|
-
background-color: var(--spectrum-global-color-red-500);
|
|
64
|
-
border-color: var(--spectrum-global-color-red-500);
|
|
65
|
-
}
|
|
66
|
-
</style>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ActionButton, Popover } from "@budibase/bbui"
|
|
4
4
|
import { DefaultColumnWidth } from "../lib/constants"
|
|
5
5
|
|
|
6
|
-
const { stickyColumn, columns } = getContext("grid")
|
|
6
|
+
const { stickyColumn, columns, compact } = getContext("grid")
|
|
7
7
|
const smallSize = 120
|
|
8
8
|
const mediumSize = DefaultColumnWidth
|
|
9
9
|
const largeSize = DefaultColumnWidth * 1.5
|
|
@@ -59,12 +59,13 @@
|
|
|
59
59
|
on:click={() => (open = !open)}
|
|
60
60
|
selected={open}
|
|
61
61
|
disabled={!allCols.length}
|
|
62
|
+
tooltip={$compact ? "Width" : null}
|
|
62
63
|
>
|
|
63
|
-
Width
|
|
64
|
+
{$compact ? "" : "Width"}
|
|
64
65
|
</ActionButton>
|
|
65
66
|
</div>
|
|
66
67
|
|
|
67
|
-
<Popover bind:open {anchor} align="left">
|
|
68
|
+
<Popover bind:open {anchor} align={$compact ? "right" : "left"}>
|
|
68
69
|
<div class="content">
|
|
69
70
|
{#each sizeOptions as option}
|
|
70
71
|
<ActionButton
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { getContext } from "svelte"
|
|
3
|
-
import { ActionButton, Popover, Toggle } from "@budibase/bbui"
|
|
3
|
+
import { ActionButton, Popover, Toggle, Icon } from "@budibase/bbui"
|
|
4
|
+
import { getColumnIcon } from "../lib/utils"
|
|
4
5
|
|
|
5
|
-
const { columns, stickyColumn } = getContext("grid")
|
|
6
|
+
const { columns, stickyColumn, compact } = getContext("grid")
|
|
6
7
|
|
|
7
8
|
let open = false
|
|
8
9
|
let anchor
|
|
@@ -47,25 +48,32 @@
|
|
|
47
48
|
on:click={() => (open = !open)}
|
|
48
49
|
selected={open || anyHidden}
|
|
49
50
|
disabled={!$columns.length}
|
|
51
|
+
tooltip={$compact ? "Columns" : ""}
|
|
50
52
|
>
|
|
51
|
-
Columns
|
|
53
|
+
{$compact ? "" : "Columns"}
|
|
52
54
|
</ActionButton>
|
|
53
55
|
</div>
|
|
54
56
|
|
|
55
|
-
<Popover bind:open {anchor} align="left">
|
|
57
|
+
<Popover bind:open {anchor} align={$compact ? "right" : "left"}>
|
|
56
58
|
<div class="content">
|
|
57
59
|
<div class="columns">
|
|
58
60
|
{#if $stickyColumn}
|
|
61
|
+
<div class="column">
|
|
62
|
+
<Icon size="S" name={getColumnIcon($stickyColumn)} />
|
|
63
|
+
{$stickyColumn.label}
|
|
64
|
+
</div>
|
|
59
65
|
<Toggle disabled size="S" value={true} />
|
|
60
|
-
<span>{$stickyColumn.label}</span>
|
|
61
66
|
{/if}
|
|
62
67
|
{#each $columns as column}
|
|
68
|
+
<div class="column">
|
|
69
|
+
<Icon size="S" name={getColumnIcon(column)} />
|
|
70
|
+
{column.label}
|
|
71
|
+
</div>
|
|
63
72
|
<Toggle
|
|
64
73
|
size="S"
|
|
65
74
|
value={column.visible}
|
|
66
75
|
on:change={e => toggleVisibility(column, e.detail)}
|
|
67
76
|
/>
|
|
68
|
-
<span>{column.label}</span>
|
|
69
77
|
{/each}
|
|
70
78
|
</div>
|
|
71
79
|
<div class="buttons">
|
|
@@ -90,6 +98,13 @@
|
|
|
90
98
|
.columns {
|
|
91
99
|
display: grid;
|
|
92
100
|
align-items: center;
|
|
93
|
-
grid-template-columns: auto
|
|
101
|
+
grid-template-columns: 1fr auto;
|
|
102
|
+
}
|
|
103
|
+
.columns :global(.spectrum-Switch) {
|
|
104
|
+
margin-right: 0;
|
|
105
|
+
}
|
|
106
|
+
.column {
|
|
107
|
+
display: flex;
|
|
108
|
+
gap: 8px;
|
|
94
109
|
}
|
|
95
110
|
</style>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
SmallRowHeight,
|
|
8
8
|
} from "../lib/constants"
|
|
9
9
|
|
|
10
|
-
const { rowHeight, columns, table } = getContext("grid")
|
|
10
|
+
const { rowHeight, columns, table, compact } = getContext("grid")
|
|
11
11
|
const sizeOptions = [
|
|
12
12
|
{
|
|
13
13
|
label: "Small",
|
|
@@ -41,12 +41,13 @@
|
|
|
41
41
|
size="M"
|
|
42
42
|
on:click={() => (open = !open)}
|
|
43
43
|
selected={open}
|
|
44
|
+
tooltip={$compact ? "Height" : null}
|
|
44
45
|
>
|
|
45
|
-
Height
|
|
46
|
+
{$compact ? "" : "Height"}
|
|
46
47
|
</ActionButton>
|
|
47
48
|
</div>
|
|
48
49
|
|
|
49
|
-
<Popover bind:open {anchor} align="left">
|
|
50
|
+
<Popover bind:open {anchor} align={$compact ? "right" : "left"}>
|
|
50
51
|
<div class="content">
|
|
51
52
|
{#each sizeOptions as option}
|
|
52
53
|
<ActionButton
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getContext } from "svelte"
|
|
3
3
|
import { ActionButton, Popover, Select } from "@budibase/bbui"
|
|
4
4
|
|
|
5
|
-
const { sort, columns, stickyColumn } = getContext("grid")
|
|
5
|
+
const { sort, columns, stickyColumn, compact } = getContext("grid")
|
|
6
6
|
|
|
7
7
|
let open = false
|
|
8
8
|
let anchor
|
|
@@ -90,12 +90,13 @@
|
|
|
90
90
|
on:click={() => (open = !open)}
|
|
91
91
|
selected={open}
|
|
92
92
|
disabled={!columnOptions.length}
|
|
93
|
+
tooltip={$compact ? "Sort" : ""}
|
|
93
94
|
>
|
|
94
|
-
Sort
|
|
95
|
+
{$compact ? "" : "Sort"}
|
|
95
96
|
</ActionButton>
|
|
96
97
|
</div>
|
|
97
98
|
|
|
98
|
-
<Popover bind:open {anchor} align="left">
|
|
99
|
+
<Popover bind:open {anchor} align={$compact ? "right" : "left"}>
|
|
99
100
|
<div class="content">
|
|
100
101
|
<Select
|
|
101
102
|
placeholder={null}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { createEventManagers } from "../lib/events"
|
|
7
7
|
import { createAPIClient } from "../../../api"
|
|
8
8
|
import { attachStores } from "../stores"
|
|
9
|
-
import
|
|
9
|
+
import BulkDeleteHandler from "../controls/BulkDeleteHandler.svelte"
|
|
10
10
|
import BetaButton from "../controls/BetaButton.svelte"
|
|
11
11
|
import GridBody from "./GridBody.svelte"
|
|
12
12
|
import ResizeOverlay from "../overlays/ResizeOverlay.svelte"
|
|
@@ -112,13 +112,12 @@
|
|
|
112
112
|
<AddRowButton />
|
|
113
113
|
<AddColumnButton />
|
|
114
114
|
<slot name="controls" />
|
|
115
|
+
<SortButton />
|
|
116
|
+
<HideColumnsButton />
|
|
115
117
|
<ColumnWidthButton />
|
|
116
118
|
<RowHeightButton />
|
|
117
|
-
<HideColumnsButton />
|
|
118
|
-
<SortButton />
|
|
119
119
|
</div>
|
|
120
120
|
<div class="controls-right">
|
|
121
|
-
<DeleteButton />
|
|
122
121
|
<UserAvatars />
|
|
123
122
|
</div>
|
|
124
123
|
</div>
|
|
@@ -131,7 +130,9 @@
|
|
|
131
130
|
<GridBody />
|
|
132
131
|
</div>
|
|
133
132
|
<BetaButton />
|
|
134
|
-
|
|
133
|
+
{#if allowAddRows}
|
|
134
|
+
<NewRow />
|
|
135
|
+
{/if}
|
|
135
136
|
<div class="overlays">
|
|
136
137
|
<ResizeOverlay />
|
|
137
138
|
<ReorderOverlay />
|
|
@@ -146,6 +147,9 @@
|
|
|
146
147
|
<ProgressCircle />
|
|
147
148
|
</div>
|
|
148
149
|
{/if}
|
|
150
|
+
{#if allowDeleteRows}
|
|
151
|
+
<BulkDeleteHandler />
|
|
152
|
+
{/if}
|
|
149
153
|
<KeyboardManager />
|
|
150
154
|
</div>
|
|
151
155
|
|
|
@@ -214,6 +218,7 @@
|
|
|
214
218
|
padding: var(--cell-padding);
|
|
215
219
|
gap: var(--cell-spacing);
|
|
216
220
|
background: var(--background);
|
|
221
|
+
z-index: 2;
|
|
217
222
|
}
|
|
218
223
|
.controls-left,
|
|
219
224
|
.controls-right {
|
|
@@ -239,7 +244,7 @@
|
|
|
239
244
|
height: 100%;
|
|
240
245
|
display: grid;
|
|
241
246
|
place-items: center;
|
|
242
|
-
z-index:
|
|
247
|
+
z-index: 100;
|
|
243
248
|
}
|
|
244
249
|
.grid-loading:before {
|
|
245
250
|
content: "";
|
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
import HeaderCell from "../cells/HeaderCell.svelte"
|
|
5
5
|
import { Icon } from "@budibase/bbui"
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
|
|
7
|
+
const {
|
|
8
|
+
renderedColumns,
|
|
9
|
+
dispatch,
|
|
10
|
+
scroll,
|
|
11
|
+
hiddenColumnsWidth,
|
|
12
|
+
width,
|
|
13
|
+
config,
|
|
14
|
+
} = getContext("grid")
|
|
9
15
|
|
|
10
16
|
$: columnsWidth = $renderedColumns.reduce(
|
|
11
17
|
(total, col) => (total += col.width),
|
|
@@ -23,13 +29,15 @@
|
|
|
23
29
|
{/each}
|
|
24
30
|
</div>
|
|
25
31
|
</GridScrollWrapper>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
{#if $config.allowAddColumns}
|
|
33
|
+
<div
|
|
34
|
+
class="add"
|
|
35
|
+
style="left:{left}px"
|
|
36
|
+
on:click={() => dispatch("add-column")}
|
|
37
|
+
>
|
|
38
|
+
<Icon name="Add" />
|
|
39
|
+
</div>
|
|
40
|
+
{/if}
|
|
33
41
|
</div>
|
|
34
42
|
|
|
35
43
|
<style>
|
|
@@ -38,7 +46,6 @@
|
|
|
38
46
|
border-bottom: var(--cell-border);
|
|
39
47
|
position: relative;
|
|
40
48
|
height: var(--default-row-height);
|
|
41
|
-
z-index: 1;
|
|
42
49
|
}
|
|
43
50
|
.row {
|
|
44
51
|
display: flex;
|
|
@@ -54,6 +61,7 @@
|
|
|
54
61
|
border-right: var(--cell-border);
|
|
55
62
|
border-bottom: var(--cell-border);
|
|
56
63
|
background: var(--spectrum-global-color-gray-100);
|
|
64
|
+
z-index: 20;
|
|
57
65
|
}
|
|
58
66
|
.add:hover {
|
|
59
67
|
background: var(--spectrum-global-color-gray-200);
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
clipboard,
|
|
14
14
|
dispatch,
|
|
15
15
|
selectedRows,
|
|
16
|
+
config,
|
|
16
17
|
} = getContext("grid")
|
|
17
18
|
|
|
18
19
|
const ignoredOriginSelectors = [
|
|
@@ -37,10 +38,12 @@
|
|
|
37
38
|
e.preventDefault()
|
|
38
39
|
focusFirstCell()
|
|
39
40
|
} else if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
if ($config.allowAddRows) {
|
|
42
|
+
e.preventDefault()
|
|
43
|
+
dispatch("add-row-inline")
|
|
44
|
+
}
|
|
42
45
|
} else if (e.key === "Delete" || e.key === "Backspace") {
|
|
43
|
-
if (Object.keys($selectedRows).length) {
|
|
46
|
+
if (Object.keys($selectedRows).length && $config.allowDeleteRows) {
|
|
44
47
|
dispatch("request-bulk-delete")
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -88,7 +91,9 @@
|
|
|
88
91
|
}
|
|
89
92
|
break
|
|
90
93
|
case "Enter":
|
|
91
|
-
|
|
94
|
+
if ($config.allowAddRows) {
|
|
95
|
+
dispatch("add-row-inline")
|
|
96
|
+
}
|
|
92
97
|
}
|
|
93
98
|
} else {
|
|
94
99
|
switch (e.key) {
|
|
@@ -106,7 +111,7 @@
|
|
|
106
111
|
break
|
|
107
112
|
case "Delete":
|
|
108
113
|
case "Backspace":
|
|
109
|
-
if (Object.keys($selectedRows).length) {
|
|
114
|
+
if (Object.keys($selectedRows).length && $config.allowDeleteRows) {
|
|
110
115
|
dispatch("request-bulk-delete")
|
|
111
116
|
} else {
|
|
112
117
|
deleteSelectedCell()
|
|
@@ -117,7 +122,9 @@
|
|
|
117
122
|
break
|
|
118
123
|
case " ":
|
|
119
124
|
case "Space":
|
|
120
|
-
|
|
125
|
+
if ($config.allowDeleteRows) {
|
|
126
|
+
toggleSelectRow()
|
|
127
|
+
}
|
|
121
128
|
break
|
|
122
129
|
default:
|
|
123
130
|
startEnteringValue(e.key, e.which)
|
|
@@ -2,6 +2,7 @@ import { writable, get, derived } from "svelte/store"
|
|
|
2
2
|
import { tick } from "svelte"
|
|
3
3
|
import {
|
|
4
4
|
DefaultRowHeight,
|
|
5
|
+
GutterWidth,
|
|
5
6
|
LargeRowHeight,
|
|
6
7
|
MediumRowHeight,
|
|
7
8
|
NewRowID,
|
|
@@ -43,6 +44,8 @@ export const deriveStores = context => {
|
|
|
43
44
|
enrichedRows,
|
|
44
45
|
rowLookupMap,
|
|
45
46
|
rowHeight,
|
|
47
|
+
stickyColumn,
|
|
48
|
+
width,
|
|
46
49
|
} = context
|
|
47
50
|
|
|
48
51
|
// Derive the row that contains the selected cell
|
|
@@ -70,6 +73,7 @@ export const deriveStores = context => {
|
|
|
70
73
|
hoveredRowId.set(null)
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
// Derive the amount of content lines to show in cells depending on row height
|
|
73
77
|
const contentLines = derived(rowHeight, $rowHeight => {
|
|
74
78
|
if ($rowHeight === LargeRowHeight) {
|
|
75
79
|
return 3
|
|
@@ -79,9 +83,15 @@ export const deriveStores = context => {
|
|
|
79
83
|
return 1
|
|
80
84
|
})
|
|
81
85
|
|
|
86
|
+
// Derive whether we should use the compact UI, depending on width
|
|
87
|
+
const compact = derived([stickyColumn, width], ([$stickyColumn, $width]) => {
|
|
88
|
+
return ($stickyColumn?.width || 0) + $width + GutterWidth < 1100
|
|
89
|
+
})
|
|
90
|
+
|
|
82
91
|
return {
|
|
83
92
|
focusedRow,
|
|
84
93
|
contentLines,
|
|
94
|
+
compact,
|
|
85
95
|
ui: {
|
|
86
96
|
actions: {
|
|
87
97
|
blur,
|