@magic-xpa/angular-material-core 4.1200.0-dev4120.21 → 4.1200.0-dev4120.212

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.
Files changed (23) hide show
  1. package/fesm2022/magic-xpa-angular-material-core.mjs +402 -35
  2. package/fesm2022/magic-xpa-angular-material-core.mjs.map +1 -1
  3. package/index.d.ts +4 -0
  4. package/package.json +6 -8
  5. package/src/angular-material.module.d.ts +24 -15
  6. package/src/components/base-mat-table-magic.component.d.ts +27 -0
  7. package/src/components/editable-combo-component.d.ts +48 -0
  8. package/src/directives/magic/form-controls/mat-magic-autocomplete.directive.d.ts +3 -0
  9. package/src/directives/magic/form-controls/mat-magic-checkbox.directive.d.ts +12 -0
  10. package/src/directives/magic/form-controls/mat-magic-combobox.directive.d.ts +10 -0
  11. package/src/directives/magic/form-controls/mat-magic-listbox.directive.d.ts +7 -0
  12. package/src/services/mat.magic.providers.d.ts +4 -1
  13. package/src/services/mattable.magic.service.d.ts +93 -0
  14. package/esm2022/index.mjs +0 -9
  15. package/esm2022/magic-xpa-angular-material-core.mjs +0 -2
  16. package/esm2022/src/angular-material.module.mjs +0 -83
  17. package/esm2022/src/components/base-mat-table-magic.component.mjs +0 -62
  18. package/esm2022/src/directives/magic/form-controls/mat-magic-autocomplete.directive.mjs +0 -28
  19. package/esm2022/src/directives/magic/form-controls/mat-magic-checkbox.directive.mjs +0 -101
  20. package/esm2022/src/directives/magic/form-controls/mat-magic-combobox.directive.mjs +0 -30
  21. package/esm2022/src/directives/magic/form-controls/mat-magic-listbox.directive.mjs +0 -27
  22. package/esm2022/src/services/mat.magic.providers.mjs +0 -7
  23. package/esm2022/src/services/mattable.magic.service.mjs +0 -138
@@ -1,7 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, Input, HostListener, Injectable, Component, ViewChild, NgModule } from '@angular/core';
2
+ import { Directive, HostListener, Input, Injectable, Component, ViewChild, forwardRef, NgModule } from '@angular/core';
3
+ import * as i2$1 from '@angular/common';
3
4
  import { CommonModule } from '@angular/common';
