完全跑通1.0版本

This commit is contained in:
2026-05-26 12:56:03 +08:00
parent 2ece5174a7
commit 93c714a93b
11557 changed files with 1648225 additions and 36 deletions

View File

@@ -0,0 +1,10 @@
import { ComputedRef } from "vue";
//#region ../../packages/hooks/use-attrs/index.d.ts
interface Params {
excludeListeners?: boolean;
excludeKeys?: ComputedRef<string[]>;
}
declare const useAttrs: (params?: Params) => ComputedRef<Record<string, unknown>>;
//#endregion
export { useAttrs };

View File

@@ -0,0 +1,24 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../_virtual/_rolldown/runtime.js");
const require_error = require("../../utils/error.js");
let lodash_unified = require("lodash-unified");
let vue = require("vue");
//#region ../../packages/hooks/use-attrs/index.ts
const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
const LISTENER_PREFIX = /^on[A-Z]/;
const useAttrs = (params = {}) => {
const { excludeListeners = false, excludeKeys } = params;
const allExcludeKeys = (0, vue.computed)(() => {
return (excludeKeys?.value || []).concat(DEFAULT_EXCLUDE_KEYS);
});
const instance = (0, vue.getCurrentInstance)();
if (!instance) {
require_error.debugWarn("use-attrs", "getCurrentInstance() returned null. useAttrs() must be called at the top of a setup function");
return (0, vue.computed)(() => ({}));
}
return (0, vue.computed)(() => (0, lodash_unified.fromPairs)(Object.entries(instance.proxy?.$attrs).filter(([key]) => !allExcludeKeys.value.includes(key) && !(excludeListeners && LISTENER_PREFIX.test(key)))));
};
//#endregion
exports.useAttrs = useAttrs;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":[],"sources":["../../../../../packages/hooks/use-attrs/index.ts"],"sourcesContent":["import { computed, getCurrentInstance } from 'vue'\nimport { fromPairs } from 'lodash-unified'\nimport { debugWarn } from '@element-plus/utils'\n\nimport type { ComputedRef } from 'vue'\n\ninterface Params {\n excludeListeners?: boolean\n excludeKeys?: ComputedRef<string[]>\n}\n\nconst DEFAULT_EXCLUDE_KEYS = ['class', 'style']\nconst LISTENER_PREFIX = /^on[A-Z]/\n\nexport const useAttrs = (\n params: Params = {}\n): ComputedRef<Record<string, unknown>> => {\n const { excludeListeners = false, excludeKeys } = params\n const allExcludeKeys = computed<string[]>(() => {\n return (excludeKeys?.value || []).concat(DEFAULT_EXCLUDE_KEYS)\n })\n\n const instance = getCurrentInstance()\n if (!instance) {\n debugWarn(\n 'use-attrs',\n 'getCurrentInstance() returned null. useAttrs() must be called at the top of a setup function'\n )\n return computed(() => ({}))\n }\n\n return computed(() =>\n fromPairs(\n Object.entries(instance.proxy?.$attrs!).filter(\n ([key]) =>\n !allExcludeKeys.value.includes(key) &&\n !(excludeListeners && LISTENER_PREFIX.test(key))\n )\n )\n )\n}\n"],"mappings":";;;;;;AAWA,MAAM,uBAAuB,CAAC,SAAS,QAAQ;AAC/C,MAAM,kBAAkB;AAExB,MAAa,YACX,SAAiB,EAAE,KACsB;CACzC,MAAM,EAAE,mBAAmB,OAAO,gBAAgB;CAClD,MAAM,kBAAA,GAAA,IAAA,gBAA0C;EAC9C,QAAQ,aAAa,SAAS,EAAE,EAAE,OAAO,qBAAqB;GAC9D;CAEF,MAAM,YAAA,GAAA,IAAA,qBAA+B;CACrC,IAAI,CAAC,UAAU;EACb,cAAA,UACE,aACA,+FACD;EACD,QAAA,GAAA,IAAA,iBAAuB,EAAE,EAAE;;CAG7B,QAAA,GAAA,IAAA,iBAAA,GAAA,eAAA,WAEI,OAAO,QAAQ,SAAS,OAAO,OAAQ,CAAC,QACrC,CAAC,SACA,CAAC,eAAe,MAAM,SAAS,IAAI,IACnC,EAAE,oBAAoB,gBAAgB,KAAK,IAAI,EAClD,CACF,CACF"}