{ "version": 3, "sources": ["focus_management_controller-7bb89328.js"], "sourcesContent": ["import { Controller } from \"@hotwired/stimulus\"\n\nfunction getFirstFocusableFrom(target) {\n const matches = target.querySelectorAll('button, [href], input, [tabindex=\"0\"]')\n\n if (matches.length > 0) {\n return matches[0]\n }\n\n return null\n}\n\nexport default class extends Controller {\n static targets = [ \"autofocus\", \"autofocusWithin\" ]\n\n autofocusTargetConnected(target) {\n target.focus()\n }\n\n autofocusWithinTargetConnected(target) {\n const firstFocusable = getFirstFocusableFrom(target)\n \n if (firstFocusable) {\n firstFocusable.focus()\n }\n }\n\n markForRestoration({ target }) {\n this.focusRestorationElement = target\n }\n\n restoreFocus({ detail: { success } }) {\n if (this.focusRestorationElement && this.focusRestorationElement.isConnected && !success) {\n this.focusRestorationElement.focus()\n }\n\n // Don't bring this in until we need it\n // this.dispatch('focusRestored')\n }\n}\n"], "mappings": "wKAAA,gDAEA,WAA+B,EAAQ,CACrC,KAAM,GAAU,EAAO,iBAAiB,uCAAuC,EAE/E,MAAI,GAAQ,OAAS,EACZ,EAAQ,GAGV,IACT,CAEA,qBAAO,SAAsB,EAAW,CAGtC,yBAAyB,EAAQ,CAC/B,EAAO,MAAM,CACf,CAEA,+BAA+B,EAAQ,CACrC,KAAM,GAAiB,EAAsB,CAAM,EAEnD,AAAI,GACF,EAAe,MAAM,CAEzB,CAEA,mBAAmB,CAAE,UAAU,CAC7B,KAAK,wBAA0B,CACjC,CAEA,aAAa,CAAE,OAAQ,CAAE,YAAa,CACpC,AAAI,KAAK,yBAA2B,KAAK,wBAAwB,aAAe,CAAC,GAC/E,KAAK,wBAAwB,MAAM,CAKvC,CACF,CA1BS,EADT,EACS,UAAU,CAAE,YAAa,iBAAkB", "names": [] }