4
- import { FormsModule } from '@angular/forms';
5
+ import * as i3 from '@angular/forms';
6
+ import { FormGroup, FormControl, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
7
  import * as i1 from '@magic-xpa/angular';
6
8
  import { ComboboxMagicDirective, MagicDirective, TableMagicService, basicMagicProviders, TaskBaseMagicComponent, MagicModule } from '@magic-xpa/angular';
7
9
  import { filter } from 'rxjs/operators';
@@ -14,14 +16,21 @@ import { MatTableDataSource, MatTableModule } from '@angular/material/table';
14
16
  import { SelectionModel } from '@angular/cdk/collections';
15
17
  import { isNullOrUndefined } from '@magic-xpa/mscorelib';
16
18
  import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
19
+ import * as i4 from '@angular/material/input';
17
20
  import { MatInputModule } from '@angular/material/input';
21
+ import * as i5 from '@angular/material/select';
22
+ import { MatSelectModule } from '@angular/material/select';
23
+ import * as i6 from '@angular/material/autocomplete';
24
+ import { MatAutocompleteTrigger, MatAutocomplete } from '@angular/material/autocomplete';
18
25
  import { MatButtonModule } from '@angular/material/button';
19
26
  import { MatListModule } from '@angular/material/list';
20
27
  import { MatTabsModule } from '@angular/material/tabs';
21
- import { MatSelectModule } from '@angular/material/select';
22
28
  import { MatDatepickerModule } from '@angular/material/datepicker';
23
29
  import { MatNativeDateModule } from '@angular/material/core';
24
30
 
31
+ /**
32
+ * Directive for material-design checkboxes not on material-design table
33
+ */
25
34
  class MatCheckboxDirective {
26
35
  magicDirective;
27
36
  matCheckbox;
@@ -30,12 +39,18 @@ class MatCheckboxDirective {
30
39
  threeState = false;
31
40
  subscribeRefreshDom = null;
32
41
  indeterminate = false;
42
+ /**
43
+ * @ignore
44
+ */
33
45
  constructor(magicDirective, matCheckbox, task, element) {
34
46
  this.magicDirective = magicDirective;
35
47
  this.matCheckbox = matCheckbox;
36
48
  this.task = task;
37
49
  this.element = element;
38
50
  }
51
+ /**
52
+ * Handles the Checkbox 'change' event - pass it to the Magic engine
53
+ */
39
54
  onChange($event) {
40
55
  if (this.threeState) {
41
56
  this.handleThreeState();
@@ -89,16 +104,20 @@ class MatCheckboxDirective {
89
104
  this.matCheckbox.checked = true;
90
105
  value = 'checked';
91
106
  }
107
+ // @ts-ignore
92
108
  this.magicDirective.task.onCheckChanged(value, this.magicDirective.id, +this.magicDirective.rowId);
93
109
  }
110
+ /**
111
+ * Cleanup
112
+ */
94
113
  ngOnDestroy() {
95
114
  if (this.subscribeRefreshDom !== null)
96
115
  this.subscribeRefreshDom.unsubscribe();
97
116
  }
98
- static ɵfac = function MatCheckboxDirective_Factory(t) { return new (t || MatCheckboxDirective)(i0.ɵɵdirectiveInject(i1.MagicDirective), i0.ɵɵdirectiveInject(i2.MatCheckbox), i0.ɵɵdirectiveInject(i1.TaskMagicService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
99
- static ɵdir = i0.ɵɵdefineDirective({ type: MatCheckboxDirective, selectors: [["mat-checkbox", "magic", "", 3, "noFormControl", ""]], hostBindings: function MatCheckboxDirective_HostBindings(rf, ctx) { if (rf & 1) {
117
+ /** @nocollapse */ static ɵfac = function MatCheckboxDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MatCheckboxDirective)(i0.ɵɵdirectiveInject(i1.MagicDirective), i0.ɵɵdirectiveInject(i2.MatCheckbox), i0.ɵɵdirectiveInject(i1.TaskMagicService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
118
+ /** @nocollapse */ static ɵdir = /** @pureOrBreakMyCode */ i0.ɵɵdefineDirective({ type: MatCheckboxDirective, selectors: [["mat-checkbox", "magic", "", 3, "noFormControl", ""]], hostBindings: function MatCheckboxDirective_HostBindings(rf, ctx) { if (rf & 1) {
100
119
  i0.ɵɵlistener("change", function MatCheckboxDirective_change_HostBindingHandler($event) { return ctx.onChange($event); });
101
- } }, inputs: { threeState: "threeState" } });
120
+ } }, inputs: { threeState: "threeState" }, standalone: false });
102
121
  }
103
122
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MatCheckboxDirective, [{
104
123
  type: Directive,
@@ -106,6 +125,7 @@ class MatCheckboxDirective {
106
125
  selector: `
107
126
  mat-checkbox[magic]:not([noFormControl])
108
127
  `,
128
+ standalone: false
109
129
  }]
110
130
  }], () => [{ type: i1.MagicDirective }, { type: i2.MatCheckbox }, { type: i1.TaskMagicService }, { type: i0.ElementRef }], { threeState: [{
111
131
  type: Input
@@ -114,24 +134,35 @@ class MatCheckboxDirective {
114
134
  args: ['change', ['$event']]
115
135
  }] }); })();
116
136
 
137
+ /**
138
+ * Directive for material-design comboboxes not on material-design table
139
+ */
117
140
  class MatComboboxDirective extends ComboboxMagicDirective {
141
+ /**
142
+ * Handles the "selectionChange" event - pass it to the "change" event handler
143
+ * @param $event
144
+ */
118
145
  onChange($event) {
119
146
  super.onChange($event);
120
147
  }
121
148
  onOpenedChanged($event) {
122
149
  MagicDirective.opened = $event;
123
150
  }
151
+ /**
152
+ * For mat-select do nothing
153
+ */
124
154
  onComboboxItemsListChanged() {
125
155
  }
126
- static ɵfac = (() => { let ɵMatComboboxDirective_BaseFactory; return function MatComboboxDirective_Factory(t) { return (ɵMatComboboxDirective_BaseFactory || (ɵMatComboboxDirective_BaseFactory = i0.ɵɵgetInheritedFactory(MatComboboxDirective)))(t || MatComboboxDirective); }; })();
127
- static ɵdir = i0.ɵɵdefineDirective({ type: MatComboboxDirective, selectors: [["mat-select", "magic", ""]], hostBindings: function MatComboboxDirective_HostBindings(rf, ctx) { if (rf & 1) {
156
+ /** @nocollapse */ static ɵfac = /** @pureOrBreakMyCode */ (() => { let ɵMatComboboxDirective_BaseFactory; return function MatComboboxDirective_Factory(__ngFactoryType__) { return (ɵMatComboboxDirective_BaseFactory || (ɵMatComboboxDirective_BaseFactory = i0.ɵɵgetInheritedFactory(MatComboboxDirective)))(__ngFactoryType__ || MatComboboxDirective); }; })();
157
+ /** @nocollapse */ static ɵdir = /** @pureOrBreakMyCode */ i0.ɵɵdefineDirective({ type: MatComboboxDirective, selectors: [["mat-select", "magic", ""]], hostBindings: function MatComboboxDirective_HostBindings(rf, ctx) { if (rf & 1) {
128
158
  i0.ɵɵlistener("selectionChange", function MatComboboxDirective_selectionChange_HostBindingHandler($event) { return ctx.onChange($event); })("openedChange", function MatComboboxDirective_openedChange_HostBindingHandler($event) { return ctx.onOpenedChanged($event); });
129
- } }, features: [i0.ɵɵInheritDefinitionFeature] });
159
+ } }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature] });
130
160
  }
131
161
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MatComboboxDirective, [{
132
162
  type: Directive,
133
163
  args: [{
134
164
  selector: `mat-select[magic]`,
165
+ standalone: false
135
166
  }]
136
167
  }], null, { onChange: [{
137
168
  type: HostListener,
@@ -141,63 +172,126 @@ class MatComboboxDirective extends ComboboxMagicDirective {
141
172
  args: ['openedChange', ['$event']]
142
173
  }] }); })();
143
174
 
175
+ /**
176
+ * Extends the Magic table service to supply functionality for Material Design tables
177
+ */
144
178
  class MgMatTableService extends TableMagicService {
145
179
  componentList;
146
180
  task;
181
+ /**
182
+ * Table data source
183
+ */
147
184
  dataSource;
185
+ /**
186
+ * @ignore
187
+ */
148
188
  get DataSource() {
149
189
  return this.dataSource;
150
190
  }
191
+ /**
192
+ * @ignore
193
+ */
151
194
  set DataSource(dataSource) {
152
195
  this.dataSource = dataSource;
153
196
  }
197
+ /**
198
+ * Provides selection options for the table
199
+ */
154
200
  selection;
201
+ /**
202
+ * @ignore
203
+ */
155
204
  get Selection() {
156
205
  return this.selection;
157
206
  }
207
+ /**
208
+ * @ignore
209
+ */
158
210
  set Selection(selection) {
159
211
  this.selection = selection;
160
212
  }
213
+ /**
214
+ * Paginator to enable changing pages in the table
215
+ */
161
216
  paginator;
217
+ /**
218
+ * @ignore
219
+ */
162
220
  get Paginator() {
163
221
  return this.paginator;
164
222
  }
223
+ /**
224
+ * @ignore
225
+ */
165
226
  set Paginator(paginator) {
166
227
  this.paginator = paginator;
167
228
  }
229
+ /**
230
+ * @ignore
231
+ */
168
232
  constructor(componentList, task) {
169
233
  super(componentList, task);
170
234
  this.componentList = componentList;
171
235
  this.task = task;
172
236
  }
237
+ /**
238
+ * Connects the service to the elements of the table component
239
+ * @param dataSource Table data source
240
+ * @param paginator Table paginator
241
+ * @param selection table SelectionModel
242
+ */
173
243
  connect(dataSource, paginator, selection) {
174
244
  this.dataSource = dataSource;
175
245
  this.paginator = paginator;
176
246
  this.selection = selection;
177
247
  }
248
+ /**
249
+ * @ignore
250
+ */
178
251
  refreshDataSource() {
179
252
  if (!isNullOrUndefined(this.paginator))
180
253
  this.dataSource.paginator = this.paginator;
181
254
  this.dataSource.data = (this.task.mgAccessorService.isDataviewEmpty() ? [] : this.task.Records.list);
182
255
  }
256
+ /**
257
+ * returns the page size of the table
258
+ * @returns
259
+ */
183
260
  getPageSize() {
184
261
  if (isNullOrUndefined(this.paginator))
185
262
  return 10;
186
263
  return this.paginator.pageSize;
187
264
  }
265
+ /**
266
+ * Selects a table row
267
+ * @param guiRowid Id of row to be selected
268
+ */
188
269
  selectRow(guiRowid) {
189
270
  super.selectRow(guiRowid);
190
271
  this.selection.select(this.task.Records.list[guiRowid]);
191
272
  this.refreshDataSource();
192
273
  }
274
+ /**
275
+ * Displays the requested table page
276
+ * @param pageId Id of page to be selected
277
+ */
193
278
  selectPage(pageId) {
194
279
  if (!isNullOrUndefined(this.paginator))
195
280
  this.paginator.pageIndex = pageId;
196
281
  this.refreshDataSource();
197
282
  }
283
+ /**
284
+ * Returns the currently seleted row
285
+ * @returns
286
+ */
198
287
  selectedRow() {
199
288
  return this.selection.selected[0];
200
289
  }
290
+ /**
291
+ * Handle the paginator's "page" event
292
+ * @param e The event received from the UI
293
+ * @param changeSelectedRow The flag true or false to indicate change the row
294
+ */
201
295
  mgOnPaginateChange(e, changeSelectedRow) {
202
296
  if (this.task.oldPageSize != e.pageSize) {
203
297
  this.handleResize(e.pageIndex, e.previousPageIndex, e.pageSize);
@@ -220,16 +314,32 @@ class MgMatTableService extends TableMagicService {
220
314
  this.getRowsIfNeeded(e.pageIndex, e.previousPageIndex, e.pageSize);
221
315
  }
222
316
  }
317
+ /**
318
+ * Handle resize and set table top index.
319
+ * @param pageIndex : New page index.
320
+ * @param prevPageIndex : Prev page index
321
+ * @param pageSize : PageSize
322
+ */
223
323
  handleResize(pageIndex, prevPageIndex, pageSize) {
224
324
  let requiredGuiRowId = pageIndex * pageSize;
225
325
  this.task.resize(pageSize, requiredGuiRowId);
226
326
  }
327
+ /**
328
+ * Execute getRows to fetch required chunk of records.
329
+ * @param pageIndex : New page index.
330
+ * @param prevPageIndex : Prev page index
331
+ * @param pageSize : PageSize
332
+ */
227
333
  getRowsIfNeeded(pageIndex, prevPageIndex, pageSize) {
228
334
  let guiEvent = getGuiEventObj("getRows", "", 0);
229
335
  guiEvent.Line = pageIndex * pageSize;
230
336
  this.task.insertEvent(guiEvent);
231
337
  this.setTableTopIndex(this.task.getDvRowId(pageSize * pageIndex));
232
338
  }
339
+ /**
340
+ * Handles the "matSortChange" event
341
+ * @param e The event received from the UI
342
+ */
233
343
  sortData(e) {
234
344
  let direction = 0;
235
345
  if (e.direction === 'asc')
@@ -239,8 +349,13 @@ class MgMatTableService extends TableMagicService {
239
349
  let guiEvent = getGuiEventObj("columnSort", e.active, direction);
240
350
  this.task.insertEvent(guiEvent);
241
351
  }
352
+ /**
353
+ * Change the number of lines in a table
354
+ * @param size New number of lines in table
355
+ */
242
356
  updateTableSize(size) {
243
- if (size === 0) {
357
+ if (size === 0) // never remove row 0 for now
358
+ {
244
359
  size = 1;
245
360
  this.task.Records.clearFirstTableRecord(this.task.template);
246
361
  }
@@ -250,41 +365,76 @@ class MgMatTableService extends TableMagicService {
250
365
  this.task.Records.updateSize(size);
251
366
  this.task.setIncludesFirst(false);
252
367
  }
368
+ /**
369
+ * Handle the selection of row and if needed move to respective page.
370
+ * @param guiRowId New number of lines in table
371
+ */
253
372
  selectPageForGuiRowId(guiRowId) {
254
373
  let pageToBeSelected = 0;
255
374
  let prevSelectedRow = this.selectedRow();
256
375
  pageToBeSelected = Math.floor(guiRowId / this.getPageSize());
376
+ // Explicitly handle selection of page when it's not raised by using pagination
257
377
  if ((isNullOrUndefined(prevSelectedRow) || (!isNullOrUndefined(this.paginator) && pageToBeSelected != this.paginator.pageIndex)))
258
378
  this.selectPage(pageToBeSelected);
259
379
  }
380
+ /**
381
+ * @ignore
382
+ */
260
383
  setTableTopIndex(value) {
261
384
  this.task.Records.setGuiTopIndex(value);
262
385
  if (value >= 0)
263
386
  this.selectPageForGuiRowId(this.task.getGuiRowId(value, true));
264
387
  }
388
+ /**
389
+ * @ignore
390
+ */
265
391
  getTableTopIndex() {
266
392
  return this.task.Records.getGuiTopIndex();
267
393
  }
268
- static ɵfac = function MgMatTableService_Factory(t) { return new (t || MgMatTableService)(i0.ɵɵinject(i1.ComponentListMagicService), i0.ɵɵinject(i1.TaskMagicService)); };
269
- static ɵprov = i0.ɵɵdefineInjectable({ token: MgMatTableService, factory: MgMatTableService.ɵfac });
394
+ /** @nocollapse */ static ɵfac = function MgMatTableService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MgMatTableService)(i0.ɵɵinject(i1.ComponentListMagicService), i0.ɵɵinject(i1.TaskMagicService)); };
395
+ /** @nocollapse */ static ɵprov = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjectable({ token: MgMatTableService, factory: MgMatTableService.ɵfac });
270
396
  }
271
397
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MgMatTableService, [{
272
398
  type: Injectable
273
399
  }], () => [{ type: i1.ComponentListMagicService }, { type: i1.TaskMagicService }], null); })();
274
400
 
401
+ /**
402
+ * @ignore
403
+ */
275
404
  const matMagicProviders = [
276
- ...basicMagicProviders,
405
+ ...basicMagicProviders, // - created error Exported variable 'matMagicProviders' has or is using name 'MagicServices' from external module "D:/magicxpaproject/_Trunk/Sources/Webclient/dist/angular/src/services/magic.services" but cannot be named.
277
406
  { provide: TableMagicService, useClass: MgMatTableService }
278
407
  ];
279
408
 
409
+ /**
410
+ * This component is the base component for forms which has a material-design table (grid)
411
+ */
280
412
  class BaseMatTableMagicComponent extends TaskBaseMagicComponent {
281
413
  ref;
282
414
  magicService;
415
+ /**
416
+ * Paginator to enable changing pages in the table
417
+ */
283
418
  paginator;
419
+ /**
420
+ * Provides the table sort capabilities
421
+ */
284
422
  sort;
423
+ /**
424
+ * List of table columns to be displayed
425
+ */
285
426
  displayedColumns;
427
+ /**
428
+ * Table data source
429
+ */
286
430
  dataSource;
431
+ /**
432
+ * Provides selection options for the table
433
+ */
287
434
  selection;
435
+ /**
436
+ * @ignore
437
+ */
288
438
  constructor(ref, magicService) {
289
439
  super(ref, magicService);
290
440
  this.ref = ref;
@@ -293,10 +443,16 @@ class BaseMatTableMagicComponent extends TaskBaseMagicComponent {
293
443
  this.dataSource = new MatTableDataSource(this.task.Records.list);
294
444
  this.selection = new SelectionModel(false, []);
295
445
  }
446
+ /**
447
+ * Initializer
448
+ */
296
449
  ngOnInit() {
297
450
  super.ngOnInit();
298
451
  this.magicService.tableService.connect(this.dataSource, this.paginator, this.selection);
299
452
  }
453
+ /**
454
+ * AfterContentChecked implementation
455
+ */
300
456
  ngAfterContentChecked() {
301
457
  if (!isNullOrUndefined(this.paginator) && !isNullOrUndefined(this.paginator.pageSize) &&
302
458
  this.paginator.pageSize != this.task.oldPageSize) {
@@ -304,21 +460,22 @@ class BaseMatTableMagicComponent extends TaskBaseMagicComponent {
304
460
  this.task.oldPageSize = this.paginator.pageSize;
305
461
  }
306
462
  }
307
- static ɵfac = function BaseMatTableMagicComponent_Factory(t) { return new (t || BaseMatTableMagicComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i1.MagicServices)); };
308
- static ɵcmp = i0.ɵɵdefineComponent({ type: BaseMatTableMagicComponent, selectors: [["ng-component"]], viewQuery: function BaseMatTableMagicComponent_Query(rf, ctx) { if (rf & 1) {
463
+ /** @nocollapse */ static ɵfac = function BaseMatTableMagicComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BaseMatTableMagicComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i1.MagicServices)); };
464
+ /** @nocollapse */ static ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: BaseMatTableMagicComponent, selectors: [["ng-component"]], viewQuery: function BaseMatTableMagicComponent_Query(rf, ctx) { if (rf & 1) {
309
465
  i0.ɵɵviewQuery(MatPaginator, 7);
310
466
  i0.ɵɵviewQuery(MatSort, 7);
311
467
  } if (rf & 2) {
312
468
  let _t;
313
469
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.paginator = _t.first);
314
470
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.sort = _t.first);
315
- } }, features: [i0.ɵɵProvidersFeature(matMagicProviders), i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseMatTableMagicComponent_Template(rf, ctx) { }, encapsulation: 2 });
471
+ } }, standalone: false, features: [i0.ɵɵProvidersFeature(matMagicProviders), i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseMatTableMagicComponent_Template(rf, ctx) { }, encapsulation: 2 });
316
472
  }
