@nextcloud/vue
Version:
Nextcloud vue components
1 lines • 2.31 kB
Source Map (JSON)
{"version":3,"file":"actionGlobal-cda46023.mjs","sources":["../../src/mixins/actionGlobal.js"],"sourcesContent":["/**\n * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport Vue from 'vue'\n\nexport default {\n\tbefore() {\n\t\t// all actions requires a valid text content\n\t\t// if none, forbid the component mount and throw error\n\t\tif (!this.$slots.default || this.text.trim() === '') {\n\t\t\tVue.util.warn(`${this.$options.name} cannot be empty and requires a meaningful text content`, this)\n\t\t\tthis.$destroy()\n\t\t\tthis.$el.remove()\n\t\t}\n\t},\n\n\tbeforeUpdate() {\n\t\tthis.text = this.getText()\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t// $slots are not reactive.\n\t\t\t// We need to update the content manually\n\t\t\ttext: this.getText(),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tisLongText() {\n\t\t\treturn this.text && this.text.trim().length > 20\n\t\t},\n\t},\n\n\tmethods: {\n\t\tgetText() {\n\t\t\treturn this.$slots.default ? this.$slots.default[0].text.trim() : ''\n\t\t},\n\t},\n}\n"],"names":["ActionGlobalMixin","Vue"],"mappings":";AAuBA,MAAeA,IAAA,EACd,SAAS;GAGJ,CAAC,KAAK,OAAO,WAAW,KAAK,KAAK,KAAM,MAAK,QAChDC,EAAI,KAAK,KAAK,GAAG,KAAK,SAAS,+DAA+D,IAAI,GAClG,KAAK,SAAU,GACf,KAAK,IAAI,OAAQ;AAElB,GAED,eAAe;AACd,OAAK,OAAO,KAAK,QAAS;AAC1B,GAED,OAAO;AACN,SAAO,EAGN,MAAM,KAAK,QAAS,EACpB;AACD,GAED,UAAU,EACT,aAAa;AACZ,SAAO,KAAK,QAAQ,KAAK,KAAK,KAAI,EAAG,SAAS;AAC9C,EACD,GAED,SAAS,EACR,UAAU;AACT,SAAO,KAAK,OAAO,UAAU,KAAK,OAAO,QAAQ,CAAC,EAAE,KAAK,KAAM,IAAG;AAClE,EACD,EACF;"}