How to use the @pluginjs/utils.arrayEqual function in @pluginjs/utils

To help you get started, we’ve selected a few @pluginjs/utils 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 pluginjs / pluginjs / modules / choice / src / main.js View on Github external
set(value) {
    if (
      this.value === value ||
      (isArray(value) && arrayEqual(this.value, value))
    ) {
      if (this.$options.length !== 0) {
        return
      }
      if (this.options.multiple) {
        this.$element.value = this.options.process.call(this, this.value)
      } else {
        this.$element.value = this.value
      }
      return
    }

    this.value = value
    // this.$element.value = this.value

    this.$items.forEach($item => {
github pluginjs / pluginjs / modules / cascader / src / main.js View on Github external
set(value, trigger = true, update = true) {
    value = this.purifyValue(value)
    if (!arrayEqual(value, this.value)) {
      if (update) {
        if (value.length === 0) {
          let level = this.value.length - 1
          this.value.reverse().forEach(v => {
            this.unselect(level, v, trigger, false)
            level--
          })
        } else {
          let level = 0
          value.forEach(v => {
            this.select(level, v, trigger, true)
            level++
          })
        }
      }
github pluginjs / pluginjs / modules / list / src / main.js View on Github external
set(data) {
    if (isArray(data) && !arrayEqual(data, this.data)) {
      this.data = this.processData(data)
      this.buildItems()
      this.element.value = this.val()
      this.trigger(EVENTS.CHANGE, this.val())
    }
  }
github pluginjs / pluginjs / modules / multi-select / src / main.js View on Github external
set(value, trigger) {
    value = this.purifyValue(value)
    if (!arrayEqual(value, this.value)) {
      const unselected = arrayDiff(this.value, value)
      const selected = arrayDiff(value, this.value)
      this.value = value
      selected.forEach(v => this.select(v, trigger, false))
      unselected.forEach(v => this.unselect(v, trigger, false))

      this.setValueForElement(value)

      if (this.DROPDOWN) {
        this.DROPDOWN.update()
      }

      if (value.length === 0) {
        removeClass(this.classes.SELECTED, this.$wrap)

        if (trigger) {
github pluginjs / pluginjs / modules / paginator / src / components / list.js View on Github external
update(trigger = false) {
    const oldPages = this.visiblePages
    const newPages = this.getVisiblePages()
    const items = this.items
    if (this.currentPage !== this.instance.currentPage || trigger) {
      items.map(item => removeClass(this.instance.classes.ACTIVE, item))
    }

    if (!arrayEqual(oldPages, newPages)) {
      const itemTemplate = templateEngine.compile(
        this.options.templates.item.call(this)
      )
      const start = FilterFromData(this.options.itemAttr, oldPages[0], items)[0]
      let end = FilterFromData(
        this.options.itemAttr,
        oldPages[oldPages.length - 1],
        items
      )[0]
      if (this.hasPrev()) {
        if (this.prev) {
          this.prev.remove()
        }
        this.prev = parseHTML(this.generatePrev())
        insertAfter(this.prev, items[0])
      } else if (this.prev) {