zhangyong
2023-08-22 1353e87cb21a4032d585d7404bae9042f2ebcf08
1
{"version":3,"file":"use-computed-data.mjs","sources":["../../../../../../../packages/components/transfer/src/composables/use-computed-data.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { usePropsAlias } from './use-props-alias'\n\nimport type { TransferDataItem, TransferKey, TransferProps } from '../transfer'\n\nexport const useComputedData = (props: TransferProps) => {\n  const propsAlias = usePropsAlias(props)\n\n  const dataObj = computed(() =>\n    props.data.reduce((o, cur) => (o[cur[propsAlias.value.key]] = cur) && o, {})\n  )\n\n  const sourceData = computed(() =>\n    props.data.filter(\n      (item) => !props.modelValue.includes(item[propsAlias.value.key])\n    )\n  )\n\n  const targetData = computed(() => {\n    if (props.targetOrder === 'original') {\n      return props.data.filter((item) =>\n        props.modelValue.includes(item[propsAlias.value.key])\n      )\n    } else {\n      return props.modelValue.reduce(\n        (arr: TransferDataItem[], cur: TransferKey) => {\n          const val = dataObj.value[cur]\n          if (val) {\n            arr.push(val)\n          }\n          return arr\n        },\n        []\n      )\n    }\n  })\n\n  return {\n    sourceData,\n    targetData,\n  }\n}\n"],"names":[],"mappings":";;;AAEY,MAAC,eAAe,GAAG,CAAC,KAAK,KAAK;AAC1C,EAAE,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,EAAE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/G,EAAE,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAA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