{"version":3,"file":"use-select-records2.mjs","sources":["../../../../../../../../packages/components/cascade-pro/src/hooks/use-select-records.ts"],"sourcesContent":["import { computed, ref, unref } from 'vue'\nimport type { CascadeProOption, IUseSelectRecordsReturn } from '../types'\n\n/**\n * 设置当前选中的所有数据\n *\n * @returns\n */\nexport function useSelectRecords(): IUseSelectRecordsReturn {\n  const selectRecordsRef = ref<CascadeProOption[]>([])\n\n  const selectRecords = computed(() => unref(selectRecordsRef))\n\n  function setSelectRecords(selectRecords: CascadeProOption[], type: 'normal' | 'recover') {\n    if (type === 'normal') {\n      const prevSelectRecords = unref(selectRecordsRef)\n      const currentSelectRecords = selectRecords.reduce((result, cur) => {\n        const isHaveSameOption = result.find((option) => option.idPath === cur.idPath)\n        !isHaveSameOption && result.push(cur)\n        return result\n      }, prevSelectRecords)\n      selectRecordsRef.value = currentSelectRecords\n    }\n\n    if (type === 'recover') {\n      selectRecordsRef.value = selectRecords\n    }\n  }\n\n  return { selectRecords, setSelectRecords }\n}\n"],"names":[],"mappings":";;AACO,SAAS,gBAAgB,GAAG;AACnC,EAAE,MAAM,gBAAgB,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC;AACnC,EAAE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAChE,EAAE,SAAS,gBAAgB,CAAC,cAAc,EAAE,IAAI,EAAE;AAClD,IAAI,IAAI,IAAI,KAAK,QAAQ,EAAE;AAC3B,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACxD,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK;AAC1E,QAAQ,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC;AACvF,QAAQ,CAAC,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9C,QAAQ,OAAO,MAAM,CAAC;AACtB,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAC5B,MAAM,gBAAgB,CAAC,KAAK,GAAG,oBAAoB,CAAC;AACpD,KAAK;AACL,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;AAC5B,MAAM,gBAAgB,CAAC,KAAK,GAAG,cAAc,CAAC;AAC9C,KAAK;AACL,GAAG;AACH,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;AAC7C;;;;"}