{"version":3,"file":"property_controller-DhvkFRWb.js","sources":["../../../app/javascript/controllers/artifact/entity/property_controller.js"],"sourcesContent":["import ApplicationController from \"@/controllers/application_controller\"\n\nexport default class extends ApplicationController {\n static values = {\n value: String,\n }\n\n static targets = [\n 'placeholderButton',\n 'inputSection',\n 'input',\n 'star'\n ]\n\n edit() {\n this.show(this.inputSectionTarget)\n this.hide(this.placeholderButtonTarget)\n\n this.focus(this.inputTarget, { moveCursorToEnd: true })\n\n const observer = new IntersectionObserver((entries) => {\n const [entry] = entries\n if (!entry.isIntersecting) {\n this.element.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }\n\n observer.disconnect()\n }, {\n threshold: 1.0\n })\n\n observer.observe(this.element)\n }\n\n restore() {\n this.hide(this.inputSectionTarget)\n this.show(this.placeholderButtonTarget)\n\n this.inputTarget.value = this.valueValue\n }\n\n save() {\n if(this.hasInputTarget) {\n this.valueValue = this.inputTarget.value\n }\n\n if(this.hasInputSectionTarget) {\n this.hide(this.inputSectionTarget)\n this.show(this.placeholderButtonTarget)\n\n this.placeholderButtonTarget.textContent = this.valueValue || t.actions.click_to_add\n }\n }\n\n onClickOutside({ target }) {\n if(!this.hasInputSectionTarget || this.isInvisible(this.inputSectionTarget) || this.element.contains(target)) return\n this.save()\n }\n\n saveValueFromOption({ currentTarget }) {\n this.valueValue = currentTarget.dataset.optionValue\n }\n\n valueValueChanged() {\n if(this.hasPlaceholderButtonTarget) {\n if(this.valueValue) {\n this.removeClass(this.placeholderButtonTarget, 'text-night-60')\n this.addClass(this.placeholderButtonTarget, 'font-medium')\n } else {\n this.removeClass(this.placeholderButtonTarget, 'font-medium')\n this.addClass(this.placeholderButtonTarget, 'text-night-60')\n }\n }\n\n if(!this.element.hasAttribute('data-required')) return\n\n if(this.valid) {\n this.element.setAttribute('data-valid', true)\n } else {\n this.element.removeAttribute('data-valid')\n }\n\n this.dispatch('validation', {\n prefix: 'property',\n })\n }\n\n markAsRequired() {\n this.show(this.starTarget)\n\n this.element.setAttribute('data-required', 'true')\n this.element.setAttribute('data-artifact--entity--form-target', 'requiredProperty')\n\n this.dispatch('validation', {\n prefix: 'property',\n })\n }\n\n markAsOptional() {\n this.hide(this.starTarget)\n\n this.element.removeAttribute('data-required')\n this.element.removeAttribute('data-artifact--entity--form-target')\n\n this.dispatch('validation', {\n prefix: 'property',\n })\n }\n\n get valid() {\n return this.valueValue\n }\n\n get kindValue() {\n return this.element.dataset.kind\n }\n}\n"],"names":["PropertyController","ApplicationController","observer","entries","entry","target","currentTarget","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAYjD,MAAO,CACL,KAAK,KAAK,KAAK,kBAAkB,EACjC,KAAK,KAAK,KAAK,uBAAuB,EAEtC,KAAK,MAAM,KAAK,YAAa,CAAE,gBAAiB,EAAM,CAAA,EAEtD,MAAMC,EAAW,IAAI,qBAAsBC,GAAY,CACrD,KAAM,CAACC,CAAK,EAAID,EACXC,EAAM,gBACT,KAAK,QAAQ,eAAe,CAAE,SAAU,SAAU,MAAO,QAAU,CAAA,EAGrEF,EAAS,WAAU,CACzB,EAAO,CACD,UAAW,CACZ,CAAA,EAEDA,EAAS,QAAQ,KAAK,OAAO,CACjC,CAEE,SAAU,CACR,KAAK,KAAK,KAAK,kBAAkB,EACjC,KAAK,KAAK,KAAK,uBAAuB,EAEtC,KAAK,YAAY,MAAQ,KAAK,UAClC,CAEE,MAAO,CACF,KAAK,iBACN,KAAK,WAAa,KAAK,YAAY,OAGlC,KAAK,wBACN,KAAK,KAAK,KAAK,kBAAkB,EACjC,KAAK,KAAK,KAAK,uBAAuB,EAEtC,KAAK,wBAAwB,YAAc,KAAK,YAAc,EAAE,QAAQ,aAE9E,CAEE,eAAe,CAAE,OAAAG,GAAU,CACtB,CAAC,KAAK,uBAAyB,KAAK,YAAY,KAAK,kBAAkB,GAAK,KAAK,QAAQ,SAASA,CAAM,GAC3G,KAAK,KAAI,CACb,CAEE,oBAAoB,CAAE,cAAAC,GAAiB,CACrC,KAA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