Vulture/VApp/node_modules/vuetify/lib/composables/forwardRefs.mjs.map

1 line
7.3 KiB
Plaintext
Raw Permalink Normal View History

{"version":3,"file":"forwardRefs.mjs","names":["Refs","Symbol","getDescriptor","obj","key","currentObj","descriptor","Reflect","getOwnPropertyDescriptor","Object","getPrototypeOf","undefined","forwardRefs","target","_len","arguments","length","refs","Array","_key","Proxy","get","has","startsWith","ref","value","val","bind","set","_","setupState","childRefs","queue","slice","shift","push"],"sources":["../../src/composables/forwardRefs.ts"],"sourcesContent":["// Types\nimport type { ComponentPublicInstance, Ref, UnwrapRef } from 'vue'\nimport type { UnionToIntersection } from '@/util'\n\nconst Refs = Symbol('Forwarded refs')\n\n/** Omit properties starting with P */\ntype OmitPrefix<T, P extends string> = [Extract<keyof T, `${P}${any}`>] extends [never] ? T : Omit<T, `${P}${any}`>\n\ntype OmitProps<T> = T extends { $props: any } ? Omit<T, keyof T['$props']> : T\n\nfunction getDescriptor (obj: any, key: PropertyKey) {\n let currentObj = obj\n while (currentObj) {\n const descriptor = Reflect.getOwnPropertyDescriptor(currentObj, key)\n if (descriptor) return descriptor\n currentObj = Object.getPrototypeOf(currentObj)\n }\n return undefined\n}\n\nexport function forwardRefs<T extends {}, U extends Ref<HTMLElement | Omit<ComponentPublicInstance, '$emit' | '$slots'> | undefined>[]> (\n target: T,\n ...refs: U\n): T & UnionToIntersection<{ [K in keyof U]: OmitPrefix<OmitProps<NonNullable<UnwrapRef<U[K]>>>, '$'> }[number]> {\n (target as any)[Refs] = refs\n\n return new Proxy(target, {\n get (target, key) {\n if (Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n\n // Skip internal properties\n if (typeof key === 'symbol' || key.startsWith('$') || key.startsWith('__')) return\n\n for (const ref of refs) {\n if (ref.value && Reflect.has(ref.value, key)) {\n const val = Reflect.get(ref.value, key)\n return typeof val === 'function'\n ? val.bind(ref.value)\n : val\n }\n }\n },\n has (target, key) {\n if (Reflect.has(target, key)) {\n return true\n }\n\n // Skip internal properties\n if (typeof key === 'symbol' || key.startsWith('$') || key.startsWith('__')) return false\n\n for (const ref of refs) {\n if (ref.value && Reflect.has(ref.value, key)) {\n return true\n }\n }\n return false\n },\n set (target, key, value) {\n if (Reflect.has(target, key)) {\n return Reflect.set(target, key, value)\n }\n\n // Skip internal properties\n if (typeof key === 'symbol' || key.startsWith('$') || key.startsWith('__')) return false\n\n for (const ref of refs) {\n if (ref.value && Reflect.has(ref.value, key)) {\n return Reflect.set(ref.value, key, value)\n }\n }\n\n return false\n },\n getOwnPropertyDescriptor (target, key) {\n const descriptor = Reflect.getOwnPropertyDescriptor(target, key)\n if (descriptor) return descriptor\n\n // Skip internal properties\n if (typeof key === 'symbol' || key.startsWith('$') || key.startsWith('__')) return\n\n // Check each ref's own properties\n for (const ref of refs) {\n if (!ref.value) continue\n const descriptor = getDescriptor(ref.value, key) ?? ('_' in ref.value ? getDescriptor(ref.value._?.setupState, key) : undefined)\n if (descriptor) return descriptor\n }\n\n // Recursive search up each ref's prototype\n for (const ref of refs) {\n const childRefs = ref.value && (ref.value as any)[Refs]\n if (!childRefs) continue\n const queue = childRefs.slice()\n while (queue.length) {\n const ref = queue.shift()\n const descriptor = getDescriptor(ref.value, key)\n if (descriptor) return descriptor\n const childRefs = ref.value && (ref.value as any)[Refs]\n if (childRefs) queue.push(...childRefs)\n }\n }\n\n return undefined\n },\n }) as any\n}\n"],"mappings":"AAAA;;AAIA,MAAMA,IAAI,GAAGC,M