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AAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;YAChC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;gBACpB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;oBACjC,IAAI,EAAE,KAAK;iBACZ,CAAC,CAAC;gBACH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aAC7B;YACD,IAAI,SAAS,KAAK,GAAG,EAAE;gBACrB,IAAI,CAAC,OAAO,CAAC;oBACX,SAAS,EAAE,CAAC,CAAC;iBACd,CAAC,CAAC;aACJ;iBAAM;gBACL,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;gBAC1B,IAAI,CAAC,OAAO,CAAC;oBACX,SAAS,EAAE,GAAG;iBACf,CAAC,CAAC;gBACH,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;oBAC3B,IAAI,EAAE,IAAI;iBACX,CAAC,CAAC;gBACH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aAC7B;QACH,CAAC;KACF;IACD,KAAK;QACH,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;CACF,CAAC,CAAC","file":"dropdown-menu.js","sourcesContent":["import TComponent from '../common/component';\nimport config from '../common/config';\n\nconst { prefix } = config;\nconst name = `${prefix}-dropdown-menu`;\n\nTComponent({\n properties: {\n overlay: {\n type: Boolean,\n value: true,\n },\n duration: {\n type: Number,\n value: 200,\n },\n closeOnClickOverlay: {\n type: Boolean,\n value: true,\n },\n },\n data: {\n classBasePrefix: prefix,\n classPrefix: name,\n nodes: null,\n menus: null,\n activeIdx: -1,\n bottom: 0,\n },\n relations: {\n './dropdown-item': {\n type: 'child',\n },\n },\n methods: {\n _getAllItems() {\n const nodes = this.getRelationNodes('./dropdown-item');\n const menus = nodes.map((a) => {\n const { title, disabled } = a.data;\n return { title, disabled };\n });\n this.setData({\n nodes,\n menus,\n });\n },\n _toggleDropdown(e) {\n const idx = e.target.dataset.index;\n const { activeIdx } = this.data;\n if (activeIdx !== -1) {\n this.triggerEvent('close');\n this.data.nodes[activeIdx].setData({\n show: false,\n });\n this.triggerEvent('closed');\n }\n if (activeIdx === idx) {\n this.setData({\n activeIdx: -1,\n });\n } else {\n this.triggerEvent('open');\n this.setData({\n activeIdx: idx,\n });\n this.data.nodes[idx].setData({\n show: true,\n });\n this.triggerEvent('opened');\n }\n },\n },\n ready() {\n this._getAllItems();\n },\n});\n"]}
|