{"version":3,"file":"form_controller-DoO1HH-V.js","sources":["../../../app/javascript/controllers/action/form_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static targets = [\n 'nameInput',\n 'displayInput',\n ]\n\n connect() {\n if(this.hasDisplayInputTarget) {\n this.focus(this.displayInputTarget, { moveCursorToEnd: true })\n }\n\n super.connect()\n }\n\n setNameFromDisplayName() {\n if(!this.displayInputTarget.value) {\n return this.nameInputTarget.value = ''\n }\n\n this.nameInputTarget.value = this.displayInputTarget.value\n this.format()\n }\n\n format() {\n const tokens = this.nameInputTarget.value.split(/[.\\s_]+/)\n\n if(!this.nameInputTarget.value) return\n\n if(tokens.length === 1) {\n return this.nameInputTarget.value = tokens[0].toLowerCase()\n }\n\n const object = tokens[0]\n const scopes = tokens.slice(1)\n\n this.nameInputTarget.value = `${object}.${scopes.join('_')}`\n .replace(/\\.{2,}/g, \".\")\n .replace(/_{2,}/g, \"_\")\n .replace(/-{2,}/g, \"-\")\n .toLowerCase()\n }\n\n removeTrailingDotsAndUnderscores() {\n this.nameInputTarget.value = this.nameInputTarget.value.replace(/[._-]+$/, '')\n }\n}\n"],"names":["form_controller","ApplicationController","tokens","object","scopes","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAMjD,SAAU,CACL,KAAK,uBACN,KAAK,MAAM,KAAK,mBAAoB,CAAE,gBAAiB,EAAM,CAAA,EAG/D,MAAM,QAAO,CACjB,CAEE,wBAAyB,CACvB,GAAG,CAAC,KAAK,mBAAmB,MAC1B,OAAO,KAAK,gBAAgB,MAAQ,GAGtC,KAAK,gBAAgB,MAAQ,KAAK,mBAAmB,MACrD,KAAK,OAAM,CACf,CAEE,QAAS,CACP,MAAMC,EAAS,KAAK,gBAAgB,MAAM,MAAM,SAAS,EAEzD,GAAG,CAAC,KAAK,gBAAgB,MAAO,OAEhC,GAAGA,EAAO,SAAW,EACnB,OAAO,KAAK,gBAAgB,MAAQA,EAAO,CAAC,EAAE,YAAW,EAG3D,MAAMC,EAASD,EAAO,CAAC,EACjBE,EAASF,EAAO,MAAM,CAAC,EAE7B,KAAK,gBAAgB,MAAQ,GAAGC,CAAM,IAAIC,EAAO,KAAK,GAAG,CAAC,GACvD,QAAQ,UAAW,GAAG,EACtB,QAAQ,SAAU,GAAG,EACrB,QAAQ,SAAU,GAAG,EACrB,YAAW,CAClB,CAEE,kCAAmC,CACjC,KAAK,gBAAgB,MAAQ,KAAK,gBAAgB,MAAM,QAAQ,UAAW,EAAE,CACjF,CACA,CA5CEC,EADkBL,EACX,UAAU,CACf,YACA,cACJ"}