UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 6 kB
{"version":3,"file":"config.mjs","sources":["../../../../../../packages/components/cascader-panel/src/config.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { NOOP, buildProps, definePropType } from '@element-plus/utils'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\n\nimport type { PropType } from 'vue'\nimport type {\n CascaderConfig,\n CascaderNodePathValue,\n CascaderOption,\n CascaderProps,\n CascaderValue,\n RenderLabel,\n} from './types'\n\nexport interface CascaderCommonProps {\n /**\n * @description specify which key of node object is used as the node's value\n */\n modelValue?: CascaderValue | null\n /**\n * @description data of the options, the key of `value` and `label` can be customize by `CascaderProps`.\n */\n options?: CascaderOption[]\n /**\n * @description configuration options, see the following `CascaderProps` table.\n */\n props?: CascaderProps\n}\n\nexport const CommonProps = buildProps({\n /**\n * @description specify which key of node object is used as the node's value\n */\n modelValue: {\n type: definePropType<CascaderValue | null>([Number, String, Array, Object]),\n },\n /**\n * @description data of the options, the key of `value` and `label` can be customize by `CascaderProps`.\n */\n options: {\n type: definePropType<CascaderOption[]>(Array),\n default: () => [] as CascaderOption[],\n },\n /**\n * @description configuration options, see the following `CascaderProps` table.\n */\n props: {\n type: definePropType<CascaderProps>(Object),\n default: () => ({}) as CascaderProps,\n },\n} as const)\n\nexport interface CascaderPanelProps extends CascaderCommonProps {\n border?: boolean\n renderLabel?: RenderLabel\n}\n\nexport const DefaultProps: CascaderConfig = {\n /**\n * @description trigger mode of expanding options\n */\n expandTrigger: 'click',\n /**\n * @description whether multiple selection is enabled\n */\n multiple: false,\n /**\n * @description whether checked state of a node not affects its parent and child nodes\n */\n checkStrictly: false, // whether all nodes can be selected\n /**\n * @description when checked nodes change, whether to emit an array of node's path, if false, only emit the value of node.\n */\n emitPath: true, // wether to emit an array of all levels value in which node is located\n /**\n * @description whether to dynamic load child nodes, use with `lazyload` attribute\n */\n lazy: false,\n /**\n * @description method for loading child nodes data, only works when `lazy` is true\n */\n lazyLoad: NOOP,\n /**\n * @description specify which key of node object is used as the node's value\n */\n value: 'value',\n /**\n * @description specify which key of node object is used as the node's label\n */\n label: 'label',\n /**\n * @description specify which key of node object is used as the node's children\n */\n children: 'children',\n /**\n * @description specify which key of node object is used as the node's leaf\n */\n leaf: 'leaf',\n /**\n * @description specify which key of node object is used as the node's disabled\n */\n disabled: 'disabled',\n /**\n * @description hover threshold of expanding options\n */\n hoverThreshold: 500,\n /**\n * @description whether to check or uncheck node when clicking on the node\n */\n checkOnClickNode: false,\n /**\n * @description whether to check or uncheck node when clicking on leaf node (last children).\n */\n checkOnClickLeaf: true,\n /**\n * @description whether to show the radio or checkbox prefix\n */\n showPrefix: true,\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `CascaderPanelProps` instead.\n */\nexport const cascaderPanelProps = buildProps({\n ...CommonProps,\n border: {\n type: Boolean,\n default: true,\n },\n renderLabel: {\n type: Function as PropType<RenderLabel>,\n },\n})\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst emitChangeFn = (value: CascaderValue | undefined | null) => true\n\nexport const cascaderPanelEmits = {\n [UPDATE_MODEL_EVENT]: emitChangeFn,\n [CHANGE_EVENT]: emitChangeFn,\n close: () => true,\n 'expand-change': (value: CascaderNodePathValue) => value,\n}\n\nexport const useCascaderConfig = (props: { props: CascaderProps }) => {\n return computed(() => ({\n ...DefaultProps,\n ...props.props,\n }))\n}\n"],"names":[],"mappings":";;;;;AA6BO,MAAM,cAAc,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAIpC,UAAA,EAAY;AAAA,IACV,MAAM,cAAA,CAAqC,CAAC,QAAQ,MAAA,EAAQ,KAAA,EAAO,MAAM,CAAC;AAAA,GAC5E;AAAA;AAAA;AAAA;AAAA,EAIA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,eAAiC,KAAK,CAAA;AAAA,IAC5C,OAAA,EAAS,MAAM;AAAC,GAClB;AAAA;AAAA;AAAA;AAAA,EAIA,KAAA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