@rowsncolumns/ui 16.0.3 → 16.0.5
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/dialog/index.d.ts.map +1 -1
- package/dist/cjs/dialog/index.js +45 -3
- 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/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/dialog/index.d.ts.map +1 -1
- package/dist/esm/dialog/index.js +33 -2
- 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/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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AA6C1B,eAAO,MAAM,WAAW,oKAYtB,CAAC;AAGH,eAAO,MAAM,iBAAiB,8KAY5B,CAAC;AAkBH,eAAO,MAAM,aAAa;sBAGJ,MAAM;gBACZ,WAAW,GAAG,IAAI;wCA8ChC,CAAC;AAGH,eAAO,MAAM,MAAM,uCAAuB,CAAC;AAC3C,eAAO,MAAM,aAAa,8GAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,4GAAwB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,4KAS5B,CAAC;AAGH,eAAO,MAAM,UAAU,GAAI,0BAGxB;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,sBAEA,CAAC"}
|
package/dist/cjs/dialog/index.js
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import { __assign, __rest } from "tslib";
|
|
1
|
+
import { __assign, __rest, __values } from "tslib";
|
|
2
2
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import Draggable from "react-draggable";
|
|
6
6
|
import { IconButton } from "./../icon-button";
|
|
7
7
|
import { cn } from "./../utils";
|
|
8
|
+
var FOCUSABLE_SELECTOR = "a[href], button, input, select, textarea, [tabindex], [contenteditable]";
|
|
9
|
+
var TEXT_ENTRY_SELECTOR = 'input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), textarea, [contenteditable]:not([contenteditable="false"])';
|
|
10
|
+
var firstTabbable = function (container) {
|
|
11
|
+
var e_1, _a;
|
|
12
|
+
try {
|
|
13
|
+
for (var _b = __values(Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14
|
+
var element = _c.value;
|
|
15
|
+
if (element.tabIndex >= 0 &&
|
|
16
|
+
!element.hasAttribute("disabled") &&
|
|
17
|
+
element.getClientRects().length > 0) {
|
|
18
|
+
return element;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
23
|
+
finally {
|
|
24
|
+
try {
|
|
25
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
26
|
+
}
|
|
27
|
+
finally { if (e_1) throw e_1.error; }
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
8
31
|
var DialogPortal = function (_a) {
|
|
9
32
|
var children = _a.children, className = _a.className, container = _a.container, props = __rest(_a, ["children", "className", "container"]);
|
|
10
33
|
return (React.createElement(DialogPrimitive.Portal, __assign({ container: container }, props),
|
|
@@ -27,13 +50,32 @@ var DialogOverlay = React.forwardRef(function (_a, ref) {
|
|
|
27
50
|
});
|
|
28
51
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
29
52
|
export var DialogContent = React.forwardRef(function (_a, ref) {
|
|
30
|
-
var className = _a.className, portalClassName = _a.portalClassName, container = _a.container, children = _a.children, props = __rest(_a, ["className", "portalClassName", "container", "children"]);
|
|
53
|
+
var className = _a.className, portalClassName = _a.portalClassName, container = _a.container, children = _a.children, onOpenAutoFocus = _a.onOpenAutoFocus, props = __rest(_a, ["className", "portalClassName", "container", "children", "onOpenAutoFocus"]);
|
|
31
54
|
var nodeRef = useRef(null);
|
|
32
55
|
return (React.createElement(DialogPortal, { className: portalClassName, container: container },
|
|
33
56
|
React.createElement(DialogOverlay, null),
|
|
34
57
|
React.createElement("div", { className: "fixed z-50 grid w-full gap-4 animate-in data-[state=open]:fade-in-90 data-[state=open]:slide-in-from-bottom-10 sm:max-w-lg sm:rounded-lg sm:zoom-in-90 data-[state=open]:sm:slide-in-from-bottom-0 pointer-events-none" },
|
|
35
58
|
React.createElement(Draggable, { handle: ".rnc-drag-handle", nodeRef: nodeRef },
|
|
36
|
-
React.createElement(DialogPrimitive.Content, __assign({ ref: nodeRef, className: cn("bg-rnc-background text-rnc-foreground shadow-lg rounded-sm border border-solid border-rnc-border pointer-events-auto min-w-0", className)
|
|
59
|
+
React.createElement(DialogPrimitive.Content, __assign({ ref: nodeRef, className: cn("bg-rnc-background text-rnc-foreground shadow-lg rounded-sm border border-solid border-rnc-border pointer-events-auto min-w-0 outline-none", className), onOpenAutoFocus: function (event) {
|
|
60
|
+
onOpenAutoFocus === null || onOpenAutoFocus === void 0 ? void 0 : onOpenAutoFocus(event);
|
|
61
|
+
if (event.defaultPrevented)
|
|
62
|
+
return;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
var content = nodeRef.current;
|
|
65
|
+
if (!content || content.contains(document.activeElement)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Radix would focus the first tabbable here. Opened from a menu
|
|
69
|
+
// item, that programmatic focus inherits the menu's
|
|
70
|
+
// :focus-visible state, so a leading tab or button paints a
|
|
71
|
+
// keyboard focus ring after a plain mouse click. Text fields
|
|
72
|
+
// always show their ring when focused, so they keep the old
|
|
73
|
+
// behaviour; anything else lands on the dialog itself and the
|
|
74
|
+
// first Tab press reaches it as before.
|
|
75
|
+
var first = firstTabbable(content);
|
|
76
|
+
var target = first && first.matches(TEXT_ENTRY_SELECTOR) ? first : content;
|
|
77
|
+
target.focus({ preventScroll: true });
|
|
78
|
+
} }, props), children)))));
|
|
37
79
|
});
|
|
38
80
|
// Exports
|
|
39
81
|
export var Dialog = DialogPrimitive.Root;
|
|
@@ -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":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prosemirror-editor.d.ts","sourceRoot":"","sources":["../../../editor-pm/prosemirror-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAK9E,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAY7B,OAAO,KAAK,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAIhD,OAAO,KAQN,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EACV,wBAAwB,EAAC,MAAM,gCAAgC,CAAC;AASlE,OAAO,EAOL,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAMnE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAoBzD,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,KAAK,CAAC,sBAAsB,CAAC,cAAc,CAAC,EAC5C,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CACzD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,OAYvB,CAAC;AAEF,YAAY,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK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IACxB;;;OAGG;gCACyB,OAAO;IACnC;;;;OAIG;qBACc,MAAM;4DAslD1B,CAAC"}
|
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
import { __assign, __awaiter, __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 +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":3,"file":"use-dropdown.d.ts","sourceRoot":"","sources":["../../../hooks/use-dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;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