Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isChecked(item: SimpleMonth) {
const checkedTimestamps = this.get('checkedTimestamps')
return Yox.array.has(checkedTimestamps, item.timestamp)
}
},
'change.checkboxGroup': function (event, data) {
if (event.phase === Yox.Event.PHASE_DOWNWARD) {
this.set({
checked: Yox.array.has(data.selected, this.get('value'))
});
}
}
},
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,
changeFiles(event: CustomEventInterface) {
const files = Yox.array.toArray(
(event.originalEvent.target as HTMLInputElement).files
)
this.upload(
files.map(function (file) {
return {
file,
id: ++guid,
}
})
)
}
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)
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)
}
}
}
return function (key: string, value: string) {
if (!Yox.array.has(values, value)) {
Yox.logger.warn(`${key} 期望是 ${values.join(',')} 中的值,实际传值 ${value}。`)
}
return true
}
}
'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 })
}
}
},
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) + '%'
}
},
function isOptionSelected(values: any[] | any, value: any) {
return Yox.is.array(values)
? Yox.array.has(values, value, FALSE)
: values == value
}