@rowsncolumns/spreadsheet 10.5.0 → 10.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AA82LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAg3LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
@@ -134,7 +134,7 @@ function CanvasGridComponent(props, forwardedRef) {
134
134
  // defaults to `getFormattedValue` inside `useGetValuesFromRange`.
135
135
  getValidationSourceValue = props.getValidationSourceValue,
136
136
  // Unused props only for api
137
- onChangeBorder = props.onChangeBorder, onDuplicateSheet = props.onDuplicateSheet, onCreateConditionalFormattingRule = props.onCreateConditionalFormattingRule, onDeleteConditionalFormattingRule = props.onDeleteConditionalFormattingRule, onUpdateConditionalFormattingRule = props.onUpdateConditionalFormattingRule, onCreateDataValidationRule = props.onCreateDataValidationRule, onUpdateDataValidationRule = props.onUpdateDataValidationRule, onDeleteDataValidationRule = props.onDeleteDataValidationRule, onCreateChart = props.onCreateChart, onDeleteSheet = props.onDeleteSheet, onCreateEmbed = props.onCreateEmbed, onDecreaseIndent = props.onDecreaseIndent, onIncreaseIndent = props.onIncreaseIndent, onChangeTheme = props.onChangeTheme, onChangeDecimals = props.onChangeDecimals, onUpdateSheet = props.onUpdateSheet, onChangeBatchStream = props.onChangeBatchStream, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["licenseKey", "sheetId", "sheetType", "ChartSheetView", "instanceId", "activeCell", "selections", "frozenColumnCount", "frozenRowCount", "rowCount", "columnCount", "autoFocus", "basicFilter", "tables", "namedRanges", "bandedRanges", "tableBorderColor", "filterIconColor", "conditionalFormats", "showFilterIcon", "showCalculatedColumnIcon", "showHeaders", "defaultColumnWidth", "defaultRowHeight", "columnHeaderHeight", "rowHeaderWidth", "gridLineColor", "cellBackgroundColor", "cellColor", "headerBorderColor", "headerBackgroundColor", "headerColor", "headerActiveBackgroundColor", "headerSelectedBackgroundColor", "headerSelectedColor", "headerTableBackgroundColor", "headerTableActiveBackgroundColor", "headerTableSelectedBackgroundColor", "frozenShadowColor", "frozenShadowThickness", "selectionBackgroundColor", "selectionBorderColor", "selectionDragBorderColor", "chartSelectedColor", "chipBackgroundColor", "merges", "borderStyles", "protectedRanges", "isWorkbookProtected", "getSheetProtection", "pivotTables", "charts", "onUpdateChart", "onChangeZOrder", "embeds", "slicers", "rowMetadata", "columnMetadata", "scale", "zoomSpeed", "overscanCount", "enableEditOnEnterKey", "enableTextOverflow", "showGridLines", "showFormulas", "protectFormulas", "showFrozenSeparator", "HeaderCell", "Cell", "SelectionTitleComponent", "CellEditor", "CellTooltip", "ContextMenu", "ContextMenuWrapper", "FilterBox", "HeaderMoveDragComponent", "SuggestionsDropdown", "stickyEditor", "scrollSnap", "scrollThrottleTimeout", "preventBrowserDefaultScroll", "mouseMoveThrottleTimeout", "tooltipIntentInterval", "selectionPolicy", "users", "userId", "renderCollaboratorCursor", "functionDescriptions", "showHeaderMenuButton", "scrollbarSize", "theme", "showNotes", "showComments", "locale", "formulaLocale", "agentSuggestions", "onReviewSuggestion", "onShowFormulas", "getDataRowCount", "getDataRegion", "getChartComponent", "getEmbedComponent", "getSlicerComponent", "onChange", "onChangeBatch", "onExpandCollapse", "onPivotDrillDown", "onDelete", "onChangeEditorValue", "onFill", "onRequestCalculate", "onChangeActiveCell", "onChangeActiveSheet", "onChangeSelections", "getSheetName", "getSheetId", "getCellData", "getNote", "getTextFormatRuns", "getDataValidation", "getEffectiveFormat", "getFormattedValue", "getTooltipContent", "errorResolutionComponent", "getEffectiveValue", "getSparklineGroup", "getUserEnteredExtendedValue", "getEffectiveExtendedValue", "getSheetRowCount", "getSheetColumnCount", "getCellPopoverContent", "onScroll", "onViewPortChange", "windowConditionalFormats", "engineConditionalFormatResults", "onResize", "onAutoResize", "onHideColumn", "onHideRow", "onShowColumn", "onShowRow", "onGroupRows", "onUngroupRows", "onCollapseRowGroup", "onExpandRowGroup", "onGroupColumns", "onUngroupColumns", "onCollapseColumnGroup", "onExpandColumnGroup", "onSetOutlineDepth", "onDeleteRow", "onDeleteColumn", "onInsertRow", "onInsertColumn", "onChangeAutoExpandTables", "onChangeAutoCalculatedColumns", "onInsertCellsShiftDown", "onInsertCellsShiftRight", "onDeleteCellsShiftLeft", "onDeleteCellsShiftUp", "onClearContents", "onMoveColumns", "onMoveRows", "onSelectNextSheet", "onSelectPreviousSheet", "onCreateNewSheet", "onKeyDown", "onChangeFormatting", "onRepeatFormatting", "onClearFormatting", "onRequestEditProtectedRange", "onMoveChart", "onResizeChart", "onDeleteChart", "onCutChart", "onCopyChart", "onMoveEmbed", "onResizeEmbed", "onDeleteEmbed", "onRequestEditEmbed", "onMoveSlicer", "onResizeSlicer", "onDeleteSlicer", "onRequestEditSlicer", "onFillRange", "disableFillRightShortcut", "keymap", "onCalculateNow", "onRequestGoTo", "onMoveSelection", "onInsertCutCells", "onInsertTime", "onInsertDate", "onInsertDateTime", "onInsertAutoSum", "onUndo", "onRedo", "onPaste", "onCopy", "onCut", "onSortColumn", "onSortTable", "onFilterTable", "onFilterPivot", "onResizeTable", "onUndoTableAutoExpansion", "onUndoCalculatedColumn", "onOverwriteCalculatedColumn", "onRequestEditTable", "onRequestEditPivotTable", "onRequestDeletePivotTable", "onRequestCreatePivotChart", "onRemoveTable", "onCreateTable", "onRequestCreateTable", "onInsertTableColumn", "onDeleteTableColumn", "onInsertTableRow", "onDeleteTableRow", "onUpdateTable", "onRequestResizeTable", "onRequestInsertSlicer", "onCreateBasicFilter", "onRequestDefineNamedRange", "onRequestFormatCells", "onRequestConditionalFormat", "onRequestDataValidation", "onRequestInsertComment", "onRequestInsertLink", "onFreezeColumn", "onFreezeRow", "onUpdateNote", "onProtectRange", "onUnProtectRange", "onSortRange", "onRequestSearch", "onRequestReplace", "onRequestResize", "getRowHeaderText", "getColumnHeaderText", "getAdditionalCellSpacing", "tokenizer", "onChangeScale", "onRemoveLink", "onSelectLink", "onSplitTextToColumns", "onRemoveDuplicates", "onGoalSeek", "onSubtotal", "onAdvancedFilter", "onRequestExpand", "cellExpandPredicate", "StructuredResult", "getMentions", "getStructuredProperties", "getFunctionParameterSuggestions", "shouldFetchFunctionParameters", "MentionTagComponent", "MentionDropdownItemComponent", "showSelectionResizeHandles", "enableMagicFill", "enableQuickEdit", "MagicFillComponent", "MagicFillContent", "QuickEdit", "PasteMenu", "SuggestionAction", "HiddenRowMarkers", "HiddenColumnMarkers", "enableResizerOverflow", "className", "defaultFontSizePoint", "defaultCellFormat", "readonly", "isComparing", "getCellDiff", "enableDataBoundaryNavigation", "footerHeight", "footerComponent", "arrowComponents", "hostHiddenRowRanges", "getFilterValues", "getFilterColors", "getValidationSourceValue", "onChangeBorder", "onDuplicateSheet", "onCreateConditionalFormattingRule", "onDeleteConditionalFormattingRule", "onUpdateConditionalFormattingRule", "onCreateDataValidationRule", "onUpdateDataValidationRule", "onDeleteDataValidationRule", "onCreateChart", "onDeleteSheet", "onCreateEmbed", "onDecreaseIndent", "onIncreaseIndent", "onChangeTheme", "onChangeDecimals", "onUpdateSheet", "onChangeBatchStream", "onBlur"]);
137
+ getDataColumnCount = props.getDataColumnCount, onDeleteNamedRange = props.onDeleteNamedRange, onChangeBorder = props.onChangeBorder, onDuplicateSheet = props.onDuplicateSheet, onCreateConditionalFormattingRule = props.onCreateConditionalFormattingRule, onDeleteConditionalFormattingRule = props.onDeleteConditionalFormattingRule, onUpdateConditionalFormattingRule = props.onUpdateConditionalFormattingRule, onCreateDataValidationRule = props.onCreateDataValidationRule, onUpdateDataValidationRule = props.onUpdateDataValidationRule, onDeleteDataValidationRule = props.onDeleteDataValidationRule, onCreateChart = props.onCreateChart, onDeleteSheet = props.onDeleteSheet, onCreateEmbed = props.onCreateEmbed, onDecreaseIndent = props.onDecreaseIndent, onIncreaseIndent = props.onIncreaseIndent, onChangeTheme = props.onChangeTheme, onChangeDecimals = props.onChangeDecimals, onUpdateSheet = props.onUpdateSheet, onChangeBatchStream = props.onChangeBatchStream, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["licenseKey", "sheetId", "sheetType", "ChartSheetView", "instanceId", "activeCell", "selections", "frozenColumnCount", "frozenRowCount", "rowCount", "columnCount", "autoFocus", "basicFilter", "tables", "namedRanges", "bandedRanges", "tableBorderColor", "filterIconColor", "conditionalFormats", "showFilterIcon", "showCalculatedColumnIcon", "showHeaders", "defaultColumnWidth", "defaultRowHeight", "columnHeaderHeight", "rowHeaderWidth", "gridLineColor", "cellBackgroundColor", "cellColor", "headerBorderColor", "headerBackgroundColor", "headerColor", "headerActiveBackgroundColor", "headerSelectedBackgroundColor", "headerSelectedColor", "headerTableBackgroundColor", "headerTableActiveBackgroundColor", "headerTableSelectedBackgroundColor", "frozenShadowColor", "frozenShadowThickness", "selectionBackgroundColor", "selectionBorderColor", "selectionDragBorderColor", "chartSelectedColor", "chipBackgroundColor", "merges", "borderStyles", "protectedRanges", "isWorkbookProtected", "getSheetProtection", "pivotTables", "charts", "onUpdateChart", "onChangeZOrder", "embeds", "slicers", "rowMetadata", "columnMetadata", "scale", "zoomSpeed", "overscanCount", "enableEditOnEnterKey", "enableTextOverflow", "showGridLines", "showFormulas", "protectFormulas", "showFrozenSeparator", "HeaderCell", "Cell", "SelectionTitleComponent", "CellEditor", "CellTooltip", "ContextMenu", "ContextMenuWrapper", "FilterBox", "HeaderMoveDragComponent", "SuggestionsDropdown", "stickyEditor", "scrollSnap", "scrollThrottleTimeout", "preventBrowserDefaultScroll", "mouseMoveThrottleTimeout", "tooltipIntentInterval", "selectionPolicy", "users", "userId", "renderCollaboratorCursor", "functionDescriptions", "showHeaderMenuButton", "scrollbarSize", "theme", "showNotes", "showComments", "locale", "formulaLocale", "agentSuggestions", "onReviewSuggestion", "onShowFormulas", "getDataRowCount", "getDataRegion", "getChartComponent", "getEmbedComponent", "getSlicerComponent", "onChange", "onChangeBatch", "onExpandCollapse", "onPivotDrillDown", "onDelete", "onChangeEditorValue", "onFill", "onRequestCalculate", "onChangeActiveCell", "onChangeActiveSheet", "onChangeSelections", "getSheetName", "getSheetId", "getCellData", "getNote", "getTextFormatRuns", "getDataValidation", "getEffectiveFormat", "getFormattedValue", "getTooltipContent", "errorResolutionComponent", "getEffectiveValue", "getSparklineGroup", "getUserEnteredExtendedValue", "getEffectiveExtendedValue", "getSheetRowCount", "getSheetColumnCount", "getCellPopoverContent", "onScroll", "onViewPortChange", "windowConditionalFormats", "engineConditionalFormatResults", "onResize", "onAutoResize", "onHideColumn", "onHideRow", "onShowColumn", "onShowRow", "onGroupRows", "onUngroupRows", "onCollapseRowGroup", "onExpandRowGroup", "onGroupColumns", "onUngroupColumns", "onCollapseColumnGroup", "onExpandColumnGroup", "onSetOutlineDepth", "onDeleteRow", "onDeleteColumn", "onInsertRow", "onInsertColumn", "onChangeAutoExpandTables", "onChangeAutoCalculatedColumns", "onInsertCellsShiftDown", "onInsertCellsShiftRight", "onDeleteCellsShiftLeft", "onDeleteCellsShiftUp", "onClearContents", "onMoveColumns", "onMoveRows", "onSelectNextSheet", "onSelectPreviousSheet", "onCreateNewSheet", "onKeyDown", "onChangeFormatting", "onRepeatFormatting", "onClearFormatting", "onRequestEditProtectedRange", "onMoveChart", "onResizeChart", "onDeleteChart", "onCutChart", "onCopyChart", "onMoveEmbed", "onResizeEmbed", "onDeleteEmbed", "onRequestEditEmbed", "onMoveSlicer", "onResizeSlicer", "onDeleteSlicer", "onRequestEditSlicer", "onFillRange", "disableFillRightShortcut", "keymap", "onCalculateNow", "onRequestGoTo", "onMoveSelection", "onInsertCutCells", "onInsertTime", "onInsertDate", "onInsertDateTime", "onInsertAutoSum", "onUndo", "onRedo", "onPaste", "onCopy", "onCut", "onSortColumn", "onSortTable", "onFilterTable", "onFilterPivot", "onResizeTable", "onUndoTableAutoExpansion", "onUndoCalculatedColumn", "onOverwriteCalculatedColumn", "onRequestEditTable", "onRequestEditPivotTable", "onRequestDeletePivotTable", "onRequestCreatePivotChart", "onRemoveTable", "onCreateTable", "onRequestCreateTable", "onInsertTableColumn", "onDeleteTableColumn", "onInsertTableRow", "onDeleteTableRow", "onUpdateTable", "onRequestResizeTable", "onRequestInsertSlicer", "onCreateBasicFilter", "onRequestDefineNamedRange", "onRequestFormatCells", "onRequestConditionalFormat", "onRequestDataValidation", "onRequestInsertComment", "onRequestInsertLink", "onFreezeColumn", "onFreezeRow", "onUpdateNote", "onProtectRange", "onUnProtectRange", "onSortRange", "onRequestSearch", "onRequestReplace", "onRequestResize", "getRowHeaderText", "getColumnHeaderText", "getAdditionalCellSpacing", "tokenizer", "onChangeScale", "onRemoveLink", "onSelectLink", "onSplitTextToColumns", "onRemoveDuplicates", "onGoalSeek", "onSubtotal", "onAdvancedFilter", "onRequestExpand", "cellExpandPredicate", "StructuredResult", "getMentions", "getStructuredProperties", "getFunctionParameterSuggestions", "shouldFetchFunctionParameters", "MentionTagComponent", "MentionDropdownItemComponent", "showSelectionResizeHandles", "enableMagicFill", "enableQuickEdit", "MagicFillComponent", "MagicFillContent", "QuickEdit", "PasteMenu", "SuggestionAction", "HiddenRowMarkers", "HiddenColumnMarkers", "enableResizerOverflow", "className", "defaultFontSizePoint", "defaultCellFormat", "readonly", "isComparing", "getCellDiff", "enableDataBoundaryNavigation", "footerHeight", "footerComponent", "arrowComponents", "hostHiddenRowRanges", "getFilterValues", "getFilterColors", "getValidationSourceValue", "getDataColumnCount", "onDeleteNamedRange", "onChangeBorder", "onDuplicateSheet", "onCreateConditionalFormattingRule", "onDeleteConditionalFormattingRule", "onUpdateConditionalFormattingRule", "onCreateDataValidationRule", "onUpdateDataValidationRule", "onDeleteDataValidationRule", "onCreateChart", "onDeleteSheet", "onCreateEmbed", "onDecreaseIndent", "onIncreaseIndent", "onChangeTheme", "onChangeDecimals", "onUpdateSheet", "onChangeBatchStream", "onBlur"]);
138
138
  /**
139
139
  * Fire onBlur only when the cell editor blurs to an element outside the
140
140
  * spreadsheet. Routed through `useEditable` so we hook the always-focused
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/range-selector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACd,MAAM,oBAAoB,CAAC;AAiC5B,OAAO,KAAyD,MAAM,OAAO,CAAC;AAU9E,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAc,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,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E,EAC/C,WAA2B,EAC3B,MAAsB,EACtB,MAAsB,EACtB,MAAM,EACN,UAA0B,EAC1B,UAAU,EACV,QAAwB,EACxB,WAA8B,EAC9B,OAAO,EACP,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,GAC1B,EAAE,uBAAuB,CAAC,CAAC,CAAC,qBAiN5B;AAED,eAAO,MAAM,aAAa,EAErB,OAAO,sBAAsB,CAAC"}
@@ -94,21 +94,45 @@ function RangeSelectorContent(_a) {
94
94
  title));
95
95
  })));
96
96
  }
97
+ /**
98
+ * The Name Box's dropdown, memoised so a cursor move does not re-render it: the
99
+ * Radix `DropdownMenu` root schedules a nested state update on every render even
100
+ * while closed, which — on top of the input-sync re-render — is what pushed a held
101
+ * arrow key past React's nested-update limit (rowsncolumns/spreadsheet#1127).
102
+ */
103
+ function NameBoxMenuComponent(_a) {
104
+ var isOpen = _a.isOpen, onOpenChange = _a.onOpenChange, namedRanges = _a.namedRanges, tables = _a.tables, sheets = _a.sheets, sheetId = _a.sheetId, activeCell = _a.activeCell, selections = _a.selections, shouldFocusSheetRef = _a.shouldFocusSheetRef, focusSheet = _a.focusSheet, onSelectNamedRange = _a.onSelectNamedRange, onSelectTable = _a.onSelectTable, onRequestUpdateNamedRange = _a.onRequestUpdateNamedRange, onDeleteNamedRange = _a.onDeleteNamedRange, onRequestDefineNamedRange = _a.onRequestDefineNamedRange, onChangeActiveSheet = _a.onChangeActiveSheet;
105
+ return (react_1.default.createElement(ui_1.DropdownMenu, { modal: false, open: isOpen, onOpenChange: onOpenChange },
106
+ react_1.default.createElement(ui_1.DropdownMenuTrigger, { asChild: true },
107
+ react_1.default.createElement(ui_1.IconButton, { className: "rounded-none mr-0", shrink: true },
108
+ react_1.default.createElement(icons_1.TriangleDownIcon, null))),
109
+ react_1.default.createElement(ui_1.DropdownMenuPortal, null,
110
+ react_1.default.createElement(ui_1.DropdownMenuContent, { align: "start", alignOffset: -SELECTOR_WIDTH + ICON_WIDTH, sideOffset: 1, className: "max-h-[300px] overflow-auto", onCloseAutoFocus: function (event) {
111
+ event.preventDefault();
112
+ if (shouldFocusSheetRef.current && !isOpen) {
113
+ focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
114
+ }
115
+ } },
116
+ react_1.default.createElement(RangeSelectorContent, { namedRanges: namedRanges, tables: tables, sheets: sheets, sheetId: sheetId, activeCell: activeCell, selections: selections, isOpen: isOpen, shouldFocusSheetRef: shouldFocusSheetRef, onSelectNamedRange: onSelectNamedRange, onSelectTable: onSelectTable, onRequestUpdateNamedRange: onRequestUpdateNamedRange, onDeleteNamedRange: onDeleteNamedRange, onRequestDefineNamedRange: onRequestDefineNamedRange, onChangeActiveSheet: onChangeActiveSheet })))));
117
+ }
118
+ var NameBoxMenu = (0, react_1.memo)(NameBoxMenuComponent);
97
119
  function RangeSelectorComponent(_a) {
98
120
  var _b = _a.namedRanges, namedRanges = _b === void 0 ? config_1.DEFAULT_ARRAY : _b, _c = _a.tables, tables = _c === void 0 ? config_1.DEFAULT_ARRAY : _c, _d = _a.sheets, sheets = _d === void 0 ? config_1.DEFAULT_ARRAY : _d, merges = _a.merges, _e = _a.selections, selections = _e === void 0 ? config_1.DEFAULT_ARRAY : _e, activeCell = _a.activeCell, _f = _a.rowCount, rowCount = _f === void 0 ? config_1.MAX_ROW_COUNT : _f, _g = _a.columnCount, columnCount = _g === void 0 ? config_1.MAX_COLUMN_COUNT : _g, sheetId = _a.sheetId, onChangeActiveSheet = _a.onChangeActiveSheet, onChangeActiveCell = _a.onChangeActiveCell, onChangeSelections = _a.onChangeSelections, onRequestUpdateNamedRange = _a.onRequestUpdateNamedRange, onDeleteNamedRange = _a.onDeleteNamedRange, onRequestDefineNamedRange = _a.onRequestDefineNamedRange;
99
121
  var _h = tslib_1.__read((0, react_1.useState)(false), 2), isOpen = _h[0], setIsOpen = _h[1];
100
- var _j = tslib_1.__read((0, react_1.useState)(""), 2), value = _j[0], setValue = _j[1];
122
+ // Only what the user is typing into the Name Box; `null` while it just mirrors the
123
+ // selection. The mirrored address is DERIVED during render below — syncing it into
124
+ // state from an effect scheduled one extra synchronous re-render per cursor move,
125
+ // which React's nested-update counter turned into "Maximum update depth exceeded"
126
+ // (#185) under a held arrow key in production builds (rowsncolumns/spreadsheet#1127).
127
+ var _j = tslib_1.__read((0, react_1.useState)(null), 2), draft = _j[0], setDraft = _j[1];
101
128
  var inputRef = (0, react_1.useRef)(null);
102
129
  var navigateToSheetRange = (0, range_selector_atom_1.useRangeContext)().navigateToSheetRange;
103
130
  var isFormulaMode = (0, atoms_1.useFormulaModeValue)();
104
131
  var shouldFocusSheetRef = (0, react_1.useRef)(false);
105
132
  var focusSheet = (0, atoms_1.useFocusSheet)();
106
133
  var getAddressFromSelection = (0, atoms_1.useGetAddressFromSelection)();
107
- // Keep input value in sync with activeCell and selections
108
- (0, react_1.useEffect)(function () {
109
- if (isFormulaMode) {
110
- return;
111
- }
134
+ // The address (or named-range name) of the current selection / active cell.
135
+ var derivedAddress = (0, react_1.useMemo)(function () {
112
136
  var lastSelection = selections[selections.length - 1];
113
137
  var isSelectionInProgress = lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.inProgress;
114
138
  var inputValue = lastSelection
@@ -122,19 +146,31 @@ function RangeSelectorComponent(_a) {
122
146
  return (range &&
123
147
  (0, grid_1.isAreasEqual)(range, lastSelection ? lastSelection.range : (0, utils_1.convertCellToRange)(activeCell)));
124
148
  });
125
- if (inputValue) {
126
- setValue(range ? range.name : inputValue);
127
- }
149
+ return inputValue ? (range ? range.name : inputValue) : undefined;
150
+ // `rowCount` / `columnCount` / `merges` shape the address text through
151
+ // `getAddressFromSelection` without being read here directly.
152
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
153
  }, [
129
154
  rowCount,
130
155
  columnCount,
131
156
  activeCell,
132
157
  selections,
133
158
  namedRanges,
134
- isFormulaMode,
135
159
  merges,
136
160
  getAddressFromSelection,
137
161
  ]);
162
+ // Formula mode freezes the box at the address it showed when the formula started
163
+ // (a range picked for the formula must not rename the box); remember the last
164
+ // address shown outside formula mode without scheduling a render.
165
+ var frozenAddressRef = (0, react_1.useRef)("");
166
+ (0, react_1.useEffect)(function () {
167
+ if (!isFormulaMode && derivedAddress !== undefined) {
168
+ frozenAddressRef.current = derivedAddress;
169
+ }
170
+ }, [isFormulaMode, derivedAddress]);
171
+ var value = draft !== null && draft !== void 0 ? draft : (isFormulaMode
172
+ ? frozenAddressRef.current
173
+ : derivedAddress !== null && derivedAddress !== void 0 ? derivedAddress : frozenAddressRef.current);
138
174
  // Select a range of cells in a sheet
139
175
  var onSelectRange = (0, react_1.useCallback)(function (range) {
140
176
  navigateToSheetRange === null || navigateToSheetRange === void 0 ? void 0 : navigateToSheetRange(range, { enableFlash: false });
@@ -156,6 +192,7 @@ function RangeSelectorComponent(_a) {
156
192
  var _a, _b, _c, _d;
157
193
  if (e.key === "Enter") {
158
194
  var value_1 = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value;
195
+ setDraft(null);
159
196
  if (value_1) {
160
197
  // Check for named range
161
198
  var namedRange = namedRanges.find(function (range) { return range.name === value_1; });
@@ -205,13 +242,7 @@ function RangeSelectorComponent(_a) {
205
242
  else if (e.key === "Escape" && !isFormulaMode) {
206
243
  // Revert the Name Box to the current selection/active cell on
207
244
  // Escape, then return focus to the grid.
208
- var lastSelection = selections[selections.length - 1];
209
- var reverted = lastSelection
210
- ? getAddressFromSelection === null || getAddressFromSelection === void 0 ? void 0 : getAddressFromSelection(lastSelection, undefined)
211
- : (0, utils_1.cellToAddress)(activeCell);
212
- if (reverted) {
213
- setValue(reverted);
214
- }
245
+ setDraft(null);
215
246
  (_d = inputRef.current) === null || _d === void 0 ? void 0 : _d.blur();
216
247
  focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
217
248
  return;
@@ -226,25 +257,14 @@ function RangeSelectorComponent(_a) {
226
257
  onChangeSelections,
227
258
  isFormulaMode,
228
259
  focusSheet,
229
- selections,
230
- activeCell,
231
- getAddressFromSelection,
232
- setValue,
233
260
  navigateToSheetRange,
234
261
  ]);
235
262
  return (react_1.default.createElement("div", { className: "flex h-full w-[90px]" },
236
- react_1.default.createElement(ui_1.Input, { value: value, type: "text", ref: inputRef, onChange: function (e) { return setValue(e.target.value); }, onKeyDown: handleKeyDown, onFocus: function (e) { return e.target.select(); }, className: "text-xs border-none rounded-none outline-none m-0 bg-rnc-background text-rnc-foreground w-full" }),
237
- react_1.default.createElement(ui_1.DropdownMenu, { modal: false, open: isOpen, onOpenChange: setIsOpen },
238
- react_1.default.createElement(ui_1.DropdownMenuTrigger, { asChild: true },
239
- react_1.default.createElement(ui_1.IconButton, { className: "rounded-none mr-0", shrink: true },
240
- react_1.default.createElement(icons_1.TriangleDownIcon, null))),
241
- react_1.default.createElement(ui_1.DropdownMenuPortal, null,
242
- react_1.default.createElement(ui_1.DropdownMenuContent, { align: "start", alignOffset: -SELECTOR_WIDTH + ICON_WIDTH, sideOffset: 1, className: "max-h-[300px] overflow-auto", onCloseAutoFocus: function (event) {
243
- event.preventDefault();
244
- if (shouldFocusSheetRef.current && !isOpen) {
245
- focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
246
- }
247
- } },
248
- react_1.default.createElement(RangeSelectorContent, { namedRanges: namedRanges, tables: tables, sheets: sheets, sheetId: sheetId, activeCell: activeCell, selections: selections, isOpen: isOpen, shouldFocusSheetRef: shouldFocusSheetRef, onSelectNamedRange: onSelectNamedRange, onSelectTable: onSelectTable, onRequestUpdateNamedRange: onRequestUpdateNamedRange, onDeleteNamedRange: onDeleteNamedRange, onRequestDefineNamedRange: onRequestDefineNamedRange, onChangeActiveSheet: onChangeActiveSheet }))))));
263
+ react_1.default.createElement(ui_1.Input, { value: value, type: "text", ref: inputRef, onChange: function (e) { return setDraft(e.target.value); }, onKeyDown: handleKeyDown, onFocus: function (e) { return e.target.select(); }, onBlur: function () { return setDraft(null); }, className: "text-xs border-none rounded-none outline-none m-0 bg-rnc-background text-rnc-foreground w-full" }),
264
+ react_1.default.createElement(NameBoxMenu, { isOpen: isOpen, onOpenChange: setIsOpen, namedRanges: namedRanges, tables: tables, sheets: sheets, sheetId: sheetId,
265
+ // Only an open menu reads the selection; while closed the props stay
266
+ // put so a cursor move never re-renders the Radix root (it schedules a
267
+ // nested update on every render, see the component note).
268
+ activeCell: isOpen ? activeCell : config_1.DEFAULT_ACTIVE_CELL, selections: isOpen ? selections : config_1.DEFAULT_ARRAY, shouldFocusSheetRef: shouldFocusSheetRef, focusSheet: focusSheet, onSelectNamedRange: onSelectNamedRange, onSelectTable: onSelectTable, onRequestUpdateNamedRange: onRequestUpdateNamedRange, onDeleteNamedRange: onDeleteNamedRange, onRequestDefineNamedRange: onRequestDefineNamedRange, onChangeActiveSheet: onChangeActiveSheet })));
249
269
  }
250
270
  exports.RangeSelector = (0, react_1.memo)(RangeSelectorComponent);
@@ -2,7 +2,28 @@ import { FontLoader } from "../api/font-loader";
2
2
  export type UseFontResults = {
3
3
  isFontActive: boolean;
4
4
  };
5
+ /** A host-provided font loader: receives `Family:weight` specs, resolves when they are usable. */
6
+ export type WebFontLoader = (fonts: string[]) => Promise<void | undefined>;
7
+ export type WebFontOptions = {
8
+ /**
9
+ * Whether the grid may fetch web fonts (a Google Fonts stylesheet appended to
10
+ * `document.head`). Hosts with a strict Content-Security-Policy or that must
11
+ * work offline turn this off; the formula editor then uses whatever
12
+ * `--rnc-formula-font-family` resolves to (rowsncolumns/spreadsheet#1125).
13
+ * Default `true`.
14
+ */
15
+ loadWebFonts?: boolean;
16
+ /** Load fonts through the host instead of Google Fonts (`onRequestFonts`). */
17
+ onRequestFonts?: WebFontLoader;
18
+ };
19
+ /** Configure web-font loading for every grid on the page (what `useFonts` applies from its options). */
20
+ export declare const configureWebFonts: (options: WebFontOptions | undefined) => void;
21
+ export declare const isWebFontLoadingEnabled: () => boolean;
5
22
  export declare const getWebFont: () => FontLoader | undefined;
6
- export declare const loadWebFont: (fonts: string[]) => Promise<void | undefined>;
7
- export declare const useFonts: (fonts?: string) => void;
23
+ /**
24
+ * Load `Family:weight` specs — through the host's loader when one is configured,
25
+ * otherwise from Google Fonts; a no-op when web fonts are turned off.
26
+ */
27
+ export declare const loadWebFont: (fonts: string[]) => Promise<void>;
28
+ export declare const useFonts: (fonts?: string, options?: WebFontOptions) => void;
8
29
  //# sourceMappingURL=use-fonts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-fonts.d.ts","sourceRoot":"","sources":["../../../hooks/use-fonts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,UAAU,8BAAmD,CAAC;AAE3E,eAAO,MAAM,WAAW,GAAU,OAAO,MAAM,EAAE,8BAEhD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,SAMtC,CAAC"}
1
+ {"version":3,"file":"use-fonts.d.ts","sourceRoot":"","sources":["../../../hooks/use-fonts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,kGAAkG;AAClG,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,aAAa,CAAC;CAChC,CAAC;AAQF,wGAAwG;AACxG,eAAO,MAAM,iBAAiB,GAAI,SAAS,cAAc,GAAG,SAAS,SAKpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,eAA8B,CAAC;AAEnE,eAAO,MAAM,UAAU,8BAAmD,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,OAAO,MAAM,EAAE,kBAIhD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,EAAE,UAAU,cAAc,SAYhE,CAAC"}
@@ -1,24 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFonts = exports.loadWebFont = exports.getWebFont = void 0;
3
+ exports.useFonts = exports.loadWebFont = exports.getWebFont = exports.isWebFontLoadingEnabled = exports.configureWebFonts = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var grid_1 = require("@rowsncolumns/grid");
6
6
  var react_1 = require("react");
7
7
  var font_loader_1 = require("../api/font-loader");
8
+ // Page-level: every grid on the page shares one policy, and the paste / import /
9
+ // font-picker fallbacks consult it too, so "off" means no third-party request at all.
10
+ var webFontConfig = { enabled: true };
11
+ /** Configure web-font loading for every grid on the page (what `useFonts` applies from its options). */
12
+ var configureWebFonts = function (options) {
13
+ var _a;
14
+ webFontConfig = {
15
+ enabled: (_a = options === null || options === void 0 ? void 0 : options.loadWebFonts) !== null && _a !== void 0 ? _a : true,
16
+ loader: options === null || options === void 0 ? void 0 : options.onRequestFonts,
17
+ };
18
+ };
19
+ exports.configureWebFonts = configureWebFonts;
20
+ var isWebFontLoadingEnabled = function () { return webFontConfig.enabled; };
21
+ exports.isWebFontLoadingEnabled = isWebFontLoadingEnabled;
8
22
  var getWebFont = function () { return (grid_1.canUseDOM ? new font_loader_1.FontLoader() : undefined); };
9
23
  exports.getWebFont = getWebFont;
24
+ /**
25
+ * Load `Family:weight` specs — through the host's loader when one is configured,
26
+ * otherwise from Google Fonts; a no-op when web fonts are turned off.
27
+ */
10
28
  var loadWebFont = function (fonts) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
11
29
  var _a;
12
30
  return tslib_1.__generator(this, function (_b) {
31
+ if (!webFontConfig.enabled)
32
+ return [2 /*return*/];
33
+ if (webFontConfig.loader)
34
+ return [2 /*return*/, webFontConfig.loader(fonts)];
13
35
  return [2 /*return*/, (_a = (0, exports.getWebFont)()) === null || _a === void 0 ? void 0 : _a.loadFonts(fonts)];
14
36
  });
15
37
  }); };
16
38
  exports.loadWebFont = loadWebFont;
17
- var useFonts = function (fonts) {
39
+ var useFonts = function (fonts, options) {
40
+ var _a;
41
+ var loadWebFonts = (_a = options === null || options === void 0 ? void 0 : options.loadWebFonts) !== null && _a !== void 0 ? _a : true;
42
+ var onRequestFonts = options === null || options === void 0 ? void 0 : options.onRequestFonts;
43
+ (0, react_1.useEffect)(function () {
44
+ (0, exports.configureWebFonts)({ loadWebFonts: loadWebFonts, onRequestFonts: onRequestFonts });
45
+ }, [loadWebFonts, onRequestFonts]);
18
46
  (0, react_1.useEffect)(function () {
47
+ if (!loadWebFonts)
48
+ return;
19
49
  var defaultFonts = ["Inconsolata:400"];
20
50
  var finalFonts = fonts === null || fonts === void 0 ? void 0 : fonts.split(",").map(function (value) { return String(value).trim(); });
21
51
  (0, exports.loadWebFont)(defaultFonts.concat(finalFonts ? finalFonts : []));
22
- }, [fonts]);
52
+ }, [fonts, loadWebFonts]);
23
53
  };
24
54
  exports.useFonts = useFonts;
@@ -1 +1 @@
1
- {"version":3,"file":"use-selection.d.ts","sourceRoot":"","sources":["../../../hooks/use-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACL,KAAK,EAcN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,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;IACvC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAuG7D,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,SAAS,EAAE,8uBA6C/C,mBAAmB,CAAC,CAAC,CAAC;;;;;;8BA2gEhB,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,cACvB,aAAa,GAAG,SAAS,aAC1B,aAAa,GAAG,SAAS,SAC7B,MAAM,GAAG,SAAS;4BAsMnB,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC;qBApgCtC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,UAAU,CAAC,YAAY;mBAsL1D,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa;0BArlC1C,aAAa,QAAO,aAAa;+BA2/CrC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;iCAmchC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;;;;8BA1iE3B,aAAa,kBAAkB,OAAO;;6BA+DvC,aAAa,QAAO,aAAa;;;6BAoL5B,MAAM,UACP,aAAa,kCAEb,KAAK;;6CAkqDT,aAAa,GAAG,SAAS,cACnB,aAAa,EAAE,GAAG,SAAS;mCAn8DjC,aAAa,OAAO,aAAa;;;;;;gCAguB3B,MAAM,GAAG,SAAS;gDA0yCpB,MAAM,aAAa,aAAa,KAAG,SAAS;CAgP3D,CAAC"}
@@ -171,6 +171,52 @@ var useSelection = function (_a) {
171
171
  (0, grid_3.useIsomorphicLayoutEffect)(function () {
172
172
  activeCellRef.current = activeCell;
173
173
  }, [activeCell]);
174
+ /**
175
+ * The last active cell this hook itself emitted. When the `activeCell` prop
176
+ * moves without a grid gesture — undo/redo restoring the cursor, a host
177
+ * navigating — the arrow-key anchor (`selectionStart`/`selectionEnd`) must
178
+ * follow it, or the next arrow key moves from where the cursor was before
179
+ * (rowsncolumns/spreadsheet#1124). Cells the hook emitted itself are skipped:
180
+ * Cmd+click anchors at the range's `start`, not the top-left it emits, and
181
+ * Shift+Arrow never emits at all, so its fixed anchor survives.
182
+ */
183
+ var lastEmittedActiveCellRef = (0, react_1.useRef)(null);
184
+ var emitActiveCell = (0, react_1.useCallback)(function (sheetId, cell) {
185
+ lastEmittedActiveCellRef.current = cell;
186
+ onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, cell);
187
+ }, [onChangeActiveCell]);
188
+ (0, grid_3.useIsomorphicLayoutEffect)(function () {
189
+ var _a;
190
+ if (!activeCell)
191
+ return;
192
+ var emitted = lastEmittedActiveCellRef.current;
193
+ if (emitted &&
194
+ emitted.rowIndex === activeCell.rowIndex &&
195
+ emitted.columnIndex === activeCell.columnIndex) {
196
+ return;
197
+ }
198
+ if (isSelecting.current || isFilling.current || isDragging.current)
199
+ return;
200
+ var range = (_a = selections[selections.length - 1]) === null || _a === void 0 ? void 0 : _a.range;
201
+ if (range && (0, grid_1.isCellWithinBounds)(activeCell, range)) {
202
+ // Keep the selection; anchor at the active cell and let the far corner
203
+ // be the moving end so Shift+Arrow extends from here.
204
+ selectionStart.current = activeCell;
205
+ selectionEnd.current = {
206
+ rowIndex: activeCell.rowIndex === range.startRowIndex
207
+ ? range.endRowIndex
208
+ : range.startRowIndex,
209
+ columnIndex: activeCell.columnIndex === range.startColumnIndex
210
+ ? range.endColumnIndex
211
+ : range.startColumnIndex,
212
+ };
213
+ }
214
+ else {
215
+ selectionStart.current = activeCell;
216
+ selectionEnd.current = activeCell;
217
+ }
218
+ // eslint-disable-next-line react-hooks/exhaustive-deps
219
+ }, [sheetId, activeCell === null || activeCell === void 0 ? void 0 : activeCell.rowIndex, activeCell === null || activeCell === void 0 ? void 0 : activeCell.columnIndex]);
174
220
  (0, grid_3.useIsomorphicLayoutEffect)(function () {
175
221
  mergedCellsRef.current = mergedCells;
176
222
  }, [mergedCells]);
@@ -280,7 +326,7 @@ var useSelection = function (_a) {
280
326
  if (!range) {
281
327
  return;
282
328
  }
283
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, {
329
+ emitActiveCell(sheetId, {
284
330
  rowIndex: range.startRowIndex,
285
331
  columnIndex: range.startColumnIndex,
286
332
  });
@@ -290,7 +336,7 @@ var useSelection = function (_a) {
290
336
  }, [
291
337
  sheetId,
292
338
  onChangeSelections,
293
- onChangeActiveCell,
339
+ emitActiveCell,
294
340
  selectionFromStartEnd,
295
341
  isCellOutOfBounds,
296
342
  selectionPolicy,
@@ -317,7 +363,7 @@ var useSelection = function (_a) {
317
363
  columnIndex: bounds.startColumnIndex,
318
364
  };
319
365
  /* Keep track of first cell that was selected by user */
320
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, coords);
366
+ emitActiveCell(sheetId, coords);
321
367
  if (newSelectionMode === "clear") {
322
368
  clearSelections();
323
369
  }
@@ -333,7 +379,7 @@ var useSelection = function (_a) {
333
379
  appendSelection,
334
380
  newSelectionMode,
335
381
  clearSelections,
336
- onChangeActiveCell,
382
+ emitActiveCell,
337
383
  selectionFromStartEnd,
338
384
  isCellOutOfBounds,
339
385
  ]);
@@ -411,12 +457,12 @@ var useSelection = function (_a) {
411
457
  if (shouldScroll === void 0) { shouldScroll = true; }
412
458
  selectionStart.current = coords;
413
459
  selectionEnd.current = coords;
414
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, coords);
460
+ emitActiveCell(sheetId, coords);
415
461
  /* Scroll to the cell */
416
462
  if (shouldScroll && coords) {
417
463
  scrollToCell(coords, align);
418
464
  }
419
- }, [onChangeActiveCell, scrollToCell]));
465
+ }, [emitActiveCell, scrollToCell]));
420
466
  /**
421
467
  * Navigate selection using keyboard
422
468
  * @param direction
@@ -1036,7 +1082,7 @@ var useSelection = function (_a) {
1036
1082
  var newSelection_1 = removeSelectionByIndex(cellIndex);
1037
1083
  var nextActiveCell = getPossibleActiveCellFromSelections(newSelection_1);
1038
1084
  if (nextActiveCell !== null) {
1039
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, nextActiveCell);
1085
+ emitActiveCell(sheetId, nextActiveCell);
1040
1086
  }
1041
1087
  if (newSelection_1.length === 1 &&
1042
1088
  cellEqualsSelection(nextActiveCell, newSelection_1)) {
@@ -1090,7 +1136,7 @@ var useSelection = function (_a) {
1090
1136
  modifySelection,
1091
1137
  mouseDownInterceptor,
1092
1138
  newSelection,
1093
- onChangeActiveCell,
1139
+ emitActiveCell,
1094
1140
  removeSelectionByIndex,
1095
1141
  selectionLeftBound,
1096
1142
  selectionTopBound,
@@ -1174,7 +1220,7 @@ var useSelection = function (_a) {
1174
1220
  var direction = isShiftKey ? grid_4.Direction.Up : grid_4.Direction.Down;
1175
1221
  var nextCell = (0, grid_4.findNextCellWithinBounds)(activeCellBounds, range, direction);
1176
1222
  if (nextCell) {
1177
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, nextCell);
1223
+ emitActiveCell(sheetId, nextCell);
1178
1224
  scrollToCell(nextCell);
1179
1225
  }
1180
1226
  }
@@ -1195,7 +1241,7 @@ var useSelection = function (_a) {
1195
1241
  var direction = isShiftKey ? grid_4.Direction.Left : grid_4.Direction.Right;
1196
1242
  var nextCell = (0, grid_4.findNextCellWithinBounds)(activeCellBounds, range, direction);
1197
1243
  if (nextCell) {
1198
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, nextCell);
1244
+ emitActiveCell(sheetId, nextCell);
1199
1245
  scrollToCell(nextCell);
1200
1246
  }
1201
1247
  }
@@ -1246,7 +1292,7 @@ var useSelection = function (_a) {
1246
1292
  activeCell,
1247
1293
  selections,
1248
1294
  keyNavigate,
1249
- onChangeActiveCell,
1295
+ emitActiveCell,
1250
1296
  pageDown,
1251
1297
  pageLeft,
1252
1298
  pageRight,
@@ -1394,7 +1440,7 @@ var useSelection = function (_a) {
1394
1440
  // The active cell normally anchors the surviving corner; if it fell in the cleared band,
1395
1441
  // move it to the remaining range's top-left so it never points at a deselected cell.
1396
1442
  if (!cellInRange(activeCell, shrink.remaining)) {
1397
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, {
1443
+ emitActiveCell(sheetId, {
1398
1444
  rowIndex: shrink.remaining.startRowIndex,
1399
1445
  columnIndex: shrink.remaining.startColumnIndex,
1400
1446
  });
@@ -1442,7 +1488,7 @@ var useSelection = function (_a) {
1442
1488
  focus,
1443
1489
  handleFillMouseMove,
1444
1490
  onChangeSelections,
1445
- onChangeActiveCell,
1491
+ emitActiveCell,
1446
1492
  onFill,
1447
1493
  onFillHandleRelease,
1448
1494
  onFillShrink,
@@ -1543,7 +1589,7 @@ var useSelection = function (_a) {
1543
1589
  columnIndex: toSelection.range.startColumnIndex,
1544
1590
  };
1545
1591
  /* Pick the first cell as activee cell */
