From c7dff4e2891ab436982e06a76be866ebe647f08d Mon Sep 17 00:00:00 2001 From: chizukicn Date: Sun, 7 Jan 2024 09:31:06 +0800 Subject: [PATCH] feat(components): add affix-target component --- .eslintrc | 9 +++++---- packages/components/components.ts | 1 + packages/core/src/affix-target/component.ts | 14 ++++++++++++++ packages/hoci/index.ts | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 packages/core/src/affix-target/component.ts create mode 100644 packages/hoci/index.ts diff --git a/.eslintrc b/.eslintrc index d962353..8235673 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,7 @@ { - "extends": ["@curev"], - "rules": { - "unicorn/prefer-spread":"off" - } + "extends": ["@curev"], + "rules": { + "unicorn/prefer-spread": "off", + "import/export": "off" + } } diff --git a/packages/components/components.ts b/packages/components/components.ts index 6601ba8..a2188cd 100644 --- a/packages/components/components.ts +++ b/packages/components/components.ts @@ -1,4 +1,5 @@ export * from "../core/src/affix/component"; +export * from "../core/src/affix-target/component"; export * from "../core/src/selection/component"; export * from "../core/src/item/component"; export * from "../core/src/icon/component"; diff --git a/packages/core/src/affix-target/component.ts b/packages/core/src/affix-target/component.ts new file mode 100644 index 0000000..fe3d664 --- /dev/null +++ b/packages/core/src/affix-target/component.ts @@ -0,0 +1,14 @@ +import { defineComponent, h, ref, renderSlot } from "vue"; +import { provideAffixTarget } from "../affix"; + +export const HiAffixTarget = defineComponent({ + name: "HiAffixTarget", + setup(_, context) { + const targetRef = ref(null); + provideAffixTarget(targetRef); + return () => h("div", { + ref: targetRef, + ...context.attrs + }, renderSlot(context.slots, "default")); + } +}); diff --git a/packages/hoci/index.ts b/packages/hoci/index.ts new file mode 100644 index 0000000..e910bb0 --- /dev/null +++ b/packages/hoci/index.ts @@ -0,0 +1 @@ +export * from "./src/index";