@sheetxl/utils-react 0.7.21 → 0.7.23-beta.2
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/BlY25fmBdmHNyBqo.mjs +139 -0
- package/browser/esm/CQUN3sZz7IrPMYIa.mjs +2171 -0
- package/browser/esm/DpI3aVOBON4B0xID.mjs +390 -0
- package/browser/esm/index.mjs +6127 -1795
- package/licenses/dependencies.txt +246 -39
- package/node/esm/B8EaqTMia4qMXy5z.mjs +139 -0
- package/node/esm/D9Xo9E4JB3ReeH-J.mjs +2171 -0
- package/node/esm/index.mjs +5140 -1763
- package/package.json +8 -5
- package/types/index.d.ts +2 -1969
- package/types/src/animation/AnimationModeContext.d.ts +10 -0
- package/types/src/animation/AnimationModeContext.d.ts.map +1 -0
- package/types/src/animation/index.d.ts +3 -0
- package/types/src/animation/index.d.ts.map +1 -0
- package/types/src/animation/useAnimatedMeasure.d.ts +39 -0
- package/types/src/animation/useAnimatedMeasure.d.ts.map +1 -0
- package/types/src/command/ActivationTracker.d.ts +53 -0
- package/types/src/command/ActivationTracker.d.ts.map +1 -0
- package/types/src/command/CommandAnchorProvider.d.ts +64 -0
- package/types/src/command/CommandAnchorProvider.d.ts.map +1 -0
- package/types/src/command/CommandButtonEntryLabel.d.ts +25 -0
- package/types/src/command/CommandButtonEntryLabel.d.ts.map +1 -0
- package/types/src/command/CommandButtonRegistry.d.ts +159 -0
- package/types/src/command/CommandButtonRegistry.d.ts.map +1 -0
- package/types/src/command/CommandButtonRegistryContext.d.ts +35 -0
- package/types/src/command/CommandButtonRegistryContext.d.ts.map +1 -0
- package/types/src/command/CommandCatalog.d.ts +155 -0
- package/types/src/command/CommandCatalog.d.ts.map +1 -0
- package/types/src/command/CommandCatalogResource.d.ts +7 -0
- package/types/src/command/CommandCatalogResource.d.ts.map +1 -0
- package/types/src/command/CommandCatalogService.d.ts +61 -0
- package/types/src/command/CommandCatalogService.d.ts.map +1 -0
- package/types/src/command/CommandChainContext.d.ts +32 -0
- package/types/src/command/CommandChainContext.d.ts.map +1 -0
- package/types/src/command/CommandFallbackContext.d.ts +30 -0
- package/types/src/command/CommandFallbackContext.d.ts.map +1 -0
- package/types/src/command/CommandFocusContext.d.ts +21 -0
- package/types/src/command/CommandFocusContext.d.ts.map +1 -0
- package/types/src/command/CommandRegistry.d.ts +164 -0
- package/types/src/command/CommandRegistry.d.ts.map +1 -0
- package/types/src/command/CommandRegistryContext.d.ts +16 -0
- package/types/src/command/CommandRegistryContext.d.ts.map +1 -0
- package/types/src/command/CommandResolver.d.ts +162 -0
- package/types/src/command/CommandResolver.d.ts.map +1 -0
- package/types/src/command/CommandScope.d.ts +343 -0
- package/types/src/command/CommandScope.d.ts.map +1 -0
- package/types/src/command/CommandScopeContext.d.ts +205 -0
- package/types/src/command/CommandScopeContext.d.ts.map +1 -0
- package/types/src/command/FocusActivation.d.ts +140 -0
- package/types/src/command/FocusActivation.d.ts.map +1 -0
- package/types/src/command/ICommand.d.ts +31 -0
- package/types/src/command/ICommand.d.ts.map +1 -0
- package/types/src/command/ICommandDefinition.d.ts +82 -0
- package/types/src/command/ICommandDefinition.d.ts.map +1 -0
- package/types/src/command/KeyBindingDispatcher.d.ts +150 -0
- package/types/src/command/KeyBindingDispatcher.d.ts.map +1 -0
- package/types/src/command/LayerActivation.d.ts +45 -0
- package/types/src/command/LayerActivation.d.ts.map +1 -0
- package/types/src/command/Types.d.ts +80 -0
- package/types/src/command/Types.d.ts.map +1 -0
- package/types/src/command/createResolvedCommand.d.ts +91 -0
- package/types/src/command/createResolvedCommand.d.ts.map +1 -0
- package/types/src/command/index.d.ts +26 -0
- package/types/src/command/index.d.ts.map +1 -0
- package/types/src/command/reduceDefinitions.d.ts +33 -0
- package/types/src/command/reduceDefinitions.d.ts.map +1 -0
- package/types/src/command/useCommands.d.ts +22 -0
- package/types/src/command/useCommands.d.ts.map +1 -0
- package/types/src/command/useContributeCommands.d.ts +18 -0
- package/types/src/command/useContributeCommands.d.ts.map +1 -0
- package/types/src/components/FocusKeyNavigation.d.ts +22 -0
- package/types/src/components/FocusKeyNavigation.d.ts.map +1 -0
- package/types/src/components/ITooltip.d.ts +38 -0
- package/types/src/components/ITooltip.d.ts.map +1 -0
- package/types/src/components/RoundedTab.d.ts +26 -0
- package/types/src/components/RoundedTab.d.ts.map +1 -0
- package/types/src/components/index.d.ts +4 -0
- package/types/src/components/index.d.ts.map +1 -0
- package/types/src/error/ErrorPanel.d.ts +14 -0
- package/types/src/error/ErrorPanel.d.ts.map +1 -0
- package/types/src/error/ReactErrorBoundary.d.ts +7 -0
- package/types/src/error/ReactErrorBoundary.d.ts.map +1 -0
- package/types/src/error/UncaughtErrorBoundary.d.ts +5 -0
- package/types/src/error/UncaughtErrorBoundary.d.ts.map +1 -0
- package/types/src/error/index.d.ts +4 -0
- package/types/src/error/index.d.ts.map +1 -0
- package/types/src/float/FloatPanel.d.ts +57 -0
- package/types/src/float/FloatPanel.d.ts.map +1 -0
- package/types/src/float/FloatPopper.d.ts +85 -0
- package/types/src/float/FloatPopper.d.ts.map +1 -0
- package/types/src/float/FloatPopup.d.ts +19 -0
- package/types/src/float/FloatPopup.d.ts.map +1 -0
- package/types/src/float/FloatProvider.d.ts +60 -0
- package/types/src/float/FloatProvider.d.ts.map +1 -0
- package/types/src/float/FloatStackContext.d.ts +25 -0
- package/types/src/float/FloatStackContext.d.ts.map +1 -0
- package/types/src/float/FloatTooltip.d.ts +22 -0
- package/types/src/float/FloatTooltip.d.ts.map +1 -0
- package/types/src/float/FloatUtils.d.ts +55 -0
- package/types/src/float/FloatUtils.d.ts.map +1 -0
- package/types/src/float/_FloatUtils.d.ts +51 -0
- package/types/src/float/_FloatUtils.d.ts.map +1 -0
- package/types/src/float/index.d.ts +9 -0
- package/types/src/float/index.d.ts.map +1 -0
- package/types/src/float/useFloatStack.d.ts +92 -0
- package/types/src/float/useFloatStack.d.ts.map +1 -0
- package/types/src/hooks/LanguageState.d.ts +15 -0
- package/types/src/hooks/LanguageState.d.ts.map +1 -0
- package/types/src/hooks/index.d.ts +19 -0
- package/types/src/hooks/index.d.ts.map +1 -0
- package/types/src/hooks/useBoundSyncExternalStore.d.ts +23 -0
- package/types/src/hooks/useBoundSyncExternalStore.d.ts.map +1 -0
- package/types/src/hooks/useCallbackRef.d.ts +11 -0
- package/types/src/hooks/useCallbackRef.d.ts.map +1 -0
- package/types/src/hooks/useDevicePixelRatio.d.ts +37 -0
- package/types/src/hooks/useDevicePixelRatio.d.ts.map +1 -0
- package/types/src/hooks/useEditMode.d.ts +66 -0
- package/types/src/hooks/useEditMode.d.ts.map +1 -0
- package/types/src/hooks/useGlobalClipboard.d.ts +7 -0
- package/types/src/hooks/useGlobalClipboard.d.ts.map +1 -0
- package/types/src/hooks/useId.d.ts +9 -0
- package/types/src/hooks/useId.d.ts.map +1 -0
- package/types/src/hooks/useImperativeElement.d.ts +3 -0
- package/types/src/hooks/useImperativeElement.d.ts.map +1 -0
- package/types/src/hooks/useLanguage.d.ts +13 -0
- package/types/src/hooks/useLanguage.d.ts.map +1 -0
- package/types/src/hooks/useMouseDownAndHoldListener.d.ts +13 -0
- package/types/src/hooks/useMouseDownAndHoldListener.d.ts.map +1 -0
- package/types/src/hooks/useNotifier.d.ts +330 -0
- package/types/src/hooks/useNotifier.d.ts.map +1 -0
- package/types/src/hooks/useOnClickOrFocusAway.d.ts +8 -0
- package/types/src/hooks/useOnClickOrFocusAway.d.ts.map +1 -0
- package/types/src/hooks/useOptionalBoundSyncExternalStore.d.ts +20 -0
- package/types/src/hooks/useOptionalBoundSyncExternalStore.d.ts.map +1 -0
- package/types/src/hooks/useOptionalSyncExternalStore.d.ts +18 -0
- package/types/src/hooks/useOptionalSyncExternalStore.d.ts.map +1 -0
- package/types/src/hooks/useSynchronizedPointerHandler.d.ts +54 -0
- package/types/src/hooks/useSynchronizedPointerHandler.d.ts.map +1 -0
- package/types/src/hooks/useTextareaCaretRect.d.ts +85 -0
- package/types/src/hooks/useTextareaCaretRect.d.ts.map +1 -0
- package/types/src/hooks/useTraceUpdate.d.ts +2 -0
- package/types/src/hooks/useTraceUpdate.d.ts.map +1 -0
- package/types/src/hooks/useTranslator.d.ts +32 -0
- package/types/src/hooks/useTranslator.d.ts.map +1 -0
- package/types/src/icons/DynamicIcon.d.ts +17 -0
- package/types/src/icons/DynamicIcon.d.ts.map +1 -0
- package/types/src/icons/DynamicIconService.d.ts +39 -0
- package/types/src/icons/DynamicIconService.d.ts.map +1 -0
- package/types/src/icons/ErrorIcon.d.ts +6 -0
- package/types/src/icons/ErrorIcon.d.ts.map +1 -0
- package/types/src/icons/Types.d.ts +81 -0
- package/types/src/icons/Types.d.ts.map +1 -0
- package/types/src/icons/WalkingIcon.d.ts +27 -0
- package/types/src/icons/WalkingIcon.d.ts.map +1 -0
- package/types/src/icons/_Utils.d.ts +3 -0
- package/types/src/icons/_Utils.d.ts.map +1 -0
- package/types/src/icons/index.d.ts +5 -0
- package/types/src/icons/index.d.ts.map +1 -0
- package/types/src/icons/packs/Base.d.ts +4 -0
- package/types/src/icons/packs/Base.d.ts.map +1 -0
- package/types/src/icons/packs/Conditional.d.ts +4 -0
- package/types/src/icons/packs/Conditional.d.ts.map +1 -0
- package/types/src/index.d.ts +18 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/loading/LoadingPanel.d.ts +31 -0
- package/types/src/loading/LoadingPanel.d.ts.map +1 -0
- package/types/src/loading/index.d.ts +2 -0
- package/types/src/loading/index.d.ts.map +1 -0
- package/types/src/persistence/InMemoryStore.d.ts +12 -0
- package/types/src/persistence/InMemoryStore.d.ts.map +1 -0
- package/types/src/persistence/LocalStorageStore.d.ts +15 -0
- package/types/src/persistence/LocalStorageStore.d.ts.map +1 -0
- package/types/src/persistence/PersistenceStateProvider.d.ts +3 -0
- package/types/src/persistence/PersistenceStateProvider.d.ts.map +1 -0
- package/types/src/persistence/Types.d.ts +95 -0
- package/types/src/persistence/Types.d.ts.map +1 -0
- package/types/src/persistence/_Context.d.ts +9 -0
- package/types/src/persistence/_Context.d.ts.map +1 -0
- package/types/src/persistence/index.d.ts +6 -0
- package/types/src/persistence/index.d.ts.map +1 -0
- package/types/src/persistence/usePersistenceState.d.ts +33 -0
- package/types/src/persistence/usePersistenceState.d.ts.map +1 -0
- package/types/src/react-resizable/Resizable.d.ts +30 -0
- package/types/src/react-resizable/Resizable.d.ts.map +1 -0
- package/types/src/react-resizable/ResizableBox.d.ts +18 -0
- package/types/src/react-resizable/ResizableBox.d.ts.map +1 -0
- package/types/src/react-resizable/index.d.ts +11 -0
- package/types/src/react-resizable/index.d.ts.map +1 -0
- package/types/src/react-resizable/propTypes.d.ts +56 -0
- package/types/src/react-resizable/propTypes.d.ts.map +1 -0
- package/types/src/react-resizable/utils.d.ts +3 -0
- package/types/src/react-resizable/utils.d.ts.map +1 -0
- package/types/src/scroll/AxisViewport.d.ts +73 -0
- package/types/src/scroll/AxisViewport.d.ts.map +1 -0
- package/types/src/scroll/IScrollPane.d.ts +63 -0
- package/types/src/scroll/IScrollPane.d.ts.map +1 -0
- package/types/src/scroll/IScrollbar.d.ts +94 -0
- package/types/src/scroll/IScrollbar.d.ts.map +1 -0
- package/types/src/scroll/NativeScrollbar.d.ts +7 -0
- package/types/src/scroll/NativeScrollbar.d.ts.map +1 -0
- package/types/src/scroll/ScrollButton.d.ts +29 -0
- package/types/src/scroll/ScrollButton.d.ts.map +1 -0
- package/types/src/scroll/ScrollPane.d.ts +4 -0
- package/types/src/scroll/ScrollPane.d.ts.map +1 -0
- package/types/src/scroll/Scrollbar.d.ts +4 -0
- package/types/src/scroll/Scrollbar.d.ts.map +1 -0
- package/types/src/scroll/TouchThumbContext.d.ts +93 -0
- package/types/src/scroll/TouchThumbContext.d.ts.map +1 -0
- package/types/src/scroll/TouchThumbHandle.d.ts +64 -0
- package/types/src/scroll/TouchThumbHandle.d.ts.map +1 -0
- package/types/src/scroll/TrackDrag.d.ts +107 -0
- package/types/src/scroll/TrackDrag.d.ts.map +1 -0
- package/types/src/scroll/Utils.d.ts +8 -0
- package/types/src/scroll/Utils.d.ts.map +1 -0
- package/types/src/scroll/Viewport.d.ts +285 -0
- package/types/src/scroll/Viewport.d.ts.map +1 -0
- package/types/src/scroll/VirtualScrollbar.d.ts +49 -0
- package/types/src/scroll/VirtualScrollbar.d.ts.map +1 -0
- package/types/src/scroll/index.d.ts +14 -0
- package/types/src/scroll/index.d.ts.map +1 -0
- package/types/src/scroll/scrollbarTheming.d.ts +27 -0
- package/types/src/scroll/scrollbarTheming.d.ts.map +1 -0
- package/types/src/scroll/useWheelScroll.d.ts +27 -0
- package/types/src/scroll/useWheelScroll.d.ts.map +1 -0
- package/types/src/scroller/Scroller.d.ts +260 -0
- package/types/src/scroller/Scroller.d.ts.map +1 -0
- package/types/src/scroller/animate.d.ts +30 -0
- package/types/src/scroller/animate.d.ts.map +1 -0
- package/types/src/scroller/index.d.ts +2 -0
- package/types/src/scroller/index.d.ts.map +1 -0
- package/types/src/singletonHook/components/SingleItemContainer.d.ts +6 -0
- package/types/src/singletonHook/components/SingleItemContainer.d.ts.map +1 -0
- package/types/src/singletonHook/components/SingletonHooksContainer.d.ts +7 -0
- package/types/src/singletonHook/components/SingletonHooksContainer.d.ts.map +1 -0
- package/types/src/singletonHook/index.d.ts +11 -0
- package/types/src/singletonHook/index.d.ts.map +1 -0
- package/types/src/singletonHook/singletonHook.d.ts +6 -0
- package/types/src/singletonHook/singletonHook.d.ts.map +1 -0
- package/types/src/singletonHook/utils/env.d.ts +4 -0
- package/types/src/singletonHook/utils/env.d.ts.map +1 -0
- package/types/src/singletonHook/utils/env.native.d.ts +1 -0
- package/types/src/singletonHook/utils/env.native.d.ts.map +1 -0
- package/types/src/singletonHook/utils/warning.d.ts +2 -0
- package/types/src/singletonHook/utils/warning.d.ts.map +1 -0
- package/types/src/splitPane/SplitPane.d.ts +91 -0
- package/types/src/splitPane/SplitPane.d.ts.map +1 -0
- package/types/src/splitPane/SplitPaneResizer.d.ts +11 -0
- package/types/src/splitPane/SplitPaneResizer.d.ts.map +1 -0
- package/types/src/splitPane/index.d.ts +3 -0
- package/types/src/splitPane/index.d.ts.map +1 -0
- package/types/src/theme/TokenTheme.d.ts +196 -0
- package/types/src/theme/TokenTheme.d.ts.map +1 -0
- package/types/src/theme/TokenThemeProvider.d.ts +97 -0
- package/types/src/theme/TokenThemeProvider.d.ts.map +1 -0
- package/types/src/theme/buildThemeCSS.d.ts +54 -0
- package/types/src/theme/buildThemeCSS.d.ts.map +1 -0
- package/types/src/theme/createThemeVars.d.ts +15 -0
- package/types/src/theme/createThemeVars.d.ts.map +1 -0
- package/types/src/theme/defaultTheme.d.ts +15 -0
- package/types/src/theme/defaultTheme.d.ts.map +1 -0
- package/types/src/theme/index.d.ts +9 -0
- package/types/src/theme/index.d.ts.map +1 -0
- package/types/src/theme/resolveTokens.d.ts +21 -0
- package/types/src/theme/resolveTokens.d.ts.map +1 -0
- package/types/src/theme/themeAttrs.d.ts +32 -0
- package/types/src/theme/themeAttrs.d.ts.map +1 -0
- package/types/src/theme/useResolvedThemeMode.d.ts +17 -0
- package/types/src/theme/useResolvedThemeMode.d.ts.map +1 -0
- package/types/src/types/Types.d.ts +71 -0
- package/types/src/types/Types.d.ts.map +1 -0
- package/types/src/types/index.d.ts +2 -0
- package/types/src/types/index.d.ts.map +1 -0
- package/types/src/utils/FullScreenPortal.d.ts +6 -0
- package/types/src/utils/FullScreenPortal.d.ts.map +1 -0
- package/types/src/utils/PinchZoom.d.ts +3 -0
- package/types/src/utils/PinchZoom.d.ts.map +1 -0
- package/types/src/utils/ReactUtils.d.ts +134 -0
- package/types/src/utils/ReactUtils.d.ts.map +1 -0
- package/types/src/utils/index.d.ts +4 -0
- package/types/src/utils/index.d.ts.map +1 -0
- package/types/src/utils/useFullScreen.d.ts +47 -0
- package/types/src/utils/useFullScreen.d.ts.map +1 -0
- package/browser/cjs/BA9O-cekHrH5qrOm.cjs +0 -6
- package/browser/esm/DTq8GPy7DLZm2D6S.mjs +0 -12
- package/node/assets/style.css +0 -1
- package/node/esm/4mSSJ5fhNdMhHCE6.mjs +0 -12
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DefaultNotifier, NotifierOptions, INotifier } from '@sheetxl/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Indicates the type of notification.
|
|
5
|
+
*/
|
|
6
|
+
export declare const NotifierType: {
|
|
7
|
+
readonly Default: "default";
|
|
8
|
+
readonly Error: "error";
|
|
9
|
+
readonly Success: "success";
|
|
10
|
+
readonly Warning: "warning";
|
|
11
|
+
readonly Info: "info";
|
|
12
|
+
};
|
|
13
|
+
export type NotifierType = typeof NotifierType[keyof typeof NotifierType];
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for non-blocking notifications.
|
|
16
|
+
*/
|
|
17
|
+
export interface EnqueueNotifierOptions extends NotifierOptions {
|
|
18
|
+
/**
|
|
19
|
+
* A hint for decorations of the message.
|
|
20
|
+
*/
|
|
21
|
+
type?: NotifierType;
|
|
22
|
+
/**
|
|
23
|
+
* Passed directly to the Snackbar component.
|
|
24
|
+
*/
|
|
25
|
+
enqueueProps?: Record<string, any>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One button in an options / input dialog. A bare `string` is shorthand for `{ label: string }` whose
|
|
29
|
+
* identity is that same string (back-compat).
|
|
30
|
+
*
|
|
31
|
+
* Identity and display are deliberately separate: `label` is what the user SEES — and may be a thunk so
|
|
32
|
+
* a language change while the dialog is open re-localizes it — while `id` is the language-free value the
|
|
33
|
+
* caller COMPARES (`results.option === 'insert'`) and never varies. Whether a button is the default
|
|
34
|
+
* (Enter) or the cancel (Esc) is NOT part of the option: that is contextual to the dialog and set by
|
|
35
|
+
* {@link ShowOptionsOptions.defaultOption} / {@link ShowOptionsOptions.cancelOption}.
|
|
36
|
+
*/
|
|
37
|
+
export interface InputOption {
|
|
38
|
+
/** Button label. A thunk resolves at render, so a mid-dialog language change re-localizes it. */
|
|
39
|
+
label: string | (() => string);
|
|
40
|
+
/**
|
|
41
|
+
* Stable, language-free identity returned as {@link InputResults.option} and compared by callers.
|
|
42
|
+
* Omit for a display-only button — then the option's own identity is returned (the `string` form, or
|
|
43
|
+
* this object by reference). NOT a thunk: an identity must not vary by language.
|
|
44
|
+
*/
|
|
45
|
+
id?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Refuses the option outright: the button renders disabled, and Enter does not activate it as the
|
|
48
|
+
* default. A thunk resolves at render, so a dialog can gate its action on live editor state.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* This is for an action that is not OFFERED — a form the user has not made valid yet. It is not
|
|
52
|
+
* {@link ShowOptionsOptions.onValidateOption}, which lets the click through and then refuses to
|
|
53
|
+
* close; use that when the reason only emerges from the attempt (a rejected password).
|
|
54
|
+
*/
|
|
55
|
+
disabled?: boolean | (() => boolean);
|
|
56
|
+
/** Per-option custom button render (replaces the former dialog-level `createOptionsButton`). */
|
|
57
|
+
renderButton?: (props: React.HTMLAttributes<HTMLButtonElement> & React.Attributes, isDefaultOption: boolean) => React.ReactNode;
|
|
58
|
+
}
|
|
59
|
+
/** A dialog option: a plain label/identity `string`, or a rich {@link InputOption}. */
|
|
60
|
+
export type OptionInput = string | InputOption;
|
|
61
|
+
/**
|
|
62
|
+
* Configuration for an options dialog.
|
|
63
|
+
*/
|
|
64
|
+
export interface ShowOptionsOptions<T = any, C = any> extends ShowWindowOptions<T, C> {
|
|
65
|
+
/**
|
|
66
|
+
* The dialog buttons: plain identity strings or rich {@link InputOption}s (mixable).
|
|
67
|
+
*/
|
|
68
|
+
options?: OptionInput[];
|
|
69
|
+
/**
|
|
70
|
+
* The title of the options panel
|
|
71
|
+
*/
|
|
72
|
+
title?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Display text information for the user to make a decision.
|
|
75
|
+
*/
|
|
76
|
+
description?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Display an icon next to the description for additional context
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* Not yet implemented
|
|
82
|
+
*/
|
|
83
|
+
icon?: React.ReactNode | string;
|
|
84
|
+
/**
|
|
85
|
+
* The option that is the default (Enter key), matched against the {@link options} by identity
|
|
86
|
+
* (a `string` matches an option's id/string form, an {@link InputOption} matches by reference).
|
|
87
|
+
* @defaultValue The first option
|
|
88
|
+
*/
|
|
89
|
+
defaultOption?: OptionInput;
|
|
90
|
+
/**
|
|
91
|
+
* The cancel option (Esc key), matched against the {@link options} by identity. Gets special styling.
|
|
92
|
+
* @defaultValue 'Cancel'
|
|
93
|
+
*/
|
|
94
|
+
cancelOption?: OptionInput;
|
|
95
|
+
/**
|
|
96
|
+
* Call when an option is selected. `option` is the selected option's IDENTITY (its `id` if provided,
|
|
97
|
+
* else the `string` form, else the {@link InputOption} object).
|
|
98
|
+
* @remarks
|
|
99
|
+
* It is possible that the option can be both a cancel and a default option.
|
|
100
|
+
*/
|
|
101
|
+
onOption?: (option: OptionInput, isCancel: boolean, isDefault: boolean) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Call when an option is selected. If false is returned, the dialog will not close. INotifier is not
|
|
104
|
+
* provided but can be supplied via the textFieldProps helperText property. `option` is the selected
|
|
105
|
+
* option's identity (see {@link onOption}).
|
|
106
|
+
*/
|
|
107
|
+
onValidateOption?: (option?: OptionInput) => boolean | Promise<boolean>;
|
|
108
|
+
}
|
|
109
|
+
export interface FocusWindowOptions extends FocusOptions {
|
|
110
|
+
/**
|
|
111
|
+
* Allows for a specific component to be selected.
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* If a string is provided this will be used as a querySelector to find the initial focusable component.
|
|
115
|
+
*/
|
|
116
|
+
selection?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface ShowWindowOptions<T = any, C = any> {
|
|
119
|
+
/**
|
|
120
|
+
* A value the window can use to display.
|
|
121
|
+
*/
|
|
122
|
+
initialValue?: T;
|
|
123
|
+
context?: () => C;
|
|
124
|
+
/**
|
|
125
|
+
* Query selector for the element to focus on show.
|
|
126
|
+
*/
|
|
127
|
+
autoFocus?: boolean | string | FocusWindowOptions;
|
|
128
|
+
/**
|
|
129
|
+
* Allow for tracking of key down events.
|
|
130
|
+
*
|
|
131
|
+
* @param e
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
onKeyDown?: (e: React.KeyboardEvent) => void;
|
|
135
|
+
/**
|
|
136
|
+
* If true show a backdrop.
|
|
137
|
+
*
|
|
138
|
+
* @remarks
|
|
139
|
+
* Our movable menu achieves modality without a background by listens to global clicks (and focus)
|
|
140
|
+
* @defaultValue false
|
|
141
|
+
*/
|
|
142
|
+
isModal?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* If true the window will not be automatically destroyed when closed.
|
|
145
|
+
*/
|
|
146
|
+
disableAutoDestroy?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Mount the window hidden (do not reveal it) so a later real open is an instant reuse. Implies
|
|
149
|
+
* {@link disableAutoDestroy} (a prewarmed window must be kept alive). Use at idle to move the
|
|
150
|
+
* heavy first-mount cost off the user's open. A no-op if an instance already exists.
|
|
151
|
+
* @defaultValue false
|
|
152
|
+
*/
|
|
153
|
+
prewarm?: boolean;
|
|
154
|
+
}
|
|
155
|
+
export interface InputValidationResults {
|
|
156
|
+
valid: boolean;
|
|
157
|
+
message?: string;
|
|
158
|
+
}
|
|
159
|
+
export interface InputResults {
|
|
160
|
+
input: string;
|
|
161
|
+
/** The selected option's identity (its `id` if provided, else the `string`, else the {@link InputOption}). */
|
|
162
|
+
option: OptionInput;
|
|
163
|
+
}
|
|
164
|
+
export interface ShowInputOptions<T = string, C = any> extends ShowOptionsOptions<T, C> {
|
|
165
|
+
/**
|
|
166
|
+
* Css style for input
|
|
167
|
+
*/
|
|
168
|
+
propsInput?: React.HTMLAttributes<HTMLInputElement | HTMLTextAreaElement>;
|
|
169
|
+
inputLabel?: string;
|
|
170
|
+
inputType?: 'text' | 'password' | 'email' | 'number' | 'search' | 'tel' | 'url';
|
|
171
|
+
inputPlaceHolder?: string;
|
|
172
|
+
onInput?: (input?: T, option?: OptionInput) => void | Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Validates the current input. Returning `{ valid: false }` keeps the dialog **open** and shows
|
|
175
|
+
* `message` under the field.
|
|
176
|
+
*
|
|
177
|
+
* @remarks
|
|
178
|
+
* Called in two situations, told apart by `option`:
|
|
179
|
+
* - **`option` is `undefined`** — the user typed. Fires on every keystroke, so this path must stay
|
|
180
|
+
* cheap (a format/duplicate-name check).
|
|
181
|
+
* - **`option` is set** — the user submitted. This is where expensive work belongs (a network
|
|
182
|
+
* round-trip, a password derivation); it is awaited, and the activated button shows a spinner
|
|
183
|
+
* while it runs.
|
|
184
|
+
*
|
|
185
|
+
* An expensive validator MUST therefore branch on `option` — otherwise it runs once per keystroke.
|
|
186
|
+
*/
|
|
187
|
+
onValidateInput?: (input?: T, option?: OptionInput) => InputValidationResults | Promise<InputValidationResults>;
|
|
188
|
+
}
|
|
189
|
+
export interface ShowBusyOptions {
|
|
190
|
+
icon?: React.ReactNode;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The handle returned by {@link IReactNotifier.showBusy}.
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* It is callable — calling it dismisses the busy indicator (the historical `hideBusy()` contract) —
|
|
197
|
+
* and also carries methods to update the indicator while it is showing. This keeps every existing
|
|
198
|
+
* `const hideBusy = await showBusy(...); hideBusy();` call working unchanged.
|
|
199
|
+
*/
|
|
200
|
+
export interface BusyHandle {
|
|
201
|
+
/**
|
|
202
|
+
* Dismiss the busy indicator.
|
|
203
|
+
*/
|
|
204
|
+
(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Update the indicator to a determinate state. When `total` is known the indicator shows a
|
|
207
|
+
* percentage / progress bar; passing `total` as `undefined` (or `completed` as `undefined`)
|
|
208
|
+
* returns it to the indeterminate (spinner) state.
|
|
209
|
+
*
|
|
210
|
+
* @param completed The cumulative work done so far.
|
|
211
|
+
* @param total The total work, in the same units as `completed`.
|
|
212
|
+
*/
|
|
213
|
+
setProgress(completed?: number, total?: number): void;
|
|
214
|
+
/**
|
|
215
|
+
* Update the message shown beside the indicator.
|
|
216
|
+
*/
|
|
217
|
+
setMessage(message: string | React.ReactNode): void;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Builds a {@link BusyHandle} from a dismiss function (and optional updaters). Used to wrap the
|
|
221
|
+
* plain `hideBusy` callbacks that providers produce, and to supply inert no-op handles where no
|
|
222
|
+
* provider is present.
|
|
223
|
+
*/
|
|
224
|
+
export declare function createBusyHandle(dismiss?: () => void, setProgress?: (completed?: number, total?: number) => void, setMessage?: (message: string | React.ReactNode) => void): BusyHandle;
|
|
225
|
+
/**
|
|
226
|
+
* An inert {@link BusyHandle} whose methods do nothing. Returned when no busy provider is available.
|
|
227
|
+
*/
|
|
228
|
+
export declare function createNoopBusyHandle(): BusyHandle;
|
|
229
|
+
/**
|
|
230
|
+
* Interface that provides popups for the user.
|
|
231
|
+
*/
|
|
232
|
+
export interface IReactNotifier extends INotifier {
|
|
233
|
+
/**
|
|
234
|
+
* Useful when informing the user of something but are not expecting a response.
|
|
235
|
+
*/
|
|
236
|
+
showMessage: (message: string | React.ReactNode, options?: EnqueueNotifierOptions) => void;
|
|
237
|
+
/**
|
|
238
|
+
* Should return error object exception.
|
|
239
|
+
*
|
|
240
|
+
* @param error The error to show
|
|
241
|
+
*/
|
|
242
|
+
showError: (error: Error | string) => void;
|
|
243
|
+
/**
|
|
244
|
+
* Useful when performing a long running operation and you want to inform the user.
|
|
245
|
+
*
|
|
246
|
+
* Returns a {@link BusyHandle}: call it to dismiss the indicator, or use its `setProgress` /
|
|
247
|
+
* `setMessage` methods to update it while it shows. If multiple calls are made the consumer should
|
|
248
|
+
* continue to indicate blocked until all handles have been dismissed.
|
|
249
|
+
*/
|
|
250
|
+
showBusy: (message: string | React.ReactNode, options?: ShowBusyOptions) => (Promise<BusyHandle>) | BusyHandle;
|
|
251
|
+
/**
|
|
252
|
+
* Show a dialog for a given type.
|
|
253
|
+
*
|
|
254
|
+
* @param type
|
|
255
|
+
* @param options
|
|
256
|
+
*/
|
|
257
|
+
showWindow: (type: string, options?: ShowWindowOptions) => Promise<HTMLElement>;
|
|
258
|
+
/**
|
|
259
|
+
* Provide a user with a list of options to choose from.
|
|
260
|
+
* @param options
|
|
261
|
+
*/
|
|
262
|
+
showOptions: (options: ShowOptionsOptions) => Promise<OptionInput>;
|
|
263
|
+
/**
|
|
264
|
+
* Provider a user with a way to enter a text input.
|
|
265
|
+
* @param options
|
|
266
|
+
*/
|
|
267
|
+
showInput: (options: ShowInputOptions) => Promise<InputResults>;
|
|
268
|
+
}
|
|
269
|
+
export declare class DefaultReactNotifier extends DefaultNotifier implements IReactNotifier {
|
|
270
|
+
/** @inheritdoc IReactNotifier.setOverrides */
|
|
271
|
+
setOverrides(overrides: Partial<IReactNotifier> | null): void;
|
|
272
|
+
/** @inheritdoc IReactNotifier.getDelegate */
|
|
273
|
+
getDelegate(): Partial<IReactNotifier> | null;
|
|
274
|
+
/** @inheritdoc IReactNotifier.showMessage */
|
|
275
|
+
showMessage(message: string | React.ReactNode, options?: EnqueueNotifierOptions): void;
|
|
276
|
+
/** @inheritdoc IReactNotifier.showBusy */
|
|
277
|
+
showBusy(message: string | React.ReactNode, options?: ShowBusyOptions): (Promise<BusyHandle>) | BusyHandle;
|
|
278
|
+
/** @inheritdoc IReactNotifier.showWindow */
|
|
279
|
+
showWindow(type: string, options?: ShowWindowOptions): Promise<HTMLElement>;
|
|
280
|
+
/** @inheritdoc IReactNotifier.showError */
|
|
281
|
+
showError(error: any): void;
|
|
282
|
+
/** @inheritdoc IReactNotifier.showOptions */
|
|
283
|
+
showOptions(options: ShowOptionsOptions): Promise<OptionInput>;
|
|
284
|
+
/** @inheritdoc IReactNotifier.showInput */
|
|
285
|
+
showInput(options: ShowInputOptions): Promise<InputResults>;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Context provider for notifications. Allows custom notification implementations
|
|
289
|
+
* to be provided to components within the provider tree.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```tsx
|
|
293
|
+
* const customNotifier = {
|
|
294
|
+
* showMessage: (message) => toast(message),
|
|
295
|
+
* showError: (error) => toast.error(error),
|
|
296
|
+
* // ... other methods
|
|
297
|
+
* };
|
|
298
|
+
*
|
|
299
|
+
* <ReactNotifierProvider notifier={customNotifier}>
|
|
300
|
+
* <App />
|
|
301
|
+
* </ReactNotifierProvider>
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
export interface ReactNotifierProviderProps {
|
|
305
|
+
children: React.ReactNode;
|
|
306
|
+
notifier: IReactNotifier;
|
|
307
|
+
}
|
|
308
|
+
export declare const ReactNotifierProvider: React.FC<ReactNotifierProviderProps>;
|
|
309
|
+
/**
|
|
310
|
+
* Hook to access the notification system. Uses the notifier from the nearest
|
|
311
|
+
* NotifierProvider, or falls back to the default ReactNotifier singleton if
|
|
312
|
+
* no provider is found.
|
|
313
|
+
*
|
|
314
|
+
* @returns The notification interface
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```tsx
|
|
318
|
+
* function MyComponent() {
|
|
319
|
+
* const notifier = useNotifier();
|
|
320
|
+
*
|
|
321
|
+
* const handleClick = () => {
|
|
322
|
+
* notifier.showMessage('Hello World!', { type: NotifierType.Success });
|
|
323
|
+
* };
|
|
324
|
+
*
|
|
325
|
+
* return <button onClick={handleClick}>Show INotifier</button>;
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
export declare const useNotifier: () => IReactNotifier;
|
|
330
|
+
//# sourceMapp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,cAAc,CAAC,GAAG,IAAI;IAI7C,6CAA6C;IAC7C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,IAAI;IAgBtF,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,UAAU;IAQ1G,4CAA4C;IAC5C,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ3E,2CAA2C;IAC3C,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAS3B,6CAA6C;IAC7C,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ9D,2CAA2C;IAC3C,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAO5D;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAetE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,QAAO,cAE9B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface ClickOrFocusAwayOptions {
|
|
3
|
+
mouseEvents?: boolean;
|
|
4
|
+
focusEvents?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type ClickOrFocusAwayListener = (event: globalThis.MouseEvent | globalThis.KeyboardEvent) => void;
|
|
7
|
+
export declare function useOnClickOrFocusAway(ref: React.RefObject<any>, listenerArg: ClickOrFocusAwayListener, options?: ClickOrFocusAwayOptions): void;
|
|
8
|
+
//# sourceMappingURL=useOnClickOrFocusAway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnClickOrFocusAway.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useOnClickOrFocusAway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC,aAAa,KAAK,IAAI,CAAC;AAGzG,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,OAAO,CAAC,EAAE,uBAAuB,QA2BxI"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"useOptionalBoundSyncExternalStore.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useOptionalBoundSyncExternalStore.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iCAAiC,CAAC,CAAC,SAAS;IAAE,SAAS,CAAC,aAAa,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;CAAE,EAAE,CAAC,EACjH,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3B,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAC3B,CAAC,GAAG,IAAI,CAOV"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"useOptionalSyncExternalStore.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useOptionalSyncExternalStore.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAC5C,SAAS,EAAE,CAAC,CAAC,aAAa,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EACzE,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GACxC,CAAC,GAAG,IAAI,CAOV"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"useSynchronizedPointerHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useSynchronizedPointerHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AACD,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO;IAChE;;OAEG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,KAAK,OAAO,GAAG,IAAI,CAAC;IAC7F;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChI;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAExH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;AAE/E;;;;;;EAME;AACF,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,qBAAqB,GAAG,mBAAmB,CA8KjG"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"useTextareaCaretRect.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextareaCaretRect.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,MAAM,IAAI,OAAO,CAAC;CACnB;AASD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG;IAClC,6FAA6F;IAC7F,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,sDAAsD;IACtD,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,qGAAqG;IACrG,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,KAAG,SAIH,CAAC;AAmCF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,mBAAmB,GAAG,IAAI,GAAG,SAAS,EAChD,QAAQ,MAAM,EACd,SAAS,WAAW,EACpB,UAAS,MAAU,KAClB,SAuCF,CAAC;AAEF,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC,wGAAwG;IACxG,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1D;;;;;;OAMG;IACH,WAAW,CACT,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,EAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAChC;QAAE,qBAAqB,IAAI,SAAS,CAAA;KAAE,CAAC;CAC3C;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,KAC/C,uBA6BF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTraceUpdate.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTraceUpdate.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,GAAE,OAAY,QAgB/D"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslator.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTranslator.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,IAAI,WAAW,CAc3C"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicIcon.d.ts","sourceRoot":"","sources":["../../../../src/icons/DynamicIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EACL,KAAK,YAAY,EAAiB,KAAK,WAAW,EACnD,MAAM,SAAS,CAAC;AAMjB,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACzE,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,MAAM,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,WAAW,oCAAgB,gBAAgB,uBAmKtD,CAAC"}
|