UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 12.7 kB
{"version":3,"file":"cascader.mjs","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 { Component, 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'\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?: string | Component\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"],"names":[],"mappings":";;;;;;;;;;;;AAmJO,MAAM,gBAAgB,UAAA,CAAW;AAAA,EACtC,GAAG,WAAA;AAAA;AAAA;AAAA;AAAA,EAIH,IAAA,EAAM,WAAA;AAAA;AAAA;AAAA;AAAA,EAIN,WAAA,EAAa,MAAA;AAAA;AAAA;AAAA;AAAA,EAIb,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,OAAA;AAAA,IACN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