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 line
8.8 KiB

{"ast":null,"code":"import { isNil } from 'lodash-unified';\nimport '../../../utils/index.mjs';\nimport '../../../constants/index.mjs';\nimport { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';\nimport { mutable } from '../../../utils/typescript.mjs';\nimport { isArray } from '@vue/shared';\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';\nconst LEFT_CHECK_CHANGE_EVENT = \"left-check-change\";\nconst RIGHT_CHECK_CHANGE_EVENT = \"right-check-change\";\nconst transferProps = buildProps({\n data: {\n type: definePropType(Array),\n default: () => []\n },\n titles: {\n type: definePropType(Array),\n default: () => []\n },\n buttonTexts: {\n type: definePropType(Array),\n default: () => []\n },\n filterPlaceholder: String,\n filterMethod: {\n type: definePropType(Function)\n },\n leftDefaultChecked: {\n type: definePropType(Array),\n default: () => []\n },\n rightDefaultChecked: {\n type: definePropType(Array),\n default: () => []\n },\n renderContent: {\n type: definePropType(Function)\n },\n modelValue: {\n type: definePropType(Array),\n default: () => []\n },\n format: {\n type: definePropType(Object),\n default: () => ({})\n },\n filterable: Boolean,\n props: {\n type: definePropType(Object),\n default: () => mutable({\n label: \"label\",\n key: \"key\",\n disabled: \"disabled\"\n })\n },\n targetOrder: {\n type: String,\n values: [\"original\", \"push\", \"unshift\"],\n default: \"original\"\n },\n validateEvent: {\n type: Boolean,\n default: true\n }\n});\nconst transferCheckedChangeFn = (value, movedKeys) => [value, movedKeys].every(isArray) || isArray(value) && isNil(movedKeys);\nconst transferEmits = {\n [CHANGE_EVENT]: (value, direction, movedKeys) => [value, movedKeys].every(isArray) && [\"left\", \"right\"].includes(direction),\n [UPDATE_MODEL_EVENT]: value => isArray(value),\n [LEFT_CHECK_CHANGE_EVENT]: transferCheckedChangeFn,\n [RIGHT_CHECK_CHANGE_EVENT]: transferCheckedChangeFn\n};\nexport { LEFT_CHECK_CHANGE_EVENT, RIGHT_CHECK_CHANGE_EVENT, transferCheckedChangeFn, transferEmits, transferProps };","map":{"version":3,"names":["LEFT_CHECK_CHANGE_EVENT","RIGHT_CHECK_CHANGE_EVENT","transferProps","buildProps","data","type","definePropType","Array","default","titles","buttonTexts","filterPlaceholder","String","filterMethod","Function","leftDefaultChecked","rightDefaultChecked","renderContent","modelValue","format","Object","filterable","Boolean","props","mutable","label","key","disabled","targetOrder","values","validateEvent","transferCheckedChangeFn","value","movedKeys","every","isArray","isNil","transferEmits","CHANGE_EVENT","direction","includes","UPDATE_MODEL_EVENT"],"sources":["../../../../../../packages/components/transfer/src/transfer.ts"],"sourcesContent":["import { isNil } from 'lodash-unified'\nimport {\n buildProps,\n definePropType,\n isArray,\n mutable,\n} from '@element-plus/utils'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\n\nimport type { ExtractPropTypes, h as H, VNode } from 'vue'\nimport type Transfer from './transfer.vue'\n\nexport type TransferKey = string | number\nexport type TransferDirection = 'left' | 'right'\n\nexport type TransferDataItem = Record<string, any>\n\nexport type renderContent = (\n h: typeof H,\n option: TransferDataItem\n) => VNode | VNode[]\n\nexport interface TransferFormat {\n noChecked?: string\n hasChecked?: string\n}\n\nexport interface TransferPropsAlias {\n label?: string\n key?: string\n disabled?: string\n}\n\nexport interface TransferCheckedState {\n leftChecked: TransferKey[]\n rightChecked: TransferKey[]\n}\n\nexport const LEFT_CHECK_CHANGE_EVENT = 'left-check-change'\nexport const RIGHT_CHECK_CHANGE_EVENT = 'right-check-change'\n\nexport const transferProps = buildProps({\n /**\n * @description data source\n */\n data: {\n type: definePropType<TransferDataItem[]>(Array),\n default: () => [],\n },\n /**\n * @description custom list titles\n */\n titles: {\n type: definePropType<[string, string]>(Array),\n default: () => [],\n },\n /**\n * @description custom button texts\n */\n buttonTexts: {\n type: definePropType<[string, string]>(Array),\n default: () => [],\n },\n /**\n * @description placeholder for the filter input\n */\n filterPlaceholder: String,\n /**\n * @description custom filter method\n */\n filterMethod: {\n type: definePropType<(query: string, item: TransferDataItem) => boolean>(\n Function\n ),\n },\n /**\n * @description key array of initially checked data items of the left list\n */\n leftDefaultChecked: {\n type: definePropType<TransferKey[]>(Array),\n default: () => [],\n },\n /**\n * @description key array of initially checked data items of the right list\n */\n rightDefaultChecked: {\n type: definePropType<TransferKey[]>(Array),\n default: () => [],\n },\n /**\n * @description custom render function for data items\n */\n renderContent: {\n type: definePropType<renderContent>(Function),\n },\n /**\n * @description binding value\n */\n modelValue: {\n type: definePropType<TransferKey[]>(Array),\n default: () => [],\n },\n /**\n * @description texts for checking status in list header\n */\n format: {\n type: definePropType<TransferFormat>(Object),\n default: () => ({}),\n },\n /**\n * @description whether Transfer is filterable\n */\n filterable: Boolean,\n /**\n * @description prop aliases for data source\n */\n props: {\n type: definePropType<TransferPropsAlias>(Object),\n default: () =>\n mutable({\n label: 'label',\n key: 'key',\n disabled: 'disabled',\n } as const),\n },\n /**\n * @description order strategy for elements in the target list. If set to `original`, the elements will keep the same order as the data source. If set to `push`, the newly added elements will be pushed to the bottom. If set to `unshift`, the newly added elements will be inserted on the top\n */\n targetOrder: {\n type: String,\n values: ['original', 'push', 'unshift'],\n default: 'original',\n },\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n} as const)\nexport type TransferProps = ExtractPropTypes<typeof transferProps>\n\nexport const transferCheckedChangeFn = (\n value: TransferKey[],\n movedKeys?: TransferKey[]\n) => [value, movedKeys].every(isArray) || (isArray(value) && isNil(movedKeys))\n\nexport const transferEmits = {\n [CHANGE_EVENT]: (\n value: TransferKey[],\n direction: TransferDirection,\n movedKeys: TransferKey[]\n ) =>\n [value, movedKeys].every(isArray) && ['left', 'right'].includes(direction),\n [UPDATE_MODEL_EVENT]: (value: TransferKey[]) => isArray(value),\n [LEFT_CHECK_CHANGE_EVENT]: transferCheckedChangeFn,\n [RIGHT_CHECK_CHANGE_EVENT]: transferCheckedChangeFn,\n}\nexport type TransferEmits = typeof transfer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