1 |
- {"version":3,"sources":["../src/collapse/collapse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAe,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGpF,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAK7D,MAAM,WAAW,aAAc,SAAQ,eAAe;CAAG;AAGzD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,cAAc;IAClD,OAAO;;MAEL;IAEF,eAAe,WAAuB;IAEtC,SAAS,EAAE,gBAAgB,CAOzB;IAEF,eAAe;;;QAKb;IAEF,UAAU,kBAAS;IAEnB,IAAI;;MAEF;IAEF,SAAS;;MAIP;IAEF,OAAO;;;MAuBL;CACH","file":"collapse.d.ts","sourcesContent":["import { SuperComponent, wxComponent, RelationsOptions } from '../common/src/index';\nimport config from '../common/config';\nimport props from './props';\nimport type { CollapseValue, TdCollapseProps } from './type';\n\nconst { prefix } = config;\nconst name = `${prefix}-collapse`;\n\nexport interface CollapseProps extends TdCollapseProps {}\n\n@wxComponent()\nexport default class Collapse extends SuperComponent {\n options = {\n addGlobalClass: true,\n };\n\n externalClasses = [`${prefix}-class`];\n\n relations: RelationsOptions = {\n './collapse-panel': {\n type: 'descendant',\n linked() {\n // this.updateExpanded();\n },\n },\n };\n\n controlledProps = [\n {\n key: 'value',\n event: 'change',\n },\n ];\n\n properties = props;\n\n data = {\n classPrefix: name,\n };\n\n observers = {\n 'value, expandMutex '() {\n this.updateExpanded();\n },\n };\n\n methods = {\n updateExpanded() {\n const panels = this.getRelationNodes('./collapse-panel');\n\n if (panels.length === 0) return;\n\n panels.forEach((child: WechatMiniprogram.Component.TrivialInstance) => {\n child.updateExpanded(this.properties.value);\n });\n },\n switch(panelValue: CollapseValue) {\n const { expandMutex, value: activeValues } = this.properties;\n let value = [];\n const hit = activeValues.indexOf(panelValue);\n\n if (hit > -1) {\n value = activeValues.filter((item) => item !== panelValue);\n } else {\n value = expandMutex ? [panelValue] : activeValues.concat(panelValue);\n }\n\n this._trigger('change', { value });\n },\n };\n}\n"]}
|