{"version":3,"file":"list_controller-DO9n_ufK.js","sources":["../../../app/javascript/controllers/mentions/list_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static targets = ['item']\n\n filter({ detail: query }) {\n this.itemTargets.forEach((item) => {\n if (item.dataset.searchable.startsWith(query.toLowerCase())) {\n this.show(item)\n item.setAttribute('data-arrow-navigatable', '')\n } else {\n this.hide(item)\n item.removeAttribute('data-arrow-navigatable')\n }\n })\n\n if(this.visibleItems.length > 0) {\n this.show()\n\n this.dispatch('arrow:navigate', {\n target: this.element,\n detail: this.visibleItems[0]\n })\n } else {\n this.hide()\n }\n }\n\n saveMention({ currentTarget }) {\n if(!this.isEditing) {\n return this.dispatch('save', {\n detail: currentTarget\n })\n }\n\n if(this.editedUserId === currentTarget.dataset.id) {\n this.closeByEscape()\n } else {\n this.dispatch('update', {\n detail: {\n id: this.editedUserId,\n element: currentTarget\n }\n })\n }\n }\n\n edit({ detail: userId }) {\n this.itemTargets.forEach((item) => {\n this.show(item)\n item.setAttribute('data-arrow-navigatable', '')\n\n if(item.dataset.id === userId) {\n this.dispatch('arrow:navigate', {\n target: this.element,\n detail: item\n })\n }\n })\n\n this.isEditing = true\n this.editedUserId = userId\n\n this.element.setAttribute('data-arrow-navigation-enabled-value', true)\n this.show()\n }\n\n closeByEscape() {\n if(this.isInvisible() || !this.isEditing) return\n\n this.hide()\n this.dispatch('closed')\n\n this.isEditing = false\n this.editedUserId = null\n }\n\n // private\n\n get visibleItems() {\n return this.itemTargets.filter(this.isVisible)\n }\n}\n"],"names":["list_controller","ApplicationController","query","item","currentTarget","userId","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAGjD,OAAO,CAAE,OAAQC,GAAS,CACxB,KAAK,YAAY,QAASC,GAAS,CAC7BA,EAAK,QAAQ,WAAW,WAAWD,EAAM,YAAW,CAAE,GACxD,KAAK,KAAKC,CAAI,EACdA,EAAK,aAAa,yBAA0B,EAAE,IAE9C,KAAK,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