Skip to content

Commit

Permalink
feat: downgrade vueuse to 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chizukicn committed Dec 1, 2023
1 parent 54dc44a commit 09e97c1
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 27 deletions.
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"prepublish": "pnpm build"
},
"peerDependencies": {
"@vueuse/core": ">=9.0.0",
"vue": "^3.0.0-0"
},
"dependencies": {
"@hoci/core": "workspace:*",
"@hoci/shared": "workspace:*",
"@vueuse/core": ">=10.5.0",
"maybe-types": "^0.1.0",
"maybe-types": "^0.2.0",
"tslx": "^0.1.1"
}
}
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"dependencies": {
"@hoci/shared": "workspace:*",
"@vueuse/core": ">=10.5.0",
"maybe-types": "^0.1.0",
"@vueuse/core": "9.0.0",
"maybe-types": "^0.2.0",
"tslx": "^0.1.1"
}
}
4 changes: 2 additions & 2 deletions packages/core/src/affix/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { computed, inject, provide, ref, watchPostEffect } from "vue";
import type { InjectionKey, MaybeRefOrGetter, PropType, Ref } from "vue";
import { toReactive, useElementBounding, useElementVisibility, useEventListener } from "@vueuse/core";
import { useElementBounding, useElementVisibility, useEventListener } from "@vueuse/core";
import type { CSSProperties } from "tslx";
import { defineHookComponent, defineHookEmits, defineHookProps, isWindow, throttleByRaf, useElement } from "@hoci/shared";
import { defineHookComponent, defineHookEmits, defineHookProps, isWindow, throttleByRaf, toReactive, useElement } from "@hoci/shared";
import { px } from "tslx";
export const affixProps = defineHookProps(
{
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/selection/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDefined, syncRef, toReactive } from "@vueuse/core";
import { isDefined, syncRef } from "@vueuse/core";
import type { InjectionKey, PropType } from "vue";
import {
computed,
Expand All @@ -14,6 +14,7 @@ import {
defineHookProps,
getFirstChilld,
labelPropType,
toReactive,
useSharedConfig,
valuePropType
} from "@hoci/shared";
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"prepublish": "pnpm build"
},
"peerDependencies": {
"@vueuse/core": ">=9.0.0",
"vue": "^3.0.0-0"
},
"dependencies": {
"@vueuse/core": ">=10.5.0",
"defu": "^6.1.2",
"maybe-types": "^0.1.0",
"maybe-types": "^0.2.0",
"type-fest": "^4.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/shared/src/composables/element.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { MaybeRefOrGetter } from "@vueuse/core";
import { toRef, useMounted } from "@vueuse/core";
import type { Ref } from "vue";
import type { MaybeRefOrGetter, Ref } from "vue";
import { useMounted } from "@vueuse/core";
import { computed } from "vue";
import { toRef } from "./vueuse";

export function useElement<E extends Element = HTMLElement>(elementSelector: MaybeRefOrGetter<string | Element | undefined | null>, defaultValue?: Ref<E | null | undefined> | MaybeRefOrGetter<E | null | undefined>) {
const selectorRef = toRef(elementSelector);
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/composables/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./element";
export * from "./vueuse";
27 changes: 27 additions & 0 deletions packages/shared/src/composables/vueuse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { toReactive as _toReactive, noop } from "@vueuse/core";
import { toRef as _toRef, customRef, readonly, ref } from "vue";
import type { ComputedRef, MaybeRefOrGetter, Ref, ToRef, UnwrapNestedRefs } from "vue";

export const toReactive = _toReactive as <T>(value: T) => UnwrapNestedRefs<T>;


export function toRef<T>(r: () => T): Readonly<Ref<T>>;
export function toRef<T>(r: ComputedRef<T>): ComputedRef<T>;
export function toRef<T>(r: MaybeRefOrGetter<T>): Ref<T>;
export function toRef<T>(r: T): Ref<T>;
export function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
export function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>;
export function toRef(...args: any[]) {
if (args.length !== 1) {
return _toRef(...args as [any, any]);
};
const r = args[0];
return typeof r === "function"
? readonly(customRef(() => ({ get: r as any, set: noop })))
: ref(r);
}

/**
* @deprecated use `toRef` instead
*/
export const resolveRef = toRef;
61 changes: 47 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/selection.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {useSelectionList} from "hoci";
import { it } from "vitest";

it("should select items", () => {
Expand Down

0 comments on commit 09e97c1

Please sign in to comment.