@budibase/frontend-core 2.7.34-alpha.8 → 2.7.35
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/api/analytics.js +2 -2
- package/src/api/datasources.js +1 -15
- package/src/api/index.js +2 -16
- package/src/api/rows.js +1 -3
- package/src/components/grid/cells/AttachmentCell.svelte +1 -3
- package/src/components/grid/cells/GridCell.svelte +1 -1
- package/src/components/grid/cells/GutterCell.svelte +14 -9
- package/src/components/grid/cells/HeaderCell.svelte +5 -7
- package/src/components/grid/cells/LongFormCell.svelte +1 -1
- package/src/components/grid/cells/OptionsCell.svelte +5 -4
- package/src/components/grid/cells/RelationshipCell.svelte +11 -22
- package/src/components/grid/controls/AddColumnButton.svelte +1 -1
- package/src/components/grid/controls/BulkDeleteHandler.svelte +8 -2
- package/src/components/grid/controls/ColumnWidthButton.svelte +92 -0
- package/src/components/grid/controls/HideColumnsButton.svelte +4 -9
- package/src/components/grid/controls/RowHeightButton.svelte +71 -0
- package/src/components/grid/controls/SortButton.svelte +4 -3
- package/src/components/grid/layout/Grid.svelte +59 -66
- package/src/components/grid/layout/GridBody.svelte +2 -3
- package/src/components/grid/layout/GridRow.svelte +2 -3
- package/src/components/grid/layout/GridScrollWrapper.svelte +0 -6
- package/src/components/grid/layout/HeaderRow.svelte +3 -3
- package/src/components/grid/layout/NewRow.svelte +5 -37
- package/src/components/grid/layout/StickyColumn.svelte +8 -10
- package/src/components/grid/lib/constants.js +3 -4
- package/src/components/grid/lib/websocket.js +2 -3
- package/src/components/grid/overlays/KeyboardManager.svelte +0 -6
- package/src/components/grid/overlays/MenuOverlay.svelte +1 -3
- package/src/components/grid/overlays/ReorderOverlay.svelte +1 -1
- package/src/components/grid/overlays/ResizeOverlay.svelte +1 -1
- package/src/components/grid/overlays/ScrollOverlay.svelte +2 -25
- package/src/components/grid/stores/columns.js +6 -37
- package/src/components/grid/stores/index.js +0 -6
- package/src/components/grid/stores/menu.js +9 -15
- package/src/components/grid/stores/rows.js +16 -18
- package/src/components/grid/stores/scroll.js +7 -5
- package/src/components/grid/stores/ui.js +4 -19
- package/src/components/grid/stores/viewport.js +6 -17
- package/src/fetch/DataFetch.js +2 -4
- package/src/utils/index.js +0 -1
- package/src/components/grid/controls/SizeButton.svelte +0 -135
- package/src/components/grid/stores/config.js +0 -27
- package/src/components/grid/stores/filter.js +0 -19
- package/src/components/grid/stores/sort.js +0 -27
- package/src/utils/memo.js +0 -43
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { setContext, onMount } from "svelte"
|
|
3
|
+
import { writable } from "svelte/store"
|
|
3
4
|
import { fade } from "svelte/transition"
|
|
4
5
|
import { clickOutside, ProgressCircle } from "@budibase/bbui"
|
|
5
6
|
import { createEventManagers } from "../lib/events"
|
|
@@ -16,8 +17,11 @@
|
|
|
16
17
|
import UserAvatars from "./UserAvatars.svelte"
|
|
17
18
|
import KeyboardManager from "../overlays/KeyboardManager.svelte"
|
|
18
19
|
import SortButton from "../controls/SortButton.svelte"
|
|
20
|
+
import AddColumnButton from "../controls/AddColumnButton.svelte"
|
|
19
21
|
import HideColumnsButton from "../controls/HideColumnsButton.svelte"
|
|
20
|
-
import
|
|
22
|
+
import AddRowButton from "../controls/AddRowButton.svelte"
|
|
23
|
+
import RowHeightButton from "../controls/RowHeightButton.svelte"
|
|
24
|
+
import ColumnWidthButton from "../controls/ColumnWidthButton.svelte"
|
|
21
25
|
import NewRow from "./NewRow.svelte"
|
|
22
26
|
import { createGridWebsocket } from "../lib/websocket"
|
|
23
27
|
import {
|
|
@@ -29,37 +33,48 @@
|
|
|
29
33
|
|
|
30
34
|
export let API = null
|
|
31
35
|
export let tableId = null
|
|
36
|
+
export let tableType = null
|
|
32
37
|
export let schemaOverrides = null
|
|
33
|
-
export let columnWhitelist = null
|
|
34
38
|
export let allowAddRows = true
|
|
39
|
+
export let allowAddColumns = true
|
|
40
|
+
export let allowEditColumns = true
|
|
35
41
|
export let allowExpandRows = true
|
|
36
42
|
export let allowEditRows = true
|
|
37
43
|
export let allowDeleteRows = true
|
|
38
|
-
export let allowSchemaChanges = true
|
|
39
44
|
export let stripeRows = false
|
|
40
45
|
export let collaboration = true
|
|
41
46
|
export let showAvatars = true
|
|
42
|
-
export let showControls = true
|
|
43
|
-
export let initialFilter = null
|
|
44
|
-
export let initialSortColumn = null
|
|
45
|
-
export let initialSortOrder = null
|
|
46
|
-
export let initialRowHeight = null
|
|
47
47
|
|
|
48
48
|
// Unique identifier for DOM nodes inside this instance
|
|
49
49
|
const rand = Math.random()
|
|
50
50
|
|
|
51
|
+
// State stores
|
|
52
|
+
const tableIdStore = writable(tableId)
|
|
53
|
+
const schemaOverridesStore = writable(schemaOverrides)
|
|
54
|
+
const config = writable({
|
|
55
|
+
allowAddRows,
|
|
56
|
+
allowAddColumns,
|
|
57
|
+
allowEditColumns,
|
|
58
|
+
allowExpandRows,
|
|
59
|
+
allowEditRows,
|
|
60
|
+
allowDeleteRows,
|
|
61
|
+
stripeRows,
|
|
62
|
+
})
|
|
63
|
+
|
|
51
64
|
// Build up context
|
|
52
65
|
let context = {
|
|
53
66
|
API: API || createAPIClient(),
|
|
54
67
|
rand,
|
|
55
|
-
|
|
68
|
+
config,
|
|
69
|
+
tableId: tableIdStore,
|
|
70
|
+
tableType,
|
|
71
|
+
schemaOverrides: schemaOverridesStore,
|
|
56
72
|
}
|
|
57
73
|
context = { ...context, ...createEventManagers() }
|
|
58
74
|
context = attachStores(context)
|
|
59
75
|
|
|
60
76
|
// Reference some stores for local use
|
|
61
77
|
const {
|
|
62
|
-
config,
|
|
63
78
|
isResizing,
|
|
64
79
|
isReordering,
|
|
65
80
|
ui,
|
|
@@ -67,27 +82,19 @@
|
|
|
67
82
|
loading,
|
|
68
83
|
rowHeight,
|
|
69
84
|
contentLines,
|
|
70
|
-
gridFocused,
|
|
71
85
|
} = context
|
|
72
86
|
|
|
73
|
-
// Keep
|
|
87
|
+
// Keep stores up to date
|
|
88
|
+
$: tableIdStore.set(tableId)
|
|
89
|
+
$: schemaOverridesStore.set(schemaOverrides)
|
|
74
90
|
$: config.set({
|
|
75
|
-
tableId,
|
|
76
|
-
schemaOverrides,
|
|
77
|
-
columnWhitelist,
|
|
78
91
|
allowAddRows,
|
|
92
|
+
allowAddColumns,
|
|
93
|
+
allowEditColumns,
|
|
79
94
|
allowExpandRows,
|
|
80
95
|
allowEditRows,
|
|
81
96
|
allowDeleteRows,
|
|
82
|
-
allowSchemaChanges,
|
|
83
97
|
stripeRows,
|
|
84
|
-
collaboration,
|
|
85
|
-
showAvatars,
|
|
86
|
-
showControls,
|
|
87
|
-
initialFilter,
|
|
88
|
-
initialSortColumn,
|
|
89
|
-
initialSortOrder,
|
|
90
|
-
initialRowHeight,
|
|
91
98
|
})
|
|
92
99
|
|
|
93
100
|
// Set context for children to consume
|
|
@@ -109,27 +116,25 @@
|
|
|
109
116
|
id="grid-{rand}"
|
|
110
117
|
class:is-resizing={$isResizing}
|
|
111
118
|
class:is-reordering={$isReordering}
|
|
112
|
-
class:stripe={stripeRows}
|
|
113
|
-
on:mouseenter={() => gridFocused.set(true)}
|
|
114
|
-
on:mouseleave={() => gridFocused.set(false)}
|
|
119
|
+
class:stripe={$config.stripeRows}
|
|
115
120
|
style="--row-height:{$rowHeight}px; --default-row-height:{DefaultRowHeight}px; --gutter-width:{GutterWidth}px; --max-cell-render-height:{MaxCellRenderHeight}px; --max-cell-render-width-overflow:{MaxCellRenderWidthOverflow}px; --content-lines:{$contentLines};"
|
|
116
121
|
>
|
|
117
|
-
|
|
118
|
-
<div class="controls">
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<div class="controls-right">
|
|
127
|
-
{#if showAvatars}
|
|
128
|
-
<UserAvatars />
|
|
129
|
-
{/if}
|
|
130
|
-
</div>
|
|
122
|
+
<div class="controls">
|
|
123
|
+
<div class="controls-left">
|
|
124
|
+
<AddRowButton />
|
|
125
|
+
<AddColumnButton />
|
|
126
|
+
<slot name="controls" />
|
|
127
|
+
<SortButton />
|
|
128
|
+
<HideColumnsButton />
|
|
129
|
+
<ColumnWidthButton />
|
|
130
|
+
<RowHeightButton />
|
|
131
131
|
</div>
|
|
132
|
-
|
|
132
|
+
<div class="controls-right">
|
|
133
|
+
{#if showAvatars}
|
|
134
|
+
<UserAvatars />
|
|
135
|
+
{/if}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
133
138
|
{#if $loaded}
|
|
134
139
|
<div class="grid-data-outer" use:clickOutside={ui.actions.blur}>
|
|
135
140
|
<div class="grid-data-inner">
|
|
@@ -162,20 +167,7 @@
|
|
|
162
167
|
</div>
|
|
163
168
|
|
|
164
169
|
<style>
|
|
165
|
-
/* Core grid */
|
|
166
170
|
.grid {
|
|
167
|
-
/* Variables */
|
|
168
|
-
--accent-color: var(--primaryColor, var(--spectrum-global-color-blue-400));
|
|
169
|
-
--grid-background: var(--spectrum-global-color-gray-50);
|
|
170
|
-
--grid-background-alt: var(--spectrum-global-color-gray-100);
|
|
171
|
-
--cell-background: var(--grid-background);
|
|
172
|
-
--cell-background-hover: var(--grid-background-alt);
|
|
173
|
-
--cell-background-alt: var(--cell-background);
|
|
174
|
-
--cell-padding: 8px;
|
|
175
|
-
--cell-spacing: 4px;
|
|
176
|
-
--cell-border: 1px solid var(--spectrum-global-color-gray-200);
|
|
177
|
-
--cell-font-size: 14px;
|
|
178
|
-
--controls-height: 50px;
|
|
179
171
|
flex: 1 1 auto;
|
|
180
172
|
display: flex;
|
|
181
173
|
flex-direction: column;
|
|
@@ -183,7 +175,17 @@
|
|
|
183
175
|
align-items: stretch;
|
|
184
176
|
position: relative;
|
|
185
177
|
overflow: hidden;
|
|
186
|
-
background: var(--
|
|
178
|
+
background: var(--cell-background);
|
|
179
|
+
|
|
180
|
+
/* Variables */
|
|
181
|
+
--cell-background: var(--spectrum-global-color-gray-50);
|
|
182
|
+
--cell-background-hover: var(--spectrum-global-color-gray-100);
|
|
183
|
+
--cell-background-alt: var(--cell-background);
|
|
184
|
+
--cell-padding: 8px;
|
|
185
|
+
--cell-spacing: 4px;
|
|
186
|
+
--cell-border: 1px solid var(--spectrum-global-color-gray-200);
|
|
187
|
+
--cell-font-size: 14px;
|
|
188
|
+
--controls-height: 50px;
|
|
187
189
|
}
|
|
188
190
|
.grid,
|
|
189
191
|
.grid :global(*) {
|
|
@@ -199,7 +201,6 @@
|
|
|
199
201
|
--cell-background-alt: var(--spectrum-global-color-gray-75);
|
|
200
202
|
}
|
|
201
203
|
|
|
202
|
-
/* Data layers */
|
|
203
204
|
.grid-data-outer,
|
|
204
205
|
.grid-data-inner {
|
|
205
206
|
flex: 1 1 auto;
|
|
@@ -233,7 +234,7 @@
|
|
|
233
234
|
border-bottom: 2px solid var(--spectrum-global-color-gray-200);
|
|
234
235
|
padding: var(--cell-padding);
|
|
235
236
|
gap: var(--cell-spacing);
|
|
236
|
-
background: var(--
|
|
237
|
+
background: var(--background);
|
|
237
238
|
z-index: 2;
|
|
238
239
|
}
|
|
239
240
|
.controls-left,
|
|
@@ -269,15 +270,7 @@
|
|
|
269
270
|
left: 0;
|
|
270
271
|
width: 100%;
|
|
271
272
|
height: 100%;
|
|
272
|
-
background: var(--
|
|
273
|
+
background: var(--background);
|
|
273
274
|
opacity: 0.6;
|
|
274
275
|
}
|
|
275
|
-
|
|
276
|
-
/* Disable checkbox animation anywhere in the grid data */
|
|
277
|
-
.grid-data-outer :global(.spectrum-Checkbox-box:before),
|
|
278
|
-
.grid-data-outer :global(.spectrum-Checkbox-box:after),
|
|
279
|
-
.grid-data-outer :global(.spectrum-Checkbox-checkmark),
|
|
280
|
-
.grid-data-outer :global(.spectrum-Checkbox-partialCheckmark) {
|
|
281
|
-
transition: none;
|
|
282
|
-
}
|
|
283
276
|
</style>
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
config,
|
|
13
13
|
hoveredRowId,
|
|
14
14
|
dispatch,
|
|
15
|
-
isDragging,
|
|
16
15
|
} = getContext("grid")
|
|
17
16
|
|
|
18
17
|
let body
|
|
@@ -48,8 +47,8 @@
|
|
|
48
47
|
class="blank"
|
|
49
48
|
class:highlighted={$hoveredRowId === BlankRowID}
|
|
50
49
|
style="width:{renderColumnsWidth}px"
|
|
51
|
-
on:mouseenter={
|
|
52
|
-
on:mouseleave={
|
|
50
|
+
on:mouseenter={() => ($hoveredRowId = BlankRowID)}
|
|
51
|
+
on:mouseleave={() => ($hoveredRowId = null)}
|
|
53
52
|
on:click={() => dispatch("add-row-inline")}
|
|
54
53
|
/>
|
|
55
54
|
{/if}
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
focusedRow,
|
|
17
17
|
columnHorizontalInversionIndex,
|
|
18
18
|
contentLines,
|
|
19
|
-
isDragging,
|
|
20
19
|
} = getContext("grid")
|
|
21
20
|
|
|
22
21
|
$: rowSelected = !!$selectedRows[row._id]
|
|
@@ -28,8 +27,8 @@
|
|
|
28
27
|
<div
|
|
29
28
|
class="row"
|
|
30
29
|
on:focus
|
|
31
|
-
on:mouseenter={
|
|
32
|
-
on:mouseleave={
|
|
30
|
+
on:mouseenter={() => ($hoveredRowId = row._id)}
|
|
31
|
+
on:mouseleave={() => ($hoveredRowId = null)}
|
|
33
32
|
>
|
|
34
33
|
{#each $renderedColumns as column, columnIdx (column.name)}
|
|
35
34
|
{@const cellId = `${row._id}-${column.name}`}
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
bounds,
|
|
13
13
|
hoveredRowId,
|
|
14
14
|
hiddenColumnsWidth,
|
|
15
|
-
menu,
|
|
16
15
|
} = getContext("grid")
|
|
17
16
|
|
|
18
17
|
export let scrollVertically = false
|
|
@@ -31,11 +30,6 @@
|
|
|
31
30
|
const handleWheel = e => {
|
|
32
31
|
e.preventDefault()
|
|
33
32
|
debouncedHandleWheel(e.deltaX, e.deltaY, e.clientY)
|
|
34
|
-
|
|
35
|
-
// If a context menu was visible, hide it
|
|
36
|
-
if ($menu.visible) {
|
|
37
|
-
menu.actions.close()
|
|
38
|
-
}
|
|
39
33
|
}
|
|
40
34
|
const debouncedHandleWheel = domDebounce((deltaX, deltaY, clientY) => {
|
|
41
35
|
const { top, left } = $scroll
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
{/each}
|
|
30
30
|
</div>
|
|
31
31
|
</GridScrollWrapper>
|
|
32
|
-
{#if $config.
|
|
32
|
+
{#if $config.allowAddColumns}
|
|
33
33
|
<div
|
|
34
34
|
class="add"
|
|
35
35
|
style="left:{left}px"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
|
|
43
43
|
<style>
|
|
44
44
|
.header {
|
|
45
|
-
background: var(--
|
|
45
|
+
background: var(--background);
|
|
46
46
|
border-bottom: var(--cell-border);
|
|
47
47
|
position: relative;
|
|
48
48
|
height: var(--default-row-height);
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
border-left: var(--cell-border);
|
|
61
61
|
border-right: var(--cell-border);
|
|
62
62
|
border-bottom: var(--cell-border);
|
|
63
|
-
background: var(--
|
|
63
|
+
background: var(--spectrum-global-color-gray-100);
|
|
64
64
|
z-index: 1;
|
|
65
65
|
}
|
|
66
66
|
.add:hover {
|
|
@@ -26,8 +26,6 @@
|
|
|
26
26
|
maxScrollTop,
|
|
27
27
|
rowVerticalInversionIndex,
|
|
28
28
|
columnHorizontalInversionIndex,
|
|
29
|
-
selectedRows,
|
|
30
|
-
config,
|
|
31
29
|
} = getContext("grid")
|
|
32
30
|
|
|
33
31
|
let visible = false
|
|
@@ -39,7 +37,6 @@
|
|
|
39
37
|
$: width = GutterWidth + ($stickyColumn?.width || 0)
|
|
40
38
|
$: $tableId, (visible = false)
|
|
41
39
|
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
|
|
42
|
-
$: selectedRowCount = Object.values($selectedRows).length
|
|
43
40
|
|
|
44
41
|
const shouldInvertY = (offset, inversionIndex, rows) => {
|
|
45
42
|
if (offset === 0) {
|
|
@@ -78,7 +75,7 @@
|
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
const startAdding = async () => {
|
|
81
|
-
if (visible
|
|
78
|
+
if (visible) {
|
|
82
79
|
return
|
|
83
80
|
}
|
|
84
81
|
|
|
@@ -132,6 +129,9 @@
|
|
|
132
129
|
e.preventDefault()
|
|
133
130
|
clear()
|
|
134
131
|
}
|
|
132
|
+
} else if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
133
|
+
e.preventDefault()
|
|
134
|
+
addRow()
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -141,18 +141,6 @@
|
|
|
141
141
|
})
|
|
142
142
|
</script>
|
|
143
143
|
|
|
144
|
-
<!-- New row FAB -->
|
|
145
|
-
{#if !visible && !selectedRowCount && $config.allowAddRows && firstColumn}
|
|
146
|
-
<div
|
|
147
|
-
class="new-row-fab"
|
|
148
|
-
on:click={() => dispatch("add-row-inline")}
|
|
149
|
-
transition:fade|local={{ duration: 130 }}
|
|
150
|
-
class:offset={!$stickyColumn}
|
|
151
|
-
>
|
|
152
|
-
<Icon name="Add" size="S" />
|
|
153
|
-
</div>
|
|
154
|
-
{/if}
|
|
155
|
-
|
|
156
144
|
<!-- Only show new row functionality if we have any columns -->
|
|
157
145
|
{#if visible}
|
|
158
146
|
<div
|
|
@@ -163,7 +151,7 @@
|
|
|
163
151
|
<div class="underlay sticky" transition:fade|local={{ duration: 130 }} />
|
|
164
152
|
<div class="underlay" transition:fade|local={{ duration: 130 }} />
|
|
165
153
|
<div class="sticky-column" transition:fade|local={{ duration: 130 }}>
|
|
166
|
-
<GutterCell
|
|
154
|
+
<GutterCell on:expand={addViaModal} rowHovered>
|
|
167
155
|
<Icon name="Add" color="var(--spectrum-global-color-gray-500)" />
|
|
168
156
|
{#if isAdding}
|
|
169
157
|
<div in:fade={{ duration: 130 }} class="loading-overlay" />
|
|
@@ -239,26 +227,6 @@
|
|
|
239
227
|
{/if}
|
|
240
228
|
|
|
241
229
|
<style>
|
|
242
|
-
/* New row FAB */
|
|
243
|
-
.new-row-fab {
|
|
244
|
-
position: absolute;
|
|
245
|
-
top: var(--default-row-height);
|
|
246
|
-
left: calc(var(--gutter-width) / 2);
|
|
247
|
-
transform: translateX(6px) translateY(-50%);
|
|
248
|
-
background: var(--cell-background);
|
|
249
|
-
padding: 4px;
|
|
250
|
-
border-radius: 50%;
|
|
251
|
-
border: var(--cell-border);
|
|
252
|
-
z-index: 10;
|
|
253
|
-
}
|
|
254
|
-
.new-row-fab:hover {
|
|
255
|
-
background: var(--cell-background-hover);
|
|
256
|
-
cursor: pointer;
|
|
257
|
-
}
|
|
258
|
-
.new-row-fab.offset {
|
|
259
|
-
margin-left: -6px;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
230
|
.container {
|
|
263
231
|
position: absolute;
|
|
264
232
|
top: var(--default-row-height);
|
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
scrollLeft,
|
|
24
24
|
dispatch,
|
|
25
25
|
contentLines,
|
|
26
|
-
isDragging,
|
|
27
26
|
} = getContext("grid")
|
|
28
27
|
|
|
29
28
|
$: rowCount = $rows.length
|
|
30
|
-
$: selectedRowCount = Object.values($selectedRows).length
|
|
29
|
+
$: selectedRowCount = Object.values($selectedRows).filter(x => !!x).length
|
|
31
30
|
$: width = GutterWidth + ($stickyColumn?.width || 0)
|
|
32
31
|
|
|
33
32
|
const selectAll = () => {
|
|
@@ -51,6 +50,7 @@
|
|
|
51
50
|
>
|
|
52
51
|
<div class="header row">
|
|
53
52
|
<GutterCell
|
|
53
|
+
disableExpand
|
|
54
54
|
disableNumber
|
|
55
55
|
on:select={selectAll}
|
|
56
56
|
defaultHeight
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
{@const cellId = `${row._id}-${$stickyColumn?.name}`}
|
|
72
72
|
<div
|
|
73
73
|
class="row"
|
|
74
|
-
on:mouseenter={
|
|
75
|
-
on:mouseleave={
|
|
74
|
+
on:mouseenter={() => ($hoveredRowId = row._id)}
|
|
75
|
+
on:mouseleave={() => ($hoveredRowId = null)}
|
|
76
76
|
>
|
|
77
77
|
<GutterCell {row} {rowFocused} {rowHovered} {rowSelected} />
|
|
78
78
|
{#if $stickyColumn}
|
|
@@ -96,13 +96,11 @@
|
|
|
96
96
|
{#if $config.allowAddRows && ($renderedColumns.length || $stickyColumn)}
|
|
97
97
|
<div
|
|
98
98
|
class="row new"
|
|
99
|
-
on:mouseenter={$
|
|
100
|
-
|
|
101
|
-
: () => ($hoveredRowId = BlankRowID)}
|
|
102
|
-
on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
|
|
99
|
+
on:mouseenter={() => ($hoveredRowId = BlankRowID)}
|
|
100
|
+
on:mouseleave={() => ($hoveredRowId = null)}
|
|
103
101
|
on:click={() => dispatch("add-row-inline")}
|
|
104
102
|
>
|
|
105
|
-
<GutterCell rowHovered={$hoveredRowId === BlankRowID}>
|
|
103
|
+
<GutterCell disableExpand rowHovered={$hoveredRowId === BlankRowID}>
|
|
106
104
|
<Icon name="Add" color="var(--spectrum-global-color-gray-500)" />
|
|
107
105
|
</GutterCell>
|
|
108
106
|
{#if $stickyColumn}
|
|
@@ -161,7 +159,7 @@
|
|
|
161
159
|
z-index: 1;
|
|
162
160
|
}
|
|
163
161
|
.header :global(.cell) {
|
|
164
|
-
background: var(--
|
|
162
|
+
background: var(--spectrum-global-color-gray-100);
|
|
165
163
|
}
|
|
166
164
|
.row {
|
|
167
165
|
display: flex;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export const Padding =
|
|
2
|
-
export const MaxCellRenderHeight =
|
|
1
|
+
export const Padding = 256
|
|
2
|
+
export const MaxCellRenderHeight = 252
|
|
3
|
+
export const MaxCellRenderWidthOverflow = 200
|
|
3
4
|
export const ScrollBarSize = 8
|
|
4
5
|
export const GutterWidth = 72
|
|
5
6
|
export const DefaultColumnWidth = 200
|
|
@@ -11,5 +12,3 @@ export const DefaultRowHeight = SmallRowHeight
|
|
|
11
12
|
export const NewRowID = "new"
|
|
12
13
|
export const BlankRowID = "blank"
|
|
13
14
|
export const RowPageSize = 100
|
|
14
|
-
export const FocusedCellMinOffset = 48
|
|
15
|
-
export const MaxCellRenderWidthOverflow = Padding - 3 * ScrollBarSize
|
|
@@ -3,7 +3,7 @@ import { createWebsocket } from "../../../utils"
|
|
|
3
3
|
import { SocketEvent, GridSocketEvent } from "@budibase/shared-core"
|
|
4
4
|
|
|
5
5
|
export const createGridWebsocket = context => {
|
|
6
|
-
const { rows, tableId, users, focusedCellId, table
|
|
6
|
+
const { rows, tableId, users, focusedCellId, table } = context
|
|
7
7
|
const socket = createWebsocket("/socket/grid")
|
|
8
8
|
|
|
9
9
|
const connectToTable = tableId => {
|
|
@@ -11,10 +11,9 @@ export const createGridWebsocket = context => {
|
|
|
11
11
|
return
|
|
12
12
|
}
|
|
13
13
|
// Identify which table we are editing
|
|
14
|
-
const appId = API.getAppID()
|
|
15
14
|
socket.emit(
|
|
16
15
|
GridSocketEvent.SelectTable,
|
|
17
|
-
{ tableId
|
|
16
|
+
{ tableId },
|
|
18
17
|
({ users: gridUsers }) => {
|
|
19
18
|
users.set(gridUsers)
|
|
20
19
|
}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
selectedRows,
|
|
16
16
|
config,
|
|
17
17
|
menu,
|
|
18
|
-
gridFocused,
|
|
19
18
|
} = getContext("grid")
|
|
20
19
|
|
|
21
20
|
const ignoredOriginSelectors = [
|
|
@@ -25,11 +24,6 @@
|
|
|
25
24
|
|
|
26
25
|
// Global key listener which intercepts all key events
|
|
27
26
|
const handleKeyDown = e => {
|
|
28
|
-
// Ignore completely if the grid is not focused
|
|
29
|
-
if (!$gridFocused) {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
27
|
// Avoid processing events sourced from certain origins
|
|
34
28
|
if (e.target?.closest) {
|
|
35
29
|
for (let selector of ignoredOriginSelectors) {
|
|
@@ -72,9 +72,7 @@
|
|
|
72
72
|
</MenuItem>
|
|
73
73
|
<MenuItem
|
|
74
74
|
icon="Maximize"
|
|
75
|
-
disabled={isNewRow ||
|
|
76
|
-
!$config.allowEditRows ||
|
|
77
|
-
!$config.allowExpandRows}
|
|
75
|
+
disabled={isNewRow || !$config.allowEditRows}
|
|
78
76
|
on:click={() => dispatch("edit-row", $focusedRow)}
|
|
79
77
|
on:click={menu.actions.close}
|
|
80
78
|
>
|
|
@@ -15,18 +15,11 @@
|
|
|
15
15
|
scrollLeft,
|
|
16
16
|
scrollTop,
|
|
17
17
|
height,
|
|
18
|
-
isDragging,
|
|
19
|
-
menu,
|
|
20
18
|
} = getContext("grid")
|
|
21
19
|
|
|
22
20
|
// State for dragging bars
|
|
23
21
|
let initialMouse
|
|
24
22
|
let initialScroll
|
|
25
|
-
let isDraggingV = false
|
|
26
|
-
let isDraggingH = false
|
|
27
|
-
|
|
28
|
-
// Update state to reflect if we are dragging
|
|
29
|
-
$: isDragging.set(isDraggingV || isDraggingH)
|
|
30
23
|
|
|
31
24
|
// Calculate V scrollbar size and offset
|
|
32
25
|
// Terminology is the same for both axes:
|
|
@@ -46,13 +39,6 @@
|
|
|
46
39
|
$: availWidth = renderWidth - barWidth
|
|
47
40
|
$: barLeft = ScrollBarSize + availWidth * ($scrollLeft / $maxScrollLeft)
|
|
48
41
|
|
|
49
|
-
// Helper to close the context menu if it's open
|
|
50
|
-
const closeMenu = () => {
|
|
51
|
-
if ($menu.visible) {
|
|
52
|
-
menu.actions.close()
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
42
|
// V scrollbar drag handlers
|
|
57
43
|
const startVDragging = e => {
|
|
58
44
|
e.preventDefault()
|
|
@@ -60,8 +46,6 @@
|
|
|
60
46
|
initialScroll = $scrollTop
|
|
61
47
|
document.addEventListener("mousemove", moveVDragging)
|
|
62
48
|
document.addEventListener("mouseup", stopVDragging)
|
|
63
|
-
isDraggingV = true
|
|
64
|
-
closeMenu()
|
|
65
49
|
}
|
|
66
50
|
const moveVDragging = domDebounce(e => {
|
|
67
51
|
const delta = e.clientY - initialMouse
|
|
@@ -75,7 +59,6 @@
|
|
|
75
59
|
const stopVDragging = () => {
|
|
76
60
|
document.removeEventListener("mousemove", moveVDragging)
|
|
77
61
|
document.removeEventListener("mouseup", stopVDragging)
|
|
78
|
-
isDraggingV = false
|
|
79
62
|
}
|
|
80
63
|
|
|
81
64
|
// H scrollbar drag handlers
|
|
@@ -85,8 +68,6 @@
|
|
|
85
68
|
initialScroll = $scrollLeft
|
|
86
69
|
document.addEventListener("mousemove", moveHDragging)
|
|
87
70
|
document.addEventListener("mouseup", stopHDragging)
|
|
88
|
-
isDraggingH = true
|
|
89
|
-
closeMenu()
|
|
90
71
|
}
|
|
91
72
|
const moveHDragging = domDebounce(e => {
|
|
92
73
|
const delta = e.clientX - initialMouse
|
|
@@ -100,7 +81,6 @@
|
|
|
100
81
|
const stopHDragging = () => {
|
|
101
82
|
document.removeEventListener("mousemove", moveHDragging)
|
|
102
83
|
document.removeEventListener("mouseup", stopHDragging)
|
|
103
|
-
isDraggingH = false
|
|
104
84
|
}
|
|
105
85
|
</script>
|
|
106
86
|
|
|
@@ -109,7 +89,6 @@
|
|
|
109
89
|
class="v-scrollbar"
|
|
110
90
|
style="--size:{ScrollBarSize}px; top:{barTop}px; height:{barHeight}px;"
|
|
111
91
|
on:mousedown={startVDragging}
|
|
112
|
-
class:dragging={isDraggingV}
|
|
113
92
|
/>
|
|
114
93
|
{/if}
|
|
115
94
|
{#if $showHScrollbar}
|
|
@@ -117,7 +96,6 @@
|
|
|
117
96
|
class="h-scrollbar"
|
|
118
97
|
style="--size:{ScrollBarSize}px; left:{barLeft}px; width:{barWidth}px;"
|
|
119
98
|
on:mousedown={startHDragging}
|
|
120
|
-
class:dragging={isDraggingH}
|
|
121
99
|
/>
|
|
122
100
|
{/if}
|
|
123
101
|
|
|
@@ -125,12 +103,11 @@
|
|
|
125
103
|
div {
|
|
126
104
|
position: absolute;
|
|
127
105
|
background: var(--spectrum-global-color-gray-500);
|
|
128
|
-
opacity: 0.
|
|
106
|
+
opacity: 0.7;
|
|
129
107
|
border-radius: 4px;
|
|
130
108
|
transition: opacity 130ms ease-out;
|
|
131
109
|
}
|
|
132
|
-
div:hover
|
|
133
|
-
div.dragging {
|
|
110
|
+
div:hover {
|
|
134
111
|
opacity: 1;
|
|
135
112
|
}
|
|
136
113
|
.v-scrollbar {
|