{"version":3,"file":"property_controller-DKC9K1L-.js","sources":["../../../app/javascript/controllers/contact/property_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nimport { useLineNotifiers } from '../mixins/useLineNotifiers'\n\nexport default class extends ApplicationController {\n static values = {\n url: String,\n persisted: { type: Boolean, default: false },\n property: String,\n placement: { type: String, default: \"bottom-start\" },\n current: { type: String, default: \"\" },\n error: { type: Boolean, default: false }\n }\n\n static targets = [\"input\", \"button\", \"form\", \"container\", \"menu\", \"overrideCheckbox\"]\n\n initialize() {\n super.initialize()\n this.currentValue ||= this.inputTarget.value\n }\n\n connect() {\n super.connect()\n useLineNotifiers(this)\n }\n\n disconnect() {\n this.disconnectLineFromThisElement()\n super.disconnect()\n }\n\n focus() {\n this.buttonTarget.classList.add(this.invisibleClass)\n this.containerTarget.classList.remove(\"hidden\")\n\n super.focus(this.inputTarget, { moveCursorToEnd: true })\n\n this.nextTick(() => {\n this.moveLineToThisElement()\n }, 0)\n }\n\n blur(dispatchMouseLeaveEvent = true) {\n this.buttonTarget.classList.remove(this.invisibleClass)\n this.containerTarget.classList.add(\"hidden\")\n\n if(this.currentValue && this.errorValue) {\n this.buttonTarget.querySelector('button[data-placeholder]').innerText = this.currentValue\n }\n\n if(this.hasError || this.errorValue) {\n this.unsetError()\n }\n\n if(dispatchMouseLeaveEvent === true) {\n this.onLineMouseLeave()\n }\n\n if(this.hasMenuTarget) {\n this.menuTarget.classList.add('hidden')\n }\n\n if(this.hasOverrideCheckbox) {\n this.overrideCheckboxTarget.checked = false\n }\n }\n\n restore() {\n if(!this.persistedValue) {\n this.currentValue = ''\n }\n\n this.inputTarget.value = this.currentValue\n this.blur(false)\n\n if(this.hasError || this.errorValue) {\n this.unsetError()\n }\n\n this.blurLine()\n\n if(this.hasMenuTarget) {\n this.menuTarget.classList.add('hidden')\n }\n\n if(this.hasOverrideCheckbox) {\n this.overrideCheckboxTarget.checked = false\n }\n }\n\n onSubmitEnd() {\n this.element.querySelectorAll(\"input\").forEach((input) => {\n input.readOnly = false\n })\n }\n\n // private\n\n unsetError() {\n this.inputTarget.classList.remove('error')\n\n this.element.querySelector('[data-error]').remove()\n this.errorValue = false\n\n if(this.hasMenuTarget) {\n this.menuTarget.classList.add('hidden')\n }\n }\n\n withinBoundaries(e) {\n return this.containerTarget.classList.contains(\"hidden\")\n || this.buttonTarget.contains(e.target)\n || e.target === this.inputTarget\n || this.containerTarget.contains(e.target)\n || e.target === this.buttonTarget\n }\n\n get invisibleClass() {\n return \"hidden\"\n }\n\n get hasError() {\n return this.element.querySelector('[data-error]')\n }\n\n get unsetClasses() {\n return ['text-night-60', 'italic']\n }\n}\n"],"names":["PropertyController","ApplicationController","useLineNotifiers","dispatchMouseLeaveEvent","input","__publicField"],"mappings":"qQAIe,MAAKA,UAASC,CAAsB,CAYjD,YAAa,CACX,MAAM,WAAU,EAChB,KAAK,eAAL,KAAK,aAAiB,KAAK,YAAY,MAC3C,CAEE,SAAU,CACR,MAAM,QAAO,EACbC,EAAiB,IAAI,CACzB,CAEE,YAAa,CACX,KAAK,8BAA6B,EAClC,MAAM,WAAU,CACpB,CAEE,OAAQ,CACN,KAAK,aAAa,UAAU,IAAI,KAAK,cAAc,EACnD,KAAK,gBAAgB,UAAU,OAAO,QAAQ,EAE9C,MAAM,MAAM,KAAK,YAAa,CAAE,gBAAiB,EAAM,CAAA,EAEvD,KAAK,SAAS,IAAM,CAClB,KAAK,sBAAqB,CAChC,EAAO,CAAC,CACR,CAEE,KAAKC,EAA0B,GAAM,CACnC,KAAK,aAAa,UAAU,OAAO,KAAK,cAAc,EACtD,KAAK,gBAAgB,UAAU,IAAI,QAAQ,EAExC,KAAK,cAAgB,KAAK,aAC3B,KAAK,aAAa,cAAc,0BAA0B,EAAE,UAAY,KAAK,eAG5E,KAAK,UAAY,KAAK,aACvB,KAAK,WAAU,EAGdA,IAA4B,IAC7B,KAAK,iBAAgB,EAGpB,KAAK,eACN,KAAK,WAAW,UAAU,IAAI,QAAQ,EAGrC,KA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