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AAC;YAED,OAAO;gBACL,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;gBACvC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;gBAElC,IAAI,gBAAgB;oBAAE,OAAO;gBAE7B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;YAED,eAAe;gBACb,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;oBACtB,IAAI,CAAC,OAAO,CAAC;wBACX,aAAa,EAAE,MAAM;qBACtB,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CAAA,CAAA;AA5GoB,aAAa;IADjC,WAAW,EAAE;GACO,aAAa,CA4GjC;eA5GoB,aAAa","file":"collapse-panel.js","sourcesContent":["import { SuperComponent, wxComponent, RelationsOptions } from '../common/src/index';\nimport config from '../common/config';\nimport props from './collapse-panel-props';\nimport type { TdCollapsePanelProps } from './type';\n\nconst { prefix } = config;\nconst name = `${prefix}-collapse-panel`;\n\nconst nextTick = () => new Promise((resolve) => setTimeout(resolve, 20));\n\nexport interface CollapsePanelProps extends TdCollapsePanelProps {}\n@wxComponent()\nexport default class CollapsePanel extends SuperComponent {\n externalClasses = [`${prefix}-class`];\n\n relations: RelationsOptions = {\n './collapse': {\n type: 'ancestor',\n linked(target: WechatMiniprogram.Component.TrivialInstance) {\n this.parent = target;\n const { value, defaultExpandAll, expandMutex, expandIcon, disabled } = target.properties;\n const activeValues = defaultExpandAll && !expandMutex ? [this.properties.value] : value;\n\n this.setData({\n ultimateExpandIcon: expandIcon || this.properties.expandIcon,\n ultimateDisabled: this.properties.disabled == null ? disabled : this.properties.disabled,\n });\n this.updateExpanded(activeValues);\n },\n },\n };\n\n properties = props;\n\n data = {\n contentHeight: 0,\n expanded: false,\n classPrefix: name,\n classBasePrefix: prefix,\n ultimateExpandIcon: false,\n ultimateDisabled: false,\n };\n\n methods = {\n set(data: Record<string, object | any>) {\n this.setData(data);\n\n return new Promise((resolve) => wx.nextTick(resolve));\n },\n updateExpanded(activeValues) {\n if (!this.parent) {\n return Promise.resolve()\n .then(nextTick)\n .then(() => {\n const data: Record<string, boolean | string> = { transition: true };\n if (this.data.expanded) {\n data.contentHeight = 'auto';\n }\n this.setData(data);\n });\n }\n\n const { value } = this.properties;\n const expanded = activeValues.includes(value);\n\n if (expanded === this.properties.expanded) return;\n\n this.setData({ expanded });\n this.updateStyle(expanded);\n },\n getRect(selector: string, all?: boolean): Promise<WechatMiniprogram.BoundingClientRectCallbackResult> {\n return new Promise((resolve) => {\n wx.createSelectorQuery()\n .in(this as WechatMiniprogram.Component.TrivialInstance)\n [all ? 'selectAll' : 'select'](selector)\n .boundingClientRect((rect) => {\n if (all && Array.isArray(rect) && rect.length) {\n resolve(rect);\n }\n\n if (!all && rect) {\n resolve(rect);\n }\n })\n .exec();\n });\n },\n updateStyle(expanded: boolean) {\n return this.getRect(`.${name}__content`)\n .then((rect: WechatMiniprogram.BoundingClientRectCallbackResult) => rect.height)\n .then((height: number) => {\n if (expanded) {\n return this.set({\n contentHeight: height ? `${height}px` : 'auto',\n });\n }\n\n return this.set({ contentHeight: `${height}px` })\n .then(nextTick)\n .then(() => this.set({ contentHeight: 0 }));\n });\n },\n\n onClick() {\n const { ultimateDisabled } = this.data;\n const { value } = this.properties;\n\n if (ultimateDisabled) return;\n\n this.parent.switch(value);\n },\n\n onTransitionEnd() {\n if (this.data.expanded) {\n this.setData({\n contentHeight: 'auto',\n });\n }\n },\n };\n}\n"]}