@i2analyze/notebook-sdk 1.10.0-dev.3 → 1.10.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2539,11 +2539,28 @@ export declare namespace commands {
2539
2539
  * Adds the specified group of actions to the user interface.
2540
2540
  *
2541
2541
  * @param group - The group to add.
2542
+ * @typeParam TCommandType - The type of the command-context for the group, which determines what event API is passed to its {@link commands.IGroup.onSurface}.
2542
2543
  * @returns An object that you can use to add actions or a further group to the new group.
2543
2544
  * @throws `Error` if the `group` was not valid, or if a group with the same {@link commands.GroupId} was already present.
2544
2545
  * @i2since 1.0
2545
2546
  */
2546
- addGroup(group: IGroup): IActionArea<undefined>;
2547
+ addGroup<TCommandType extends CommandType = 'unscoped'>(group: IGroup<TCommandType>): IActionArea<undefined>;
2548
+ /**
2549
+ * Adds a dynamic group whose commands are created on demand each time the group is opened.
2550
+ *
2551
+ * @remarks
2552
+ * Unlike {@link commands.IActionArea.addGroup}, the commands in a dynamic group are not created during plug-in
2553
+ * initialization. Instead, the {@link commands.IDynamicGroupConfig.onPopulate} callback is called each time the
2554
+ * group is opened, allowing you to create commands that reflect the current application state.
2555
+ *
2556
+ * Dynamic groups are always collapsed — they render as a dropdown or submenu.
2557
+ *
2558
+ * @param config - The configuration for the dynamic group, including the `onPopulate` callback.
2559
+ * @typeParam TCommandType - The type of the command-context for the group, which determines what payload is passed to `onPopulate` and what event API is passed to `onSurface`.
2560
+ * @throws `Error` if `config.id` is not a valid {@link commands.GroupId | GroupId}.
2561
+ * @i2since 1.10
2562
+ */
2563
+ addDynamicGroup<TCommandType extends CommandType = CommandType>(config: IDynamicGroupConfig<TCommandType>): void;
2547
2564
  /**
2548
2565
  * Adds the specified group of actions to the user interface, or gets an existing group with the same identifier.
2549
2566
  *
@@ -2553,11 +2570,12 @@ export declare namespace commands {
2553
2570
  * plug-ins that want to use the same group, and these plug-ins can be deployed independently, then you should use this method.
2554
2571
  *
2555
2572
  * @param group - The group to add or get.
2573
+ * @typeParam TCommandType - The type of the command-context for the group, which determines what event API is passed to its {@link commands.IGroup.onSurface}.
2556
2574
  * @returns An object that you can use to add actions or a further group to the new or existing group.
2557
2575
  * @throws `Error` if the `group` was not valid, or if it was added before by the same plug-in.
2558
2576
  * @i2since 1.0
2559
2577
  */
2560
- addOrGetGroup(group: IGroup): IActionArea<undefined>;
2578
+ addOrGetGroup<TCommandType extends CommandType = 'unscoped'>(group: IGroup<TCommandType>): IActionArea<undefined>;
2561
2579
  /**
2562
2580
  * Locates the area of the user interface that appears immediately after a particular action or group of actions.
2563
2581
  *
@@ -2733,9 +2751,11 @@ export declare namespace commands {
2733
2751
  }
2734
2752
  /**
2735
2753
  * A group of actions in either the i2 Notebook application ribbon or a popup menu.
2754
+ *
2755
+ * @typeParam TCommandType - The type of the command-context for the group, which determines what event API is passed to {@link commands.IGroup.onSurface}. Defaults to `'unscoped'`.
2736
2756
  * @i2since 1.0
2737
2757
  */
2738
- export interface IGroup extends IGroupBase {
2758
+ export interface IGroup<TCommandType extends CommandType = 'unscoped'> extends IGroupBase {
2739
2759
  /**
2740
2760
  * Gets the icon of the group, which is displayed if the group is collapsed.
2741
2761
  * @i2since 1.0
@@ -2759,6 +2779,36 @@ export declare namespace commands {
2759
2779
  * @i2since 1.9
2760
2780
  */
2761
2781
  readonly type?: GroupType;
2782
+ /**
2783
+ * Gets the command-context type, which determines what event API is passed to {@link commands.IGroup.onSurface}.
2784
+ *
2785
+ * @remarks
2786
+ * Mirrors {@link commands.IDynamicGroupConfig.context} (and, by analogy, {@link commands.ICommandConfig."type"}).
2787
+ * Defaults to `'unscoped'`, which means {@link commands.IGroup.onSurface} receives no event API.
2788
+ * @i2since 1.10
2789
+ */
2790
+ readonly context?: TCommandType;
2791
+ /**
2792
+ * Runs when an action derived from the group is surfaced, enabling the group to configure the action in response to events.
2793
+ *
2794
+ * @remarks
2795
+ * Mirrors {@link commands.ICommandConfig.onSurface} but applies to groups: use the supplied
2796
+ * {@link commands.IGroupAction} to change the group's label, icon, or enabled/hidden state at any
2797
+ * time during its surfaced lifetime. The signal aborts when the group is removed from the user
2798
+ * interface; the optional returned cleanup function runs at the same time.
2799
+ *
2800
+ * If there is no implementation of `onSurface()`, the group renders with its static configuration
2801
+ * and remains enabled.
2802
+ *
2803
+ * @param groupAction - The group action being surfaced.
2804
+ * @param eventApi - The events that the group can subscribe to, keyed by the group's `context`.
2805
+ * @param signal - A signal that the application uses to tell the group that it is removing it from the user interface.
2806
+ *
2807
+ * @returns A function that the application calls when it removes the group from the user interface.
2808
+ * In its implementation, the group must unsubscribe from any events that it has subscribed to.
2809
+ * @i2since 1.10
2810
+ */
2811
+ onSurface?(groupAction: IGroupAction, eventApi: CommandEventsMap[TCommandType], signal: AbortSignal): void | (() => void);
2762
2812
  }
2763
2813
  /**
2764
2814
  * A group of actions in a popup menu that do not have a label or an icon.
@@ -2767,6 +2817,186 @@ export declare namespace commands {
2767
2817
  */
2768
2818
  export interface IMenuGroup extends IGroupBase {
2769
2819
  }
2820
+ /**
2821
+ * Configuration for a dynamic group whose commands are created on demand when the group is opened.
2822
+ *
2823
+ * @remarks
2824
+ * A dynamic group solves the limitation that commands can only be created during plug-in initialization.
2825
+ * Instead, the {@link commands.IDynamicGroupConfig.onPopulate} callback is called each time the group is
2826
+ * opened, allowing commands to be created based on the current application state. The group's
2827
+ * popup-button state (label, icon, enabled, hidden) can be driven separately by an optional
2828
+ * {@link commands.IDynamicGroupConfig.onSurface} callback that runs once when the group is
2829
+ * surfaced on a host.
2830
+ *
2831
+ * Dynamic groups are always collapsed — they render as a dropdown/submenu that opens on click.
2832
+ *
2833
+ * @typeParam TCommandType - The type of the command-context for the group, which determines what payload is passed to {@link commands.IDynamicGroupConfig.onPopulate} and what event API is passed to {@link commands.IDynamicGroupConfig.onSurface}.
2834
+ * @i2since 1.10
2835
+ */
2836
+ export interface IDynamicGroupConfig<TCommandType extends CommandType = CommandType> {
2837
+ /**
2838
+ * Gets the identifier of the group, which should be a GUID. GUIDs are case-insensitive.
2839
+ * @i2since 1.10
2840
+ */
2841
+ readonly id: GroupId;
2842
+ /**
2843
+ * Gets the label of the group, which is displayed as the button/menu-entry title.
2844
+ * @i2since 1.10
2845
+ */
2846
+ readonly label: string;
2847
+ /**
2848
+ * Gets the icon of the group.
2849
+ * @i2since 1.10
2850
+ */
2851
+ readonly icon?: IIcon;
2852
+ /**
2853
+ * Gets the command-context type for the group.
2854
+ *
2855
+ * @remarks
2856
+ * Determines what payload is passed to {@link commands.IDynamicGroupConfig.onPopulate} and what
2857
+ * event API is passed to {@link commands.IDynamicGroupConfig.onSurface}.
2858
+ * @i2since 1.10
2859
+ */
2860
+ readonly context: TCommandType;
2861
+ /**
2862
+ * Populates the group's commands each time the group is opened.
2863
+ *
2864
+ * @param commandArea - A scoped area for creating and surfacing commands. Only commands created here are visible in this group.
2865
+ * @param context - The context based on the group's `context` field: `undefined` for `'unscoped'`, {@link commands.IRecordsContext} for `'records'`, the application object for `'application'`.
2866
+ * @param signal - An AbortSignal that is aborted when the group closes. Use it to cancel any async work started in this callback.
2867
+ * @returns An optional cleanup function that is called when the group closes, before the signal is aborted.
2868
+ * @i2since 1.10
2869
+ */
2870
+ onPopulate(commandArea: IDynamicActionArea, context: CommandPayloadMap[TCommandType], signal: AbortSignal): void | (() => void);
2871
+ /**
2872
+ * Runs when the dynamic group's popup button is surfaced, enabling its state to be driven from events.
2873
+ *
2874
+ * @remarks
2875
+ * The lifetime of this callback is the dynamic group's *button* — separate from the per-open
2876
+ * lifecycle of {@link commands.IDynamicGroupConfig.onPopulate}, which populates the popup's
2877
+ * contents. Use this callback to react to long-lived application state; populate the popup's
2878
+ * contents in `onPopulate`.
2879
+ *
2880
+ * If there is no implementation of `onSurface()`, the popup button renders with its static
2881
+ * configuration and remains enabled.
2882
+ *
2883
+ * @param groupAction - The group action being surfaced.
2884
+ * @param eventApi - The events that the group can subscribe to, keyed by the group's `type`.
2885
+ * @param signal - A signal that the application uses to tell the group that it is removing the popup button from the user interface.
2886
+ *
2887
+ * @returns A function that the application calls when it removes the popup button from the user interface.
2888
+ * In its implementation, the group must unsubscribe from any events that it has subscribed to.
2889
+ * @i2since 1.10
2890
+ */
2891
+ onSurface?(groupAction: IGroupAction, eventApi: CommandEventsMap[TCommandType], signal: AbortSignal): void | (() => void);
2892
+ }
2893
+ /**
2894
+ * A scoped area for creating and surfacing commands within a {@link commands.IDynamicGroupConfig.onPopulate} callback.
2895
+ *
2896
+ * @remarks
2897
+ * Methods on this interface work like their equivalents on {@link commands.IActionArea}, but are scoped to the
2898
+ * current populate session. Commands created here exist only while the group is open and are automatically
2899
+ * unregistered when it closes.
2900
+ *
2901
+ * `getGroup` is restricted to groups created within the same `onPopulate` call — it throws if you pass an
2902
+ * external group identifier.
2903
+ * @i2since 1.10
2904
+ */
2905
+ export interface IDynamicActionArea extends Pick<ICommandApi, 'createCommand'> {
2906
+ /**
2907
+ * Returns an area positioned immediately before the specified action or group.
2908
+ * @param idOrCommand - The command, command identifier, or group identifier to use as a reference.
2909
+ * @returns A scoped area positioned before the specified item.
2910
+ * @i2since 1.10
2911
+ */
2912
+ before(idOrCommand: CommandId | GroupId | ICommand): IDynamicActionArea;
2913
+ /**
2914
+ * Returns an area positioned immediately after the specified action or group.
2915
+ * @param idOrCommand - The command, command identifier, or group identifier to use as a reference.
2916
+ * @returns A scoped area positioned after the specified item.
2917
+ * @i2since 1.10
2918
+ */
2919
+ after(idOrCommand: CommandId | GroupId | ICommand): IDynamicActionArea;
2920
+ /**
2921
+ * Returns an area scoped to a group created during this `onPopulate` call.
2922
+ *
2923
+ * @param id - The identifier of a group created in this populate session.
2924
+ * @returns A scoped area for the contents of the group.
2925
+ * @throws `Error` if `id` refers to a group that was not created in this populate session.
2926
+ * @i2since 1.10
2927
+ */
2928
+ getGroup(id: GroupId): IDynamicActionArea;
2929
+ /**
2930
+ * Adds a new group.
2931
+ * @param group - The group configuration.
2932
+ * @typeParam TCommandType - The type of the command-context for the group, which determines what event API is passed to its {@link commands.IGroup.onSurface}.
2933
+ * @returns A scoped area for the contents of the new group.
2934
+ * @i2since 1.10
2935
+ */
2936
+ addGroup<TCommandType extends CommandType = 'unscoped'>(group: IGroup<TCommandType>): IDynamicActionArea;
2937
+ /**
2938
+ * Adds a new group, or returns the existing one if it was already added during this `onPopulate` call.
2939
+ * @param group - The group configuration.
2940
+ * @typeParam TCommandType - The type of the command-context for the group, which determines what event API is passed to its {@link commands.IGroup.onSurface}.
2941
+ * @returns A scoped area for the contents of the new or existing group.
2942
+ * @i2since 1.10
2943
+ */
2944
+ addOrGetGroup<TCommandType extends CommandType = 'unscoped'>(group: IGroup<TCommandType>): IDynamicActionArea;
2945
+ /**
2946
+ * Surfaces the specified commands in the group.
2947
+ * @param commandsOrCommandIds - The commands or command identifiers to surface.
2948
+ * @i2since 1.10
2949
+ */
2950
+ surfaceCommands(...commandsOrCommandIds: (ICommand | CommandId)[]): void;
2951
+ }
2952
+ /**
2953
+ * A representation of a group of commands in the user interface. A group action is created when a group is surfaced.
2954
+ *
2955
+ * @remarks
2956
+ * Group actions mirror {@link commands.IAction} for individual commands. They are passed to
2957
+ * {@link commands.IGroup.onSurface} (for static groups) and {@link commands.IDynamicGroupConfig.onSurface}
2958
+ * (for the popup button of a dynamic group), allowing the group's label, icon, and enabled/hidden
2959
+ * state to be driven from application state.
2960
+ *
2961
+ * When a group is disabled and expanded, its immediate children are rendered as disabled too —
2962
+ * disabling the group is therefore a render-time cascade, not a mutation of child state.
2963
+ * @i2since 1.10
2964
+ */
2965
+ export interface IGroupAction {
2966
+ /**
2967
+ * Sets the label of the group. For example, "Layouts".
2968
+ *
2969
+ * @param value - A label for the group.
2970
+ * @i2since 1.10
2971
+ */
2972
+ setName(value: string): void;
2973
+ /**
2974
+ * Sets whether the group is enabled — that is, whether it is available for users to interact with.
2975
+ *
2976
+ * @remarks
2977
+ * When disabled and expanded, the group's immediate child actions render as disabled; when
2978
+ * disabled and collapsed (or a dynamic group), the popup trigger cannot be opened.
2979
+ *
2980
+ * @param value - `true` to enable the group; `false` to disable it.
2981
+ * @i2since 1.10
2982
+ */
2983
+ setEnabled(value: boolean): void;
2984
+ /**
2985
+ * Sets whether the group is hidden — that is, whether it is visible to users at all.
2986
+ * Hidden groups do not render their container, label, or children.
2987
+ *
2988
+ * @param value - `true` to hide the group; `false` to show it.
2989
+ * @i2since 1.10
2990
+ */
2991
+ setHidden(value: boolean): void;
2992
+ /**
2993
+ * Sets the icon for the group.
2994
+ *
2995
+ * @param value - An icon for the group.
2996
+ * @i2since 1.10
2997
+ */
2998
+ setIcon(value: IIcon): void;
2999
+ }
2770
3000
  /**
2771
3001
  * A representation of a command in the user interface. An action is created when a command is surfaced.
2772
3002
  * @i2since 1.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i2analyze/notebook-sdk",
3
- "version": "1.10.0-dev.3",
3
+ "version": "1.10.0-dev.5",
4
4
  "description": "i2 Notebook SDK",
5
5
  "license": "MIT",
6
6
  "publishConfig": {