How to use the yox.is 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 / component / textarea / Textarea.ts View on Github external
textareaStyle() {

      let size = this.get('size')
      let autoSize = this.get('autoSize')

      // 单行的高度
      const ROW_HEIGHT = fontSizes[size] * 1.5

      // 上下 padding + border
      const PADDING_VERTICAL = 2 * (1 + sizes[size])

      if (autoSize) {
        let rows = this.get('rows')
        let value = this.get('value')
        if (Yox.is.object(autoSize)) {
          rows = value ? value.split('\n').length : autoSize.minRows
          return `min-height: ${autoSize.minRows * ROW_HEIGHT + PADDING_VERTICAL}px;max-height: ${autoSize.maxRows * ROW_HEIGHT + PADDING_VERTICAL}px;height: ${rows * ROW_HEIGHT + PADDING_VERTICAL}px;`
        }

        rows = value ? value.split('\n').length : 1
        return `min-height: ${ROW_HEIGHT + PADDING_VERTICAL}px;height: ${rows * ROW_HEIGHT + PADDING_VERTICAL}px;`
      }

      return `height: ${this.get('rows') * ROW_HEIGHT + PADDING_VERTICAL}px;`

    }
  },
github divawth / bell-ui / src / components / form / util / validate.ts View on Github external
}
      }
      else {
        // 默认必传
        if (rule.required !== false) {
          errorReason = 'required'
        }
        else {
          continue
        }
      }

      if (errorReason) {

        let message = messages && messages[key] && messages[key][errorReason]
        if (Yox.is.string(message)) {
          errors[key] = message
        }
        else {
          errors[key] = errorReason
        }

      }

    }

    if (Object.keys(errors).length > 0) {
      return errors
    }

  }
}
github divawth / bell-ui / src / component / input-number / InputNumber.ts View on Github external
upDisabled(): boolean {
      const max = this.get('max')
      return Yox.is.numeric(max)
        && max - this.get('value') < this.get('step')
    },
    downDisabled(): boolean {
github divawth / bell-ui / src / components / datepicker / components / DateMonth.ts View on Github external
data(options) {
    const props = options.props || {}
    let date = props.defaultDate
    if (!date) {
      if (Yox.is.array(props.checkedDate)) {
        date = props.checkedDate[0]
      }
      else {
        date = props.checkedDate
      }
    }
    return {
      type: RAW_TYPE_MONTH,
      RAW_TYPE_YEAR,
      RAW_TYPE_MONTH,

      year: (toDate(date) || new Date()).getFullYear(),
    }
  },
github divawth / bell-ui / dist / components / grid / Col.js View on Github external
getClass: function (name, data) {
            var classArr = [];
            if (Yox.is.object(data)) {
                if (data.span) {
                    classArr.push('${prefix}col-' + name + '-' + data.span);
                }
                if (data.order) {
                    classArr.push('${prefix}col-' + name + '-order-' + data.order);
                }
                if (data.offset) {
                    classArr.push('${prefix}col-' + name + '-offset-' + data.offset);
                }
                if (data.push) {
                    classArr.push('${prefix}col-' + name + '-push-' + data.push);
                }
                if (data.pull) {
                    classArr.push('${prefix}col-' + name + '-pull-' + data.pull);
                }
            }
github divawth / bell-ui / dist / components / page / Page.js View on Github external
var onKeydown = function (event) {
            var currentPage = +me.get('currentPage');
            var current = me.get('current');
            var count = me.get('count');
            switch (event.originalEvent.keyCode) {
                case 40:
                    current = current + 1 > count ? count : current + 1;
                    break;
                case 38:
                    current = current > 1 ? current - 1 : 1;
                    break;
                case 13:
                    if (Yox.is.number(currentPage)
                        && currentPage > 0
                        && currentPage <= count) {
                        current = currentPage;
                    }
                    break;
            }
            me.set({
                current: current,
                currentPage: current
            });
        };
        Yox.dom.on(doc, 'keydown', onKeydown);
github divawth / bell-ui / dist / components / message / Message.js View on Github external
var addMessage = function (type, arg) {
    var data = {};
    data.type = type;
    if (Yox.is.string(arg)) {
        data.content = arg;
    }
    else {
        Yox.object.extend(data, arg);
        Yox.object.extend(data, config);
    }
    add(data);
};
var updateConfig = function (data) {
github divawth / bell-ui / src / component / input-number / InputNumber.ts View on Github external
down() {
      const min = this.get('min')
      const step = this.get('step')
      this.decrease(
        'value',
        toNumber(step),
        Yox.is.numeric(min) ? +min : UNDEFINED
      )
    },
    handleFocus() {
github divawth / bell-ui / src / component / collapse / Collapse.ts View on Github external
'open.collapseItem': function (event, data) {
      if (event.phase === Yox.Event.PHASE_UPWARD) {
        event.stop()

        let { name, opened } = data

        let value = this.get('value')

        if (this.get('accordion')) {
          value = opened ? name : UNDEFINED
        }
        else {
          value = Yox.is.array(value) ? this.copy(value) : []
          if (opened) {
            if (!Yox.array.has(value, name, FALSE)) {
              value.push(name)
            }
          }
          else {
            Yox.array.remove(value, name, FALSE)
          }
        }

        this.set('value', value)

      }
    }
  }

yox

A lightweight mvvm framework

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis