@budibase/frontend-core 2.27.2 → 2.27.4
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 +5 -5
- package/src/components/grid/cells/HeaderCell.svelte +16 -8
- package/src/components/grid/cells/OptionsCell.svelte +8 -3
- package/src/components/grid/cells/RelationshipCell.svelte +2 -2
- package/src/components/grid/layout/ButtonColumn.svelte +9 -20
- package/src/components/grid/layout/NewColumnButton.svelte +3 -1
- package/src/components/grid/layout/NewRow.svelte +1 -1
- package/src/components/grid/layout/StickyColumn.svelte +1 -1
- package/src/components/grid/lib/utils.js +0 -7
- package/src/components/grid/overlays/KeyboardManager.svelte +2 -1
- package/src/components/grid/stores/ui.js +2 -0
- package/src/constants.js +4 -0
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.4",
|
|
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.27.
|
|
10
|
-
"@budibase/shared-core": "2.27.
|
|
11
|
-
"@budibase/types": "2.27.
|
|
9
|
+
"@budibase/bbui": "2.27.4",
|
|
10
|
+
"@budibase/shared-core": "2.27.4",
|
|
11
|
+
"@budibase/types": "2.27.4",
|
|
12
12
|
"dayjs": "^1.10.8",
|
|
13
13
|
"lodash": "4.17.21",
|
|
14
14
|
"shortid": "2.2.15",
|
|
15
15
|
"socket.io-client": "^4.6.1"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "58c6101ae8cb7c3ae780e10aa5935ebdb7491268"
|
|
18
18
|
}
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
focusedCellId,
|
|
30
30
|
filter,
|
|
31
31
|
inlineFilters,
|
|
32
|
+
keyboardBlocked,
|
|
32
33
|
} = getContext("grid")
|
|
33
34
|
|
|
34
35
|
const searchableTypes = [
|
|
@@ -57,6 +58,8 @@
|
|
|
57
58
|
$: searching = searchValue != null
|
|
58
59
|
$: debouncedUpdateFilter(searchValue)
|
|
59
60
|
$: orderable = !column.primaryDisplay
|
|
61
|
+
$: editable = $config.canEditColumns && !column.schema.disabled
|
|
62
|
+
$: keyboardBlocked.set(open)
|
|
60
63
|
|
|
61
64
|
const close = () => {
|
|
62
65
|
open = false
|
|
@@ -231,6 +234,14 @@
|
|
|
231
234
|
}
|
|
232
235
|
const debouncedUpdateFilter = debounce(updateFilter, 250)
|
|
233
236
|
|
|
237
|
+
const handleDoubleClick = () => {
|
|
238
|
+
if (!editable || searching) {
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
open = true
|
|
242
|
+
editColumn()
|
|
243
|
+
}
|
|
244
|
+
|
|
234
245
|
onMount(() => subscribe("close-edit-column", close))
|
|
235
246
|
</script>
|
|
236
247
|
|
|
@@ -241,14 +252,15 @@
|
|
|
241
252
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
242
253
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
243
254
|
<div
|
|
255
|
+
bind:this={anchor}
|
|
244
256
|
class="header-cell"
|
|
257
|
+
style="flex: 0 0 {column.width}px;"
|
|
245
258
|
class:open
|
|
246
259
|
class:searchable
|
|
247
260
|
class:searching
|
|
248
|
-
style="flex: 0 0 {column.width}px;"
|
|
249
|
-
bind:this={anchor}
|
|
250
261
|
class:disabled={$isReordering || $isResizing}
|
|
251
262
|
class:sticky={idx === "sticky"}
|
|
263
|
+
on:dblclick={handleDoubleClick}
|
|
252
264
|
>
|
|
253
265
|
<GridCell
|
|
254
266
|
on:mousedown={onMouseDown}
|
|
@@ -311,7 +323,7 @@
|
|
|
311
323
|
{#if open}
|
|
312
324
|
<GridPopover
|
|
313
325
|
{anchor}
|
|
314
|
-
align="
|
|
326
|
+
align="left"
|
|
315
327
|
on:close={close}
|
|
316
328
|
maxHeight={null}
|
|
317
329
|
resizable
|
|
@@ -322,11 +334,7 @@
|
|
|
322
334
|
</div>
|
|
323
335
|
{:else}
|
|
324
336
|
<Menu>
|
|
325
|
-
<MenuItem
|
|
326
|
-
icon="Edit"
|
|
327
|
-
on:click={editColumn}
|
|
328
|
-
disabled={!$config.canEditColumns || column.schema.disabled}
|
|
329
|
-
>
|
|
337
|
+
<MenuItem icon="Edit" on:click={editColumn} disabled={!editable}>
|
|
330
338
|
Edit column
|
|
331
339
|
</MenuItem>
|
|
332
340
|
<MenuItem
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { Icon } from "@budibase/bbui"
|
|
3
|
-
import { getColor } from "../lib/utils"
|
|
4
3
|
import { onMount } from "svelte"
|
|
5
4
|
import GridPopover from "../overlays/GridPopover.svelte"
|
|
5
|
+
import { OptionColours } from "../../../constants"
|
|
6
6
|
|
|
7
7
|
export let value
|
|
8
8
|
export let schema
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
export let api
|
|
14
14
|
export let contentLines = 1
|
|
15
15
|
|
|
16
|
+
const InvalidColor = "hsla(0, 0%, 70%, 0.3)"
|
|
17
|
+
|
|
16
18
|
let isOpen = false
|
|
17
19
|
let focusedOptionIdx = null
|
|
18
20
|
let anchor
|
|
@@ -38,8 +40,11 @@
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
const getOptionColor = value => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
let idx = value ? options.indexOf(value) : null
|
|
44
|
+
if (idx == null || idx === -1) {
|
|
45
|
+
return InvalidColor
|
|
46
|
+
}
|
|
47
|
+
return OptionColours[idx % OptionColours.length]
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
const toggleOption = option => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getColor } from "../lib/utils"
|
|
3
2
|
import { onMount, getContext } from "svelte"
|
|
4
3
|
import { Icon, Input, ProgressCircle } from "@budibase/bbui"
|
|
5
4
|
import { debounce } from "../../../utils/utils"
|
|
6
5
|
import GridPopover from "../overlays/GridPopover.svelte"
|
|
6
|
+
import { OptionColours } from "../../../constants"
|
|
7
7
|
|
|
8
8
|
const { API, cache } = getContext("grid")
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
export let primaryDisplay
|
|
19
19
|
export let hideCounter = false
|
|
20
20
|
|
|
21
|
-
const color =
|
|
21
|
+
const color = OptionColours[0]
|
|
22
22
|
|
|
23
23
|
let isOpen = false
|
|
24
24
|
let searchResults
|
|
@@ -43,19 +43,6 @@
|
|
|
43
43
|
})
|
|
44
44
|
</script>
|
|
45
45
|
|
|
46
|
-
<!-- Hidden copy of buttons to measure -->
|
|
47
|
-
<div class="measure" bind:this={measureContainer}>
|
|
48
|
-
<GridCell width="auto">
|
|
49
|
-
<div class="buttons">
|
|
50
|
-
{#each buttons as button}
|
|
51
|
-
<Button size="S">
|
|
52
|
-
{button.text || "Button"}
|
|
53
|
-
</Button>
|
|
54
|
-
{/each}
|
|
55
|
-
</div>
|
|
56
|
-
</GridCell>
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
46
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
60
47
|
<div
|
|
61
48
|
class="button-column"
|
|
@@ -72,6 +59,7 @@
|
|
|
72
59
|
class="row"
|
|
73
60
|
on:mouseenter={$isDragging ? null : () => ($hoveredRowId = row._id)}
|
|
74
61
|
on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
|
|
62
|
+
bind:this={measureContainer}
|
|
75
63
|
>
|
|
76
64
|
<GridCell
|
|
77
65
|
width="auto"
|
|
@@ -91,6 +79,9 @@
|
|
|
91
79
|
overBackground={button.type === "overBackground"}
|
|
92
80
|
on:click={() => handleClick(button, row)}
|
|
93
81
|
>
|
|
82
|
+
{#if button.icon}
|
|
83
|
+
<i class="{button.icon} S" />
|
|
84
|
+
{/if}
|
|
94
85
|
{button.text || "Button"}
|
|
95
86
|
</Button>
|
|
96
87
|
{/each}
|
|
@@ -130,16 +121,14 @@
|
|
|
130
121
|
gap: var(--cell-padding);
|
|
131
122
|
height: inherit;
|
|
132
123
|
}
|
|
124
|
+
.buttons :global(.spectrum-Button-Label) {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
gap: 4px;
|
|
128
|
+
}
|
|
133
129
|
|
|
134
130
|
/* Add left cell border */
|
|
135
131
|
.button-column :global(.cell) {
|
|
136
132
|
border-left: var(--cell-border);
|
|
137
133
|
}
|
|
138
|
-
|
|
139
|
-
/* Hidden copy of buttons to measure width against */
|
|
140
|
-
.measure {
|
|
141
|
-
position: absolute;
|
|
142
|
-
opacity: 0;
|
|
143
|
-
pointer-events: none;
|
|
144
|
-
}
|
|
145
134
|
</style>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { Icon } from "@budibase/bbui"
|
|
4
4
|
import GridPopover from "../overlays/GridPopover.svelte"
|
|
5
5
|
|
|
6
|
-
const { visibleColumns, scroll, width, subscribe, ui } =
|
|
6
|
+
const { visibleColumns, scroll, width, subscribe, ui, keyboardBlocked } =
|
|
7
|
+
getContext("grid")
|
|
7
8
|
|
|
8
9
|
let anchor
|
|
9
10
|
let isOpen = false
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
)
|
|
15
16
|
$: end = columnsWidth - 1 - $scroll.left
|
|
16
17
|
$: left = Math.min($width - 40, end)
|
|
18
|
+
$: keyboardBlocked.set(isOpen)
|
|
17
19
|
|
|
18
20
|
const open = () => {
|
|
19
21
|
ui.actions.blur()
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
<GridScrollWrapper scrollHorizontally attachHandlers>
|
|
210
210
|
<div class="row">
|
|
211
211
|
{#each $visibleColumns as column}
|
|
212
|
-
{@const cellId =
|
|
212
|
+
{@const cellId = getCellID(NewRowID, column.name)}
|
|
213
213
|
<DataCell
|
|
214
214
|
{cellId}
|
|
215
215
|
{column}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
|
|
67
67
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
68
68
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
69
|
-
<div class="content"
|
|
69
|
+
<div class="content">
|
|
70
70
|
<GridScrollWrapper scrollVertically attachHandlers>
|
|
71
71
|
{#each $renderedRows as row, idx}
|
|
72
72
|
{@const rowSelected = !!$selectedRows[row._id]}
|
|
@@ -18,13 +18,6 @@ export const getCellID = (rowId, fieldName) => {
|
|
|
18
18
|
return `${rowId}${JOINING_CHARACTER}${fieldName}`
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export const getColor = (idx, opacity = 0.3) => {
|
|
22
|
-
if (idx == null || idx === -1) {
|
|
23
|
-
idx = 0
|
|
24
|
-
}
|
|
25
|
-
return `hsla(${((idx + 1) * 222) % 360}, 90%, 75%, ${opacity})`
|
|
26
|
-
}
|
|
27
|
-
|
|
28
21
|
export const getColumnIcon = column => {
|
|
29
22
|
if (column.schema.autocolumn) {
|
|
30
23
|
return "MagicWand"
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
config,
|
|
18
18
|
menu,
|
|
19
19
|
gridFocused,
|
|
20
|
+
keyboardBlocked,
|
|
20
21
|
} = getContext("grid")
|
|
21
22
|
|
|
22
23
|
const ignoredOriginSelectors = [
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
// Global key listener which intercepts all key events
|
|
30
31
|
const handleKeyDown = e => {
|
|
31
32
|
// Ignore completely if the grid is not focused
|
|
32
|
-
if (!$gridFocused) {
|
|
33
|
+
if (!$gridFocused || $keyboardBlocked) {
|
|
33
34
|
return
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -19,6 +19,7 @@ export const createStores = context => {
|
|
|
19
19
|
const previousFocusedRowId = writable(null)
|
|
20
20
|
const previousFocusedCellId = writable(null)
|
|
21
21
|
const gridFocused = writable(false)
|
|
22
|
+
const keyboardBlocked = writable(false)
|
|
22
23
|
const isDragging = writable(false)
|
|
23
24
|
const buttonColumnWidth = writable(0)
|
|
24
25
|
|
|
@@ -54,6 +55,7 @@ export const createStores = context => {
|
|
|
54
55
|
hoveredRowId,
|
|
55
56
|
rowHeight,
|
|
56
57
|
gridFocused,
|
|
58
|
+
keyboardBlocked,
|
|
57
59
|
isDragging,
|
|
58
60
|
buttonColumnWidth,
|
|
59
61
|
selectedRows: {
|
package/src/constants.js
CHANGED