317
473
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMatTableMagicComponent, [{
318
474
  type: Component,
319
475
  args: [{
320
476
  providers: matMagicProviders,
321
- template: ''
477
+ template: '',
478
+ standalone: false
322
479
  }]
323
480
  }], () => [{ type: i0.ChangeDetectorRef }, { type: i1.MagicServices }], { paginator: [{
324
481
  type: ViewChild,
@@ -327,31 +484,205 @@ class BaseMatTableMagicComponent extends TaskBaseMagicComponent {
327
484
  type: ViewChild,
328
485
  args: [MatSort, { static: true }]
329
486
  }] }); })();
330
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BaseMatTableMagicComponent, { className: "BaseMatTableMagicComponent", filePath: "src\\components\\base-mat-table-magic.component.ts", lineNumber: 19 }); })();
487
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BaseMatTableMagicComponent, { className: "BaseMatTableMagicComponent", filePath: "src/components/base-mat-table-magic.component.ts", lineNumber: 19 }); })();
331
488
 
489
+ const _c0 = ["comboinput"];
490
+ function EditableComboComponent_mat_option_6_Template(rf, ctx) { if (rf & 1) {
491
+ i0.ɵɵelementStart(0, "mat-option", 6);
492
+ i0.ɵɵtext(1);
493
+ i0.ɵɵelementEnd();
494
+ } if (rf & 2) {
495
+ const o_r2 = ctx.$implicit;
496
+ i0.ɵɵproperty("value", o_r2.displayValue);
497
+ i0.ɵɵadvance();
498
+ i0.ɵɵtextInterpolate1(" ", o_r2.displayValue, " ");
499
+ } }
500
+ class EditableComboComponent {
501
+ magicServices;
502
+ /**
503
+ * @ignore
504
+ */
505
+ controlId = "";
506
+ rowId = "0";
507
+ combo_input;
508
+ /**
509
+ * @ignore
510
+ */
511
+ set magic(val) {
512
+ this.controlId = val;
513
+ }
514
+ ;
515
+ set rowId1(val) {
516
+ this.rowId = val;
517
+ }
518
+ ;
519
+ placeholder = '';
520
+ formGroup = new FormGroup({});
521
+ // These are the functions required by ControlValueAccessor
522
+ onChange = () => { };
523
+ onTouched = () => { };
524
+ constructor(magicServices) {
525
+ this.magicServices = magicServices;
526
+ }
527
+ /**
528
+ * Returns the Magic accessor service
529
+ * @returns
530
+ */
531
+ get mg() {
532
+ return this.magicServices.mgAccessorService;
533
+ }
534
+ /**
535
+ * Returns the Magic task service
536
+ * @returns
537
+ */
538
+ get task() {
539
+ return this.magicServices.task;
540
+ }
541
+ ngOnInit() {
542
+ this.formGroup.addControl("combo_fc", new FormControl());
543
+ }
544
+ // Write value method will be called when FormControl value is updated
545
+ writeValue(value) {
546
+ if (typeof value == 'number' && value >= 0) {
547
+ const options = this.mg.getItemListValues(this.controlId, this.rowId);
548
+ const matchingOption = options.find(option => option.index === value);
549
+ if (matchingOption != undefined)
550
+ this.formGroup.get("combo_fc")?.setValue(matchingOption.displayValue);
551
+ else
552
+ this.formGroup.get("combo_fc")?.setValue("");
553
+ }
554
+ else
555
+ this.formGroup.get("combo_fc")?.setValue("");
556
+ }
557
+ // Register onChange function to be triggered when the input value changes
558
+ registerOnChange(fn) {
559
+ this.onChange = fn;
560
+ }
561
+ // Register onTouched function to be triggered when the input is touched
562
+ registerOnTouched(fn) {
563
+ this.onTouched = fn;
564
+ }
565
+ // Optional: Handle the touch event when the input is blurred
566
+ onBlur() {
567
+ this.onTouched();
568
+ }
569
+ onOptionSelected(event) {
570
+ const selectedVal = event.option.value;
571
+ const options = this.mg.getItemListValues(this.controlId, this.rowId);
572
+ const matchingOption = options.find(option => option.displayValue === selectedVal);
573
+ let selectedIndex = -1;
574
+ if (matchingOption != undefined)
575
+ selectedIndex = matchingOption.index;
576
+ this.onChange(selectedIndex);
577
+ let guiEvent = getGuiEventObj('selectionchanged', this.controlId, +this.rowId);
578
+ guiEvent.Value = selectedIndex.toString();
579
+ this.task.insertEvent(guiEvent);
580
+ }
581
+ onOpened() {
582
+ MagicDirective.noOfAutoCompleteBoxesOpened++;
583
+ }
584
+ onClosed() {
585
+ this.writeValue(this.mg.getValue(this.controlId, this.rowId));
586
+ MagicDirective.noOfAutoCompleteBoxesOpened--;
587
+ }
588
+ getFilteredListForChoiceControl() {
589
+ const elem = this.combo_input;
590
+ let value = elem ? elem.nativeElement.value : "";
591
+ let items = this.mg.getItemListValues(this.controlId, this.rowId);
592
+ if (value !== null && value !== "" && items instanceof Array) {
593
+ value = value.toLowerCase();
594
+ return items.filter(option => option.displayValue.toLowerCase().includes(value));
595
+ }
596
+ else
597
+ return items;
598
+ }
599
+ /** @nocollapse */ static ɵfac = function EditableComboComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || EditableComboComponent)(i0.ɵɵdirectiveInject(i1.MagicServices)); };
600
+ /** @nocollapse */ static ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: EditableComboComponent, selectors: [["editable-combo"]], viewQuery: function EditableComboComponent_Query(rf, ctx) { if (rf & 1) {
601
+ i0.ɵɵviewQuery(_c0, 5);
602
+ } if (rf & 2) {
603
+ let _t;
604
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.combo_input = _t.first);
605
+ } }, inputs: { magic: "magic", rowId1: [0, "rowId", "rowId1"], placeholder: "placeholder" }, standalone: false, features: [i0.ɵɵProvidersFeature([
606
+ {
607
+ provide: NG_VALUE_ACCESSOR,
608
+ useExisting: forwardRef((() => EditableComboComponent)),
609
+ multi: true
610
+ }
611
+ ])], decls: 7, vars: 4, consts: [["comboinput", ""], ["Editable_Combo", "matAutocomplete"], ["novalidate", "", 3, "formGroup"], ["matInput", "", "formControlName", "combo_fc", 3, "blur", "matAutocomplete", "placeholder"], ["requireSelection", "true", "autoActiveFirstOption", "true", 3, "optionSelected", "closed", "opened"], [3, "value", 4, "ngFor", "ngForOf"], [3, "value"]], template: function EditableComboComponent_Template(rf, ctx) { if (rf & 1) {
612
+ const _r1 = i0.ɵɵgetCurrentView();
613
+ i0.ɵɵelementStart(0, "div", 2)(1, "mat-form-field")(2, "input", 3, 0);
614
+ i0.ɵɵlistener("blur", function EditableComboComponent_Template_input_blur_2_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onBlur()); });
615
+ i0.ɵɵelementEnd();
616
+ i0.ɵɵelementStart(4, "mat-autocomplete", 4, 1);
617
+ i0.ɵɵlistener("optionSelected", function EditableComboComponent_Template_mat_autocomplete_optionSelected_4_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onOptionSelected($event)); })("closed", function EditableComboComponent_Template_mat_autocomplete_closed_4_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onClosed()); })("opened", function EditableComboComponent_Template_mat_autocomplete_opened_4_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onOpened()); });
618
+ i0.ɵɵtemplate(6, EditableComboComponent_mat_option_6_Template, 2, 2, "mat-option", 5);
619
+ i0.ɵɵelementEnd()()();
620
+ } if (rf & 2) {
621
+ const Editable_Combo_r3 = i0.ɵɵreference(5);
622
+ i0.ɵɵproperty("formGroup", ctx.formGroup);
623
+ i0.ɵɵadvance(2);
624
+ i0.ɵɵproperty("matAutocomplete", Editable_Combo_r3)("placeholder", ctx.placeholder);
625
+ i0.ɵɵadvance(4);
626
+ i0.ɵɵproperty("ngForOf", ctx.getFilteredListForChoiceControl());
627
+ } }, dependencies: [i2$1.NgForOf, i3.DefaultValueAccessor, i3.NgControlStatus, i3.NgControlStatusGroup, i4.MatInput, i4.MatFormField, i5.MatOption, i6.MatAutocompleteTrigger, i6.MatAutocomplete, i3.FormGroupDirective, i3.FormControlName], encapsulation: 2 });
628
+ }
629
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EditableComboComponent, [{
630
+ type: Component,
631
+ args: [{ selector: 'editable-combo', standalone: false, providers: [
632
+ {
633
+ provide: NG_VALUE_ACCESSOR,
634
+ useExisting: forwardRef((() => EditableComboComponent)),
635
+ multi: true
636
+ }
637
+ ], template: "<div\n novalidate\n [formGroup]=\"formGroup\"\n>\n <mat-form-field>\n <input\n #comboinput\n matInput\n formControlName=\"combo_fc\"\n [matAutocomplete]=\"Editable_Combo\"\n (blur)=\"onBlur()\"\n [placeholder]=\"placeholder\"\n >\n<!-- <mat-icon matSuffix>arrow_drop_down</mat-icon>-->\n <mat-autocomplete\n #Editable_Combo=\"matAutocomplete\"\n requireSelection=\"true\"\n autoActiveFirstOption=\"true\"\n (optionSelected)=\"onOptionSelected($event)\"\n (closed)=\"onClosed()\"\n (opened)=\"onOpened()\"\n >\n <mat-option\n *ngFor=\"let o of getFilteredListForChoiceControl();\"\n [value]=\"o.displayValue\"\n >\n {{o.displayValue}}\n </mat-option>\n </mat-autocomplete>\n</mat-form-field>\n</div>\n" }]
638
+ }], () => [{ type: i1.MagicServices }], { combo_input: [{
639
+ type: ViewChild,
640
+ args: ['comboinput']
641
+ }], magic: [{
642
+ type: Input,
643
+ args: ['magic']
644
+ }], rowId1: [{
645
+ type: Input,
646
+ args: ['rowId']
647
+ }], placeholder: [{
648
+ type: Input
649
+ }] }); })();
650
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EditableComboComponent, { className: "EditableComboComponent", filePath: "src/components/editable-combo-component.ts", lineNumber: 25 }); })();
651
+
652
+ /**
653
+ * Directive for material-design listboxes not on material-design table
654
+ */
332
655
  class MatListboxDirective {
333
656
  magicDirective;
334
657
  constructor(magicDirective) {
335
658
  this.magicDirective = magicDirective;
336
659
  }
660
+ /**
661
+ * Handles the "selectionChange" event - pass it to the "change" event handler
662
+ * @param $event
663
+ */
337
664
  onChange($event) {
338
665
  this.magicDirective.task.onListBoxSelectionChanged($event, this.magicDirective.id);
339
666
  }
340
- static ɵfac = function MatListboxDirective_Factory(t) { return new (t || MatListboxDirective)(i0.ɵɵdirectiveInject(i1.MagicDirective)); };
341
- static ɵdir = i0.ɵɵdefineDirective({ type: MatListboxDirective, selectors: [["mat-selection-list", "magic", ""]], hostBindings: function MatListboxDirective_HostBindings(rf, ctx) { if (rf & 1) {
667
+ /** @nocollapse */ static ɵfac = function MatListboxDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MatListboxDirective)(i0.ɵɵdirectiveInject(i1.MagicDirective)); };
668
+ /** @nocollapse */ static ɵdir = /** @pureOrBreakMyCode */ i0.ɵɵdefineDirective({ type: MatListboxDirective, selectors: [["mat-selection-list", "magic", ""]], hostBindings: function MatListboxDirective_HostBindings(rf, ctx) { if (rf & 1) {
342
669
  i0.ɵɵlistener("selectionChange", function MatListboxDirective_selectionChange_HostBindingHandler($event) { return ctx.onChange($event); });
343
- } } });
670
+ } }, standalone: false });
344
671
  }
