{"version":3,"file":"transfer.mjs","names":[],"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 {\n  ComponentInstance,\n  ExtractPublicPropTypes,\n  h as H,\n  VNode,\n} from 'vue'\nimport type { ComponentExposed } from 'vue-component-type-helpers'\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<T extends TransferDataItem = TransferDataItem> = (\n  h: typeof H,\n  option: T\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 interface TransferProps<T extends TransferDataItem = TransferDataItem> {\n  /**\n   * @description data source\n   */\n  data?: T[]\n  /**\n   * @description custom list titles\n   */\n  titles?: [string, string]\n  /**\n   * @description custom button texts\n   */\n  buttonTexts?: [string, string]\n  /**\n   * @description placeholder for the filter input\n   */\n  filterPlaceholder?: string\n  /**\n   * @description custom filter method\n   */\n  filterMethod?: (query: string, item: T) => boolean\n  /**\n   * @description key array of initially checked data items of the left list\n   */\n  leftDefaultChecked?: TransferKey[]\n  /**\n   * @description key array of initially checked data items of the right list\n   */\n  rightDefaultChecked?: TransferKey[]\n  /**\n   * @description custom render function for data items\n   */\n  renderContent?: renderContent<T>\n  /**\n   * @description binding value\n   */\n  modelValue?: TransferKey[]\n  /**\n   * @description texts for checking status in list header\n   */\n  format?: TransferFormat\n  /**\n   * @description whether Transfer is filterable\n   */\n  filterable?: boolean\n  /**\n   * @description prop aliases for data source\n   */\n  props?: TransferPropsAlias\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?: 'original' | 'push' | 'unshift'\n  /**\n   * @description whether to trigger form validation\n   */\n  validateEvent?: boolean\n  /**\n   * @description whether to enable virtual scrolling\n   */\n  virtualScroll?: boolean\n  /**\n   * @description line height for virtual scrolling\n   */\n  itemSize?: number\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `TransferProps` instead.\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  /**\n   * @description whether to enable virtual scrolling\n   */\n  virtualScroll: Boolean,\n  /**\n   * @description line height for virtual scrolling\n   */\n  itemSize: {\n    type: Number,\n    default: 30,\n  },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `TransferProps` instead.\n */\nexport type TransferPropsPublic = ExtractPublicPropTypes<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 transferEmits\n\nexport type TransferInstance = ComponentInstance<typeof Transfer> &\n  ComponentExposed<typeof Transfer>\n"],"mappings":";;;;;;AA4CA,MAAa,0BAA0B;AACvC,MAAa,2BAA2B;;;;AAwExC,MAAa,gBAAgB,WAAW;;;;CAItC,MAAM;EACJ,MAAM,eAAmC,KAAK;EAC9C,eAAe,CAAC;CAClB;;;;CAIA,QAAQ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