How to use the heyui/src/utils/utils.toggleValue function in heyui

To help you get started, we’ve selected a few heyui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heyui / heyui / src / components / menu / menu.vue View on Github external
trigger(data) {
      if (data.type == 'togglemenuEvent') {
        let menu = data.data;
        this.status.opened = utils.toggleValue(this.status.opened, menu.key);

        // accordion
        if (this.accordion && this.status.opened.indexOf(menu.key) > -1) {
          for (let key in this.menuobj) {
            let mo = this.menuobj[key];
            if (mo.parent === menu.parent && menu.key != key && this.status.opened.indexOf(mo.key) > -1) {
              this.status.opened.splice(this.status.opened.indexOf(mo.key), 1);
            }
          }
        }

        this.$emit('click', menu);
        let isParent = menu.children && menu.children.length > 0;
        if (isParent && (!this.activeAll || this.status.selected == menu.key)) {
          return;
        }
github heyui / heyui / src / components / checkbox / checkbox.vue View on Github external
if (this.disabled || (option && option.disabled)) return;
      let value = null;
      if (this.isSingle) {
        if (!utils.isNull(this.value)) {
          value = utils.toggleValue(this.checkList, this.value);
        } else if (!utils.isNull(this.checkStatus)) {
          value = this.isChecked ? this.falseValue : this.trueValue;
        } else if (this.checked === true) {
          value = this.checked;
        } else {
          value = this.isChecked ? this.falseValue : this.trueValue;
        }
      } else {
        value = utils.copy(this.checkStatus);
        let key = option[this.key];
        value = utils.toggleValue(value, key);
        if (this.limit && this.limit < value.length) {
          Message.error(this.t('h.checkbox.limitSize', { limitSize: this.limit }));
          return;
        }
      }
      this.$emit('change', value);
      this.$emit('input', value);
      let event = document.createEvent('CustomEvent');
      event.initCustomEvent('setvalue', true, true, value);
      this.$el.dispatchEvent(event);
    },
    check(key) {
github heyui / heyui / src / components / select / select.vue View on Github external
setvalue(option, trigger) {
      if (this.disabled) return;
      if (option.disabled || option.isLabel) return;
      let code = option[this.keyName];
      if (this.multiple) {
        if (!utils.isNull(this.limit) && !this.isIncludes(code) && this.codes.length >= this.limit) {
          Message.error(this.t('h.select.limitSize', { limitSize: this.limit }));
          return;
        }
        this.codes = utils.toggleValue(this.codes, code);
      } else {
        this.codes = code;
      }
      this.setObjects();
      let value = this.type == 'key' ? this.codes : this.objects;
      this.$emit('input', value);
      this.$emit('change', this.objects);
      let event = document.createEvent('CustomEvent');
      event.initCustomEvent('setvalue', true, true, this.objects);
      this.$el.dispatchEvent(event);
      this.nowSelected = -1;
      if (this.multiple) {
        this.searchInput = '';
        this.$nextTick(() => {
          this.dropdown.update();
        });
github heyui / heyui / src / components / checkbox / checkbox.vue View on Github external
setvalue(option) {
      if (this.disabled || (option && option.disabled)) return;
      let value = null;
      if (this.isSingle) {
        if (!utils.isNull(this.value)) {
          value = utils.toggleValue(this.checkList, this.value);
        } else if (!utils.isNull(this.checkStatus)) {
          value = this.isChecked ? this.falseValue : this.trueValue;
        } else if (this.checked === true) {
          value = this.checked;
        } else {
          value = this.isChecked ? this.falseValue : this.trueValue;
        }
      } else {
        value = utils.copy(this.checkStatus);
        let key = option[this.key];
        value = utils.toggleValue(value, key);
        if (this.limit && this.limit < value.length) {
          Message.error(this.t('h.checkbox.limitSize', { limitSize: this.limit }));
          return;
        }
      }