@sheetxl/utils-react 0.7.21 → 0.7.23
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/{BA9O-cekHrH5qrOm.cjs → Bhq-qomDuX-3Zv9l.cjs} +1 -1
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/{DTq8GPy7DLZm2D6S.mjs → Czq3S5X04g1B_iOl.mjs} +1 -1
- package/browser/esm/index.mjs +640 -630
- package/node/esm/{4mSSJ5fhNdMhHCE6.mjs → 1il9ZLP9RKvPohl7.mjs} +1 -1
- package/node/esm/index.mjs +598 -588
- package/package.json +2 -2
- package/types/index.d.ts +198 -124
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheetxl/utils-react",
|
|
3
3
|
"description": "Utils React - Utilities for React capabilities needed for all SheetXL components.",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.23",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"react"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@sheetxl/utils": "^0.7.
|
|
43
|
+
"@sheetxl/utils": "^0.7.23",
|
|
44
44
|
"clsx": "^2.1.1",
|
|
45
45
|
"detect-it": "^4.0.1",
|
|
46
46
|
"react-merge-refs": "^3.0.2",
|
package/types/index.d.ts
CHANGED
|
@@ -30,45 +30,60 @@ export declare interface ClickOrFocusAwayOptions {
|
|
|
30
30
|
focusEvents?: boolean;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* A default implementation of ICommand
|
|
35
|
+
*/
|
|
33
36
|
export declare class Command<STATE extends any = void, CONTEXT extends any = void> implements ICommand<STATE, CONTEXT> {
|
|
34
37
|
protected _key: string;
|
|
35
|
-
protected _target:
|
|
36
|
-
protected _label: DynamicValue<string, CONTEXT>;
|
|
37
|
-
protected _scopedLabels?: Record<string, DynamicValue<string, CONTEXT>>;
|
|
38
|
-
protected _description?: DynamicValue<string, CONTEXT>;
|
|
39
|
-
protected _icon: DynamicValue<React.ReactElement | string, CONTEXT>;
|
|
40
|
-
protected _tags: DynamicValue<string[], CONTEXT>;
|
|
41
|
-
protected _shortcut: DynamicValue<IKeyStroke | IKeyStroke[] | null, CONTEXT>;
|
|
42
|
-
protected _disabled: DynamicValue<boolean, CONTEXT>;
|
|
38
|
+
protected _target: ICommand.ITarget | (() => ICommand.ITarget);
|
|
39
|
+
protected _label: ICommand.DynamicValue<string, CONTEXT>;
|
|
40
|
+
protected _scopedLabels?: Record<string, ICommand.DynamicValue<string, CONTEXT>>;
|
|
41
|
+
protected _description?: ICommand.DynamicValue<string, CONTEXT>;
|
|
42
|
+
protected _icon: ICommand.DynamicValue<React.ReactElement | string, CONTEXT>;
|
|
43
|
+
protected _tags: ICommand.DynamicValue<string[], CONTEXT>;
|
|
44
|
+
protected _shortcut: ICommand.DynamicValue<IKeyStroke | IKeyStroke[] | null, CONTEXT>;
|
|
45
|
+
protected _disabled: ICommand.DynamicValue<boolean, CONTEXT>;
|
|
43
46
|
protected _state: STATE;
|
|
44
47
|
protected _context: CONTEXT;
|
|
45
|
-
protected _callback:
|
|
46
|
-
protected _listenersProperties: Set<
|
|
47
|
-
protected _listenersExecute: Set<
|
|
48
|
-
constructor(key: string, target:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
protected _callback: ICommand.Callback<STATE>;
|
|
49
|
+
protected _listenersProperties: Set<ICommand.PropertyListener<STATE, CONTEXT>>;
|
|
50
|
+
protected _listenersExecute: Set<ICommand.Hook<STATE, CONTEXT>>;
|
|
51
|
+
constructor(key: string, target: ICommand.ITarget | (() => ICommand.ITarget) | null, props?: ICommand.Properties<STATE, CONTEXT>, callback?: ICommand.Callback<STATE>);
|
|
52
|
+
/** @inheritdoc ICommand.getKey */
|
|
53
|
+
getKey(): string;
|
|
54
|
+
protected _resolve<T = any>(value: ICommand.DynamicValue<T, CONTEXT>, scopedContext?: CONTEXT | (() => CONTEXT)): T;
|
|
55
|
+
/** @inheritdoc ICommand.getTarget */
|
|
56
|
+
getTarget(): ICommand.ITarget;
|
|
57
|
+
/** @inheritdoc ICommand.getLabel */
|
|
58
|
+
getLabel(scope?: string, scopedContext?: CONTEXT): string;
|
|
59
|
+
/** @inheritdoc ICommand.getDescription */
|
|
60
|
+
getDescription(context?: ICommand.DynamicContext<CONTEXT>): string;
|
|
61
|
+
/** @inheritdoc ICommand.getTags */
|
|
62
|
+
getTags(context?: ICommand.DynamicContext<CONTEXT>): string[];
|
|
63
|
+
/** @inheritdoc ICommand.getIcon */
|
|
64
|
+
getIcon(context?: ICommand.DynamicContext<CONTEXT>): React.ReactElement | string;
|
|
65
|
+
/** @inheritdoc ICommand.getShortcut */
|
|
66
|
+
getShortcut(): IKeyStroke | readonly IKeyStroke[];
|
|
67
|
+
/** @inheritdoc ICommand.disabled */
|
|
57
68
|
disabled(): boolean;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
/** @inheritdoc ICommand.getState */
|
|
70
|
+
getState(): STATE;
|
|
71
|
+
/** @inheritdoc ICommand.getContext */
|
|
72
|
+
getContext(): CONTEXT;
|
|
73
|
+
/** @inheritdoc ICommand.execute */
|
|
74
|
+
execute(args: STATE, hook?: ICommand.Hook<STATE, CONTEXT>): Promise<boolean>;
|
|
75
|
+
/** @inheritdoc ICommand.addPropertyListener */
|
|
76
|
+
addPropertyListener(listener: ICommand.PropertyListener<STATE, CONTEXT>, fireOnListen?: boolean): RemoveListener;
|
|
77
|
+
/** @inheritdoc ICommand.addExecuteListener */
|
|
78
|
+
addExecuteListener(listener: ICommand.Hook<STATE, CONTEXT>): RemoveListener;
|
|
66
79
|
protected _notifyExecute(args: STATE): void;
|
|
67
80
|
protected _notifyError(error: any, args: STATE): void;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
/** @inheritdoc ICommand.updateCallback */
|
|
82
|
+
updateCallback(callback: ICommand.Callback<STATE>): ICommand<STATE, CONTEXT>;
|
|
83
|
+
/** @inheritdoc ICommand.update */
|
|
84
|
+
update(props: ICommand.Properties<STATE, CONTEXT>): ICommand<STATE, CONTEXT>;
|
|
85
|
+
protected _notifyPropertyChange(props: ICommand.Properties<STATE, CONTEXT>): void;
|
|
86
|
+
protected _applyProps(props: ICommand.Properties<STATE, CONTEXT>): ICommand.Properties<STATE, CONTEXT>;
|
|
72
87
|
}
|
|
73
88
|
|
|
74
89
|
export declare interface CommandButtonOptions<STATE = any, CONTEXT = any> extends Omit<React.HTMLAttributes<HTMLElement>, "color" | "label"> {
|
|
@@ -77,7 +92,7 @@ export declare interface CommandButtonOptions<STATE = any, CONTEXT = any> extend
|
|
|
77
92
|
* Useful when knowing the specific button that executed a command is required.
|
|
78
93
|
* (For example when closing menus or restoring focus)
|
|
79
94
|
*/
|
|
80
|
-
commandHook?:
|
|
95
|
+
commandHook?: ICommand.Hook<STATE, CONTEXT>;
|
|
81
96
|
/**
|
|
82
97
|
* Optional string to enable the command label to be configured based on the scope of how it is being used.
|
|
83
98
|
*/
|
|
@@ -152,7 +167,7 @@ export declare type CommandButtonType = typeof CommandButtonType[keyof typeof Co
|
|
|
152
167
|
* Default implementation of `ICommands.IGroup`.
|
|
153
168
|
*/
|
|
154
169
|
export declare class CommandGroup implements ICommands.IGroup {
|
|
155
|
-
protected _target:
|
|
170
|
+
protected _target: ICommand.ITarget | (() => ICommand.ITarget);
|
|
156
171
|
protected _groupKey: string;
|
|
157
172
|
protected _root: CommandGroup | null;
|
|
158
173
|
protected _parent: CommandGroup | null;
|
|
@@ -165,13 +180,13 @@ export declare class CommandGroup implements ICommands.IGroup {
|
|
|
165
180
|
protected _listeners: Set<ICommands.IListener>;
|
|
166
181
|
protected _listenersByKey: Map<string, Set<ICommands.IListener> | null>;
|
|
167
182
|
protected _unListenersByCommand: Map<ICommand, RemoveListener>;
|
|
168
|
-
protected _commandsPropertyListener:
|
|
169
|
-
constructor(target:
|
|
183
|
+
protected _commandsPropertyListener: ICommand.PropertyListener<any, any>;
|
|
184
|
+
constructor(target: ICommand.ITarget | (() => ICommand.ITarget), groupKey?: string);
|
|
170
185
|
private _getCommand;
|
|
171
186
|
/** {@inheritDoc ICommands.IGroup.getCommand} */
|
|
172
187
|
getCommand(key: string, _ignoreActive?: boolean): ICommand<any, any>;
|
|
173
188
|
/** {@inheritDoc ICommands.IGroup.createChildGroup} */
|
|
174
|
-
createChildGroup(target:
|
|
189
|
+
createChildGroup(target: ICommand.ITarget | (() => ICommand.ITarget), when: string, replace?: boolean): ICommands.IGroup;
|
|
175
190
|
/** {@inheritDoc ICommands.IGroup.getKey} */
|
|
176
191
|
getKey(): string;
|
|
177
192
|
/** {@inheritDoc ICommands.IGroup.getGroup} */
|
|
@@ -363,8 +378,6 @@ export declare interface DevicePixelRatioOptions {
|
|
|
363
378
|
maxDpr?: number;
|
|
364
379
|
}
|
|
365
380
|
|
|
366
|
-
declare type DynamicContext<CONTEXT> = CONTEXT | (() => CONTEXT);
|
|
367
|
-
|
|
368
381
|
export declare const DynamicIcon: default_2.MemoExoticComponent<(props: DynamicIconProps) => JSX.Element>;
|
|
369
382
|
|
|
370
383
|
export declare interface DynamicIconProps extends default_2.HTMLAttributes<HTMLElement> {
|
|
@@ -381,8 +394,6 @@ export declare interface DynamicIconProps extends default_2.HTMLAttributes<HTMLE
|
|
|
381
394
|
propsSource?: unknown;
|
|
382
395
|
}
|
|
383
396
|
|
|
384
|
-
declare type DynamicValue<T, CONTEXT> = T | ((context?: DynamicContext<CONTEXT>) => T);
|
|
385
|
-
|
|
386
397
|
export declare type EmojiGlyph = BaseGlyph & {
|
|
387
398
|
emoji: string | {
|
|
388
399
|
text: string;
|
|
@@ -533,59 +544,164 @@ export declare interface ICommand<STATE extends any = any, CONTEXT extends any =
|
|
|
533
544
|
* @remarks
|
|
534
545
|
* Immutable
|
|
535
546
|
*/
|
|
536
|
-
|
|
537
|
-
|
|
547
|
+
getKey(): string;
|
|
548
|
+
/**
|
|
549
|
+
* The target that the command operates on.
|
|
550
|
+
*/
|
|
551
|
+
getTarget(): ICommand.ITarget;
|
|
552
|
+
/**
|
|
553
|
+
* Indicates if the command is disabled.
|
|
554
|
+
*/
|
|
538
555
|
disabled(): boolean;
|
|
539
|
-
execute(args?: STATE, hook?: ICommandHook<STATE, CONTEXT>): Promise<boolean>;
|
|
540
556
|
/**
|
|
541
|
-
*
|
|
557
|
+
* Called to execute the command.
|
|
558
|
+
*
|
|
559
|
+
* @param args Optional arguments for the command.
|
|
560
|
+
*/
|
|
561
|
+
execute(args?: STATE, hook?: ICommand.Hook<STATE, CONTEXT>): Promise<boolean>;
|
|
562
|
+
/**
|
|
563
|
+
* Represents the model state.
|
|
564
|
+
*/
|
|
565
|
+
getState(): STATE;
|
|
566
|
+
/**
|
|
567
|
+
* The current view context associated with the command.
|
|
542
568
|
*/
|
|
543
|
-
|
|
544
|
-
context(): CONTEXT;
|
|
569
|
+
getContext(): CONTEXT;
|
|
545
570
|
/**
|
|
546
571
|
* Additional information that may be needed to render or make decisions about setting state.
|
|
547
572
|
*/
|
|
548
|
-
update(props:
|
|
549
|
-
updateCallback(callback: ICommandCallback<STATE>): ICommand<STATE, CONTEXT>;
|
|
573
|
+
update(props: ICommand.Properties<STATE, CONTEXT>): ICommand<STATE, CONTEXT>;
|
|
550
574
|
/**
|
|
551
|
-
*
|
|
575
|
+
* Update the callback function for the command.
|
|
576
|
+
* @param callback
|
|
552
577
|
*/
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
578
|
+
updateCallback(callback: ICommand.Callback<STATE>): ICommand<STATE, CONTEXT>;
|
|
579
|
+
/**
|
|
580
|
+
* Add a listener that will be called when command properties have changed
|
|
581
|
+
*/
|
|
582
|
+
addPropertyListener(listener: ICommand.PropertyListener<STATE, CONTEXT>, fireOnListen?: boolean): RemoveListener;
|
|
583
|
+
/**
|
|
584
|
+
* Add a listener that will be called when the command is executed
|
|
585
|
+
* @param listener
|
|
586
|
+
*/
|
|
587
|
+
addExecuteListener(listener: ICommand.Hook<STATE, CONTEXT>): RemoveListener;
|
|
588
|
+
/**
|
|
589
|
+
* Get the shortcut(s) associated with the command.
|
|
590
|
+
*/
|
|
591
|
+
getShortcut(): IKeyStroke | readonly IKeyStroke[];
|
|
592
|
+
/**
|
|
593
|
+
* Get the label associated with the command.
|
|
594
|
+
*/
|
|
595
|
+
getLabel(scope?: string, context?: ICommand.DynamicContext<CONTEXT>): string;
|
|
596
|
+
/**
|
|
597
|
+
* Get the tags associated with the command.
|
|
598
|
+
*/
|
|
599
|
+
getTags(context?: ICommand.DynamicContext<CONTEXT>): string[];
|
|
600
|
+
/**
|
|
601
|
+
* Get the description associated with the command.
|
|
602
|
+
*/
|
|
603
|
+
getDescription(context?: ICommand.DynamicContext<CONTEXT>): string;
|
|
604
|
+
/**
|
|
605
|
+
* Get the icon associated with the command.
|
|
606
|
+
*/
|
|
607
|
+
getIcon(context?: ICommand.DynamicContext<CONTEXT>): React.ReactElement | string;
|
|
564
608
|
}
|
|
565
609
|
|
|
566
610
|
/**
|
|
567
|
-
*
|
|
611
|
+
* @see
|
|
612
|
+
* ### **Interface**
|
|
613
|
+
*
|
|
614
|
+
* {@link ICommand}
|
|
568
615
|
*/
|
|
569
|
-
export declare
|
|
616
|
+
export declare namespace ICommand {
|
|
617
|
+
/**
|
|
618
|
+
* Used to interactive with a dom element.
|
|
619
|
+
*
|
|
620
|
+
* @remarks
|
|
621
|
+
* * When dispatching keystrokes the target is used to determine if the keystroke
|
|
622
|
+
* can be consumed by the element.
|
|
623
|
+
* * Many commands will refocus the target after they have completed. The target focus will be called.
|
|
624
|
+
*/
|
|
625
|
+
export interface ITarget {
|
|
626
|
+
/**
|
|
627
|
+
* Used to determine if a dom element is contained with the group.
|
|
628
|
+
*
|
|
629
|
+
* @param element
|
|
630
|
+
*
|
|
631
|
+
* @remarks
|
|
632
|
+
* This is used for validating keystrokes and focus traversal.
|
|
633
|
+
*/
|
|
634
|
+
contains(element: Node | null): boolean;
|
|
635
|
+
/**
|
|
636
|
+
* Called after a command is executed.
|
|
637
|
+
*/
|
|
638
|
+
focus(): void;
|
|
639
|
+
}
|
|
570
640
|
/**
|
|
571
|
-
*
|
|
572
|
-
* this is completed.
|
|
641
|
+
* The callback function for a command.
|
|
573
642
|
*
|
|
574
|
-
* @
|
|
575
|
-
*
|
|
643
|
+
* @remarks
|
|
644
|
+
* When
|
|
576
645
|
*/
|
|
577
|
-
|
|
646
|
+
export interface Callback<STATE extends any = void> {
|
|
647
|
+
(args?: STATE, command?: ICommand<STATE, unknown>): void | boolean | Promise<boolean> | Promise<void>;
|
|
648
|
+
}
|
|
649
|
+
export type DynamicContext<CONTEXT> = CONTEXT | (() => CONTEXT);
|
|
650
|
+
export type DynamicValue<T, CONTEXT> = T | ((context?: DynamicContext<CONTEXT>) => T);
|
|
578
651
|
/**
|
|
579
|
-
*
|
|
652
|
+
* Properties that can be updated on a command.
|
|
580
653
|
*/
|
|
581
|
-
|
|
654
|
+
export interface Properties<STATE extends any = void, CONTEXT extends any = void> {
|
|
655
|
+
disabled?: boolean | (() => boolean);
|
|
656
|
+
/**
|
|
657
|
+
* Values associated with the command model.
|
|
658
|
+
*/
|
|
659
|
+
state?: STATE;
|
|
660
|
+
/**
|
|
661
|
+
* View specific context values
|
|
662
|
+
*/
|
|
663
|
+
context?: DynamicContext<CONTEXT>;
|
|
664
|
+
shortcut?: IKeyStroke | IKeyStroke[] | (() => IKeyStroke);
|
|
665
|
+
label?: DynamicValue<string, CONTEXT>;
|
|
666
|
+
tags?: DynamicValue<string[], CONTEXT>;
|
|
667
|
+
/**
|
|
668
|
+
* The ability to override labels for specific context. Useful for content menus
|
|
669
|
+
* For example 'Rename Sheet' command might only want to be displayed as 'Rename' in the content menu.
|
|
670
|
+
*/
|
|
671
|
+
scopedLabels?: Record<string, DynamicValue<string, CONTEXT>>;
|
|
672
|
+
description?: DynamicValue<string, CONTEXT>;
|
|
673
|
+
icon?: DynamicValue<React.ReactNode, CONTEXT>;
|
|
674
|
+
}
|
|
675
|
+
export interface PropertyListener<STATE extends any, CONTEXT extends any> {
|
|
676
|
+
/**
|
|
677
|
+
* Called when command properties have changed.
|
|
678
|
+
*/
|
|
679
|
+
(props: ICommand.Properties<STATE, CONTEXT>, command: ICommand<STATE, CONTEXT>): void;
|
|
680
|
+
}
|
|
582
681
|
/**
|
|
583
|
-
*
|
|
682
|
+
* A hook that can be passed to a command execute function.
|
|
584
683
|
*/
|
|
585
|
-
|
|
684
|
+
export interface Hook<STATE extends any, CONTEXT extends any = void> {
|
|
685
|
+
/**
|
|
686
|
+
* If implemented will be called when execute is called. If a promise is return if will wait until
|
|
687
|
+
* this is completed.
|
|
688
|
+
*
|
|
689
|
+
* @param command
|
|
690
|
+
* @param args
|
|
691
|
+
*/
|
|
692
|
+
beforeExecute?(command: ICommand<STATE, CONTEXT>, args: STATE): Promise<boolean | void> | boolean | void;
|
|
693
|
+
/**
|
|
694
|
+
* Called when a command has been executed successful.
|
|
695
|
+
*/
|
|
696
|
+
onExecute?(command: ICommand<STATE, CONTEXT>, args: STATE): void;
|
|
697
|
+
/**
|
|
698
|
+
* Called when a command failed to executed successfully.
|
|
699
|
+
*/
|
|
700
|
+
onError?(command: ICommand<STATE, CONTEXT>, error: any, args: STATE): void;
|
|
701
|
+
}
|
|
586
702
|
}
|
|
587
703
|
|
|
588
|
-
export declare interface ICommandListener<STATE extends any, CONTEXT extends any = void> extends
|
|
704
|
+
export declare interface ICommandListener<STATE extends any, CONTEXT extends any = void> extends ICommand.Hook<STATE, CONTEXT> {
|
|
589
705
|
onChange?(command: ICommand<STATE, CONTEXT>): void;
|
|
590
706
|
}
|
|
591
707
|
|
|
@@ -593,29 +709,6 @@ export declare interface ICommandListenerOptions {
|
|
|
593
709
|
fireOnCommandChange: boolean;
|
|
594
710
|
}
|
|
595
711
|
|
|
596
|
-
export declare interface ICommandProperties<STATE extends any = void, CONTEXT extends any = void> {
|
|
597
|
-
disabled?: boolean | (() => boolean);
|
|
598
|
-
state?: STATE;
|
|
599
|
-
context?: DynamicContext<CONTEXT>;
|
|
600
|
-
shortcut?: IKeyStroke | IKeyStroke[] | (() => IKeyStroke);
|
|
601
|
-
label?: DynamicValue<string, CONTEXT>;
|
|
602
|
-
tags?: DynamicValue<string[], CONTEXT>;
|
|
603
|
-
/**
|
|
604
|
-
* The ability to override labels for specific context. Useful for content menus
|
|
605
|
-
* For example 'Rename Sheet' command might only want to be displayed as 'Rename' in the content menu.
|
|
606
|
-
*/
|
|
607
|
-
scopedLabels?: Record<string, DynamicValue<string, CONTEXT>>;
|
|
608
|
-
description?: DynamicValue<string, CONTEXT>;
|
|
609
|
-
icon?: DynamicValue<React.ReactNode, CONTEXT>;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
export declare interface ICommandPropertyListener<STATE extends any, CONTEXT extends any> {
|
|
613
|
-
/**
|
|
614
|
-
* Called when command properties have changed.
|
|
615
|
-
*/
|
|
616
|
-
(props: ICommandProperties<STATE, CONTEXT>, command: ICommand<STATE, CONTEXT>): void;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
712
|
/**
|
|
620
713
|
* The ICommands namespace contains interfaces for managing collections of commands and
|
|
621
714
|
* dispatching keystrokes to the most specific command.
|
|
@@ -655,29 +748,6 @@ export declare namespace ICommands {
|
|
|
655
748
|
*/
|
|
656
749
|
keys?: string[];
|
|
657
750
|
}
|
|
658
|
-
/**
|
|
659
|
-
* Used to interactive with a dom element.
|
|
660
|
-
*
|
|
661
|
-
* @remarks
|
|
662
|
-
* * When dispatching keystrokes the target is used to determine if the keystroke
|
|
663
|
-
* can be consumed by the element.
|
|
664
|
-
* * Many commands will refocus the target after they have completed. The target focus will be called.
|
|
665
|
-
*/
|
|
666
|
-
export interface ITarget {
|
|
667
|
-
/**
|
|
668
|
-
* Used to determine if a dom element is contained with the group.
|
|
669
|
-
*
|
|
670
|
-
* @param element
|
|
671
|
-
*
|
|
672
|
-
* @remarks
|
|
673
|
-
* This is used for validating keystrokes and focus traversal.
|
|
674
|
-
*/
|
|
675
|
-
contains(element: Node | null): boolean;
|
|
676
|
-
/**
|
|
677
|
-
* Called after a command is executed.
|
|
678
|
-
*/
|
|
679
|
-
focus(): void;
|
|
680
|
-
}
|
|
681
751
|
/**
|
|
682
752
|
* Contains commands and child command maps.
|
|
683
753
|
*/
|
|
@@ -697,11 +767,11 @@ export declare namespace ICommands {
|
|
|
697
767
|
/**
|
|
698
768
|
* Create a new map to add Commands.
|
|
699
769
|
*
|
|
700
|
-
* @param target {@link
|
|
770
|
+
* @param target {@link ICommand.ITarget}.
|
|
701
771
|
* @param groupKey String description describing the reason for the group. This is presented to the user in the shortcut UI.
|
|
702
772
|
* @param replace If `true` replace the existing commands. If `false` ignores duplicates. If unspecified a warning will be logged for duplicates.
|
|
703
773
|
*/
|
|
704
|
-
createChildGroup(target:
|
|
774
|
+
createChildGroup(target: ICommand.ITarget | (() => ICommand.ITarget), groupKey: string, replace?: boolean): ICommands.IGroup;
|
|
705
775
|
/**
|
|
706
776
|
* Returns the keys associated with the group
|
|
707
777
|
*/
|
|
@@ -777,9 +847,10 @@ export declare namespace ICommands {
|
|
|
777
847
|
}
|
|
778
848
|
}
|
|
779
849
|
|
|
780
|
-
export declare interface ICommandsListeners<STATE extends any, CONTEXT extends any = void> extends
|
|
850
|
+
export declare interface ICommandsListeners<STATE extends any, CONTEXT extends any = void> extends ICommand.Hook<STATE, CONTEXT> {
|
|
781
851
|
/**
|
|
782
852
|
* Called when either the command group is updated or if keys are provided then the commands as well.
|
|
853
|
+
*
|
|
783
854
|
* @param commands
|
|
784
855
|
*/
|
|
785
856
|
onChange?(commands: ICommands.IGroup): void;
|
|
@@ -1499,6 +1570,9 @@ export declare interface ShowWindowOptions<T = any, C = any> {
|
|
|
1499
1570
|
disableAutoDestroy?: boolean;
|
|
1500
1571
|
}
|
|
1501
1572
|
|
|
1573
|
+
/**
|
|
1574
|
+
* A simple command that does not maintain state or context.
|
|
1575
|
+
*/
|
|
1502
1576
|
export declare class SimpleCommand extends Command<void, void> {
|
|
1503
1577
|
}
|
|
1504
1578
|
|
|
@@ -1791,7 +1865,7 @@ export declare interface UseAnimatedMeasureOptions {
|
|
|
1791
1865
|
export declare const useCallbackRef: <T extends (...args: any[]) => any>(callback: T, deps: DependencyList) => T;
|
|
1792
1866
|
|
|
1793
1867
|
/**
|
|
1794
|
-
* Useful for capture command changes. This can be used with an @see
|
|
1868
|
+
* Useful for capture command changes. This can be used with an @see ICommand.Hook or without.
|
|
1795
1869
|
* If used with then will call the function. If not then a change will force a re-render.
|
|
1796
1870
|
|
|
1797
1871
|
* @param command
|
|
@@ -1800,7 +1874,7 @@ export declare const useCallbackRef: <T extends (...args: any[]) => any>(callbac
|
|
|
1800
1874
|
export declare function useCommand<STATE = any, CONTEXT = any>(command: ICommand<STATE, CONTEXT> | ICommand<STATE, CONTEXT>[], listener?: ICommandListener<STATE, CONTEXT>): number;
|
|
1801
1875
|
|
|
1802
1876
|
/**
|
|
1803
|
-
* Useful for capture command changes. This can be used with an @see
|
|
1877
|
+
* Useful for capture command changes. This can be used with an @see ICommand.Hook or without.
|
|
1804
1878
|
* If used with then will call the function. If not then a change will force a re-render.
|
|
1805
1879
|
*
|
|
1806
1880
|
* @param commands
|