@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,343 @@
|
|
|
1
|
+
import { RemoveListener } from '@sheetxl/utils';
|
|
2
|
+
import { ICommandDefinition } from './ICommandDefinition';
|
|
3
|
+
import { CommandRegistry } from './CommandRegistry';
|
|
4
|
+
import { ActivationTracker } from './ActivationTracker';
|
|
5
|
+
import { ResolvedCommand, ExecuteHook, CommandMiddleware } from './createResolvedCommand';
|
|
6
|
+
/** Coarse change notification — fired (root-anchored) on any contribution/active change. */
|
|
7
|
+
export interface CommandScopeListener {
|
|
8
|
+
onChange?(): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A tracked contribution **session** on a scope (see {@link CommandScope.contribution}). Every
|
|
12
|
+
* {@link updateCommand} through it records the key; {@link remove} tears down **exactly** those keys
|
|
13
|
+
* in one call — so a contributor's teardown is a single `contribution.remove()` instead of an
|
|
14
|
+
* easy-to-miss, per-key `removeCommand` list (which gets long for large contributors). Re-`updateCommand`
|
|
15
|
+
* for a key already tracked is idempotent.
|
|
16
|
+
*/
|
|
17
|
+
export interface CommandContribution {
|
|
18
|
+
updateCommand<STATE = any, CONTEXT = any, ARGS = void>(commandKey: string, partial: Omit<ICommandDefinition<STATE, CONTEXT, ARGS>, 'key'>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Register dispatch {@link CommandMiddleware} on the owning scope — the cross-cutting wrapper for
|
|
21
|
+
* the callbacks this contribution authors (e.g. a sheet's transactional batch/busy wrapper, so each
|
|
22
|
+
* command callback stays pure). Tracked like commands: undone by {@link remove}. This is the
|
|
23
|
+
* authoring facet's equivalent of {@link CommandScope.use}, so a contributor never needs the raw scope.
|
|
24
|
+
*/
|
|
25
|
+
use(middleware: CommandMiddleware<any, any, any>): void;
|
|
26
|
+
/**
|
|
27
|
+
* All command keys reachable from the owning scope (its chain → root) whose merged definition
|
|
28
|
+
* carries `tag`. The authoring counterpart of {@link CommandScope.collectKeysByTag} — it lets a
|
|
29
|
+
* contributor apply a **cross-cutting rule by tag** without hand-maintaining a parallel key list:
|
|
30
|
+
* e.g. a sheet's protection reducer does `for (const key of getKeysByTag('mutator')) updateCommand(key,
|
|
31
|
+
* { disabledReasons })`, so the tag authored in the catalog is the single source of truth (the
|
|
32
|
+
* resolved `disabled()` then accumulates the reasons — no new resolve-time machinery needed).
|
|
33
|
+
*/
|
|
34
|
+
getKeysByTag(tag: string): string[];
|
|
35
|
+
/** Remove every command + middleware this contribution touched. Idempotent. */
|
|
36
|
+
remove(): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A node in the command **scope** tree — the pure registry (the new-model counterpart of the
|
|
40
|
+
* existing `CommandGroup`, but holding *definitions* instead of instances). A scope holds the
|
|
41
|
+
* **within-scope merged** {@link ICommandDefinition} for each command key; it knows nothing
|
|
42
|
+
* about "active"/focus — *which* leaf to resolve from is the consumer's `anchor` (see
|
|
43
|
+
* `CommandResolver`).
|
|
44
|
+
*
|
|
45
|
+
* {@link resolve} walks the chain from a given `anchor` leaf → root, reducing each scope's
|
|
46
|
+
* contribution least→most specific into a derived {@link ResolvedCommand}. Two merge levels:
|
|
47
|
+
* - **within a scope** — successive {@link updateCommand} calls merge (here);
|
|
48
|
+
* - **across scopes** — the anchor-chain reduction (in {@link resolve}).
|
|
49
|
+
*
|
|
50
|
+
* Also provides change notification ({@link addListener} / {@link invalidate}) and per-key
|
|
51
|
+
* execute observation ({@link addExecuteListener}). It does NOT dispatch — the resolved
|
|
52
|
+
* command's `execute()` does (firing the per-key observers).
|
|
53
|
+
*/
|
|
54
|
+
export declare class CommandScope {
|
|
55
|
+
readonly key: string;
|
|
56
|
+
/**
|
|
57
|
+
* The scope's **name** — its key into the flat {@link CommandRegistry} (design/COMMAND-DESIGN.md
|
|
58
|
+
* §"Named scopes"). Defaults to {@link key}; a distinct name lets two instances with different keys
|
|
59
|
+
* (a double-buffer's two `workbook`s, a sheet's per-pane scopes) share one registry entry. At every
|
|
60
|
+
* node of {@link resolve}/{@link collectKeys}, the registry entry for this `name` is folded in as the
|
|
61
|
+
* least-specific (prototype) layer beneath the node's own defs.
|
|
62
|
+
*/
|
|
63
|
+
readonly name: string;
|
|
64
|
+
protected _parent: CommandScope | null;
|
|
65
|
+
protected _children: Map<string, CommandScope>;
|
|
66
|
+
/** This scope's own within-scope merged definitions, by command key. */
|
|
67
|
+
protected _defs: Map<string, ICommandDefinition<any, any, void>>;
|
|
68
|
+
/** Dispatch middleware authored on THIS scope (wraps callbacks this scope contributes). */
|
|
69
|
+
protected _middleware: CommandMiddleware<any, any, any>[];
|
|
70
|
+
/** Teardown for a contribution bound at {@link createChild} (its `setup`'s returned disposer). */
|
|
71
|
+
protected _setupDisposer?: RemoveListener;
|
|
72
|
+
/** Root reference (every node points at the root). */
|
|
73
|
+
protected readonly _root: CommandScope;
|
|
74
|
+
protected _version: number;
|
|
75
|
+
protected _resolveCache: WeakMap<CommandScope, WeakMap<CommandScope, Map<string, ResolvedCommand<any, any, any> | undefined>>>;
|
|
76
|
+
protected _resolveCacheVersion: number;
|
|
77
|
+
/** root-only: coarse change listeners (fired on any version bump). */
|
|
78
|
+
protected _listeners: Set<CommandScopeListener>;
|
|
79
|
+
/** root-only: per-command-key execute observers (ripple/close, middleware). `any` ARGS so
|
|
80
|
+
* observers for differently-parameterized commands coexist in one registry map. */
|
|
81
|
+
protected _executeListeners: Map<string, Set<ExecuteHook<any, any, any>>>;
|
|
82
|
+
/** root-only: the flat named registry consulted as each node's prototype (undefined ⇒ no registry). */
|
|
83
|
+
protected _registry?: CommandRegistry;
|
|
84
|
+
/** root-only: cache for {@link resolveStatic} (the not-in-context by-name fallback), keyed by version. */
|
|
85
|
+
protected _resolveStaticCache: Map<string, ResolvedCommand<any, any, any> | undefined>;
|
|
86
|
+
protected _resolveStaticCacheVersion: number;
|
|
87
|
+
/** root-only: unsubscribe from the registry's change notifications (see the ctor). */
|
|
88
|
+
protected _registryUnsub?: RemoveListener;
|
|
89
|
+
/**
|
|
90
|
+
* root-only: the **`element → region source` index** (pull-model focus discovery). A focus region — a
|
|
91
|
+
* pane's `Stage`, an editor leaf — records *its own* focusable element here via {@link attachElement}, and
|
|
92
|
+
* every consumer's {@link FocusActivation} reads it on the focus walk. Living on the **tree** (rather than a
|
|
93
|
+
* parallel side-registry) is deliberate: the map is **shared across resolvers** (studio + script toolbar
|
|
94
|
+
* both resolve focus against the same regions), so it sits *below* the per-container resolvers — at the tree
|
|
95
|
+
* level (design/COMMAND-DESIGN.md §"Fold the region bridge into the tree"). Only **leaf** regions are
|
|
96
|
+
* recorded; the rest of the chain is the {@link getParent} walk. A plain `Map` (not weak): the recording
|
|
97
|
+
* site removes its own entry on unmount, so nothing is retained.
|
|
98
|
+
*/
|
|
99
|
+
protected _regions?: Map<Element, AnchorSource>;
|
|
100
|
+
/**
|
|
101
|
+
* This scope's own attached DOM element(s) (recorded by {@link attachElement} or
|
|
102
|
+
* {@link attachBounds}, removed by their removers) — the instance-side record {@link contains}
|
|
103
|
+
* reads for **origin containment** (the root {@link _regions} index is the focus-discovery side of
|
|
104
|
+
* an `attachElement`). Plural: a region may span several containers — its main element plus e.g. a
|
|
105
|
+
* **portaled** float/popup container that is logically inside the region but DOM-outside it.
|
|
106
|
+
*/
|
|
107
|
+
protected _elements: Element[];
|
|
108
|
+
constructor(key: string, parent?: CommandScope | null, opts?: {
|
|
109
|
+
name?: string;
|
|
110
|
+
registry?: CommandRegistry;
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* (Re)establish this scope's registry subscription. Idempotent. The owning provider's mount
|
|
114
|
+
* effect calls this so a scope {@link dispose}d on an effect *cleanup* (React StrictMode's
|
|
115
|
+
* mount→unmount→remount) comes back to life instead of staying **permanently deaf to
|
|
116
|
+
* registry changes** — the same resurrect contract as `CommandResolver.connect`. Without it,
|
|
117
|
+
* anything that reaches consumers *only* through the registry listener (a plugin registering
|
|
118
|
+
* statics after mount, a language-pack switch re-deriving translated chrome) silently stops
|
|
119
|
+
* propagating after the StrictMode cycle. Bumps on re-subscribe: the registry may have
|
|
120
|
+
* changed while deaf.
|
|
121
|
+
*/
|
|
122
|
+
connect(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Create (and register) a child scope. The bare form deliberately does **not** bump the version: a
|
|
125
|
+
* fresh child has no definitions, so it changes no resolved command (resolution only sees it once it
|
|
126
|
+
* gets {@link updateCommand} — which bumps — or becomes the anchor). This keeps the endorsed pattern
|
|
127
|
+
* of creating a region's scope during render (`useMemo(() => parent.createChild(key))`) free of a
|
|
128
|
+
* notify-during-render — which would re-enter subscribed consumers (the "setState while rendering"
|
|
129
|
+
* warning). Teardown ({@link dispose}) *does* bump, since it drops contributions.
|
|
130
|
+
*
|
|
131
|
+
* **`contributor` — bind a contribution to the child's lifetime** (so a scope and its commands are
|
|
132
|
+
* created and torn down as one, instead of a separate `useEffect`). It runs immediately with a fresh
|
|
133
|
+
* {@link CommandContribution} for the new child (plus any forwarded `args`), and returns *only its own
|
|
134
|
+
* external-subscription disposer* (e.g. a model listener) — it does **not** manage command removal.
|
|
135
|
+
* `dispose()` does the rest automatically: invoke that disposer **and** clear the child's `_defs`
|
|
136
|
+
* (so the contributed commands go without a per-key list). Declarative call site:
|
|
137
|
+
* `parent.createChild('undo', contributeUndoCommands, { manager, notifier })`.
|
|
138
|
+
*
|
|
139
|
+
* NOTE: the contributor **contributes synchronously**, and contributing bumps (notifies). So — like
|
|
140
|
+
* any `updateCommand` — call this where a contribution-time notify is fine: at **mount** (in `useMemo`,
|
|
141
|
+
* no subscribers yet), NOT mid-render with live subscribers.
|
|
142
|
+
*/
|
|
143
|
+
createChild<A extends any[] = []>(keyOrOpts: string | {
|
|
144
|
+
key: string;
|
|
145
|
+
name?: string;
|
|
146
|
+
}, contributor?: (contribution: CommandContribution, ...args: A) => RemoveListener | void, ...args: A): CommandScope;
|
|
147
|
+
getParent(): CommandScope | null;
|
|
148
|
+
getRoot(): CommandScope;
|
|
149
|
+
getChild(key: string): CommandScope | undefined;
|
|
150
|
+
/** The flat named registry bound to this tree (from the root), or `undefined` if none. */
|
|
151
|
+
getRegistry(): CommandRegistry | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Record `element → source` in the tree's {@link _regions region index} — a **focus region** naming its
|
|
154
|
+
* own focusable element so a consumer's {@link FocusActivation} can anchor there on focus. `source`
|
|
155
|
+
* defaults to **this** scope (a fixed leaf — the formula-bar editor, the script pane); pass a live
|
|
156
|
+
* {@link AnchorSource} (a pane's `LayerActivation`, or a getter) for a **dynamic leaf** whose current
|
|
157
|
+
* value tracks a moving stack top. The entry lands on the **root** (shared by every consumer), so this can
|
|
158
|
+
* be called on any node. Returns a remover the recording site calls on unmount — identity-guarded, so a
|
|
159
|
+
* re-record of the same element by another owner is never clobbered by a stale cleanup.
|
|
160
|
+
*/
|
|
161
|
+
attachElement(element: Element, source?: AnchorSource): RemoveListener;
|
|
162
|
+
/**
|
|
163
|
+
* Bound this scope's **region** to `element` for {@link contains origin containment} — WITHOUT
|
|
164
|
+
* naming a focus region. The containment half of {@link attachElement}, alone.
|
|
165
|
+
*
|
|
166
|
+
* Use this when a scope's commands need a UI region but the scope is not a focus *leaf*: the
|
|
167
|
+
* `sheet` scope owns the grid's commands, yet focus inside the grid must keep anchoring at the
|
|
168
|
+
* pane's z-stack (a deeper region), not here. Recording it in the root index would make this scope
|
|
169
|
+
* a candidate anchor and change what a focus lands on; bounding only does not.
|
|
170
|
+
*
|
|
171
|
+
* Leaving a scope unbounded is a **decision, not a default**: an element-less scope is unrestricted
|
|
172
|
+
* (see {@link contains}), so its shortcuts fire from any origin under the dispatch seam — correct
|
|
173
|
+
* for app-tier commands (`ctrl+S` saves while the caret is in a task-pane field), wrong for
|
|
174
|
+
* anything that acts on a region's own UI.
|
|
175
|
+
*
|
|
176
|
+
* **A region is a set of containers, not one subtree.** Call this more than once when the region's UI
|
|
177
|
+
* is not contiguous in the DOM — a host that renders workbook chrome (a formula bar, a status bar, a
|
|
178
|
+
* toolbar with a search box) outside the workbook element adds each piece, and a keystroke born there
|
|
179
|
+
* still reaches the region's commands. A host declares those from where the chrome renders, via
|
|
180
|
+
* `useCommandElement`; the scope's own owner does not have to know about them. Same seam for a
|
|
181
|
+
* **portaled** float — DOM-outside the region, logically inside it.
|
|
182
|
+
*
|
|
183
|
+
* Returns a remover the recording site calls on unmount.
|
|
184
|
+
*/
|
|
185
|
+
attachBounds(element: Element): RemoveListener;
|
|
186
|
+
/**
|
|
187
|
+
* The region source recorded **exactly at** `element` (single-element lookup on the root index), or
|
|
188
|
+
* `undefined`. The bounded DOM walk-up is the caller's ({@link FocusActivation.findSource}, region-bounded;
|
|
189
|
+
* or {@link findScope}, unbounded) — this is the per-element primitive both build on.
|
|
190
|
+
*/
|
|
191
|
+
getRegion(element: Element): AnchorSource | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* **Origin containment — the scope decides** (design/COMMAND-DESIGN.md "Core law", consequence 3):
|
|
194
|
+
* whether `node` counts as *within this scope's region*, i.e. whether a keystroke born at `node`
|
|
195
|
+
* may dispatch this scope's contributions. The default policy:
|
|
196
|
+
*
|
|
197
|
+
* - this scope has {@link attachElement attached} element(s) → `true` iff **any** of them
|
|
198
|
+
* DOM-contains `node`. (Plural is the **portal** seam: a float/popup portaled to `body` is
|
|
199
|
+
* DOM-outside the region but logically inside it — its owner attaches the portal container as
|
|
200
|
+
* an additional element and keys born there qualify.)
|
|
201
|
+
* - no elements of its own → **delegate to the parent** — the nearest region-owning ancestor
|
|
202
|
+
* decides (a pane's z-chain layers all inherit the pane `Stage` via the chain base, so the whole
|
|
203
|
+
* z-stack shares one region, and a key a layer deliberately lets propagate — the editor's commit
|
|
204
|
+
* Enter — still qualifies, because it was born inside that Stage).
|
|
205
|
+
* - nothing up the whole chain → `true` (an element-less chain — a sheet/workbook/app-level scope
|
|
206
|
+
* — is *unrestricted*: its commands may fire from any origin under the dispatch seam).
|
|
207
|
+
*
|
|
208
|
+
* It is a **method on the scope** — not an inline DOM check — precisely so a region owner can make
|
|
209
|
+
* a richer decision than raw containment when the DOM and the logical UI disagree (portals today;
|
|
210
|
+
* anything else tomorrow).
|
|
211
|
+
*/
|
|
212
|
+
contains(node: Node): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* The nearest region **scope** at or above `element`: walk `parentElement` to the first
|
|
215
|
+
* {@link attachElement attached} element and **stop** (leaf-finding, unbounded — a live source is resolved
|
|
216
|
+
* to its current scope). This is *leaf-finding*, NOT the resolution walk (design/COMMAND-DESIGN.md
|
|
217
|
+
* §Guardrail): it names the anchor; resolution is the separate `anchor → root` command-parent walk.
|
|
218
|
+
* `undefined` if no attached element is on the ancestor chain.
|
|
219
|
+
*/
|
|
220
|
+
findScope(element: Element | null): CommandScope | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Re-attach this scope under a new parent (or detach with `null`). The primitive the **z-ordered
|
|
223
|
+
* layer chain** is built from: a layer registry re-parents each layer's scope into a stack ordered
|
|
224
|
+
* by z (higher z → deeper → wins the cascade), so the unchanged {@link resolve} (which walks
|
|
225
|
+
* `_parent` from the anchor) resolves **top-of-stack first**. This is what lets a *stacked* layer
|
|
226
|
+
* override a command by **stacking**, not by focus — and lets a client add a command-bearing layer
|
|
227
|
+
* with no core special-casing.
|
|
228
|
+
*
|
|
229
|
+
* Reorders **within the same root** (the layer stack shares one registry root); `_root` is fixed at
|
|
230
|
+
* construction, so cross-root moves are rejected. Rejects a cycle. Bumps the root so resolvers
|
|
231
|
+
* re-resolve. No-op if `parent` is already the parent.
|
|
232
|
+
*/
|
|
233
|
+
setParent(parent: CommandScope | null): void;
|
|
234
|
+
/**
|
|
235
|
+
* Tear this scope down when the feature/region that owns it unmounts: recursively dispose
|
|
236
|
+
* children, drop this scope's definitions, detach it from its parent (so it stops
|
|
237
|
+
* contributing to resolution), and bump the root version so resolvers re-resolve. The
|
|
238
|
+
* `_parent` pointer is left intact so a stale `anchor` still pointing here resolves *up* the
|
|
239
|
+
* (now-detached) chain rather than throwing — turning a torn-down scope into its parent is
|
|
240
|
+
* the eventual destruction-fallback (design/COMMAND-DESIGN.md, open Q5). Idempotent.
|
|
241
|
+
*/
|
|
242
|
+
dispose(): void;
|
|
243
|
+
/**
|
|
244
|
+
* Contribute/merge a partial definition for `commandKey` into THIS scope (within-scope
|
|
245
|
+
* merge). `undefined` fields are ignored (don't clobber); `null` is kept (an explicit
|
|
246
|
+
* clear). The cross-scope cascade happens later, in {@link resolve}.
|
|
247
|
+
*/
|
|
248
|
+
updateCommand<STATE = any, CONTEXT = any, ARGS = void>(commandKey: string, partial: Omit<ICommandDefinition<STATE, CONTEXT, ARGS>, 'key'>): void;
|
|
249
|
+
/** Remove this scope's contribution for `commandKey`. */
|
|
250
|
+
removeCommand(commandKey: string): void;
|
|
251
|
+
/**
|
|
252
|
+
* Open a tracked {@link CommandContribution} on THIS scope: `updateCommand` through the handle
|
|
253
|
+
* records each key, and `remove()` removes exactly those — so a contributor (esp. a large one)
|
|
254
|
+
* cleans up with a single call rather than a per-key `removeCommand` list that's easy to fall out
|
|
255
|
+
* of sync. The handle owns *its* keys only; it doesn't touch other contributions to this scope.
|
|
256
|
+
*/
|
|
257
|
+
contribution(): CommandContribution;
|
|
258
|
+
/**
|
|
259
|
+
* Register dispatch {@link CommandMiddleware} on THIS scope: it auto-wraps every callback
|
|
260
|
+
* this scope **authors** (so contributor callbacks stay pure — transactional wrapping
|
|
261
|
+
* becomes one `use(tx)` instead of wrapping each command by hand). **Not inherited** — a
|
|
262
|
+
* command's middleware is that of the scope whose callback wins resolution, nothing up the
|
|
263
|
+
* chain. First-registered is outermost. Returns a remover.
|
|
264
|
+
*/
|
|
265
|
+
use(middleware: CommandMiddleware<any, any, any>): RemoveListener;
|
|
266
|
+
/** This scope's own middleware (authoring order). */
|
|
267
|
+
getMiddleware(): readonly CommandMiddleware<any, any, any>[];
|
|
268
|
+
/** This scope's own (merged) contribution for a key, or `undefined`. */
|
|
269
|
+
getDefinition(commandKey: string): ICommandDefinition | undefined;
|
|
270
|
+
/**
|
|
271
|
+
* All command keys contributed along the chain from `anchor` → root (deduped, order
|
|
272
|
+
* unspecified). The keystroke dispatcher uses this to enumerate the commands that could
|
|
273
|
+
* match an event at the current anchor (then resolves each to read its shortcut).
|
|
274
|
+
*/
|
|
275
|
+
collectKeys(anchor?: CommandScope, root?: CommandScope): string[];
|
|
276
|
+
/**
|
|
277
|
+
* Like {@link collectKeys}, but only keys whose contribution **somewhere along the chain** carries
|
|
278
|
+
* `tag` (tags accumulate across scopes, so a match at any scope on the chain counts). Enables
|
|
279
|
+
* cross-cutting, tag-driven rules — e.g. "disable every `mutator` command when the sheet is
|
|
280
|
+
* protected" — without a hand-maintained parallel key list. Order unspecified; deduped.
|
|
281
|
+
*/
|
|
282
|
+
collectKeysByTag(tag: string, anchor?: CommandScope): string[];
|
|
283
|
+
getVersion(): number;
|
|
284
|
+
/**
|
|
285
|
+
* Trigger a re-resolution **without** changing any contribution — bump version + notify.
|
|
286
|
+
* A contributor calls this when the model/context changed (so dynamic values should
|
|
287
|
+
* re-evaluate) instead of enumerating `updateCommand`s; containers re-resolve on their own
|
|
288
|
+
* cadence (debounce). NOT a substitute for {@link updateCommand} (which sets values).
|
|
289
|
+
*/
|
|
290
|
+
invalidate(): void;
|
|
291
|
+
protected _bump(): void;
|
|
292
|
+
/** Subscribe to coarse changes (re-resolve on fire). Root-anchored. */
|
|
293
|
+
addListener(listener: CommandScopeListener): RemoveListener;
|
|
294
|
+
/**
|
|
295
|
+
* Observe executions of a specific command key. Fires for ALL dispatch paths (button,
|
|
296
|
+
* keystroke, programmatic) because the resolved command's `execute()` fires it — the
|
|
297
|
+
* ripple/close + middleware hook. Root-anchored, so it survives command re-derivation.
|
|
298
|
+
*/
|
|
299
|
+
addExecuteListener(commandKey: string, hook: ExecuteHook<any, any, any>): RemoveListener;
|
|
300
|
+
/**
|
|
301
|
+
* Resolve a command by gathering its contributions along the chain from `anchor` → root,
|
|
302
|
+
* reducing them least→most specific, and deriving a {@link ResolvedCommand}. `anchor` is the
|
|
303
|
+
* **resolution leaf**; it defaults to the registry **root**. A consumer (`useCommands({
|
|
304
|
+
* anchor })`) sets it — normally to the focus-driven active scope (an {@link ActiveScope}
|
|
305
|
+
* the consumer reads), or to a context menu's snapshot. Returns `undefined` when no **dynamic**
|
|
306
|
+
* contribution for the key exists on the chain — a registry (static) catalog entry alone does not
|
|
307
|
+
* resolve (see the "static only if dynamic first" note below). Memoized by version, per `anchor`.
|
|
308
|
+
*
|
|
309
|
+
* `origin` (keystroke dispatch only — buttons/display omit it) applies **origin containment** per
|
|
310
|
+
* contribution: a node whose {@link contains} rejects the event's origin contributes nothing to
|
|
311
|
+
* this resolve, so the cascade falls through to the permitted portion (or to `undefined` when
|
|
312
|
+
* everything is omitted). See the gather-loop comment below.
|
|
313
|
+
*/
|
|
314
|
+
resolve<STATE = any, CONTEXT = any, ARGS = void>(commandKey: string, anchor?: CommandScope, injected?: readonly ICommandDefinition[], root?: CommandScope, origin?: Node | null): ResolvedCommand<STATE, CONTEXT, ARGS> | undefined;
|
|
315
|
+
/**
|
|
316
|
+
* Resolve a command **purely from the static registry** — the *not-in-context* primitive a consumer's
|
|
317
|
+
* fallback composes, deliberately bypassing the "static only if a dynamic exists" rule that governs the
|
|
318
|
+
* context {@link resolve}. Use it to show a command whose scope isn't currently contributing (a toolbar's
|
|
319
|
+
* disabled button; a `table` command with no table) — the result is **disabled** if the static has no
|
|
320
|
+
* `callback`, or **executable** if it carries a global one. `prefer` is the consumer's priority list of
|
|
321
|
+
* names ({@link CommandRegistry.findByKey} searches it first, then all names).
|
|
322
|
+
*
|
|
323
|
+
* **Never call this from dispatch.** The keyboard dispatcher resolves only via {@link resolve}, so an
|
|
324
|
+
* inert static never binds a shortcut (an idle editor's F4 stays free for `redo`). The *policy* — whether
|
|
325
|
+
* to fall back at all, and the `prefer` list — is entirely the consumer's; the core never decides it.
|
|
326
|
+
* Returns `undefined` if the key is registered under no name. Memoized by version.
|
|
327
|
+
*/
|
|
328
|
+
resolveStatic<STATE = any, CONTEXT = any, ARGS = void>(commandKey: string, prefer?: readonly string[]): ResolvedCommand<STATE, CONTEXT, ARGS> | undefined;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* An anchor **source** registered against a DOM element (via {@link CommandScope.attachElement}) — three
|
|
332
|
+
* forms, all resolved to a leaf scope:
|
|
333
|
+
* - a fixed {@link CommandScope} — an ordinary region (the formula-bar editor names its own element → its scope);
|
|
334
|
+
* - an {@link ActivationTracker} (e.g. a pane's `LayerActivation`) — the **dynamic leaf**
|
|
335
|
+
* (design/COMMAND-DESIGN.md §"Layered resolver", mechanism 2): its `getAnchor()` is read *live*, so focusing
|
|
336
|
+
* a pane's `Stage` anchors at the **current** top of that pane's z-chain (the non-focusable-layer case);
|
|
337
|
+
* - a **getter** (`() => CommandScope | null`) — the general escape hatch.
|
|
338
|
+
*/
|
|
339
|
+
export type AnchorSource = CommandScope | ActivationTracker | (() => CommandScope | null);
|
|
340
|
+
/** Evaluate an {@link AnchorSource} to its current scope: a scope is returned as-is; a tracker's `getAnchor()`
|
|
341
|
+
* and a getter are read **live** (so a layer stack's moving top is always current). */
|
|
342
|
+
export declare function resolveAnchorSource(source: AnchorSource | null): CommandScope | null;
|
|
343
|
+
//# sourceMappingURL=CommandScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandScope.d.ts","sourceRoot":"","sources":["../../../../src/command/CommandScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,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iB,GAAG,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,CAAC;AAE1F;wFACwF;AACxF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,YAAY,GAAG,IAAI,CAKpF"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { RemoveListener } from '@sheetxl/utils';
|
|
3
|
+
import { CommandScope, CommandContribution, AnchorSource } from './CommandScope';
|
|
4
|
+
import { CommandMiddleware } from './createResolvedCommand';
|
|
5
|
+
/**
|
|
6
|
+
* Provides the registry {@link CommandScope} to descendants — the app/workbook root, or a
|
|
7
|
+
* nested **feature** scope. A container's *resolution* (its `anchor` + cadence) lives in a
|
|
8
|
+
* `CommandResolver` provided by `CommandAnchorProvider`, not here.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CommandScopeContext: import('react').Context<CommandScope | null>;
|
|
11
|
+
export declare function useCommandScope(): CommandScope | null;
|
|
12
|
+
/**
|
|
13
|
+
* The write surface a **static** seeder needs — just `updateCommand`. Satisfied by BOTH a scope's
|
|
14
|
+
* {@link CommandContribution} and the registry's `CommandRegistryContribution`, so one seeder writes into a
|
|
15
|
+
* live scope's defaults OR a registry name interchangeably. (Static is permanent: no `remove`/`use`/disposer.)
|
|
16
|
+
*/
|
|
17
|
+
export type CommandCatalogTarget = Pick<CommandContribution, 'updateCommand'>;
|
|
18
|
+
/**
|
|
19
|
+
* A **static** command contributor — seeds instance-independent presentation (icon/label/shortcut/tags) into
|
|
20
|
+
* the catalog. No model, no disposer (permanent); the function reference is its stacking identity.
|
|
21
|
+
*/
|
|
22
|
+
export type StaticCommandContributor = (target: CommandCatalogTarget) => void;
|
|
23
|
+
/**
|
|
24
|
+
* A **dynamic** command contributor — attaches model-closured behavior (callback/state/dynamic
|
|
25
|
+
* `disabledReasons`, and any `use()` middleware) to a live scope for its lifetime. `data` is the single
|
|
26
|
+
* per-instance context bundle (the model **and** its services together — the model-vs-services split was
|
|
27
|
+
* ambiguous, so it's one thing). Returns a disposer for external subscriptions (or nothing).
|
|
28
|
+
*/
|
|
29
|
+
export type DynamicCommandContributor<T = any> = (contribution: CommandContribution, data: T) => RemoveListener | void;
|
|
30
|
+
/**
|
|
31
|
+
* A feature's (or plugin's) command contribution — implements **either** half or **both**: `static` seeds the
|
|
32
|
+
* catalog (by name), `dynamic` runs on live scope instances. This is the single shape a plugin registers to
|
|
33
|
+
* inject into a named scope (design/COMMAND-DESIGN.md §"Named scopes").
|
|
34
|
+
*/
|
|
35
|
+
export interface CommandContributor<T = any> {
|
|
36
|
+
static?: StaticCommandContributor;
|
|
37
|
+
dynamic?: DynamicCommandContributor<T>;
|
|
38
|
+
}
|
|
39
|
+
/** Props the generic provider passes to each registered dynamic contribution component. */
|
|
40
|
+
export interface CommandContributionComponentProps<T = any> {
|
|
41
|
+
/** The live named scope instance to contribute onto (via `scope.contribution()`). */
|
|
42
|
+
scope: CommandScope;
|
|
43
|
+
/** The scope's `data` bundle (the spec-determined shape). */
|
|
44
|
+
data: T;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A **plugin's** dynamic contribution — a React **component** rendered by the generic provider **at** the named
|
|
48
|
+
* scope, so it inherits the React context there (free to use hooks like `useTaskPane()`) and contributes via
|
|
49
|
+
* `props.scope.contribution()`. Renders `null`. Distinct from the scope's own {@link DynamicCommandContributor}
|
|
50
|
+
* (a pure function): a plugin one may need hooks, so it is a component. Registered via
|
|
51
|
+
* `CommandRegistry.registerDynamic(name, …)` and mounted by {@link CommandScopeProvider}.
|
|
52
|
+
*/
|
|
53
|
+
export type CommandContributionComponent<T = any> = ComponentType<CommandContributionComponentProps<T>>;
|
|
54
|
+
/**
|
|
55
|
+
* The **declarative** form accepted by {@link CommandScopeProvider} in place of a pre-built scope: "create a
|
|
56
|
+
* `scopeName` child of the container's ambient scope, run the `contributor`'s `dynamic` half on it for its
|
|
57
|
+
* lifetime, and provide it." DRYs the create-child + contribute + provide boilerplate. The scope tree mirrors
|
|
58
|
+
* the container tree because the child is created off {@link useCommandScope}.
|
|
59
|
+
*/
|
|
60
|
+
export interface CommandScopeSpec<T = any> {
|
|
61
|
+
/** The child's tree key (or `{ key, name }` when the registry name differs from the key). */
|
|
62
|
+
scopeName: string | {
|
|
63
|
+
key: string;
|
|
64
|
+
name?: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The feature's contributor; its `dynamic` half runs on the created scope (its `static` half is seeded
|
|
68
|
+
* elsewhere). Optional: a scope can exist purely as a **named region** that OTHERS contribute into (the
|
|
69
|
+
* script editor's, contributed by its toolbar and its editor commands) — the create/dispose/region
|
|
70
|
+
* plumbing is the same either way.
|
|
71
|
+
*/
|
|
72
|
+
contributor?: CommandContributor<T>;
|
|
73
|
+
/** The single per-instance context bundle passed to `dynamic`. **Memoize it** — a new object re-runs it. */
|
|
74
|
+
data?: T;
|
|
75
|
+
}
|
|
76
|
+
export interface CommandScopeProviderProps {
|
|
77
|
+
/**
|
|
78
|
+
* The command contribution — a {@link CommandScopeSpec} `{ scopeName, contributor, data }`. The provider
|
|
79
|
+
* `createChild`s it off the ambient scope, runs the contributor's `dynamic` half for the scope's lifetime,
|
|
80
|
+
* **joins the ambient pane {@link CommandChain}** (if any) at {@link CommandScopeProviderProps.order order},
|
|
81
|
+
* and disposes it on unmount. **This is the one way a feature, plugin, or grid layer contributes commands**
|
|
82
|
+
* (design/COMMAND-DESIGN.md §"How a layer contributes commands") — one component, no layer-specific API.
|
|
83
|
+
* `null` ⇒ a pass-through (degrade on a bare grid). Mutually exclusive with {@link scope}.
|
|
84
|
+
*/
|
|
85
|
+
spec?: CommandScopeSpec | null;
|
|
86
|
+
/**
|
|
87
|
+
* An **already-built** scope to provide, instead of creating one from a {@link spec}. Not created and
|
|
88
|
+
* not disposed here — its owner keeps the lifecycle; this only provides it to descendants and, with an
|
|
89
|
+
* {@link elementRef}, adds that element to its region.
|
|
90
|
+
*
|
|
91
|
+
* This is how chrome declares that it belongs to a scope it does not own: a host rendering a status
|
|
92
|
+
* bar, a formula bar or a custom toolbar OUTSIDE the workbook element wraps it in
|
|
93
|
+
* `<CommandScopeProvider scope={workbookScope} elementRef={…}>`, and both halves follow — its buttons
|
|
94
|
+
* resolve workbook commands, and a keystroke born there reaches them too (see
|
|
95
|
+
* {@link CommandScope.attachBounds}: a region is a set of containers, not one subtree). Provide with
|
|
96
|
+
* no `elementRef` for resolution alone.
|
|
97
|
+
*/
|
|
98
|
+
scope?: CommandScope | null;
|
|
99
|
+
/**
|
|
100
|
+
* Dispatch {@link CommandMiddleware} to register on the effective scope (via {@link CommandScope.use}) for
|
|
101
|
+
* this provider's lifetime — so a feature provider can declare its `tx` wrapper without reaching for the
|
|
102
|
+
* scope handle. Wraps the callbacks **this scope authors** (not inherited). Pass a **stable** reference
|
|
103
|
+
* (memoize/const) — a new array each render re-registers.
|
|
104
|
+
*/
|
|
105
|
+
use?: CommandMiddleware | readonly CommandMiddleware[];
|
|
106
|
+
/**
|
|
107
|
+
* The z **order** to join the ambient {@link CommandChain} at (a layer's `useLayer().zIndex`). Used only for
|
|
108
|
+
* a **declarative** spec **inside a pane's chain** (mechanism 1, design/COMMAND-DESIGN.md §"Layered
|
|
109
|
+
* resolver"); ignored otherwise. Falls back to the ambient {@link useCommandOrder} (default `0`). This is
|
|
110
|
+
* the one grid-aware value a layer passes — everything else about being a "layer" is ambient.
|
|
111
|
+
*/
|
|
112
|
+
order?: number;
|
|
113
|
+
/**
|
|
114
|
+
* The created scope's **element** — the DOM node this scope's commands belong to. Attaching one bounds
|
|
115
|
+
* the scope's region for **origin containment**: its shortcuts then only dispatch for keystrokes born
|
|
116
|
+
* inside the element (the `sheet` scope names the sheet element, so `Delete` → `clearContents` cannot
|
|
117
|
+
* fire from a studio task pane). Leaving it off makes the scope *unrestricted*, which is only right for
|
|
118
|
+
* genuinely app-global commands (`ctrl+S`). See {@link CommandScope.attachBounds}.
|
|
119
|
+
*
|
|
120
|
+
* Pair with {@link region} when the element is also a **focus leaf**. Bounds alone is the default
|
|
121
|
+
* because most scopes are not: the `sheet` scope owns the grid's commands, but focus inside the grid
|
|
122
|
+
* anchors at the pane's z-stack, one level deeper.
|
|
123
|
+
*
|
|
124
|
+
* Typed with a **readonly** `current` (covariant), so any element ref fits — a `useRef<HTMLDivElement>`, or
|
|
125
|
+
* a typed imperative handle (`RefObject<IFormulaBarElement>`) — with no cast at the call site.
|
|
126
|
+
*/
|
|
127
|
+
elementRef?: {
|
|
128
|
+
readonly current: Element | null;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Also make {@link elementRef} a **focus region**: record it in the tree's region index
|
|
132
|
+
* ({@link CommandScope.attachElement}) so a consumer's `FocusActivation` anchors here when focus lands
|
|
133
|
+
* inside it. `true` ⇒ the created scope is the anchor (a formula bar, a script editor — fixed leaves);
|
|
134
|
+
* an {@link AnchorSource} ⇒ a **live** leaf whose current value tracks something that moves (a pane
|
|
135
|
+
* passes its `LayerActivation`, whose anchor is the z-stack top).
|
|
136
|
+
*
|
|
137
|
+
* Ignored without an `elementRef` — "the element only names the leaf"
|
|
138
|
+
* (design/COMMAND-DESIGN.md §Guardrail).
|
|
139
|
+
*/
|
|
140
|
+
region?: boolean | AnchorSource;
|
|
141
|
+
/**
|
|
142
|
+
* Hand the **created scope** back *up* to this provider's own parent (populated on mount, cleared on
|
|
143
|
+
* unmount). The output counterpart of {@link elementRef}: it lets a single component **provide a scope AND
|
|
144
|
+
* hold its handle** — e.g. to `resolve`/`execute` a command directly on it — without the provide-above /
|
|
145
|
+
* consume-below split (a parent can't `useCommandScope()` its own child's scope). `null` while there's no
|
|
146
|
+
* created scope (a `null` spec, or a bare grid with no ambient parent).
|
|
147
|
+
*/
|
|
148
|
+
scopeRef?: {
|
|
149
|
+
current: CommandScope | null;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* The subtree the scope covers. As a **function** it is handed the ref for {@link elementRef} — attach
|
|
153
|
+
* it to whichever node is the scope's element and the provider binds it, with no ref declaration at
|
|
154
|
+
* the call site:
|
|
155
|
+
*
|
|
156
|
+
* ```tsx
|
|
157
|
+
* <CommandScopeProvider scope={workbookScope}>
|
|
158
|
+
* {(ref) => <div ref={ref} className="status-bar">…</div>}
|
|
159
|
+
* </CommandScopeProvider>
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* An explicit {@link elementRef} wins when both are given (the element already has an owner) — the
|
|
163
|
+
* function still receives it, so the same child code works either way.
|
|
164
|
+
*/
|
|
165
|
+
children?: ReactNode | ((elementRef: React.RefObject<any>) => ReactNode);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Attach `ref.current` once it exists — the element may be null for a frame (the provider mounts above
|
|
169
|
+
* the element it names), so retry on the next frame until it lands or the effect is torn down.
|
|
170
|
+
*/
|
|
171
|
+
export declare function attachWhenReady(ref: {
|
|
172
|
+
readonly current: Element | null;
|
|
173
|
+
}, attach: (el: Element) => RemoveListener): RemoveListener;
|
|
174
|
+
/**
|
|
175
|
+
* **A scope and its element** — the one declarative way a feature, plugin, grid layer, or host renders a
|
|
176
|
+
* subtree that belongs to a command scope. Two forms, same shape:
|
|
177
|
+
*
|
|
178
|
+
* - {@link CommandScopeProviderProps.spec spec} — CREATE a child of the ambient scope: `createChild`, run
|
|
179
|
+
* the contributor for its lifetime, **join the ambient pane {@link CommandChain}** at
|
|
180
|
+
* {@link CommandScopeProviderProps.order order}, dispose on unmount. How a feature contributes commands.
|
|
181
|
+
* - {@link CommandScopeProviderProps.scope scope} — PROVIDE an already-built one, untouched lifecycle. How
|
|
182
|
+
* chrome that renders outside a scope's element still belongs to it.
|
|
183
|
+
*
|
|
184
|
+
* Either way {@link CommandScopeProviderProps.elementRef elementRef} names the subtree's element, bounding
|
|
185
|
+
* the scope's region (and, with {@link CommandScopeProviderProps.region region}, naming a focus leaf).
|
|
186
|
+
* Optionally registers dispatch middleware via {@link CommandScopeProviderProps.use}.
|
|
187
|
+
*/
|
|
188
|
+
export declare function CommandScopeProvider({ spec, scope, use, order, elementRef, region, scopeRef, children }: CommandScopeProviderProps): ReactNode;
|
|
189
|
+
/**
|
|
190
|
+
* Name a scope's **element** — the primitive {@link CommandScopeProvider} is built on, for a component
|
|
191
|
+
* that already owns both. Bounds the scope's region ({@link CommandScope.attachBounds}) so its commands
|
|
192
|
+
* only dispatch for keystrokes born inside the element; `region` additionally records it in the tree's
|
|
193
|
+
* region index as a focus leaf (`true` ⇒ the scope is the anchor, an {@link AnchorSource} ⇒ a live leaf).
|
|
194
|
+
*
|
|
195
|
+
* Prefer the provider — `<CommandScopeProvider scope={…} elementRef={…}>` — which also puts the scope in
|
|
196
|
+
* context for the subtree; reach for the hook when the element and the scope are already in hand and
|
|
197
|
+
* there is nothing to wrap.
|
|
198
|
+
*
|
|
199
|
+
* Re-attaches when `scope`, `elementRef` or `region` changes and detaches on unmount. A `null` scope is a
|
|
200
|
+
* no-op, so a chromeless host degrades quietly.
|
|
201
|
+
*/
|
|
202
|
+
export declare function useCommandElement(scope: CommandScope | null | undefined, elementRef: {
|
|
203
|
+
readonly current: Element | null;
|
|
204
|
+
}, region?: boolean | AnchorSource): void;
|
|
205
|
+
//# sourceMappingURL=CommandScopeContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandScopeContext.d.ts","sourceRoot":"","sources":["../../../../src/command/CommandScopeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAAE,KAAK,SAAS,EACnC,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,8CAA2C,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