This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
import type { ComputedRef } from 'vue';
interface Params {
excludeListeners?: boolean;
excludeKeys?: ComputedRef<string[]>;
}
export declare const useAttrs: (params?: Params) => ComputedRef<Record<string, unknown>>;
export {};

22
node_modules/element-plus/es/hooks/use-attrs/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import { computed, getCurrentInstance } from 'vue';
import { fromPairs } from 'lodash-unified';
const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
const LISTENER_PREFIX = /^on[A-Z]/;
const useAttrs = (params = {}) => {
const { excludeListeners = false, excludeKeys } = params;
const allExcludeKeys = computed(() => {
return ((excludeKeys == null ? void 0 : excludeKeys.value) || []).concat(DEFAULT_EXCLUDE_KEYS);
});
const instance = getCurrentInstance();
if (!instance) {
return computed(() => ({}));
}
return computed(() => {
var _a;
return fromPairs(Object.entries((_a = instance.proxy) == null ? void 0 : _a.$attrs).filter(([key]) => !allExcludeKeys.value.includes(key) && !(excludeListeners && LISTENER_PREFIX.test(key))));
});
};
export { useAttrs };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","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"],"names":[],"mappings":";;;AAGA,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAChD,MAAM,eAAe,GAAG,UAAU,CAAC;AACvB,MAAC,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,KAAK;AACzC,EAAE,MAAM,EAAE,gBAAgB,GAAG,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;AAC3D,EAAE,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM;AACxC,IAAI,OAAO,CAAC,CAAC,WAAW,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,KAAK,KAAK,EAAE,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACnG,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,QAAQ,GAAG,kBAAkB,EAAE,CAAC;AACxC,EAAE,IAAI,CAAC,QAAQ,EAAE;AAEjB,IAAI,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAChC,GAAG;AACH,EAAE,OAAO,QAAQ,CAAC,MAAM;AACxB,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,OAAO,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,gBAAgB,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpM,GAAG,CAAC,CAAC;AACL;;;;"}