345
672
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MatListboxDirective, [{
346
673
  type: Directive,
347
674
  args: [{
348
675
  selector: `mat-selection-list[magic]`,
676
+ standalone: false
349
677
  }]
350
678
  }], () => [{ type: i1.MagicDirective }], { onChange: [{
351
679
  type: HostListener,
352
680
  args: ['selectionChange', ['$event']]
353
681
  }] }); })();
354
682
 
683
+ /**
684
+ * Directive for material-design autocomplete not on material-design table
685
+ */
355
686
  class MatMagicAutocompleteDirective {
356
687
  onOpenedChanged($event) {
357
688
  MagicDirective.noOfAutoCompleteBoxesOpened++;
@@ -359,15 +690,16 @@ class MatMagicAutocompleteDirective {
359
690
  onClosedChanged($event) {
360
691
  MagicDirective.noOfAutoCompleteBoxesOpened--;
361
692
  }
362
- static ɵfac = function MatMagicAutocompleteDirective_Factory(t) { return new (t || MatMagicAutocompleteDirective)(); };
363
- static ɵdir = i0.ɵɵdefineDirective({ type: MatMagicAutocompleteDirective, selectors: [["mat-autocomplete", "magic", ""]], hostBindings: function MatMagicAutocompleteDirective_HostBindings(rf, ctx) { if (rf & 1) {
693
+ /** @nocollapse */ static ɵfac = function MatMagicAutocompleteDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MatMagicAutocompleteDirective)(); };
694
+ /** @nocollapse */ static ɵdir = /** @pureOrBreakMyCode */ i0.ɵɵdefineDirective({ type: MatMagicAutocompleteDirective, selectors: [["mat-autocomplete", "magic", ""]], hostBindings: function MatMagicAutocompleteDirective_HostBindings(rf, ctx) { if (rf & 1) {
364
695
  i0.ɵɵlistener("opened", function MatMagicAutocompleteDirective_opened_HostBindingHandler($event) { return ctx.onOpenedChanged($event); })("closed", function MatMagicAutocompleteDirective_closed_HostBindingHandler($event) { return ctx.onClosedChanged($event); });
365
- } } });
696
+ } }, standalone: false });
366
697
  }
