@i2analyze/notebook-sdk 1.9.0-dev.1 → 1.9.0-dev.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.
@@ -2295,6 +2295,47 @@ export declare namespace commands {
2295
2295
  * @i2since 1.0
2296
2296
  */
2297
2297
  surfaceCommands(...commandsOrCommandIds: (ICommand | CommandId)[]): void;
2298
+ /**
2299
+ * Adds a dynamic group whose commands are determined at runtime based on the current application state.
2300
+ *
2301
+ * @remarks
2302
+ * Dynamic groups allow commands to be created and surfaced at runtime, when the group is displayed
2303
+ * from a menu or ribbon popup. The group's `onSurface` callback is invoked when the group needs to
2304
+ * be rendered, and receives the current context along with a scoped {@link commands.IDynamicActionArea}
2305
+ * for creating and positioning commands.
2306
+ *
2307
+ * Commands created within a dynamic group are transient - they exist only while the group is visible
2308
+ * and are automatically cleaned up when the group is removed from the surface.
2309
+ *
2310
+ * @example
2311
+ * ```typescript
2312
+ * // Add a dynamic group to the chart item popup menu
2313
+ * api.commands.chartItemPopupMenu.addDynamicGroup({
2314
+ * id: 'context-actions',
2315
+ * label: 'Context Actions',
2316
+ * type: 'records',
2317
+ * onSurface: (commandArea, context, signal) => {
2318
+ * // Create commands based on current selection
2319
+ * const entityCount = context.entityRecords.count;
2320
+ * if (entityCount > 0) {
2321
+ * const cmd = commandArea.createCommand({
2322
+ * id: 'process-selected',
2323
+ * name: `Process ${entityCount} selected items`,
2324
+ * type: 'records',
2325
+ * onExecute: (payload) => { /* ... *\/ }
2326
+ * });
2327
+ * commandArea.surfaceCommands(cmd);
2328
+ * }
2329
+ * }
2330
+ * });
2331
+ * ```
2332
+ *
2333
+ * @typeParam TCommandType - The type of commands in this group, which determines the context passed to `onSurface`.
2334
+ * @param config - The configuration for the dynamic group.
2335
+ * @throws `Error` if the configuration is invalid or a group with the same identifier already exists.
2336
+ * @i2since 1.9
2337
+ */
2338
+ addDynamicGroup<TCommandType extends CommandType = CommandType>(config: IDynamicGroupConfig<TCommandType>): void;
2298
2339
  /**
2299
2340
  * Gets the system groups for the action area, which you can use to specify relative locations for your actions and groups.
2300
2341
  * @i2since 1.0
@@ -2419,6 +2460,128 @@ export declare namespace commands {
2419
2460
  */
2420
2461
  export interface IMenuGroup extends IGroupBase {
2421
2462
  }
2463
+ /**
2464
+ * Configuration for a dynamic group whose contents is determined at runtime.
2465
+ *
2466
+ * @typeParam TCommandType - The type of commands in this group, which determines the context passed to `onSurface`.
2467
+ * @i2since 1.9
2468
+ */
2469
+ export interface IDynamicGroupConfig<TCommandType extends CommandType = CommandType> {
2470
+ /**
2471
+ * Gets the identifier of the group, which should be a GUID.
2472
+ * @i2since 1.9
2473
+ */
2474
+ readonly id: GroupId;
2475
+ /**
2476
+ * Gets the label of the group, which is displayed to users.
2477
+ *
2478
+ * @remarks
2479
+ * The label appears in popup menus and submenus, and also as the label for ribbon buttons
2480
+ * that open a pop-out menu.
2481
+ *
2482
+ * @i2since 1.9
2483
+ */
2484
+ readonly label: string;
2485
+ /**
2486
+ * Gets the icon of the group, which is displayed in the user interface.
2487
+ * @i2since 1.9
2488
+ */
2489
+ readonly icon?: IIcon;
2490
+ /**
2491
+ * Gets the type of context that is passed to the `onSurface` callback.
2492
+ *
2493
+ * @remarks
2494
+ * The value `'unscoped'` means no context (the context parameter is `undefined`).
2495
+ * The value `'records'` provides a chart selection records context ({@link commands.IRecordsContext}).
2496
+ * The value `'application'` provides the full application contents context ({@link app.IApplicationContents}).
2497
+ *
2498
+ * @i2since 1.9
2499
+ */
2500
+ readonly type: TCommandType;
2501
+ /**
2502
+ * Invokes a callback when the group needs to be rendered in the user interface.
2503
+ *
2504
+ * @remarks
2505
+ * Receives a scoped {@link commands.IDynamicActionArea} for creating and surfacing commands.
2506
+ * Commands created in this callback are transient and exist only while the group is visible.
2507
+ * They are automatically unregistered when the group is removed from the surface.
2508
+ *
2509
+ * The `signal` parameter fires when the group is being removed, allowing you to cancel pending
2510
+ * async operations or clean up resources.
2511
+ *
2512
+ * @param commandArea - A scoped action area for creating and positioning commands within this group.
2513
+ * @param context - The context based on the group type, determined by {@link commands.CommandPayloadMap}.
2514
+ * @param signal - An `AbortSignal` that fires when the group is removed from the surface.
2515
+ * @returns An optional cleanup function that is called when the group is removed.
2516
+ * @i2since 1.9
2517
+ */
2518
+ onSurface(commandArea: IDynamicActionArea, context: CommandPayloadMap[TCommandType], signal: AbortSignal): void | (() => void);
2519
+ }
2520
+ /**
2521
+ * A scoped action area for creating and positioning commands within a dynamic group.
2522
+ *
2523
+ * @remarks
2524
+ * This interface is provided to the `onSurface` callback of {@link commands.IDynamicGroupConfig}.
2525
+ * It allows you to create commands and organize them within the dynamic group using positioning
2526
+ * methods like `before`, `after`, and `getGroup`.
2527
+ *
2528
+ * Commands created through this area are automatically cleaned up when the dynamic group is removed
2529
+ * from the surface.
2530
+ *
2531
+ * @i2since 1.9
2532
+ */
2533
+ export interface IDynamicActionArea extends Pick<ICommandApi, 'createCommand'> {
2534
+ /**
2535
+ * Locates the area of the user interface that appears immediately before a particular action or group of actions.
2536
+ *
2537
+ * @param idOrCommand - The identifier of the action or group to use as a reference, or a command object.
2538
+ * @returns An object that you can use to add actions or a group to the located area.
2539
+ * @i2since 1.9
2540
+ */
2541
+ before(idOrCommand: CommandId | GroupId | ICommand): IDynamicActionArea;
2542
+ /**
2543
+ * Locates the area of the user interface that appears immediately after a particular action or group of actions.
2544
+ *
2545
+ * @param idOrCommand - The identifier of the action or group to use as a reference, or a command object.
2546
+ * @returns An object that you can use to add actions or a group to the located area.
2547
+ * @i2since 1.9
2548
+ */
2549
+ after(idOrCommand: CommandId | GroupId | ICommand): IDynamicActionArea;
2550
+ /**
2551
+ * Locates the area of the user interface that is occupied by a particular group of actions.
2552
+ *
2553
+ * @param id - The identifier of the group to use as a reference.
2554
+ * @returns An action area representing the specified group.
2555
+ * @i2since 1.9
2556
+ */
2557
+ getGroup(id: GroupId): IDynamicActionArea;
2558
+ /**
2559
+ * Adds the specified group of actions to the user interface.
2560
+ *
2561
+ * @param group - The group to add.
2562
+ * @returns An object that you can use to add actions or a further group to the new group.
2563
+ * @i2since 1.9
2564
+ */
2565
+ addGroup(group: IGroup): IDynamicActionArea;
2566
+ /**
2567
+ * Adds the specified group of actions to the user interface, or gets an existing group with the same identifier.
2568
+ *
2569
+ * @param group - The group to add or get.
2570
+ * @returns An object that you can use to add actions or a further group to the new or existing group.
2571
+ * @i2since 1.9
2572
+ */
2573
+ addOrGetGroup(group: IGroup): IDynamicActionArea;
2574
+ /**
2575
+ * Adds actions for the specified registered commands to the user interface.
2576
+ *
2577
+ * @remarks
2578
+ * When you surface multiple commands, the actions are added to the user interface in the same order as you specify them.
2579
+ *
2580
+ * @param commandsOrCommandIds - The registered commands, or the identifiers of the commands, to surface.
2581
+ * @i2since 1.9
2582
+ */
2583
+ surfaceCommands(...commandsOrCommandIds: (ICommand | CommandId)[]): void;
2584
+ }
2422
2585
  /**
2423
2586
  * A representation of a command in the user interface. An action is created when a command is surfaced.
2424
2587
  * @i2since 1.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i2analyze/notebook-sdk",
3
- "version": "1.9.0-dev.1",
3
+ "version": "1.9.0-dev.2",
4
4
  "description": "i2 Notebook SDK",
5
5
  "license": "MIT",
6
6
  "publishConfig": {