@warkypublic/svelix 0.1.21 → 0.1.22
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.
|
@@ -91,6 +91,8 @@
|
|
|
91
91
|
let backdropZ = $state(1090);
|
|
92
92
|
let dropdownZ = $state(1100);
|
|
93
93
|
let pointerInteractingWithDropdown = $state(false);
|
|
94
|
+
let insideDialog = $state(false);
|
|
95
|
+
const effectiveDisablePortal = $derived(disablePortal || insideDialog);
|
|
94
96
|
// Plain variable — NOT $state to avoid deep proxy on the complex virtualizer object.
|
|
95
97
|
let rawVirtualizer: SvelteVirtualizer<
|
|
96
98
|
HTMLDivElement,
|
|
@@ -356,6 +358,10 @@
|
|
|
356
358
|
onOptionSubmit(index);
|
|
357
359
|
}
|
|
358
360
|
|
|
361
|
+
function syncInsideDialogFlag() {
|
|
362
|
+
insideDialog = !!anchorEl?.closest('dialog, [role="dialog"]');
|
|
363
|
+
}
|
|
364
|
+
|
|
359
365
|
// Public API via bind:this
|
|
360
366
|
export function clear() {
|
|
361
367
|
onClear();
|
|
@@ -378,7 +384,7 @@
|
|
|
378
384
|
}
|
|
379
385
|
|
|
380
386
|
$effect(() => {
|
|
381
|
-
if (!$store.opened ||
|
|
387
|
+
if (!$store.opened || effectiveDisablePortal || disabled) {
|
|
382
388
|
return;
|
|
383
389
|
}
|
|
384
390
|
|
|
@@ -408,7 +414,7 @@
|
|
|
408
414
|
|
|
409
415
|
const overlay = registerOverlay({
|
|
410
416
|
kind: "popover",
|
|
411
|
-
mount:
|
|
417
|
+
mount: effectiveDisablePortal ? "inline" : "portal",
|
|
412
418
|
});
|
|
413
419
|
backdropZ = overlay.layer.backdrop;
|
|
414
420
|
dropdownZ = overlay.layer.content;
|
|
@@ -419,6 +425,32 @@
|
|
|
419
425
|
dropdownZ = 1100;
|
|
420
426
|
};
|
|
421
427
|
});
|
|
428
|
+
|
|
429
|
+
$effect(() => {
|
|
430
|
+
anchorEl;
|
|
431
|
+
storeOpened;
|
|
432
|
+
syncInsideDialogFlag();
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
$effect(() => {
|
|
436
|
+
if (!$store.opened || !effectiveDisablePortal || disabled || typeof window === "undefined") {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const onDocumentPointerDown = (event: PointerEvent) => {
|
|
441
|
+
const target = event.target as Node | null;
|
|
442
|
+
if (!target) return;
|
|
443
|
+
|
|
444
|
+
const insideAnchor = !!anchorEl?.contains(target);
|
|
445
|
+
const insideDropdown = !!dropdownEl?.contains(target);
|
|
446
|
+
if (!insideAnchor && !insideDropdown) {
|
|
447
|
+
store.setOpened(false);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
window.addEventListener("pointerdown", onDocumentPointerDown, true);
|
|
452
|
+
return () => window.removeEventListener("pointerdown", onDocumentPointerDown, true);
|
|
453
|
+
});
|
|
422
454
|
</script>
|
|
423
455
|
|
|
424
456
|
<div
|
|
@@ -458,28 +490,30 @@
|
|
|
458
490
|
}}
|
|
459
491
|
/>
|
|
460
492
|
|
|
461
|
-
<Portal disabled={
|
|
493
|
+
<Portal disabled={effectiveDisablePortal}>
|
|
462
494
|
{#if $store.opened}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
495
|
+
{#if !effectiveDisablePortal}
|
|
496
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
497
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
498
|
+
<div
|
|
499
|
+
class="fixed inset-0"
|
|
500
|
+
onpointerdown={onBackdropPointerDown}
|
|
501
|
+
style:z-index={backdropZ}
|
|
502
|
+
></div>
|
|
503
|
+
{/if}
|
|
470
504
|
|
|
471
505
|
<div
|
|
472
506
|
bind:this={dropdownEl}
|
|
473
|
-
class={`${
|
|
507
|
+
class={`${effectiveDisablePortal
|
|
474
508
|
? "absolute left-0 right-0 top-full mt-1"
|
|
475
509
|
: "fixed"} card bg-surface-50-950 shadow-lg border border-surface-300-700 overflow-hidden`}
|
|
476
510
|
role="listbox"
|
|
477
511
|
aria-label={label ?? "Options"}
|
|
478
512
|
onpointerdown={markDropdownPointerInteraction}
|
|
479
513
|
style:z-index={dropdownZ}
|
|
480
|
-
style:top={!
|
|
481
|
-
style:left={!
|
|
482
|
-
style:width={!
|
|
514
|
+
style:top={!effectiveDisablePortal ? `${popupTop}px` : undefined}
|
|
515
|
+
style:left={!effectiveDisablePortal ? `${popupLeft}px` : undefined}
|
|
516
|
+
style:width={!effectiveDisablePortal ? `${popupWidth}px` : undefined}
|
|
483
517
|
>
|
|
484
518
|
{#if $store.boxerData.length > 0}
|
|
485
519
|
<div
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warkypublic/svelix",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "Svelte 5 component library with Skeleton UI and Tailwind CSS",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"dev": "vite dev",
|
|
86
|
-
"build": "vite build",
|
|
86
|
+
"build": "vite build && pnpm run package",
|
|
87
87
|
"preview": "vite preview",
|
|
88
88
|
"package": "svelte-kit sync && svelte-package && mkdir -p dist/css && cp src/lib/css/tailwind-source.css dist/css/tailwind-source.css && publint",
|
|
89
89
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|