@tableslayer/ui 0.1.7 → 0.1.9

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;
@@ -29,6 +29,7 @@
29
29
  };
30
30
 
31
31
  export const addToast = helpers.addToast;
32
+ export const removeToast = helpers.removeToast;
32
33
  </script>
33
34
 
34
35
  <script lang="ts">
@@ -1,5 +1,6 @@
1
1
  import type { ToastDataProps } from './types';
2
2
  export declare const addToast: (props: import("@melt-ui/svelte").AddToastProps<ToastDataProps>) => import("@melt-ui/svelte").Toast<ToastDataProps>;
3
+ export declare const removeToast: (id: string) => void;
3
4
  declare const Toast: import("svelte").Component<Record<string, never>, {}, "">;
4
5
  type Toast = ReturnType<typeof Toast>;
5
6
  export default Toast;
@@ -1,3 +1,3 @@
1
- export { default as Toast, addToast } from './Toast.svelte';
1
+ export { default as Toast, addToast, removeToast } from './Toast.svelte';
2
2
  export * from './toastCookie';
3
3
  export * from './types';
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
2
  // @ts-nocheck https://github.com/sveltejs/svelte/issues/7304
3
- export { default as Toast, addToast } from './Toast.svelte';
3
+ export { default as Toast, addToast, removeToast } from './Toast.svelte';
4
4
  export * from './toastCookie';
5
5
  export * from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tableslayer/ui",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "repository": {
6
6
  "type": "git",