New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

streaksheet

Package Overview
Dependencies
Maintainers
4
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streaksheet - npm Package Compare versions

Comparing version 0.8.5 to 0.8.6

build/src/SectionRelativeRowMatcher.d.ts

4

build/src/CellContainer.js

@@ -34,2 +34,3 @@ "use strict";

sectionRowMatcher = data.sectionRowMatcher,
selectedRowsManager = data.selectedRowsManager,
setCellBeingEdited = data.setCellBeingEdited;

@@ -97,2 +98,3 @@ var position = sectionRowMatcher.getSectionRow(rowIndex);

isEditing: isEditing,
isRowSelected: selectedRowsManager.isRowSelected(sectionKey, rowKey),
setEditing: setEditing,

@@ -159,3 +161,3 @@ rowData: rowData,

if (prevData.Cell !== nextData.Cell || prevData.sectionRowMatcher !== nextData.sectionRowMatcher || prevData.styles !== nextData.styles || prevData.rowHoveredClassName !== nextData.rowHoveredClassName) {
if (prevData.Cell !== nextData.Cell || prevData.sectionRowMatcher !== nextData.sectionRowMatcher || prevData.selectedRowsManager !== nextData.selectedRowsManager || prevData.styles !== nextData.styles || prevData.rowHoveredClassName !== nextData.rowHoveredClassName) {
return false;

@@ -162,0 +164,0 @@ }

import React, { ComponentType } from 'react';
import type { ColumnHeaderCellProps, ColumnInfo, Styles } from './';
import { SelectedRowsManager } from './useRowSelection';
interface Props {

@@ -17,5 +18,6 @@ adjacentHiddenColumnKeys: string[];

renderColumnsExpandButton: (columnKeys: string[]) => React.ReactNode;
selectedRowsManager: SelectedRowsManager;
styles: Styles;
}
export default function ColumnHeaderCellContainer({ adjacentHiddenColumnKeys, ColumnHeaderCell, column, columnIndex, columnLeft, height, isDragging, minimumColumnWidth, onDragStart, onDragResizeHandle, onDragResizeHandleEnd, onExpandColumns, renderColumnsExpandButton, styles, }: Props): JSX.Element;
export default function ColumnHeaderCellContainer({ adjacentHiddenColumnKeys, ColumnHeaderCell, column, columnIndex, columnLeft, height, isDragging, minimumColumnWidth, onDragStart, onDragResizeHandle, onDragResizeHandleEnd, onExpandColumns, renderColumnsExpandButton, selectedRowsManager, styles, }: Props): JSX.Element;
export {};

@@ -28,2 +28,3 @@ "use strict";

renderColumnsExpandButton = _ref.renderColumnsExpandButton,
selectedRowsManager = _ref.selectedRowsManager,
styles = _ref.styles;

@@ -59,3 +60,4 @@ var isHidden = column.isHidden,

columnKey: key,
isHidden: isHidden
isHidden: isHidden,
isSheetSelected: selectedRowsManager.isSheetSelected()
})), adjacentHiddenColumnKeys.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {

@@ -62,0 +64,0 @@ style: {

@@ -5,2 +5,3 @@ import React, { ComponentType } from 'react';

import type { ColumnInfo } from './useSheetData';
import { SelectedRowsManager } from './useRowSelection';
interface Props {

@@ -17,2 +18,3 @@ ColumnHeaderCell: ComponentType<ColumnHeaderCellProps>;

resetAfterColumnIndex: VariableSizeGrid['resetAfterColumnIndex'];
selectedRowsManager: SelectedRowsManager;
styles: Styles;

@@ -23,3 +25,3 @@ totalWidth: number;

}
export default function ColumnHeadersContainer({ ColumnHeaderCell, columns, height, liveResize, minimumColumnWidth, onExpandColumns, onReorderColumn, onResizeColumn, renderColumnsExpandButton, resetAfterColumnIndex, styles, totalWidth, topSectionHeight, groupbarHeight, }: Props): JSX.Element;
export default function ColumnHeadersContainer({ ColumnHeaderCell, columns, height, liveResize, minimumColumnWidth, onExpandColumns, onReorderColumn, onResizeColumn, renderColumnsExpandButton, resetAfterColumnIndex, selectedRowsManager, styles, totalWidth, topSectionHeight, groupbarHeight, }: Props): JSX.Element;
export {};

@@ -54,2 +54,3 @@ "use strict";

resetAfterColumnIndex = _ref.resetAfterColumnIndex,
selectedRowsManager = _ref.selectedRowsManager,
styles = _ref.styles,

@@ -286,2 +287,3 @@ totalWidth = _ref.totalWidth,

renderColumnsExpandButton: renderColumnsExpandButton,
selectedRowsManager: selectedRowsManager,
styles: styles

@@ -288,0 +290,0 @@ });

