Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;`
}
},
}
}
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
}
}
}
upDisabled(): boolean {
const max = this.get('max')
return Yox.is.numeric(max)
&& max - this.get('value') < this.get('step')
},
downDisabled(): boolean {
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(),
}
},
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);
}
}
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);
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) {
down() {
const min = this.get('min')
const step = this.get('step')
this.decrease(
'value',
toNumber(step),
Yox.is.numeric(min) ? +min : UNDEFINED
)
},
handleFocus() {
'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)
}
}
}
isObject(value) {
return Yox.is.object(value)
}
},