@sheetxl/utils-react 0.7.27 → 0.7.28-beta.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.
- package/browser/cjs/C7jPCqFJNiWyD2pr.cjs +1 -0
- package/browser/cjs/CyWMySHsu-RvsIGs.cjs +1 -0
- package/browser/cjs/DZSvmqU8nRas1uz6.cjs +1 -0
- package/browser/cjs/index.cjs +5 -7
- package/browser/esm/CD4Q4NRTfHSJirLz.mjs +139 -0
- package/browser/esm/DAwEWkKjQCR-nguL.mjs +2171 -0
- package/browser/esm/DUF3Ugd4Z1SDNXPb.mjs +390 -0
- package/browser/esm/index.mjs +6128 -1806
- package/licenses/dependencies.txt +246 -39
- package/node/esm/DA8vLJ8AED3TYoSo.mjs +2171 -0
- package/node/esm/DKS7p6NraAuZKdCC.mjs +139 -0
- package/node/esm/index.mjs +5141 -1774
- package/package.json +8 -5
- package/types/index.d.ts +2 -2043
- package/types/src/animation/AnimationModeContext.d.ts +10 -0
- package/types/src/animation/index.d.ts +3 -0
- package/types/src/animation/useAnimatedMeasure.d.ts +39 -0
- package/types/src/command/ActivationTracker.d.ts +53 -0
- package/types/src/command/CommandAnchorProvider.d.ts +64 -0
- package/types/src/command/CommandButtonEntryLabel.d.ts +25 -0
- package/types/src/command/CommandButtonRegistry.d.ts +159 -0
- package/types/src/command/CommandButtonRegistryContext.d.ts +35 -0
- package/types/src/command/CommandCatalog.d.ts +155 -0
- package/types/src/command/CommandCatalogResource.d.ts +7 -0
- package/types/src/command/CommandCatalogService.d.ts +61 -0
- package/types/src/command/CommandChainContext.d.ts +32 -0
- package/types/src/command/CommandFallbackContext.d.ts +30 -0
- package/types/src/command/CommandFocusContext.d.ts +21 -0
- package/types/src/command/CommandRegistry.d.ts +164 -0
- package/types/src/command/CommandRegistryContext.d.ts +16 -0
- package/types/src/command/CommandResolver.d.ts +162 -0
- package/types/src/command/CommandScope.d.ts +343 -0
- package/types/src/command/CommandScopeContext.d.ts +205 -0
- package/types/src/command/FocusActivation.d.ts +140 -0
- package/types/src/command/ICommand.d.ts +31 -0
- package/types/src/command/ICommandDefinition.d.ts +82 -0
- package/types/src/command/KeyBindingDispatcher.d.ts +150 -0
- package/types/src/command/LayerActivation.d.ts +45 -0
- package/types/src/command/Types.d.ts +80 -0
- package/types/src/command/createResolvedCommand.d.ts +91 -0
- package/types/src/command/index.d.ts +26 -0
- package/types/src/command/reduceDefinitions.d.ts +33 -0
- package/types/src/command/useCommands.d.ts +22 -0
- package/types/src/command/useContributeCommands.d.ts +18 -0
- package/types/src/components/FocusKeyNavigation.d.ts +22 -0
- package/types/src/components/ITooltip.d.ts +38 -0
- package/types/src/components/RoundedTab.d.ts +26 -0
- package/types/src/components/index.d.ts +4 -0
- package/types/src/error/ErrorPanel.d.ts +14 -0
- package/types/src/error/ReactErrorBoundary.d.ts +7 -0
- package/types/src/error/UncaughtErrorBoundary.d.ts +5 -0
- package/types/src/error/index.d.ts +4 -0
- package/types/src/float/FloatPanel.d.ts +57 -0
- package/types/src/float/FloatPopper.d.ts +85 -0
- package/types/src/float/FloatPopup.d.ts +19 -0
- package/types/src/float/FloatProvider.d.ts +60 -0
- package/types/src/float/FloatStackContext.d.ts +25 -0
- package/types/src/float/FloatTooltip.d.ts +22 -0
- package/types/src/float/FloatUtils.d.ts +55 -0
- package/types/src/float/_FloatUtils.d.ts +51 -0
- package/types/src/float/index.d.ts +9 -0
- package/types/src/float/useFloatStack.d.ts +92 -0
- package/types/src/hooks/LanguageState.d.ts +15 -0
- package/types/src/hooks/index.d.ts +19 -0
- package/types/src/hooks/useBoundSyncExternalStore.d.ts +23 -0
- package/types/src/hooks/useCallbackRef.d.ts +11 -0
- package/types/src/hooks/useDevicePixelRatio.d.ts +37 -0
- package/types/src/hooks/useEditMode.d.ts +66 -0
- package/types/src/hooks/useGlobalClipboard.d.ts +7 -0
- package/types/src/hooks/useId.d.ts +9 -0
- package/types/src/hooks/useImperativeElement.d.ts +3 -0
- package/types/src/hooks/useLanguage.d.ts +13 -0
- package/types/src/hooks/useMouseDownAndHoldListener.d.ts +13 -0
- package/types/src/hooks/useNotifier.d.ts +330 -0
- package/types/src/hooks/useOnClickOrFocusAway.d.ts +8 -0
- package/types/src/hooks/useOptionalBoundSyncExternalStore.d.ts +20 -0
- package/types/src/hooks/useOptionalSyncExternalStore.d.ts +18 -0
- package/types/src/hooks/useSynchronizedPointerHandler.d.ts +54 -0
- package/types/src/hooks/useTextareaCaretRect.d.ts +85 -0
- package/types/src/hooks/useTraceUpdate.d.ts +2 -0
- package/types/src/hooks/useTranslator.d.ts +32 -0
- package/types/src/icons/DynamicIcon.d.ts +17 -0
- package/types/src/icons/DynamicIconService.d.ts +39 -0
- package/types/src/icons/ErrorIcon.d.ts +6 -0
- package/types/src/icons/Types.d.ts +81 -0
- package/types/src/icons/WalkingIcon.d.ts +27 -0
- package/types/src/icons/_Utils.d.ts +3 -0
- package/types/src/icons/index.d.ts +5 -0
- package/types/src/icons/packs/Base.d.ts +4 -0
- package/types/src/icons/packs/Conditional.d.ts +4 -0
- package/types/src/index.d.ts +18 -0
- package/types/src/loading/LoadingPanel.d.ts +31 -0
- package/types/src/loading/index.d.ts +2 -0
- package/types/src/persistence/InMemoryStore.d.ts +12 -0
- package/types/src/persistence/LocalStorageStore.d.ts +15 -0
- package/types/src/persistence/PersistenceStateProvider.d.ts +3 -0
- package/types/src/persistence/Types.d.ts +95 -0
- package/types/src/persistence/_Context.d.ts +9 -0
- package/types/src/persistence/index.d.ts +6 -0
- package/types/src/persistence/usePersistenceState.d.ts +33 -0
- package/types/src/react-resizable/Resizable.d.ts +30 -0
- package/types/src/react-resizable/ResizableBox.d.ts +18 -0
- package/types/src/react-resizable/index.d.ts +11 -0
- package/types/src/react-resizable/propTypes.d.ts +56 -0
- package/types/src/react-resizable/utils.d.ts +3 -0
- package/types/src/scroll/AxisViewport.d.ts +73 -0
- package/types/src/scroll/IScrollPane.d.ts +63 -0
- package/types/src/scroll/IScrollbar.d.ts +94 -0
- package/types/src/scroll/NativeScrollbar.d.ts +7 -0
- package/types/src/scroll/ScrollButton.d.ts +29 -0
- package/types/src/scroll/ScrollPane.d.ts +4 -0
- package/types/src/scroll/Scrollbar.d.ts +4 -0
- package/types/src/scroll/TouchThumbContext.d.ts +93 -0
- package/types/src/scroll/TouchThumbHandle.d.ts +64 -0
- package/types/src/scroll/TrackDrag.d.ts +107 -0
- package/types/src/scroll/Utils.d.ts +8 -0
- package/types/src/scroll/Viewport.d.ts +285 -0
- package/types/src/scroll/VirtualScrollbar.d.ts +49 -0
- package/types/src/scroll/index.d.ts +14 -0
- package/types/src/scroll/scrollbarTheming.d.ts +27 -0
- package/types/src/scroll/useWheelScroll.d.ts +27 -0
- package/types/src/scroller/Scroller.d.ts +260 -0
- package/types/src/scroller/animate.d.ts +30 -0
- package/types/src/scroller/index.d.ts +2 -0
- package/types/src/singletonHook/components/SingleItemContainer.d.ts +6 -0
- package/types/src/singletonHook/components/SingletonHooksContainer.d.ts +7 -0
- package/types/src/singletonHook/index.d.ts +11 -0
- package/types/src/singletonHook/singletonHook.d.ts +6 -0
- package/types/src/singletonHook/utils/env.d.ts +4 -0
- package/types/src/singletonHook/utils/env.native.d.ts +1 -0
- package/types/src/singletonHook/utils/warning.d.ts +2 -0
- package/types/src/splitPane/SplitPane.d.ts +91 -0
- package/types/src/splitPane/SplitPaneResizer.d.ts +11 -0
- package/types/src/splitPane/index.d.ts +3 -0
- package/types/src/theme/TokenTheme.d.ts +196 -0
- package/types/src/theme/TokenThemeProvider.d.ts +97 -0
- package/types/src/theme/buildThemeCSS.d.ts +54 -0
- package/types/src/theme/createThemeVars.d.ts +15 -0
- package/types/src/theme/defaultTheme.d.ts +15 -0
- package/types/src/theme/index.d.ts +9 -0
- package/types/src/theme/resolveTokens.d.ts +21 -0
- package/types/src/theme/themeAttrs.d.ts +32 -0
- package/types/src/theme/useResolvedThemeMode.d.ts +17 -0
- package/types/src/types/Types.d.ts +71 -0
- package/types/src/types/index.d.ts +2 -0
- package/types/src/utils/FullScreenPortal.d.ts +6 -0
- package/types/src/utils/PinchZoom.d.ts +3 -0
- package/types/src/utils/ReactUtils.d.ts +134 -0
- package/types/src/utils/index.d.ts +4 -0
- package/types/src/utils/useFullScreen.d.ts +47 -0
- package/browser/cjs/DJJQOl0dYYJgXfru.cjs +0 -6
- package/browser/esm/Bh0xih0ZamA4MXkt.mjs +0 -12
- package/node/assets/style.css +0 -1
- package/node/esm/DdwriRgF582bPBWP.mjs +0 -12
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like {@link useBoundSyncExternalStore}, but for a store that may be **absent** (`null`/`undefined`)
|
|
3
|
+
* — the bound-method analog of {@link useOptionalSyncExternalStore}. It calls `store.subscribe(...)`
|
|
4
|
+
* and the snapshot selector **on the instance**, so a normal `this`-centric class whose methods are
|
|
5
|
+
* NOT pre-bound works without the caller detaching them (which would strip `this`); returns the
|
|
6
|
+
* snapshot, or `null` when there is no store.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Pass the store instance (or `null`/`undefined`) and a selector that reads the snapshot off it
|
|
10
|
+
* (`s => s.getState()`). `subscribe` is memoized on the store identity so it stays a stable reference
|
|
11
|
+
* across renders; the snapshot selector may be an inline arrow. The `null` snapshot doubles as the
|
|
12
|
+
* SSR snapshot, keeping it SSR-safe.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam S - The store type; must expose a `subscribe(listener)` method.
|
|
15
|
+
* @typeParam T - The snapshot value type.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useOptionalBoundSyncExternalStore<S extends {
|
|
18
|
+
subscribe(onStoreChange: () => void): () => void;
|
|
19
|
+
}, T>(store: S | null | undefined, getSnapshot: (store: S) => T): T | null;
|
|
20
|
+
//# sourceMappingURL=useOptionalBoundSyncExternalStore.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like {@link useSyncExternalStore}, but for a store that may be **absent** (`null`/`undefined`).
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* React forbids calling `useSyncExternalStore` conditionally, so observing a sometimes-there store
|
|
6
|
+
* otherwise forces per-call-site `null` sentinels (you cannot early-return, nor pass `null.subscribe`).
|
|
7
|
+
* Pass the store's `subscribe` and snapshot getter — or `null`/`undefined` when there is no store;
|
|
8
|
+
* returns the snapshot, or `null` when absent. The snapshot doubles as the SSR snapshot (`null` with
|
|
9
|
+
* no store), keeping it SSR-safe.
|
|
10
|
+
*
|
|
11
|
+
* `subscribe`/`getSnapshot` MUST be **stable references** (e.g. bound class-field methods): an inline
|
|
12
|
+
* arrow changes identity every render and would resubscribe each time. Reading them off a stable
|
|
13
|
+
* instance via optional chaining (`store?.subscribe`) is the intended usage.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam T - The snapshot value type.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useOptionalSyncExternalStore<T>(subscribe: ((onStoreChange: () => void) => () => void) | null | undefined, getSnapshot: (() => T) | null | undefined): T | null;
|
|
18
|
+
//# sourceMappingURL=useOptionalSyncExternalStore.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The pointer modifiers are used because pointer events and keyboard events
|
|
4
|
+
* both have modifiers but pointer events are not updated with a keyboard event
|
|
5
|
+
* is pressed.
|
|
6
|
+
*/
|
|
7
|
+
export interface PointerModifiers {
|
|
8
|
+
ctrlKey: boolean;
|
|
9
|
+
shiftKey: boolean;
|
|
10
|
+
altKey: boolean;
|
|
11
|
+
metaKey: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface PointerHandlerOptions<T extends Element = Element> {
|
|
14
|
+
/**
|
|
15
|
+
* If returns false then other events will not be fired
|
|
16
|
+
*/
|
|
17
|
+
onPointerDown: (event: React.PointerEvent<T>, modifiers: PointerModifiers) => boolean | void;
|
|
18
|
+
/**
|
|
19
|
+
* If the Pointer has moved or it the Pointer was held for a period of timerContinuous.
|
|
20
|
+
*/
|
|
21
|
+
onPointerMoveOrWait?: (event: React.PointerEvent<T>, modifiers: PointerModifiers, originalEvent: React.PointerEvent<T>) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Called when Pointer is released. This is different than the regular
|
|
24
|
+
* Pointer up in that it will be called even if the Pointer is released
|
|
25
|
+
* when outside the component.
|
|
26
|
+
*/
|
|
27
|
+
onPointerUp?: (event: React.PointerEvent<T>, modifiers: PointerModifiers, originalEvent: React.PointerEvent<T>) => void;
|
|
28
|
+
timerInitial?: number;
|
|
29
|
+
timerContinuous?: number;
|
|
30
|
+
/**
|
|
31
|
+
* If this is being used for a touch device then this should be true. This will
|
|
32
|
+
* prevent the default touch events from being fired (by calling defaultPrevent during the capture phase).
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
processTouch?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* If true the touch events will be consumed and not propagated.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
consumeTouch?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* If returns false don't setup the other listeners
|
|
44
|
+
*/
|
|
45
|
+
export type PointerDownListener = (event: React.PointerEvent<Element>) => void;
|
|
46
|
+
/**
|
|
47
|
+
* This hook will respond on Pointer down and then continue to fire events
|
|
48
|
+
* until the Pointer is released.
|
|
49
|
+
*
|
|
50
|
+
* Returns PointerDownListener that should be added to the
|
|
51
|
+
* source component's onPointerDown event handler.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useSynchronizedPointerHandler(options: PointerHandlerOptions): PointerDownListener;
|
|
54
|
+
//# sourceMappingURL=useSynchronizedPointerHandler.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal, `DOMRect`-shaped result (all eight box fields + `toJSON`). We build our own instead of
|
|
3
|
+
* `new DOMRect(...)` so the pure {@link composeCaretRect} math stays usable in a non-DOM (node) test
|
|
4
|
+
* env, and so the result can be handed directly to a float **virtual anchor**
|
|
5
|
+
* (`{ getBoundingClientRect(): DOMRect }`) — a plain rect satisfies that contract at runtime.
|
|
6
|
+
*/
|
|
7
|
+
export interface CaretRect {
|
|
8
|
+
readonly x: number;
|
|
9
|
+
readonly y: number;
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
readonly top: number;
|
|
13
|
+
readonly left: number;
|
|
14
|
+
readonly right: number;
|
|
15
|
+
readonly bottom: number;
|
|
16
|
+
toJSON(): unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compose the viewport-space caret rect from the three measured boxes — the **pure** core of the caret
|
|
20
|
+
* geometry, split out so it can be unit-tested without a layout engine (jsdom does no layout).
|
|
21
|
+
*
|
|
22
|
+
* The caret's offset *within the content* is `marker.left/top − mirror.left/top`: because the mirror
|
|
23
|
+
* copies the textarea's border + padding, that delta measured from the mirror's **border-box** corner
|
|
24
|
+
* equals the same offset from the textarea's border-box corner. Add the textarea's viewport position and
|
|
25
|
+
* subtract its scroll to land on the on-screen caret.
|
|
26
|
+
*/
|
|
27
|
+
export declare const composeCaretRect: (p: {
|
|
28
|
+
/** The textarea's border-box origin, viewport space (`textarea.getBoundingClientRect()`). */
|
|
29
|
+
textareaRect: {
|
|
30
|
+
left: number;
|
|
31
|
+
top: number;
|
|
32
|
+
};
|
|
33
|
+
/** The mirror's border-box origin, viewport space. */
|
|
34
|
+
mirrorRect: {
|
|
35
|
+
left: number;
|
|
36
|
+
top: number;
|
|
37
|
+
};
|
|
38
|
+
/** The caret marker span's box: origin (viewport space) + its line-box height (the caret height). */
|
|
39
|
+
markerRect: {
|
|
40
|
+
left: number;
|
|
41
|
+
top: number;
|
|
42
|
+
height: number;
|
|
43
|
+
};
|
|
44
|
+
/** `textarea.scrollLeft` — the caret shifts left as the field scrolls right. */
|
|
45
|
+
scrollLeft: number;
|
|
46
|
+
/** `textarea.scrollTop`. */
|
|
47
|
+
scrollTop: number;
|
|
48
|
+
}) => CaretRect;
|
|
49
|
+
/**
|
|
50
|
+
* Measure the on-screen caret rect for `textarea` at `index` (default: the current `selectionStart`).
|
|
51
|
+
* Uses a hidden mirror div — pass a persistent one (the hook does) to avoid per-call DOM churn; omit it
|
|
52
|
+
* and a transient mirror is created + removed. Returns a zero-size rect at the origin when there is no
|
|
53
|
+
* DOM / element (SSR-safe).
|
|
54
|
+
*/
|
|
55
|
+
export declare const getTextareaCaretRect: (textarea: HTMLTextAreaElement | null | undefined, index?: number, mirror?: HTMLElement, padding?: number) => CaretRect;
|
|
56
|
+
/** What {@link useTextareaCaretRect} returns. */
|
|
57
|
+
export interface TextareaCaretRectHandle {
|
|
58
|
+
/** Measure the caret rect now, at `index` (default: live `selectionStart`); `padding` pulls it left. */
|
|
59
|
+
getCaretRect(index?: number, padding?: number): CaretRect;
|
|
60
|
+
/**
|
|
61
|
+
* A stable **virtual element** (`{ getBoundingClientRect }`) that re-measures on every read — pass it
|
|
62
|
+
* straight to a float `anchor` so the popup tracks the position as it moves. `index` may be a fixed
|
|
63
|
+
* number, a live getter (e.g. a token-start offset, so the popup anchors to the token rather than the
|
|
64
|
+
* caret), or omitted (follows `selectionStart`). `padding` (fixed or live) pulls the anchor left so a
|
|
65
|
+
* popup with its own left inset lines up flush under the offset.
|
|
66
|
+
*/
|
|
67
|
+
caretAnchor(index?: number | (() => number), padding?: number | (() => number)): {
|
|
68
|
+
getBoundingClientRect(): CaretRect;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Caret geometry for a `<textarea>`: turn a caret offset into a viewport rect you can anchor a float
|
|
73
|
+
* (dropdown / function tip / range hint) to. The workhorse behind the formula editor's popups; also the
|
|
74
|
+
* measurement seam the token-highlight overlay reuses. DOM-only (no SDK), so it lives here alongside the
|
|
75
|
+
* other generic hooks and is shared by both the inline cell editor and the formula bar.
|
|
76
|
+
*
|
|
77
|
+
* @param ref A ref to the textarea to measure.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Backed by one persistent hidden mirror div (created on mount, removed on unmount) that copies the
|
|
81
|
+
* textarea's font / padding / border / wrap so measurement matches what the user sees — including zoom,
|
|
82
|
+
* since the grid applies zoom via font-size (not a transform), which the computed style already carries.
|
|
83
|
+
*/
|
|
84
|
+
export declare const useTextareaCaretRect: (ref: React.RefObject<HTMLTextAreaElement | null>) => TextareaCaretRectHandle;
|
|
85
|
+
//# sourceMappingURL=useTextareaCaretRect.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The call-site translate function: `t(key, params?)`.
|
|
3
|
+
*
|
|
4
|
+
* The English is NOT a parameter — it lives only in the package's `locales/en/messages.json`
|
|
5
|
+
* (I18N-DESIGN.md decision 9), and a pack overlays by key. A miss renders the key: visible and
|
|
6
|
+
* debuggable, never blank.
|
|
7
|
+
*/
|
|
8
|
+
export type TranslateFn = (key: string, params?: Record<string, unknown>) => string;
|
|
9
|
+
/**
|
|
10
|
+
* The **React** binding for call-site (`t()`) strings — subscribes to the active language and
|
|
11
|
+
* returns a `t` bound to it.
|
|
12
|
+
*
|
|
13
|
+
* Use this instead of importing `t` from `@sheetxl/utils` inside a component. The module-level
|
|
14
|
+
* `t` reads a singleton, so React cannot know its value changed on a language switch: a component
|
|
15
|
+
* calling it had to *separately* remember to subscribe (a bare `useLanguage()`), and forgetting
|
|
16
|
+
* was invisible — the string simply froze at whatever language was active when the component
|
|
17
|
+
* mounted. (That is not hypothetical: the Name Box tooltip shipped exactly that way.) Taking `t`
|
|
18
|
+
* from this hook makes the subscription inseparable from the use — the same reason
|
|
19
|
+
* react-i18next hands you `t` from `useTranslation()` rather than exporting it.
|
|
20
|
+
*
|
|
21
|
+
* The returned function's **identity changes when the language changes**, so it is the natural
|
|
22
|
+
* memo dependency for anything that bakes a translated string:
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const t = useTranslator();
|
|
26
|
+
* const items = useMemo(() => [{ label: t('formulaBar.cancel') }], [t]);
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* The module-level `t` remains exported for **non-React** contexts (and is what this delegates to).
|
|
30
|
+
*/
|
|
31
|
+
export declare function useTranslator(): TranslateFn;
|
|
32
|
+
//# sourceMappingURL=useTranslator.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IconGlyphKey, IconPackKey } from './Types';
|
|
3
|
+
export interface DynamicIconProps extends React.HTMLAttributes<HTMLElement> {
|
|
4
|
+
iconKey?: IconGlyphKey;
|
|
5
|
+
packKey?: IconPackKey;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
/** Sets wrapper font-size; children scale to 1em */
|
|
9
|
+
size?: string | number;
|
|
10
|
+
title?: string;
|
|
11
|
+
role?: 'img' | 'presentation' | string;
|
|
12
|
+
ariaHidden?: boolean;
|
|
13
|
+
/** Extra props forwarded to React glyphs (if the glyph is of type `react`) */
|
|
14
|
+
propsSource?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export declare const DynamicIcon: React.MemoExoticComponent<(props: DynamicIconProps) => React.JSX.Element>;
|
|
17
|
+
//# sourceMappingURL=DynamicIcon.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RemoveListener } from '@sheetxl/utils';
|
|
2
|
+
import { IconPackKey, IconGlyphKey, IconPack, IconGlyphPackPair, IconPackInput } from './Types';
|
|
3
|
+
export interface ResolveOptions {
|
|
4
|
+
packKey?: IconPackKey;
|
|
5
|
+
}
|
|
6
|
+
type PackModule = {
|
|
7
|
+
readonly default: IconPack | IconPackInput;
|
|
8
|
+
} & Record<string, unknown>;
|
|
9
|
+
type PackLoader = () => Promise<IconPack | IconPackInput | PackModule>;
|
|
10
|
+
export declare function createDynamicIconService(): {
|
|
11
|
+
register: (key: IconPackKey, packOrLoader: IconPack | IconPackInput | PackLoader) => void;
|
|
12
|
+
prefetch: (keys?: IconPackKey | IconPackKey[]) => Promise<void>;
|
|
13
|
+
setActive: (packKey: IconPackKey) => void;
|
|
14
|
+
getActive: () => IconPackKey;
|
|
15
|
+
resolve: (key: IconGlyphKey, o?: ResolveOptions) => Promise<IconGlyphPackPair | null>;
|
|
16
|
+
registerAlias: (packKey: IconPackKey, fromKey: IconGlyphKey, toKey: IconGlyphKey) => void;
|
|
17
|
+
has: (key: IconGlyphKey, o?: ResolveOptions) => boolean;
|
|
18
|
+
getPack: (packKey?: IconPackKey) => IconPack | undefined;
|
|
19
|
+
hasPack: (packKey: IconPackKey) => boolean;
|
|
20
|
+
listPacks: () => IconPackKey[];
|
|
21
|
+
listIcons: (packKey: IconPackKey) => string[];
|
|
22
|
+
addActiveListener: (cb: (key: IconPackKey) => void) => RemoveListener;
|
|
23
|
+
};
|
|
24
|
+
export declare const DefaultIconService: {
|
|
25
|
+
register: (key: IconPackKey, packOrLoader: IconPack | IconPackInput | PackLoader) => void;
|
|
26
|
+
prefetch: (keys?: IconPackKey | IconPackKey[]) => Promise<void>;
|
|
27
|
+
setActive: (packKey: IconPackKey) => void;
|
|
28
|
+
getActive: () => IconPackKey;
|
|
29
|
+
resolve: (key: IconGlyphKey, o?: ResolveOptions) => Promise<IconGlyphPackPair | null>;
|
|
30
|
+
registerAlias: (packKey: IconPackKey, fromKey: IconGlyphKey, toKey: IconGlyphKey) => void;
|
|
31
|
+
has: (key: IconGlyphKey, o?: ResolveOptions) => boolean;
|
|
32
|
+
getPack: (packKey?: IconPackKey) => IconPack | undefined;
|
|
33
|
+
hasPack: (packKey: IconPackKey) => boolean;
|
|
34
|
+
listPacks: () => IconPackKey[];
|
|
35
|
+
listIcons: (packKey: IconPackKey) => string[];
|
|
36
|
+
addActiveListener: (cb: (key: IconPackKey) => void) => RemoveListener;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=DynamicIconService.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export type IconPackKey = string;
|
|
2
|
+
export type IconGlyphKey = string;
|
|
3
|
+
export type IconPath = {
|
|
4
|
+
d: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
fill?: string;
|
|
7
|
+
stroke?: string;
|
|
8
|
+
opacity?: number | string;
|
|
9
|
+
fillRule?: "nonzero" | "evenodd";
|
|
10
|
+
clipRule?: "nonzero" | "evenodd";
|
|
11
|
+
};
|
|
12
|
+
type BaseGlyph = {
|
|
13
|
+
tags?: string[];
|
|
14
|
+
rtlMirror?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type SvgRender = (props: React.HTMLAttributes<SVGElement>) => React.ReactNode;
|
|
17
|
+
export type SvgDef = {
|
|
18
|
+
paths: IconPath[];
|
|
19
|
+
viewBox?: string;
|
|
20
|
+
};
|
|
21
|
+
export type SvgSource = SvgDef | SvgRender;
|
|
22
|
+
export type SvgGlyph = BaseGlyph & {
|
|
23
|
+
svg: SvgSource;
|
|
24
|
+
};
|
|
25
|
+
export type UrlGlyph = BaseGlyph & {
|
|
26
|
+
url: {
|
|
27
|
+
src: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type EmojiGlyph = BaseGlyph & {
|
|
31
|
+
emoji: string | {
|
|
32
|
+
text: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type ReactGlyph<P extends ReactIconProps = ReactIconProps> = BaseGlyph & {
|
|
36
|
+
react: ReactInput<P>;
|
|
37
|
+
};
|
|
38
|
+
export type IconGlyph = SvgGlyph | UrlGlyph | EmojiGlyph | ReactGlyph;
|
|
39
|
+
export interface IconPackMeta {
|
|
40
|
+
label: string;
|
|
41
|
+
version: string;
|
|
42
|
+
license: string;
|
|
43
|
+
defaultViewBox: string;
|
|
44
|
+
extends: IconPackKey[];
|
|
45
|
+
}
|
|
46
|
+
export interface IconPack {
|
|
47
|
+
icons: Readonly<Record<IconGlyphKey, IconGlyph>>;
|
|
48
|
+
meta: IconPackMeta;
|
|
49
|
+
}
|
|
50
|
+
export interface IconGlyphPackPair {
|
|
51
|
+
glyph: IconGlyph;
|
|
52
|
+
pack: IconPack;
|
|
53
|
+
packKey: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ReactIconProps extends React.HTMLAttributes<HTMLElement> {
|
|
56
|
+
}
|
|
57
|
+
export type SvgSourceInput = (SvgDef & BaseGlyph) | SvgRender | IconPath[] | string[] | string;
|
|
58
|
+
export type UrlInput = {
|
|
59
|
+
src: string;
|
|
60
|
+
} | string;
|
|
61
|
+
export type EmojiInput = {
|
|
62
|
+
text: string;
|
|
63
|
+
} | string;
|
|
64
|
+
export type ReactInput<P extends ReactIconProps = ReactIconProps> = (props: P) => React.ReactNode;
|
|
65
|
+
export type IconGlyphInput = ({
|
|
66
|
+
svg: SvgSourceInput;
|
|
67
|
+
}) | ({
|
|
68
|
+
url: UrlInput;
|
|
69
|
+
} & BaseGlyph) | ({
|
|
70
|
+
emoji: EmojiInput;
|
|
71
|
+
} & BaseGlyph) | ({
|
|
72
|
+
react: ReactInput;
|
|
73
|
+
} & BaseGlyph);
|
|
74
|
+
export type IconsInputRecord = Readonly<Record<IconGlyphKey, IconGlyphInput>>;
|
|
75
|
+
export interface IconPackInput {
|
|
76
|
+
icons: IconsInputRecord;
|
|
77
|
+
meta?: Partial<IconPackMeta>;
|
|
78
|
+
overrides?: Record<IconPackKey, IconsInputRecord>;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IconGlyphKey } from './Types';
|
|
3
|
+
import { DynamicIconProps } from './DynamicIcon';
|
|
4
|
+
/**
|
|
5
|
+
* This wraps an icon with a walking stroke animation.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This requires a 'delegating' glyph icons to passed.
|
|
9
|
+
* This will then use CSS animation to create a walking stroke effect.
|
|
10
|
+
*/
|
|
11
|
+
export interface WalkingIconProps extends DynamicIconProps {
|
|
12
|
+
/** The key of the icon this must be available in the DynamicIconService. */
|
|
13
|
+
iconKey: IconGlyphKey;
|
|
14
|
+
/** Animate the stroke marching effect. */
|
|
15
|
+
isWalking: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Retint the walkable stroke to a semantic token. Mirrors `SheetClipboardLayer`
|
|
18
|
+
* (`isCut ? warning : primary`): defaults to `"primary"`, pass `"warning"` for a cut.
|
|
19
|
+
*/
|
|
20
|
+
themedType?: "primary" | "accent" | "success" | "info" | "warning" | "error";
|
|
21
|
+
/** Animation speed in milliseconds. */
|
|
22
|
+
speed?: number;
|
|
23
|
+
dashGap?: number;
|
|
24
|
+
dashLength?: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function WalkingIcon(props: WalkingIconProps): React.JSX.Element;
|
|
27
|
+
//# sourceMappingURL=WalkingIcon.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './command';
|
|
3
|
+
export * as Command from './command';
|
|
4
|
+
export * from './animation';
|
|
5
|
+
export * from './components';
|
|
6
|
+
export * from './loading';
|
|
7
|
+
export * from './error';
|
|
8
|
+
export * from './float';
|
|
9
|
+
export * from './splitPane';
|
|
10
|
+
export * from './hooks';
|
|
11
|
+
export * from './icons';
|
|
12
|
+
export * from './persistence';
|
|
13
|
+
export * from './scroll';
|
|
14
|
+
export * from './theme';
|
|
15
|
+
export * from './utils';
|
|
16
|
+
export { Resizable, ResizableBox } from './react-resizable';
|
|
17
|
+
export type { ResizeCallbackData, ResizeHandleAxis } from './react-resizable';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for LoadingPanel
|
|
3
|
+
*/
|
|
4
|
+
export interface LoadingPanelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* A delay for showing the loading panel.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This helps prevent flicker if loading is very fast.
|
|
10
|
+
*/
|
|
11
|
+
transitionDelay?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the background should be transparent.
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue false
|
|
16
|
+
*/
|
|
17
|
+
transparentBackground?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Optional callback when mounted
|
|
20
|
+
*/
|
|
21
|
+
onMount?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Optional callback when unmounted
|
|
24
|
+
*/
|
|
25
|
+
onUnmount?: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Ref to the element.
|
|
28
|
+
*/
|
|
29
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=LoadingPanel.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PersistenceStore } from './Types';
|
|
2
|
+
/** In-memory state (default fallback / SSR-safe) */
|
|
3
|
+
export declare class InMemoryStore implements PersistenceStore {
|
|
4
|
+
private store;
|
|
5
|
+
/** {@inheritDoc PersistenceStore.getItem} */
|
|
6
|
+
getItem(k: string): string | null;
|
|
7
|
+
/** {@inheritDoc PersistenceStore.setItem} */
|
|
8
|
+
setItem(k: string, v: string): void;
|
|
9
|
+
/** {@inheritDoc PersistenceStore.removeItem} */
|
|
10
|
+
removeItem(k: string): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=InMemoryStore.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PersistenceStore } from './Types';
|
|
2
|
+
/** LocalStorage state with cross-tab sync */
|
|
3
|
+
export declare class LocalStorageStore implements PersistenceStore {
|
|
4
|
+
private storage;
|
|
5
|
+
constructor(storage?: Storage);
|
|
6
|
+
/** {@inheritDoc PersistenceStore.getItem} */
|
|
7
|
+
getItem(k: string): string | null;
|
|
8
|
+
/** {@inheritDoc PersistenceStore.setItem} */
|
|
9
|
+
setItem(k: string, v: string): void;
|
|
10
|
+
/** {@inheritDoc PersistenceStore.removeItem} */
|
|
11
|
+
removeItem(k: string): void;
|
|
12
|
+
/** {@inheritDoc PersistenceStore.subscribe} */
|
|
13
|
+
subscribe?(onExternalChange: (changedKey: string) => void): () => void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=LocalStorageStore.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primary interface for storing retrieving key/value pairs
|
|
3
|
+
*/
|
|
4
|
+
export interface PersistenceStore {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the value associated with the given key.
|
|
7
|
+
*
|
|
8
|
+
* @param key The key to retrieve.
|
|
9
|
+
*/
|
|
10
|
+
getItem(key: string): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the value for the given key.
|
|
13
|
+
*
|
|
14
|
+
* @param key The key to set.
|
|
15
|
+
* @param value The value to associate with the key.
|
|
16
|
+
*/
|
|
17
|
+
setItem(key: string, value: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Removes the value associated with the given key.
|
|
20
|
+
*
|
|
21
|
+
* @param key The key to remove.
|
|
22
|
+
*/
|
|
23
|
+
removeItem(key: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Subscribes to external changes for cross-tab synchronization.
|
|
26
|
+
*
|
|
27
|
+
* @param onExternalChange Callback invoked when a key changes externally.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* Not all state implementations support cross-tab subscription (may no-op)
|
|
31
|
+
*/
|
|
32
|
+
subscribe?(onExternalChange: (changedKey: string) => void): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* If implemented the provider will is this called when the store is ready to be used.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* This is useful for avoiding flash with asynchronous stores that need to do some initialization before use.
|
|
38
|
+
*
|
|
39
|
+
* If this is implemented it should be called once when the store is ready.
|
|
40
|
+
* If the store is already ready when called it should invoke immediately the callback synchronously.
|
|
41
|
+
*/
|
|
42
|
+
onReady?(callback: () => void): void;
|
|
43
|
+
}
|
|
44
|
+
export type PersistenceSerializer<T = any> = {
|
|
45
|
+
parse: (raw: string | null) => T;
|
|
46
|
+
stringify: (val: T) => string;
|
|
47
|
+
};
|
|
48
|
+
export type PersistenceStateOptions<T = any> = {
|
|
49
|
+
/**
|
|
50
|
+
* Convert the value to/from a string for storage
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue JSON
|
|
53
|
+
*/
|
|
54
|
+
serializer?: PersistenceSerializer<T>;
|
|
55
|
+
version?: number;
|
|
56
|
+
migrate?: (oldValue: unknown, oldVersion: number | undefined) => T;
|
|
57
|
+
lazy?: boolean;
|
|
58
|
+
};
|
|
59
|
+
export type PersistenceStateSetter<T> = (next: T | ((prev: T) => T)) => void;
|
|
60
|
+
export type PersistenceProviderProps = {
|
|
61
|
+
/**
|
|
62
|
+
* Storage backend to use
|
|
63
|
+
*/
|
|
64
|
+
store: PersistenceStore;
|
|
65
|
+
/**
|
|
66
|
+
* Namespace prefix for all keys
|
|
67
|
+
*
|
|
68
|
+
* @defaultValue none
|
|
69
|
+
*/
|
|
70
|
+
namespace?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Convert the value to/from a string for storage.
|
|
73
|
+
*
|
|
74
|
+
* @defaultValue `JSON.parse / JSON.stringify`
|
|
75
|
+
*/
|
|
76
|
+
serializer?: PersistenceSerializer;
|
|
77
|
+
/**
|
|
78
|
+
* Callback invoked when the store is ready to be used.
|
|
79
|
+
*/
|
|
80
|
+
onReady?: (callback: () => void) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Debounce time in milliseconds for state updates.
|
|
83
|
+
*
|
|
84
|
+
* @defaultValue `150`
|
|
85
|
+
*/
|
|
86
|
+
debounceMs?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Children elements that will have access to the persistence context.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* Required for provider
|
|
92
|
+
*/
|
|
93
|
+
children: React.ReactNode;
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PersistenceProviderProps, PersistenceSerializer } from './Types';
|
|
2
|
+
export type Ctx = Required<Omit<PersistenceProviderProps, 'children'>> & {
|
|
3
|
+
notify(key: string, value?: string): void;
|
|
4
|
+
subscribeKey(key: string, fn: (value?: string) => void): () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const PersistenceContext: import('react').Context<Ctx | null>;
|
|
7
|
+
export declare const DefaultSerializer: PersistenceSerializer;
|
|
8
|
+
export declare function usePersistenceContext(): Ctx;
|
|
9
|
+
//# sourceMappingURL=_Context.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PersistenceStateOptions, PersistenceStateSetter } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* Persisted state hook backed by the current persistence context.
|
|
4
|
+
*
|
|
5
|
+
* This works like `useState`, but:
|
|
6
|
+
*
|
|
7
|
+
* - The value is persisted under `namespace:key` using the current store.
|
|
8
|
+
* - On first render, it initializes from `defaultValue`.
|
|
9
|
+
* - Then it **hydrates asynchronously** from the configured store
|
|
10
|
+
* (memory, localStorage, IndexedDB, remote, etc.).
|
|
11
|
+
* - Writes are **debounced** according to `debounceMs` from the context.
|
|
12
|
+
* - Optional **versioning + migration** lets you evolve stored shapes over time.
|
|
13
|
+
*
|
|
14
|
+
* ### Optional persistence
|
|
15
|
+
*
|
|
16
|
+
* If `key` is `null`, **persistence is disabled** and the hook behaves like
|
|
17
|
+
* a plain `useState` with the same `defaultValue` semantics:
|
|
18
|
+
*
|
|
19
|
+
* - No reads or writes go to the persistence store.
|
|
20
|
+
* - No cross-tab / cross-hook subscription is set up.
|
|
21
|
+
* - `clear()` simply resets back to the default value (or `undefined`).
|
|
22
|
+
*
|
|
23
|
+
* @typeParam T - Type of the stored value.
|
|
24
|
+
* @param key - Logical storage key; use `null` to disable persistence entirely.
|
|
25
|
+
* @param defaultValue - Initial value or lazy initializer function.
|
|
26
|
+
* @param opts - Options controlling serialization, versioning, migration, and laziness.
|
|
27
|
+
* @returns A tuple of `[state, setState, clear]`:
|
|
28
|
+
* - `state` – The current value.
|
|
29
|
+
* - `setState(next)` – Updates the value and persists it (unless `key === null`).
|
|
30
|
+
* - `clear()` – Removes the persisted value and resets to `defaultValue`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function usePersistenceState<T = unknown>(key: string | null, defaultValue?: T | (() => T), opts?: PersistenceStateOptions<T>): [T, PersistenceStateSetter<T>, () => void];
|
|
33
|
+
//# sourceMappingURL=usePersistenceState.d.ts.map
|