367
698
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MatMagicAutocompleteDirective, [{
368
699
  type: Directive,
369
700
  args: [{
370
- selector: 'mat-autocomplete[magic]'
701
+ selector: 'mat-autocomplete[magic]',
702
+ standalone: false
371
703
  }]
372
704
  }], null, { onOpenedChanged: [{
373
705
  type: HostListener,
@@ -377,6 +709,9 @@ class MatMagicAutocompleteDirective {
377
709
  args: ['closed', ['$event']]
378
710
  }] }); })();
379
711
 
712
+ /**
713
+ * @ignore
714
+ */
380
715
  const materialModules = [
381
716
  MatTableModule,
382
717
  MatPaginatorModule,
@@ -388,12 +723,28 @@ const materialModules = [
388
723
  MatSelectModule,
389
724
  MatDatepickerModule,
390
725
  MatNativeDateModule,
726
+ MatAutocompleteTrigger,
727
+ MatAutocomplete
391
728
  ];
729
+ /**
730
+ * @ignore
731
+ */
392
732
  class MagicAngularMaterialModule {
393
- static ɵfac = function MagicAngularMaterialModule_Factory(t) { return new (t || MagicAngularMaterialModule)(); };
394
- static ɵmod = i0.ɵɵdefineNgModule({ type: MagicAngularMaterialModule });
395
- static ɵinj = i0.ɵɵdefineInjector({ imports: [CommonModule,
396
- FormsModule, materialModules, MagicModule] });
733
+ /** @nocollapse */ static ɵfac = function MagicAngularMaterialModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MagicAngularMaterialModule)(); };
734
+ /** @nocollapse */ static ɵmod = /** @pureOrBreakMyCode */ i0.ɵɵdefineNgModule({ type: MagicAngularMaterialModule });
735
+ /** @nocollapse */ static ɵinj = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjector({ imports: [CommonModule,
736
+ FormsModule, MatTableModule,
737
+ MatPaginatorModule,
738
+ MatInputModule,
739
+ MatButtonModule,
740
+ MatListModule,
741
+ MatCheckboxModule,
742
+ MatTabsModule,
743
+ MatSelectModule,
744
+ MatDatepickerModule,
745
+ MatNativeDateModule,
746
+ MatAutocomplete, MagicModule,
747
+ ReactiveFormsModule] });
397
748
  }