1546
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, coords);
1592
+ emitActiveCell(sheetId, coords);
1547
1593
  /* Update selection start */
1548
1594
  selectionStart.current = coords;
1549
1595
  if ((0, grid_4.selectionSpansCells)(toSelection === null || toSelection === void 0 ? void 0 : toSelection.range)) {
@@ -1581,7 +1627,7 @@ var useSelection = function (_a) {
1581
1627
  onMoveSelection === null || onMoveSelection === void 0 ? void 0 : onMoveSelection(sheetId, fromSelection, toSelection);
1582
1628
  return;
1583
1629
  }
1584
- onChangeActiveCell === null || onChangeActiveCell === void 0 ? void 0 : onChangeActiveCell(sheetId, {
1630
+ emitActiveCell(sheetId, {
1585
1631
  rowIndex: fromSelection.range.startRowIndex,
1586
1632
  columnIndex: fromSelection.range.startColumnIndex,
1587
1633
  });
@@ -1621,7 +1667,7 @@ var useSelection = function (_a) {
1621
1667
  getValue,
1622
1668
  handleSelectionMouseMove,
1623
1669
  focus,
1624
- onChangeActiveCell,
1670
+ emitActiveCell,
1625
1671
  onChangeSelections,
1626
1672
  ]);
1627
1673
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AA82LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAg3LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
@@ -129,7 +129,7 @@ function CanvasGridComponent(props, forwardedRef) {
129
129
  // defaults to `getFormattedValue` inside `useGetValuesFromRange`.
130
130
  getValidationSourceValue,
131
131
  // Unused props only for api
132
- onChangeBorder, onDuplicateSheet, onCreateConditionalFormattingRule, onDeleteConditionalFormattingRule, onUpdateConditionalFormattingRule, onCreateDataValidationRule, onUpdateDataValidationRule, onDeleteDataValidationRule, onCreateChart, onDeleteSheet, onCreateEmbed, onDecreaseIndent, onIncreaseIndent, onChangeTheme, onChangeDecimals, onUpdateSheet, onChangeBatchStream, onBlur, ...rest } = props;
132
+ getDataColumnCount, onDeleteNamedRange, onChangeBorder, onDuplicateSheet, onCreateConditionalFormattingRule, onDeleteConditionalFormattingRule, onUpdateConditionalFormattingRule, onCreateDataValidationRule, onUpdateDataValidationRule, onDeleteDataValidationRule, onCreateChart, onDeleteSheet, onCreateEmbed, onDecreaseIndent, onIncreaseIndent, onChangeTheme, onChangeDecimals, onUpdateSheet, onChangeBatchStream, onBlur, ...rest } = props;
133
133
  /**
134
134
  * Fire onBlur only when the cell editor blurs to an element outside the
135
135
  * spreadsheet. Routed through `useEditable` so we hook the always-focused
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/range-selector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACd,MAAM,oBAAoB,CAAC;AAiC5B,OAAO,KAAyD,MAAM,OAAO,CAAC;AAU9E,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAc,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAEhC,KAAK,uBAAuB,CAAC,CAAC,SAAS,KAAK,IAAI;IAC9C,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,CAAC;IAClD,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IACb,WAAW,CAAC,EAAE,UAAU,EAAE,CA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AAC,qBAiN5B;AAED,eAAO,MAAM,aAAa,EAErB,OAAO,sBAAsB,CAAC"}
@@ -3,11 +3,11 @@ import { ChevronRightIcon, FileIcon, GroupIcon, PlusIcon, TableIcon, TriangleDow
3
3
  import { DropdownLeftSlot, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DropdownRightSlot, IconButton, Input, } from "@rowsncolumns/ui";
4
4
  import { addressToCell, cellToAddress, convertCellToRange, sortSheetsByIndex, } from "@rowsncolumns/utils";
5
5
  import { useVirtualizer } from "@tanstack/react-virtual";
6
- import React, { memo, useCallback, useEffect, useRef, useState } from "react";
6
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState, } from "react";
7
7
  import { addressToSelection, selectionToRxC } from "../../api/selections";
8
8
  import { useFocusSheet, useFormulaModeValue, useGetAddressFromSelection, } from "../../atoms";
9
9
  import { useRangeContext } from "../../atoms/range-selector.atom";
10
- import { DEFAULT_ARRAY, MAX_COLUMN_COUNT, MAX_ROW_COUNT } from "../../config";
10
+ import { DEFAULT_ACTIVE_CELL, DEFAULT_ARRAY, MAX_COLUMN_COUNT, MAX_ROW_COUNT, } from "../../config";
11
11
  const SELECTOR_WIDTH = 90;
12
12
  const ICON_WIDTH = 23;
13
13
  const ITEM_HEIGHT = 28;
@@ -84,20 +84,43 @@ function RangeSelectorContent({ namedRanges, tables, sheets, sheetId, activeCell
84
84
  React.createElement(FileIcon, null)),
85
85
  title)))));
86
86
  }
87
+ /**
88
+ * The Name Box's dropdown, memoised so a cursor move does not re-render it: the
89
+ * Radix `DropdownMenu` root schedules a nested state update on every render even
90
+ * while closed, which — on top of the input-sync re-render — is what pushed a held
91
+ * arrow key past React's nested-update limit (rowsncolumns/spreadsheet#1127).
92
+ */
93
+ function NameBoxMenuComponent({ isOpen, onOpenChange, namedRanges, tables, sheets, sheetId, activeCell, selections, shouldFocusSheetRef, focusSheet, onSelectNamedRange, onSelectTable, onRequestUpdateNamedRange, onDeleteNamedRange, onRequestDefineNamedRange, onChangeActiveSheet, }) {
94
+ return (React.createElement(DropdownMenu, { modal: false, open: isOpen, onOpenChange: onOpenChange },
95
+ React.createElement(DropdownMenuTrigger, { asChild: true },
96
+ React.createElement(IconButton, { className: "rounded-none mr-0", shrink: true },
97
+ React.createElement(TriangleDownIcon, null))),
98
+ React.createElement(DropdownMenuPortal, null,
99
+ React.createElement(DropdownMenuContent, { align: "start", alignOffset: -SELECTOR_WIDTH + ICON_WIDTH, sideOffset: 1, className: "max-h-[300px] overflow-auto", onCloseAutoFocus: (event) => {
100
+ event.preventDefault();
101
+ if (shouldFocusSheetRef.current && !isOpen) {
102
+ focusSheet?.();
103
+ }
104
+ } },
105
+ React.createElement(RangeSelectorContent, { namedRanges: namedRanges, tables: tables, sheets: sheets, sheetId: sheetId, activeCell: activeCell, selections: selections, isOpen: isOpen, shouldFocusSheetRef: shouldFocusSheetRef, onSelectNamedRange: onSelectNamedRange, onSelectTable: onSelectTable, onRequestUpdateNamedRange: onRequestUpdateNamedRange, onDeleteNamedRange: onDeleteNamedRange, onRequestDefineNamedRange: onRequestDefineNamedRange, onChangeActiveSheet: onChangeActiveSheet })))));
106
+ }
107
+ const NameBoxMenu = memo(NameBoxMenuComponent);
87
108
  function RangeSelectorComponent({ namedRanges = DEFAULT_ARRAY, tables = DEFAULT_ARRAY, sheets = DEFAULT_ARRAY, merges, selections = DEFAULT_ARRAY, activeCell, rowCount = MAX_ROW_COUNT, columnCount = MAX_COLUMN_COUNT, sheetId, onChangeActiveSheet, onChangeActiveCell, onChangeSelections, onRequestUpdateNamedRange, onDeleteNamedRange, onRequestDefineNamedRange, }) {
88
109
  const [isOpen, setIsOpen] = useState(false);
89
- const [value, setValue] = useState("");
110
+ // Only what the user is typing into the Name Box; `null` while it just mirrors the
111
+ // selection. The mirrored address is DERIVED during render below — syncing it into
112
+ // state from an effect scheduled one extra synchronous re-render per cursor move,
113
+ // which React's nested-update counter turned into "Maximum update depth exceeded"
114
+ // (#185) under a held arrow key in production builds (rowsncolumns/spreadsheet#1127).
115
+ const [draft, setDraft] = useState(null);
90
116
  const inputRef = useRef(null);
91
117
  const { navigateToSheetRange } = useRangeContext();
92
118
  const isFormulaMode = useFormulaModeValue();
93
119
  const shouldFocusSheetRef = useRef(false);
94
120
  const focusSheet = useFocusSheet();
95
121
  const getAddressFromSelection = useGetAddressFromSelection();
96
- // Keep input value in sync with activeCell and selections
97
- useEffect(() => {
98
- if (isFormulaMode) {
99
- return;
100
- }
122
+ // The address (or named-range name) of the current selection / active cell.
123
+ const derivedAddress = useMemo(() => {
101
124
  const lastSelection = selections[selections.length - 1];
102
125
  const isSelectionInProgress = lastSelection?.inProgress;
103
126
  const inputValue = lastSelection
@@ -110,19 +133,32 @@ function RangeSelectorComponent({ namedRanges = DEFAULT_ARRAY, tables = DEFAULT_
110
133
  return (range &&
111
134
  isAreasEqual(range, lastSelection ? lastSelection.range : convertCellToRange(activeCell)));
112
135
  });
113
- if (inputValue) {
114
- setValue(range ? range.name : inputValue);
115
- }
136
+ return inputValue ? (range ? range.name : inputValue) : undefined;
137
+ // `rowCount` / `columnCount` / `merges` shape the address text through
138
+ // `getAddressFromSelection` without being read here directly.
139
+ // eslint-disable-next-line react-hooks/exhaustive-deps
116
140
  }, [
117
141
  rowCount,
118
142
  columnCount,
119
143
  activeCell,
120
144
  selections,
121
145
  namedRanges,
122
- isFormulaMode,
123
146
  merges,
124
147
  getAddressFromSelection,
125
148
  ]);
149
+ // Formula mode freezes the box at the address it showed when the formula started
150
+ // (a range picked for the formula must not rename the box); remember the last
151
+ // address shown outside formula mode without scheduling a render.
152
+ const frozenAddressRef = useRef("");
153
+ useEffect(() => {
154
+ if (!isFormulaMode && derivedAddress !== undefined) {
155
+ frozenAddressRef.current = derivedAddress;
156
+ }
157
+ }, [isFormulaMode, derivedAddress]);
158
+ const value = draft ??
159
+ (isFormulaMode
160
+ ? frozenAddressRef.current
161
+ : derivedAddress ?? frozenAddressRef.current);
126
162
  // Select a range of cells in a sheet
127
163
  const onSelectRange = useCallback((range) => {
128
164
  navigateToSheetRange?.(range, { enableFlash: false });
@@ -142,6 +178,7 @@ function RangeSelectorComponent({ namedRanges = DEFAULT_ARRAY, tables = DEFAULT_
142
178
  const handleKeyDown = useCallback((e) => {
143
179
  if (e.key === "Enter") {
144
180
  const value = inputRef.current?.value;
181
+ setDraft(null);
145
182
  if (value) {
146
183
  // Check for named range
147
184
  const namedRange = namedRanges.find((range) => range.name === value);
@@ -191,13 +228,7 @@ function RangeSelectorComponent({ namedRanges = DEFAULT_ARRAY, tables = DEFAULT_
191
228
  else if (e.key === "Escape" && !isFormulaMode) {
192
229
  // Revert the Name Box to the current selection/active cell on
193
230
  // Escape, then return focus to the grid.
194
- const lastSelection = selections[selections.length - 1];
195
- const reverted = lastSelection
196
- ? getAddressFromSelection?.(lastSelection, undefined)
197
- : cellToAddress(activeCell);
198
- if (reverted) {
199
- setValue(reverted);
200
- }
231
+ setDraft(null);
201
232
  inputRef.current?.blur();
202
233
  focusSheet?.();
203
234
  return;
@@ -212,25 +243,14 @@ function RangeSelectorComponent({ namedRanges = DEFAULT_ARRAY, tables = DEFAULT_
212
243
  onChangeSelections,
213
244
  isFormulaMode,
214
245
  focusSheet,
215
- selections,
216
- activeCell,
217
- getAddressFromSelection,
218
- setValue,
219
246
  navigateToSheetRange,
220
247
  ]);
221
248
  return (React.createElement("div", { className: "flex h-full w-[90px]" },
222
- React.createElement(Input, { value: value, type: "text", ref: inputRef, onChange: (e) => setValue(e.target.value), onKeyDown: handleKeyDown, onFocus: (e) => e.target.select(), className: "text-xs border-none rounded-none outline-none m-0 bg-rnc-background text-rnc-foreground w-full" }),
223
- React.createElement(DropdownMenu, { modal: false, open: isOpen, onOpenChange: setIsOpen },
224
- React.createElement(DropdownMenuTrigger, { asChild: true },
225
- React.createElement(IconButton, { className: "rounded-none mr-0", shrink: true },
226
- React.createElement(TriangleDownIcon, null))),
227
- React.createElement(DropdownMenuPortal, null,
228
- React.createElement(DropdownMenuContent, { align: "start", alignOffset: -SELECTOR_WIDTH + ICON_WIDTH, sideOffset: 1, className: "max-h-[300px] overflow-auto", onCloseAutoFocus: (event) => {
229
- event.preventDefault();
230
- if (shouldFocusSheetRef.current && !isOpen) {
231
- focusSheet?.();
232
- }
233
- } },
234
- React.createElement(RangeSelectorContent, { namedRanges: namedRanges, tables: tables, sheets: sheets, sheetId: sheetId, activeCell: activeCell, selections: selections, isOpen: isOpen, shouldFocusSheetRef: shouldFocusSheetRef, onSelectNamedRange: onSelectNamedRange, onSelectTable: onSelectTable, onRequestUpdateNamedRange: onRequestUpdateNamedRange, onDeleteNamedRange: onDeleteNamedRange, onRequestDefineNamedRange: onRequestDefineNamedRange, onChangeActiveSheet: onChangeActiveSheet }))))));
249
+ React.createElement(Input, { value: value, type: "text", ref: inputRef, onChange: (e) => setDraft(e.target.value), onKeyDown: handleKeyDown, onFocus: (e) => e.target.select(), onBlur: () => setDraft(null), className: "text-xs border-none rounded-none outline-none m-0 bg-rnc-background text-rnc-foreground w-full" }),
250
+ React.createElement(NameBoxMenu, { isOpen: isOpen, onOpenChange: setIsOpen, namedRanges: namedRanges, tables: tables, sheets: sheets, sheetId: sheetId,
251
+ // Only an open menu reads the selection; while closed the props stay
252
+ // put so a cursor move never re-renders the Radix root (it schedules a
253
+ // nested update on every render, see the component note).
254
+ activeCell: isOpen ? activeCell : DEFAULT_ACTIVE_CELL, selections: isOpen ? selections : DEFAULT_ARRAY, shouldFocusSheetRef: shouldFocusSheetRef, focusSheet: focusSheet, onSelectNamedRange: onSelectNamedRange, onSelectTable: onSelectTable, onRequestUpdateNamedRange: onRequestUpdateNamedRange, onDeleteNamedRange: onDeleteNamedRange, onRequestDefineNamedRange: onRequestDefineNamedRange, onChangeActiveSheet: onChangeActiveSheet })));
235
255
  }
236
256
  export const RangeSelector = memo(RangeSelectorComponent);
@@ -2,7 +2,28 @@ import { FontLoader } from "../api/font-loader";
2
2
  export type UseFontResults = {
3
3
  isFontActive: boolean;
4
4
  };
5
+ /** A host-provided font loader: receives `Family:weight` specs, resolves when they are usable. */
6
+ export type WebFontLoader = (fonts: string[]) => Promise<void | undefined>;
7
+ export type WebFontOptions = {
8
+ /**
9
+ * Whether the grid may fetch web fonts (a Google Fonts stylesheet appended to
10
+ * `document.head`). Hosts with a strict Content-Security-Policy or that must
11
+ * work offline turn this off; the formula editor then uses whatever
12
+ * `--rnc-formula-font-family` resolves to (rowsncolumns/spreadsheet#1125).
13
+ * Default `true`.
14
+ */
15
+ loadWebFonts?: boolean;
16
+ /** Load fonts through the host instead of Google Fonts (`onRequestFonts`). */
17
+ onRequestFonts?: WebFontLoader;
18
+ };
19
+ /** Configure web-font loading for every grid on the page (what `useFonts` applies from its options). */
20
+ export declare const configureWebFonts: (options: WebFontOptions | undefined) => void;
21
+ export declare const isWebFontLoadingEnabled: () => boolean;
5
22
  export declare const getWebFont: () => FontLoader | undefined;
6
- export declare const loadWebFont: (fonts: string[]) => Promise<void | undefined>;
7
- export declare const useFonts: (fonts?: string) => void;
23
+ /**
24
+ * Load `Family:weight` specs — through the host's loader when one is configured,
25
+ * otherwise from Google Fonts; a no-op when web fonts are turned off.
26
+ */
27
+ export declare const loadWebFont: (fonts: string[]) => Promise<void>;
28
+ export declare const useFonts: (fonts?: string, options?: WebFontOptions) => void;
8
29
  //# sourceMappingURL=use-fonts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-fonts.d.ts","sourceRoot":"","sources":["../../../hooks/use-fonts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,UAAU,8BAAmD,CAAC;AAE3E,eAAO,MAAM,WAAW,GAAU,OAAO,MAAM,EAAE,8BAEhD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,SAMtC,CAAC"}
1
+ {"version":3,"file":"use-fonts.d.ts","sourceRoot":"","sources":["../../../hooks/use-fonts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,kGAAkG;AAClG,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,aAAa,CAAC;CAChC,CAAC;AAQF,wGAAwG;AACxG,eAAO,MAAM,iBAAiB,GAAI,SAAS,cAAc,GAAG,SAAS,SAKpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,eAA8B,CAAC;AAEnE,eAAO,MAAM,UAAU,8BAAmD,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,OAAO,MAAM,EAAE,kBAIhD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,EAAE,UAAU,cAAc,SAYhE,CAAC"}
@@ -1,14 +1,40 @@
1
1
  import { canUseDOM } from "@rowsncolumns/grid";
2
2
  import { useEffect } from "react";
3
3
  import { FontLoader } from "../api/font-loader";
4
+ // Page-level: every grid on the page shares one policy, and the paste / import /
5
+ // font-picker fallbacks consult it too, so "off" means no third-party request at all.
6
+ let webFontConfig = { enabled: true };
7
+ /** Configure web-font loading for every grid on the page (what `useFonts` applies from its options). */
8
+ export const configureWebFonts = (options) => {
9
+ webFontConfig = {
10
+ enabled: options?.loadWebFonts ?? true,
11
+ loader: options?.onRequestFonts,
12
+ };
13
+ };
14
+ export const isWebFontLoadingEnabled = () => webFontConfig.enabled;
4
15
  export const getWebFont = () => (canUseDOM ? new FontLoader() : undefined);
16
+ /**
17
+ * Load `Family:weight` specs — through the host's loader when one is configured,
18
+ * otherwise from Google Fonts; a no-op when web fonts are turned off.
19
+ */
5
20
  export const loadWebFont = async (fonts) => {
21
+ if (!webFontConfig.enabled)
22
+ return;
23
+ if (webFontConfig.loader)
24
+ return webFontConfig.loader(fonts);
6
25
  return getWebFont()?.loadFonts(fonts);
7
26
  };
8
- export const useFonts = (fonts) => {
27
+ export const useFonts = (fonts, options) => {
28
+ const loadWebFonts = options?.loadWebFonts ?? true;
29
+ const onRequestFonts = options?.onRequestFonts;
30
+ useEffect(() => {
31
+ configureWebFonts({ loadWebFonts, onRequestFonts });
32
+ }, [loadWebFonts, onRequestFonts]);
9
33
  useEffect(() => {
34
+ if (!loadWebFonts)
35
+ return;
10
36
  const defaultFonts = ["Inconsolata:400"];
11
37
  const finalFonts = fonts?.split(",").map((value) => String(value).trim());
12
38
  loadWebFont(defaultFonts.concat(finalFonts ? finalFonts : []));
13
- }, [fonts]);
39
+ }, [fonts, loadWebFonts]);
14
40
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-selection.d.ts","sourceRoot":"","sources":["../../../hooks/use-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACL,KAAK,EAcN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,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MAAM,GAAG,OAAO,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAuG7D,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,SAAS,EAAE,8uBA6C/C,mBAAmB,CAAC,CAAC,CAAC;;;;;;8BA2gEhB,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,cACvB,aAAa,GAAG,SAAS,aAC1B,aAAa,GAAG,SAAS,SAC7B,MAAM,GAAG,SAAS;4BAsMnB,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC;qBApgCtC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,UAAU,CAAC,YAAY;mBAsL1D,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa;0BArlC1C,aAAa,QAAO,aAAa;+BA2/CrC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;iCAmchC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;;;;8BA1iE3B,aAAa,kBAAkB,OAAO;;6BA+DvC,aAAa,QAAO,aAAa;;;6BAoL5B,MAAM,UACP,aAAa,kCAEb,KAAK;;6CAkqDT,aAAa,GAAG,SAAS,cACnB,aAAa,EAAE,GAAG,SAAS;mCAn8DjC,aAAa,OAAO,aAAa;;;;;;gCAguB3B,MAAM,GAAG,SAAS;gDA0yCpB,MAAM,aAAa,aAAa,KAAG,SAAS;CAgP3D,CAAC"}
@@ -1,4 +1,4 @@
1
- import { findLastContentfulCell, isNull } from "@rowsncolumns/grid";
1
+ import { findLastContentfulCell, isCellWithinBounds, isNull, } from "@rowsncolumns/grid";
2
2
  import { cellToArea } from "@rowsncolumns/grid";
3
3
  import { getOwnerDocument, useIsomorphicLayoutEffect } from "@rowsncolumns/grid";
4
4
  import { Align, cellIdentifier, cellRangeToBounds, clampCellCoords, clampIndex, Direction, findNextCellInDataRegion, findNextCellWithinBounds, getBoundedCells, isAreasEqual, isEqualCells, MouseButtonCodes, newSelectionFromDrag, selectionSpansCells, } from "@rowsncolumns/grid";
@@ -157,6 +157,51 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
157
157
  useIsomorphicLayoutEffect(() => {
158
158
  activeCellRef.current = activeCell;
159
159
  }, [activeCell]);
160
+ /**
161
+ * The last active cell this hook itself emitted. When the `activeCell` prop
162
+ * moves without a grid gesture — undo/redo restoring the cursor, a host
163
+ * navigating — the arrow-key anchor (`selectionStart`/`selectionEnd`) must
164
+ * follow it, or the next arrow key moves from where the cursor was before
165
+ * (rowsncolumns/spreadsheet#1124). Cells the hook emitted itself are skipped:
166
+ * Cmd+click anchors at the range's `start`, not the top-left it emits, and
167
+ * Shift+Arrow never emits at all, so its fixed anchor survives.
168
+ */
169
+ const lastEmittedActiveCellRef = useRef(null);
170
+ const emitActiveCell = useCallback((sheetId, cell) => {
171
+ lastEmittedActiveCellRef.current = cell;
172
+ onChangeActiveCell?.(sheetId, cell);
173
+ }, [onChangeActiveCell]);
174
+ useIsomorphicLayoutEffect(() => {
175
+ if (!activeCell)
176
+ return;
177
+ const emitted = lastEmittedActiveCellRef.current;
178
+ if (emitted &&
179
+ emitted.rowIndex === activeCell.rowIndex &&
180
+ emitted.columnIndex === activeCell.columnIndex) {
181
+ return;
182
+ }
183
+ if (isSelecting.current || isFilling.current || isDragging.current)
184
+ return;
185
+ const range = selections[selections.length - 1]?.range;
186
+ if (range && isCellWithinBounds(activeCell, range)) {
187
+ // Keep the selection; anchor at the active cell and let the far corner
188
+ // be the moving end so Shift+Arrow extends from here.
189
+ selectionStart.current = activeCell;
190
+ selectionEnd.current = {
191
+ rowIndex: activeCell.rowIndex === range.startRowIndex
192
+ ? range.endRowIndex
193
+ : range.startRowIndex,
194
+ columnIndex: activeCell.columnIndex === range.startColumnIndex
195
+ ? range.endColumnIndex
196
+ : range.startColumnIndex,
197
+ };
198
+ }
199
+ else {
200
+ selectionStart.current = activeCell;
201
+ selectionEnd.current = activeCell;
202
+ }
203
+ // eslint-disable-next-line react-hooks/exhaustive-deps
204
+ }, [sheetId, activeCell?.rowIndex, activeCell?.columnIndex]);
160
205
  useIsomorphicLayoutEffect(() => {
161
206
  mergedCellsRef.current = mergedCells;
162
207
  }, [mergedCells]);
@@ -269,7 +314,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
269
314
  if (!range) {
270
315
  return;
271
316
  }
272
- onChangeActiveCell?.(sheetId, {
317
+ emitActiveCell(sheetId, {
273
318
  rowIndex: range.startRowIndex,
274
319
  columnIndex: range.startColumnIndex,
275
320
  });
@@ -279,7 +324,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
279
324
  }, [
280
325
  sheetId,
281
326
  onChangeSelections,
282
- onChangeActiveCell,
327
+ emitActiveCell,
283
328
  selectionFromStartEnd,
284
329
  isCellOutOfBounds,
285
330
  selectionPolicy,
@@ -305,7 +350,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
305
350
  columnIndex: bounds.startColumnIndex,
306
351
  };
307
352
  /* Keep track of first cell that was selected by user */
308
- onChangeActiveCell?.(sheetId, coords);
353
+ emitActiveCell(sheetId, coords);
309
354
  if (newSelectionMode === "clear") {
310
355
  clearSelections();
311
356
  }
@@ -321,7 +366,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
321
366
  appendSelection,
322
367
  newSelectionMode,
323
368
  clearSelections,
324
- onChangeActiveCell,
369
+ emitActiveCell,
325
370
  selectionFromStartEnd,
326
371
  isCellOutOfBounds,
327
372
  ]);
@@ -400,12 +445,12 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
400
445
  const handleSetActiveCell = useCallbackRef(useCallback((sheetId, coords, shouldScroll = true, align) => {
401
446
  selectionStart.current = coords;
402
447
  selectionEnd.current = coords;
403
- onChangeActiveCell?.(sheetId, coords);
448
+ emitActiveCell(sheetId, coords);
404
449
  /* Scroll to the cell */
405
450
  if (shouldScroll && coords) {
406
451
  scrollToCell(coords, align);
407
452
  }
408
- }, [onChangeActiveCell, scrollToCell]));
453
+ }, [emitActiveCell, scrollToCell]));
409
454
  /**
410
455
  * Navigate selection using keyboard
411
456
  * @param direction
@@ -1053,7 +1098,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1053
1098
  const newSelection = removeSelectionByIndex(cellIndex);
1054
1099
  const nextActiveCell = getPossibleActiveCellFromSelections(newSelection);
1055
1100
  if (nextActiveCell !== null) {
1056
- onChangeActiveCell?.(sheetId, nextActiveCell);
1101
+ emitActiveCell(sheetId, nextActiveCell);
1057
1102
  }
1058
1103
  if (newSelection.length === 1 &&
1059
1104
  cellEqualsSelection(nextActiveCell, newSelection)) {
@@ -1107,7 +1152,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1107
1152
  modifySelection,
1108
1153
  mouseDownInterceptor,
1109
1154
  newSelection,
1110
- onChangeActiveCell,
1155
+ emitActiveCell,
1111
1156
  removeSelectionByIndex,
1112
1157
  selectionLeftBound,
1113
1158
  selectionTopBound,
@@ -1190,7 +1235,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1190
1235
  const direction = isShiftKey ? Direction.Up : Direction.Down;
1191
1236
  const nextCell = findNextCellWithinBounds(activeCellBounds, range, direction);
1192
1237
  if (nextCell) {
1193
- onChangeActiveCell?.(sheetId, nextCell);
1238
+ emitActiveCell(sheetId, nextCell);
1194
1239
  scrollToCell(nextCell);
1195
1240
  }
1196
1241
  }
@@ -1211,7 +1256,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1211
1256
  const direction = isShiftKey ? Direction.Left : Direction.Right;
1212
1257
  const nextCell = findNextCellWithinBounds(activeCellBounds, range, direction);
1213
1258
  if (nextCell) {
1214
- onChangeActiveCell?.(sheetId, nextCell);
1259
+ emitActiveCell(sheetId, nextCell);
1215
1260
  scrollToCell(nextCell);
1216
1261
  }
1217
1262
  }
@@ -1262,7 +1307,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1262
1307
  activeCell,
1263
1308
  selections,
1264
1309
  keyNavigate,
1265
- onChangeActiveCell,
1310
+ emitActiveCell,
1266
1311
  pageDown,
1267
1312
  pageLeft,
1268
1313
  pageRight,
@@ -1419,7 +1464,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1419
1464
  // The active cell normally anchors the surviving corner; if it fell in the cleared band,
1420
1465
  // move it to the remaining range's top-left so it never points at a deselected cell.
1421
1466
  if (!cellInRange(activeCell, shrink.remaining)) {
1422
- onChangeActiveCell?.(sheetId, {
1467
+ emitActiveCell(sheetId, {
1423
1468
  rowIndex: shrink.remaining.startRowIndex,
1424
1469
  columnIndex: shrink.remaining.startColumnIndex,
1425
1470
  });
@@ -1470,7 +1515,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1470
1515
  focus,
1471
1516
  handleFillMouseMove,
1472
1517
  onChangeSelections,
1473
- onChangeActiveCell,
1518
+ emitActiveCell,
1474
1519
  onFill,
1475
1520
  onFillHandleRelease,
1476
1521
  onFillShrink,
@@ -1568,7 +1613,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1568
1613
  columnIndex: toSelection.range.startColumnIndex,
1569
1614
  };
1570
1615
  /* Pick the first cell as activee cell */
1571
- onChangeActiveCell?.(sheetId, coords);
1616
+ emitActiveCell(sheetId, coords);
1572
1617
  /* Update selection start */
1573
1618
  selectionStart.current = coords;
1574
1619
  if (selectionSpansCells(toSelection?.range)) {
@@ -1604,7 +1649,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1604
1649
  onMoveSelection?.(sheetId, fromSelection, toSelection);
1605
1650
  return;
1606
1651
  }
1607
- onChangeActiveCell?.(sheetId, {
1652
+ emitActiveCell(sheetId, {
1608
1653
  rowIndex: fromSelection.range.startRowIndex,
1609
1654
  columnIndex: fromSelection.range.startColumnIndex,
1610
1655
  });
@@ -1642,7 +1687,7 @@ export const useSelection = ({ sheetId, activeCell, onChangeActiveCell, selectio
1642
1687
  getValue,
1643
1688
  handleSelectionMouseMove,
1644
1689
  focus,
1645
- onChangeActiveCell,
1690
+ emitActiveCell,
1646
1691
  onChangeSelections,
1647
1692
  ]);
1648
1693
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowsncolumns/spreadsheet",
3
- "version": "10.5.0",
3
+ "version": "10.5.1",
4
4
  "author": "Vinay M",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "./dist/cjs/index.js",