@invopop/popui 0.0.13 → 0.0.14

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.
@@ -98,6 +98,13 @@ function selectRange(to) {
98
98
  metaKeyPressed = event.metaKey
99
99
  shiftKeyPressed = event.shiftKey
100
100
 
101
+ if (event.key === 'Enter') {
102
+ if (lastSelectedIndex >= 0) {
103
+ dispatch('rowClick', lastSelected)
104
+ }
105
+ return
106
+ }
107
+
101
108
  if (event.key === 'Shift') {
102
109
  selectWithArrowPosition = lastSelectedIndex
103
110
  return
@@ -20,8 +20,8 @@ declare const __propDef: {
20
20
  orderBy: CustomEvent<any>;
21
21
  action: CustomEvent<any>;
22
22
  copied: CustomEvent<any>;
23
- rowNewTabClick: CustomEvent<any>;
24
23
  rowClick: CustomEvent<any>;
24
+ rowNewTabClick: CustomEvent<any>;
25
25
  rowRightClick: CustomEvent<any>;
26
26
  tableEndReached: CustomEvent<any>;
27
27
  } & {
@@ -4,6 +4,7 @@ import BaseTableCell from "./BaseTableCell.svelte";
4
4
  import InputCheckbox from "./InputCheckbox.svelte";
5
5
  const dispatch = createEventDispatcher();
6
6
  let actionsDropdown;
7
+ let checkboxButton;
7
8
  export let row;
8
9
  export let getActions = void 0;
9
10
  export let fields = [];
@@ -21,6 +22,30 @@ $:
21
22
  return false;
22
23
  return field === row[selectedTrackedBy];
23
24
  });
25
+ $:
26
+ if (checked) {
27
+ scrollIntoView();
28
+ }
29
+ function scrollIntoView() {
30
+ const offset = 40;
31
+ const elementRect = checkboxButton.getBoundingClientRect();
32
+ const elementTop = elementRect.top + offset;
33
+ const elementBottom = elementRect.bottom + offset;
34
+ const viewportHeight = window.innerHeight;
35
+ const isAboveView = elementRect.top - offset < 0;
36
+ const isBelowView = elementRect.bottom + offset > viewportHeight;
37
+ if (isAboveView) {
38
+ window.scrollTo({
39
+ top: elementTop - offset,
40
+ behavior: "smooth"
41
+ });
42
+ } else if (isBelowView) {
43
+ window.scrollTo({
44
+ top: elementBottom - viewportHeight + offset,
45
+ behavior: "smooth"
46
+ });
47
+ }
48
+ }
24
49
  </script>
25
50
 
26
51
  <tr
@@ -37,6 +62,7 @@ $:
37
62
  {#if selectable}
38
63
  <td>
39
64
  <button
65
+ bind:this={checkboxButton}
40
66
  class="pl-5 pr-1.5 h-[40px] flex items-center outline-none group cursor-default"
41
67
  on:click|stopPropagation={() => {
42
68
  dispatch('checked', !checked)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.0.13",
4
+ "version": "0.0.14",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run package",