@budibase/frontend-core 2.11.15-alpha.2 → 2.11.16

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 CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "2.11.15-alpha.2",
3
+ "version": "2.11.16",
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.11.15-alpha.2",
10
- "@budibase/shared-core": "2.11.15-alpha.2",
9
+ "@budibase/bbui": "2.11.16",
10
+ "@budibase/shared-core": "2.11.16",
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": "2dd5d4e24145308689bf0aa62052c8672593fe88"
16
+ "gitHead": "c0e8a437c5079010fe16810adde01723f97e6531"
17
17
  }
@@ -17,24 +17,13 @@
17
17
  const { config, dispatch, selectedRows } = getContext("grid")
18
18
  const svelteDispatch = createEventDispatcher()
19
19
 
20
- const select = e => {
21
- e.stopPropagation()
20
+ const select = () => {
22
21
  svelteDispatch("select")
23
22
  const id = row?._id
24
23
  if (id) {
25
24
  selectedRows.actions.toggleRow(id)
26
25
  }
27
26
  }
28
-
29
- const bulkDelete = e => {
30
- e.stopPropagation()
31
- dispatch("request-bulk-delete")
32
- }
33
-
34
- const expand = e => {
35
- e.stopPropagation()
36
- svelteDispatch("expand")
37
- }
38
27
  </script>
39
28
 
40
29
  <GridCell
@@ -67,7 +56,7 @@
67
56
  {/if}
68
57
  {/if}
69
58
  {#if rowSelected && $config.canDeleteRows}
70
- <div class="delete" on:click={bulkDelete}>
59
+ <div class="delete" on:click={() => dispatch("request-bulk-delete")}>
71
60
  <Icon
72
61
  name="Delete"
73
62
  size="S"
@@ -76,7 +65,12 @@
76
65
  </div>
77
66
  {:else}
78
67
  <div class="expand" class:visible={$config.canExpandRows && expandable}>
79
- <Icon size="S" name="Maximize" hoverable on:click={expand} />
68
+ <Icon
69
+ size="S"
70
+ name="Maximize"
71
+ hoverable
72
+ on:click={() => svelteDispatch("expand")}
73
+ />
80
74
  </div>
81
75
  {/if}
82
76
  </div>
@@ -35,7 +35,7 @@
35
35
  </script>
36
36
 
37
37
  <div bind:this={body} class="grid-body">
38
- <GridScrollWrapper scrollHorizontally scrollVertically attachHandlers>
38
+ <GridScrollWrapper scrollHorizontally scrollVertically wheelInteractive>
39
39
  {#each $renderedRows as row, idx}
40
40
  <GridRow
41
41
  {row}
@@ -17,7 +17,6 @@
17
17
  columnHorizontalInversionIndex,
18
18
  contentLines,
19
19
  isDragging,
20
- dispatch,
21
20
  } = getContext("grid")
22
21
 
23
22
  $: rowSelected = !!$selectedRows[row._id]
@@ -31,7 +30,6 @@
31
30
  on:focus
32
31
  on:mouseenter={$isDragging ? null : () => ($hoveredRowId = row._id)}
33
32
  on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
34
- on:click={() => dispatch("rowclick", row)}
35
33
  >
36
34
  {#each $renderedColumns as column, columnIdx (column.name)}
37
35
  {@const cellId = `${row._id}-${column.name}`}
@@ -17,11 +17,7 @@
17
17
 
18
18
  export let scrollVertically = false
19
19
  export let scrollHorizontally = false
20
- export let attachHandlers = false
21
-
22
- // Used for tracking touch events
23
- let initialTouchX
24
- let initialTouchY
20
+ export let wheelInteractive = false
25
21
 
26
22
  $: style = generateStyle($scroll, $rowHeight, $hiddenColumnsWidth)
27
23
 
@@ -31,47 +27,17 @@
31
27
  return `transform: translate3d(${offsetX}px, ${offsetY}px, 0);`
32
28
  }
33
29
 
34
- // Handles a mouse wheel event and updates scroll state
30
+ // Handles a wheel even and updates the scroll offsets
35
31
  const handleWheel = e => {
36
32
  e.preventDefault()
37
- updateScroll(e.deltaX, e.deltaY, e.clientY)
33
+ debouncedHandleWheel(e.deltaX, e.deltaY, e.clientY)
38
34
 
39
35
  // If a context menu was visible, hide it
40
36
  if ($menu.visible) {
41
37
  menu.actions.close()
42
38
  }
43
39
  }
44
-
45
- // Handles touch start events
46
- const handleTouchStart = e => {
47
- if (!e.touches?.[0]) return
48
- initialTouchX = e.touches[0].clientX
49
- initialTouchY = e.touches[0].clientY
50
- }
51
-
52
- // Handles touch move events and updates scroll state
53
- const handleTouchMove = e => {
54
- if (!e.touches?.[0]) return
55
- e.preventDefault()
56
-
57
- // Compute delta from previous event, and update scroll
58
- const deltaX = initialTouchX - e.touches[0].clientX
59
- const deltaY = initialTouchY - e.touches[0].clientY
60
- updateScroll(deltaX, deltaY)
61
-
62
- // Store position to reference in next event
63
- initialTouchX = e.touches[0].clientX
64
- initialTouchY = e.touches[0].clientY
65
-
66
- // If a context menu was visible, hide it
67
- if ($menu.visible) {
68
- menu.actions.close()
69
- }
70
- }
71
-
72
- // Updates the scroll offset by a certain delta, and ensure scrolling
73
- // stays within sensible bounds. Debounced for performance.
74
- const updateScroll = domDebounce((deltaX, deltaY, clientY) => {
40
+ const debouncedHandleWheel = domDebounce((deltaX, deltaY, clientY) => {
75
41
  const { top, left } = $scroll
76
42
 
77
43
  // Calculate new scroll top
@@ -89,19 +55,15 @@
89
55
  })
90
56
 
91
57
  // Hover row under cursor
92
- if (clientY != null) {
93
- const y = clientY - $bounds.top + (newScrollTop % $rowHeight)
94
- const hoveredRow = $renderedRows[Math.floor(y / $rowHeight)]
95
- hoveredRowId.set(hoveredRow?._id)
96
- }
58
+ const y = clientY - $bounds.top + (newScrollTop % $rowHeight)
59
+ const hoveredRow = $renderedRows[Math.floor(y / $rowHeight)]
60
+ hoveredRowId.set(hoveredRow?._id)
97
61
  })
98
62
  </script>
99
63
 
100
64
  <div
101
65
  class="outer"
102
- on:wheel={attachHandlers ? handleWheel : null}
103
- on:touchstart={attachHandlers ? handleTouchStart : null}
104
- on:touchmove={attachHandlers ? handleTouchMove : null}
66
+ on:wheel={wheelInteractive ? handleWheel : null}
105
67
  on:click|self={() => ($focusedCellId = null)}
106
68
  >
107
69
  <div {style} class="inner">
@@ -205,7 +205,7 @@
205
205
  {/if}
206
206
  </div>
207
207
  <div class="normal-columns" transition:fade|local={{ duration: 130 }}>
208
- <GridScrollWrapper scrollHorizontally attachHandlers>
208
+ <GridScrollWrapper scrollHorizontally wheelInteractive>
209
209
  <div class="row">
210
210
  {#each $renderedColumns as column, columnIdx}
211
211
  {@const cellId = `new-${column.name}`}
@@ -64,7 +64,7 @@
64
64
  </div>
65
65
 
66
66
  <div class="content" on:mouseleave={() => ($hoveredRowId = null)}>
67
- <GridScrollWrapper scrollVertically attachHandlers>
67
+ <GridScrollWrapper scrollVertically wheelInteractive>
68
68
  {#each $renderedRows as row, idx}
69
69
  {@const rowSelected = !!$selectedRows[row._id]}
70
70
  {@const rowHovered = $hoveredRowId === row._id}
@@ -74,7 +74,6 @@
74
74
  class="row"
75
75
  on:mouseenter={$isDragging ? null : () => ($hoveredRowId = row._id)}
76
76
  on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
77
- on:click={() => dispatch("rowclick", row)}
78
77
  >
79
78
  <GutterCell {row} {rowFocused} {rowHovered} {rowSelected} />
80
79
  {#if $stickyColumn}
@@ -53,27 +53,18 @@
53
53
  }
54
54
  }
55
55
 
56
- const getLocation = e => {
57
- return {
58
- y: e.touches?.[0]?.clientY ?? e.clientY,
59
- x: e.touches?.[0]?.clientX ?? e.clientX,
60
- }
61
- }
62
-
63
56
  // V scrollbar drag handlers
64
57
  const startVDragging = e => {
65
58
  e.preventDefault()
66
- initialMouse = getLocation(e).y
59
+ initialMouse = e.clientY
67
60
  initialScroll = $scrollTop
68
61
  document.addEventListener("mousemove", moveVDragging)
69
- document.addEventListener("touchmove", moveVDragging)
70
62
  document.addEventListener("mouseup", stopVDragging)
71
- document.addEventListener("touchend", stopVDragging)
72
63
  isDraggingV = true
73
64
  closeMenu()
74
65
  }
75
66
  const moveVDragging = domDebounce(e => {
76
- const delta = getLocation(e).y - initialMouse
67
+ const delta = e.clientY - initialMouse
77
68
  const weight = delta / availHeight
78
69
  const newScrollTop = initialScroll + weight * $maxScrollTop
79
70
  scroll.update(state => ({
@@ -83,26 +74,22 @@
83
74
  })
84
75
  const stopVDragging = () => {
85
76
  document.removeEventListener("mousemove", moveVDragging)
86
- document.removeEventListener("touchmove", moveVDragging)
87
77
  document.removeEventListener("mouseup", stopVDragging)
88
- document.removeEventListener("touchend", stopVDragging)
89
78
  isDraggingV = false
90
79
  }
91
80
 
92
81
  // H scrollbar drag handlers
93
82
  const startHDragging = e => {
94
83
  e.preventDefault()
95
- initialMouse = getLocation(e).x
84
+ initialMouse = e.clientX
96
85
  initialScroll = $scrollLeft
97
86
  document.addEventListener("mousemove", moveHDragging)
98
- document.addEventListener("touchmove", moveHDragging)
99
87
  document.addEventListener("mouseup", stopHDragging)
100
- document.addEventListener("touchend", stopHDragging)
101
88
  isDraggingH = true
102
89
  closeMenu()
103
90
  }
104
91
  const moveHDragging = domDebounce(e => {
105
- const delta = getLocation(e).x - initialMouse
92
+ const delta = e.clientX - initialMouse
106
93
  const weight = delta / availWidth
107
94
  const newScrollLeft = initialScroll + weight * $maxScrollLeft
108
95
  scroll.update(state => ({
@@ -112,9 +99,7 @@
112
99
  })
113
100
  const stopHDragging = () => {
114
101
  document.removeEventListener("mousemove", moveHDragging)
115
- document.removeEventListener("touchmove", moveHDragging)
116
102
  document.removeEventListener("mouseup", stopHDragging)
117
- document.removeEventListener("touchend", stopHDragging)
118
103
  isDraggingH = false
119
104
  }
120
105
  </script>
@@ -124,7 +109,6 @@
124
109
  class="v-scrollbar"
125
110
  style="--size:{ScrollBarSize}px; top:{barTop}px; height:{barHeight}px;"
126
111
  on:mousedown={startVDragging}
127
- on:touchstart={startVDragging}
128
112
  class:dragging={isDraggingV}
129
113
  />
130
114
  {/if}
@@ -133,7 +117,6 @@
133
117
  class="h-scrollbar"
134
118
  style="--size:{ScrollBarSize}px; left:{barLeft}px; width:{barWidth}px;"
135
119
  on:mousedown={startHDragging}
136
- on:touchstart={startHDragging}
137
120
  class:dragging={isDraggingH}
138
121
  />
139
122
  {/if}
@@ -1,5 +1,4 @@
1
1
  import { writable, get } from "svelte/store"
2
- import { Helpers } from "@budibase/bbui"
3
2
 
4
3
  export const createStores = () => {
5
4
  const copiedCell = writable(null)
@@ -13,16 +12,7 @@ export const createActions = context => {
13
12
  const { copiedCell, focusedCellAPI } = context
14
13
 
15
14
  const copy = () => {
16
- const value = get(focusedCellAPI)?.getValue()
17
- copiedCell.set(value)
18
-
19
- // Also copy a stringified version to the clipboard
20
- let stringified = ""
21
- if (value != null && value !== "") {
22
- // Only conditionally stringify to avoid redundant quotes around text
23
- stringified = typeof value === "object" ? JSON.stringify(value) : value
24
- }
25
- Helpers.copyToClipboard(stringified)
15
+ copiedCell.set(get(focusedCellAPI)?.getValue())
26
16
  }
27
17
 
28
18
  const paste = () => {