UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 3.33 kB
{"version":3,"file":"collapse.mjs","sources":["../../../../../../packages/components/collapse/src/collapse.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isArray,\n isNumber,\n isString,\n mutable,\n} from '@element-plus/utils'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type { Arrayable, Awaitable } from '@element-plus/utils'\n\nexport type CollapseActiveName = string | number\nexport type CollapseModelValue = Arrayable<CollapseActiveName>\n\nexport type CollapseIconPositionType = 'left' | 'right'\n\nexport const emitChangeFn = (value: CollapseModelValue) =>\n isNumber(value) || isString(value) || isArray(value)\n\nexport interface CollapseProps {\n /**\n * @description whether to activate accordion mode\n */\n accordion?: boolean\n /**\n * @description currently active panel, the type is `string` in accordion mode, otherwise it is `array`\n */\n modelValue?: CollapseModelValue\n /**\n * @description set expand icon position\n */\n expandIconPosition?: CollapseIconPositionType\n /**\n * @description before-collapse hook before the collapse state changes. If `false` is returned or a `Promise` is returned and then is rejected, will stop collapsing\n */\n beforeCollapse?: (name: CollapseActiveName) => Awaitable<boolean>\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `CollapseProps` instead.\n */\nexport const collapseProps = buildProps({\n /**\n * @description whether to activate accordion mode\n */\n accordion: Boolean,\n /**\n * @description currently active panel, the type is `string` in accordion mode, otherwise it is `array`\n */\n modelValue: {\n type: definePropType<CollapseModelValue>([Array, String, Number]),\n default: () => mutable([] as const),\n },\n /**\n * @description set expand icon position\n */\n expandIconPosition: {\n type: definePropType<CollapseIconPositionType>([String]),\n default: 'right',\n },\n /**\n * @description before-collapse hook before the collapse state changes. If `false` is returned or a `Promise` is returned and then is rejected, will stop collapsing\n */\n beforeCollapse: {\n type: definePropType<(name: CollapseActiveName) => Awaitable<boolean>>(\n Function\n ),\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `CollapseProps` instead.\n */\nexport type CollapsePropsPublic = ExtractPublicPropTypes<typeof collapseProps>\n\nexport const collapseEmits = {\n [UPDATE_MODEL_EVENT]: emitChangeFn,\n [CHANGE_EVENT]: emitChangeFn,\n}\nexport type CollapseEmits = typeof collapseEmits\n"],"names":[],"mappings":";;;;;;AAkBO,MAAM,YAAA,GAAe,CAAC,KAAA,KAC3B,QAAA,CAAS,KAAK,KAAK,QAAA,CAAS,KAAK,CAAA,IAAK,OAAA,CAAQ,KAAK;AAwB9C,MAAM,gBAAgB,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAItC,SAAA,EAAW,OAAA;AAAA;AAAA;AAAA;AAAA,EAIX,UAAA,EAAY;AAAA,IACV,MAAM,cAAA,CAAmC,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAM,CAAC,CAAA;AAAA,IAChE,OAAA,EAAS,MAAM,OAAA,CAAQ,EAAW;AAAA,GACpC;AAAA;AAAA;AAAA;AAAA,EAIA,kBAAA,EAAoB;AAAA,IAClB,IAAA,EAAM,cAAA,CAAyC,CAAC,MAAM,CAAC,CAAA;AAAA,IACvD,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,cAAA,EAAgB;AAAA,IACd,IAAA,EAAM,cAAA;AAAA,MACJ;AAAA;AACF;AAEJ,CAAU;AAOH,MAAM,aAAA,GAAgB;AAAA,EAC3B,CAAC,kBAAkB,GAAG,YAAA;AAAA,EACtB,CAAC,YAAY,GAAG;AAClB;;;;"}