@valerius_petrini/corekit-ui 0.1.83 → 0.1.84

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.
@@ -0,0 +1,3 @@
1
+ export declare function portal(node: HTMLElement, target?: string): {
2
+ destroy(): void;
3
+ };
@@ -0,0 +1,9 @@
1
+ export function portal(node, target = 'body') {
2
+ const targetEl = document.querySelector(target);
3
+ targetEl.appendChild(node);
4
+ return {
5
+ destroy() {
6
+ node.remove();
7
+ }
8
+ };
9
+ }
@@ -19,6 +19,7 @@
19
19
  import { Input } from "..";
20
20
 
21
21
  import Pipette from "@lucide/svelte/icons/pipette";
22
+ import { portal } from "../../../actions/portal";
22
23
 
23
24
  let {
24
25
  children = undefined,
@@ -89,6 +90,7 @@
89
90
 
90
91
  const { x, y } = await computePosition(element, floatingEl, {
91
92
  placement: "bottom-start",
93
+ strategy: "absolute",
92
94
  middleware: [
93
95
  offset(8),
94
96
  flip(),
@@ -300,8 +302,9 @@
300
302
  {@const hsv = hexToHsv(value || "#000000")}
301
303
  <div
302
304
  bind:this={floatingEl}
305
+ use:portal
303
306
  transition:fly={{ y: -10, duration: 200 }}
304
- class="fixed z-999999 bg-sub-background rounded-md p-4 flex gap-2.5 flex-wrap"
307
+ class="absolute z-999999 bg-sub-background rounded-md p-4 flex gap-2.5 flex-wrap"
305
308
  style="top: {dropdownY}px; left: {dropdownX}px; min-width: {referenceWidth}px; max-width: calc(100vw - 16px);"
306
309
  >
307
310
  <div class="color-canvas relative rounded h-36 cursor-crosshair" style="background-color: hsl({hue}, 100%, 50%);" bind:this={canvasEl}>
@@ -11,6 +11,7 @@
11
11
  import BaseInput from "../helper/BaseInput.svelte";
12
12
  import Text from "../../typography/Text/index.svelte";
13
13
  import { fly } from "svelte/transition";
14
+ import { portal } from "../../../actions/portal";
14
15
 
15
16
  let {
16
17
  children = undefined,
@@ -90,6 +91,7 @@
90
91
 
91
92
  const { x, y } = await computePosition(element!, node, {
92
93
  placement: "bottom-start",
94
+ strategy: "absolute",
93
95
  middleware: [offset(8), flip(), shift({ padding: 8 })]
94
96
  });
95
97
 
@@ -223,7 +225,8 @@
223
225
  {#if isFocused}
224
226
  <div
225
227
  use:initFloating
226
- style="position: fixed; top: {dropdownY}px; left: {dropdownX}px; width: {referenceWidth}px;"
228
+ use:portal
229
+ style="position: absolute; top: {dropdownY}px; left: {dropdownX}px; width: {referenceWidth}px;"
227
230
  style:visibility={ready ? "visible" : "hidden"}
228
231
  transition:fly={{ y: -10, duration: 200 }}
229
232
  class="z-999999 overflow-hidden border border-white/10 bg-sub-background shadow-xl shadow-black/40 {getSizeStyleClass(radius, 'radius')}"
@@ -14,6 +14,7 @@
14
14
 
15
15
  import ChevronUp from "@lucide/svelte/icons/chevron-up";
16
16
  import ChevronDown from "@lucide/svelte/icons/chevron-down";
17
+ import { portal } from "../../../actions/portal.js";
17
18
 
18
19
  let {
19
20
  children = undefined,
@@ -46,6 +47,7 @@
46
47
  async function updatePosition() {
47
48
  const { x: fx, y: fy, placement } = await computePosition(element!, node, {
48
49
  placement: "bottom-start",
50
+ strategy: "absolute",
49
51
  middleware: [offset(4), flip(), shift({ padding: 12 })],
50
52
  });
51
53
  x = fx;
@@ -102,8 +104,9 @@
102
104
  {#if open}
103
105
  <div
104
106
  use:initDropdown
107
+ use:portal
105
108
  role="menu"
106
- style="position: fixed; top: {y}px; left: {x}px;"
109
+ style="position: absolute; top: {y}px; left: {x}px;"
107
110
  class="z-100 shadow-lg"
108
111
  style:visibility={ready ? "visible" : "hidden"}
109
112
  >
@@ -15,6 +15,7 @@
15
15
  autoUpdate
16
16
 
17
17
  } from "@floating-ui/dom";
18
+ import { portal } from "../../../actions/portal.js";
18
19
 
19
20
  let {
20
21
  text,
@@ -44,6 +45,7 @@
44
45
 
45
46
  const { x: fx, y: fy, placement, middlewareData } = await computePosition(trigger, tooltipEl, {
46
47
  placement: position,
48
+ strategy: "absolute",
47
49
  middleware: [
48
50
  offset(8),
49
51
  flip(),
@@ -156,8 +158,9 @@
156
158
  {#if visible}
157
159
  <div
158
160
  bind:this={tooltipEl}
161
+ use:portal
159
162
  role="tooltip"
160
- style="position: fixed; top: {y}px; left: {x}px;"
163
+ style="position: absolute; top: {y}px; left: {x}px;"
161
164
  class="z-999999 {interactive ? 'pointer-events-auto' : 'pointer-events-none'}"
162
165
  onmouseenter={onTooltipEnter}
163
166
  onmouseleave={onTooltipLeave}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerius_petrini/corekit-ui",
3
- "version": "0.1.83",
3
+ "version": "0.1.84",
4
4
  "description": "Component Library used across all my projects",
5
5
  "author": "Valerius Petrini Jr.",
6
6
  "license": "MIT",