Huge News!Announcing our $40M Series B led by Abstract Ventures.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.9.11 to 0.9.12

build/x.d.ts

1

build/src/index.d.ts

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

};
getSelectedRowsManager(): SelectedRowsManager;
isRowSelected(sectionKey: string, rowKey: string): boolean;

@@ -168,0 +169,0 @@ isSectionSelected(sectionKey: string): 'all' | 'some' | 'none';

77

build/src/index.js

@@ -349,14 +349,16 @@ "use strict";

{
// Whenever topSectionHeight or groupbar.maxHeight change, re-layout
// Whenever topSectionHeight, groupbar.maxHeight, or sectionCounts change, re-layout
// the row positions. Don't do it on first render though.
var topSectionHeight_firstRender = (0, React.useRef)(true);
var resetAfterRowEffect_firstRender = (0, React.useRef)(true);
var sectionCounts = columnAndOverviewData.sections.map(function (section) {
return getEffectiveSectionRowCount(section);
});
var sectionCountsJSON = JSON.stringify(sectionCounts);
(0, React.useEffect)(function () {
if (!topSectionHeight_firstRender.current) {
var _gridRef$current;
(_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.resetAfterRowIndex(0);
if (!resetAfterRowEffect_firstRender.current) {
gridRef.current.resetAfterRowIndex(0);
} else {
topSectionHeight_firstRender.current = false;
resetAfterRowEffect_firstRender.current = false;
}
}, [topSectionHeight, groupbar === null || groupbar === void 0 ? void 0 : groupbar.maxHeight]);
}, [topSectionHeight, groupbar === null || groupbar === void 0 ? void 0 : groupbar.maxHeight, sectionCountsJSON]);
}

