Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let newData = R.clone(data);
// Might add columns, not modifying the columns themselves, shallow clone is sufficient
let newColumns = columns_.slice(0);
let newVisibleColumns = visibleColumns.slice(0);
if (overflowColumns && values[0].length + (activeCell as any).column >= visibleColumns.length) {
const _newColumns = [];
for (
let i = visibleColumns.length;
i < values[0].length + (activeCell as any).column;
i++
) {
_newColumns.push({
id: `Column ${i + 1}`,
name: `Column ${i + 1}`,
type: ColumnType.Any,
sort_as_null: []
} as any);
newData.forEach(row => (row[`Column ${i}`] = ''));
}
newColumns = R.insertAll(
R.indexOf(R.last(visibleColumns), columns_) + 1,
_newColumns,
newColumns
);
newVisibleColumns = R.concat(newVisibleColumns, _newColumns);
}
const realActiveRow = derived_viewport_indices[(activeCell as any).row];
if (overflowRows && values.length + realActiveRow >= data.length) {
.add('first column is editable and not blue', () => ())
.add('style header and column based on edibility', () => (
.add('with 1 column', () => (
.add('with 1 column', () => ())
{ a: 1, b: 2, c: '3', d: '4', e: 5, f: 6, g: 7, h: 8 },
{ a: 11, b: 22, c: '33', d: '44', e: 55, f: 66, g: 77, h: 88 },
{ a: 111, b: 222, c: '333', d: '444', e: 555, f: 666, g: 777, h: 888 }
]}
columns={[
{ id: 'a', name: 'A', type: ColumnType.Any },
{ id: 'b', name: 'B', type: ColumnType.Any },
{ id: 'c', name: 'C', type: ColumnType.Text },
{ id: 'd', name: 'D', type: ColumnType.Text },
{ id: 'e', name: 'E', type: ColumnType.Numeric },
{ id: 'f', name: 'F', type: ColumnType.Numeric },
{ id: 'g', name: 'G' },
{ id: 'h', name: 'H' }
]}
style_data_conditional={[
{ if: { column_type: ColumnType.Any, row_index: 'even' }, background_color: 'blue', color: 'white' },
{ if: { column_type: ColumnType.Text, row_index: 'even' }, background_color: 'red', color: 'white' },
{ if: { column_type: ColumnType.Numeric, row_index: 'even' }, background_color: 'green', color: 'white' },
{ if: { column_type: ColumnType.Any }, background_color: 'blue' },
{ if: { column_type: ColumnType.Text }, background_color: 'red' },
{ if: { column_type: ColumnType.Numeric }, background_color: 'green' }
]}
/>))
.add('row padding', () => (
function getImplicitLexeme(type: ColumnType = ColumnType.Any): ILexemeResult {
switch (type) {
case ColumnType.Any:
case ColumnType.Text:
return {
lexeme: boundLexeme(contains),
value: RelationalOperator.Contains
};
case ColumnType.Datetime:
return {
lexeme: boundLexeme(dateStartsWith),
value: RelationalOperator.DateStartsWith
};
case ColumnType.Numeric:
return {
lexeme: boundLexeme(equal),
value: RelationalOperator.Equal
};
}
function getValidator(c: Options): (value: any, c?: any) => IReconciliation {
switch (c.type) {
case ColumnType.Numeric:
return validateNumber;
case ColumnType.Text:
return validateText;
case ColumnType.Datetime:
return validateDate;
case ColumnType.Any:
default:
return reconcileAny;
}
}
export function ifColumnType(condition: ITypedElement | undefined, columnType?: ColumnType) {
return !condition ||
condition.column_type === undefined ||
condition.column_type === (columnType || ColumnType.Any);
}
function getImplicitLexeme(type: ColumnType = ColumnType.Any): ILexemeResult {
switch (type) {
case ColumnType.Any:
case ColumnType.Text:
return {
lexeme: boundLexeme(contains),
value: RelationalOperator.Contains
};
case ColumnType.Datetime:
return {
lexeme: boundLexeme(dateStartsWith),
value: RelationalOperator.DateStartsWith
};
case ColumnType.Numeric:
return {
lexeme: boundLexeme(equal),
value: RelationalOperator.Equal