Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selection: [],
reserveSelection: false,
selectable: null,
currentRow: null,
hoverRow: null,
filters: {},
expandRows: [],
defaultExpandAll: false,
selectOnIndeterminate: false,
treeData: {},
indent: 16,
lazy: false,
lazyTreeNodeMap: {}
};
this._toggleAllSelection = debounce(10, function(states) {
const data = states.data || [];
if (data.length === 0) return;
const selection = this.states.selection;
// when only some rows are selected (but not all), select or deselect all of them
// depending on the value of selectOnIndeterminate
const value = states.selectOnIndeterminate ? !states.isAllSelected : !(states.isAllSelected || selection.length);
let selectionChanged = false;
data.forEach((item, index) => {
if (states.selectable) {
if (states.selectable.call(null, item, index) && toggleRowSelection(states, item, value)) {
selectionChanged = true;
}
} else {
if (toggleRowSelection(states, item, value)) {
selectionChanged = true;
}
export function createStore(table, initialState = {}) {
if (!table) {
throw new Error('Table is required.');
}
const store = new Store();
store.table = table;
// fix https://github.com/ElemeFE/element/issues/14075
// related pr https://github.com/ElemeFE/element/pull/14146
store.toggleAllSelection = debounce(10, store._toggleAllSelection);
Object.keys(initialState).forEach(key => {
store.states[key] = initialState[key];
});
return store;
}
tooltip.handleClosePopper()
}
const cell = getCell(event)
if (!cell) return
const oldHoverState = this.table.hoverState || {}
this.table.$emit(
'cell-mouse-leave',
oldHoverState.row,
oldHoverState.column,
oldHoverState.cell,
event
)
},
handleMouseEnter: debounce(30, function(index) {
this.store.commit('setHoverRow', index)
}),
handleMouseLeave: debounce(30, function() {
this.store.commit('setHoverRow', null)
}),
handleContextMenu(event, row) {
this.handleEvent(event, row, 'contextmenu')
},
handleDoubleClick(event, row) {
this.handleEvent(event, row, 'dblclick')
},
handleClick(event, row) {
},
rowSelectedChanged (states, row) {
const changed = toggleRowSelection(states, row);
const selection = states.selection;
if (changed) {
const table = this.table;
table.$emit('selection-change', selection ? selection.slice() : []);
table.$emit('select', selection, row);
}
this.updateAllSelected();
},
toggleAllSelection: debounce(10, function (states) {
const data = states.data || [];
if (data.length === 0) return;
const value = !states.isAllSelected;
const selection = this.states.selection;
let selectionChanged = false;
data.forEach((item, index) => {
if (states.selectable) {
if (states.selectable.call(null, item, index) && toggleRowSelection(states, item, value)) {
selectionChanged = true;
}
} else {
if (toggleRowSelection(states, item, value)) {
selectionChanged = true;
}
}
created() {
this.debouncedSearch = debounce(300, this.search);
},
constructor(props) {
super(props);
this.state = {
value: '',
items: this.props.items || [],
loading: false,
};
this.search = debounce(600, this.search.bind(this));
}
created() {
this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper());
},
created() {
this.debouncedSearch = debounce(300, this.search);
},
created() {
this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper())
},
componentDidMount(): void {
const nodeModel = this.props.nodeModel;
const childrenKey = this.props.options.children || 'children';
const triggerChange = debounce(20, (...args) => {
if (this.isDeconstructed) return;
this.handleSelectChange.apply(this, args);
});
this.loadHandler = this.enhanceLoad(nodeModel);
this.watchers = {
[this.idGen.next()]: watchPropertyChange(
nodeModel,
'indeterminate',
value => {
triggerChange(nodeModel.checked, value);
}
),
[this.idGen.next()]: watchPropertyChange(nodeModel, 'checked', value => {
triggerChange(value, nodeModel.indeterminate);
}),