@marianmeres/stuic 1.96.0 → 1.98.0

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.
@@ -34,6 +34,7 @@ export interface TooltipOptions {
34
34
  touch?: Readable<number>;
35
35
  trigger?: Readable<boolean>;
36
36
  notifier?: Writable<boolean>;
37
+ getAppendChildTarget?: () => HTMLElement;
37
38
  }
38
39
  export declare const _TRANSITION_OPACITY_DUR = 150;
39
40
  export declare function tooltip(node: HTMLElement, initialOptions?: string | Partial<TooltipOptions>): {
@@ -57,11 +57,11 @@ const TRIGGERS = {
57
57
  // default TW value
58
58
  export const _TRANSITION_OPACITY_DUR = 150;
59
59
  const _ensureDiv = (div, opts, log) => {
60
- log('_ensureDiv');
60
+ log('_ensureDiv', div);
61
61
  if (!div) {
62
62
  log('creating tooltip div...');
63
63
  div = document.createElement('div');
64
- document.body.appendChild(div);
64
+ (opts?.getAppendChildTarget?.() || document.body).appendChild(div);
65
65
  }
66
66
  else {
67
67
  log('div exists... going to apply classes');
@@ -87,7 +87,7 @@ const _ensureArrow = (arrow, opts, log) => {
87
87
  if (!arrow) {
88
88
  log('creating tooltip arrow...');
89
89
  arrow = document.createElement('div');
90
- document.body.appendChild(arrow);
90
+ (opts?.getAppendChildTarget?.() || document.body).appendChild(arrow);
91
91
  }
92
92
  else {
93
93
  log('arrow exists... going to apply classes');
@@ -45,7 +45,7 @@ $:
45
45
  on:keydown={(e) => e.code === 'Escape' && dispatch('escape')}
46
46
  in:fade={{ duration: fadeInDuration }}
47
47
  out:fade={{ duration: fadeOutDuration }}
48
- use:focusTrap={{ ...focusTrapOptions, enabled: useFocusTrap }}
48
+ use:focusTrap={{ enabled: useFocusTrap, ...(focusTrapOptions || {}) }}
49
49
  role="presentation"
50
50
  tabindex="-1"
51
51
  >
@@ -25,6 +25,7 @@ export let describedby = "";
25
25
  export let transitionDuration = 250;
26
26
  export let transitionEnabled = !$prefersReducedMotionStore;
27
27
  export let animOffset = "66vw";
28
+ export let backdropFocusTrapOptions = {};
28
29
  $:
29
30
  fadeInDuration = transitionEnabled ? Math.min(transitionDuration * 0.66, 200) : 0;
30
31
  const _presetsClsBackdrop = {
@@ -60,6 +61,7 @@ $:
60
61
  {fadeInDuration}
61
62
  fadeOutDuration={transitionEnabled ? transitionDuration : 0}
62
63
  on:element
64
+ focusTrapOptions={backdropFocusTrapOptions}
63
65
  >
64
66
  <!--
65
67
  svelte-ignore
@@ -1,4 +1,5 @@
1
1
  import { SvelteComponent } from "svelte";
2
+ import type { FocusTrapOptions } from '../../actions/focus-trap.js';
2
3
  export type DrawerStore = ReturnType<typeof createDrawerStore>;
3
4
  export declare const createDrawerStore: (open?: boolean) => import("@marianmeres/switch-store").SwitchStore<any>;
4
5
  declare const __propDef: {
@@ -12,6 +13,7 @@ declare const __propDef: {
12
13
  transitionDuration?: number | undefined;
13
14
  transitionEnabled?: boolean | undefined;
14
15
  animOffset?: string | number | undefined;
16
+ backdropFocusTrapOptions?: Partial<FocusTrapOptions> | undefined;
15
17
  };
16
18
  events: {
17
19
  escape: CustomEvent<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.96.0",
3
+ "version": "1.98.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",