Vue.component("size-capacity-box", { props: ["v-name", "v-value", "v-count", "v-unit", "size", "maxlength", "v-supported-units"], data: function () { let v = this.vValue if (v == null) { v = { count: this.vCount, unit: this.vUnit } } if (typeof (v["count"]) != "number") { v["count"] = -1 } let vSize = this.size if (vSize == null) { vSize = 6 } let vMaxlength = this.maxlength if (vMaxlength == null) { vMaxlength = 10 } let supportedUnits = this.vSupportedUnits if (supportedUnits == null) { supportedUnits = [] } return { capacity: v, countString: (v.count >= 0) ? v.count.toString() : "", vSize: vSize, vMaxlength: vMaxlength, supportedUnits: supportedUnits } }, watch: { "countString": function (newValue) { let value = newValue.trim() if (value.length == 0) { this.capacity.count = -1 this.change() return } let count = parseInt(value) if (!isNaN(count)) { this.capacity.count = count } this.change() } }, methods: { change: function () { this.$emit("change", this.capacity) } }, template: `