UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 11.2 kB
{"version":3,"file":"cascader.mjs","names":[],"sources":["../../../../../../packages/components/cascader/src/cascader.ts"],"sourcesContent":["import { placements } from '@popperjs/core'\nimport { CommonProps } from '@element-plus/components/cascader-panel'\nimport {\n buildProps,\n definePropType,\n iconPropType,\n isBoolean,\n} from '@element-plus/utils'\nimport { useEmptyValuesProps, useSizeProp } from '@element-plus/hooks'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\nimport { tagProps } from '@element-plus/components/tag'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { CircleClose } from '@element-plus/icons-vue'\n\nimport type { StyleValue } from 'vue'\nimport type { UseEmptyValuesProps } from '@element-plus/hooks'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type { Placement, PopperEffect } from '@element-plus/components/popper'\nimport type {\n CascaderCommonProps,\n CascaderNode,\n CascaderValue,\n} from '@element-plus/components/cascader-panel'\nimport type { TagProps } from '@element-plus/components/tag'\nimport type { IconPropType } from '@element-plus/utils'\n\ntype CascaderClassType = string | Record<string, boolean> | CascaderClassType[]\n\nexport interface CascaderComponentProps\n extends CascaderCommonProps, UseEmptyValuesProps {\n /**\n * @description size of input\n */\n size?: ComponentSize\n /**\n * @description placeholder of input\n */\n placeholder?: string\n /**\n * @description whether Cascader is disabled\n */\n disabled?: boolean\n /**\n * @description whether selected value can be cleared\n */\n clearable?: boolean\n /**\n * @description custom clear icon component\n */\n clearIcon?: IconPropType\n /**\n * @description whether the options can be searched\n */\n filterable?: boolean\n /**\n * @description customize search logic, the first parameter is `node`, the second is `keyword`, and need return a boolean value indicating whether it hits.\n */\n filterMethod?: (node: CascaderNode, keyword: string) => boolean\n /**\n * @description option label separator\n */\n separator?: string\n /**\n * @description whether to display all levels of the selected value in the input\n */\n showAllLevels?: boolean\n /**\n * @description whether to collapse tags in multiple selection mode\n */\n collapseTags?: boolean\n /**\n * @description The max tags number to be shown. To use this, collapse-tags must be true\n */\n maxCollapseTags?: number\n /**\n * @description whether show all selected tags when mouse hover text of collapse-tags. To use this, collapse-tags must be true\n */\n collapseTagsTooltip?: boolean\n /**\n * @description The max height of collapse tags tooltip, in pixels. To use this, collapse-tags-tooltip must be true\n */\n maxCollapseTagsTooltipHeight?: string | number\n /**\n * @description debounce delay when typing filter keyword, in milliseconds\n */\n debounce?: number\n /**\n * @description hook function before filtering with the value to be filtered as its parameter. If `false` is returned or a `Promise` is returned and then is rejected, filtering will be aborted\n */\n beforeFilter?: (value: string) => boolean | Promise<any>\n /**\n * @description position of dropdown\n */\n placement?: Placement\n /**\n * @description list of possible positions for dropdown\n */\n fallbackPlacements?: Placement[]\n /**\n * @description custom class name for Cascader's dropdown\n */\n popperClass?: CascaderClassType\n /**\n * @description custom style for Cascader's dropdown\n */\n popperStyle?: StyleValue\n /**\n * @description whether cascader popup is teleported\n */\n teleported?: boolean\n /**\n * @description tooltip theme, built-in theme: `dark` / `light`\n */\n effect?: PopperEffect\n /**\n * @description tag type\n */\n tagType?: TagProps['type']\n /**\n * @description tag effect\n */\n tagEffect?: TagProps['effect']\n /**\n * @description whether to trigger form validation\n */\n validateEvent?: boolean\n /**\n * @description when dropdown is inactive and `persistent` is `false`, dropdown will be destroyed\n */\n persistent?: boolean\n /**\n * @description Use `parent` when you want things tidy (like \"Entire Collection\" instead of listing 100 items)\n * Use `child` when every single item matters (like important settings)\n */\n showCheckedStrategy?: 'parent' | 'child'\n /**\n * @description whether to check or uncheck node when clicking on the node\n */\n checkOnClickNode?: boolean\n /**\n * @description whether to show the radio or checkbox prefix\n */\n showPrefix?: boolean\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `CascaderComponentProps` instead.\n */\nexport const cascaderProps = buildProps({\n ...CommonProps,\n /**\n * @description size of input\n */\n size: useSizeProp,\n /**\n * @description placeholder of input\n */\n placeholder: String,\n /**\n * @description whether Cascader is disabled\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description whether selected value can be cleared\n */\n clearable: Boolean,\n /**\n * @description custom clear icon component\n */\n clearIcon: {\n type: iconPropType,\n default: CircleClose,\n },\n /**\n * @description whether the options can be searched\n */\n filterable: Boolean,\n /**\n * @description customize search logic, the first parameter is `node`, the second is `keyword`, and need return a boolean value indicating whether it hits.\n */\n filterMethod: {\n type: definePropType<(node: CascaderNode, keyword: string) => boolean>(\n Function\n ),\n default: (node: CascaderNode, keyword: string) =>\n node.text.includes(keyword),\n },\n /**\n * @description option label separator\n */\n separator: {\n type: String,\n default: ' / ',\n },\n /**\n * @description whether to display all levels of the selected value in the input\n */\n showAllLevels: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether to collapse tags in multiple selection mode\n */\n collapseTags: Boolean,\n /**\n * @description The max tags number to be shown. To use this, collapse-tags must be true\n */\n maxCollapseTags: {\n type: Number,\n default: 1,\n },\n /**\n * @description whether show all selected tags when mouse hover text of collapse-tags. To use this, collapse-tags must be true\n */\n collapseTagsTooltip: Boolean,\n /**\n * @description The max height of collapse tags tooltip, in pixels. To use this, collapse-tags-tooltip must be true\n */\n maxCollapseTagsTooltipHeight: {\n type: [String, Number],\n },\n /**\n * @description debounce delay when typing filter keyword, in milliseconds\n */\n debounce: {\n type: Number,\n default: 300,\n },\n /**\n * @description hook function before filtering with the value to be filtered as its parameter. If `false` is returned or a `Promise` is returned and then is rejected, filtering will be aborted\n */\n beforeFilter: {\n type: definePropType<(value: string) => boolean | Promise<any>>(Function),\n default: () => true,\n },\n /**\n * @description position of dropdown\n */\n placement: {\n type: definePropType<Placement>(String),\n values: placements,\n default: 'bottom-start',\n },\n /**\n * @description list of possible positions for dropdown\n */\n fallbackPlacements: {\n type: definePropType<Placement[]>(Array),\n default: ['bottom-start', 'bottom', 'top-start', 'top', 'right', 'left'],\n },\n /**\n * @description custom class name for Cascader's dropdown\n */\n popperClass: useTooltipContentProps.popperClass,\n /**\n * @description custom style for Cascader's dropdown\n */\n popperStyle: useTooltipContentProps.popperStyle,\n /**\n * @description whether cascader popup is teleported\n */\n teleported: useTooltipContentProps.teleported,\n /**\n * @description tooltip theme, built-in theme: `dark` / `light`\n */\n effect: {\n type: definePropType<PopperEffect>(String),\n default: 'light',\n },\n /**\n * @description tag type\n */\n\n tagType: { ...tagProps.type, default: 'info' },\n /**\n * @description tag effect\n */\n tagEffect: { ...tagProps.effect, default: 'light' },\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description when dropdown is inactive and `persistent` is `false`, dropdown will be destroyed\n */\n persistent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Use `parent` when you want things tidy (like \"Entire Collection\" instead of listing 100 items)\n * Use `child` when every single item matters (like important settings)\n */\n showCheckedStrategy: {\n type: String,\n values: ['parent', 'child'],\n default: 'child',\n },\n /**\n * @description whether to check or uncheck node when clicking on the node\n */\n checkOnClickNode: Boolean,\n /**\n * @description whether to show the radio or checkbox prefix\n */\n showPrefix: {\n type: Boolean,\n default: true,\n },\n ...useEmptyValuesProps,\n})\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst emitChangeFn = (value: CascaderValue | null | undefined) => true\n\nexport const cascaderEmits = {\n [UPDATE_MODEL_EVENT]: emitChangeFn,\n [CHANGE_EVENT]: emitChangeFn,\n focus: (evt: FocusEvent) => evt instanceof FocusEvent,\n blur: (evt: FocusEvent) => evt instanceof FocusEvent,\n clear: () => true,\n visibleChange: (val: boolean) => isBoolean(val),\n expandChange: (val: CascaderValue) => !!val,\n removeTag: (val: CascaderNode['valueByOption']) => !!val,\n}\n\nexport type CascaderEmits = typeof cascaderEmits\n"],"mappings":";;;;;;;;;;;;;;;;AAoJA,MAAa,gBAAgB,WAAW;CACtC,GAAG;CAIH,MAAM;CAIN,aAAa;CAIb,UAAU;EACR,MAAM;EACN,SAAS;EACV;CAID,WAAW;CAIX,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAID,YAAY;CAIZ,cAAc;EACZ,MAAM,eACJ,SACD;EACD,U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