@tableslayer/ui 0.1.23 → 0.1.25

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.
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
- import { computePosition, offset, flip, shift, platform } from '@floating-ui/dom';
2
+ import { computePosition, offset, flip, shift, autoUpdate } from '@floating-ui/dom';
3
3
  import { Button, type ConfirmActionButtonProps } from './';
4
- import { tick, onDestroy } from 'svelte';
4
+ import { onDestroy } from 'svelte';
5
5
 
6
6
  let {
7
7
  trigger,
@@ -19,6 +19,7 @@
19
19
  let portalContainer: HTMLDivElement | null = null;
20
20
  let isShowingConfirm = $state(false);
21
21
  let floatingStyles = $state('');
22
+ let cleanupAutoUpdate: (() => void) | null = null;
22
23
 
23
24
  // Handle portal mounting
24
25
  $effect(() => {
@@ -36,16 +37,31 @@
36
37
  }
37
38
  });
38
39
 
40
+ // Set up autoUpdate when popover is shown
41
+ $effect(() => {
42
+ if (isShowingConfirm && triggerElement && popoverElement) {
43
+ cleanupAutoUpdate = autoUpdate(triggerElement, popoverElement, updatePosition);
44
+ }
45
+
46
+ return () => {
47
+ if (cleanupAutoUpdate) {
48
+ cleanupAutoUpdate();
49
+ cleanupAutoUpdate = null;
50
+ }
51
+ };
52
+ });
53
+
39
54
  onDestroy(() => {
40
55
  if (portalContainer?.parentNode) {
41
56
  portalContainer.parentNode.removeChild(portalContainer);
42
57
  }
58
+ if (cleanupAutoUpdate) {
59
+ cleanupAutoUpdate();
60
+ }
43
61
  });
44
62
 
45
63
  const toggleShowConfirm = async () => {
46
64
  isShowingConfirm = true;
47
- await tick();
48
- updatePosition();
49
65
  };
50
66
 
51
67
  const triggerProps = {
@@ -61,8 +77,11 @@
61
77
 
62
78
  computePosition(triggerElement, popoverElement, {
63
79
  placement: positioning?.placement,
64
- middleware: [offset(({ rects }) => -rects.reference.height / 2 - rects.floating.height / 2), flip(), shift()],
65
- platform
80
+ middleware: [
81
+ offset(({ rects }) => -rects.reference.height / 2 - rects.floating.height / 2),
82
+ flip({ boundary: document.body }),
83
+ shift({ padding: 8, crossAxis: true, boundary: document.body })
84
+ ]
66
85
  })
67
86
  .then(({ x, y, strategy }) => {
68
87
  floatingStyles = `position: ${strategy}; left: ${x}px; top: ${y}px;`;
@@ -297,6 +297,7 @@
297
297
  gap: 0.5rem;
298
298
  border: solid 2px transparent;
299
299
  gap: 1rem;
300
+ white-space: nowrap;
300
301
  }
301
302
 
302
303
  .select__option:hover,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tableslayer/ui",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "repository": {
6
6
  "type": "git",