@contrail/extensions-sdk 1.0.27 → 1.0.28

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.
@@ -7,7 +7,8 @@ export declare enum PlanCommand {
7
7
  ADD_PLACEHOLDERS_WITH_ITEMS = "plan:add_placeholders_with_items",
8
8
  GET_PLACEHOLDERS = "plan:get_placeholders",
9
9
  GET_VIEW_STATE = "plan:get_view_state",
10
- ASSIGN_ITEMS = "plan:assign_items"
10
+ ASSIGN_ITEMS = "plan:assign_items",
11
+ SCROLL_TO_PLACEHOLDER = "plan:scroll_to_placeholder"
11
12
  }
12
13
  /**
13
14
  * A row on a plan. Beyond the item linkage below, properties are the org-configured
@@ -42,6 +43,30 @@ export interface PlaceholderItemAssignment {
42
43
  /** The item to assign — an item family or an item option. */
43
44
  itemId: string;
44
45
  }
46
+ export interface ScrollToPlaceholderOptions {
47
+ /**
48
+ * Also bring this column into view horizontally.
49
+ *
50
+ * Omit to scroll vertically only, which is usually what you want after writing to a row —
51
+ * it leaves the user's horizontal position alone.
52
+ */
53
+ propertySlug?: string;
54
+ }
55
+ /** Why a row could not be brought into view. */
56
+ export declare type ScrollToPlaceholderFailure = 'not-on-plan' | 'not-displayed' | 'no-grid';
57
+ export interface ScrollToPlaceholderResult {
58
+ /** Whether the row was brought into view. Already-visible rows report `true`. */
59
+ revealed: boolean;
60
+ /**
61
+ * Set only when `revealed` is false.
62
+ *
63
+ * - `not-on-plan` - no row on this plan has that id.
64
+ * - `not-displayed` - the row exists but the user's filter or sort excludes it, so there is
65
+ * no position to scroll to. Reading {@link PlanApp.getViewState} will say why.
66
+ * - `no-grid` - the plan is not currently showing the grid, so there is nothing to scroll.
67
+ */
68
+ reason?: ScrollToPlaceholderFailure;
69
+ }
45
70
  export interface GetPlaceholdersOptions {
46
71
  /** Defaults to `all`. */
47
72
  scope?: PlanPlaceholderScope;
@@ -130,6 +155,27 @@ export declare class PlanApp {
130
155
  * Requires the plan to be editable.
131
156
  */
132
157
  static assignItems(assignments: Array<PlaceholderItemAssignment>): Promise<void>;
158
+ /**
159
+ * Scrolls the plan's grid so a row is in view.
160
+ *
161
+ * Use this after writing to the plan - assigning items or adding rows - so the user can see
162
+ * what changed instead of having to hunt for it. A row that is already on screen is left
163
+ * alone rather than re-centred.
164
+ *
165
+ * This is a view-only operation: it does not select the row, change the filter, or edit
166
+ * anything, and it does not require the plan to be editable.
167
+ *
168
+ * Check the result rather than assuming success - a row outside the user's current filter has
169
+ * no position in the grid to scroll to:
170
+ *
171
+ * ```ts
172
+ * const result = await PlanApp.scrollToPlaceholder(rowId);
173
+ * if (!result.revealed && result.reason === 'not-displayed') {
174
+ * // The row was written, but the user's filter hides it.
175
+ * }
176
+ * ```
177
+ */
178
+ static scrollToPlaceholder(placeholderId: string, options?: ScrollToPlaceholderOptions): Promise<ScrollToPlaceholderResult>;
133
179
  /**
134
180
  * Creates new rows on the plan from property data, and returns them.
135
181
  *
package/lib/apps/plan.js CHANGED
@@ -22,6 +22,7 @@ var PlanCommand;
22
22
  PlanCommand["GET_PLACEHOLDERS"] = "plan:get_placeholders";
23
23
  PlanCommand["GET_VIEW_STATE"] = "plan:get_view_state";
24
24
  PlanCommand["ASSIGN_ITEMS"] = "plan:assign_items";
25
+ PlanCommand["SCROLL_TO_PLACEHOLDER"] = "plan:scroll_to_placeholder";
25
26
  })(PlanCommand = exports.PlanCommand || (exports.PlanCommand = {}));
26
27
  class PlanApp {
27
28
  static getCurrentPlan() {
@@ -171,6 +172,39 @@ class PlanApp {
171
172
  PlanApp.validateAndReturnResults(results);
172
173
  });
173
174
  }
175
+ /**
176
+ * Scrolls the plan's grid so a row is in view.
177
+ *
178
+ * Use this after writing to the plan - assigning items or adding rows - so the user can see
179
+ * what changed instead of having to hunt for it. A row that is already on screen is left
180
+ * alone rather than re-centred.
181
+ *
182
+ * This is a view-only operation: it does not select the row, change the filter, or edit
183
+ * anything, and it does not require the plan to be editable.
184
+ *
185
+ * Check the result rather than assuming success - a row outside the user's current filter has
186
+ * no position in the grid to scroll to:
187
+ *
188
+ * ```ts
189
+ * const result = await PlanApp.scrollToPlaceholder(rowId);
190
+ * if (!result.revealed && result.reason === 'not-displayed') {
191
+ * // The row was written, but the user's filter hides it.
192
+ * }
193
+ * ```
194
+ */
195
+ static scrollToPlaceholder(placeholderId, options) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ PlanApp.validatePlanContext();
198
+ if (!placeholderId) {
199
+ return { revealed: false, reason: 'not-on-plan' };
200
+ }
201
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
202
+ command: PlanCommand.SCROLL_TO_PLACEHOLDER,
203
+ data: { placeholderId, options },
204
+ });
205
+ return PlanApp.validateAndReturnResults(results);
206
+ });
207
+ }
174
208
  /**
175
209
  * Creates new rows on the plan from property data, and returns them.
176
210
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/extensions-sdk",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "Client library for interfacing with VibeIQ's services and apps from an extension.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",