{"version":3,"file":"property_controller-BBq8Asoo.js","sources":["../../../app/javascript/controllers/artifact/blueprint/property_controller.js"],"sourcesContent":["import SortableItemController from \"@/controllers/sortable/item_controller\"\n\nexport default class extends SortableItemController {\n static values = {\n kind: String,\n name: String,\n unique: { type: Boolean, default: false },\n required: { type: Boolean, default: false },\n builtin: { type: Boolean, default: false },\n position: Number,\n }\n\n static targets = [\n 'nameInput',\n 'kindInput',\n 'uniquenessInput',\n 'uniquenessLabel',\n 'uniqueButton',\n 'removeUniquenessButton',\n 'requiredLabel',\n 'requireButton',\n 'removeRequiredButton',\n 'requiredInput',\n 'nameSection',\n 'nameButton',\n 'settings',\n 'sortButton',\n 'positionInput',\n ]\n\n connect() {\n if(!this.positionValue) {\n this.positionValue = this.element.closest('[data-controller*=\"sortable--list\"]').children.length + 1\n }\n\n super.connect()\n }\n\n editName() {\n if(this.builtinValue) return\n\n this.show(this.nameInputTarget)\n this.hide(this.nameSectionTarget)\n\n this.focus(this.nameInputTarget, { moveCursorToEnd: true })\n\n this.element.querySelector('[data-error-container]')?.classList.add('hidden')\n }\n\n cancelNameEdit() {\n this.hide(this.nameInputTarget)\n this.show(this.nameSectionTarget)\n\n this.nameInputTarget.value = this.nameValue\n\n this.element.querySelector('[data-error-container]')?.classList.remove('hidden')\n }\n\n saveName() {\n if(this.builtinValue) return\n\n if(this.nameInputTarget.value !== this.nameValue) {\n this.element.querySelector('[data-error-container]')?.remove()\n } else {\n this.element.querySelector('[data-error-container]')?.classList.remove('hidden')\n }\n\n this.nameValue = this.nameInputTarget.value\n\n this.hide(this.nameInputTarget)\n this.show(this.nameSectionTarget)\n }\n\n toggleUniqueness() {\n this.uniqueValue = !this.uniqueValue\n }\n\n toggleRequired() {\n this.requiredValue = !this.requiredValue\n }\n\n enableSorting() {\n this.enable()\n\n this.handleTarget.classList.remove('hidden')\n this.settingsTarget.classList.add('hidden')\n\n this.element.classList.add('cursor-move')\n }\n\n sorted() {\n this.disable()\n\n this.handleTarget.classList.add('hidden')\n this.settingsTarget.classList.remove('hidden')\n\n this.element.classList.remove('cursor-move')\n }\n\n disableSorting({ target }) {\n if(this.disabled || this.element.contains(target)) return\n this.sorted()\n }\n\n abortSorting() {\n if(this.disabled) return\n\n this.sorted()\n }\n\n sortable() {\n this.show(this.sortButtonTarget)\n }\n\n unsortable() {\n this.hide(this.sortButtonTarget)\n }\n\n updatePosition({ detail: newPosition }) {\n if(isNaN(parseInt(newPosition))) {\n this.positionValue = Array.from(this.element.closest('[data-controller*=\"sortable--list\"]').children).indexOf(this.element) + 1\n } else {\n this.positionValue = newPosition\n }\n }\n\n showOptions() {\n this.show(this.settingsTarget)\n }\n\n hideOptions() {\n this.hide(this.settingsTarget)\n }\n\n onClickOutside({ target }) {\n if(this.builtinValue || this.isInvisible(this.nameInputTarget) || this.element.contains(target)) return;\n this.saveName()\n }\n\n kindValueChanged() {\n if(this.builtinValue) return\n\n this.kindInputTarget.value = this.kindValue\n\n if(['address', 'array', 'boolean', 'date'].includes(this.kindValue)) {\n if(this.hasUniqueButtonTarget) {\n this.hide(this.uniqueButtonTarget)\n }\n\n if(this.hasRemoveUniquenessButtonTarget) {\n this.hide(this.removeUniquenessButtonTarget)\n }\n }\n }\n\n uniqueValueChanged() {\n if(this.builtinValue || ['address', 'array', 'boolean', 'date'].includes(this.kindValue)) return\n\n if(this.uniqueValue) {\n this.show(this.uniquenessLabelTarget, this.removeUniquenessButtonTarget)\n this.hide(this.uniqueButtonTarget)\n } else {\n this.hide(this.uniquenessLabelTarget, this.removeUniquenessButtonTarget)\n this.show(this.uniqueButtonTarget)\n }\n\n this.uniquenessInputTarget.value = this.uniqueValue\n }\n\n requiredValueChanged() {\n if(this.builtinValue) return\n\n if(this.requiredValue) {\n this.show(this.requiredLabelTarget, this.removeRequiredButtonTarget)\n this.hide(this.requireButtonTarget)\n } else {\n this.hide(this.requiredLabelTarget, this.removeRequiredButtonTarget)\n this.show(this.requireButtonTarget)\n }\n\n this.requiredInputTarget.value = this.requiredValue\n }\n\n nameValueChanged() {\n if(this.builtinValue) return\n\n this.nameInputTarget.value = this.nameValue\n this.nameButtonTarget.textContent = this.nameValue || t.properties.kinds[this.kindValue]\n }\n\n positionValueChanged() {\n if(!this.positionValue) return\n\n console.log(this.positionValue)\n this.positionInputTarget.value = this.positionValue\n }\n\n delete() {\n this.element.remove()\n }\n}\n"],"names":["property_controller","SortableItemController","_a","_b","target","newPosition","__publicField"],"mappings":"sNAEe,MAAKA,UAASC,CAAuB,CA4BlD,SAAU,CACJ,KAAK,gBACP,KAAK,cAAgB,KAAK,QAAQ,QAAQ,qCAAqC,EAAE,SAAS,OAAS,GAGrG,MAAM,QAAO,CACjB,CAEE,UAAW,OACN,KAAK,eAER,KAAK,KAAK,KAAK,eAAe,EAC9B,KAAK,KAAK,KAAK,iBAAiB,EAEhC,KAAK,MAAM,KAAK,gBAAiB,CAAE,gBAAiB,EAAM,CAAA,GAE1DC,EAAA,KAAK,QAAQ,cAAc,wBAAwB,IAAnD,MAAAA,EAAsD,UAAU,IAAI,UACxE,CAEE,gBAAiB,OACf,KAAK,KAAK,KAAK,eAAe,EAC9B,KAAK,KAAK,KAAK,iBAAiB,EAEhC,KAAK,gBAAgB,MAAQ,KAAK,WAElCA,EAAA,KAAK,QAAQ,cAAc,wBAAwB,IAAnD,MAAAA,EAAsD,UAAU,OAAO,SAC3E,CAEE,UAAW,SACN,KAAK,eAEL,KAAK,gBAAgB,QAAU,KAAK,WACrCA,EAAA,KAAK,QAAQ,cAAc,wBAAwB,IAAnD,MAAAA,EAAsD,UAEtDC,EAAA,KAAK,QAAQ,cAAc,wBAAwB,IAAnD,MAAAA,EAAsD,UAAU,OAAO,UAGzE,KAAK,UAAY,KAAK,gBAAgB,MAEtC,KAAK,KAAK,KAAK,eAAe,EAC9B,KAAK,KAAK,KAAK,iBAAiB,EACpC,CAEE,kBAAmB,CACjB,KAAK,YAAc,CAAC,KAAK,WAC7B,CAEE,gBAAiB,CACf,KAAK,cAAgB,CAAC,KAAK,a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