How to use the yox.array function in yox

To help you get started, we’ve selected a few yox 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 divawth / bell-ui / src / components / datepicker / components / DateMonth.ts View on Github external
isChecked(item: SimpleMonth) {
      const checkedTimestamps = this.get('checkedTimestamps')
      return Yox.array.has(checkedTimestamps, item.timestamp)
    }
  },
github divawth / bell-ui / dist / components / checkbox / Checkbox.js View on Github external
'change.checkboxGroup': function (event, data) {
            if (event.phase === Yox.Event.PHASE_DOWNWARD) {
                this.set({
                    checked: Yox.array.has(data.selected, this.get('value'))
                });
            }
        }
    },
github divawth / bell-ui / src / component / table / Table.ts View on Github external
data() {

    let sortKey = UNDEFINED
    let sortOrder = UNDEFINED

    Yox.array.each(
      this.get('columns'),
      function (item: any) {
        if (item.defaultSortOrder) {
          sortKey = item.key
          sortOrder = item.defaultSortOrder
        }
      }
    )

    return {
      SORT_ORDER_ASC,
      SORT_ORDER_DESC,

      colWidths: UNDEFINED,
      sortKey,
      sortOrder,
github divawth / bell-ui / src / component / upload / Upload.ts View on Github external
changeFiles(event: CustomEventInterface) {

      const files = Yox.array.toArray(
        (event.originalEvent.target as HTMLInputElement).files
      )

      this.upload(
        files.map(function (file) {
          return {
            file,
            id: ++guid,
          }
        })
      )

    }
github divawth / bell-ui / src / component / select / Select.ts View on Github external
deselectOption(value: any) {

      const me = this
      const values = me.get('value')

      if (me.get('multiple')) {

        const selectedIndex = Yox.is.array(values)
          ? Yox.array.indexOf(values, value)
          : -1

        if (selectedIndex < 0) {
          return
        }

        me.removeAt('value', selectedIndex)

      }
      else {

        if (values !== value) {
          return
        }

        me.set('value', UNDEFINED)
github divawth / bell-ui / src / component / checkbox / Checkbox.ts View on Github external
beforeCreate(options) {

    const props = options.props || (options.props = {})

    const checkboxGroup = findComponentUpward(options.parent, '${prefix}CheckboxGroup')
    if (checkboxGroup) {
      if (props.name === UNDEFINED) {
        props.name = checkboxGroup.get('name')
      }

      if (props.disabled === UNDEFINED) {
        props.disabled = checkboxGroup.get('disabled')
      }

      if (props.checked === UNDEFINED) {
        props.checked = Yox.array.has(checkboxGroup.get('value'), props.value)
      }
    }

  }
github divawth / bell-ui / src / components / util.ts View on Github external
return function (key: string, value: string) {
    if (!Yox.array.has(values, value)) {
      Yox.logger.warn(`${key} 期望是 ${values.join(',')} 中的值,实际传值 ${value}。`)
    }
    return true
  }
}
github divawth / bell-ui / src / component / checkbox / CheckboxGroup.ts View on Github external
'change.checkbox': function (event, data) {
      event.stop()

      const value = this.copy(this.get('value'))
      const { length } = value

      if (data.checked) {
        if (!Yox.array.has(value, data.value)) {
          value.push(data.value)
        }
      }
      else {
        Yox.array.remove(value, data.value)
      }

      if (value.length !== length) {
        this.set({ value })
      }
    }
  },
github divawth / bell-ui / src / components / tabs / Tabs.ts View on Github external
translateStyle() {
      let me = this
      let index = 0

      const tabs: Tab[] = me.get('tabsList')

      Yox.array.each(
        tabs,
        (item, key) => {
          if (item.id == me.get('value')) {
            index = key
            return FALSE
          }
        }
      )

      return index * (-100) + '%'
    }
  },
github divawth / bell-ui / src / component / select / Option.ts View on Github external
function isOptionSelected(values: any[] | any, value: any) {
  return Yox.is.array(values)
    ? Yox.array.has(values, value, FALSE)
    : values == value
}

yox

A lightweight mvvm framework

MIT
Latest version published 1 year ago

Package Health Score

49 / 100
Full package analysis