@budibase/frontend-core 2.11.45 → 2.12.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/package.json +4 -4
- package/src/components/grid/cells/DataCell.svelte +2 -0
- package/src/components/grid/cells/GridCell.svelte +5 -0
- package/src/components/grid/cells/HeaderCell.svelte +2 -2
- package/src/components/grid/layout/GridBody.svelte +3 -3
- package/src/components/grid/layout/GridRow.svelte +4 -2
- package/src/components/grid/layout/GridScrollWrapper.svelte +3 -4
- package/src/components/grid/layout/HeaderRow.svelte +2 -2
- package/src/components/grid/layout/NewColumnButton.svelte +4 -5
- package/src/components/grid/layout/NewRow.svelte +24 -24
- package/src/components/grid/overlays/ResizeOverlay.svelte +2 -2
- package/src/components/grid/stores/viewport.js +19 -39
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
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.
|
|
10
|
-
"@budibase/shared-core": "2.
|
|
9
|
+
"@budibase/bbui": "2.12.0",
|
|
10
|
+
"@budibase/shared-core": "2.12.0",
|
|
11
11
|
"dayjs": "^1.10.8",
|
|
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": "b1ed21810000332da296d8fe556a166851626ae2"
|
|
17
17
|
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
export let invertX = false
|
|
22
22
|
export let invertY = false
|
|
23
23
|
export let contentLines = 1
|
|
24
|
+
export let hidden = false
|
|
24
25
|
|
|
25
26
|
const emptyError = writable(null)
|
|
26
27
|
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
{focused}
|
|
79
80
|
{selectedUser}
|
|
80
81
|
{readonly}
|
|
82
|
+
{hidden}
|
|
81
83
|
error={$error}
|
|
82
84
|
on:click={() => focusedCellId.set(cellId)}
|
|
83
85
|
on:contextmenu={e => menu.actions.open(cellId, e)}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
export let defaultHeight = false
|
|
11
11
|
export let center = false
|
|
12
12
|
export let readonly = false
|
|
13
|
+
export let hidden = false
|
|
13
14
|
|
|
14
15
|
$: style = getStyle(width, selectedUser)
|
|
15
16
|
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
class:error
|
|
31
32
|
class:center
|
|
32
33
|
class:readonly
|
|
34
|
+
class:hidden
|
|
33
35
|
class:default-height={defaultHeight}
|
|
34
36
|
class:selected-other={selectedUser != null}
|
|
35
37
|
class:alt={rowIdx % 2 === 1}
|
|
@@ -81,6 +83,9 @@
|
|
|
81
83
|
.cell.center {
|
|
82
84
|
align-items: center;
|
|
83
85
|
}
|
|
86
|
+
.cell.hidden {
|
|
87
|
+
content-visibility: hidden;
|
|
88
|
+
}
|
|
84
89
|
|
|
85
90
|
/* Cell border */
|
|
86
91
|
.cell.focused:after,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
isResizing,
|
|
18
18
|
rand,
|
|
19
19
|
sort,
|
|
20
|
-
|
|
20
|
+
visibleColumns,
|
|
21
21
|
dispatch,
|
|
22
22
|
subscribe,
|
|
23
23
|
config,
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
|
|
51
51
|
$: sortedBy = column.name === $sort.column
|
|
52
52
|
$: canMoveLeft = orderable && idx > 0
|
|
53
|
-
$: canMoveRight = orderable && idx < $
|
|
53
|
+
$: canMoveRight = orderable && idx < $visibleColumns.length - 1
|
|
54
54
|
$: sortingLabels = getSortingLabels(column.schema?.type)
|
|
55
55
|
$: searchable = isColumnSearchable(column)
|
|
56
56
|
$: resetSearchValue(column.name)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
const {
|
|
8
8
|
bounds,
|
|
9
9
|
renderedRows,
|
|
10
|
-
|
|
10
|
+
visibleColumns,
|
|
11
11
|
rowVerticalInversionIndex,
|
|
12
12
|
hoveredRowId,
|
|
13
13
|
dispatch,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
let body
|
|
19
19
|
|
|
20
|
-
$:
|
|
20
|
+
$: columnsWidth = $visibleColumns.reduce(
|
|
21
21
|
(total, col) => (total += col.width),
|
|
22
22
|
0
|
|
23
23
|
)
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
<div
|
|
48
48
|
class="blank"
|
|
49
49
|
class:highlighted={$hoveredRowId === BlankRowID}
|
|
50
|
-
style="width:{
|
|
50
|
+
style="width:{columnsWidth}px"
|
|
51
51
|
on:mouseenter={$isDragging ? null : () => ($hoveredRowId = BlankRowID)}
|
|
52
52
|
on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
|
|
53
53
|
on:click={() => dispatch("add-row-inline")}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
focusedCellId,
|
|
11
11
|
reorder,
|
|
12
12
|
selectedRows,
|
|
13
|
-
|
|
13
|
+
visibleColumns,
|
|
14
14
|
hoveredRowId,
|
|
15
15
|
selectedCellMap,
|
|
16
16
|
focusedRow,
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
isDragging,
|
|
20
20
|
dispatch,
|
|
21
21
|
rows,
|
|
22
|
+
columnRenderMap,
|
|
22
23
|
} = getContext("grid")
|
|
23
24
|
|
|
24
25
|
$: rowSelected = !!$selectedRows[row._id]
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
|
|
35
36
|
on:click={() => dispatch("rowclick", rows.actions.cleanRow(row))}
|
|
36
37
|
>
|
|
37
|
-
{#each $
|
|
38
|
+
{#each $visibleColumns as column, columnIdx}
|
|
38
39
|
{@const cellId = `${row._id}-${column.name}`}
|
|
39
40
|
<DataCell
|
|
40
41
|
{cellId}
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
selectedUser={$selectedCellMap[cellId]}
|
|
52
53
|
width={column.width}
|
|
53
54
|
contentLines={$contentLines}
|
|
55
|
+
hidden={!$columnRenderMap[column.name]}
|
|
54
56
|
/>
|
|
55
57
|
{/each}
|
|
56
58
|
</div>
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
maxScrollLeft,
|
|
12
12
|
bounds,
|
|
13
13
|
hoveredRowId,
|
|
14
|
-
hiddenColumnsWidth,
|
|
15
14
|
menu,
|
|
16
15
|
} = getContext("grid")
|
|
17
16
|
|
|
@@ -23,10 +22,10 @@
|
|
|
23
22
|
let initialTouchX
|
|
24
23
|
let initialTouchY
|
|
25
24
|
|
|
26
|
-
$: style = generateStyle($scroll, $rowHeight
|
|
25
|
+
$: style = generateStyle($scroll, $rowHeight)
|
|
27
26
|
|
|
28
|
-
const generateStyle = (scroll, rowHeight
|
|
29
|
-
const offsetX = scrollHorizontally ? -1 * scroll.left
|
|
27
|
+
const generateStyle = (scroll, rowHeight) => {
|
|
28
|
+
const offsetX = scrollHorizontally ? -1 * scroll.left : 0
|
|
30
29
|
const offsetY = scrollVertically ? -1 * (scroll.top % rowHeight) : 0
|
|
31
30
|
return `transform: translate3d(${offsetX}px, ${offsetY}px, 0);`
|
|
32
31
|
}
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import HeaderCell from "../cells/HeaderCell.svelte"
|
|
6
6
|
import { TempTooltip, TooltipType } from "@budibase/bbui"
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const { visibleColumns, config, hasNonAutoColumn, datasource, loading } =
|
|
9
9
|
getContext("grid")
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<div class="header">
|
|
13
13
|
<GridScrollWrapper scrollHorizontally>
|
|
14
14
|
<div class="row">
|
|
15
|
-
{#each $
|
|
15
|
+
{#each $visibleColumns as column, idx}
|
|
16
16
|
<HeaderCell {column} {idx}>
|
|
17
17
|
<slot name="edit-column" />
|
|
18
18
|
</HeaderCell>
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
import { getContext, onMount } from "svelte"
|
|
3
3
|
import { Icon, Popover, clickOutside } from "@budibase/bbui"
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
getContext("grid")
|
|
5
|
+
const { visibleColumns, scroll, width, subscribe } = getContext("grid")
|
|
7
6
|
|
|
8
7
|
let anchor
|
|
9
8
|
let open = false
|
|
10
9
|
|
|
11
|
-
$: columnsWidth = $
|
|
10
|
+
$: columnsWidth = $visibleColumns.reduce(
|
|
12
11
|
(total, col) => (total += col.width),
|
|
13
12
|
0
|
|
14
13
|
)
|
|
15
|
-
$: end =
|
|
14
|
+
$: end = columnsWidth - 1 - $scroll.left
|
|
16
15
|
$: left = Math.min($width - 40, end)
|
|
17
16
|
|
|
18
17
|
const close = () => {
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
<Popover
|
|
35
34
|
bind:open
|
|
36
35
|
{anchor}
|
|
37
|
-
align={$
|
|
36
|
+
align={$visibleColumns.length ? "right" : "left"}
|
|
38
37
|
offset={0}
|
|
39
38
|
popoverTarget={document.getElementById(`add-column-button`)}
|
|
40
39
|
customZindex={100}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
datasource,
|
|
21
21
|
subscribe,
|
|
22
22
|
renderedRows,
|
|
23
|
-
|
|
23
|
+
visibleColumns,
|
|
24
24
|
rowHeight,
|
|
25
25
|
hasNextPage,
|
|
26
26
|
maxScrollTop,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
refreshing,
|
|
32
32
|
config,
|
|
33
33
|
filter,
|
|
34
|
+
columnRenderMap,
|
|
34
35
|
} = getContext("grid")
|
|
35
36
|
|
|
36
37
|
let visible = false
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
let newRow
|
|
39
40
|
let offset = 0
|
|
40
41
|
|
|
41
|
-
$: firstColumn = $stickyColumn || $
|
|
42
|
+
$: firstColumn = $stickyColumn || $visibleColumns[0]
|
|
42
43
|
$: width = GutterWidth + ($stickyColumn?.width || 0)
|
|
43
44
|
$: $datasource, (visible = false)
|
|
44
45
|
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
|
|
@@ -211,29 +212,28 @@
|
|
|
211
212
|
<div class="normal-columns" transition:fade|local={{ duration: 130 }}>
|
|
212
213
|
<GridScrollWrapper scrollHorizontally attachHandlers>
|
|
213
214
|
<div class="row">
|
|
214
|
-
{#each $
|
|
215
|
+
{#each $visibleColumns as column, columnIdx}
|
|
215
216
|
{@const cellId = `new-${column.name}`}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
{/key}
|
|
217
|
+
<DataCell
|
|
218
|
+
{cellId}
|
|
219
|
+
{column}
|
|
220
|
+
{updateValue}
|
|
221
|
+
rowFocused
|
|
222
|
+
row={newRow}
|
|
223
|
+
focused={$focusedCellId === cellId}
|
|
224
|
+
width={column.width}
|
|
225
|
+
topRow={offset === 0}
|
|
226
|
+
invertX={columnIdx >= $columnHorizontalInversionIndex}
|
|
227
|
+
{invertY}
|
|
228
|
+
hidden={!$columnRenderMap[column.name]}
|
|
229
|
+
>
|
|
230
|
+
{#if column?.schema?.autocolumn}
|
|
231
|
+
<div class="readonly-overlay">Can't edit auto column</div>
|
|
232
|
+
{/if}
|
|
233
|
+
{#if isAdding}
|
|
234
|
+
<div in:fade={{ duration: 130 }} class="loading-overlay" />
|
|
235
|
+
{/if}
|
|
236
|
+
</DataCell>
|
|
237
237
|
{/each}
|
|
238
238
|
</div>
|
|
239
239
|
</GridScrollWrapper>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getContext } from "svelte"
|
|
3
3
|
import { GutterWidth } from "../lib/constants"
|
|
4
4
|
|
|
5
|
-
const { resize,
|
|
5
|
+
const { resize, visibleColumns, stickyColumn, isReordering, scrollLeft } =
|
|
6
6
|
getContext("grid")
|
|
7
7
|
|
|
8
8
|
$: offset = GutterWidth + ($stickyColumn?.width || 0)
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<div class="resize-indicator" />
|
|
27
27
|
</div>
|
|
28
28
|
{/if}
|
|
29
|
-
{#each $
|
|
29
|
+
{#each $visibleColumns as column}
|
|
30
30
|
<div
|
|
31
31
|
class="resize-slider"
|
|
32
32
|
class:visible={activeColumn === column.name}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { derived
|
|
1
|
+
import { derived } from "svelte/store"
|
|
2
2
|
import {
|
|
3
3
|
MaxCellRenderHeight,
|
|
4
4
|
MaxCellRenderWidthOverflow,
|
|
@@ -50,12 +50,11 @@ export const deriveStores = context => {
|
|
|
50
50
|
const interval = MinColumnWidth
|
|
51
51
|
return Math.round($scrollLeft / interval) * interval
|
|
52
52
|
})
|
|
53
|
-
const
|
|
53
|
+
const columnRenderMap = derived(
|
|
54
54
|
[visibleColumns, scrollLeftRounded, width],
|
|
55
|
-
([$visibleColumns, $scrollLeft, $width]
|
|
55
|
+
([$visibleColumns, $scrollLeft, $width]) => {
|
|
56
56
|
if (!$visibleColumns.length) {
|
|
57
|
-
|
|
58
|
-
return
|
|
57
|
+
return {}
|
|
59
58
|
}
|
|
60
59
|
let startColIdx = 0
|
|
61
60
|
let rightEdge = $visibleColumns[0].width
|
|
@@ -75,34 +74,16 @@ export const deriveStores = context => {
|
|
|
75
74
|
leftEdge += $visibleColumns[endColIdx].width
|
|
76
75
|
endColIdx++
|
|
77
76
|
}
|
|
78
|
-
// Render an additional column on either side to account for
|
|
79
|
-
// debounce column updates based on scroll position
|
|
80
|
-
const next = $visibleColumns.slice(
|
|
81
|
-
Math.max(0, startColIdx - 1),
|
|
82
|
-
endColIdx + 1
|
|
83
|
-
)
|
|
84
|
-
const current = get(renderedColumns)
|
|
85
|
-
if (JSON.stringify(next) !== JSON.stringify(current)) {
|
|
86
|
-
set(next)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
77
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
col =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
width += $visibleColumns[i].width
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return width
|
|
104
|
-
},
|
|
105
|
-
0
|
|
78
|
+
// Only update the store if different
|
|
79
|
+
let next = {}
|
|
80
|
+
$visibleColumns
|
|
81
|
+
.slice(Math.max(0, startColIdx), endColIdx)
|
|
82
|
+
.forEach(col => {
|
|
83
|
+
next[col.name] = true
|
|
84
|
+
})
|
|
85
|
+
return next
|
|
86
|
+
}
|
|
106
87
|
)
|
|
107
88
|
|
|
108
89
|
// Determine the row index at which we should start vertically inverting cell
|
|
@@ -130,12 +111,12 @@ export const deriveStores = context => {
|
|
|
130
111
|
// Determine the column index at which we should start horizontally inverting
|
|
131
112
|
// cell dropdowns
|
|
132
113
|
const columnHorizontalInversionIndex = derived(
|
|
133
|
-
[
|
|
134
|
-
([$
|
|
114
|
+
[visibleColumns, scrollLeft, width],
|
|
115
|
+
([$visibleColumns, $scrollLeft, $width]) => {
|
|
135
116
|
const cutoff = $width + $scrollLeft - ScrollBarSize * 3
|
|
136
|
-
let inversionIdx = $
|
|
137
|
-
for (let i = $
|
|
138
|
-
const rightEdge = $
|
|
117
|
+
let inversionIdx = $visibleColumns.length
|
|
118
|
+
for (let i = $visibleColumns.length - 1; i >= 0; i--, inversionIdx--) {
|
|
119
|
+
const rightEdge = $visibleColumns[i].left + $visibleColumns[i].width
|
|
139
120
|
if (rightEdge + MaxCellRenderWidthOverflow <= cutoff) {
|
|
140
121
|
break
|
|
141
122
|
}
|
|
@@ -148,8 +129,7 @@ export const deriveStores = context => {
|
|
|
148
129
|
scrolledRowCount,
|
|
149
130
|
visualRowCapacity,
|
|
150
131
|
renderedRows,
|
|
151
|
-
|
|
152
|
-
hiddenColumnsWidth,
|
|
132
|
+
columnRenderMap,
|
|
153
133
|
rowVerticalInversionIndex,
|
|
154
134
|
columnHorizontalInversionIndex,
|
|
155
135
|
}
|