{"version":3,"file":"use-children-components.mjs","sources":["../../../../packages/hooks/use-children-components.ts"],"sourcesContent":["import { onMounted, onUpdated, ref } from 'vue'\nimport type { SlotChildren } from '../utils/types'\nimport { getComponentsFromChildren } from '../utils/vue-utils'\n\nexport const useChildrenComponents = (name: string) => {\n  // only save VNodes reference, not use ref\n  const children: SlotChildren = {}\n  const components = ref<number[]>([])\n\n  const getComponents = () => {\n    if (children.value) {\n      const _components = getComponentsFromChildren(children.value, name)\n      if (\n        _components.length !== components.value.length ||\n        _components.toString() !== components.value.toString()\n      ) {\n        components.value = _components\n      }\n    }\n  }\n\n  onMounted(() => getComponents())\n\n  onUpdated(() => getComponents())\n\n  return {\n    children,\n    components\n  }\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,qBAAA,GAAwB,CAAC,IAAiB,KAAA;AAErD,EAAA,MAAM,WAAyB,EAAC,CAAA;AAChC,EAAM,MAAA,UAAA,GAAa,GAAc,CAAA,EAAE,CAAA,CAAA;AAEnC,EAAA,MAAM,gBAAgB,MAAM;AAC1B,IAAA,IAAI,SAAS,KAAO,EAAA;AAClB,MAAA,MAAM,WAAc,GAAA,yBAAA,CAA0B,QAAS,CAAA,KAAA,EAAO,IAAI,CAAA,CAAA;AAClE,MACE,IAAA,WAAA,CAAY,MAAW,KAAA,UAAA,CAAW,KAAM,CAAA,MAAA,IACxC,WAAY,CAAA,QAAA,EAAe,KAAA,UAAA,CAAW,KAAM,CAAA,QAAA,EAC5C,EAAA;AACA,QAAA,UAAA,CAAW,KAAQ,GAAA,WAAA,CAAA;AAAA,OACrB;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAU,SAAA,CAAA,MAAM,eAAe,CAAA,CAAA;AAE/B,EAAU,SAAA,CAAA,MAAM,eAAe,CAAA,CAAA;AAE/B,EAAO,OAAA;AAAA,IACL,QAAA;AAAA,IACA,UAAA;AAAA,GACF,CAAA;AACF;;;;"}