398
749
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MagicAngularMaterialModule, [{
399
750
  type: NgModule,
@@ -404,19 +755,22 @@ class MagicAngularMaterialModule {
404
755
  MatListboxDirective,
405
756
  MatMagicAutocompleteDirective,
406
757
  BaseMatTableMagicComponent,
758
+ EditableComboComponent
407
759
  ],
408
760
  exports: [
409
761
  MatCheckboxDirective,
410
762
  MatComboboxDirective,
411
763
  MatListboxDirective,
412
764
  MatMagicAutocompleteDirective,
413
- BaseMatTableMagicComponent
765
+ BaseMatTableMagicComponent,
766
+ EditableComboComponent
414
767
  ],
415
768
  imports: [
416
769
  CommonModule,
417
770
  FormsModule,
418
771
  ...materialModules,
419
- MagicModule
772
+ MagicModule,
773
+ ReactiveFormsModule,
420
774
  ]
421
775
  }]
422
776
  }], null, null); })();
@@ -424,7 +778,8 @@ class MagicAngularMaterialModule {
424
778
  MatComboboxDirective,
425
779
  MatListboxDirective,
426
780
  MatMagicAutocompleteDirective,
427
- BaseMatTableMagicComponent], imports: [CommonModule,
781
+ BaseMatTableMagicComponent,
782
+ EditableComboComponent], imports: [CommonModule,
428
783
  FormsModule, MatTableModule,
429
784
  MatPaginatorModule,
430
785
  MatInputModule,
@@ -434,11 +789,23 @@ class MagicAngularMaterialModule {
434
789
  MatTabsModule,
435
790
  MatSelectModule,
436
791
  MatDatepickerModule,
437
- MatNativeDateModule, MagicModule], exports: [MatCheckboxDirective,
792
+ MatNativeDateModule,
793
+ MatAutocompleteTrigger,
794
+ MatAutocomplete, MagicModule,
795
+ ReactiveFormsModule], exports: [MatCheckboxDirective,
438
796
  MatComboboxDirective,
439
797
  MatListboxDirective,
440
798
  MatMagicAutocompleteDirective,
441
- BaseMatTableMagicComponent] }); })();
799
+ BaseMatTableMagicComponent,
800
+ EditableComboComponent] }); })();
801
+
802
+ /**
803
+ * @file Automatically generated by barrelsby.
804
+ */
805
+
806
+ /**
807
+ * Generated bundle index. Do not edit.
808
+ */
442
809
 
443
- export { BaseMatTableMagicComponent, MagicAngularMaterialModule, MatCheckboxDirective, MatComboboxDirective, MatListboxDirective, MatMagicAutocompleteDirective, MgMatTableService, matMagicProviders, materialModules };
810
+ export { BaseMatTableMagicComponent, EditableComboComponent, MagicAngularMaterialModule, MatCheckboxDirective, MatComboboxDirective, MatListboxDirective, MatMagicAutocompleteDirective, MgMatTableService, matMagicProviders, materialModules };
444
811
  //# sourceMappingURL=magic-xpa-angular-material-core.mjs.map