@progress/kendo-angular-grid 21.0.0-develop.12 → 21.0.0-develop.14

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,9 +7,12 @@ import { AIPromptComponent, OutputViewComponent, PromptViewComponent, AIPromptCu
7
7
  import { HttpClient, HttpRequest } from '@angular/common/http';
8
8
  import { ContextService } from './../../../../common/provider.service';
9
9
  import { ColumnInfoService } from './../../../../common/column-info.service';
10
- import { GridToolbarAIResponseSuccessEvent, GridToolbarAIResponseErrorEvent } from './models';
10
+ import { GridAIAssistantResponseSuccessEvent, GridAIAssistantResponseErrorEvent } from './models';
11
11
  import { NgIf } from '@angular/common';
12
12
  import { convertDateStringsInFilter, highlightBy } from './utils';
13
+ import { isCheckboxColumn } from '../../../../columns/column-base';
14
+ import { CommandColumnComponent } from '../../../../columns/command-column.component';
15
+ import { isPresent } from '@progress/kendo-angular-common';
13
16
  import * as i0 from "@angular/core";
14
17
  import * as i1 from "@angular/common/http";
15
18
  import * as i2 from "./../../../../common/provider.service";
@@ -34,7 +37,11 @@ export class AiAssistantComponent {
34
37
  currentRequestSubscription = null;
35
38
  //Remove this when the AI Assistant has a built-in loading indicator
36
39
  loadingOutput = { id: 'k-loading-item', output: '', prompt: '' };
40
+ // flat columns used for highlight utilities (expects { field })
37
41
  columns = [];
42
+ leafColumns = [];
43
+ // nested tree representing the actual Grid column components sent to the AI service
44
+ columnsTree = [];
38
45
  idCounter = 0;
39
46
  constructor(http, ctx, columnInfoService) {
40
47
  this.http = http;
@@ -42,7 +49,36 @@ export class AiAssistantComponent {
42
49
  this.columnInfoService = columnInfoService;
43
50
  }
44
51
  ngAfterViewInit() {
45
- this.columns = this.columnInfoService.leafNamedColumns.map((col) => ({ field: col.field }));
52
+ // Build a nested GridColumnDescriptor tree based on the actual Grid columns structure.
53
+ // This includes root columns and their nested children (for ColumnGroup and SpanColumn).
54
+ const rootColumns = this.ctx?.grid?.columnList?.rootColumns() || [];
55
+ const buildDescriptor = (col) => {
56
+ const hasChildren = Boolean(col.hasChildren && col.childrenArray?.length);
57
+ const descriptor = {
58
+ id: col.id,
59
+ field: col.field
60
+ };
61
+ if (hasChildren) {
62
+ descriptor.header = col.displayTitle;
63
+ descriptor.columns = col.childrenArray.map((c) => buildDescriptor(c));
64
+ }
65
+ // For special columns that don't have a field, emit an optional type token
66
+ // so the AI service knows how to treat them (checkbox/command/reorder)
67
+ if (!col.field) {
68
+ if (isCheckboxColumn(col)) {
69
+ descriptor.type = 'checkbox';
70
+ }
71
+ else if (col instanceof CommandColumnComponent) {
72
+ descriptor.type = 'command';
73
+ }
74
+ }
75
+ return descriptor;
76
+ };
77
+ this.columnsTree = rootColumns.map((col) => buildDescriptor(col));
78
+ // Preserve a flat columns array (fields) for highlight utilities.
79
+ // Use leafNamedColumns as the canonical list of leaf columns with display titles.
80
+ this.leafColumns = this.columnInfoService.leafNamedColumns || [];
81
+ this.columns = this.leafColumns.map((col) => ({ field: col.field }));
46
82
  }
47
83
  ngOnDestroy() {
48
84
  this.unsubscribeCurrentRequest();
@@ -66,7 +102,8 @@ export class AiAssistantComponent {
66
102
  this.lastMessage = ev.prompt;
67
103
  }
68
104
  this.requestData = {
69
- columns: this.columns,
105
+ // send nested tree to AI service
106
+ columns: this.columnsTree,
70
107
  promptMessage: ev.prompt,
71
108
  url: this.requestUrl,
72
109
  requestOptions: {
@@ -110,30 +147,22 @@ export class AiAssistantComponent {
110
147
  this.aiToolDirective.emitOpenClose = true;
111
148
  this.aiToolDirective.toggleWindow();
112
149
  }
113
- const responseBody = response.body;
114
- const responseSuccessEvent = new GridToolbarAIResponseSuccessEvent(response);
150
+ const responseBody = response.body || { commands: [] };
151
+ const responseSuccessEvent = new GridAIAssistantResponseSuccessEvent(response);
115
152
  this.aiToolDirective.responseSuccess.emit(responseSuccessEvent);
116
153
  if (responseSuccessEvent.isDefaultPrevented()) {
117
154
  this.deleteLoadingOutput();
118
155
  return;
119
156
  }
120
- const isFilterable = Boolean(this.ctx.grid.filterable);
121
- const isSortable = Boolean(this.ctx.grid.sortable);
122
- const isGroupable = Boolean(this.ctx.grid.groupable);
123
- if (isFilterable && responseBody.filter) {
124
- this.processFilterResponse(responseBody.filter);
125
- }
126
- if (isSortable && responseBody.sort) {
127
- this.processArrayResponse(responseBody.sort, this.ctx.grid.currentState.sort || [], (item) => item.field, (mergedArray) => this.ctx.grid.sortChange.next(mergedArray));
128
- }
129
- if (isGroupable && responseBody.group) {
130
- this.processArrayResponse(responseBody.group, this.ctx.grid.currentState.group || [], (item) => item.field, (mergedArray) => this.ctx.grid.groupChange.next(mergedArray));
131
- }
132
- if (this.ctx.highlightDirective && responseBody.highlight) {
133
- this.processHighlightResponse(responseBody.highlight);
157
+ const messages = [];
158
+ // Include optional top-level message from the response
159
+ if (responseBody.message) {
160
+ messages.push(responseBody.message);
134
161
  }
162
+ // Execute received commands sequentially and collect messages.
163
+ this.processCommands(responseBody.commands || [], messages);
135
164
  const responseContentStart = [`${this.ctx.localization.get('aiAssistantOutputCardBodyContent')} \n`];
136
- const responseContentBody = responseBody.messages
165
+ const responseContentBody = messages
137
166
  .map((output, idx) => `${idx + 1} ${output}`)
138
167
  .join('\n');
139
168
  const output = {
@@ -146,7 +175,7 @@ export class AiAssistantComponent {
146
175
  this.aiToolDirective.promptOutputs.unshift(output);
147
176
  }
148
177
  handleError(error) {
149
- const responseErrorEvent = new GridToolbarAIResponseErrorEvent(error);
178
+ const responseErrorEvent = new GridAIAssistantResponseErrorEvent(error);
150
179
  this.aiToolDirective.responseError.emit(responseErrorEvent);
151
180
  if (responseErrorEvent.isDefaultPrevented()) {
152
181
  this.deleteLoadingOutput();
@@ -183,12 +212,468 @@ export class AiAssistantComponent {
183
212
  updateGrid(mergedArray);
184
213
  }
185
214
  }
186
- processHighlightResponse(highlight) {
187
- if (highlight.length === 0) {
188
- this.ctx.highlightDirective['setState']([]);
215
+ processCommands(commands, messages) {
216
+ if (!commands?.length) {
217
+ return;
218
+ }
219
+ const isFilterable = Boolean(this.ctx.grid.filterable);
220
+ const isSortable = Boolean(this.ctx.grid.sortable);
221
+ const isGroupable = Boolean(this.ctx.grid.groupable);
222
+ const findColumnById = (id) => this.ctx.grid.columnList.toArray().find((c) => c.id === id);
223
+ const updateColumnHierarchy = (column, updater) => {
224
+ const changed = [];
225
+ const queue = [column];
226
+ while (queue.length) {
227
+ const current = queue.shift();
228
+ if (!current) {
229
+ continue;
230
+ }
231
+ const didChange = updater(current);
232
+ if (didChange) {
233
+ changed.push(current);
234
+ }
235
+ if (current.hasChildren && current.childrenArray?.length) {
236
+ queue.push(...current.childrenArray);
237
+ }
238
+ }
239
+ return changed;
240
+ };
241
+ commands.forEach((cmd) => {
242
+ let displayMessage = cmd.message || '';
243
+ if (this.isColumnCommand(cmd.type)) {
244
+ if (cmd.id) {
245
+ const column = findColumnById(cmd.id);
246
+ const replacement = this.getColumnReplacement(column);
247
+ displayMessage = this.replaceQuotedColumnId(displayMessage, replacement);
248
+ }
249
+ }
250
+ messages.push(displayMessage);
251
+ switch (cmd.type) {
252
+ case 'GridSort':
253
+ if (!isSortable) {
254
+ break;
255
+ }
256
+ // cmd.sort is a SortDescriptor - replace or merge with existing sort
257
+ this.processArrayResponse([cmd.sort], this.ctx.grid.currentState.sort || [], (item) => item.field, (mergedArray) => this.ctx.grid.sortChange.next(mergedArray));
258
+ break;
259
+ case 'GridClearSort':
260
+ if (!isSortable) {
261
+ break;
262
+ }
263
+ this.ctx.grid.sortChange.next([]);
264
+ break;
265
+ case 'GridFilter':
266
+ if (!isFilterable) {
267
+ break;
268
+ }
269
+ this.processFilterResponse(cmd.filter);
270
+ break;
271
+ case 'GridClearFilter':
272
+ if (!isFilterable) {
273
+ break;
274
+ }
275
+ this.ctx.grid.filterChange.next(undefined);
276
+ break;
277
+ case 'GridGroup':
278
+ if (!isGroupable) {
279
+ break;
280
+ }
281
+ this.processArrayResponse([cmd.group], this.ctx.grid.currentState.group || [], (item) => item.field, (mergedArray) => this.ctx.grid.groupChange.next(mergedArray));
282
+ break;
283
+ case 'GridClearGroup':
284
+ if (!isGroupable) {
285
+ break;
286
+ }
287
+ this.ctx.grid.groupChange.next([]);
288
+ break;
289
+ case 'GridHighlight':
290
+ if (!this.ctx.highlightDirective) {
291
+ break;
292
+ }
293
+ this.processHighlightResponse([cmd.highlight]);
294
+ break;
295
+ case 'GridClearHighlight':
296
+ if (!this.ctx.highlightDirective) {
297
+ break;
298
+ }
299
+ this.ctx.highlightDirective['setState']([]);
300
+ break;
301
+ case 'GridSelect': {
302
+ this.processSelectionResponse([cmd.select], messages);
303
+ break;
304
+ }
305
+ case 'GridClearSelect': {
306
+ const selectionInstance = this.getSelectionInstance();
307
+ if (!selectionInstance) {
308
+ this.updateLastMessage(messages, this.ctx.localization?.get('aiAssistantSelectionNotEnabled'));
309
+ break;
310
+ }
311
+ this.applySelectionState(selectionInstance, []);
312
+ break;
313
+ }
314
+ case 'GridColumnResize': {
315
+ const col = findColumnById(cmd.id);
316
+ if (!col) {
317
+ break;
318
+ }
319
+ // parse size (accept numeric or strings like '200px')
320
+ let newWidth;
321
+ if (typeof cmd.size === 'number') {
322
+ newWidth = cmd.size;
323
+ }
324
+ else if (typeof cmd.size === 'string') {
325
+ const numericPart = parseFloat(cmd.size);
326
+ if (!isNaN(numericPart)) {
327
+ newWidth = numericPart;
328
+ }
329
+ }
330
+ if (typeof newWidth === 'number') {
331
+ const oldWidth = col.width;
332
+ // set the column width (ColumnBase.width setter handles string -> number)
333
+ col.width = newWidth;
334
+ // emit columnResize event with ColumnResizeArgs[]
335
+ const args = [{ column: col, oldWidth: oldWidth, newWidth: newWidth }];
336
+ this.ctx.grid.columnResize.emit(args);
337
+ }
338
+ break;
339
+ }
340
+ case 'GridColumnReorder': {
341
+ const col = findColumnById(cmd.id);
342
+ if (!col) {
343
+ break;
344
+ }
345
+ const newIndex = Number(cmd.position);
346
+ if (!isNaN(newIndex)) {
347
+ // call grid API to reorder the column - this will trigger columnReorder event internally
348
+ this.ctx.grid.reorderColumn(col, newIndex, { before: true });
349
+ }
350
+ break;
351
+ }
352
+ case 'GridColumnShow':
353
+ case 'GridColumnHide': {
354
+ const col = findColumnById(cmd.id);
355
+ if (!col) {
356
+ break;
357
+ }
358
+ const targetHidden = cmd.type === 'GridColumnHide';
359
+ const changed = updateColumnHierarchy(col, (current) => {
360
+ if (current.hidden === targetHidden) {
361
+ return false;
362
+ }
363
+ current.hidden = targetHidden;
364
+ return true;
365
+ });
366
+ if (changed.length) {
367
+ this.columnInfoService.changeVisibility(changed);
368
+ }
369
+ break;
370
+ }
371
+ case 'GridColumnLock':
372
+ case 'GridColumnUnlock': {
373
+ const col = findColumnById(cmd.id);
374
+ if (!col) {
375
+ break;
376
+ }
377
+ const targetLocked = cmd.type === 'GridColumnLock';
378
+ const changed = updateColumnHierarchy(col, (current) => {
379
+ if (current.locked === targetLocked) {
380
+ return false;
381
+ }
382
+ current.locked = targetLocked;
383
+ return true;
384
+ });
385
+ if (changed.length) {
386
+ this.columnInfoService.changeLocked(changed);
387
+ }
388
+ break;
389
+ }
390
+ case 'GridPage': {
391
+ this.processPageCommand(cmd);
392
+ break;
393
+ }
394
+ case 'GridPageSize': {
395
+ this.processPageSizeCommand(cmd);
396
+ break;
397
+ }
398
+ case 'GridExportExcel': {
399
+ this.runExportWithFileName(this.ctx.excelComponent, cmd.fileName, () => this.ctx.grid.saveAsExcel());
400
+ break;
401
+ }
402
+ case 'GridExportPDF': {
403
+ this.runExportWithFileName(this.ctx.pdfComponent, cmd.fileName, () => this.ctx.grid.saveAsPDF());
404
+ break;
405
+ }
406
+ default:
407
+ // Unknown command - ignore
408
+ break;
409
+ }
410
+ });
411
+ }
412
+ runExportWithFileName(component, fileName, action) {
413
+ if (!component) {
414
+ action();
415
+ return;
416
+ }
417
+ const hasComponentFileName = isPresent(component.fileName) && component.fileName !== '';
418
+ if (hasComponentFileName || !fileName) {
419
+ action();
420
+ return;
421
+ }
422
+ const previousFileName = component.fileName;
423
+ component.fileName = fileName;
424
+ try {
425
+ action();
426
+ }
427
+ finally {
428
+ component.fileName = previousFileName;
429
+ }
430
+ }
431
+ processPageCommand(command) {
432
+ const pageSize = this.getCurrentPageSizeValue();
433
+ if (!isPresent(pageSize) || pageSize <= 0) {
434
+ return;
435
+ }
436
+ const total = this.getTotalItemsCount();
437
+ const requestedPage = Number(command.page);
438
+ let targetPage = Number.isFinite(requestedPage) ? Math.floor(requestedPage) : 1;
439
+ if (targetPage < 1) {
440
+ targetPage = 1;
441
+ }
442
+ if (isPresent(total) && pageSize > 0) {
443
+ const maxPage = Math.max(1, Math.ceil(total / pageSize));
444
+ targetPage = Math.min(targetPage, maxPage);
445
+ }
446
+ const skip = (targetPage - 1) * pageSize;
447
+ this.emitGridPageChange(skip, pageSize);
448
+ }
449
+ processPageSizeCommand(command) {
450
+ const rawPageSize = Number(command.pageSize);
451
+ if (!Number.isFinite(rawPageSize)) {
452
+ return;
453
+ }
454
+ const newPageSize = Math.max(1, Math.floor(rawPageSize));
455
+ const skip = Math.max(0, this.ctx.grid?.skip ?? 0);
456
+ this.ensurePageSizeOption(newPageSize);
457
+ this.emitGridPageChange(skip, newPageSize);
458
+ }
459
+ emitGridPageChange(skip, take) {
460
+ const grid = this.ctx.grid;
461
+ const normalizedSkip = Math.max(0, Math.floor(skip));
462
+ const normalizedTake = Math.max(1, Math.floor(take));
463
+ grid.skip = normalizedSkip;
464
+ grid.pageSize = normalizedTake;
465
+ grid.pageChange.emit({ skip: normalizedSkip, take: normalizedTake });
466
+ }
467
+ ensurePageSizeOption(pageSize) {
468
+ const grid = this.ctx.grid;
469
+ if (!grid) {
189
470
  return;
190
471
  }
191
- const highlightedItems = highlightBy(this.ctx.dataBindingDirective['originalData'], highlight, this.columns);
472
+ const pageable = grid.pageable;
473
+ if (!pageable || typeof pageable === 'boolean') {
474
+ return;
475
+ }
476
+ const pageSizes = pageable.pageSizes;
477
+ if (!Array.isArray(pageSizes) || pageSizes.length === 0) {
478
+ return;
479
+ }
480
+ if (pageSizes.includes(pageSize)) {
481
+ return;
482
+ }
483
+ const uniqueSizes = [pageSize, ...pageSizes.filter(size => size !== pageSize)];
484
+ grid.pageable = {
485
+ ...pageable,
486
+ pageSizes: uniqueSizes
487
+ };
488
+ const changeDetector = grid?.changeDetectorRef;
489
+ if (changeDetector && typeof changeDetector.markForCheck === 'function') {
490
+ changeDetector.markForCheck();
491
+ }
492
+ }
493
+ getCurrentPageSizeValue() {
494
+ const grid = this.ctx.grid;
495
+ if (!grid) {
496
+ return null;
497
+ }
498
+ const candidates = [grid.pageSize, grid.currentState?.take, this.ctx.dataBindingDirective?.['state']?.take];
499
+ for (const candidate of candidates) {
500
+ if (typeof candidate === 'number' && candidate > 0) {
501
+ return candidate;
502
+ }
503
+ }
504
+ const pageable = grid.pageable;
505
+ if (pageable && typeof pageable === 'object' && Array.isArray(pageable.pageSizes)) {
506
+ const numericSize = pageable.pageSizes.find(size => typeof size === 'number' && size > 0);
507
+ if (numericSize) {
508
+ return numericSize;
509
+ }
510
+ }
511
+ const originalData = this.ctx.dataBindingDirective?.['originalData'];
512
+ if (Array.isArray(originalData) && originalData.length > 0) {
513
+ return originalData.length;
514
+ }
515
+ return null;
516
+ }
517
+ getTotalItemsCount() {
518
+ const grid = this.ctx.grid;
519
+ if (!grid) {
520
+ return null;
521
+ }
522
+ const gridData = grid.data;
523
+ if (gridData && typeof gridData.total === 'number') {
524
+ return gridData.total;
525
+ }
526
+ const view = grid.view;
527
+ if (view && typeof view.total === 'number') {
528
+ return view.total;
529
+ }
530
+ const originalData = this.ctx.dataBindingDirective?.['originalData'];
531
+ if (Array.isArray(originalData)) {
532
+ return originalData.length;
533
+ }
534
+ return null;
535
+ }
536
+ getSelectionInstance() {
537
+ const selectionDirective = this.ctx.grid?.selectionDirective;
538
+ if (selectionDirective && typeof selectionDirective === 'object') {
539
+ return selectionDirective;
540
+ }
541
+ const defaultSelection = this.ctx.grid?.defaultSelection;
542
+ if (defaultSelection && typeof defaultSelection === 'object') {
543
+ return defaultSelection;
544
+ }
545
+ return null;
546
+ }
547
+ updateLastMessage(messages, newMessage) {
548
+ if (!messages.length) {
549
+ return;
550
+ }
551
+ messages[messages.length - 1] = newMessage;
552
+ }
553
+ getHighlightItems(descriptors) {
554
+ if (!descriptors?.length) {
555
+ return [];
556
+ }
557
+ const data = this.ctx.dataBindingDirective?.['originalData'] || [];
558
+ return highlightBy(data, descriptors, this.columns);
559
+ }
560
+ processSelectionResponse(selection, messages) {
561
+ const selectionInstance = this.getSelectionInstance();
562
+ if (!selectionInstance) {
563
+ this.updateLastMessage(messages, this.ctx.localization?.get('aiAssistantSelectionNotEnabled'));
564
+ return;
565
+ }
566
+ const descriptors = (selection || []).filter((descriptor) => Boolean(descriptor));
567
+ if (descriptors.length === 0) {
568
+ this.applySelectionState(selectionInstance, []);
569
+ return;
570
+ }
571
+ const highlightItems = this.getHighlightItems(descriptors);
572
+ if (!highlightItems.length) {
573
+ this.applySelectionState(selectionInstance, []);
574
+ return;
575
+ }
576
+ const hasCellSelections = highlightItems.some(item => isPresent(item.columnKey));
577
+ const hasRowSelections = highlightItems.some(item => !isPresent(item.columnKey));
578
+ const isCellMode = selectionInstance.isCellSelectionMode;
579
+ if ((!isCellMode && hasCellSelections) || (isCellMode && hasRowSelections)) {
580
+ const key = isCellMode ? 'aiAssistantSelectionCellModeRequired' : 'aiAssistantSelectionRowModeRequired';
581
+ this.updateLastMessage(messages, this.ctx.localization?.get(key));
582
+ return;
583
+ }
584
+ const selectionState = this.mapHighlightItemsToSelection(selectionInstance, highlightItems, isCellMode);
585
+ this.applySelectionState(selectionInstance, selectionState);
586
+ }
587
+ mapHighlightItemsToSelection(selectionInstance, highlightItems, isCellMode) {
588
+ const data = this.ctx.dataBindingDirective?.['originalData'] || [];
589
+ if (isCellMode) {
590
+ const mapped = highlightItems
591
+ .filter(item => isPresent(item.itemKey) && isPresent(item.columnKey))
592
+ .map(item => {
593
+ const rowIndex = item.itemKey;
594
+ const columnIndex = item.columnKey;
595
+ const dataItem = data[rowIndex];
596
+ if (!isPresent(dataItem)) {
597
+ return null;
598
+ }
599
+ if (typeof selectionInstance['getSelectionItem'] === 'function') {
600
+ const columnComponent = this.leafColumns[columnIndex];
601
+ const selectionItem = selectionInstance['getSelectionItem']({ dataItem, index: rowIndex }, columnComponent, columnIndex);
602
+ if (selectionItem && isPresent(selectionItem.itemKey) && isPresent(selectionItem.columnKey)) {
603
+ return selectionItem;
604
+ }
605
+ return null;
606
+ }
607
+ const itemKey = typeof selectionInstance.getItemKey === 'function'
608
+ ? selectionInstance.getItemKey({ dataItem, index: rowIndex })
609
+ : rowIndex;
610
+ return isPresent(itemKey) ? { itemKey, columnKey: columnIndex } : null;
611
+ })
612
+ .filter((item) => isPresent(item));
613
+ return mapped.filter((item, index, self) => self.findIndex(other => other.itemKey === item.itemKey && other.columnKey === item.columnKey) === index);
614
+ }
615
+ const rowKeys = highlightItems
616
+ .filter(item => isPresent(item.itemKey))
617
+ .map(item => {
618
+ const rowIndex = item.itemKey;
619
+ const dataItem = data[rowIndex];
620
+ if (!isPresent(dataItem)) {
621
+ return null;
622
+ }
623
+ if (typeof selectionInstance.getItemKey === 'function') {
624
+ return selectionInstance.getItemKey({ dataItem, index: rowIndex });
625
+ }
626
+ return rowIndex;
627
+ })
628
+ .filter(isPresent);
629
+ return Array.from(new Set(rowKeys));
630
+ }
631
+ applySelectionState(selectionInstance, selectionState) {
632
+ selectionInstance.selectedKeys = selectionState;
633
+ if (typeof selectionInstance['setState'] === 'function') {
634
+ selectionInstance['setState'](selectionState);
635
+ }
636
+ const changeDetector = selectionInstance['cd'];
637
+ if (changeDetector && typeof changeDetector.markForCheck === 'function') {
638
+ changeDetector.markForCheck();
639
+ }
640
+ if (typeof selectionInstance['notifyChange'] === 'function') {
641
+ selectionInstance['notifyChange']();
642
+ }
643
+ }
644
+ replaceQuotedColumnId(message, replacement) {
645
+ if (!replacement) {
646
+ const columnIdPattern = /(?:&quot;|")(k-grid\d+-col\d+)(?:&quot;|")\s*/g;
647
+ return message.replace(columnIdPattern, '').replace(/\s{2,}/g, ' ').trim();
648
+ }
649
+ const columnIdPattern = /(?:&quot;|")(k-grid\d+-col\d+)(?:&quot;|")/g;
650
+ return message.replace(columnIdPattern, (match) => {
651
+ const isEncoded = match.startsWith('&quot;');
652
+ return isEncoded ? `&quot;${replacement}&quot;` : `"${replacement}"`;
653
+ });
654
+ }
655
+ isColumnCommand(type) {
656
+ return type === 'GridColumnResize' ||
657
+ type === 'GridColumnReorder' ||
658
+ type === 'GridColumnShow' ||
659
+ type === 'GridColumnHide' ||
660
+ type === 'GridColumnLock' ||
661
+ type === 'GridColumnUnlock';
662
+ }
663
+ getColumnReplacement(column) {
664
+ if (!column) {
665
+ return '';
666
+ }
667
+ if (column.title && String(column.title).trim()) {
668
+ return String(column.title).trim();
669
+ }
670
+ if (column.field && String(column.field).trim()) {
671
+ return String(column.field).trim();
672
+ }
673
+ return '';
674
+ }
675
+ processHighlightResponse(highlight) {
676
+ const highlightedItems = this.getHighlightItems(highlight);
192
677
  this.ctx.highlightDirective['setState'](highlightedItems);
193
678
  }
194
679
  processFilterResponse(filter) {
@@ -18,7 +18,7 @@ export const DEFAULT_AI_REQUEST_OPTIONS = {
18
18
  /**
19
19
  * Represents the event data when the AI Assistant request completes successfully.
20
20
  */
21
- export class GridToolbarAIResponseSuccessEvent extends PreventableEvent {
21
+ export class GridAIAssistantResponseSuccessEvent extends PreventableEvent {
22
22
  /**
23
23
  * The HTTP response from the AI service.
24
24
  */
@@ -31,7 +31,7 @@ export class GridToolbarAIResponseSuccessEvent extends PreventableEvent {
31
31
  /**
32
32
  * Represents the event data when the AI Assistant request completes with an error.
33
33
  */
34
- export class GridToolbarAIResponseErrorEvent extends PreventableEvent {
34
+ export class GridAIAssistantResponseErrorEvent extends PreventableEvent {
35
35
  /**
36
36
  * The HTTP error response from the AI service.
37
37
  */