UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 8.64 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 {\n CascaderNode,\n CascaderValue,\n} from '@element-plus/components/cascader-panel'\nimport type { Placement, PopperEffect } from '@element-plus/components/popper'\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\n// Type name is taken(cascader-panel/src/node), needs discussion\n// export type CascaderProps = ExtractPropTypes<typeof cascaderProps>\n\nexport type CascaderEmits = typeof cascaderEmits\n"],"names":[],"mappings":";;;;;;;;;;;;AAoBO,MAAM,gBAAgB,UAAW,CAAA;AAAA,EACtC,GAAG,WAAA;AAAA,EAIH,IAAM,EAAA,WAAA;AAAA,EAIN,WAAa,EAAA,MAAA;AAAA,EAIb,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA,CAAA;AAAA,GACX;AAAA,EAIA,SAAW,EAAA,OAAA;AAAA,EAIX,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,YAAA;AAAA,IACN,OAAS,EAAA,WAAA;AAAA,GACX;AAAA,EAIA,UAAY,EAAA,OAAA;AAAA,EAIZ,YAAc,EAAA;AAAA,IACZ,IAAM,EAAA,cAAA;AAAA,MACJ,QAAA;AAAA,KACF;AAAA,IACA,SAAS,CAAC,IAAA,EAAoB,YAC5B,IAAK,CAAA,IAAA,CAAK,SAAS,OAAO,CAAA;AAAA,GAC9B;AAAA,EAIA,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,aAAe,EAAA;AAAA,IACb,IAAM,E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