Skip to content

Commit aeb1be8

Browse files
committed
things are not good
1 parent 4c93759 commit aeb1be8

File tree

13 files changed

+38
-26
lines changed

13 files changed

+38
-26
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "monorepo",
33
"private": true,
44
"scripts": {
5+
"dev": "pnpm -F \"./packages/**\" svelte-kit sync && pnpm -r --parallel --reporter append-only --color dev",
56
"format": "biome check . --write",
67
"format:check": "biome check .",
78
"build": "pnpm --recursive build",

packages/floating-ui-svelte/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
"build": "svelte-package --input ./src",
66
"build:watch": "pnpm build --watch",
77
"test": "vitest run",
8+
"dev": "pnpm build:watch",
89
"test:watch": "pnpm test --watch",
910
"sync": "svelte-kit sync && pnpm build"
1011
},
11-
"files": [
12-
"dist"
13-
],
12+
"files": ["dist"],
1413
"sideEffects": false,
1514
"svelte": "./dist/index.js",
1615
"types": "./dist/index.d.ts",

packages/floating-ui-svelte/src/components/floating-tree/floating-arrow.svelte renamed to packages/floating-ui-svelte/src/components/floating-arrow.svelte

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" module>
22
import type { SVGAttributes } from "svelte/elements";
3-
import type { FloatingContext } from "../../hooks/use-floating.svelte.js";
3+
import type { FloatingContext } from "../hooks/use-floating.svelte.js";
44
55
export interface FloatingArrowProps extends SVGAttributes<SVGElement> {
66
/** The bound HTML element reference. */
@@ -47,14 +47,12 @@
4747

4848
<script lang="ts">
4949
import type { Alignment, Side } from "@floating-ui/dom";
50-
import { platform } from "@floating-ui/dom";
51-
import { useId } from "../../hooks/use-id.js";
50+
import { useId } from "../hooks/use-id.js";
5251
import {
5352
styleObjectToString,
5453
styleStringToObject,
55-
} from "../../internal/style-object-to-string.js";
56-
import parse from "style-to-object";
57-
import { watch } from "../../internal/watch.svelte.js";
54+
} from "../internal/style-object-to-string.js";
55+
import { watch } from "../internal/watch.svelte.js";
5856
5957
let {
6058
ref = $bindable(null),

packages/floating-ui-svelte/src/hooks/use-floating-root-context.svelte.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class FloatingRootContext<RT extends ReferenceType = ReferenceType> {
8787
this.#positionReference = node;
8888
}
8989

90+
setFloatingElement(node: HTMLElement | null) {
91+
this.#floatingElement = node;
92+
}
93+
9094
get elements() {
9195
const _this = this;
9296
return {
@@ -97,7 +101,7 @@ class FloatingRootContext<RT extends ReferenceType = ReferenceType> {
97101
return _this.#elements.floating;
98102
},
99103
set floating(node: HTMLElement | null) {
100-
_this.#floatingElement = node;
104+
_this.setFloatingElement(node);
101105
},
102106
get domReference() {
103107
return _this.#referenceElement;

packages/floating-ui-svelte/src/hooks/use-floating.svelte.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ class FloatingState<RT extends ReferenceType = ReferenceType> {
210210
this.#positionReference = computedPositionReference;
211211
}
212212

213+
setDomReference(node: NarrowedElement<RT> | null) {
214+
this.#domReference = node;
215+
}
216+
213217
get placement() {
214218
return this.#position.data.placement;
215219
}
@@ -249,7 +253,7 @@ class FloatingState<RT extends ReferenceType = ReferenceType> {
249253
},
250254
set reference(node: RT | null) {
251255
if (isElement(node) || node === null) {
252-
state.#domReference = node as NarrowedElement<RT> | null;
256+
state.setDomReference(node as NarrowedElement<RT> | null);
253257
}
254258
},
255259
get floating() {
@@ -264,9 +268,9 @@ class FloatingState<RT extends ReferenceType = ReferenceType> {
264268
};
265269
};
266270

267-
get elements() {
271+
readonly elements = $derived.by(() => {
268272
return this.#getElements(this);
269-
}
273+
});
270274
}
271275

272276
/**

packages/floating-ui-svelte/src/hooks/use-hover.svelte.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
isMouseLikePointerType,
77
} from "../internal/dom.js";
88
import { noop } from "../internal/noop.js";
9-
import type { ElementProps } from "./use-interactions.svelte.js";
109
import type { FloatingTreeType, OpenChangeReason } from "../types.js";
1110
import type {
1211
FloatingContext,

packages/floating-ui-svelte/src/hooks/use-position.svelte.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ interface UsePositionData {
109109
* Manages the positioning of floating elements.
110110
*/
111111
class PositionState<RT extends ReferenceType = ReferenceType> {
112-
#strategy: Strategy = $derived.by(() => this.options.strategy ?? "absolute");
113-
#placement: Placement = $derived.by(() => this.options.placement ?? "bottom");
112+
#strategy: Strategy = $derived.by(() => this.options?.strategy ?? "absolute");
113+
#placement: Placement = $derived.by(
114+
() => this.options?.placement ?? "bottom",
115+
);
114116
#middleware: Array<Middleware | undefined | null | false> = $derived.by(
115-
() => this.options.middleware ?? [],
117+
() => this.options?.middleware ?? [],
116118
);
117-
#transform: boolean = $derived.by(() => this.options.transform ?? true);
119+
#transform: boolean = $derived.by(() => this.options?.transform ?? true);
118120
#positionReference = $derived.by(() => this.getPositionReference());
119121
reference = $derived.by(
120122
() => this.#positionReference ?? this.rootContext.elements.reference,

packages/floating-ui-svelte/src/internal/context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* Sourced from Runed `Context`: https://runed.dev/docs/utilities/context
33
*/
4-
54
import { getContext, hasContext, setContext } from "svelte";
65

76
export class Context<TContext> {

packages/floating-ui-svelte/test/hooks/wrapper-components/use-click.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<script lang="ts">
22
import { autoUpdate } from "@floating-ui/dom";
3-
import {
4-
type UseClickOptions,
5-
useClick,
6-
} from "../../../src/hooks/use-click.svelte.js";
73
import { useFloating } from "../../../src/hooks/use-floating.svelte.js";
84
import { useHover } from "../../../src/hooks/use-hover.svelte.js";
95
import { useInteractions } from "../../../src/hooks/use-interactions.svelte.js";
6+
import { useClick, type UseClickOptions } from "../../../src/index.js";
107
118
interface Props extends UseClickOptions {
129
open?: boolean;

packages/floating-ui-svelte/test/hooks/wrapper-components/use-dismiss.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
<button
3131
data-testid="reference"
3232
bind:this={floating.elements.reference}
33-
{...interactions.getReferenceProps()}></button>
33+
{...interactions.getReferenceProps()}>
34+
button
35+
</button>
3436

3537
{#if open}
3638
<div

0 commit comments

Comments
 (0)