@@ -1,5 +0,5 @@

import type SectionRowMatcher from './SectionRowMatcher';
import type SectionRelativeRowMatcher from './SectionRelativeRowMatcher';
import type { CellIndexes } from './internalTypes';
import type { ColumnAndOverviewData, Section } from './useSheetData';
export default function getRectForRange(start: CellIndexes, end: CellIndexes, columnAndOverviewData: ColumnAndOverviewData, sectionRowMatcher: SectionRowMatcher, defaultRowHeight: number, topSectionHeight: number, getEffectiveSectionRowCount: (section: Section) => number): {
export default function getRectForRange(start: CellIndexes, end: CellIndexes, columnAndOverviewData: ColumnAndOverviewData, sectionRowMatcher: SectionRelativeRowMatcher, defaultRowHeight: number, topSectionHeight: number, getEffectiveSectionRowCount: (section: Section) => number): {
height: number;

@@ -6,0 +6,0 @@ left: number;

@@ -38,2 +38,3 @@ import * as React from 'react';

isEditing: boolean;
isRowSelected: boolean;
setEditing(isEditing: boolean): void;

@@ -48,2 +49,3 @@ initialEditQueuedValue: unknown | undefined;

isEditing: boolean;
isSectionSelected: 'all' | 'some' | 'none';
isHidden: boolean;

@@ -54,2 +56,3 @@ sectionKey: string;

export interface ColumnHeaderCellProps {
isSheetSelected: 'all' | 'some' | 'none';
columnKey: string;

@@ -149,2 +152,14 @@ isHidden: boolean;

getSelectedCells(): CellKeys[];
isRowSelected(sectionKey: string, rowKey: string): boolean;
setRowSelection(sectionKey: string, rowKey: string, selected: boolean): void;
setRowSelectionOverRange(start: {
sectionKey: string;
rowKey: string;
}, end: {
sectionKey: string;
rowKey: string;
}, selected: boolean): void;
setRowSelectionOverSection(sectionKey: string, selected: boolean): void;
setSheetSelection(selected: boolean): void;
getSelectedRows(): Promise<T[]>;
highlightNextSearchResult(): void;

@@ -151,0 +166,0 @@ highlightPreviousSearchResult(): void;

@@ -18,2 +18,8 @@ "use strict";

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

@@ -61,2 +67,8 @@

var _useRowSelection = _interopRequireDefault(require("./useRowSelection"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/* Demo goal:

@@ -369,6 +381,17 @@ Should contain header row with column names, two groups, and multiple toggleable frozen columns.

}
var cellDataMappers = (0, _useCellDataMappers["default"])(rowsBySection, visibleColumns, sectionRowMatcher, columnAndOverviewData, sheetDataForStreakSheet.getIndexForRow);
var cellIndexesToKeysAndData = cellDataMappers.cellIndexesToKeysAndData,
var cellDataMappers = (0, _useCellDataMappers["default"])(rowsBySection, visibleColumns, sectionRowMatcher, columnAndOverviewData, sheetData.getIndexForRow);
var cellKeysToIndexes = cellDataMappers.cellKeysToIndexes,
cellIndexesToKeysAndData = cellDataMappers.cellIndexesToKeysAndData,
cellIndexesToKeys = cellDataMappers.cellIndexesToKeys,
cellRegionToKeysAndData = cellDataMappers.cellRegionToKeysAndData;
var getSectionRelativeRowIndex = (0, React.useCallback)(function (sectionKey, rowKey) {
var index = cellKeysToIndexes(sectionKey, rowKey, columnAndOverviewData.columns[0].key);
if (!index) {
throw new Error('attempted to get absolute index of row key that is not loaded');
}
return sectionRowMatcher.getSectionRow(index[0]);
}, [cellKeysToIndexes, columnAndOverviewData.columns, sectionRowMatcher]);
var selectedRowsManager = (0, _useRowSelection["default"])(sheetData.useByStreakSheet(), columnAndOverviewData.sections, rowsBySection, getSectionRelativeRowIndex);
var handleGridDoubleClick = (0, React.useCallback)(function (event) {

@@ -545,2 +568,69 @@ var cellIndexes = (0, _getCellIndexesFromMouseEvent["default"])(event);

},
isRowSelected: function isRowSelected(sectionKey, rowKey) {
return selectedRowsManager.isRowSelected(sectionKey, rowKey);
},
setRowSelection: function setRowSelection(sectionKey, rowKey, selected) {
return selectedRowsManager.setRowSelection(sectionKey, rowKey, selected);
},
setRowSelectionOverRange: function setRowSelectionOverRange(start, end) {
var _objectSpread3;
var startIndex = cellKeysToIndexes(start.sectionKey, start.rowKey, columnAndOverviewData.columns[0].key);
var endIndex = cellKeysToIndexes(end.sectionKey, end.rowKey, columnAndOverviewData.columns[0].key);
if (!startIndex || !endIndex) {
throw new Error('Cannot call setRowSelectionOverRange for section/row key that is not synchronously available');
}
if (start.sectionKey === end.sectionKey) {
// same section, so the range is between the two
return selectedRowsManager.setRowSelectionOverRange((0, _defineProperty2["default"])({}, start.sectionKey, [sectionRowMatcher.getSectionRow(Math.min(startIndex[0], endIndex[0])).rowIndex, sectionRowMatcher.getSectionRow(Math.max(startIndex[0], endIndex[0])).rowIndex]));
}
var _startSectionIndex = columnAndOverviewData.sections.findIndex(function (section) {
return section.key === start.sectionKey;
});
var _endSectionIndex = columnAndOverviewData.sections.findIndex(function (section) {
return section.key === end.sectionKey;
});
if (_startSectionIndex < 0 || _endSectionIndex < 0) {
throw new Error("Cannot call setRowSelectionOverRange for sections that do not exist. start: ".concat(start.sectionKey, " - end: ").concat(end.sectionKey));
}
var startSectionIndex = Math.min(_startSectionIndex, _endSectionIndex);
var endSectionIndex = Math.max(_startSectionIndex, _endSectionIndex);
var startSection = columnAndOverviewData.sections[startSectionIndex];
var endSection = columnAndOverviewData.sections[endSectionIndex];
var startRowIndex = Math.min(startIndex[0], endIndex[0]);
var endRowIndex = Math.max(startIndex[0], endIndex[0]);
var coveredSections = columnAndOverviewData.sections.slice(startSectionIndex + 1, endSectionIndex);
var coveredRanges = coveredSections.reduce(function (acc, cur) {
return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2["default"])({}, cur.key, [0, getEffectiveSectionRowCount(cur)]));
}, {});
return selectedRowsManager.setRowSelectionOverRange(_objectSpread((_objectSpread3 = {}, (0, _defineProperty2["default"])(_objectSpread3, startSection.key, [sectionRowMatcher.getSectionRow(startRowIndex).rowIndex, getEffectiveSectionRowCount(startSection)]), (0, _defineProperty2["default"])(_objectSpread3, endSection.key, [0, sectionRowMatcher.getSectionRow(endRowIndex).rowIndex]), _objectSpread3), coveredRanges));
},
setRowSelectionOverSection: function setRowSelectionOverSection(sectionKey, selected) {
return selectedRowsManager.setRowSelectionOverSection(sectionKey, selected);
},
setSheetSelection: function setSheetSelection(selected) {
selectedRowsManager.setSheetSelection(selected);
},
getSelectedRows: function getSelectedRows() {
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", []);
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
moveColumnRight: function moveColumnRight(columnKey) {

@@ -581,3 +671,3 @@ var _gridRef$current6;

};
}, [cellIndexesToKeys, columnAndOverviewData.sections, getEffectiveSectionRowCount, onSwapColumns, selection, setCellBeingEdited, visibleColumns]); // TODO have cell/column keys so adding a column doesn't re-render all subsequent columns?
}, [setCellBeingEdited, selection, cellKeysToIndexes, sectionRowMatcher, cellIndexesToKeys, onSwapColumns, visibleColumns, selectedRowsManager, columnAndOverviewData.columns, columnAndOverviewData.sections, getEffectiveSectionRowCount]); // TODO have cell/column keys so adding a column doesn't re-render all subsequent columns?
// const frozenColumns = props.frozenColumns || 0;

@@ -595,2 +685,3 @@

sectionRowMatcher: sectionRowMatcher,
selectedRowsManager: selectedRowsManager,
styles: styles,

@@ -600,3 +691,3 @@ setCellBeingEdited: setCellBeingEdited,

};
}, [Cell, editedCellRef, cellBeingEdited, cellIndexesToKeys, cellIndexesToKeysAndData, sectionRowMatcher, styles, setCellBeingEdited, props.rowHoveredClassName]);
}, [Cell, editedCellRef, cellBeingEdited, cellIndexesToKeys, cellIndexesToKeysAndData, sectionRowMatcher, selectedRowsManager, styles, setCellBeingEdited, props.rowHoveredClassName]);
var onItemsRendered = (0, React.useCallback)(function (_ref4) {

@@ -712,2 +803,3 @@ var visibleRowStartIndex = _ref4.visibleRowStartIndex,

selection: selection,
selectedRowsManager: selectedRowsManager,
sheetProps: props,

@@ -714,0 +806,0 @@ styles: styles,

@@ -50,2 +50,3 @@ "use strict";

selection = _ref.selection,
selectedRowsManager = _ref.selectedRowsManager,
sheetProps = _ref.sheetProps,

@@ -161,2 +162,3 @@ styles = _ref.styles,

resetAfterColumnIndex: resetAfterColumnIndex,
selectedRowsManager: selectedRowsManager,
styles: styles,

@@ -179,2 +181,3 @@ totalWidth: totalWidth,

rowsBySection: rowsBySection,
selectedRowsManager: selectedRowsManager,
getEffectiveSectionRowCount: getEffectiveSectionRowCount

@@ -181,0 +184,0 @@ }));

import * as React from 'react';
import type { ComponentType } from 'react';
import type { CellKeys, CellProps, Props, Section, Styles } from '.';
import type SectionRowMatcher from './SectionRowMatcher';
import type { SectionRow } from './SectionRowMatcher';
import type SectionRelativeRowMatcher from './SectionRelativeRowMatcher';
import type { SectionRelativeRowIndex } from './SectionRelativeRowMatcher';
import { VariableSizeGrid } from 'react-window';
import { CopyHandler } from './useSheetData';
import { KeysAndDataByIndex } from './useCellDataMappers';
import { SelectedRowsManager } from './useRowSelection';
export declare type CellRegion = [CellIndexes, CellIndexes];

@@ -46,3 +47,4 @@ export declare type CellIndexes = [number, number];

cellIndexesToKeysAndData: (rowIndex: number, columnIndex: number) => CellIndexesToKeysAndDataResult<T> | null;
sectionRowMatcher: SectionRowMatcher;
sectionRowMatcher: SectionRelativeRowMatcher;
selectedRowsManager: SelectedRowsManager;
styles: Styles;

@@ -57,4 +59,4 @@ setCellBeingEdited: SetCellBeingEdited;

export interface SectionRowRange {
start: SectionRow;
stop: SectionRow;
start: SectionRelativeRowIndex;
stop: SectionRelativeRowIndex;
}

@@ -70,2 +72,3 @@ export declare type SelectionState = [CellIndexes, CellIndexes][];

removerAbortController: AbortController | null;
isSelected: boolean;
}

@@ -94,2 +97,3 @@ export interface StartedRowsRequests {

selection: SelectionState;
selectedRowsManager: SelectedRowsManager;
sheetProps: Props<any, any>;

@@ -96,0 +100,0 @@ styles: Styles;

import { CSSProperties } from 'react';
import type SectionRowMatcher from './SectionRowMatcher';
import type SectionRelativeRowMatcher from './SectionRelativeRowMatcher';
import type { CellIndexes } from './internalTypes';

@@ -11,3 +11,3 @@ import type { ColumnAndOverviewData } from './useSheetData';

region: [CellIndexes, CellIndexes];
sectionRowMatcher: SectionRowMatcher;
sectionRowMatcher: SectionRelativeRowMatcher;
styleFunction: (base: CSSProperties) => CSSProperties;

@@ -14,0 +14,0 @@ getEffectiveSectionRowCount: (section: Section) => number;

@@ -8,3 +8,3 @@ "use strict";

var _SectionRowMatcher = require("../SectionRowMatcher");
var _SectionRelativeRowMatcher = require("../SectionRelativeRowMatcher");

@@ -22,10 +22,35 @@ // If batchCb is null, then the function returns true as soon as any item is found.

if (si < start.sectionIndex || si > stop.sectionIndex) {
if (!batchCb) {
return true;
if (startedRowsRequests[_sectionKey].every(function (rowRequest) {
return !rowRequest.isSelected;
})) {
if (!batchCb) {
return true;
}
batchCb({
sectionKey: _sectionKey,
requestIndexes: 'WHOLE SECTION'
});
} else {
var requestIndexes = [];
for (var i = 0; i < startedRowsRequests[_sectionKey].length; i++) {
var rowRequest = startedRowsRequests[_sectionKey][i];
if (!rowRequest.isSelected) {
if (!batchCb) {
return true;
}
requestIndexes.push(i);
}
}
if (batchCb) {
batchCb({
sectionKey: _sectionKey,
requestIndexes: requestIndexes
});
}
}
batchCb({
sectionKey: _sectionKey,
requestIndexes: 'WHOLE SECTION'
});
} else {

@@ -35,3 +60,3 @@ var sectionStartedRowsRequests = startedRowsRequests[_sectionKey];

if (si === start.sectionIndex) {
var requestIndexes = [];
var _requestIndexes = [];

@@ -45,3 +70,3 @@ for (var requestIndex = 0; requestIndex < sectionStartedRowsRequests.length; requestIndex++) {

if ((0, _SectionRowMatcher.compareSectionRows)(requestEndSectionRow, start) < 0) {
if ((0, _SectionRelativeRowMatcher.compareSectionRows)(requestEndSectionRow, start) < 0) {
if (!batchCb) {

@@ -51,10 +76,10 @@ return true;

requestIndexes.push(requestIndex);
_requestIndexes.push(requestIndex);
}
}
if (requestIndexes.length) {
if (_requestIndexes.length) {
batchCb({
sectionKey: _sectionKey,
requestIndexes: requestIndexes
requestIndexes: _requestIndexes
});

@@ -65,3 +90,3 @@ }

if (si === stop.sectionIndex) {
var _requestIndexes = [];
var _requestIndexes2 = [];

@@ -75,3 +100,3 @@ for (var _requestIndex = 0; _requestIndex < sectionStartedRowsRequests.length; _requestIndex++) {

if ((0, _SectionRowMatcher.compareSectionRows)(requestStartSectionRow, stop) > 0) {
if ((0, _SectionRelativeRowMatcher.compareSectionRows)(requestStartSectionRow, stop) > 0) {
if (!batchCb) {

@@ -81,10 +106,10 @@ return true;

_requestIndexes.push(_requestIndex);
_requestIndexes2.push(_requestIndex);
}
}
if (_requestIndexes.length) {
if (_requestIndexes2.length) {
batchCb({
sectionKey: _sectionKey,
requestIndexes: _requestIndexes
requestIndexes: _requestIndexes2
});

@@ -91,0 +116,0 @@ }

import * as React from 'react';
import { CellKeys, ColumnInfo, SectionHeaderCellProps, Styles } from '.';
import { RowsBySection, SetCellBeingEdited } from './internalTypes';
import { SelectedRowsManager } from './useRowSelection';
import { ColumnAndOverviewData, Section } from './useSheetData';
interface Props {
interface Props<T> {
cellBeingEdited: CellKeys | null;

@@ -18,5 +19,6 @@ columnAndOverviewData: ColumnAndOverviewData;

rowsBySection: RowsBySection<any>;
selectedRowsManager: SelectedRowsManager;
getEffectiveSectionRowCount: (section: Section) => number;
}
declare const SectionHeadersContainer: React.NamedExoticComponent<Props>;
declare const SectionHeadersContainer: React.MemoExoticComponent<(<T>({ cellBeingEdited, columnAndOverviewData, totalWidth, defaultRowHeight, setCellBeingEdited, styles, topSectionHeight, groupbarHeight, groupbarMaxHeight, visibleColumns, SectionHeaderCell, selectedRowsManager, getEffectiveSectionRowCount, }: Props<T>) => JSX.Element)>;
export default SectionHeadersContainer;

@@ -24,2 +24,3 @@ "use strict";

SectionHeaderCell = _ref.SectionHeaderCell,
selectedRowsManager = _ref.selectedRowsManager,
getEffectiveSectionRowCount = _ref.getEffectiveSectionRowCount;

@@ -77,2 +78,3 @@ return /*#__PURE__*/React.createElement("div", {

isEditing: isEditing,
isSectionSelected: selectedRowsManager.isSectionSelected(section.key),
columnKey: column.key,

@@ -79,0 +81,0 @@ isHidden: section.isHidden,

/// <reference types="react" />
import type SectionRowMatcher from './SectionRowMatcher';
import type SectionRelativeRowMatcher from './SectionRelativeRowMatcher';
import type { Section, Styles } from '.';

@@ -11,3 +11,3 @@ import type { CellIndexes, SelectionState } from './internalTypes';

topSectionHeight: number;
sectionRowMatcher: SectionRowMatcher;
sectionRowMatcher: SectionRelativeRowMatcher;
selection: SelectionState;

@@ -14,0 +14,0 @@ styles: Styles;

/// <reference types="react" />
import type SectionRowMatcher from './SectionRowMatcher';
import type SectionRelativeRowMatcher from './SectionRelativeRowMatcher';
import type { Section, Styles } from '.';

@@ -11,3 +11,3 @@ import type { CellIndexes, SelectionState } from './internalTypes';

topSectionHeight: number;
sectionRowMatcher: SectionRowMatcher;
sectionRowMatcher: SectionRelativeRowMatcher;
selection: SelectionState;

@@ -14,0 +14,0 @@ styles: Styles;

import { CellKeys, ColumnInfo } from '.';
import { CellIndexes, CellIndexesToKeysAndDataResult, CellRegion, RowsBySection } from './internalTypes';
import SectionRowMatcher from './SectionRowMatcher';
import SectionRelativeRowMatcher from './SectionRelativeRowMatcher';
import { ColumnAndOverviewData } from './useSheetData';

@@ -16,2 +16,2 @@ export declare type KeysAndDataByIndex<T> = {

}
export default function useCellDataMappers<T>(rowsBySection: RowsBySection<T>, visibleColumns: ColumnInfo[], sectionRowMatcher: SectionRowMatcher, columnAndOverviewData: ColumnAndOverviewData, rowKeysToIndex: (sectionKey: string, rowKey: string) => number | undefined): CellDataMappers<T>;
export default function useCellDataMappers<T>(rowsBySection: RowsBySection<T>, visibleColumns: ColumnInfo[], sectionRowMatcher: SectionRelativeRowMatcher, columnAndOverviewData: ColumnAndOverviewData, rowKeysToIndex: (sectionKey: string, rowKey: string) => number | undefined): CellDataMappers<T>;
import { RowsBySection, StartedRowsRequests } from './internalTypes';
import { DataHandler, Section } from './useSheetData';
import { DataHandler, ExposedRowsResult, Section } from './useSheetData';
export interface RowsBySectionOptions<T> {

@@ -10,3 +10,3 @@ sections: Array<Section>;

startedRowsRequests: StartedRowsRequests;
createRowsRequest(sectionKey: string, startIndex: number, count: number): Promise<void>;
createRowsRequest(sectionKey: string, startIndex: number, count: number, storeResult?: boolean): Promise<ExposedRowsResult<T> | undefined>;
releaseRowsRequests(sectionKey: string, requestIndexes?: number[]): void;

@@ -13,0 +13,0 @@ reset(): void;

@@ -502,3 +502,14 @@ "use strict";

var hiddenRowsBeforeStartIndex, startIndex, abortController, _getCursorFromIndex, cursor, offset, direction, request, newIndex, rowsResult;
var storeResult,
hiddenRowsBeforeStartIndex,
startIndex,
abortController,
_getCursorFromIndex,
cursor,
offset,
direction,
request,
newIndex,
rowsResult,
_args = arguments;

@@ -509,2 +520,3 @@ return _regenerator["default"].wrap(function _callee$(_context) {

case 0:
storeResult = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
// The starting index does not know that data may have been deduplicated or deleted

@@ -531,30 +543,32 @@ // need to figure out what the index would be considering any hidden rows

abortController: abortController,
removerAbortController: null
removerAbortController: null,
isSelected: false
};
if (!startedRowsRequests.current[sectionKey]) {
startedRowsRequests.current[sectionKey] = [request];
} else {
newIndex = (0, _lodash.sortedIndexBy)(startedRowsRequests.current[sectionKey], request, function (r) {
return r.startIndex;
});
startedRowsRequests.current[sectionKey].splice(newIndex, 0, request);
if (storeResult) {
if (!startedRowsRequests.current[sectionKey]) {
startedRowsRequests.current[sectionKey] = [request];
} else {
newIndex = (0, _lodash.sortedIndexBy)(startedRowsRequests.current[sectionKey], request, function (r) {
return r.startIndex;
});
startedRowsRequests.current[sectionKey].splice(newIndex, 0, request);
}
}
_context.prev = 6;
_context.next = 9;
return dataHandler.getRows(sectionKey, request.cursor, request.offset, request.limit, request.abortController.signal);
_context.prev = 7;
_context.next = 10;
return dataHandler.getRows(sectionKey, request.cursor, request.offset, request.limit, abortController.signal);
case 9:
case 10:
rowsResult = _context.sent;
storeRowsForRequest(rowsResult, sectionKey, request);
_context.next = 17;
break;
storeResult && storeRowsForRequest(rowsResult, sectionKey, request);
return _context.abrupt("return", rowsResult);
case 13:
_context.prev = 13;
_context.t0 = _context["catch"](6);
case 15:
_context.prev = 15;
_context.t0 = _context["catch"](7);
if (request.abortController.signal.aborted) {
_context.next = 17;
if (abortController.signal.aborted) {
_context.next = 19;
break;

@@ -565,3 +579,3 @@ }

case 17:
case 19:
case "end":

@@ -571,3 +585,3 @@ return _context.stop();

}
}, _callee, null, [[6, 13]]);
}, _callee, null, [[7, 15]]);
}));

@@ -574,0 +588,0 @@

/// <reference types="react" />
import { JumpPointGetter, Row, RowsBySection } from './internalTypes';
import SectionRowMatcher from './SectionRowMatcher';
import { CellRegion, JumpPointGetter, Row, RowsBySection } from './internalTypes';
import SectionRelativeRowMatcher from './SectionRelativeRowMatcher';
import { SelectedRowsManager } from './useRowSelection';
export interface Section {

@@ -20,2 +21,6 @@ isHidden: boolean;

}
export interface SectionAndRowKey {
sectionKey: string;
rowKey: string;
}
export interface ExposedRowsResult<T> {

@@ -108,14 +113,16 @@ rows: Row<T>[];

rowsBySection: RowsBySection<T>;
sectionRowMatcher: SectionRowMatcher;
sectionRowMatcher: SectionRelativeRowMatcher;
setRowData(rowKey: string, rowData: T): void;
getRowData(sectionKey: string, rowKey: string): T | undefined;
totalRowCount: number;
useByStreakSheet(): SheetDataForStreakSheet;
useByStreakSheet(): SheetDataForStreakSheet<T>;
getEffectiveSectionRowCount(section: Section): number;
getIndexForRow(sectionKey: string, rowKey: string): number;
}
export interface SheetDataForStreakSheet {
export interface SheetDataForStreakSheet<T> {
onScroll(visibleRowStartIndex: number, visibleRowStopIndex: number): void;
updateSelectedRowsManager(rowsManager: SelectedRowsManager): void;
getIndexForRow(sectionKey: string, rowKey: string): number | undefined;
requestRowDataForRange(region: CellRegion): Promise<T[]>;
}
export default function useSheetData<T>(options: SheetDataOptions<T>): SheetData<T>;

@@ -26,4 +26,10 @@ "use strict";

var _useSectionRowMatcher = _interopRequireDefault(require("./useSectionRowMatcher"));
var _useSectionRelativeRowMatcher = _interopRequireDefault(require("./useSectionRelativeRowMatcher"));
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function useSheetData(options) {

@@ -56,3 +62,3 @@ var columnAndOverviewData = options.columnAndOverviewData,

verify(options);
var sectionRowMatcher = (0, _useSectionRowMatcher["default"])(columnAndOverviewData.sections, getEffectiveSectionRowCount);
var sectionRowMatcher = (0, _useSectionRelativeRowMatcher["default"])(columnAndOverviewData.sections, getEffectiveSectionRowCount);

@@ -156,8 +162,123 @@ var _useState = (0, _react.useState)(),

var refreshRows = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
var lastSelectedRowsManager = (0, _react.useRef)();
var requestRowDataForRangeLatest = (0, _react.useRef)(); // TODO: Implement this function
// eslint-disable-next-line @typescript-eslint/no-unused-vars
requestRowDataForRangeLatest.current = /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(region) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", []);
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}();
var updateSelectedRowsManagerLatest = (0, _react.useRef)();
updateSelectedRowsManagerLatest.current = function (selectedRowsManager) {
if (selectedRowsManager !== lastSelectedRowsManager.current) {
// we've got new rows to process
lastSelectedRowsManager.current = selectedRowsManager;
var _loop = function _loop() {
var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
sectionKey = _Object$entries$_i[0],
startedSectionRequests = _Object$entries$_i[1];
startedSectionRequests.forEach(function (rowRequest) {
rowRequest.isSelected = false; // Consider selectedRowKeys
if (!rowRequest.abortController) {
// this request has finished
var sectionRowsChunk = rowsBySection[sectionKey];
var rowChunk = sectionRowsChunk === null || sectionRowsChunk === void 0 ? void 0 : sectionRowsChunk.find(function (chunk) {
return chunk.startIndex === rowRequest.startIndex;
});
if (!rowChunk) {
// TODO: this should throw an error, but
// there's a race condition in useRowsBySection
// that is allowing a rowRequest to be "finished"
// but we don't see the updated rowsBySection object in
// this scope
return;
}
var _iterator = _createForOfIteratorHelper(rowChunk.rowsResult.rows),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var row = _step.value;
if (selectedRowsManager.isRowSelected(sectionKey, row.key)) {
rowRequest.isSelected = true;
break;
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
} else {
// check indices or groupSelection
if (selectedRowsManager.isSectionSelected(sectionKey)) {
rowRequest.isSelected = true;
} else {
// check indices
var selectedIndices = selectedRowsManager.getSelectedIndices();
var selectedIndicesForSection = selectedIndices[sectionKey] || [];
if (selectedIndicesForSection.some(function (index) {
return rowRequest.startIndex <= index && index <= rowRequest.startIndex + rowRequest.limit;
})) {
rowRequest.isSelected = true;
}
}
}
});
};
for (var _i = 0, _Object$entries = Object.entries(startedRowsRequests); _i < _Object$entries.length; _i++) {
_loop();
}
}
};
var getIndexForRowLatest = (0, _react.useRef)();
getIndexForRowLatest.current = function (sectionKey, rowKey) {
var index = _getIndexForRow(sectionKey, rowKey);
return index;
};
var getIndexForRow = (0, _react.useCallback)(function (sectionKey, rowKey) {
var index = _getIndexForRow(sectionKey, rowKey);
if (!index) {
throw new Error("attempted to get index for unloaded row (sectionKey=".concat(sectionKey, ", rowKey=").concat(rowKey, ")"));
}
return index;
}, [_getIndexForRow]);
var refreshRows = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
var _onScrollLatest$curre;
return _regenerator["default"].wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context.prev = _context.next) {
switch (_context2.prev = _context2.next) {
case 0:

@@ -167,7 +288,7 @@ resetRowsBySection();

if (!isRefreshing) {
_context.next = 3;
_context2.next = 3;
break;
}
return _context.abrupt("return");
return _context2.abrupt("return");

@@ -178,10 +299,10 @@ case 3:

if (lastOnScroll.current) {
_context.next = 6;
_context2.next = 6;
break;
}
return _context.abrupt("return");
return _context2.abrupt("return");
case 6:
_context.next = 8;
_context2.next = 8;
return (_onScrollLatest$curre = onScrollLatest.current) === null || _onScrollLatest$curre === void 0 ? void 0 : _onScrollLatest$curre.call(onScrollLatest, lastOnScroll.current.visibleRowStartIndex, lastOnScroll.current.visibleRowStopIndex);

@@ -194,6 +315,6 @@

case "end":
return _context.stop();
return _context2.stop();
}
}
}, _callee);
}, _callee2);
})), [isRefreshing, resetRowsBySection, rowsBySection]); // This function is to be used as a hook inside of a StreakSheet instance.

