| | |
| | | linked(parent) { |
| | | const { value, disabled, borderless } = parent.data; |
| | | const valueSet = new Set(value); |
| | | const checkedFromParent = valueSet.has(this.data.value); |
| | | const data = { |
| | | disabled: disabled || this.data.disabled, |
| | | _disabled: this.data.disabled == null ? disabled : this.data.disabled, |
| | | }; |
| | | if (borderless) { |
| | | data.borderless = true; |
| | | } |
| | | data.checked = valueSet.has(this.data.value); |
| | | data.checked = this.data.checked || checkedFromParent; |
| | | if (this.data.checked) { |
| | | parent.updateValue(this.data); |
| | | } |
| | | if (this.data.checkAll) { |
| | | data.checked = valueSet.size > 0; |
| | | } |
| | |
| | | this.properties = Object.assign(Object.assign({}, Props), { theme: { |
| | | type: String, |
| | | value: 'default', |
| | | }, borderless: { |
| | | type: Boolean, |
| | | value: false, |
| | | } }); |
| | | this.data = { |
| | | prefix, |
| | | classPrefix: name, |
| | | _disabled: false, |
| | | }; |
| | | this.observers = { |
| | | disabled(v) { |
| | | this.setData({ _disabled: v }); |
| | | }, |
| | | }; |
| | | this.controlledProps = [ |
| | | { |
| | |
| | | }, |
| | | ]; |
| | | this.methods = { |
| | | onChange(e) { |
| | | const { disabled, readonly } = this.data; |
| | | if (disabled || readonly) |
| | | return; |
| | | handleTap(e) { |
| | | const { _disabled, readonly, contentDisabled } = this.data; |
| | | const { target } = e.currentTarget.dataset; |
| | | const { contentDisabled } = this.data; |
| | | if (target === 'text' && contentDisabled) { |
| | | if (_disabled || readonly || (target === 'text' && contentDisabled)) |
| | | return; |
| | | } |
| | | const { value, label } = this.data; |
| | | const checked = !this.data.checked; |
| | | const parent = this.$parent; |
| | | if (parent) { |
| | | parent.updateValue(Object.assign(Object.assign({}, this.data), { checked })); |
| | | } |
| | | else { |
| | | this._trigger('change', { checked }); |
| | | this._trigger('change', { context: { value, label }, checked }); |
| | | } |
| | | }, |
| | | setDisabled(disabled) { |
| | | this.setData({ |
| | | _disabled: this.data.disabled || disabled, |
| | | }); |
| | | }, |
| | | }; |
| | | } |
| | | }; |