var t = require; var e = module; var i = exports; var s, o = (this && this.__decorate) || function(t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }; Object.defineProperty(i, "__esModule", { value: !0 }); const { ccclass: a, property: n, disallowMultiple: r, menu: l, executionOrder: h } = cc._decorator; ((e = s = s || {})[(e.NONE = 0)] = "NONE"), (e[(e.TOGGLE = 1)] = "TOGGLE"), (e[(e.SWITCH = 2)] = "SWITCH"); e = class extends cc.Component { constructor() { super(...arguments), (this.icon = null), (this.title = null), (this.selectedMode = s.NONE), (this.selectedFlag = null), (this.selectedSpriteFrame = null), (this._unselectedSpriteFrame = null), (this.adaptiveSize = !1), (this._selected = !1), (this._eventReg = !1); } set selected(e) { if (((this._selected = e), this.selectedFlag)) switch (this.selectedMode) { case s.TOGGLE: this.selectedFlag.active = e; break; case s.SWITCH: let t = this.selectedFlag.getComponent(cc.Sprite); t && (t.spriteFrame = e ? this.selectedSpriteFrame : this._unselectedSpriteFrame); } } get selected() { return this._selected; } get btnCom() { return this._btnCom || (this._btnCom = this.node.getComponent(cc.Button)), this._btnCom; } onLoad() { var t; this.selectedMode == s.SWITCH && ((t = this.selectedFlag.getComponent(cc.Sprite)), (this._unselectedSpriteFrame = t.spriteFrame)); } onDestroy() { this.node.off(cc.Node.EventType.SIZE_CHANGED, this._onSizeChange, this); } _registerEvent() { this._eventReg || (this.btnCom && 0 < this.list.selectedMode && this.btnCom.clickEvents.unshift(this.createEvt(this, "onClickThis")), this.adaptiveSize && this.node.on(cc.Node.EventType.SIZE_CHANGED, this._onSizeChange, this), (this._eventReg = !0)); } _onSizeChange() { this.list._onItemAdaptive(this.node); } createEvt(e, i, s = null) { if (e.isValid) { e.comName = e.comName || e.name .match(/\<(.*?)\>/g) .pop() .replace(/\<|>/g, ""); let t = new cc.Component.EventHandler(); return (t.target = s || e.node), (t.component = e.comName), (t.handler = i), t; } } showAni(t, e, i) { let s; switch (t) { case 0: s = [cc.scaleTo(0.2, 0.7), cc.moveBy(0.3, 0, 2 * this.node.height)]; break; case 1: s = [cc.scaleTo(0.2, 0.7), cc.moveBy(0.3, 2 * this.node.width, 0)]; break; case 2: s = [cc.scaleTo(0.2, 0.7), cc.moveBy(0.3, 0, -2 * this.node.height)]; break; case 3: s = [cc.scaleTo(0.2, 0.7), cc.moveBy(0.3, -2 * this.node.width, 0)]; break; default: s = [cc.scaleTo(0.3, 0.1)]; } (e || i) && s.push( cc.callFunc(() => { if (i) { this.list._delSingleItem(this.node); for (let t = this.list.displayData.length - 1; 0 <= t; t--) if (this.list.displayData[t].id == this.listId) { this.list.displayData.splice(t, 1); break; } } e(); }) ), this.node.runAction(cc.sequence(s)); } onClickThis() { this.list.selectedId = this.listId; } }; o([n({ type: cc.Sprite })], e.prototype, "icon", void 0), o([n({ type: cc.Node })], e.prototype, "title", void 0), o([n({ type: cc.Enum(s) })], e.prototype, "selectedMode", void 0), o( [ n({ type: cc.Node, visible() { return this.selectedMode > s.NONE; } }) ], e.prototype, "selectedFlag", void 0 ), o( [ n({ type: cc.SpriteFrame, visible() { return this.selectedMode == s.SWITCH; } }) ], e.prototype, "selectedSpriteFrame", void 0 ), o([n({})], e.prototype, "adaptiveSize", void 0), (e = o([a, r(), h(-5001)], e)), (i.default = e);