1 line
5.3 KiB
Plaintext
1 line
5.3 KiB
Plaintext
|
{"version":3,"file":"relation.js","sources":["../../../../../../../src/uni_modules/lime-painter/components/common/relation.js"],"sourcesContent":["const styles = (v ='') => v.split(';').filter(v => v && !/^[\\n\\s]+$/.test(v)).map(v => {\r\n\t\t\t\t\t\tconst key = v.slice(0, v.indexOf(':'))\r\n\t\t\t\t\t\tconst value = v.slice(v.indexOf(':')+1)\r\n\t\t\t\t\t\treturn {\r\n\t\t\t\t\t\t\t[key\r\n\t\t\t\t\t\t\t\t.replace(/-([a-z])/g, function() { return arguments[1].toUpperCase()})\r\n\t\t\t\t\t\t\t\t.replace(/\\s+/g, '')\r\n\t\t\t\t\t\t\t]: value.replace(/^\\s+/, '').replace(/\\s+$/, '') || ''\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t})\r\nexport function parent(parent) {\r\n\treturn {\r\n\t\tprovide() {\r\n\t\t\treturn {\r\n\t\t\t\t[parent]: this\r\n\t\t\t}\r\n\t\t},\r\n\t\tdata() {\r\n\t\t\treturn {\r\n\t\t\t\tel: {\r\n\t\t\t\t\tid: null,\r\n\t\t\t\t\tcss: {},\r\n\t\t\t\t\tviews: []\r\n\t\t\t\t},\r\n\t\t\t}\r\n\t\t},\r\n\t\twatch: {\r\n\t\t\tcss: { \r\n\t\t\t\thandler(v) {\r\n\t\t\t\t\tif(this.canvasId) {\r\n\t\t\t\t\t\tthis.el.css = (typeof v == 'object' ? v : v && Object.assign(...styles(v))) || {}\r\n\t\t\t\t\t\tthis.canvasWidth = this.el.css && this.el.css.width || this.canvasWidth\r\n\t\t\t\t\t\tthis.canvasHeight = this.el.css && this.el.css.height || this.canvasHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t\timmediate: true\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nexport function children(parent, options = {}) {\r\n\tconst indexKey = options.indexKey || 'index'\r\n\treturn {\r\n\t\tinject: {\r\n\t\t\t[parent]: {\r\n\t\t\t\tdefault: null\r\n\t\t\t}\r\n\t\t},\r\n\t\twatch: {\r\n\t\t\tel: {\r\n\t\t\t\thandler(v, o) {\r\n\t\t\t\t\tif(JSON.stringify(v) != JSON.stringify(o))\r\n\t\t\t\t\t\tthis.bindRelation()\r\n\t\t\t\t},\r\n\t\t\t\tdeep: true,\r\n\t\t\t\timmediate: true\r\n\t\t\t},\r\n\t\t\tsrc: {\r\n\t\t\t\thandler(v, o) {\r\n\t\t\t\t\tif(v != o)\r\n\t\t\t\t\t\tthis.bindRelation()\r\n\t\t\t\t},\r\n\t\t\t\timmediate: true\r\n\t\t\t},\r\n\t\t\ttext: {\r\n\t\t\t\thandler(v, o) {\r\n\t\t\t\t\tif(v != o) this.bindRelation()\r\n\t\t\t\t},\r\n\t\t\t\timmediate: true\r\n\t\t\t},\r\n\t\t\tcss: {\r\n\t\t\t\thandler(v, o) {\r\n\t\t\t\t\tif(v != o)\r\n\t\t\t\t\t\tthis.el.css = (typeof v == 'object' ? v : v && Object.assign(...styles(v))) || {}\r\n\t\t\t\t},\r\n\t\t\t\timmediate: true\r\n\t\t\t},\r\n\t\t\treplace: {\r\n\t\t\t\thandler(v, o) {\r\n\t\t\t\t\tif(JSON.stringify(v) != JSON.stringify(o))\r\n\t\t\t\t\t\tthis.bindRelation()\r\n\t\t\t\t},\r\n\t\t\t\tdeep: true,\r\n\t\t\t\timmediate: true\r\n\t\t\t}\r\n\t\t},\r\n\t\tcreated() {\r\n\t\t\tif(!this._uid) {\r\n\t\t\t\tthis._uid = this._.uid\r\n\t\t\t}\r\n\t\t\tObject.defineProperty(this, 'parent', {\r\n\t\t\t\tget: () => this[parent] || [],\r\n\t\t\t})\r\n\t\t\tObject.defineProperty(this, 'index', {\r\n\t\t\t\tget: () => {\r\n\t\t\t\t\tthis.bindRelation();\r\n\t\t\t\t\tconst {parent: {el: {views=[]}={}}={}} = this\r\n\t\t\t\t\treturn views.indexOf(this.el)\r\n\t\t\t\t},\r\n\t\t\t});\r\n\t\t\tthis.el.type = this.type\r\n\t\t\tif(this.uid) {\r\n\t\t\t\tthis.el.uid = this.uid\r\n\t\t\t}\r\n\t\t\tthis.bindRelation()\r\n\t\t},\r\n\t\t// #ifdef VUE3\r\n\t\tbeforeUnmount() {\r\n\t\t\tthis.removeEl()\r\n\t\t},\r\n\t\t// #endif\r\n\t\t// #ifdef VUE2\r\n\t\tbeforeDestroy() {\r\n\t\t\tthis.removeEl()\r\n\t\t},\r\n\t\t// #endif\r\n\t\tmethods: {\r\n\t\t\tremoveEl() {\r\n\t\t\t\tif (this.parent) {\r\n\t\t\t\t\tthis.parent.el.views = this.parent.el.views.filter(\r\n\t\t\t\t\t\t(item) => item._uid !== this._uid\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tbindRelation() {\r\n\t\t\t\tif(!this.el._uid) {\r\n\t\t\t\t\tthis.el._uid = this._uid \r\n\t\t\t\t}\r\n\t\t\t\tif(['text','qrcode'].includes(this.type)) {\r\n\t\t\t\t\tthis.el.text = this.$slots && this.$slots.default && this.$slots.default[0].text || `${this.text || ''}`.replace(/\\\\n/g, '\\n')\r\n\t\t\t\t}\r\n\t\t\t\tif(this.type == 'image') {\r\n\t\t\t\t\tthis.el.src = this.src\r\n\t\t\t\t}\r\n\t\t\t\tif (!this.parent) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tlet views = this.parent.el.views || [];\r\n\t\t\t\tif(views.indexOf(this.el) !== -1)
|