diff --git a/public/js/components/Form/Input.js b/public/js/components/Form/Input.js index 62c6217e6..35ddf1fee 100644 --- a/public/js/components/Form/Input.js +++ b/public/js/components/Form/Input.js @@ -27,6 +27,7 @@ export default { name: String, containerClass: [String, Array, Object], label: String, + labelClass: [String, Array, Object], // NOTE(chris): remove these from $attrs array to prevent doubled event listeners onInput: [Array, Function], 'onUpdate:modelValue': [Array, Function], @@ -63,7 +64,7 @@ export default { if (this.noAutoClass) return this.acc; - const acc = {...this.acc}; + const acc = { ...this.acc }; if (this.inputGroup) acc['input-group-item'] = true; @@ -78,6 +79,31 @@ export default { } return acc; }, + alc() { + if (!this.labelClass || !this.label) + return {}; + if (typeof this.labelClass === 'string' || this.labelClass instanceof String) + return this.labelClass.split(' ').reduce((a,c) => {a[c] = true; return a}, {}); + if (Array.isArray(this.labelClass)) + return this.labelClass.reduce((a,c) => {a[c] = true; return a}, {}); + return this.labelClass; + }, + autoLabelClass() { + if (!this.label) + return {}; + + if (this.noAutoClass) + return this.alc; + + const alc = { ...this.alc }; + + if (this.lcType == 'radio' || this.lcType == 'checkbox') + alc['form-check-label'] = true; + else + alc['form-label'] = true; + + return alc; + }, lcType() { if (!this.type) return 'text'; @@ -243,7 +269,7 @@ export default { }, template: ` - +