Skip to content

Commit c9758b3

Browse files
committed
refactor: rename unwrap util
1 parent f36ad02 commit c9758b3

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

packages/react/src/hooks/useAdhesive.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Adhesive, type AdhesiveOptions } from "@adhesivejs/core";
22
import { useEffect, useRef } from "react";
33
import {
4-
unrefElement,
4+
unwrapElement,
55
type MaybeElementOrSelectorRef,
6-
} from "../utils/unrefElement.js";
6+
} from "../utils/unwrapElement.js";
77

88
/**
99
* Configuration options for the useAdhesive hook.
@@ -53,9 +53,9 @@ export function useAdhesive(
5353
options?: UseAdhesiveOptions,
5454
) {
5555
function getValidatedOptions() {
56-
const targetEl = unrefElement(target);
56+
const targetEl = unwrapElement(target);
5757
const boundingEl =
58-
unrefElement(options?.boundingRef) ?? options?.boundingEl;
58+
unwrapElement(options?.boundingRef) ?? options?.boundingEl;
5959

6060
if (!targetEl) {
6161
throw new Error("@adhesivejs/react: sticky element is not defined");
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export type MaybeElementOrSelectorRef =
77
| null
88
| undefined;
99

10-
type UnRefElementReturn = HTMLElement | string | null | undefined;
10+
type UnwrapElementReturn = HTMLElement | string | null | undefined;
1111

12-
export function unrefElement(
12+
export function unwrapElement(
1313
elOrSelectorRef: MaybeElementOrSelectorRef,
14-
): UnRefElementReturn {
14+
): UnwrapElementReturn {
1515
// Handle React ref objects by accessing their .current property
1616
// For non-ref values, return them as-is
1717
if (
@@ -21,5 +21,5 @@ export function unrefElement(
2121
) {
2222
return elOrSelectorRef.current;
2323
}
24-
return elOrSelectorRef as UnRefElementReturn;
24+
return elOrSelectorRef as UnwrapElementReturn;
2525
}

packages/vue/src/components/AdhesiveContainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
useAdhesive,
1111
type UseAdhesiveOptions,
1212
} from "../composables/useAdhesive.js";
13-
import type { MaybeElementOrSelectorRef } from "../utils/unrefElement.js";
13+
import type { MaybeElementOrSelectorRef } from "../utils/unwrapElement.js";
1414

1515
type BaseProps = Omit<
1616
Partial<UseAdhesiveOptions>,

packages/vue/src/composables/useAdhesive.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
type MaybeRefOrGetter,
88
} from "vue";
99
import {
10-
unrefElement,
10+
unwrapElement,
1111
type MaybeElementOrSelectorRef,
12-
} from "../utils/unrefElement.js";
12+
} from "../utils/unwrapElement.js";
1313

1414
/**
1515
* Configuration options for the useAdhesive composable.
@@ -80,9 +80,9 @@ export function useAdhesive(
8080
function getValidatedOptions() {
8181
const optionsValue = toValue(options);
8282

83-
const targetEl = unrefElement(target);
83+
const targetEl = unwrapElement(target);
8484
const boundingEl =
85-
unrefElement(optionsValue?.boundingRef) ?? optionsValue?.boundingEl;
85+
unwrapElement(optionsValue?.boundingRef) ?? optionsValue?.boundingEl;
8686

8787
if (!targetEl) {
8888
throw new Error("@adhesivejs/vue: sticky element is not defined");
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export type MaybeElementOrSelectorRef<
1717
T extends MaybeElementOrSelector = MaybeElementOrSelector,
1818
> = MaybeRefOrGetter<T>;
1919

20-
type UnRefElementReturn = HTMLElement | string | null | undefined;
20+
type UnwrapElementReturn = HTMLElement | string | null | undefined;
2121

22-
export function unrefElement(
22+
export function unwrapElement(
2323
elOrSelectorRef: MaybeElementOrSelectorRef,
24-
): UnRefElementReturn {
24+
): UnwrapElementReturn {
2525
const elOrSelectorValue = toValue(elOrSelectorRef);
2626
return (elOrSelectorValue as VueInstance)?.$el ?? elOrSelectorValue;
2727
}

0 commit comments

Comments
 (0)