@rowsncolumns/ui 16.0.3 → 16.0.4
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.
- package/dist/cjs/cell-tooltip/index.d.ts +4 -4
- package/dist/cjs/editor-pm/mentions-plugin.d.ts +3 -3
- package/dist/cjs/editor-pm/mentions-plugin.d.ts.map +1 -1
- package/dist/cjs/editor-pm/mentions-plugin.js +11 -0
- package/dist/cjs/editor-pm/prosemirror-editor.d.ts +4 -4
- package/dist/cjs/editor-pm/prosemirror-editor.d.ts.map +1 -1
- package/dist/cjs/editor-pm/prosemirror-editor.js +95 -35
- package/dist/cjs/editor-pm/schema.d.ts +1 -1
- package/dist/cjs/editor-pm/use-parameter-suggestions.d.ts.map +1 -1
- package/dist/cjs/editor-pm/use-parameter-suggestions.js +27 -9
- package/dist/cjs/hooks/use-dropdown.d.ts +12 -5
- package/dist/cjs/hooks/use-dropdown.d.ts.map +1 -1
- package/dist/cjs/hooks/use-dropdown.js +72 -45
- package/dist/esm/cell-tooltip/index.d.ts +4 -4
- package/dist/esm/editor-pm/mentions-plugin.d.ts +3 -3
- package/dist/esm/editor-pm/mentions-plugin.d.ts.map +1 -1
- package/dist/esm/editor-pm/mentions-plugin.js +11 -0
- package/dist/esm/editor-pm/prosemirror-editor.d.ts +4 -4
- package/dist/esm/editor-pm/prosemirror-editor.d.ts.map +1 -1
- package/dist/esm/editor-pm/prosemirror-editor.js +86 -34
- package/dist/esm/editor-pm/schema.d.ts +1 -1
- package/dist/esm/editor-pm/use-parameter-suggestions.d.ts.map +1 -1
- package/dist/esm/editor-pm/use-parameter-suggestions.js +27 -9
- package/dist/esm/hooks/use-dropdown.d.ts +12 -5
- package/dist/esm/hooks/use-dropdown.d.ts.map +1 -1
- package/dist/esm/hooks/use-dropdown.js +68 -43
- package/package.json +3 -3
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { VariantProps } from "class-variance-authority";
|
|
2
2
|
import React from "react";
|
|
3
3
|
declare const cellTooltipVariants: (props?: ({
|
|
4
|
-
variant?: "link" | "none" | "note" | "error" | "
|
|
4
|
+
variant?: "link" | "none" | "note" | "error" | "custom" | "invalid" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
6
6
|
export declare const tooltipTitleVariants: (props?: ({
|
|
7
|
-
variant?: "link" | "none" | "note" | "error" | "
|
|
7
|
+
variant?: "link" | "none" | "note" | "error" | "custom" | "invalid" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
9
9
|
export declare const CellTooltip: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & VariantProps<(props?: ({
|
|
10
|
-
variant?: "link" | "none" | "note" | "error" | "
|
|
10
|
+
variant?: "link" | "none" | "note" | "error" | "custom" | "invalid" | null | undefined;
|
|
11
11
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
12
12
|
export declare const CellTooltipTitle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & VariantProps<(props?: ({
|
|
13
|
-
variant?: "link" | "none" | "note" | "error" | "
|
|
13
|
+
variant?: "link" | "none" | "note" | "error" | "custom" | "invalid" | null | undefined;
|
|
14
14
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
15
15
|
export type CellTooltipVariants = VariantProps<typeof cellTooltipVariants>;
|
|
16
16
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Mention } from "@rowsncolumns/common-types";
|
|
1
2
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Mention } from "@rowsncolumns/common-types";
|
|
3
|
+
import type { EditorView } from "prosemirror-view";
|
|
4
|
+
import type { MentionRange, MentionState } from "./prosemirror-editor";
|
|
5
5
|
interface MentionPosition {
|
|
6
6
|
left: number;
|
|
7
7
|
top: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentions-plugin.d.ts","sourceRoot":"","sources":["../../../editor-pm/mentions-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mentions-plugin.d.ts","sourceRoot":"","sources":["../../../editor-pm/mentions-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEvE,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AACD,QAAA,MAAM,iBAAiB,yBAA0C,CAAC;AAGlE,QAAA,MAAM,aAAa,GACjB,MAAM,UAAU,EAChB,SAAS,OAAO,EAChB,OAAO,YAAY,KAClB,IAOF,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,cAAc,EAAE,MAAM,OAAO,CAAC;CAC/B,CAAC;AAGF,QAAA,MAAM,oBAAoB,GAAI,oCAG3B,0BAA0B,KAAG,MAAM,CAAC,YAAY,CA8GlD,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -61,6 +61,17 @@ var createMentionsPlugin = function (_a) {
|
|
|
61
61
|
return pluginState;
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
+
// Already idle: keep the state (and its identity) as is. Every
|
|
65
|
+
// transaction reaches here while no mention is being typed — the
|
|
66
|
+
// decorations refresh dispatched from the editor's commit phase
|
|
67
|
+
// included — and notifying the host with a fresh-but-equal state
|
|
68
|
+
// each time scheduled a React re-render per transaction.
|
|
69
|
+
if (!pluginState.active &&
|
|
70
|
+
pluginState.query === "" &&
|
|
71
|
+
pluginState.range === null &&
|
|
72
|
+
pluginState.selectedIndex === 0) {
|
|
73
|
+
return pluginState;
|
|
74
|
+
}
|
|
64
75
|
var newPluginState = __assign(__assign({}, pluginState), { active: false, query: "", range: null, selectedIndex: 0 });
|
|
65
76
|
onChangeState(newPluginState);
|
|
66
77
|
return newPluginState;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ParsedToken } from "@rowsncolumns/calculator";
|
|
2
2
|
import type { CalculatorFunction, Mention } from "@rowsncolumns/common-types";
|
|
3
3
|
import { type FormulaLocale } from "@rowsncolumns/utils";
|
|
4
|
+
import type { Command } from "prosemirror-state";
|
|
4
5
|
import React from "react";
|
|
5
|
-
import {
|
|
6
|
+
import type { SuggestionsDropdownProps } from "../editor/suggestions-dropdown";
|
|
6
7
|
import { type RunColorResolver } from "./helpers";
|
|
7
|
-
import {
|
|
8
|
-
import { OptionItem, TextFormatRun } from "./types";
|
|
9
|
-
import { MentionTagComponentProps } from "./mention-nodeview";
|
|
8
|
+
import type { MentionTagComponentProps } from "./mention-nodeview";
|
|
9
|
+
import type { OptionItem, TextFormatRun } from "./types";
|
|
10
10
|
export type RichTextEditorAttribues = Omit<React.TextareaHTMLAttributes<HTMLDivElement>, "onChange" | "onSubmit" | "onCopy" | "onPaste" | "onCut">;
|
|
11
11
|
/**
|
|
12
12
|
* This fixes a IME bug in prosemirror
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosemirror-editor.d.ts","sourceRoot":"","sources":["../../../editor-pm/prosemirror-editor.tsx"],"names":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ter, __generator, __read, __rest, __spreadArray, __values } from "tslib";
|
|
2
|
+
import * as Popper from "@radix-ui/react-popper";
|
|
3
|
+
import { Portal } from "@radix-ui/react-portal";
|
|
4
|
+
import { tokenVocabulary } from "@rowsncolumns/fast-formula-parser";
|
|
5
|
+
import { useCallbackRef } from "@rowsncolumns/grid";
|
|
2
6
|
import { LoadingIcon, QuestionMarkIcon } from "@rowsncolumns/icons";
|
|
7
|
+
import { DEFAULT_ARRAY } from "@rowsncolumns/spreadsheet";
|
|
3
8
|
import { canonicalizeFunctionName, clipboardHtmlToRichText, } from "@rowsncolumns/utils";
|
|
4
9
|
import { addressToCell, getHotkeyKey, isAFormula, isNil, log, } from "@rowsncolumns/utils";
|
|
5
|
-
import React, { forwardRef, memo, useCallback, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
6
|
-
import { history, undo, redo } from "prosemirror-history";
|
|
7
|
-
import { keymap } from "prosemirror-keymap";
|
|
8
10
|
import { baseKeymap, joinBackward, toggleMark } from "prosemirror-commands";
|
|
11
|
+
import { history, redo, undo } from "prosemirror-history";
|
|
12
|
+
import { keymap } from "prosemirror-keymap";
|
|
13
|
+
import { DOMSerializer, Slice } from "prosemirror-model";
|
|
9
14
|
import { AllSelection, EditorState } from "prosemirror-state";
|
|
10
|
-
import { EditorView, DecorationSet } from "prosemirror-view";
|
|
11
15
|
import { TextSelection } from "prosemirror-state";
|
|
12
|
-
import {
|
|
16
|
+
import { DecorationSet, EditorView } from "prosemirror-view";
|
|
17
|
+
import React, { forwardRef, memo, useCallback, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
18
|
+
import { withErrorBoundary } from "react-error-boundary";
|
|
19
|
+
import { ConditionalWrapper } from "../conditional-wrapper";
|
|
20
|
+
import { SPECIAL_ITEMS, THIS_ROW_ITEM } from "../editor/constants";
|
|
21
|
+
import { ErrorFallback } from "../editor/editor-error-boundary";
|
|
22
|
+
import { StyledFormulaHelp } from "../editor/style";
|
|
23
|
+
import { SuggestionsDropdown as DefaultSuggestionsDropdown } from "../editor/suggestions-dropdown";
|
|
13
24
|
import { useCycleFormulaReference } from "../hooks/use-cycle-reference";
|
|
14
25
|
import { useDropdown } from "../hooks/use-dropdown";
|
|
15
|
-
import { useDropdownChangePM } from "./use-dropdown-change-pm";
|
|
16
|
-
import { useEditorKeyDownPM } from "./use-editor-keydown-pm";
|
|
17
|
-
import { useEditorDecoratorPM } from "./use-editor-decorator-pm";
|
|
18
|
-
import { useEditorOnChangePM } from "./use-editor-change-pm";
|
|
19
|
-
import { createDecorationPlugin } from "./decoration-plugin";
|
|
20
|
-
import { createUnfocusedSelectionPlugin } from "./unfocused-selection-plugin";
|
|
21
|
-
import { createPlaceholderPlugin } from "./placeholder-plugin";
|
|
22
26
|
import { useIsomorphicLayoutEffect } from "../hooks/use-isomorphic-layout-effect.ts";
|
|
23
27
|
import { cn } from "../utils";
|
|
24
|
-
import {
|
|
25
|
-
import { applyTextFormatRuns, applyTextFormatToSelection,
|
|
26
|
-
import {
|
|
27
|
-
import { ErrorFallback } from "../editor/editor-error-boundary";
|
|
28
|
-
import { withErrorBoundary } from "react-error-boundary";
|
|
29
|
-
import * as Popper from "@radix-ui/react-popper";
|
|
30
|
-
import { Portal } from "@radix-ui/react-portal";
|
|
31
|
-
import { ConditionalWrapper } from "../conditional-wrapper";
|
|
32
|
-
import { schema } from "./schema";
|
|
33
|
-
import { StyledFormulaHelp } from "../editor/style";
|
|
34
|
-
import { tokenVocabulary } from "@rowsncolumns/fast-formula-parser";
|
|
35
|
-
import { createMentionsPlugin } from "./mentions-plugin";
|
|
28
|
+
import { createDecorationPlugin } from "./decoration-plugin";
|
|
29
|
+
import { applyTextFormatRuns, applyTextFormatToSelection, deserializeString, getPropertyStartIndex, getSelectionFontSize, isCellToken, serializeEditorValue, } from "./helpers";
|
|
30
|
+
import { MentionNodeView } from "./mention-nodeview";
|
|
36
31
|
import { MentionsDropdown } from "./mentions-dropdown";
|
|
32
|
+
import { createMentionsPlugin } from "./mentions-plugin";
|
|
33
|
+
import { createPlaceholderPlugin } from "./placeholder-plugin";
|
|
34
|
+
import { schema } from "./schema";
|
|
35
|
+
import { createUnfocusedSelectionPlugin } from "./unfocused-selection-plugin";
|
|
36
|
+
import { useDropdownChangePM } from "./use-dropdown-change-pm";
|
|
37
|
+
import { useEditorOnChangePM } from "./use-editor-change-pm";
|
|
38
|
+
import { useEditorDecoratorPM } from "./use-editor-decorator-pm";
|
|
39
|
+
import { useEditorKeyDownPM } from "./use-editor-keydown-pm";
|
|
37
40
|
import { useMentionKeyDown } from "./use-mention-keydown";
|
|
38
|
-
import { MentionNodeView } from "./mention-nodeview";
|
|
39
|
-
import { useCallbackRef } from "@rowsncolumns/grid";
|
|
40
41
|
import { useParameterSuggestions } from "./use-parameter-suggestions";
|
|
41
|
-
|
|
42
|
+
/** Meta key of the decorations-refresh transaction dispatched from the commit phase. */
|
|
43
|
+
var UPDATE_DECORATIONS_META = "updateDecorations";
|
|
42
44
|
/**
|
|
43
45
|
* This fixes a IME bug in prosemirror
|
|
44
46
|
* Cmd+a and delete and then entering a character
|
|
@@ -300,9 +302,26 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
300
302
|
onChangeIsEdgeOfCell: setIsEdgeOfCell,
|
|
301
303
|
onChangeParameterIndex: setParameterIndex,
|
|
302
304
|
onCellPropertyTokenChange: setCellPropertyToken,
|
|
305
|
+
// The analysis hands over fresh arrays on every run (empty ones
|
|
306
|
+
// outside a formula); only a content change may schedule a render —
|
|
307
|
+
// this runs for the formula bar's value-sync dispatch in the commit
|
|
308
|
+
// phase, where a same-content write is a second render per keystroke.
|
|
303
309
|
onChangeFunctionParameters: function (params, ranges) {
|
|
304
|
-
setParameterArguments(
|
|
305
|
-
|
|
310
|
+
setParameterArguments(function (previous) {
|
|
311
|
+
return previous.length === params.length &&
|
|
312
|
+
previous.every(function (value, index) { return value === params[index]; })
|
|
313
|
+
? previous
|
|
314
|
+
: params;
|
|
315
|
+
});
|
|
316
|
+
setParameterRanges(function (previous) {
|
|
317
|
+
return previous.length === ranges.length &&
|
|
318
|
+
previous.every(function (range, index) {
|
|
319
|
+
return range.start === ranges[index].start &&
|
|
320
|
+
range.end === ranges[index].end;
|
|
321
|
+
})
|
|
322
|
+
? previous
|
|
323
|
+
: ranges;
|
|
324
|
+
});
|
|
306
325
|
},
|
|
307
326
|
onChangePreviousToken: setPreviousToken,
|
|
308
327
|
enableContinuousSelection: enableContinuousSelection !== null && enableContinuousSelection !== void 0 ? enableContinuousSelection : isNil(navigationMode),
|
|
@@ -348,7 +367,18 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
348
367
|
}
|
|
349
368
|
},
|
|
350
369
|
}),
|
|
351
|
-
keymap(__assign(__assign({}, baseKeymap), {
|
|
370
|
+
keymap(__assign(__assign({}, baseKeymap), {
|
|
371
|
+
// While the grid is navigating, this editor is the invisible sticky buffer and
|
|
372
|
+
// select-all belongs to the GRID (Ctrl/Cmd+A selects the current region). Letting
|
|
373
|
+
// the base binding run left an `AllSelection` in the hidden document that the next
|
|
374
|
+
// seeded value inherited — the first typed character then replaced the seed
|
|
375
|
+
// (Athena-Intel/demo-app-monorepo#37167 UI1-1). Declining lets the grid's own
|
|
376
|
+
// keydown handler take the key (it prevents the native select-all default).
|
|
377
|
+
"Mod-a": function (state, dispatch, view) {
|
|
378
|
+
return navigationModeRef.current
|
|
379
|
+
? false
|
|
380
|
+
: baseKeymap["Mod-a"](state, dispatch, view);
|
|
381
|
+
}, Backspace: function (state, dispatch, view) {
|
|
352
382
|
if (view === null || view === void 0 ? void 0 : view.composing) {
|
|
353
383
|
return false;
|
|
354
384
|
}
|
|
@@ -455,8 +485,18 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
455
485
|
try {
|
|
456
486
|
var newState = view_1.state.apply(transaction);
|
|
457
487
|
view_1.updateState(newState);
|
|
458
|
-
// Call the onChange handler which will handle all token
|
|
459
|
-
|
|
488
|
+
// Call the onChange handler which will handle all token
|
|
489
|
+
// analysis and state updates. A caret-driven decorations
|
|
490
|
+
// refresh (dispatched from the commit phase below) changes
|
|
491
|
+
// neither the document nor the selection, so re-running the
|
|
492
|
+
// analysis would only re-emit the state that triggered it —
|
|
493
|
+
// and every setState from the commit phase costs a second
|
|
494
|
+
// render per keystroke (see the burst-typing spec).
|
|
495
|
+
var decorationsMeta = transaction.getMeta(UPDATE_DECORATIONS_META);
|
|
496
|
+
var caretOnlyRefresh = (decorationsMeta === null || decorationsMeta === void 0 ? void 0 : decorationsMeta.caretOnly) === true &&
|
|
497
|
+
!transaction.docChanged &&
|
|
498
|
+
!transaction.selectionSet;
|
|
499
|
+
if (!navigationModeRef.current && !caretOnlyRefresh) {
|
|
460
500
|
onEditorChange(newState);
|
|
461
501
|
}
|
|
462
502
|
}
|
|
@@ -575,6 +615,15 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
575
615
|
if (currentContent !== value) {
|
|
576
616
|
var newDoc = createInitialDocument();
|
|
577
617
|
var tr = viewRef.current.state.tr.replaceWith(0, viewRef.current.state.doc.content.size, newDoc.content);
|
|
618
|
+
// A whole-document replacement is a fresh seed (an `editCell(value)` open, the
|
|
619
|
+
// formula bar echoing the cell): the caret belongs after the seeded text. A cursor
|
|
620
|
+
// already maps there through the replace step, but an `AllSelection` maps to an
|
|
621
|
+
// `AllSelection` over the NEW document — so the next typed character replaced the
|
|
622
|
+
// seed (`=` then `7*6` came out as `7*6`, Athena-Intel/demo-app-monorepo#37167
|
|
623
|
+
// UI1-1). Collapse it to a caret at the end.
|
|
624
|
+
if (tr.selection instanceof AllSelection) {
|
|
625
|
+
tr.setSelection(TextSelection.atEnd(tr.doc));
|
|
626
|
+
}
|
|
578
627
|
viewRef.current.dispatch(tr);
|
|
579
628
|
}
|
|
580
629
|
}
|
|
@@ -583,18 +632,29 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
583
632
|
}
|
|
584
633
|
}
|
|
585
634
|
}, [value, createInitialDocument]);
|
|
586
|
-
// Update decorations when formula mode
|
|
635
|
+
// Update decorations when formula mode, active state or the caret
|
|
636
|
+
// position changes. A change of mode/active state re-runs the token
|
|
637
|
+
// analysis (it depends on `isActive`); a caret-only refresh is tagged so
|
|
638
|
+
// `dispatchTransaction` skips the analysis — the caret position came
|
|
639
|
+
// out of that very analysis, so re-running it is a no-op.
|
|
640
|
+
var decorationsContextRef = useRef({ formulaMode: formulaMode, isActive: isActive });
|
|
587
641
|
useIsomorphicLayoutEffect(function () {
|
|
588
642
|
if (navigationModeRef.current)
|
|
589
643
|
return;
|
|
644
|
+
var previous = decorationsContextRef.current;
|
|
645
|
+
decorationsContextRef.current = { formulaMode: formulaMode, isActive: isActive };
|
|
646
|
+
var caretOnly = previous.formulaMode === formulaMode &&
|
|
647
|
+
previous.isActive === isActive;
|
|
590
648
|
if (viewRef.current) {
|
|
591
649
|
try {
|
|
592
650
|
// Force a decoration update by dispatching a metadata transaction
|
|
593
|
-
var
|
|
651
|
+
var meta = {
|
|
594
652
|
formulaMode: formulaMode,
|
|
595
653
|
isActive: isActive,
|
|
596
654
|
cursorPosition: cursorPosition,
|
|
597
|
-
|
|
655
|
+
caretOnly: caretOnly,
|
|
656
|
+
};
|
|
657
|
+
var tr = viewRef.current.state.tr.setMeta(UPDATE_DECORATIONS_META, meta);
|
|
598
658
|
viewRef.current.dispatch(tr);
|
|
599
659
|
}
|
|
600
660
|
catch (error) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Schema } from "prosemirror-model";
|
|
2
|
-
export declare const schema: Schema<"text" | "line" | "mention" | "doc", "link" | "color" | "bold" | "fontFamily" | "fontSize" | "
|
|
2
|
+
export declare const schema: Schema<"text" | "line" | "mention" | "doc", "link" | "color" | "bold" | "fontFamily" | "fontSize" | "superscript" | "subscript" | "italic" | "underline" | "strikethrough">;
|
|
3
3
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-parameter-suggestions.d.ts","sourceRoot":"","sources":["../../../editor-pm/use-parameter-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-parameter-suggestions.d.ts","sourceRoot":"","sources":["../../../editor-pm/use-parameter-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,MAAM,GAAG;IACZ,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,6BAA6B,CAAC,EAAE,CAC9B,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAAE,KACjB,OAAO,CAAC;IACb,+BAA+B,CAAC,EAAE,CAChC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAAE,KAElB,UAAU,EAAE,GACZ,SAAS,GACT,OAAO,CAAC,UAAU,EAAE,GAAG,SAAS,CAAC,GACjC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,wHAMrC,MAAM;;;CA4FR,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter, __generator, __read } from "tslib";
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
2
|
import { DEFAULT_ARRAY } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Fetch parameter suggestions (sync or async) for the active function.
|
|
6
6
|
* Ensures stale responses are ignored when dependency changes mid-flight.
|
|
@@ -11,6 +11,24 @@ export var useParameterSuggestions = function (_a) {
|
|
|
11
11
|
var _c = __read(useState([]), 2), parameterSuggestions = _c[0], setSuggestions = _c[1];
|
|
12
12
|
var _d = __read(useState(false), 2), isFetchingParameters = _d[0], setIsFetchingParameters = _d[1];
|
|
13
13
|
var requestIdRef = useRef(0);
|
|
14
|
+
// Mirrors of the two states so the effect below only writes on a real
|
|
15
|
+
// change: a same-value setState from the commit phase still schedules a
|
|
16
|
+
// render when the fiber is mid-update, and this effect re-runs on every
|
|
17
|
+
// keystroke inside a function call (`parameterArgsKey`).
|
|
18
|
+
var suggestionsRef = useRef(parameterSuggestions);
|
|
19
|
+
var isFetchingRef = useRef(isFetchingParameters);
|
|
20
|
+
var writeSuggestions = function (next) {
|
|
21
|
+
if (suggestionsRef.current === next)
|
|
22
|
+
return;
|
|
23
|
+
suggestionsRef.current = next;
|
|
24
|
+
setSuggestions(next);
|
|
25
|
+
};
|
|
26
|
+
var writeIsFetching = function (next) {
|
|
27
|
+
if (isFetchingRef.current === next)
|
|
28
|
+
return;
|
|
29
|
+
isFetchingRef.current = next;
|
|
30
|
+
setIsFetchingParameters(next);
|
|
31
|
+
};
|
|
14
32
|
var functionName = (_b = functionToken === null || functionToken === void 0 ? void 0 : functionToken.image) !== null && _b !== void 0 ? _b : "";
|
|
15
33
|
var hasFunctionToken = Boolean(functionToken);
|
|
16
34
|
var parameterArgsKey = useMemo(function () { return JSON.stringify(parameterArguments !== null && parameterArguments !== void 0 ? parameterArguments : []); }, [parameterArguments]);
|
|
@@ -18,14 +36,14 @@ export var useParameterSuggestions = function (_a) {
|
|
|
18
36
|
requestIdRef.current += 1;
|
|
19
37
|
var requestId = requestIdRef.current;
|
|
20
38
|
if (!hasFunctionToken || !getFunctionParameterSuggestions) {
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
writeIsFetching(false);
|
|
40
|
+
writeSuggestions(DEFAULT_ARRAY);
|
|
23
41
|
return;
|
|
24
42
|
}
|
|
25
43
|
if (shouldFetchFunctionParameters &&
|
|
26
44
|
!shouldFetchFunctionParameters(functionName, parameterIndex, parameterArguments)) {
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
writeIsFetching(false);
|
|
46
|
+
writeSuggestions(DEFAULT_ARRAY);
|
|
29
47
|
return;
|
|
30
48
|
}
|
|
31
49
|
var cancelled = false;
|
|
@@ -35,12 +53,12 @@ export var useParameterSuggestions = function (_a) {
|
|
|
35
53
|
switch (_a.label) {
|
|
36
54
|
case 0:
|
|
37
55
|
_a.trys.push([0, 2, 3, 4]);
|
|
38
|
-
|
|
56
|
+
writeIsFetching(true);
|
|
39
57
|
return [4 /*yield*/, getFunctionParameterSuggestions(functionName, parameterIndex, parameterArguments)];
|
|
40
58
|
case 1:
|
|
41
59
|
result = _a.sent();
|
|
42
60
|
if (!cancelled && requestIdRef.current === requestId) {
|
|
43
|
-
|
|
61
|
+
writeSuggestions(result !== null && result !== void 0 ? result : []);
|
|
44
62
|
}
|
|
45
63
|
return [3 /*break*/, 4];
|
|
46
64
|
case 2:
|
|
@@ -48,12 +66,12 @@ export var useParameterSuggestions = function (_a) {
|
|
|
48
66
|
// Keep dropdown stable on errors instead of throwing
|
|
49
67
|
if (!cancelled && requestIdRef.current === requestId) {
|
|
50
68
|
console.warn("Error fetching parameter suggestions", error_1);
|
|
51
|
-
|
|
69
|
+
writeSuggestions([]);
|
|
52
70
|
}
|
|
53
71
|
return [3 /*break*/, 4];
|
|
54
72
|
case 3:
|
|
55
73
|
if (!cancelled && requestIdRef.current === requestId) {
|
|
56
|
-
|
|
74
|
+
writeIsFetching(false);
|
|
57
75
|
}
|
|
58
76
|
return [7 /*endfinally*/];
|
|
59
77
|
case 4: return [2 /*return*/];
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import type { Maybe } from "@rowsncolumns/common-types";
|
|
1
2
|
import type React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { OptionItem } from "../editor-pm/types.js";
|
|
3
|
+
import type { OptionItem } from "../editor-pm/types.js";
|
|
4
4
|
type UseDropdownProps<T> = {
|
|
5
5
|
items: T[] | undefined;
|
|
6
6
|
initialQuery?: string;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* No longer read: the menu is open exactly when it has items to show and
|
|
9
|
+
* was not dismissed (Escape) for that item set — which is the state the
|
|
10
|
+
* former open/close effect settled on right after mount anyway. Kept so
|
|
11
|
+
* existing call sites type-check.
|
|
12
|
+
*/
|
|
13
|
+
initialOpen?: boolean;
|
|
8
14
|
initialHighlightedIndex: number;
|
|
9
15
|
limit?: number;
|
|
10
16
|
showAllIfEmpty?: boolean;
|
|
11
17
|
isNewValue?: boolean;
|
|
12
18
|
itemsWhenEmpty?: T[];
|
|
13
|
-
|
|
19
|
+
/** Not read by the hook (items are matched on `title`); kept for call sites. */
|
|
20
|
+
itemToString?(item: T): string;
|
|
14
21
|
onChange(value: T): void;
|
|
15
22
|
/**
|
|
16
23
|
* Marks the item that matches the current (pre-edit) value so the dropdown
|
|
@@ -22,7 +29,7 @@ type UseDropdownProps<T> = {
|
|
|
22
29
|
};
|
|
23
30
|
export declare const sortByUnderscore: <T extends OptionItem>(a: Maybe<T>, b: Maybe<T>) => 0 | 1 | -1;
|
|
24
31
|
export declare const sanitizeDropdownQuery: (value: string) => string;
|
|
25
|
-
export declare const useDropdown: <T extends OptionItem>({
|
|
32
|
+
export declare const useDropdown: <T extends OptionItem>({ initialHighlightedIndex, initialQuery, onChange, items, isNewValue, limit, showAllIfEmpty, itemsWhenEmpty, isItemSelected, }: UseDropdownProps<T>) => {
|
|
26
33
|
isOpen: boolean;
|
|
27
34
|
highlightedIndex: number;
|
|
28
35
|
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dropdown.d.ts","sourceRoot":"","sources":["../../../hooks/use-dropdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":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, __spreadArray } from "tslib";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.ts";
|
|
4
2
|
import { matchSorter } from "match-sorter";
|
|
3
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.ts";
|
|
5
5
|
export var sortByUnderscore = function (a, b) {
|
|
6
6
|
var _a, _b;
|
|
7
7
|
var aUnderscore = (_a = String(a === null || a === void 0 ? void 0 : a.title)) === null || _a === void 0 ? void 0 : _a.startsWith("_");
|
|
@@ -55,35 +55,53 @@ var reorderByPriority = function (list) {
|
|
|
55
55
|
export var sanitizeDropdownQuery = function (value) {
|
|
56
56
|
return value.replace(/["'`]/g, "");
|
|
57
57
|
};
|
|
58
|
+
var areSameItems = function (a, b) {
|
|
59
|
+
return a === b || (a.length === b.length && a.every(function (item, i) { return item === b[i]; }));
|
|
60
|
+
};
|
|
58
61
|
export var useDropdown = function (_a) {
|
|
59
|
-
var
|
|
60
|
-
var _d = __read(useState(
|
|
61
|
-
var _e = __read(useState(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
var initialHighlightedIndex = _a.initialHighlightedIndex, initialQuery = _a.initialQuery, onChange = _a.onChange, _b = _a.items, items = _b === void 0 ? [] : _b, isNewValue = _a.isNewValue, _c = _a.limit, limit = _c === void 0 ? 10 : _c, showAllIfEmpty = _a.showAllIfEmpty, itemsWhenEmpty = _a.itemsWhenEmpty, isItemSelected = _a.isItemSelected;
|
|
63
|
+
var _d = __read(useState(initialQuery !== null && initialQuery !== void 0 ? initialQuery : ""), 2), query = _d[0], setQuery = _d[1];
|
|
64
|
+
var _e = __read(useState(initialHighlightedIndex), 2), highlightedIndex = _e[0], setHighlightedIndex = _e[1];
|
|
65
|
+
// The item set the menu was dismissed (Escape) for. The menu is open exactly
|
|
66
|
+
// when it has items and was not dismissed for that set; any change to the
|
|
67
|
+
// set (a keystroke re-filtering it) or an explicit `openMenu` lifts the
|
|
68
|
+
// dismissal.
|
|
69
|
+
var _f = __read(useState(null), 2), dismissedItems = _f[0], setDismissedItems = _f[1];
|
|
65
70
|
// Refs
|
|
66
71
|
var isDirty = useRef(isNewValue);
|
|
67
|
-
var initialQueryRef = useRef(
|
|
72
|
+
var initialQueryRef = useRef(initialQuery !== null && initialQuery !== void 0 ? initialQuery : "");
|
|
68
73
|
var highlightedIndexRef = useRef(undefined);
|
|
69
74
|
var queryRef = useRef(undefined);
|
|
70
|
-
var filteredItemsRef = useRef(undefined);
|
|
71
75
|
useIsomorphicLayoutEffect(function () {
|
|
72
76
|
queryRef.current = query;
|
|
73
77
|
}, [query]);
|
|
74
78
|
useIsomorphicLayoutEffect(function () {
|
|
75
79
|
highlightedIndexRef.current = highlightedIndex;
|
|
76
80
|
}, [highlightedIndex]);
|
|
77
|
-
|
|
81
|
+
// Re-seed for a new editing session. The hosting editor stays mounted
|
|
82
|
+
// (hidden) between sessions, so the query must follow `initialQuery` when a
|
|
83
|
+
// new session starts — otherwise the previous session's filter narrows the
|
|
84
|
+
// next dropdown open.
|
|
85
|
+
//
|
|
86
|
+
// Derived during render (React re-runs the component before committing),
|
|
87
|
+
// deliberately NOT from an effect. The in-cell editor passes the live cell
|
|
88
|
+
// text as `initialQuery`, so an effect here ran after every keystroke and
|
|
89
|
+
// scheduled a second render from the commit phase; together with the
|
|
90
|
+
// open/close effect below that left a render pending at the tail of every
|
|
91
|
+
// commit, which in a typing burst never let React's nested-update counter
|
|
92
|
+
// reset and threw "Maximum update depth exceeded" (Minified React error
|
|
93
|
+
// #185) — dropping the keystroke whose update threw.
|
|
94
|
+
var _g = __read(useState(function () { return ({ initialQuery: initialQuery, isNewValue: isNewValue }); }), 2), seed = _g[0], setSeed = _g[1];
|
|
95
|
+
if (seed.initialQuery !== initialQuery || seed.isNewValue !== isNewValue) {
|
|
96
|
+
setSeed({ initialQuery: initialQuery, isNewValue: isNewValue });
|
|
78
97
|
initialQueryRef.current = initialQuery !== null && initialQuery !== void 0 ? initialQuery : "";
|
|
79
98
|
isDirty.current = Boolean(isNewValue);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, [initialQuery, isNewValue]);
|
|
99
|
+
if (query !== (initialQuery !== null && initialQuery !== void 0 ? initialQuery : "")) {
|
|
100
|
+
setQuery(initialQuery !== null && initialQuery !== void 0 ? initialQuery : "");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
85
103
|
// Filtered items
|
|
86
|
-
var
|
|
104
|
+
var computedFilteredItems = useMemo(function () {
|
|
87
105
|
if (!query) {
|
|
88
106
|
if (itemsWhenEmpty === null || itemsWhenEmpty === void 0 ? void 0 : itemsWhenEmpty.length) {
|
|
89
107
|
return reorderByPriority(__spreadArray([], __read(itemsWhenEmpty), false));
|
|
@@ -120,10 +138,43 @@ export var useDropdown = function (_a) {
|
|
|
120
138
|
baseSort: dropdownBaseSort,
|
|
121
139
|
});
|
|
122
140
|
return reorderByPriority(sorted).slice(0, limit);
|
|
123
|
-
}, [items, query, limit,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
141
|
+
}, [items, query, limit, showAllIfEmpty, itemsWhenEmpty]);
|
|
142
|
+
// Identity follows content: the open state and the highlight bookkeeping
|
|
143
|
+
// below key off "the item set changed", and a caller re-creating `items`
|
|
144
|
+
// per render must not read as a change (it would reopen a dismissed menu
|
|
145
|
+
// on every render and never let the render-phase derivations settle).
|
|
146
|
+
var filteredItemsRef = useRef(computedFilteredItems);
|
|
147
|
+
var filteredItems = areSameItems(filteredItemsRef.current, computedFilteredItems)
|
|
148
|
+
? filteredItemsRef.current
|
|
149
|
+
: computedFilteredItems;
|
|
150
|
+
filteredItemsRef.current = filteredItems;
|
|
151
|
+
var isOpen = filteredItems.length > 0 && dismissedItems !== filteredItems;
|
|
152
|
+
var openMenu = useCallback(function () { return setDismissedItems(null); }, []);
|
|
153
|
+
var closeMenu = useCallback(function () { return setDismissedItems(filteredItemsRef.current); }, []);
|
|
154
|
+
// Highlight bookkeeping for a changed query / item set, derived during
|
|
155
|
+
// render for the same reason as the re-seed above (an effect-scheduled
|
|
156
|
+
// setState per keystroke): clearing the query drops the highlight, and a
|
|
157
|
+
// pristine session pre-selects the item matching the current value (e.g. a
|
|
158
|
+
// data-validation dropdown highlighting the cell's current entry — Excel
|
|
159
|
+
// behavior); once the user types, the filter owns the highlight. The
|
|
160
|
+
// pre-select wins over the clear, as the former effect ordering did.
|
|
161
|
+
var _h = __read(useState(null), 2), highlightSync = _h[0], setHighlightSync = _h[1];
|
|
162
|
+
if (highlightSync === null ||
|
|
163
|
+
highlightSync.query !== query ||
|
|
164
|
+
highlightSync.filteredItems !== filteredItems ||
|
|
165
|
+
highlightSync.isItemSelected !== isItemSelected) {
|
|
166
|
+
setHighlightSync({ query: query, filteredItems: filteredItems, isItemSelected: isItemSelected });
|
|
167
|
+
var nextHighlightedIndex = highlightedIndex;
|
|
168
|
+
if (!query) {
|
|
169
|
+
nextHighlightedIndex = -1;
|
|
170
|
+
}
|
|
171
|
+
if (isItemSelected && !isDirty.current) {
|
|
172
|
+
nextHighlightedIndex = filteredItems.findIndex(isItemSelected);
|
|
173
|
+
}
|
|
174
|
+
if (nextHighlightedIndex !== highlightedIndex) {
|
|
175
|
+
setHighlightedIndex(nextHighlightedIndex);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
127
178
|
// User selects a value from the dropdown
|
|
128
179
|
var onSelect = useCallback(function (value) {
|
|
129
180
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
@@ -190,30 +241,6 @@ export var useDropdown = function (_a) {
|
|
|
190
241
|
}
|
|
191
242
|
}
|
|
192
243
|
}, [isOpen, openMenu, onSelect, closeMenu]);
|
|
193
|
-
useEffect(function () {
|
|
194
|
-
if (filteredItems.length) {
|
|
195
|
-
openMenu();
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
closeMenu();
|
|
199
|
-
}
|
|
200
|
-
// If user clears the
|
|
201
|
-
if (!query) {
|
|
202
|
-
setHighlightedIndex(-1);
|
|
203
|
-
}
|
|
204
|
-
}, [query, filteredItems, closeMenu, openMenu]);
|
|
205
|
-
// Pre-select the item matching the current value (e.g. a data-validation
|
|
206
|
-
// dropdown highlighting the cell's current entry — Excel behavior). Runs
|
|
207
|
-
// only while the session is pristine (`isDirty` flips on the first typed
|
|
208
|
-
// change, handing the highlight to the filter). Declared AFTER the reset
|
|
209
|
-
// effect above so the seed wins the mount-time ordering when the query is
|
|
210
|
-
// empty (a blank cell selecting the list's empty/text-prefix entry).
|
|
211
|
-
useEffect(function () {
|
|
212
|
-
if (!isItemSelected || isDirty.current) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
setHighlightedIndex(filteredItems.findIndex(isItemSelected));
|
|
216
|
-
}, [filteredItems, isItemSelected]);
|
|
217
244
|
var handleSetQuery = useCallback(function (value) {
|
|
218
245
|
setQuery(value);
|
|
219
246
|
setHighlightedIndex(0);
|