zhangyong
2023-08-22 1353e87cb21a4032d585d7404bae9042f2ebcf08
1
{"version":3,"file":"autocomplete.mjs","sources":["../../../../../../packages/components/autocomplete/src/autocomplete.ts"],"sourcesContent":["import { NOOP } from '@vue/shared'\nimport {\n  buildProps,\n  definePropType,\n  isObject,\n  isString,\n} from '@element-plus/utils'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\nimport {\n  CHANGE_EVENT,\n  INPUT_EVENT,\n  UPDATE_MODEL_EVENT,\n} from '@element-plus/constants'\n\nimport type { ExtractPropTypes } from 'vue'\nimport type Autocomplete from './autocomplete.vue'\nimport type { Placement } from '@element-plus/components/popper'\nimport type { Awaitable } from '@element-plus/utils'\n\nexport type AutocompleteData = Record<string, any>[]\nexport type AutocompleteFetchSuggestionsCallback = (\n  data: AutocompleteData\n) => void\nexport type AutocompleteFetchSuggestions =\n  | ((\n      queryString: string,\n      cb: AutocompleteFetchSuggestionsCallback\n    ) => Awaitable<AutocompleteData> | void)\n  | AutocompleteData\n\nexport const autocompleteProps = buildProps({\n  /**\n   * @description key name of the input suggestion object for display\n   */\n  valueKey: {\n    type: String,\n    default: 'value',\n  },\n  /**\n   * @description binding value\n   */\n  modelValue: {\n    type: [String, Number],\n    default: '',\n  },\n  /**\n   * @description debounce delay when typing, in milliseconds\n   */\n  debounce: {\n    type: Number,\n    default: 300,\n  },\n  /**\n   * @description the placeholder of Autocomplete\n   */\n  placement: {\n    type: definePropType<Placement>(String),\n    values: [\n      'top',\n      'top-start',\n      'top-end',\n      'bottom',\n      'bottom-start',\n      'bottom-end',\n    ],\n    default: 'bottom-start',\n  },\n  /**\n   * @description a method to fetch input suggestions. When suggestions are ready, invoke `callback(data:[])` to return them to Autocomplete\n   */\n  fetchSuggestions: {\n    type: definePropType<AutocompleteFetchSuggestions>([Function, Array]),\n    default: NOOP,\n  },\n  /**\n   * @description custom class name for autocomplete's dropdown\n   */\n  popperClass: {\n    type: String,\n    default: '',\n  },\n  /**\n   * @description whether show suggestions when input focus\n   */\n  triggerOnFocus: {\n    type: Boolean,\n    default: true,\n  },\n  /**\n   * @description whether to emit a `select` event on enter when there is no autocomplete match\n   */\n  selectWhenUnmatched: {\n    type: Boolean,\n    default: false,\n  },\n  /**\n   * @description whether to hide the loading icon in remote search\n   */\n  hideLoading: {\n    type: Boolean,\n    default: false,\n  },\n  /**\n   * @description label text\n   */\n  label: {\n    type: String,\n  },\n  teleported: useTooltipContentProps.teleported,\n  /**\n   * @description whether to highlight first item in remote search suggestions by default\n   */\n  highlightFirstItem: {\n    type: Boolean,\n    default: false,\n  },\n  /**\n   * @description whether the width of the dropdown is the same as the input\n   */\n  fitInputWidth: {\n    type: Boolean,\n    default: false,\n  },\n  /**\n   * @description whether to show clear button\n   */\n  clearable: {\n    type: Boolean,\n    default: false,\n  },\n  /**\n   * @description whether to disable\n   */\n  disabled: {\n    type: Boolean,\n    default: false,\n  },\n  /**\n   * @description same as `name` in native input\n   */\n  name: String,\n} as const)\nexport type AutocompleteProps = ExtractPropTypes<typeof autocompleteProps>\n\nexport const autocompleteEmits = {\n  [UPDATE_MODEL_EVENT]: (value: string) => isString(value),\n  [INPUT_EVENT]: (value: string) => isString(value),\n  [CHANGE_EVENT]: (value: string) => isString(value),\n  focus: (evt: FocusEvent) => evt instanceof FocusEvent,\n  blur: (evt: FocusEvent) => evt instanceof FocusEvent,\n  clear: () => true,\n  select: (item: Record<string, any>) => isObject(item),\n}\nexport type AutocompleteEmits = typeof autocompleteEmits\n\nexport type AutocompleteInstance = InstanceType<typeof Autocomplete>\n"],"names":[],"mappings":";;;;;;;;AAaY,MAAC,iBAAiB,GAAG,UAAU,CAAC;AAC5C,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH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