You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
3.4 KiB
1 lines
3.4 KiB
{"ast":null,"code":"import { computed } from 'vue';\nimport { usePropsAlias } from './use-props-alias.mjs';\nconst useComputedData = props => {\n const propsAlias = usePropsAlias(props);\n const dataObj = computed(() => props.data.reduce((o, cur) => (o[cur[propsAlias.value.key]] = cur) && o, {}));\n const sourceData = computed(() => props.data.filter(item => !props.modelValue.includes(item[propsAlias.value.key])));\n const targetData = computed(() => {\n if (props.targetOrder === \"original\") {\n return props.data.filter(item => props.modelValue.includes(item[propsAlias.value.key]));\n } else {\n return props.modelValue.reduce((arr, cur) => {\n const val = dataObj.value[cur];\n if (val) {\n arr.push(val);\n }\n return arr;\n }, []);\n }\n });\n return {\n sourceData,\n targetData\n };\n};\nexport { useComputedData };","map":{"version":3,"names":["useComputedData","props","propsAlias","usePropsAlias","dataObj","computed","data","reduce","o","cur","value","key","sourceData","filter","item","modelValue","includes","targetData","targetOrder","arr","val","push"],"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"],"mappings":";;AAEY,MAACA,eAAe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