form-field-textarea.js 860 Bytes
Component({
	properties: {
		field: {
			type: Object,
			value: {}
		},
		value: {
			type: String,
			value: ''
		},
		disabled: {
			type: Boolean,
			value: false
		},
		error: {
			type: String,
			value: ''
		},
		groupKey: { type: String, value: '' },
		rowIndex: { type: Number, value: -1 }
	},
	data: {
		currentLength: 0
	},
	observers: {
		value: function (value) {
			this.setData({
				currentLength: (value || '').length
			})
		}
	},
	methods: {
		onInput(e) {
			if (this.data.disabled) return
			const detail = { key: this.data.field.key, value: e.detail.value }
			if (this.properties.groupKey) {
				detail.groupKey = this.properties.groupKey
				const rowIndex = Number(this.properties.rowIndex)
				if (!Number.isNaN(rowIndex) && rowIndex >= 0) {
					detail.rowIndex = rowIndex
				}
			}
			this.triggerEvent('change', detail)
		}
	}
})