@@ -366,24 +368,11 @@ {

// Don't do it on first render though.
var visibleColumns_firstRender = (0, React.useRef)(true);
var resetAfterColumnEffect_firstRender = (0, React.useRef)(true);
(0, React.useEffect)(function () {
if (!visibleColumns_firstRender.current) {
var _gridRef$current2;
(_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.resetAfterColumnIndex(0);
if (!resetAfterColumnEffect_firstRender.current) {
gridRef.current.resetAfterColumnIndex(0);
} else {
visibleColumns_firstRender.current = false;
resetAfterColumnEffect_firstRender.current = false;
}
}, [visibleColumns]);
}
{
var sectionCounts = columnAndOverviewData.sections.map(function (section) {
return getEffectiveSectionRowCount(section);
});
var sectionJSON = JSON.stringify(sectionCounts);
(0, React.useEffect)(function () {
var _gridRef$current3;
(_gridRef$current3 = gridRef.current) === null || _gridRef$current3 === void 0 ? void 0 : _gridRef$current3.resetAfterRowIndex(0);
}, [sectionJSON]);
}
var cellDataMappers = (0, _useCellDataMappers["default"])(rowsBySection, columnAndOverviewData.sections, visibleColumns, sectionRowMatcher, columnAndOverviewData, getEffectiveSectionRowCount);

@@ -429,8 +418,9 @@ var cellKeysToIndexes = cellDataMappers.cellKeysToIndexes,

}, [selectedRowsManager, cellSelectionManager]);
sheetDataForStreakSheet.updateSelectionManager(selectionManager);
sheetDataForStreakSheet.updateSelectionManager(selectionManager); // TODO we should issue this call when it actually changes, not in useEffect after we've
// rendered the change, and not after the initial render.
var onRowSelectionChanged = props.onRowSelectionChanged;
(0, React.useEffect)(function () {
var _props$onRowSelection;
(_props$onRowSelection = props.onRowSelectionChanged) === null || _props$onRowSelection === void 0 ? void 0 : _props$onRowSelection.call(props, selectedRowsManager);
}, [props, selectedRowsManager]);
onRowSelectionChanged === null || onRowSelectionChanged === void 0 ? void 0 : onRowSelectionChanged(selectedRowsManager);
}, [onRowSelectionChanged, selectedRowsManager]);
var handleGridDoubleClick = (0, React.useCallback)(function (event) {

@@ -463,3 +453,3 @@ var cellIndexes = (0, _getCellIndexesFromMouseEvent["default"])(event);

(0, React.useEffect)(function () {
var _gridRef$current4;
var _gridRef$current;

@@ -471,3 +461,3 @@ if (selection.length === 0) {

var lastSelection = selection[0][1];
(_gridRef$current4 = gridRef.current) === null || _gridRef$current4 === void 0 ? void 0 : _gridRef$current4.scrollToItem({
(_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.scrollToItem({
align: 'smart',

@@ -605,3 +595,3 @@ columnIndex: lastSelection[1],

moveColumnLeft: function moveColumnLeft(columnKey) {
var _gridRef$current5;
var _gridRef$current2;

@@ -622,5 +612,8 @@ if (!onSwapColumns) {

var leftColumnKey = visibleColumns[leftColumnIndex].key;
(_gridRef$current5 = gridRef.current) === null || _gridRef$current5 === void 0 ? void 0 : _gridRef$current5.resetAfterColumnIndex(leftColumnIndex, false);
(_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.resetAfterColumnIndex(leftColumnIndex, false);
onSwapColumns(columnKey, leftColumnKey);
},
getSelectedRowsManager: function getSelectedRowsManager() {
return selectedRowsManager;
},
isRowSelected: function isRowSelected(sectionKey, rowKey) {

@@ -897,3 +890,3 @@ return selectedRowsManager.isRowSelected(sectionKey, rowKey);

moveColumnRight: function moveColumnRight(columnKey) {
var _gridRef$current6;
var _gridRef$current3;

@@ -914,3 +907,3 @@ if (!onSwapColumns) {

var rightColumnKey = visibleColumns[rightColumnIndex].key;
(_gridRef$current6 = gridRef.current) === null || _gridRef$current6 === void 0 ? void 0 : _gridRef$current6.resetAfterColumnIndex(columnIndex, false);
(_gridRef$current3 = gridRef.current) === null || _gridRef$current3 === void 0 ? void 0 : _gridRef$current3.resetAfterColumnIndex(columnIndex, false);
onSwapColumns(columnKey, rightColumnKey);

@@ -924,8 +917,8 @@ },

scrollTo: function scrollTo(scrollArgs) {
var _gridRef$current7;
var _gridRef$current4;
(_gridRef$current7 = gridRef.current) === null || _gridRef$current7 === void 0 ? void 0 : _gridRef$current7.scrollTo(scrollArgs);
(_gridRef$current4 = gridRef.current) === null || _gridRef$current4 === void 0 ? void 0 : _gridRef$current4.scrollTo(scrollArgs);
},
scrollToSection: function scrollToSection(sectionKey) {
var _gridRef$current8;
var _gridRef$current5;

@@ -935,3 +928,3 @@ var rowIndex = (0, _getSectionRawRowIndex["default"])(columnAndOverviewData.sections, sectionKey, getEffectiveSectionRowCount) - 3; // subtract a few so topSection and header row doesn't cover anything.

(_gridRef$current8 = gridRef.current) === null || _gridRef$current8 === void 0 ? void 0 : _gridRef$current8.scrollToItem({
(_gridRef$current5 = gridRef.current) === null || _gridRef$current5 === void 0 ? void 0 : _gridRef$current5.scrollToItem({
align: 'start',

@@ -1051,5 +1044,5 @@ rowIndex: rowIndex

var resetAfterColumnIndex = (0, React.useCallback)(function (index, shouldForceUpdate) {
var _gridRef$current9;
var _gridRef$current6;
return (_gridRef$current9 = gridRef.current) === null || _gridRef$current9 === void 0 ? void 0 : _gridRef$current9.resetAfterColumnIndex(index, shouldForceUpdate);
return (_gridRef$current6 = gridRef.current) === null || _gridRef$current6 === void 0 ? void 0 : _gridRef$current6.resetAfterColumnIndex(index, shouldForceUpdate);
}, []);

@@ -1056,0 +1049,0 @@ return /*#__PURE__*/React.createElement("div", {

@@ -35,3 +35,12 @@ "use strict";

var rectForRange = (0, _getRectForRange["default"])(start, end, columnAndOverviewData, sectionRowMatcher, defaultRowHeight, topSectionHeight, getEffectiveSectionRowCount);
var rectForRange = null;
try {
// TODO an error can happen here when a section has been
// collapsed when the selection was on it.
rectForRange = (0, _getRectForRange["default"])(start, end, columnAndOverviewData, sectionRowMatcher, defaultRowHeight, topSectionHeight, getEffectiveSectionRowCount);
} catch (err) {
console.warn('Caught error while trying to place RegionSpan', err);
}
return rectForRange && /*#__PURE__*/_react["default"].createElement("div", {

@@ -38,0 +47,0 @@ style: styleFunction(_objectSpread({

@@ -59,19 +59,33 @@ "use strict";

var selectionAsKeys = (0, _react.useCallback)(function (regions) {
return regions.map(function (_ref2) {
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
startIndexes = _ref3[0],
endIndexes = _ref3[1];
var results = [];
var start = mappers.cellIndexesToKeys(startIndexes[0], startIndexes[1]);
var end = mappers.cellIndexesToKeys(endIndexes[0], endIndexes[1]);
var _iterator = _createForOfIteratorHelper(regions),
_step;
if (start === null || end === null) {
throw new Error('cannot be null');
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = (0, _slicedToArray2["default"])(_step.value, 2),
startIndexes = _step$value[0],
endIndexes = _step$value[1];
var start = mappers.cellIndexesToKeys(startIndexes[0], startIndexes[1]);
var end = mappers.cellIndexesToKeys(endIndexes[0], endIndexes[1]);
if (start === null || end === null) {
// return empty list if any selections are unloaded
return [];
}
results.push({
start: start,
end: end
});
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return {
start: start,
end: end
};
});
return results;
}, [mappers]);

@@ -182,29 +196,33 @@ var updateSelection = (0, _react.useCallback)(function (action) {

var _iterator = _createForOfIteratorHelper(validSelections),
_step;
if (validSelections.length > 0) {
var effectiveSectionRowCount = getEffectiveSectionRowCount(sections[sectionIndexOfConcern]);
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var region = _step.value;
var _iterator2 = _createForOfIteratorHelper(validSelections),
_step2;
for (var i = region[0][0]; i <= region[1][0]; i++) {
var _matcher$getSectionRo = matcher.getSectionRow(i),
rowIndex = _matcher$getSectionRo.rowIndex,
sectionIndex = _matcher$getSectionRo.sectionIndex;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var region = _step2.value;
if (sectionIndex !== sectionIndexOfConcern) {
continue;
for (var i = region[0][0]; i <= Math.min(region[1][0], effectiveSectionRowCount - 1); i++) {
var _matcher$getSectionRo = matcher.getSectionRow(i),
rowIndex = _matcher$getSectionRo.rowIndex,
sectionIndex = _matcher$getSectionRo.sectionIndex;
if (sectionIndex !== sectionIndexOfConcern) {
continue;
}
indexesSet.add(rowIndex);
}
indexesSet.add(rowIndex);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return (0, _toConsumableArray2["default"])(indexesSet);
}, [cellSelections, matcher, sections, selectionAsIndexes]); // It's important that we conservatively change the array identity of the selected indices
}, [cellSelections, matcher, sections, selectionAsIndexes, getEffectiveSectionRowCount]); // It's important that we conservatively change the array identity of the selected indices
// The selection changing causes the selection to be brought into view, for one.

@@ -218,3 +236,5 @@

return selectedRegions.filter(_isNotNil["default"]);
}, [selectedRegionsJSON]);
}, [selectedRegionsJSON]); // TODO should this be a useEffect? Should this maybe happen during render, or where
// we set the selections? What case does this handle exactly?
(0, _react.useEffect)(function () {

@@ -221,0 +241,0 @@ var selectedRegions = JSON.parse(selectedRegionsJSON);

@@ -197,2 +197,7 @@ "use strict";

function useRowSelection(sections, rowsBySection, getSectionRelativeRowIndex) {
// TODO there's an awkward tension between wanting to use useReducer, and wanting to
// make the results available to the parent component of StreakSheet, because the results
// of useReducer can only be known during render of the component, at which time it's too
// late to send any results to the parent component before its render.
// Maybe row selection should be in sheet data or another hook?
var _useReducer = (0, _react.useReducer)(reducer, {

@@ -199,0 +204,0 @@ selectedSections: [],

@@ -234,2 +234,5 @@ "use strict";

updateSelectionManagerLatest.current = function (selectionManager) {
// It's a little bad that side-effects against the startedRowsRequests object happens
// here during render.
// TODO should this logic for marking requests as selected happen inside of a useEffect?
if (selectionManager !== lastSelectionManager.current) {

@@ -236,0 +239,0 @@ // we've got new rows to process

{
"name": "streaksheet",
"version": "0.9.11",
"version": "0.9.12",
"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

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