ea478a0bba9fcc43a0c4333d31cc6bf9bff9e79deadac6595f1af3bcf8a59b6f5a3f821d76f7df35ae8acd85de3b1cf4663e78fdfc464dec21ebbb8967b6f4 824 B

12345678910111213141516171819202122
  1. import { computed, getCurrentInstance } from 'vue';
  2. import { fromPairs } from 'lodash-unified';
  3. const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
  4. const LISTENER_PREFIX = /^on[A-Z]/;
  5. const useAttrs = (params = {}) => {
  6. const { excludeListeners = false, excludeKeys } = params;
  7. const allExcludeKeys = computed(() => {
  8. return ((excludeKeys == null ? void 0 : excludeKeys.value) || []).concat(DEFAULT_EXCLUDE_KEYS);
  9. });
  10. const instance = getCurrentInstance();
  11. if (!instance) {
  12. return computed(() => ({}));
  13. }
  14. return computed(() => {
  15. var _a;
  16. return fromPairs(Object.entries((_a = instance.proxy) == null ? void 0 : _a.$attrs).filter(([key]) => !allExcludeKeys.value.includes(key) && !(excludeListeners && LISTENER_PREFIX.test(key))));
  17. });
  18. };
  19. export { useAttrs };
  20. //# sourceMappingURL=index.mjs.map