1 |
- {"version":3,"sources":["../../src/mixins/proxyable.ts"],"names":[],"mappings":";;AAAA,OAAO,GAAP,MAAoC,KAApC;AASA,OAAM,SAAU,OAAV,GAEY;AAAA,QADhB,IACgB,uEADT,OACS;AAAA,QAAhB,KAAgB,uEAAR,QAAQ;;AAEhB,WAAO,IAAI,MAAJ,CAAW;AAChB,cAAM,WADU;AAGhB,eAAO;AACL,sBADK;AAEL;AAFK,SAHS;AAQhB,mCACG,IADH,EACU;AACN,sBAAU;AADJ,SADV,CARgB;AAchB,YAdgB,kBAcZ;AACF,mBAAO;AACL,mCAAmB,KAAK,IAAL;AADd,aAAP;AAGD,SAlBe;;AAoBhB,kBAAU;AACR,2BAAe;AACb,mBADa,iBACV;AACD,2BAAO,KAAK,iBAAZ;AACD,iBAHY;AAIb,mBAJa,eAIR,GAJQ,EAIA;AACX,wBAAI,QAAQ,KAAK,iBAAjB,EAAoC;AAEpC,yBAAK,iBAAL,GAAyB,GAAzB;AAEA,yBAAK,KAAL,CAAW,KAAX,EAAkB,GAAlB;AACD;AAVY;AADP,SApBM;AAmChB,mCACG,IADH,YACU,GADV,EACa;AACT,iBAAK,iBAAL,GAAyB,GAAzB;AACD,SAHH;AAnCgB,KAAX,CAAP;AAyCD;AAED;AACA,IAAM,YAAY,SAAlB;AAEA,eAAe,SAAf","sourcesContent":["import Vue, { VueConstructor } from 'vue'\n\n/* eslint-disable-next-line no-use-before-define */\nexport type Proxyable<T extends string = 'value'> = VueConstructor<Vue & {\n internalLazyValue: unknown\n internalValue: unknown\n} & Record<T, any>>\n\nexport function factory<T extends string = 'value'> (prop?: T, event?: string): Proxyable<T>\nexport function factory (\n prop = 'value',\n event = 'change'\n) {\n return Vue.extend({\n name: 'proxyable',\n\n model: {\n prop,\n event\n },\n\n props: {\n [prop]: {\n required: false\n }\n },\n\n data () {\n return {\n internalLazyValue: this[prop] as unknown\n }\n },\n\n computed: {\n internalValue: {\n get (): unknown {\n return this.internalLazyValue\n },\n set (val: any) {\n if (val === this.internalLazyValue) return\n\n this.internalLazyValue = val\n\n this.$emit(event, val)\n }\n }\n },\n\n watch: {\n [prop] (val) {\n this.internalLazyValue = val\n }\n }\n })\n}\n\n/* eslint-disable-next-line no-redeclare */\nconst Proxyable = factory()\n\nexport default Proxyable\n"],"sourceRoot":""}
|