@@ -224,17 +345,16 @@ // This allows one SheetData instance to be used by several StreakSheet

},
getIndexForRow: _getIndexForRow
updateSelectedRowsManager: function updateSelectedRowsManager(selectedRowsManager) {
updateSelectedRowsManagerLatest.current(selectedRowsManager);
},
getIndexForRow: function getIndexForRow(sectionKey, rowKey) {
return getIndexForRowLatest.current(sectionKey, rowKey);
},
requestRowDataForRange: function requestRowDataForRange(region) {
return requestRowDataForRangeLatest.current(region);
}
};
}, []);
}
} // Block locally add/deleting rows while refreshing
var getIndexForRow = (0, _react.useCallback)(function (sectionKey, rowKey) {
var index = _getIndexForRow(sectionKey, rowKey);
if (!index) {
throw new Error("attempted to get index for unloaded row (sectionKey=".concat(sectionKey, ", rowKey=").concat(rowKey, ")"));
}
return index;
}, [_getIndexForRow]); // Block locally add/deleting rows while refreshing
var addRowData = (0, _react.useCallback)(function (sectionKey, rowKey, rowData, afterRowKey) {

@@ -283,3 +403,3 @@ if (isRefreshing) {

};
} // SectionRow can have a negative section to represent the column headers,
} // SectionRelativeRowIndex can have a negative section to represent the column headers,
// and a negative row to represent the section row. We don't care about these,

@@ -286,0 +406,0 @@ // so just fudge SectionRows pointing to those to point to the first item.

{
"name": "streaksheet",
"version": "0.8.5",
"version": "0.8.6",
"author": "Chris Cowan <agentme49@gmail.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc