@tableslayer/ui 0.1.6 → 0.1.8

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
2
  import { computePosition, offset, flip, shift, platform } from '@floating-ui/dom';
3
3
  import { Button, type ConfirmActionButtonProps } from './';
4
- import { tick } from 'svelte';
4
+ import { tick, onDestroy } from 'svelte';
5
5
 
6
6
  let {
7
7
  trigger,
@@ -10,14 +10,38 @@
10
10
  action,
11
11
  isLoading,
12
12
  positioning = { placement: 'bottom' },
13
+ portal = null,
13
14
  ...restProps
14
15
  }: ConfirmActionButtonProps = $props();
15
16
 
16
17
  let triggerElement: HTMLElement | null = null;
17
18
  let popoverElement = $state<HTMLElement | null>(null);
19
+ let portalContainer: HTMLDivElement | null = null;
18
20
  let isShowingConfirm = $state(false);
19
21
  let floatingStyles = $state('');
20
22
 
23
+ // Handle portal mounting
24
+ $effect(() => {
25
+ if (isShowingConfirm && portal && popoverElement) {
26
+ const targetEl = typeof portal === 'string' ? document.querySelector(portal) : null;
27
+ if (targetEl && popoverElement.parentNode !== targetEl) {
28
+ // Create a container for the portal if needed
29
+ if (!portalContainer) {
30
+ portalContainer = document.createElement('div');
31
+ portalContainer.style.display = 'contents';
32
+ }
33
+ portalContainer.appendChild(popoverElement);
34
+ targetEl.appendChild(portalContainer);
35
+ }
36
+ }
37
+ });
38
+
39
+ onDestroy(() => {
40
+ if (portalContainer?.parentNode) {
41
+ portalContainer.parentNode.removeChild(portalContainer);
42
+ }
43
+ });
44
+
21
45
  const toggleShowConfirm = async () => {
22
46
  isShowingConfirm = true;
23
47
  await tick();
@@ -42,6 +42,11 @@ export type ConfirmActionButtonProps = {
42
42
  actionButtonText?: string;
43
43
  isLoading?: boolean;
44
44
  positioning?: FloatingConfig;
45
+ /**
46
+ * Render the popover in a portal to avoid overflow clipping.
47
+ * Set to 'body' or a CSS selector to enable.
48
+ */
49
+ portal?: string | null;
45
50
  };
46
51
  export type RadioOption = {
47
52
  label: string | Snippet;
@@ -8,6 +8,7 @@
8
8
 
9
9
  <style>
10
10
  .hr {
11
+ min-height: 1px;
11
12
  height: 1px;
12
13
  width: 100%;
13
14
  background: var(--contrastMedium);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tableslayer/ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "repository": {
6
6
  "type": "git",