ngx-t-forms 3.1.5 → 3.1.6

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 (103) hide show
  1. package/fesm2022/{ngx-t-forms-api-endpoint-config.component-DLg5vzNJ.mjs → ngx-t-forms-api-endpoint-config.component-Di79aHfa.mjs} +6 -6
  2. package/fesm2022/{ngx-t-forms-api-endpoint-config.component-DLg5vzNJ.mjs.map → ngx-t-forms-api-endpoint-config.component-Di79aHfa.mjs.map} +1 -1
  3. package/fesm2022/{ngx-t-forms-auto-complete-input-element.component-CQ9gB964.mjs → ngx-t-forms-auto-complete-input-element.component-DJ84laIO.mjs} +2 -2
  4. package/fesm2022/{ngx-t-forms-auto-complete-input-element.component-CQ9gB964.mjs.map → ngx-t-forms-auto-complete-input-element.component-DJ84laIO.mjs.map} +1 -1
  5. package/fesm2022/{ngx-t-forms-basic-input-input-element.component-B-J4qO_Z.mjs → ngx-t-forms-basic-input-input-element.component-1wixvEKK.mjs} +3 -3
  6. package/fesm2022/{ngx-t-forms-basic-input-input-element.component-B-J4qO_Z.mjs.map → ngx-t-forms-basic-input-input-element.component-1wixvEKK.mjs.map} +1 -1
  7. package/fesm2022/{ngx-t-forms-calculated-field-rules.component-KHUBx8wM.mjs → ngx-t-forms-calculated-field-rules.component-CMOyxJ4K.mjs} +2 -2
  8. package/fesm2022/{ngx-t-forms-calculated-field-rules.component-KHUBx8wM.mjs.map → ngx-t-forms-calculated-field-rules.component-CMOyxJ4K.mjs.map} +1 -1
  9. package/fesm2022/{ngx-t-forms-chip-options-creator-editor.component-DAZVCoUZ.mjs → ngx-t-forms-chip-options-creator-editor.component-D2LhKaem.mjs} +2 -2
  10. package/fesm2022/{ngx-t-forms-chip-options-creator-editor.component-DAZVCoUZ.mjs.map → ngx-t-forms-chip-options-creator-editor.component-D2LhKaem.mjs.map} +1 -1
  11. package/fesm2022/{ngx-t-forms-conditional-display-config.component-p3dEGx1z.mjs → ngx-t-forms-conditional-display-config.component-DSyIhkWf.mjs} +2 -2
  12. package/fesm2022/{ngx-t-forms-conditional-display-config.component-p3dEGx1z.mjs.map → ngx-t-forms-conditional-display-config.component-DSyIhkWf.mjs.map} +1 -1
  13. package/fesm2022/{ngx-t-forms-config-mscoa-additional-inputs.component-CAk0k2YC.mjs → ngx-t-forms-config-mscoa-additional-inputs.component-DSUAcg8R.mjs} +2 -2
  14. package/fesm2022/{ngx-t-forms-config-mscoa-additional-inputs.component-CAk0k2YC.mjs.map → ngx-t-forms-config-mscoa-additional-inputs.component-DSUAcg8R.mjs.map} +1 -1
  15. package/fesm2022/{ngx-t-forms-data-source-picker.component-CUVjocuE.mjs → ngx-t-forms-data-source-picker.component-h_e5wDIJ.mjs} +6 -6
  16. package/fesm2022/{ngx-t-forms-data-source-picker.component-CUVjocuE.mjs.map → ngx-t-forms-data-source-picker.component-h_e5wDIJ.mjs.map} +1 -1
  17. package/fesm2022/{ngx-t-forms-date-picker-input-element.component-lQfvlGfA.mjs → ngx-t-forms-date-picker-input-element.component-BPoqT0as.mjs} +2 -2
  18. package/fesm2022/{ngx-t-forms-date-picker-input-element.component-lQfvlGfA.mjs.map → ngx-t-forms-date-picker-input-element.component-BPoqT0as.mjs.map} +1 -1
  19. package/fesm2022/{ngx-t-forms-date-range-picker-input-element.component-7t9Ib-35.mjs → ngx-t-forms-date-range-picker-input-element.component-DLeCZF3n.mjs} +2 -2
  20. package/fesm2022/{ngx-t-forms-date-range-picker-input-element.component-7t9Ib-35.mjs.map → ngx-t-forms-date-range-picker-input-element.component-DLeCZF3n.mjs.map} +1 -1
  21. package/fesm2022/{ngx-t-forms-date-time-picker-input-element.component-Co0nzt6l.mjs → ngx-t-forms-date-time-picker-input-element.component-D2kj-knT.mjs} +2 -2
  22. package/fesm2022/{ngx-t-forms-date-time-picker-input-element.component-Co0nzt6l.mjs.map → ngx-t-forms-date-time-picker-input-element.component-D2kj-knT.mjs.map} +1 -1
  23. package/fesm2022/{ngx-t-forms-document-list-label-config-editor.component-xQuX0E3x.mjs → ngx-t-forms-document-list-label-config-editor.component-BvQoKyeP.mjs} +3 -3
  24. package/fesm2022/{ngx-t-forms-document-list-label-config-editor.component-xQuX0E3x.mjs.map → ngx-t-forms-document-list-label-config-editor.component-BvQoKyeP.mjs.map} +1 -1
  25. package/fesm2022/{ngx-t-forms-document-picker.component-umv9Z3rU.mjs → ngx-t-forms-document-picker.component-D0hW0jUu.mjs} +2 -2
  26. package/fesm2022/{ngx-t-forms-document-picker.component-umv9Z3rU.mjs.map → ngx-t-forms-document-picker.component-D0hW0jUu.mjs.map} +1 -1
  27. package/fesm2022/{ngx-t-forms-editor-input-element.component-BHq-LOhI.mjs → ngx-t-forms-editor-input-element.component-DlIfYjsU.mjs} +3 -3
  28. package/fesm2022/{ngx-t-forms-editor-input-element.component-BHq-LOhI.mjs.map → ngx-t-forms-editor-input-element.component-DlIfYjsU.mjs.map} +1 -1
  29. package/fesm2022/{ngx-t-forms-file-upload-input-element.component-DjVntIfw.mjs → ngx-t-forms-file-upload-input-element.component-Dv21OQ8v.mjs} +6 -6
  30. package/fesm2022/{ngx-t-forms-file-upload-input-element.component-DjVntIfw.mjs.map → ngx-t-forms-file-upload-input-element.component-Dv21OQ8v.mjs.map} +1 -1
  31. package/fesm2022/{ngx-t-forms-form-input-selector.component-DX85MMcQ.mjs → ngx-t-forms-form-input-selector.component-HjtfeAew.mjs} +2 -2
  32. package/fesm2022/{ngx-t-forms-form-input-selector.component-DX85MMcQ.mjs.map → ngx-t-forms-form-input-selector.component-HjtfeAew.mjs.map} +1 -1
  33. package/fesm2022/{ngx-t-forms-form-json-view.component-f6QyPY6E.mjs → ngx-t-forms-form-json-view.component-XsTfLIOP.mjs} +2 -2
  34. package/fesm2022/{ngx-t-forms-form-json-view.component-f6QyPY6E.mjs.map → ngx-t-forms-form-json-view.component-XsTfLIOP.mjs.map} +1 -1
  35. package/fesm2022/{ngx-t-forms-form-section-stepper.component-ChaSUCrg.mjs → ngx-t-forms-form-section-stepper.component-DF3-s7Ou.mjs} +4 -4
  36. package/fesm2022/{ngx-t-forms-form-section-stepper.component-ChaSUCrg.mjs.map → ngx-t-forms-form-section-stepper.component-DF3-s7Ou.mjs.map} +1 -1
  37. package/fesm2022/{ngx-t-forms-forms-builder-menu.component-Qkw23Bzy.mjs → ngx-t-forms-forms-builder-menu.component-D_As34Ib.mjs} +4 -4
  38. package/fesm2022/{ngx-t-forms-forms-builder-menu.component-Qkw23Bzy.mjs.map → ngx-t-forms-forms-builder-menu.component-D_As34Ib.mjs.map} +1 -1
  39. package/fesm2022/{ngx-t-forms-geo-location.component-DqYEmeLs.mjs → ngx-t-forms-geo-location.component-BGg8uGQV.mjs} +2 -2
  40. package/fesm2022/{ngx-t-forms-geo-location.component-DqYEmeLs.mjs.map → ngx-t-forms-geo-location.component-BGg8uGQV.mjs.map} +1 -1
  41. package/fesm2022/{ngx-t-forms-header-template-editor.component-CIft152I.mjs → ngx-t-forms-header-template-editor.component-D78_YC80.mjs} +2 -2
  42. package/fesm2022/{ngx-t-forms-header-template-editor.component-CIft152I.mjs.map → ngx-t-forms-header-template-editor.component-D78_YC80.mjs.map} +1 -1
  43. package/fesm2022/{ngx-t-forms-image-capture-input-element.component-BmVXoC_z.mjs → ngx-t-forms-image-capture-input-element.component-B2ldh1-n.mjs} +2 -2
  44. package/fesm2022/{ngx-t-forms-image-capture-input-element.component-BmVXoC_z.mjs.map → ngx-t-forms-image-capture-input-element.component-B2ldh1-n.mjs.map} +1 -1
  45. package/fesm2022/{ngx-t-forms-index-yasuBvXP.mjs → ngx-t-forms-index-CerXcX5U.mjs} +2 -2
  46. package/fesm2022/ngx-t-forms-index-CerXcX5U.mjs.map +1 -0
  47. package/fesm2022/{ngx-t-forms-input-custom.component-CTye_tsv.mjs → ngx-t-forms-input-custom.component-BrZ59sIz.mjs} +2 -2
  48. package/fesm2022/{ngx-t-forms-input-custom.component-CTye_tsv.mjs.map → ngx-t-forms-input-custom.component-BrZ59sIz.mjs.map} +1 -1
  49. package/fesm2022/{ngx-t-forms-input-editor.component-DbhnFkYQ.mjs → ngx-t-forms-input-editor.component-B5eMJWrz.mjs} +3 -3
  50. package/fesm2022/{ngx-t-forms-input-editor.component-DbhnFkYQ.mjs.map → ngx-t-forms-input-editor.component-B5eMJWrz.mjs.map} +1 -1
  51. package/fesm2022/{ngx-t-forms-map-mat-options-keys-B49fcbzx.mjs → ngx-t-forms-map-mat-options-keys-BOX1dYlB.mjs} +2 -2
  52. package/fesm2022/{ngx-t-forms-map-mat-options-keys-B49fcbzx.mjs.map → ngx-t-forms-map-mat-options-keys-BOX1dYlB.mjs.map} +1 -1
  53. package/fesm2022/{ngx-t-forms-mat-chip-list-editor.component-C0iLh1ON.mjs → ngx-t-forms-mat-chip-list-editor.component-lv4MlFT8.mjs} +2 -2
  54. package/fesm2022/{ngx-t-forms-mat-chip-list-editor.component-C0iLh1ON.mjs.map → ngx-t-forms-mat-chip-list-editor.component-lv4MlFT8.mjs.map} +1 -1
  55. package/fesm2022/{ngx-t-forms-missing-form-configs.component-BsX7Ezy-.mjs → ngx-t-forms-missing-form-configs.component-DV55dGC2.mjs} +2 -2
  56. package/fesm2022/{ngx-t-forms-missing-form-configs.component-BsX7Ezy-.mjs.map → ngx-t-forms-missing-form-configs.component-DV55dGC2.mjs.map} +1 -1
  57. package/fesm2022/{ngx-t-forms-mscoa-chart-toolbar.component-D8GL9Aht.mjs → ngx-t-forms-mscoa-chart-toolbar.component-C9hD1Cnq.mjs} +2 -2
  58. package/fesm2022/{ngx-t-forms-mscoa-chart-toolbar.component-D8GL9Aht.mjs.map → ngx-t-forms-mscoa-chart-toolbar.component-C9hD1Cnq.mjs.map} +1 -1
  59. package/fesm2022/{ngx-t-forms-mscoa-config.component-Sz8VZ-vc.mjs → ngx-t-forms-mscoa-config.component-BqgTVHRS.mjs} +6 -6
  60. package/fesm2022/{ngx-t-forms-mscoa-config.component-Sz8VZ-vc.mjs.map → ngx-t-forms-mscoa-config.component-BqgTVHRS.mjs.map} +1 -1
  61. package/fesm2022/{ngx-t-forms-mscoa-segment-config.component-COepe5G2.mjs → ngx-t-forms-mscoa-segment-config.component-7w9J1RgE.mjs} +2 -2
  62. package/fesm2022/{ngx-t-forms-mscoa-segment-config.component-COepe5G2.mjs.map → ngx-t-forms-mscoa-segment-config.component-7w9J1RgE.mjs.map} +1 -1
  63. package/fesm2022/ngx-t-forms-multiple-input-input-element.component-BbbRpwPw.mjs +2336 -0
  64. package/fesm2022/ngx-t-forms-multiple-input-input-element.component-BbbRpwPw.mjs.map +1 -0
  65. package/fesm2022/{ngx-t-forms-ngx-t-forms-B3WhBGlD.mjs → ngx-t-forms-ngx-t-forms-XLA9yzak.mjs} +1230 -139
  66. package/fesm2022/ngx-t-forms-ngx-t-forms-XLA9yzak.mjs.map +1 -0
  67. package/fesm2022/{ngx-t-forms-paginated-selection-table-CILBCL4K.mjs → ngx-t-forms-paginated-selection-table-DisWM3sL.mjs} +2 -2
  68. package/fesm2022/{ngx-t-forms-paginated-selection-table-CILBCL4K.mjs.map → ngx-t-forms-paginated-selection-table-DisWM3sL.mjs.map} +1 -1
  69. package/fesm2022/{ngx-t-forms-payload-template-editor.component-C8OasgK7.mjs → ngx-t-forms-payload-template-editor.component-DM4-3jzA.mjs} +2 -2
  70. package/fesm2022/{ngx-t-forms-payload-template-editor.component-C8OasgK7.mjs.map → ngx-t-forms-payload-template-editor.component-DM4-3jzA.mjs.map} +1 -1
  71. package/fesm2022/{ngx-t-forms-pipeline-generator.component-_yowsgF6.mjs → ngx-t-forms-pipeline-generator.component-Bc8En673.mjs} +2 -2
  72. package/fesm2022/{ngx-t-forms-pipeline-generator.component-_yowsgF6.mjs.map → ngx-t-forms-pipeline-generator.component-Bc8En673.mjs.map} +1 -1
  73. package/fesm2022/{ngx-t-forms-quill-input.component-BWq5cLY-.mjs → ngx-t-forms-quill-input.component-CN3aorpW.mjs} +2 -2
  74. package/fesm2022/{ngx-t-forms-quill-input.component-BWq5cLY-.mjs.map → ngx-t-forms-quill-input.component-CN3aorpW.mjs.map} +1 -1
  75. package/fesm2022/{ngx-t-forms-record-list-manager.component-C-lAzlO-.mjs → ngx-t-forms-record-list-manager.component-CpyrWNo5.mjs} +2 -2
  76. package/fesm2022/{ngx-t-forms-record-list-manager.component-C-lAzlO-.mjs.map → ngx-t-forms-record-list-manager.component-CpyrWNo5.mjs.map} +1 -1
  77. package/fesm2022/{ngx-t-forms-required-inputs.component-8cQr2QWm.mjs → ngx-t-forms-required-inputs.component-CtUXVAvg.mjs} +2 -2
  78. package/fesm2022/{ngx-t-forms-required-inputs.component-8cQr2QWm.mjs.map → ngx-t-forms-required-inputs.component-CtUXVAvg.mjs.map} +1 -1
  79. package/fesm2022/{ngx-t-forms-rest-api-call-setup.component-Bhj9jcQk.mjs → ngx-t-forms-rest-api-call-setup.component-a4z2V-a1.mjs} +2 -2
  80. package/fesm2022/{ngx-t-forms-rest-api-call-setup.component-Bhj9jcQk.mjs.map → ngx-t-forms-rest-api-call-setup.component-a4z2V-a1.mjs.map} +1 -1
  81. package/fesm2022/{ngx-t-forms-section-report.component-CWCqrc7k.mjs → ngx-t-forms-section-report.component-D-FE0aL3.mjs} +2 -2
  82. package/fesm2022/{ngx-t-forms-section-report.component-CWCqrc7k.mjs.map → ngx-t-forms-section-report.component-D-FE0aL3.mjs.map} +1 -1
  83. package/fesm2022/{ngx-t-forms-select-input-element.component-BGD67Dnh.mjs → ngx-t-forms-select-input-element.component-Bwlqr26x.mjs} +2 -2
  84. package/fesm2022/{ngx-t-forms-select-input-element.component-BGD67Dnh.mjs.map → ngx-t-forms-select-input-element.component-Bwlqr26x.mjs.map} +1 -1
  85. package/fesm2022/{ngx-t-forms-selection-options-editor.component-ClXaOeXt.mjs → ngx-t-forms-selection-options-editor.component-BfaTlXQU.mjs} +2 -2
  86. package/fesm2022/{ngx-t-forms-selection-options-editor.component-ClXaOeXt.mjs.map → ngx-t-forms-selection-options-editor.component-BfaTlXQU.mjs.map} +1 -1
  87. package/fesm2022/{ngx-t-forms-textarea-input-element.component-Z-wkFzgQ.mjs → ngx-t-forms-textarea-input-element.component-B35jrn-j.mjs} +2 -2
  88. package/fesm2022/{ngx-t-forms-textarea-input-element.component-Z-wkFzgQ.mjs.map → ngx-t-forms-textarea-input-element.component-B35jrn-j.mjs.map} +1 -1
  89. package/fesm2022/{ngx-t-forms-toggle-input-element.component-CvR3-IjP.mjs → ngx-t-forms-toggle-input-element.component-Cku3HoDl.mjs} +2 -2
  90. package/fesm2022/{ngx-t-forms-toggle-input-element.component-CvR3-IjP.mjs.map → ngx-t-forms-toggle-input-element.component-Cku3HoDl.mjs.map} +1 -1
  91. package/fesm2022/{ngx-t-forms-token-text-input.component-vnOkP_CV.mjs → ngx-t-forms-token-text-input.component-B1I95sk3.mjs} +2 -2
  92. package/fesm2022/{ngx-t-forms-token-text-input.component-vnOkP_CV.mjs.map → ngx-t-forms-token-text-input.component-B1I95sk3.mjs.map} +1 -1
  93. package/fesm2022/{ngx-t-forms-validators-config.component-DhuB7c63.mjs → ngx-t-forms-validators-config.component-yq3EGgU2.mjs} +2 -2
  94. package/fesm2022/{ngx-t-forms-validators-config.component-DhuB7c63.mjs.map → ngx-t-forms-validators-config.component-yq3EGgU2.mjs.map} +1 -1
  95. package/fesm2022/{ngx-t-forms-workflow-adjudication.component-Dc4r01D7.mjs → ngx-t-forms-workflow-adjudication.component-CZZX1hYU.mjs} +5 -5
  96. package/fesm2022/{ngx-t-forms-workflow-adjudication.component-Dc4r01D7.mjs.map → ngx-t-forms-workflow-adjudication.component-CZZX1hYU.mjs.map} +1 -1
  97. package/fesm2022/ngx-t-forms.mjs +1 -1
  98. package/package.json +2 -2
  99. package/types/ngx-t-forms.d.ts +484 -13
  100. package/fesm2022/ngx-t-forms-index-yasuBvXP.mjs.map +0 -1
  101. package/fesm2022/ngx-t-forms-multiple-input-input-element.component-DlgTjJpj.mjs +0 -909
  102. package/fesm2022/ngx-t-forms-multiple-input-input-element.component-DlgTjJpj.mjs.map +0 -1
  103. package/fesm2022/ngx-t-forms-ngx-t-forms-B3WhBGlD.mjs.map +0 -1
@@ -0,0 +1,2336 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, output, inject, DestroyRef, ViewContainerRef, Injector, signal, computed, viewChild, ElementRef, effect, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component, PLATFORM_ID, Injectable, ErrorHandler } from '@angular/core';
3
+ import * as i1$2 from '@angular/forms';
4
+ import { NgControl, ReactiveFormsModule } from '@angular/forms';
5
+ import * as i2$1 from '@angular/material/form-field';
6
+ import { MatFormFieldControl, MatFormFieldModule } from '@angular/material/form-field';
7
+ import * as i3 from '@angular/material/icon';
8
+ import { MatIconModule } from '@angular/material/icon';
9
+ import * as i2 from '@angular/material/button';
10
+ import { MatButtonModule } from '@angular/material/button';
11
+ import * as i5$1 from '@angular/material/tooltip';
12
+ import { MatTooltipModule } from '@angular/material/tooltip';
13
+ import { c as TDynamicDataViewComponent, Y as TFormInputComponent, a5 as calculateListOveralFunctions, a4 as resolveDateRangeControlNames, a6 as multipleInputRowIdKey, a7 as SPREADSHEET_WRITER, a8 as SPREADSHEET_PARSER, a9 as TFormImportController, aa as isMultiSelectInput, ab as applyOptionChoice, ac as normaliseOptionText, B as BaseCustomInput, _ as _isEqual, a2 as getInputErrorMessage, a3 as TFormInputStatusComponent } from './ngx-t-forms-ngx-t-forms-XLA9yzak.mjs';
14
+ import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
15
+ import * as i5 from '@angular/material/table';
16
+ import { MatTableDataSource, MatTableModule } from '@angular/material/table';
17
+ import * as i1$1 from '@angular/material/dialog';
18
+ import { MatDialog, MAT_DIALOG_DATA, MatDialogRef, MatDialogModule } from '@angular/material/dialog';
19
+ import * as i6 from '@angular/material/menu';
20
+ import { MatMenuModule } from '@angular/material/menu';
21
+ import { DocumentLitsLabelConfigInterfaceValueType, InputDataTypes, MultipleInputAvailableOperations, CalculationFunctions, ElementTypes, InputTypes } from 'ngx-t-forms-types';
22
+ import { CdkConnectedOverlay } from '@angular/cdk/overlay';
23
+ import * as i4 from '@angular/material/chips';
24
+ import { MatChipsModule } from '@angular/material/chips';
25
+ import * as i3$1 from '@angular/material/paginator';
26
+ import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
27
+ import * as i4$1 from '@angular/material/progress-bar';
28
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
29
+ import * as i4$2 from '@angular/material/progress-spinner';
30
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
31
+ import * as i3$2 from '@angular/common';
32
+ import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';
33
+ import * as i3$3 from '@angular/material/card';
34
+ import { MatCardModule } from '@angular/material/card';
35
+ import { MatDividerModule } from '@angular/material/divider';
36
+ import * as i1 from '@angular/cdk/drag-drop';
37
+ import { DragDropModule } from '@angular/cdk/drag-drop';
38
+ import { Subject, timer, tap, takeUntil } from 'rxjs';
39
+ import { v4 } from 'uuid';
40
+ import * as i6$1 from '@angular/material/list';
41
+
42
+ class ColorScale {
43
+ constructor(min, max, colorStops, alpha = 1) {
44
+ validateMinMaxValues(min, max);
45
+ validateColorStops(colorStops);
46
+ validateAlphaValue(alpha);
47
+ this.min = min;
48
+ this.max = max;
49
+ this.alpha = alpha;
50
+ this.colorStops = colorStops.map((colorStop) => hexToColor(colorStop, alpha));
51
+ }
52
+ getColor(value) {
53
+ const numOfColorStops = this.colorStops.length;
54
+ if (value < this.min)
55
+ return this.colorStops[0];
56
+ if (value > this.max)
57
+ return this.colorStops[numOfColorStops - 1];
58
+ const range = this.max - this.min;
59
+ let weight = (value - this.min) / range;
60
+ const colorStopIndex = Math.max(Math.ceil(weight * (numOfColorStops - 1)), 1);
61
+ const minColor = this.colorStops[colorStopIndex - 1];
62
+ const maxColor = this.colorStops[colorStopIndex];
63
+ if (maxColor === undefined)
64
+ return minColor;
65
+ if (minColor === undefined)
66
+ return maxColor;
67
+ weight = weight * (numOfColorStops - 1) - (colorStopIndex - 1);
68
+ const r = Math.floor(weight * maxColor.r + (1 - weight) * minColor.r);
69
+ const g = Math.floor(weight * maxColor.g + (1 - weight) * minColor.g);
70
+ const b = Math.floor(weight * maxColor.b + (1 - weight) * minColor.b);
71
+ return new Color(r, g, b, this.alpha);
72
+ }
73
+ }
74
+ function validateMinMaxValues(min, max) {
75
+ if (min > max) {
76
+ throw new Error('The minimum value must be less than the maximum value.');
77
+ }
78
+ }
79
+ function validateColorStops(colorStops) {
80
+ if (colorStops.length < 2) {
81
+ throw new Error('At least two colors must be provided.');
82
+ }
83
+ colorStops.forEach((str) => {
84
+ if (!isValidHexColor(str)) {
85
+ throw new Error(`${str} is not a valid hex color.`);
86
+ }
87
+ });
88
+ }
89
+ function validateAlphaValue(alpha) {
90
+ if (alpha < 0 || alpha > 1) {
91
+ throw new Error('The alpha value must be between 0 and 1.');
92
+ }
93
+ }
94
+ function hexToColor(hex, alpha) {
95
+ if (isValid3DigitHexColor(hex)) {
96
+ hex = convertTo6DigitHexColor(hex);
97
+ }
98
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
99
+ if (!!result?.[1] && !!result?.[2] && !!result?.[3]) {
100
+ return new Color(parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), alpha);
101
+ }
102
+ else {
103
+ throw new Error(`${hex} is not a valid hex color.`);
104
+ }
105
+ }
106
+ function isValidHexColor(colorString) {
107
+ return (isValid3DigitHexColor(colorString) || isValid6DigitHexColor(colorString));
108
+ }
109
+ function isValid3DigitHexColor(colorString) {
110
+ const hexColorRegex = /^#(?:[0-9a-fA-F]{3})$/;
111
+ return colorString.match(hexColorRegex);
112
+ }
113
+ function isValid6DigitHexColor(colorString) {
114
+ const hexColorRegex = /^#(?:[0-9a-fA-F]{6})$/;
115
+ return colorString.match(hexColorRegex);
116
+ }
117
+ function convertTo6DigitHexColor(threeDigitHex) {
118
+ return threeDigitHex
119
+ .substring(1)
120
+ .split('')
121
+ .map((char) => {
122
+ return char + char;
123
+ })
124
+ .join('');
125
+ }
126
+ function componentToHex(c) {
127
+ const hex = c.toString(16);
128
+ return hex.length === 1 ? '0' + hex : hex;
129
+ }
130
+ function rgbaToHex(color) {
131
+ const r = Math.floor(color.r * color.a);
132
+ const g = Math.floor(color.g * color.a);
133
+ const b = Math.floor(color.b * color.a);
134
+ return `#${componentToHex(r)}${componentToHex(g)}${componentToHex(b)}`;
135
+ }
136
+ class Color {
137
+ constructor(r, g, b, a = 1) {
138
+ validateAlphaValue(a);
139
+ this.r = r;
140
+ this.g = g;
141
+ this.b = b;
142
+ this.a = a;
143
+ }
144
+ toRGBString() {
145
+ return `rgb(${Math.floor(this.r * this.a)},${Math.floor(this.g * this.a)},${Math.floor(this.b * this.a)})`;
146
+ }
147
+ toRGBAString() {
148
+ return `rgba(${this.r},${this.g},${this.b},${this.a})`;
149
+ }
150
+ toHexString() {
151
+ return rgbaToHex(this);
152
+ }
153
+ }
154
+
155
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
+ function configureCols(inputConfig, tempLabels) {
157
+ try {
158
+ const labelInputs = (inputConfig?.formInputs || []).filter(input => input.showAsLabel || tempLabels.includes(input.formControlName));
159
+ const cols = [];
160
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
161
+ const colConfigs = {};
162
+ for (let index = 0; index < (labelInputs).length; index++) {
163
+ const c = labelInputs[index];
164
+ const col = { ...c };
165
+ cols.push(`${inputConfig.id}.${col.id}`);
166
+ if (!col.id) {
167
+ continue;
168
+ }
169
+ colConfigs[`${inputConfig.id}.${col.id}`] = {
170
+ property: `${inputConfig.id}.${col.id}`,
171
+ formControlName: col.formControlName,
172
+ label: col.label,
173
+ dataType: getDataType(col)
174
+ };
175
+ }
176
+ //add remove section config
177
+ cols.push('itemRemovalButton');
178
+ colConfigs['itemRemovalButton'] = {
179
+ property: 'itemRemovalButton',
180
+ label: '',
181
+ type: 'removal',
182
+ };
183
+ // end
184
+ return {
185
+ displayedColumnsInOrder: cols.filter((c) => !!c),
186
+ columnsConfig: colConfigs
187
+ };
188
+ }
189
+ catch (error) {
190
+ const message = error instanceof Error ? error.message : 'Failed to configure columns';
191
+ throw new Error(message);
192
+ }
193
+ }
194
+ function getDataType(input) {
195
+ try {
196
+ if (input.pipe?.pipeType) {
197
+ return input.pipe.pipeType;
198
+ }
199
+ const inputDataType = input.dataType;
200
+ switch (inputDataType) {
201
+ case InputDataTypes.Number:
202
+ return DocumentLitsLabelConfigInterfaceValueType.number;
203
+ case InputDataTypes.Date:
204
+ return DocumentLitsLabelConfigInterfaceValueType.date;
205
+ case InputDataTypes.Array:
206
+ return InputDataTypes.Array;
207
+ case InputDataTypes.Boolean:
208
+ return InputDataTypes.Boolean;
209
+ case InputDataTypes.Object:
210
+ return InputDataTypes.Object;
211
+ default:
212
+ return DocumentLitsLabelConfigInterfaceValueType.string;
213
+ }
214
+ }
215
+ catch (error) {
216
+ const msg = error instanceof Error ? error.message : 'Failed to get data type';
217
+ throw new Error(msg);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Relative-age labels for the table's "opened" column.
223
+ *
224
+ * A long list is edited row by row, and the single question the author keeps asking is *have I
225
+ * already been in this one?* The column answers it in the smallest amount of ink that can:
226
+ * a two-or-three character token in the row, and the full sentence in its tooltip.
227
+ *
228
+ * Pure and Angular-free so the thresholds can be tested directly — the component only supplies
229
+ * the elapsed milliseconds.
230
+ */
231
+ const SECOND = 1000;
232
+ const MINUTE = 60 * SECOND;
233
+ const HOUR = 60 * MINUTE;
234
+ const DAY = 24 * HOUR;
235
+ const WEEK = 7 * DAY;
236
+ const YEAR = 365 * DAY;
237
+ /**
238
+ * Anything fresher than this reads as "now". A whole minute exactly, so the minutes branch below
239
+ * can never produce a bare `0m` — the first token after "now" is always `1m`.
240
+ */
241
+ const JUST_NOW = MINUTE;
242
+ /** `1 minute` / `4 minutes` — the tooltip is a sentence, so it agrees in number. */
243
+ function plural(count, unit) {
244
+ return `${count} ${unit}${count === 1 ? '' : 's'} ago`;
245
+ }
246
+ /**
247
+ * Formats how long ago a row was opened.
248
+ *
249
+ * @param elapsedMs milliseconds since the row was last opened. A negative value (a clock that
250
+ * moved backwards) is treated as zero rather than rendering a future age.
251
+ *
252
+ * @example
253
+ * openedAgo(0); // { short: 'now', long: 'Opened just now' }
254
+ * openedAgo(7 * 60_000); // { short: '7m', long: 'Opened 7 minutes ago' }
255
+ */
256
+ function openedAgo(elapsedMs) {
257
+ const elapsed = Number.isFinite(elapsedMs) ? Math.max(elapsedMs, 0) : 0;
258
+ if (elapsed < JUST_NOW) {
259
+ return { short: 'now', long: 'Opened just now' };
260
+ }
261
+ if (elapsed < HOUR) {
262
+ const minutes = Math.floor(elapsed / MINUTE);
263
+ return { short: `${minutes}m`, long: `Opened ${plural(minutes, 'minute')}` };
264
+ }
265
+ if (elapsed < DAY) {
266
+ const hours = Math.floor(elapsed / HOUR);
267
+ return { short: `${hours}h`, long: `Opened ${plural(hours, 'hour')}` };
268
+ }
269
+ if (elapsed < WEEK) {
270
+ const days = Math.floor(elapsed / DAY);
271
+ return { short: `${days}d`, long: `Opened ${plural(days, 'day')}` };
272
+ }
273
+ if (elapsed < YEAR) {
274
+ const weeks = Math.floor(elapsed / WEEK);
275
+ return { short: `${weeks}w`, long: `Opened ${plural(weeks, 'week')}` };
276
+ }
277
+ const years = Math.floor(elapsed / YEAR);
278
+ return { short: `${years}y`, long: `Opened ${plural(years, 'year')}` };
279
+ }
280
+
281
+ /** Column key `configureCols` appends for the row-actions cell. */
282
+ const ACTIONS_COLUMN = 'itemRemovalButton';
283
+ /**
284
+ * Column key for the leading row-number column. Data columns are always `${parentId}.${inputId}`,
285
+ * so a key with no dot in it can never collide with one.
286
+ */
287
+ const INDEX_COLUMN = 'mitRowNumber';
288
+ /** Column key for the trailing "last opened" column. Same collision argument as {@link INDEX_COLUMN}. */
289
+ const OPENED_COLUMN = 'mitLastOpened';
290
+ /**
291
+ * How often the relative "opened" labels are re-rendered. Half a minute keeps `now` -> `1m` honest
292
+ * without the table repainting for no reason; the interval only runs once a row has been opened.
293
+ */
294
+ const OPENED_TICK_MS = 30_000;
295
+ /** Row key marking a calculation (total / average / …) row appended by `getCaluculatedTableData`. */
296
+ const CALCULATION_KEY = 'SYSTEM_KEY_PROPERTY_FOR_MULTIPLE_INPUTS_CALCULATION_FUNCTION';
297
+ /** Row key a host may set to flag the row currently open in the editor. */
298
+ const IN_EDIT_KEY = 'SYSTEM_KEY_IN_EDIT';
299
+ /** Page sizes offered by the paginator. */
300
+ const PAGE_SIZE_OPTIONS = [5, 10, 25, 50];
301
+ /** Rows per page before the user picks otherwise. */
302
+ const DEFAULT_PAGE_SIZE = 10;
303
+ /**
304
+ * The paginator is only worth its space once the rows outgrow the smallest page. Below this the
305
+ * table shows everything and the toolbar count is the whole story.
306
+ */
307
+ const PAGINATION_THRESHOLD = PAGE_SIZE_OPTIONS[0];
308
+ /** Two-step delete: the row is removed this long after arming unless the user cancels. */
309
+ const DELETE_COUNTDOWN_MS = 3000;
310
+ /**
311
+ * Read-only table of a multiple-input field's rows, with per-row actions.
312
+ *
313
+ * Columns come from the field's `showAsLabel` inner inputs plus any the user toggles on from the
314
+ * toolbar's column chooser. Rows page client-side through the shared `MatTableDataSource`, the
315
+ * actions column stays pinned to the right edge when the table overflows, and the whole table can
316
+ * be opened full screen. Full screen is a full-viewport Material dialog rather than the Fullscreen
317
+ * API: this table's menus, tooltips and the paginator's page-size select all live in the CDK
318
+ * overlay container, which native full screen (and top-layer popovers) would paint over.
319
+ *
320
+ * Two columns are the view's own rather than the field's: a leading row number, pinned to the
321
+ * start so a row keeps its identity while a wide table scrolls, and a trailing "opened" age that
322
+ * appears once the author has opened their first row — in a seventy-row list, knowing which rows
323
+ * you have already been into is most of the navigation problem.
324
+ *
325
+ * Editing, duplicating and deleting are delegated to the parent through outputs — this component
326
+ * owns no row state beyond which rows the author has opened in this session.
327
+ *
328
+ * @example
329
+ * <lib-multiple-input-table-view
330
+ * [inputConfig]="inputConfig()"
331
+ * [dataSource]="dataSource"
332
+ * (onEditItem)="editRow($event)"
333
+ * (onDeleteItem)="removeRow($event)"
334
+ * />
335
+ */
336
+ class MultipleInputTableViewComponent {
337
+ #destroyRef;
338
+ #dialog;
339
+ #viewContainerRef;
340
+ #injector;
341
+ // ── Columns ─────────────────────────────────────────────────────────────────
342
+ /** Inner inputs the user has switched on from the column chooser, by `formControlName`. */
343
+ #tempLabels;
344
+ #dialogRef;
345
+ constructor() {
346
+ /** The multiple-input field whose rows are shown. Drives columns, permissions and labels. */
347
+ this.inputConfig = input(undefined, ...(ngDevMode ? [{ debugName: "inputConfig" }] : /* istanbul ignore next */ []));
348
+ /** Shared data source; the parent owns its `data`, this view owns its `paginator`. */
349
+ this.dataSource = input(new MatTableDataSource(), ...(ngDevMode ? [{ debugName: "dataSource" }] : /* istanbul ignore next */ []));
350
+ /** Row the parent is currently applying an action to (kept for the parent's bookkeeping). */
351
+ this.applyOptionsTo = input(undefined, ...(ngDevMode ? [{ debugName: "applyOptionsTo" }] : /* istanbul ignore next */ []));
352
+ /** Parent form group, used to spot the row currently open in the editor. */
353
+ this.formGroup = input(null, ...(ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []));
354
+ /** Emits the id of the row to open in the editor. */
355
+ this.onEditItem = output();
356
+ /** Emits the row to delete once its countdown has run out. */
357
+ this.onDeleteItem = output();
358
+ /** Emits the id of the row to duplicate. */
359
+ this.onCopy = output();
360
+ /** Emits the row whose action menu was opened, so the parent can target it. */
361
+ this.onApplyOptionsTo = output();
362
+ /** Reserved for the parent's label toggle; never emitted by this view. */
363
+ this.showItemAsLabel = output();
364
+ this.#destroyRef = inject(DestroyRef);
365
+ this.#dialog = inject(MatDialog);
366
+ this.#viewContainerRef = inject(ViewContainerRef);
367
+ this.#injector = inject(Injector);
368
+ // ── Columns ─────────────────────────────────────────────────────────────────
369
+ /** Inner inputs the user has switched on from the column chooser, by `formControlName`. */
370
+ this.#tempLabels = signal([], ...(ngDevMode ? [{ debugName: "#tempLabels" }] : /* istanbul ignore next */ []));
371
+ this.colConfig = computed(() => {
372
+ const cfg = this.inputConfig();
373
+ if (!cfg) {
374
+ return {
375
+ columnsConfig: {},
376
+ displayedColumnsInOrder: [],
377
+ };
378
+ }
379
+ return configureCols(cfg, [...this.#tempLabels()]);
380
+ }, ...(ngDevMode ? [{ debugName: "colConfig" }] : /* istanbul ignore next */ []));
381
+ this.columnsConfig = computed(() => this.colConfig().columnsConfig, ...(ngDevMode ? [{ debugName: "columnsConfig" }] : /* istanbul ignore next */ []));
382
+ /**
383
+ * Render order: the row number, then the field's own columns, then — once anything has been
384
+ * opened — the "opened" column immediately before the actions column. Both of those are
385
+ * `stickyEnd`, and Material requires pinned columns to be contiguous at the end.
386
+ */
387
+ this.displayedColumnsInOrderSig = computed(() => {
388
+ const base = this.colConfig().displayedColumnsInOrder;
389
+ if (!this.anyRowOpened()) {
390
+ return [INDEX_COLUMN, ...base];
391
+ }
392
+ // `configureCols` always appends the actions column last; guard anyway, so a future column
393
+ // order cannot silently break the sticky group.
394
+ const insertAt = base[base.length - 1] === ACTIONS_COLUMN ? base.length - 1 : base.length;
395
+ return [INDEX_COLUMN, ...base.slice(0, insertAt), OPENED_COLUMN, ...base.slice(insertAt)];
396
+ }, ...(ngDevMode ? [{ debugName: "displayedColumnsInOrderSig" }] : /* istanbul ignore next */ []));
397
+ this.allPossibleLabels = computed(() => {
398
+ const cfg = this.inputConfig();
399
+ const displayed = this.displayedColumnsInOrderSig();
400
+ return (cfg?.formInputs?.map((inp) => ({
401
+ label: inp.label,
402
+ selected: displayed.includes(`${cfg?.id}.${inp.id}`),
403
+ formControlName: inp.formControlName,
404
+ })) || []);
405
+ }, ...(ngDevMode ? [{ debugName: "allPossibleLabels" }] : /* istanbul ignore next */ []));
406
+ // ── Permissions ─────────────────────────────────────────────────────────────
407
+ this.userCanEdit = computed(() => {
408
+ const cfg = this.inputConfig();
409
+ if (!cfg)
410
+ return false;
411
+ if (!cfg.multipleInputAvailableOperations)
412
+ return true;
413
+ return cfg.multipleInputAvailableOperations.includes(MultipleInputAvailableOperations.Update);
414
+ }, ...(ngDevMode ? [{ debugName: "userCanEdit" }] : /* istanbul ignore next */ []));
415
+ this.userCanRemove = computed(() => {
416
+ const cfg = this.inputConfig();
417
+ if (!cfg)
418
+ return false;
419
+ if (!cfg.multipleInputAvailableOperations)
420
+ return true;
421
+ return cfg.multipleInputAvailableOperations.includes(MultipleInputAvailableOperations.Remove);
422
+ }, ...(ngDevMode ? [{ debugName: "userCanRemove" }] : /* istanbul ignore next */ []));
423
+ this.userCanAdd = computed(() => {
424
+ const cfg = this.inputConfig();
425
+ if (!cfg)
426
+ return false;
427
+ if (!cfg.multipleInputAvailableOperations)
428
+ return true;
429
+ return cfg.multipleInputAvailableOperations.includes(MultipleInputAvailableOperations.Add);
430
+ }, ...(ngDevMode ? [{ debugName: "userCanAdd" }] : /* istanbul ignore next */ []));
431
+ this.userCanApplyOptionsTo = computed(() => {
432
+ return this.userCanEdit() || this.userCanRemove() || this.userCanAdd();
433
+ }, ...(ngDevMode ? [{ debugName: "userCanApplyOptionsTo" }] : /* istanbul ignore next */ []));
434
+ /** A read-only or disabled field shows its rows but offers no actions at all. */
435
+ this.isEditable = computed(() => {
436
+ const cfg = this.inputConfig();
437
+ return !!cfg && !cfg.readonly && !cfg.disabled;
438
+ }, ...(ngDevMode ? [{ debugName: "isEditable" }] : /* istanbul ignore next */ []));
439
+ this.showRowActions = computed(() => this.isEditable() && this.userCanApplyOptionsTo(), ...(ngDevMode ? [{ debugName: "showRowActions" }] : /* istanbul ignore next */ []));
440
+ /** Edit is the everyday action, so it gets its own button instead of hiding in the menu. */
441
+ this.showRowEdit = computed(() => this.isEditable() && this.userCanEdit(), ...(ngDevMode ? [{ debugName: "showRowEdit" }] : /* istanbul ignore next */ []));
442
+ /** The overflow menu holds duplicate and delete; it is dropped when neither is allowed. */
443
+ this.showRowMenu = computed(() => this.isEditable() && (this.userCanAdd() || this.userCanRemove()), ...(ngDevMode ? [{ debugName: "showRowMenu" }] : /* istanbul ignore next */ []));
444
+ // ── Pagination ──────────────────────────────────────────────────────────────
445
+ this.pageSizeOptions = PAGE_SIZE_OPTIONS;
446
+ this.pageIndex = signal(0, ...(ngDevMode ? [{ debugName: "pageIndex" }] : /* istanbul ignore next */ []));
447
+ this.pageSize = signal(DEFAULT_PAGE_SIZE, ...(ngDevMode ? [{ debugName: "pageSize" }] : /* istanbul ignore next */ []));
448
+ /**
449
+ * The live paginator. It is re-created when the table moves between its inline slot and the
450
+ * full-screen dialog, so it is read reactively rather than captured once.
451
+ */
452
+ this.paginator = viewChild(MatPaginator, ...(ngDevMode ? [{ debugName: "paginator" }] : /* istanbul ignore next */ []));
453
+ // ── Full screen ─────────────────────────────────────────────────────────────
454
+ this.fullscreen = signal(false, ...(ngDevMode ? [{ debugName: "fullscreen" }] : /* istanbul ignore next */ []));
455
+ /**
456
+ * Height the inline slot keeps while the table is in the dialog, so the surrounding form does not
457
+ * collapse and the page does not jump when full screen is left.
458
+ */
459
+ this.reservedHeight = signal(null, ...(ngDevMode ? [{ debugName: "reservedHeight" }] : /* istanbul ignore next */ []));
460
+ this.shellTemplate = viewChild('shell', ...(ngDevMode ? [{ debugName: "shellTemplate" }] : /* istanbul ignore next */ []));
461
+ this.inlineHost = viewChild('inlineHost', ...(ngDevMode ? [{ debugName: "inlineHost" }] : /* istanbul ignore next */ []));
462
+ // `read: ElementRef` — the ref sits on a `mat-icon-button`, which would otherwise resolve to
463
+ // the button component rather than its element.
464
+ this.fullscreenToggle = viewChild('fullscreenToggle', { ...(ngDevMode ? { debugName: "fullscreenToggle" } : /* istanbul ignore next */ {}), read: ElementRef });
465
+ // ── Refresh ─────────────────────────────────────────────────────────────────
466
+ /**
467
+ * The host may offer a reload of the field's data. It used to hang off the form field as a
468
+ * `matSuffix`, which both floated it away from the table it refreshes and stole the width the
469
+ * table needed; it belongs with the table's own chrome.
470
+ */
471
+ this.canReload = computed(() => !!this.inputConfig()?.canReload?.canReload, ...(ngDevMode ? [{ debugName: "canReload" }] : /* istanbul ignore next */ []));
472
+ // ── "Opened" tracking ───────────────────────────────────────────────────────
473
+ /*
474
+ * A long list is edited row by row, and the question the author keeps asking is "have I already
475
+ * been in this one?". Every open stamps the row, and the column reports the age of that stamp.
476
+ *
477
+ * In memory, deliberately: LIB-05 forbids the library reaching for `localStorage`, and the state
478
+ * answers a question about THIS editing session anyway. It costs one Map and one interval.
479
+ */
480
+ /** When each row was last opened, by row id. */
481
+ this.#openedAt = signal(new Map(), ...(ngDevMode ? [{ debugName: "#openedAt" }] : /* istanbul ignore next */ []));
482
+ /** The clock the relative labels render against. Ticks only while something has been opened. */
483
+ this.#nowMs = signal(Date.now(), ...(ngDevMode ? [{ debugName: "#nowMs" }] : /* istanbul ignore next */ []));
484
+ /** The column materialises on the first open, so an untouched table carries no extra ink. */
485
+ this.anyRowOpened = computed(() => this.#openedAt().size > 0, ...(ngDevMode ? [{ debugName: "anyRowOpened" }] : /* istanbul ignore next */ []));
486
+ // ── Two-step delete ─────────────────────────────────────────────────────────
487
+ this.#armedDeletions = {};
488
+ this.#deletionTimers = {};
489
+ this.#countDownDate = new Date();
490
+ // ── Structured-value popover ────────────────────────────────────────────────
491
+ this.overlayOpen = signal(false, ...(ngDevMode ? [{ debugName: "overlayOpen" }] : /* istanbul ignore next */ []));
492
+ this.overlayData = signal(null, ...(ngDevMode ? [{ debugName: "overlayData" }] : /* istanbul ignore next */ []));
493
+ this.overlayOrigin = signal(null, ...(ngDevMode ? [{ debugName: "overlayOrigin" }] : /* istanbul ignore next */ []));
494
+ // The data source pages whatever paginator is currently rendered — inline, in the dialog, or
495
+ // none while the rows fit on one page.
496
+ effect(() => {
497
+ const ds = this.dataSource();
498
+ const paginator = this.paginator() ?? null;
499
+ if (ds && ds.paginator !== paginator) {
500
+ ds.paginator = paginator;
501
+ }
502
+ });
503
+ }
504
+ ngOnDestroy() {
505
+ // An armed delete must not fire from a component that no longer exists.
506
+ for (const handle of Object.values(this.#deletionTimers)) {
507
+ clearTimeout(handle);
508
+ }
509
+ this.#deletionTimers = {};
510
+ if (this.#openedTicker !== undefined) {
511
+ clearInterval(this.#openedTicker);
512
+ this.#openedTicker = undefined;
513
+ }
514
+ this.#dialogRef?.close();
515
+ }
516
+ // ── Column helpers (template) ───────────────────────────────────────────────
517
+ isActionsColumn(col) {
518
+ return col === ACTIONS_COLUMN;
519
+ }
520
+ isIndexColumn(col) {
521
+ return col === INDEX_COLUMN;
522
+ }
523
+ isOpenedColumn(col) {
524
+ return col === OPENED_COLUMN;
525
+ }
526
+ columnLabel(col) {
527
+ if (this.isActionsColumn(col)) {
528
+ return this.showRowActions() ? 'Actions' : '';
529
+ }
530
+ if (this.isOpenedColumn(col)) {
531
+ return 'Opened';
532
+ }
533
+ return this.columnsConfig()[col]?.label ?? '';
534
+ }
535
+ columnDataType(col) {
536
+ return this.columnsConfig()[col]?.dataType;
537
+ }
538
+ isNumericColumn(col) {
539
+ const type = this.columnDataType(col);
540
+ return type === 'number' || type === 'currency' || type === 'percent';
541
+ }
542
+ isStructuredColumn(col) {
543
+ const type = this.columnDataType(col);
544
+ return type === 'array' || type === 'object';
545
+ }
546
+ // ── Row helpers (template) ──────────────────────────────────────────────────
547
+ isCalculationRow(row) {
548
+ return !!row[CALCULATION_KEY];
549
+ }
550
+ rowIsFlaggedInEdit(row) {
551
+ return !!row[IN_EDIT_KEY];
552
+ }
553
+ rowHasActions(row) {
554
+ // `row[''] !== 'true'` is a legacy host marker for rows that must not be acted on.
555
+ return this.showRowActions() && !this.isCalculationRow(row) && row[''] !== 'true';
556
+ }
557
+ /** A calculation row is labelled unless it is the one the editor currently has open. */
558
+ showsCalculationLabel(row) {
559
+ if (!this.isCalculationRow(row))
560
+ return false;
561
+ const inEditId = this.inputConfig()?.multipleInputInEditId;
562
+ return inEditId ? inEditId !== row['id'] : !row['id'];
563
+ }
564
+ /**
565
+ * The row's position in the whole list rather than in the page: the page offset plus the index
566
+ * Material hands the cell. A calculation row is a total, not an entry, so it carries no number.
567
+ */
568
+ rowNumber(row, indexInPage) {
569
+ if (this.isCalculationRow(row)) {
570
+ return '';
571
+ }
572
+ // Without a paginator every row is rendered, and a stale `pageIndex` from a larger data set
573
+ // would otherwise offset the numbering.
574
+ const offset = this.showPaginator() ? this.pageIndex() * this.pageSize() : 0;
575
+ return String(offset + indexInPage + 1);
576
+ }
577
+ totalRows() {
578
+ return this.dataSource()?.data.length ?? 0;
579
+ }
580
+ isEmpty() {
581
+ return this.totalRows() === 0;
582
+ }
583
+ showPaginator() {
584
+ return this.totalRows() > PAGINATION_THRESHOLD;
585
+ }
586
+ /** "3 items" — calculation rows are totals, not items, so they are left out of the count. */
587
+ rowSummary() {
588
+ const count = (this.dataSource()?.data ?? []).filter((row) => !this.isCalculationRow(row)).length;
589
+ return `${count} ${count === 1 ? 'item' : 'items'}`;
590
+ }
591
+ reload() {
592
+ this.inputConfig()?.canReload?.emit();
593
+ }
594
+ // ── "Opened" tracking ───────────────────────────────────────────────────────
595
+ /*
596
+ * A long list is edited row by row, and the question the author keeps asking is "have I already
597
+ * been in this one?". Every open stamps the row, and the column reports the age of that stamp.
598
+ *
599
+ * In memory, deliberately: LIB-05 forbids the library reaching for `localStorage`, and the state
600
+ * answers a question about THIS editing session anyway. It costs one Map and one interval.
601
+ */
602
+ /** When each row was last opened, by row id. */
603
+ #openedAt;
604
+ /** The clock the relative labels render against. Ticks only while something has been opened. */
605
+ #nowMs;
606
+ #openedTicker;
607
+ /** Column token for a row that has been opened, `''` for one that has not. */
608
+ openedShort(row) {
609
+ const at = this.#openedAtFor(row);
610
+ return at === undefined ? '' : openedAgo(this.#nowMs() - at).short;
611
+ }
612
+ /** The same age as a sentence, for the cell's tooltip. */
613
+ openedLong(row) {
614
+ const at = this.#openedAtFor(row);
615
+ return at === undefined ? '' : openedAgo(this.#nowMs() - at).long;
616
+ }
617
+ #openedAtFor(row) {
618
+ const id = this.#rowId(row);
619
+ return id ? this.#openedAt().get(id) : undefined;
620
+ }
621
+ /**
622
+ * Stamps a row as opened. Every open re-stamps it, so the column reads as "what I touched last"
623
+ * rather than "what I touched first".
624
+ */
625
+ #markOpened(row) {
626
+ const id = this.#rowId(row);
627
+ if (!id) {
628
+ return;
629
+ }
630
+ const next = new Map(this.#openedAt());
631
+ next.set(id, Date.now());
632
+ this.#openedAt.set(next);
633
+ this.#startOpenedTicker();
634
+ }
635
+ /** One interval for the whole table, started on the first open and stopped with the component. */
636
+ #startOpenedTicker() {
637
+ if (this.#openedTicker !== undefined) {
638
+ return;
639
+ }
640
+ this.#nowMs.set(Date.now());
641
+ this.#openedTicker = setInterval(() => this.#nowMs.set(Date.now()), OPENED_TICK_MS);
642
+ }
643
+ onPage(event) {
644
+ this.pageIndex.set(event.pageIndex);
645
+ this.pageSize.set(event.pageSize);
646
+ }
647
+ // ── Full screen ─────────────────────────────────────────────────────────────
648
+ toggleFullscreen() {
649
+ if (this.fullscreen()) {
650
+ this.#dialogRef?.close();
651
+ return;
652
+ }
653
+ const shell = this.shellTemplate();
654
+ if (!shell)
655
+ return;
656
+ this.reservedHeight.set(this.inlineHost()?.nativeElement.offsetHeight ?? null);
657
+ this.fullscreen.set(true);
658
+ const label = this.inputConfig()?.label;
659
+ const ref = this.#dialog.open(shell, {
660
+ viewContainerRef: this.#viewContainerRef,
661
+ width: 'calc(100vw - 3rem)',
662
+ height: 'calc(100vh - 3rem)',
663
+ maxWidth: '100vw',
664
+ maxHeight: '100vh',
665
+ panelClass: 'lib-multiple-input-table-view__dialog',
666
+ ariaLabel: label ? `${label} full screen` : 'Table full screen',
667
+ autoFocus: 'dialog',
668
+ // The inline toggle is re-created after the dialog closes, so focus is restored by hand.
669
+ restoreFocus: false,
670
+ });
671
+ this.#dialogRef = ref;
672
+ ref
673
+ .afterClosed()
674
+ .pipe(takeUntilDestroyed(this.#destroyRef))
675
+ .subscribe(() => {
676
+ if (this.#dialogRef === ref)
677
+ this.#dialogRef = undefined;
678
+ this.fullscreen.set(false);
679
+ this.reservedHeight.set(null);
680
+ afterNextRender(() => this.fullscreenToggle()?.nativeElement.focus({ preventScroll: true }), { injector: this.#injector });
681
+ });
682
+ }
683
+ /** The editor opens in the form behind the dialog, so leave full screen before handing over. */
684
+ #leaveFullscreen() {
685
+ this.#dialogRef?.close();
686
+ }
687
+ // ── Actions ─────────────────────────────────────────────────────────────────
688
+ #rowId(row) {
689
+ return row[`${this.inputConfig()?.id}.id`];
690
+ }
691
+ applyOptionsToFn(item) {
692
+ this.onApplyOptionsTo.emit(item);
693
+ }
694
+ editItem(row) {
695
+ this.#markOpened(row);
696
+ this.#leaveFullscreen();
697
+ this.onEditItem.emit(this.#rowId(row));
698
+ }
699
+ copy(row) {
700
+ this.#leaveFullscreen();
701
+ this.onCopy.emit(this.#rowId(row));
702
+ }
703
+ // ── Two-step delete ─────────────────────────────────────────────────────────
704
+ #armedDeletions;
705
+ #deletionTimers;
706
+ #countDownDate;
707
+ isAboutToDeleteRow(row) {
708
+ return !!this.#armedDeletions[this.#rowId(row)];
709
+ }
710
+ getCountdownSeconds() {
711
+ const now = new Date();
712
+ const timeElapsed = (now.getTime() - this.#countDownDate.getTime()) / 1000;
713
+ return Math.min(Math.round((timeElapsed / (DELETE_COUNTDOWN_MS / 1000)) * 100), 100);
714
+ }
715
+ secondsCountDown() {
716
+ const total = DELETE_COUNTDOWN_MS / 1000;
717
+ return (total - (this.getCountdownSeconds() / 100) * total).toFixed(1);
718
+ }
719
+ multipleInputRemoveItem(event, row) {
720
+ const rowId = this.#rowId(row);
721
+ if (this.#armedDeletions[rowId]) {
722
+ const handle = this.#deletionTimers[rowId];
723
+ if (handle) {
724
+ clearTimeout(handle);
725
+ delete this.#deletionTimers[rowId];
726
+ }
727
+ delete this.#armedDeletions[rowId];
728
+ }
729
+ else {
730
+ this.#armedDeletions[rowId] = true;
731
+ this.#countDownDate = new Date();
732
+ this.#deletionTimers[rowId] = setTimeout(() => {
733
+ if (this.#armedDeletions[rowId]) {
734
+ this.onDeleteItem.emit(row);
735
+ delete this.#armedDeletions[rowId];
736
+ delete this.#deletionTimers[rowId];
737
+ }
738
+ }, DELETE_COUNTDOWN_MS);
739
+ }
740
+ event.preventDefault();
741
+ event.stopPropagation();
742
+ }
743
+ // ── Cell presentation ───────────────────────────────────────────────────────
744
+ returnBackground(row, columnsConfig) {
745
+ let background = '';
746
+ const ds = this.dataSource();
747
+ if (ds
748
+ ? ds.data.length > 1
749
+ ? columnsConfig?.['colorScale']
750
+ : false
751
+ : false) {
752
+ const inputCfg = this.inputConfig();
753
+ const colKey = columnsConfig?.['key'] ?? '';
754
+ const point = Number(row[colKey]);
755
+ const inputIsGrouped = inputCfg.groupBy;
756
+ const groupKey = inputCfg.groupBy?.[0] || '';
757
+ const dataSet = inputIsGrouped
758
+ ? ds?.data.filter((s) => s[groupKey] === row[groupKey])
759
+ : new Array(ds?.data || []);
760
+ const arrayValues = dataSet?.map((vr) => Number(vr[colKey])) || [];
761
+ const max = Math.max(...arrayValues);
762
+ const min = Math.min(...arrayValues);
763
+ const hasNun = isNaN(max) || isNaN(min);
764
+ if (!hasNun && Number(max) !== Number(min)) {
765
+ const colorScale = new ColorScale(min, max, ['#2fdf75', '#FFA500', '#ff4961'], 0.8);
766
+ const color = colorScale.getColor(point)?.toRGBAString();
767
+ background = color ?? '';
768
+ }
769
+ }
770
+ return background;
771
+ }
772
+ hasTopBorder(row) {
773
+ const inputCfg = this.inputConfig();
774
+ const inputIsGrouped = inputCfg?.groupBy;
775
+ const ds = this.dataSource();
776
+ if (inputIsGrouped && ds) {
777
+ const indexOfRow = ds.data.indexOf(row);
778
+ const rowIsFirstInTable = indexOfRow === 0;
779
+ if (!inputCfg.groupBy) {
780
+ return false;
781
+ }
782
+ const groupKey = inputCfg.groupBy?.[0] ?? '';
783
+ const isFirstInGroup = rowIsFirstInTable
784
+ ? true
785
+ : ds.data[indexOfRow - 1][groupKey] !==
786
+ row[groupKey];
787
+ return isFirstInGroup;
788
+ }
789
+ else {
790
+ return false;
791
+ }
792
+ }
793
+ getCalculationFunction(row) {
794
+ const func = row[CALCULATION_KEY];
795
+ switch (func) {
796
+ case CalculationFunctions.Sum:
797
+ return 'TOTAL';
798
+ case CalculationFunctions.Avg:
799
+ return 'AVERAGE';
800
+ case CalculationFunctions.Max:
801
+ return 'MAX';
802
+ case CalculationFunctions.Min:
803
+ return 'MIN';
804
+ default:
805
+ return func;
806
+ }
807
+ }
808
+ // ── Column chooser ──────────────────────────────────────────────────────────
809
+ toggleTempLabel(event, label) {
810
+ this.#tempLabels.update((labels) => labels.includes(label) ? labels.filter((l) => l !== label) : [...labels, label]);
811
+ // Keep the menu open so several columns can be toggled in one go.
812
+ event.stopPropagation();
813
+ event.preventDefault();
814
+ }
815
+ /** Column keys in display order — the removal column is always last. */
816
+ get displayedColumnsInOrder() {
817
+ return this.displayedColumnsInOrderSig();
818
+ }
819
+ rowIsInEdit(row) {
820
+ const cfg = this.inputConfig();
821
+ const fg = this.formGroup();
822
+ return (!!cfg?.formIsOpen &&
823
+ fg?.controls[`${cfg?.id}.id`]?.value === row[`${cfg?.id}.id`]);
824
+ }
825
+ openDataOverlay(event, data) {
826
+ event.stopPropagation();
827
+ this.overlayOrigin.set(event.currentTarget);
828
+ this.overlayData.set(data);
829
+ this.overlayOpen.set(true);
830
+ }
831
+ closeDataOverlay() {
832
+ this.overlayOpen.set(false);
833
+ this.overlayData.set(null);
834
+ this.overlayOrigin.set(null);
835
+ }
836
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputTableViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
837
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: MultipleInputTableViewComponent, isStandalone: true, selector: "lib-multiple-input-table-view", inputs: { inputConfig: { classPropertyName: "inputConfig", publicName: "inputConfig", isSignal: true, isRequired: false, transformFunction: null }, dataSource: { classPropertyName: "dataSource", publicName: "dataSource", isSignal: true, isRequired: false, transformFunction: null }, applyOptionsTo: { classPropertyName: "applyOptionsTo", publicName: "applyOptionsTo", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onEditItem: "onEditItem", onDeleteItem: "onDeleteItem", onCopy: "onCopy", onApplyOptionsTo: "onApplyOptionsTo", showItemAsLabel: "showItemAsLabel" }, host: { properties: { "class.lib-multiple-input-table-view--fullscreen": "fullscreen()" }, classAttribute: "lib-multiple-input-table-view" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, isSignal: true }, { propertyName: "shellTemplate", first: true, predicate: ["shell"], descendants: true, isSignal: true }, { propertyName: "inlineHost", first: true, predicate: ["inlineHost"], descendants: true, isSignal: true }, { propertyName: "fullscreenToggle", first: true, predicate: ["fullscreenToggle"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: "@defer (on viewport) {\n <!--\n The table shell is a template so the same markup renders in two places: inline in the form,\n or inside the full-screen dialog. Only one instance exists at a time \u2014 the inline slot empties\n while the dialog is open \u2014 so the shared data source always pages through a single paginator.\n -->\n <ng-template #shell>\n <section class=\"mit-shell\" [class.mit-shell--fullscreen]=\"fullscreen()\">\n <header class=\"mit-toolbar\">\n <div class=\"mit-toolbar__lead\">\n @if (fullscreen()) {\n <h2 class=\"mit-toolbar__title\">{{ inputConfig()?.label }}</h2>\n }\n <span class=\"mit-toolbar__summary\">{{ rowSummary() }}</span>\n </div>\n <div class=\"mit-toolbar__actions\">\n @if (canReload()) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-reload\"\n matTooltip=\"Refresh this list\"\n aria-label=\"Refresh this list\"\n (click)=\"reload()\"\n >\n <mat-icon>sync</mat-icon>\n </button>\n }\n @if (allPossibleLabels().length > 0) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-columns-trigger\"\n matTooltip=\"Choose columns\"\n aria-label=\"Choose columns\"\n [matMenuTriggerFor]=\"colOptions\"\n >\n <mat-icon>view_column</mat-icon>\n </button>\n }\n <button\n #fullscreenToggle\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-fullscreen-toggle\"\n [matTooltip]=\"fullscreen() ? 'Exit full screen' : 'Full screen'\"\n [attr.aria-label]=\"fullscreen() ? 'Exit full screen' : 'Full screen'\"\n [attr.aria-pressed]=\"fullscreen()\"\n (click)=\"toggleFullscreen()\"\n >\n <mat-icon>{{ fullscreen() ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>\n </button>\n </div>\n </header>\n\n @if (displayedColumnsInOrder.length === 0) {\n <div class=\"mit-state\">No columns</div>\n }\n\n <div class=\"mit-scroll\">\n <table mat-table [dataSource]=\"dataSource() ?? []\" class=\"mit-table\">\n @for (col of displayedColumnsInOrder; track col) {\n <!--\n The row number is pinned to the start and the \"opened\" age and actions to the end, so\n a row keeps its identity and stays actionable however far a wide table is scrolled.\n Material needs each pinned group contiguous at its edge, which is why the \"opened\"\n column is inserted before the actions column rather than appended after it.\n -->\n <ng-container\n [matColumnDef]=\"col\"\n [sticky]=\"isIndexColumn(col)\"\n [stickyEnd]=\"isActionsColumn(col) || isOpenedColumn(col)\"\n >\n <th\n mat-header-cell\n *matHeaderCellDef\n scope=\"col\"\n [attr.aria-label]=\"isIndexColumn(col) ? 'Row number' : null\"\n [class.mit-th--index]=\"isIndexColumn(col)\"\n [class.mit-th--opened]=\"isOpenedColumn(col)\"\n [class.mit-th--numeric]=\"isNumericColumn(col)\"\n [class.mit-th--actions]=\"isActionsColumn(col)\"\n >\n @if (isIndexColumn(col)) {\n <span class=\"mit-th-hash\" aria-hidden=\"true\">#</span>\n } @else {\n <span class=\"mit-th-label\">{{ columnLabel(col) }}</span>\n }\n </th>\n <td\n mat-cell\n *matCellDef=\"let row; let rowIndex = index\"\n [class.mit-td--calc]=\"isCalculationRow(row)\"\n [class.mit-td--index]=\"isIndexColumn(col)\"\n [class.mit-td--opened]=\"isOpenedColumn(col)\"\n [class.mit-td--actions]=\"isActionsColumn(col)\"\n [class.mit-td--numeric]=\"isNumericColumn(col)\"\n [style.background]=\"returnBackground(row, columnsConfig()[col])\"\n >\n @if (isIndexColumn(col)) {\n <span class=\"mit-index\">{{ rowNumber(row, rowIndex) }}</span>\n } @else if (isOpenedColumn(col)) {\n <!-- Blank for a row nobody has been into: the column is a record of what the\n author touched, so an empty cell is the honest reading of \"not yet\". -->\n @let opened = openedShort(row);\n @if (opened) {\n <span class=\"mit-opened\" [matTooltip]=\"openedLong(row)\">{{ opened }}</span>\n }\n } @else if (isActionsColumn(col)) {\n <div class=\"mit-actions\">\n @if (showsCalculationLabel(row)) {\n <span class=\"mit-calc-label\">{{ getCalculationFunction(row) }}</span>\n }\n @if (rowIsFlaggedInEdit(row)) {\n <mat-chip class=\"mit-chip\">In {{ inputConfig()?.readonly ? 'View' : 'Edit' }}</mat-chip>\n }\n @if (rowHasActions(row)) {\n @if (showRowEdit()) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-row-edit\"\n [class.mit-icon-button--active]=\"rowIsInEdit(row)\"\n matTooltip=\"Edit\"\n aria-label=\"Edit row\"\n (click)=\"editItem(row)\"\n >\n <mat-icon>edit</mat-icon>\n </button>\n }\n @if (showRowMenu()) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-row-trigger\"\n [class.mit-icon-button--active]=\"t.menuOpen\"\n matTooltip=\"More actions\"\n aria-label=\"More row actions\"\n [matMenuTriggerFor]=\"rowOptions\"\n [matMenuTriggerData]=\"{ row: row }\"\n #t=\"matMenuTrigger\"\n (click)=\"applyOptionsToFn(row)\"\n >\n <mat-icon>{{ t.menuOpen ? 'close' : 'more_horiz' }}</mat-icon>\n </button>\n }\n }\n </div>\n } @else if (isStructuredColumn(col)) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-data-button\"\n matTooltip=\"View data\"\n aria-label=\"View data\"\n (click)=\"openDataOverlay($event, row[col])\"\n >\n <mat-icon>data_object</mat-icon>\n </button>\n } @else {\n @let text = row[col] | formatData: columnDataType(col);\n <span class=\"mit-cell-text\" [attr.title]=\"text\">{{ text }}</span>\n }\n </td>\n </ng-container>\n }\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumnsInOrder; sticky: true\"></tr>\n <tr\n mat-row\n *matRowDef=\"let row; columns: displayedColumnsInOrder\"\n class=\"mit-row\"\n [class.mit-row--group-start]=\"hasTopBorder(row)\"\n [class.mit-row--calc]=\"isCalculationRow(row)\"\n [class.mit-row--in-edit]=\"rowIsInEdit(row)\"\n ></tr>\n </table>\n\n @if (isEmpty()) {\n <div class=\"mit-empty\">\n <strong class=\"mit-empty-title\">No items yet</strong>\n <p class=\"mit-empty-text\">\n Use the add button below to create a row. Each saved entry appears here.\n </p>\n </div>\n }\n </div>\n\n @if (showPaginator()) {\n <mat-paginator\n class=\"mit-paginator\"\n [pageIndex]=\"pageIndex()\"\n [pageSize]=\"pageSize()\"\n [pageSizeOptions]=\"pageSizeOptions\"\n showFirstLastButtons\n aria-label=\"Table pagination\"\n (page)=\"onPage($event)\"\n />\n }\n </section>\n </ng-template>\n\n <div class=\"mit-inline\" #inlineHost [style.min-height.px]=\"reservedHeight()\">\n @if (!fullscreen()) {\n <ng-container [ngTemplateOutlet]=\"shell\" />\n }\n </div>\n} @placeholder {\n <div class=\"mit-placeholder\">\n <mat-spinner diameter=\"32\" />\n </div>\n}\n\n<!--\n Structured (array / object) cell values open in a CDK overlay anchored to the button that was\n clicked. An overlay, rather than a fixed-position panel, so it stacks correctly above the\n full-screen dialog and is never clipped by a transformed ancestor.\n-->\n@if (overlayOrigin(); as origin) {\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"origin\"\n [cdkConnectedOverlayOpen]=\"overlayOpen()\"\n [cdkConnectedOverlayHasBackdrop]=\"true\"\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\n [cdkConnectedOverlayPush]=\"true\"\n (backdropClick)=\"closeDataOverlay()\"\n (detach)=\"closeDataOverlay()\"\n >\n <div class=\"mit-data-panel\" role=\"dialog\" aria-label=\"Cell data\">\n <div class=\"mit-data-panel__header\">\n <span class=\"mit-data-panel__title\">Data</span>\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-data-close\"\n aria-label=\"Close\"\n (click)=\"closeDataOverlay()\"\n >\n <mat-icon>close</mat-icon>\n </button>\n </div>\n <div class=\"mit-data-panel__body\">\n <lib-t-dynamic-data-view [data]=\"overlayData()\" />\n </div>\n </div>\n </ng-template>\n}\n\n<mat-menu #colOptions=\"matMenu\">\n <ng-template matMenuContent>\n @for (label of allPossibleLabels(); track label.formControlName) {\n <button\n mat-menu-item\n role=\"menuitemcheckbox\"\n [attr.aria-checked]=\"label.selected\"\n (click)=\"toggleTempLabel($event, label.formControlName)\"\n >\n <mat-icon>{{ label.selected ? 'check_box' : 'check_box_outline_blank' }}</mat-icon>\n {{ label.label }}\n </button>\n }\n </ng-template>\n</mat-menu>\n\n<mat-menu #rowOptions=\"matMenu\">\n <ng-template matMenuContent let-row=\"row\">\n @if (isEditable()) {\n @if (userCanAdd()) {\n <button mat-menu-item (click)=\"copy(row)\">\n <mat-icon>content_copy</mat-icon>\n <div class=\"option-text\">\n <div class=\"option-main-text\">Duplicate</div>\n <div class=\"option-sub-text\">Create a copy with the same values</div>\n </div>\n </button>\n }\n\n @if (userCanRemove()) {\n @if (isAboutToDeleteRow(row)) {\n <button mat-menu-item (click)=\"multipleInputRemoveItem($event, row)\">\n <mat-icon color=\"accent\">cancel</mat-icon>\n <div class=\"option-text\">\n <div class=\"option-main-text option-main-text--cancel\">Cancel Deletion</div>\n <div class=\"option-sub-text\">Auto-deleting in {{ secondsCountDown() }} seconds...</div>\n </div>\n </button>\n <div class=\"deletion-progress-container\">\n <mat-progress-bar color=\"warn\" mode=\"determinate\" [value]=\"getCountdownSeconds()\"></mat-progress-bar>\n @if (getCountdownSeconds() > 75) {\n <div class=\"deletion-message\">Deleting soon...</div>\n }\n </div>\n } @else {\n <button mat-menu-item (click)=\"multipleInputRemoveItem($event, row)\">\n <mat-icon color=\"warn\">delete_outline</mat-icon>\n <div class=\"option-text\">\n <div class=\"option-main-text\">Delete</div>\n <div class=\"option-sub-text\">Removes after 3 seconds. Click again to cancel</div>\n </div>\n </button>\n }\n }\n }\n </ng-template>\n</mat-menu>\n", styles: [":host{display:block}.mit-inline{display:block}.mit-shell{display:flex;flex-direction:column;background:var(--lib-forms-surface);border:1px solid color-mix(in srgb,var(--lib-forms-outline) 10%,transparent);border-radius:var(--lib-forms-radius-md);box-shadow:var(--lib-forms-shadow-resting);overflow:hidden}.mit-shell--fullscreen{height:100%;box-sizing:border-box;padding:1.25rem 1.5rem .5rem;border:none;border-radius:0;box-shadow:none}.mit-toolbar{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:.375rem .375rem .375rem .75rem}.mit-shell--fullscreen .mit-toolbar{padding:0 0 1.25rem}.mit-toolbar__lead{display:flex;align-items:center;gap:.75rem;min-width:0}.mit-toolbar__title{margin:0;font-size:1.25rem;font-weight:500;letter-spacing:-.01em;color:var(--lib-forms-on-surface);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mit-toolbar__summary{display:inline-flex;align-items:center;height:1.375rem;padding:0 .5625rem;border-radius:var(--lib-forms-radius-pill);background:color-mix(in srgb,var(--lib-forms-primary) 10%,transparent);color:var(--lib-forms-primary);font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;white-space:nowrap}.mit-toolbar__actions{display:flex;align-items:center;gap:.125rem;flex-shrink:0}.mit-icon-button.mat-mdc-icon-button{--mdc-icon-button-state-layer-size: 1.75rem;--mdc-icon-button-icon-size: 1rem;width:1.75rem;height:1.75rem;padding:.375rem;border-radius:50%;color:var(--lib-forms-on-surface-variant);transition:color var(--lib-forms-duration-hover) var(--lib-forms-easing),background-color var(--lib-forms-duration-hover) var(--lib-forms-easing),box-shadow var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mit-icon-button.mat-mdc-icon-button .mat-icon{font-size:1rem;width:1rem;height:1rem;line-height:1rem}.mit-icon-button.mat-mdc-icon-button:hover,.mit-icon-button.mat-mdc-icon-button:focus-visible{color:var(--lib-forms-primary);background-color:color-mix(in srgb,var(--lib-forms-primary) 10%,transparent)}.mit-icon-button.mat-mdc-icon-button:focus-visible{outline:3px solid color-mix(in srgb,var(--lib-forms-primary) 14%,transparent);outline-offset:1px}.mit-icon-button--active.mat-mdc-icon-button{color:var(--lib-forms-primary);background-color:color-mix(in srgb,var(--lib-forms-primary) 14%,transparent)}.mit-row-edit.mat-mdc-icon-button{color:var(--lib-forms-primary)}.mit-row-edit.mat-mdc-icon-button:hover,.mit-row-edit.mat-mdc-icon-button:focus-visible{background-color:color-mix(in srgb,var(--lib-forms-primary) 14%,transparent);box-shadow:var(--lib-forms-shadow-edge)}.mit-scroll{width:100%;overflow:auto;overscroll-behavior-x:contain;scrollbar-width:thin}.mit-shell--fullscreen .mit-scroll{flex:1 1 auto;min-height:0;border-radius:var(--lib-forms-radius-sm);border:1px solid color-mix(in srgb,var(--lib-forms-outline) 10%,transparent)}.mit-table{--mat-table-row-item-outline-width: 0;--mat-table-background-color: transparent;--mat-table-header-container-height: 1.875rem;--mat-table-row-item-container-height: 2rem;width:100%;background:transparent}.mit-table .mat-mdc-header-row{--mit-row-bg: color-mix(in srgb, var(--lib-forms-primary) 5%, var(--lib-forms-surface));height:1.875rem;background:var(--mit-row-bg)}.mit-table .mat-mdc-header-cell{padding:0 .625rem;white-space:nowrap;background:var(--mit-row-bg)}.mit-th-label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mit-th--numeric,.mit-th--actions{text-align:right}.mit-table .mat-mdc-row{--mit-row-bg: var(--lib-forms-surface);height:2rem;background:var(--mit-row-bg);transition:background-color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mit-table .mat-mdc-row:nth-child(2n){--mit-row-bg: var(--lib-forms-surface-container-low)}.mit-table .mat-mdc-row:hover{--mit-row-bg: color-mix(in srgb, var(--lib-forms-primary) 7%, var(--lib-forms-surface))}.mit-table .mit-row--in-edit,.mit-table .mit-row--in-edit:hover{--mit-row-bg: color-mix(in srgb, var(--lib-forms-primary) 11%, var(--lib-forms-surface))}.mit-table .mit-row--in-edit .mat-mdc-cell:first-child{box-shadow:inset 3px 0 0 var(--lib-forms-primary)}.mit-table .mit-row--calc,.mit-table .mit-row--calc:hover{--mit-row-bg: var(--lib-forms-surface-container-high)}.mit-table .mit-td--calc{font-weight:600}.mit-table .mat-mdc-cell{padding:0 .625rem;font-size:.8125rem;line-height:1.3;color:var(--lib-forms-on-surface);vertical-align:middle}.mit-cell-text{display:block;max-width:18rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mit-shell--fullscreen .mit-cell-text{max-width:40rem}.mit-table .mat-mdc-header-cell:not(.mit-th--index):not(.mit-th--opened):not(.mit-th--actions),.mit-table .mat-mdc-cell:not(.mit-td--index):not(.mit-td--opened):not(.mit-td--actions){min-width:6rem}.mit-td--numeric{text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}.mit-table .mit-row--group-start .mat-mdc-cell{border-top:2px solid var(--lib-forms-outline-variant)}.mit-table .mat-column-itemRemovalButton{width:1%;white-space:nowrap;background:var(--mit-row-bg)}.mit-table .mat-column-itemRemovalButton.mat-mdc-table-sticky{box-shadow:-10px 0 14px -12px color-mix(in srgb,var(--lib-forms-shadow-color) 22%,transparent)}.mit-table .mit-th--index,.mit-table .mit-td--index{width:1%;padding:0 .5rem 0 .625rem;text-align:right;white-space:nowrap;background:var(--mit-row-bg)}.mit-th-hash{font-size:.625rem;font-weight:600;color:var(--lib-forms-on-surface-variant)}.mit-index{font-size:.6875rem;font-variant-numeric:tabular-nums;color:color-mix(in srgb,var(--lib-forms-on-surface-variant) 65%,transparent)}.mit-table .mit-th--opened,.mit-table .mit-td--opened{width:1%;padding:0 .625rem;text-align:right;white-space:nowrap;background:var(--mit-row-bg)}.mit-opened{font-size:.6875rem;font-variant-numeric:tabular-nums;color:color-mix(in srgb,var(--lib-forms-on-surface-variant) 75%,transparent)}.mit-table .mit-th--opened.mat-mdc-table-sticky,.mit-table .mit-td--opened.mat-mdc-table-sticky{box-shadow:-10px 0 14px -12px color-mix(in srgb,var(--lib-forms-shadow-color) 22%,transparent)}.mit-table .mit-th--opened.mat-mdc-table-sticky+.mat-column-itemRemovalButton.mat-mdc-table-sticky,.mit-table .mit-td--opened.mat-mdc-table-sticky+.mat-column-itemRemovalButton.mat-mdc-table-sticky{box-shadow:none}.mit-actions{display:flex;align-items:center;justify-content:flex-end;gap:.125rem;min-height:1.625rem}.mit-calc-label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mit-chip{--mdc-chip-container-height: 1.375rem;font-size:.625rem}.mit-paginator{--mat-paginator-container-size: 2.5rem;--mat-paginator-container-text-size: .6875rem;--mat-paginator-select-trigger-text-size: .6875rem;--mat-paginator-touch-target-display: none;--mat-paginator-form-field-container-height: 1.75rem;--mat-paginator-form-field-container-vertical-padding: .125rem;--mat-paginator-container-background-color: transparent;--mat-paginator-container-text-color: var(--lib-forms-on-surface-variant);background:var(--lib-forms-surface-container-low)}.mit-shell--fullscreen .mit-paginator{flex:0 0 auto;margin-top:.5rem;border-radius:var(--lib-forms-radius-sm)}.mit-state{display:flex;justify-content:center;padding:1rem;font-size:.8125rem;color:var(--lib-forms-on-surface-variant);opacity:.7}.mit-empty{display:flex;flex-direction:column;align-items:center;text-align:center;gap:.375rem;padding:2.5rem 2rem;color:var(--lib-forms-on-surface-variant)}.mit-empty-title{font-size:.9375rem;font-weight:500;color:var(--lib-forms-on-surface)}.mit-empty-text{margin:0;max-width:24rem;font-size:.8125rem;line-height:1.5}.mit-placeholder{display:flex;justify-content:center;align-items:center;padding:2rem}.mit-data-panel{display:flex;flex-direction:column;min-width:280px;max-width:min(380px,calc(100vw - 16px));max-height:60vh;overflow:hidden;background:var(--lib-forms-surface);border:1px solid color-mix(in srgb,var(--lib-forms-outline) 15%,transparent);border-radius:var(--lib-forms-radius-lg);box-shadow:var(--lib-forms-shadow-floating);animation:mit-fade-in var(--lib-forms-duration) var(--lib-forms-easing)}.mit-data-panel__header{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.5rem .5rem .25rem 1rem;flex-shrink:0}.mit-data-panel__title{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mit-data-panel__body{flex:1;overflow:auto;padding:.25rem 1rem 1rem}@keyframes mit-fade-in{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.mit-data-panel{animation:none}}.option-text{display:flex;flex-direction:column;margin-left:.5rem}.option-main-text{font-size:.875rem;font-weight:500;margin-bottom:2px;line-height:normal}.option-main-text--cancel{color:var(--lib-forms-primary)}.option-sub-text{font-size:.75rem;color:var(--lib-forms-on-surface-variant);font-weight:400;line-height:1.2}.deletion-progress-container{position:relative;padding:0 1rem .5rem}.deletion-message{position:absolute;right:1rem;top:2px;font-size:.6875rem;color:var(--sem-error);font-weight:500;line-height:1.6;animation:mit-pulse 1s infinite}@keyframes mit-pulse{0%{opacity:.7}50%{opacity:1}to{opacity:.7}}@media(max-width:600px){.option-sub-text{max-width:180px;white-space:normal}}\n"], dependencies: [{ kind: "directive", type: CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation", "cdkConnectedOverlayUsePopover", "cdkConnectedOverlayMatchWidth", "cdkConnectedOverlay"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatChipsModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i6.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i6.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i6.MatMenuContent, selector: "ng-template[matMenuContent]" }, { kind: "ngmodule", type: MatPaginatorModule }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i4$1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i4$2.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "ngmodule", type: MatTableModule }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "component", type: TDynamicDataViewComponent, selector: "lib-t-dynamic-data-view", inputs: ["data"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, deferBlockDependencies: [() => [import('@angular/common').then(m => m.NgTemplateOutlet), i2.MatIconButton, i4.MatChip, i3.MatIcon, i6.MatMenuTrigger, i3$1.MatPaginator, i5.MatTable, i5.MatHeaderCellDef, i5.MatHeaderRowDef, i5.MatColumnDef, i5.MatCellDef, i5.MatRowDef, i5.MatHeaderCell, i5.MatCell, i5.MatHeaderRow, i5.MatRow, i5$1.MatTooltip, import('./ngx-t-forms-ngx-t-forms-XLA9yzak.mjs').then(function (n) { return n.bn; }).then(m => m.FormatDataPipe)]] }); }
838
+ }
839
+ i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputTableViewComponent, resolveDeferredDeps: () => [import('@angular/common').then(m => m.NgTemplateOutlet), import('./ngx-t-forms-ngx-t-forms-XLA9yzak.mjs').then(function (n) { return n.bn; }).then(m => m.FormatDataPipe)], resolveMetadata: (NgTemplateOutlet, FormatDataPipe) => ({ decorators: [{
840
+ type: Component,
841
+ args: [{ selector: 'lib-multiple-input-table-view', imports: [
842
+ CdkConnectedOverlay,
843
+ NgTemplateOutlet,
844
+ MatButtonModule,
845
+ MatChipsModule,
846
+ MatIconModule,
847
+ MatMenuModule,
848
+ MatPaginatorModule,
849
+ MatProgressBarModule,
850
+ MatProgressSpinnerModule,
851
+ MatTableModule,
852
+ MatTooltipModule,
853
+ FormatDataPipe,
854
+ TDynamicDataViewComponent,
855
+ ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, host: {
856
+ 'class': 'lib-multiple-input-table-view',
857
+ '[class.lib-multiple-input-table-view--fullscreen]': 'fullscreen()',
858
+ }, template: "@defer (on viewport) {\n <!--\n The table shell is a template so the same markup renders in two places: inline in the form,\n or inside the full-screen dialog. Only one instance exists at a time \u2014 the inline slot empties\n while the dialog is open \u2014 so the shared data source always pages through a single paginator.\n -->\n <ng-template #shell>\n <section class=\"mit-shell\" [class.mit-shell--fullscreen]=\"fullscreen()\">\n <header class=\"mit-toolbar\">\n <div class=\"mit-toolbar__lead\">\n @if (fullscreen()) {\n <h2 class=\"mit-toolbar__title\">{{ inputConfig()?.label }}</h2>\n }\n <span class=\"mit-toolbar__summary\">{{ rowSummary() }}</span>\n </div>\n <div class=\"mit-toolbar__actions\">\n @if (canReload()) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-reload\"\n matTooltip=\"Refresh this list\"\n aria-label=\"Refresh this list\"\n (click)=\"reload()\"\n >\n <mat-icon>sync</mat-icon>\n </button>\n }\n @if (allPossibleLabels().length > 0) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-columns-trigger\"\n matTooltip=\"Choose columns\"\n aria-label=\"Choose columns\"\n [matMenuTriggerFor]=\"colOptions\"\n >\n <mat-icon>view_column</mat-icon>\n </button>\n }\n <button\n #fullscreenToggle\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-fullscreen-toggle\"\n [matTooltip]=\"fullscreen() ? 'Exit full screen' : 'Full screen'\"\n [attr.aria-label]=\"fullscreen() ? 'Exit full screen' : 'Full screen'\"\n [attr.aria-pressed]=\"fullscreen()\"\n (click)=\"toggleFullscreen()\"\n >\n <mat-icon>{{ fullscreen() ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>\n </button>\n </div>\n </header>\n\n @if (displayedColumnsInOrder.length === 0) {\n <div class=\"mit-state\">No columns</div>\n }\n\n <div class=\"mit-scroll\">\n <table mat-table [dataSource]=\"dataSource() ?? []\" class=\"mit-table\">\n @for (col of displayedColumnsInOrder; track col) {\n <!--\n The row number is pinned to the start and the \"opened\" age and actions to the end, so\n a row keeps its identity and stays actionable however far a wide table is scrolled.\n Material needs each pinned group contiguous at its edge, which is why the \"opened\"\n column is inserted before the actions column rather than appended after it.\n -->\n <ng-container\n [matColumnDef]=\"col\"\n [sticky]=\"isIndexColumn(col)\"\n [stickyEnd]=\"isActionsColumn(col) || isOpenedColumn(col)\"\n >\n <th\n mat-header-cell\n *matHeaderCellDef\n scope=\"col\"\n [attr.aria-label]=\"isIndexColumn(col) ? 'Row number' : null\"\n [class.mit-th--index]=\"isIndexColumn(col)\"\n [class.mit-th--opened]=\"isOpenedColumn(col)\"\n [class.mit-th--numeric]=\"isNumericColumn(col)\"\n [class.mit-th--actions]=\"isActionsColumn(col)\"\n >\n @if (isIndexColumn(col)) {\n <span class=\"mit-th-hash\" aria-hidden=\"true\">#</span>\n } @else {\n <span class=\"mit-th-label\">{{ columnLabel(col) }}</span>\n }\n </th>\n <td\n mat-cell\n *matCellDef=\"let row; let rowIndex = index\"\n [class.mit-td--calc]=\"isCalculationRow(row)\"\n [class.mit-td--index]=\"isIndexColumn(col)\"\n [class.mit-td--opened]=\"isOpenedColumn(col)\"\n [class.mit-td--actions]=\"isActionsColumn(col)\"\n [class.mit-td--numeric]=\"isNumericColumn(col)\"\n [style.background]=\"returnBackground(row, columnsConfig()[col])\"\n >\n @if (isIndexColumn(col)) {\n <span class=\"mit-index\">{{ rowNumber(row, rowIndex) }}</span>\n } @else if (isOpenedColumn(col)) {\n <!-- Blank for a row nobody has been into: the column is a record of what the\n author touched, so an empty cell is the honest reading of \"not yet\". -->\n @let opened = openedShort(row);\n @if (opened) {\n <span class=\"mit-opened\" [matTooltip]=\"openedLong(row)\">{{ opened }}</span>\n }\n } @else if (isActionsColumn(col)) {\n <div class=\"mit-actions\">\n @if (showsCalculationLabel(row)) {\n <span class=\"mit-calc-label\">{{ getCalculationFunction(row) }}</span>\n }\n @if (rowIsFlaggedInEdit(row)) {\n <mat-chip class=\"mit-chip\">In {{ inputConfig()?.readonly ? 'View' : 'Edit' }}</mat-chip>\n }\n @if (rowHasActions(row)) {\n @if (showRowEdit()) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-row-edit\"\n [class.mit-icon-button--active]=\"rowIsInEdit(row)\"\n matTooltip=\"Edit\"\n aria-label=\"Edit row\"\n (click)=\"editItem(row)\"\n >\n <mat-icon>edit</mat-icon>\n </button>\n }\n @if (showRowMenu()) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-row-trigger\"\n [class.mit-icon-button--active]=\"t.menuOpen\"\n matTooltip=\"More actions\"\n aria-label=\"More row actions\"\n [matMenuTriggerFor]=\"rowOptions\"\n [matMenuTriggerData]=\"{ row: row }\"\n #t=\"matMenuTrigger\"\n (click)=\"applyOptionsToFn(row)\"\n >\n <mat-icon>{{ t.menuOpen ? 'close' : 'more_horiz' }}</mat-icon>\n </button>\n }\n }\n </div>\n } @else if (isStructuredColumn(col)) {\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-data-button\"\n matTooltip=\"View data\"\n aria-label=\"View data\"\n (click)=\"openDataOverlay($event, row[col])\"\n >\n <mat-icon>data_object</mat-icon>\n </button>\n } @else {\n @let text = row[col] | formatData: columnDataType(col);\n <span class=\"mit-cell-text\" [attr.title]=\"text\">{{ text }}</span>\n }\n </td>\n </ng-container>\n }\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumnsInOrder; sticky: true\"></tr>\n <tr\n mat-row\n *matRowDef=\"let row; columns: displayedColumnsInOrder\"\n class=\"mit-row\"\n [class.mit-row--group-start]=\"hasTopBorder(row)\"\n [class.mit-row--calc]=\"isCalculationRow(row)\"\n [class.mit-row--in-edit]=\"rowIsInEdit(row)\"\n ></tr>\n </table>\n\n @if (isEmpty()) {\n <div class=\"mit-empty\">\n <strong class=\"mit-empty-title\">No items yet</strong>\n <p class=\"mit-empty-text\">\n Use the add button below to create a row. Each saved entry appears here.\n </p>\n </div>\n }\n </div>\n\n @if (showPaginator()) {\n <mat-paginator\n class=\"mit-paginator\"\n [pageIndex]=\"pageIndex()\"\n [pageSize]=\"pageSize()\"\n [pageSizeOptions]=\"pageSizeOptions\"\n showFirstLastButtons\n aria-label=\"Table pagination\"\n (page)=\"onPage($event)\"\n />\n }\n </section>\n </ng-template>\n\n <div class=\"mit-inline\" #inlineHost [style.min-height.px]=\"reservedHeight()\">\n @if (!fullscreen()) {\n <ng-container [ngTemplateOutlet]=\"shell\" />\n }\n </div>\n} @placeholder {\n <div class=\"mit-placeholder\">\n <mat-spinner diameter=\"32\" />\n </div>\n}\n\n<!--\n Structured (array / object) cell values open in a CDK overlay anchored to the button that was\n clicked. An overlay, rather than a fixed-position panel, so it stacks correctly above the\n full-screen dialog and is never clipped by a transformed ancestor.\n-->\n@if (overlayOrigin(); as origin) {\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"origin\"\n [cdkConnectedOverlayOpen]=\"overlayOpen()\"\n [cdkConnectedOverlayHasBackdrop]=\"true\"\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\n [cdkConnectedOverlayPush]=\"true\"\n (backdropClick)=\"closeDataOverlay()\"\n (detach)=\"closeDataOverlay()\"\n >\n <div class=\"mit-data-panel\" role=\"dialog\" aria-label=\"Cell data\">\n <div class=\"mit-data-panel__header\">\n <span class=\"mit-data-panel__title\">Data</span>\n <button\n type=\"button\"\n mat-icon-button\n class=\"mit-icon-button mit-data-close\"\n aria-label=\"Close\"\n (click)=\"closeDataOverlay()\"\n >\n <mat-icon>close</mat-icon>\n </button>\n </div>\n <div class=\"mit-data-panel__body\">\n <lib-t-dynamic-data-view [data]=\"overlayData()\" />\n </div>\n </div>\n </ng-template>\n}\n\n<mat-menu #colOptions=\"matMenu\">\n <ng-template matMenuContent>\n @for (label of allPossibleLabels(); track label.formControlName) {\n <button\n mat-menu-item\n role=\"menuitemcheckbox\"\n [attr.aria-checked]=\"label.selected\"\n (click)=\"toggleTempLabel($event, label.formControlName)\"\n >\n <mat-icon>{{ label.selected ? 'check_box' : 'check_box_outline_blank' }}</mat-icon>\n {{ label.label }}\n </button>\n }\n </ng-template>\n</mat-menu>\n\n<mat-menu #rowOptions=\"matMenu\">\n <ng-template matMenuContent let-row=\"row\">\n @if (isEditable()) {\n @if (userCanAdd()) {\n <button mat-menu-item (click)=\"copy(row)\">\n <mat-icon>content_copy</mat-icon>\n <div class=\"option-text\">\n <div class=\"option-main-text\">Duplicate</div>\n <div class=\"option-sub-text\">Create a copy with the same values</div>\n </div>\n </button>\n }\n\n @if (userCanRemove()) {\n @if (isAboutToDeleteRow(row)) {\n <button mat-menu-item (click)=\"multipleInputRemoveItem($event, row)\">\n <mat-icon color=\"accent\">cancel</mat-icon>\n <div class=\"option-text\">\n <div class=\"option-main-text option-main-text--cancel\">Cancel Deletion</div>\n <div class=\"option-sub-text\">Auto-deleting in {{ secondsCountDown() }} seconds...</div>\n </div>\n </button>\n <div class=\"deletion-progress-container\">\n <mat-progress-bar color=\"warn\" mode=\"determinate\" [value]=\"getCountdownSeconds()\"></mat-progress-bar>\n @if (getCountdownSeconds() > 75) {\n <div class=\"deletion-message\">Deleting soon...</div>\n }\n </div>\n } @else {\n <button mat-menu-item (click)=\"multipleInputRemoveItem($event, row)\">\n <mat-icon color=\"warn\">delete_outline</mat-icon>\n <div class=\"option-text\">\n <div class=\"option-main-text\">Delete</div>\n <div class=\"option-sub-text\">Removes after 3 seconds. Click again to cancel</div>\n </div>\n </button>\n }\n }\n }\n </ng-template>\n</mat-menu>\n", styles: [":host{display:block}.mit-inline{display:block}.mit-shell{display:flex;flex-direction:column;background:var(--lib-forms-surface);border:1px solid color-mix(in srgb,var(--lib-forms-outline) 10%,transparent);border-radius:var(--lib-forms-radius-md);box-shadow:var(--lib-forms-shadow-resting);overflow:hidden}.mit-shell--fullscreen{height:100%;box-sizing:border-box;padding:1.25rem 1.5rem .5rem;border:none;border-radius:0;box-shadow:none}.mit-toolbar{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:.375rem .375rem .375rem .75rem}.mit-shell--fullscreen .mit-toolbar{padding:0 0 1.25rem}.mit-toolbar__lead{display:flex;align-items:center;gap:.75rem;min-width:0}.mit-toolbar__title{margin:0;font-size:1.25rem;font-weight:500;letter-spacing:-.01em;color:var(--lib-forms-on-surface);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mit-toolbar__summary{display:inline-flex;align-items:center;height:1.375rem;padding:0 .5625rem;border-radius:var(--lib-forms-radius-pill);background:color-mix(in srgb,var(--lib-forms-primary) 10%,transparent);color:var(--lib-forms-primary);font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;white-space:nowrap}.mit-toolbar__actions{display:flex;align-items:center;gap:.125rem;flex-shrink:0}.mit-icon-button.mat-mdc-icon-button{--mdc-icon-button-state-layer-size: 1.75rem;--mdc-icon-button-icon-size: 1rem;width:1.75rem;height:1.75rem;padding:.375rem;border-radius:50%;color:var(--lib-forms-on-surface-variant);transition:color var(--lib-forms-duration-hover) var(--lib-forms-easing),background-color var(--lib-forms-duration-hover) var(--lib-forms-easing),box-shadow var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mit-icon-button.mat-mdc-icon-button .mat-icon{font-size:1rem;width:1rem;height:1rem;line-height:1rem}.mit-icon-button.mat-mdc-icon-button:hover,.mit-icon-button.mat-mdc-icon-button:focus-visible{color:var(--lib-forms-primary);background-color:color-mix(in srgb,var(--lib-forms-primary) 10%,transparent)}.mit-icon-button.mat-mdc-icon-button:focus-visible{outline:3px solid color-mix(in srgb,var(--lib-forms-primary) 14%,transparent);outline-offset:1px}.mit-icon-button--active.mat-mdc-icon-button{color:var(--lib-forms-primary);background-color:color-mix(in srgb,var(--lib-forms-primary) 14%,transparent)}.mit-row-edit.mat-mdc-icon-button{color:var(--lib-forms-primary)}.mit-row-edit.mat-mdc-icon-button:hover,.mit-row-edit.mat-mdc-icon-button:focus-visible{background-color:color-mix(in srgb,var(--lib-forms-primary) 14%,transparent);box-shadow:var(--lib-forms-shadow-edge)}.mit-scroll{width:100%;overflow:auto;overscroll-behavior-x:contain;scrollbar-width:thin}.mit-shell--fullscreen .mit-scroll{flex:1 1 auto;min-height:0;border-radius:var(--lib-forms-radius-sm);border:1px solid color-mix(in srgb,var(--lib-forms-outline) 10%,transparent)}.mit-table{--mat-table-row-item-outline-width: 0;--mat-table-background-color: transparent;--mat-table-header-container-height: 1.875rem;--mat-table-row-item-container-height: 2rem;width:100%;background:transparent}.mit-table .mat-mdc-header-row{--mit-row-bg: color-mix(in srgb, var(--lib-forms-primary) 5%, var(--lib-forms-surface));height:1.875rem;background:var(--mit-row-bg)}.mit-table .mat-mdc-header-cell{padding:0 .625rem;white-space:nowrap;background:var(--mit-row-bg)}.mit-th-label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mit-th--numeric,.mit-th--actions{text-align:right}.mit-table .mat-mdc-row{--mit-row-bg: var(--lib-forms-surface);height:2rem;background:var(--mit-row-bg);transition:background-color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mit-table .mat-mdc-row:nth-child(2n){--mit-row-bg: var(--lib-forms-surface-container-low)}.mit-table .mat-mdc-row:hover{--mit-row-bg: color-mix(in srgb, var(--lib-forms-primary) 7%, var(--lib-forms-surface))}.mit-table .mit-row--in-edit,.mit-table .mit-row--in-edit:hover{--mit-row-bg: color-mix(in srgb, var(--lib-forms-primary) 11%, var(--lib-forms-surface))}.mit-table .mit-row--in-edit .mat-mdc-cell:first-child{box-shadow:inset 3px 0 0 var(--lib-forms-primary)}.mit-table .mit-row--calc,.mit-table .mit-row--calc:hover{--mit-row-bg: var(--lib-forms-surface-container-high)}.mit-table .mit-td--calc{font-weight:600}.mit-table .mat-mdc-cell{padding:0 .625rem;font-size:.8125rem;line-height:1.3;color:var(--lib-forms-on-surface);vertical-align:middle}.mit-cell-text{display:block;max-width:18rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mit-shell--fullscreen .mit-cell-text{max-width:40rem}.mit-table .mat-mdc-header-cell:not(.mit-th--index):not(.mit-th--opened):not(.mit-th--actions),.mit-table .mat-mdc-cell:not(.mit-td--index):not(.mit-td--opened):not(.mit-td--actions){min-width:6rem}.mit-td--numeric{text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}.mit-table .mit-row--group-start .mat-mdc-cell{border-top:2px solid var(--lib-forms-outline-variant)}.mit-table .mat-column-itemRemovalButton{width:1%;white-space:nowrap;background:var(--mit-row-bg)}.mit-table .mat-column-itemRemovalButton.mat-mdc-table-sticky{box-shadow:-10px 0 14px -12px color-mix(in srgb,var(--lib-forms-shadow-color) 22%,transparent)}.mit-table .mit-th--index,.mit-table .mit-td--index{width:1%;padding:0 .5rem 0 .625rem;text-align:right;white-space:nowrap;background:var(--mit-row-bg)}.mit-th-hash{font-size:.625rem;font-weight:600;color:var(--lib-forms-on-surface-variant)}.mit-index{font-size:.6875rem;font-variant-numeric:tabular-nums;color:color-mix(in srgb,var(--lib-forms-on-surface-variant) 65%,transparent)}.mit-table .mit-th--opened,.mit-table .mit-td--opened{width:1%;padding:0 .625rem;text-align:right;white-space:nowrap;background:var(--mit-row-bg)}.mit-opened{font-size:.6875rem;font-variant-numeric:tabular-nums;color:color-mix(in srgb,var(--lib-forms-on-surface-variant) 75%,transparent)}.mit-table .mit-th--opened.mat-mdc-table-sticky,.mit-table .mit-td--opened.mat-mdc-table-sticky{box-shadow:-10px 0 14px -12px color-mix(in srgb,var(--lib-forms-shadow-color) 22%,transparent)}.mit-table .mit-th--opened.mat-mdc-table-sticky+.mat-column-itemRemovalButton.mat-mdc-table-sticky,.mit-table .mit-td--opened.mat-mdc-table-sticky+.mat-column-itemRemovalButton.mat-mdc-table-sticky{box-shadow:none}.mit-actions{display:flex;align-items:center;justify-content:flex-end;gap:.125rem;min-height:1.625rem}.mit-calc-label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mit-chip{--mdc-chip-container-height: 1.375rem;font-size:.625rem}.mit-paginator{--mat-paginator-container-size: 2.5rem;--mat-paginator-container-text-size: .6875rem;--mat-paginator-select-trigger-text-size: .6875rem;--mat-paginator-touch-target-display: none;--mat-paginator-form-field-container-height: 1.75rem;--mat-paginator-form-field-container-vertical-padding: .125rem;--mat-paginator-container-background-color: transparent;--mat-paginator-container-text-color: var(--lib-forms-on-surface-variant);background:var(--lib-forms-surface-container-low)}.mit-shell--fullscreen .mit-paginator{flex:0 0 auto;margin-top:.5rem;border-radius:var(--lib-forms-radius-sm)}.mit-state{display:flex;justify-content:center;padding:1rem;font-size:.8125rem;color:var(--lib-forms-on-surface-variant);opacity:.7}.mit-empty{display:flex;flex-direction:column;align-items:center;text-align:center;gap:.375rem;padding:2.5rem 2rem;color:var(--lib-forms-on-surface-variant)}.mit-empty-title{font-size:.9375rem;font-weight:500;color:var(--lib-forms-on-surface)}.mit-empty-text{margin:0;max-width:24rem;font-size:.8125rem;line-height:1.5}.mit-placeholder{display:flex;justify-content:center;align-items:center;padding:2rem}.mit-data-panel{display:flex;flex-direction:column;min-width:280px;max-width:min(380px,calc(100vw - 16px));max-height:60vh;overflow:hidden;background:var(--lib-forms-surface);border:1px solid color-mix(in srgb,var(--lib-forms-outline) 15%,transparent);border-radius:var(--lib-forms-radius-lg);box-shadow:var(--lib-forms-shadow-floating);animation:mit-fade-in var(--lib-forms-duration) var(--lib-forms-easing)}.mit-data-panel__header{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.5rem .5rem .25rem 1rem;flex-shrink:0}.mit-data-panel__title{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mit-data-panel__body{flex:1;overflow:auto;padding:.25rem 1rem 1rem}@keyframes mit-fade-in{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.mit-data-panel{animation:none}}.option-text{display:flex;flex-direction:column;margin-left:.5rem}.option-main-text{font-size:.875rem;font-weight:500;margin-bottom:2px;line-height:normal}.option-main-text--cancel{color:var(--lib-forms-primary)}.option-sub-text{font-size:.75rem;color:var(--lib-forms-on-surface-variant);font-weight:400;line-height:1.2}.deletion-progress-container{position:relative;padding:0 1rem .5rem}.deletion-message{position:absolute;right:1rem;top:2px;font-size:.6875rem;color:var(--sem-error);font-weight:500;line-height:1.6;animation:mit-pulse 1s infinite}@keyframes mit-pulse{0%{opacity:.7}50%{opacity:1}to{opacity:.7}}@media(max-width:600px){.option-sub-text{max-width:180px;white-space:normal}}\n"] }]
859
+ }], ctorParameters: () => [], propDecorators: { inputConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputConfig", required: false }] }], dataSource: [{ type: i0.Input, args: [{ isSignal: true, alias: "dataSource", required: false }] }], applyOptionsTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "applyOptionsTo", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }], onEditItem: [{ type: i0.Output, args: ["onEditItem"] }], onDeleteItem: [{ type: i0.Output, args: ["onDeleteItem"] }], onCopy: [{ type: i0.Output, args: ["onCopy"] }], onApplyOptionsTo: [{ type: i0.Output, args: ["onApplyOptionsTo"] }], showItemAsLabel: [{ type: i0.Output, args: ["showItemAsLabel"] }], paginator: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MatPaginator), { isSignal: true }] }], shellTemplate: [{ type: i0.ViewChild, args: ['shell', { isSignal: true }] }], inlineHost: [{ type: i0.ViewChild, args: ['inlineHost', { isSignal: true }] }], fullscreenToggle: [{ type: i0.ViewChild, args: ['fullscreenToggle', { ...{ read: ElementRef }, isSignal: true }] }] } }) });
860
+
861
+ class MultipleInputTableEditComponent {
862
+ constructor() {
863
+ this.InputComponent = TFormInputComponent;
864
+ this.inputConfig = input.required(...(ngDevMode ? [{ debugName: "inputConfig" }] : /* istanbul ignore next */ []));
865
+ this.editorMode = input(false, ...(ngDevMode ? [{ debugName: "editorMode" }] : /* istanbul ignore next */ []));
866
+ this.formGroup = input(null, ...(ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []));
867
+ this.formBuilderFunctions = input(undefined, ...(ngDevMode ? [{ debugName: "formBuilderFunctions" }] : /* istanbul ignore next */ []));
868
+ this.onSaveMultipleInputForm = output();
869
+ this.editMultipleInput = output();
870
+ this.deleteInput = output();
871
+ this.showItemAsLabel = output();
872
+ this.addFunction = output();
873
+ this.reorderItems = output();
874
+ this.calculationFunctions = Object.values(CalculationFunctions);
875
+ this.activeInput = '';
876
+ this.dragging = false;
877
+ this.overId = null;
878
+ this.areYouSure = false;
879
+ this.countdownSeconds = {};
880
+ this.innerInputs = computed(() => {
881
+ const cfg = this.inputConfig();
882
+ return (cfg?.formInputs?.map((input) => ({
883
+ ...input,
884
+ originalId: input.id,
885
+ id: `${cfg?.id}.${input.id}`,
886
+ })) || []);
887
+ }, ...(ngDevMode ? [{ debugName: "innerInputs" }] : /* istanbul ignore next */ []));
888
+ this.rowInUpdate = computed(() => {
889
+ const cfg = this.inputConfig();
890
+ const fg = this.formGroup();
891
+ return !!cfg?.formIsOpen && !!fg?.controls[`${cfg?.id}.id`]?.value;
892
+ }, ...(ngDevMode ? [{ debugName: "rowInUpdate" }] : /* istanbul ignore next */ []));
893
+ this.formInvalid = computed(() => {
894
+ const cfg = this.inputConfig();
895
+ const fg = this.formGroup();
896
+ const allControls = [];
897
+ cfg?.formInputs?.forEach((input) => {
898
+ const control = fg?.controls[`${cfg?.id}.${input.id}`];
899
+ if (control) {
900
+ allControls.push(control);
901
+ }
902
+ });
903
+ return allControls.some((control) => control?.invalid || !control);
904
+ }, ...(ngDevMode ? [{ debugName: "formInvalid" }] : /* istanbul ignore next */ []));
905
+ this.#destroyRef = inject(DestroyRef);
906
+ }
907
+ #destroyRef;
908
+ ngOnDestroy() {
909
+ Object.values(this.countdownSeconds).forEach(({ stop$ }) => stop$.complete());
910
+ }
911
+ saveMultipleInputForm() {
912
+ this.onSaveMultipleInputForm.emit();
913
+ }
914
+ inputWillBeRemovedIn(id) {
915
+ return this.countdownSeconds[id]?.count;
916
+ }
917
+ removeInput(item) {
918
+ if (this.countdownSeconds[item.id]) {
919
+ this.stopDeletion(item.id);
920
+ return;
921
+ }
922
+ this.countdownSeconds[item.id] = {
923
+ count: 5,
924
+ stop$: new Subject(),
925
+ };
926
+ const countdown$ = timer(0, 1000).pipe(tap((secondsElapsed) => {
927
+ const data = this.countdownSeconds[item.id];
928
+ if (!data) {
929
+ return;
930
+ }
931
+ const remainingTime = 5 - secondsElapsed;
932
+ if (remainingTime <= 0) {
933
+ this.formDeleteInput(item);
934
+ this.stopDeletion(item.id);
935
+ }
936
+ else {
937
+ data.count = remainingTime;
938
+ }
939
+ }), takeUntil(this.countdownSeconds[item.id].stop$), takeUntilDestroyed(this.#destroyRef));
940
+ countdown$.subscribe({
941
+ complete: () => { },
942
+ });
943
+ }
944
+ stopDeletion(id) {
945
+ if (this.countdownSeconds[id]) {
946
+ this.countdownSeconds[id]?.stop$.next();
947
+ delete this.countdownSeconds[id];
948
+ }
949
+ }
950
+ formDeleteInput(item) {
951
+ this.deleteInput.emit(item);
952
+ }
953
+ dropItems(event) {
954
+ this.reorderItems.emit(event);
955
+ }
956
+ editInput(input) {
957
+ this.editMultipleInput.emit(input);
958
+ }
959
+ toggleLabel(item) {
960
+ this.showItemAsLabel.emit(item);
961
+ }
962
+ toggleFunction(func, _inputId) {
963
+ const addFunction = {
964
+ id: v4(),
965
+ inputId: this.activeInput,
966
+ func,
967
+ };
968
+ this.addFunction.emit(addFunction);
969
+ }
970
+ selectedFunction(func) {
971
+ return this.inputConfig()?.calculateListFunctions?.find((f) => f.inputId === this.activeInput && f.func === func);
972
+ }
973
+ closeMultipleInput() {
974
+ if (this.areYouSure) {
975
+ this.formBuilderFunctions()?.multipleInputToggleForm(this.inputConfig().id, false);
976
+ this.areYouSure = false;
977
+ return;
978
+ }
979
+ this.areYouSure = true;
980
+ }
981
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputTableEditComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
982
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: MultipleInputTableEditComponent, isStandalone: true, selector: "lib-multiple-input-table-edit", inputs: { inputConfig: { classPropertyName: "inputConfig", publicName: "inputConfig", isSignal: true, isRequired: true, transformFunction: null }, editorMode: { classPropertyName: "editorMode", publicName: "editorMode", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null }, formBuilderFunctions: { classPropertyName: "formBuilderFunctions", publicName: "formBuilderFunctions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSaveMultipleInputForm: "onSaveMultipleInputForm", editMultipleInput: "editMultipleInput", deleteInput: "deleteInput", showItemAsLabel: "showItemAsLabel", addFunction: "addFunction", reorderItems: "reorderItems" }, ngImport: i0, template: "<mat-card appearance=\"outlined\" class=\"edit-card mat-elevation-z4\">\r\n <mat-card-content>\r\n <div class=\"list row\" (cdkDropListDropped)=\"dropItems($event)\"\r\n [cdkDropListData]=\"innerInputs()\" cdkDropList #InputList=\"cdkDropList\">\r\n @for (innerInput of innerInputs(); track innerInput.id) {\r\n <ng-container>\r\n @if (editorMode()) {\r\n @if (!!formGroup()) {\r\n <mat-card (mouseover)=\"activeInput = innerInput.id\" cdkDrag\r\n (cdkDragStarted)=\"dragging = true\" (cdkDragReleased)=\"dragging = false\"\r\n [class.inputCardElevated]=\"activeInput === innerInput.id\"\r\n [class.inputCard]=\"activeInput !== innerInput.id\"\r\n [class]=\"'col-md-' + (dragging ? '12' : innerInput.colSize)\" class=\"box\">\r\n <ng-container *ngComponentOutlet=\"InputComponent;\r\n inputs: {\r\n inputConfig: innerInput,\r\n formGroup: formGroup(),\r\n formBuilderFunctions: formBuilderFunctions(),\r\n }\">\r\n </ng-container>\r\n @if (activeInput === innerInput.id) {\r\n <mat-card-actions class=\"input-actions\">\r\n <span class=\"spacer\"></span>\r\n <button [matTooltip]=\"'Edit Input: ' + innerInput.label\"\r\n (click)=\"editInput(innerInput)\" mat-icon-button>\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n @if (!!inputWillBeRemovedIn(innerInput.id)) {\r\n <button (mouseover)=\"overId = innerInput.id\" (mouseout)=\"overId = null\"\r\n (click)=\"removeInput(innerInput)\" color=\"warn\" mat-stroked-button>\r\n <div class=\"countdown-button\">\r\n <mat-progress-spinner class=\"cancelProgress\" color=\"primary\"\r\n [value]=\"((inputWillBeRemovedIn(innerInput.id) || 0) / 5) * 100\">\r\n </mat-progress-spinner>\r\n {{ overId === innerInput.id ? 'Click to cancel' : 'Deleting in' }}\r\n {{ inputWillBeRemovedIn(innerInput.id) }}\r\n </div>\r\n </button>\r\n } @else if (inputConfig().systemDefault !== true && innerInput.systemDefault !== true) {\r\n <button [matTooltip]=\"'Delete input ' + innerInput.label\"\r\n (click)=\"removeInput(innerInput)\" mat-icon-button>\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n }\r\n <span class=\"action-divider\"></span>\r\n @if (!!innerInput.showAsLabel && innerInput.dataType === 'number' || !!innerInput.showAsLabel && innerInput.type === 'number') {\r\n <button\r\n [matMenuTriggerFor]=\"calculationMenu\"\r\n [matMenuTriggerData]=\"{inputId:innerInput.originalId || innerInput.id}\"\r\n [matTooltip]=\"'calculate sum,avg,min,max'\"\r\n mat-icon-button>\r\n <mat-icon>calculate</mat-icon>\r\n </button>\r\n }\r\n <button [color]=\"innerInput.showAsLabel ? 'primary' : ''\"\r\n (click)=\"toggleLabel(innerInput)\"\r\n [matTooltip]=\"innerInput.showAsLabel ? 'Hide as label' : 'Show as label'\"\r\n mat-icon-button>\r\n <mat-icon>label</mat-icon>\r\n </button>\r\n <span class=\"spacer\"></span>\r\n </mat-card-actions>\r\n }\r\n </mat-card>\r\n }\r\n } @else {\r\n <div [class]=\"'col-md-' + (dragging ? '12' : innerInput.colSize)\" class=\"box\">\r\n <ng-container *ngComponentOutlet=\"InputComponent;\r\n inputs: {\r\n inputConfig: innerInput,\r\n formGroup: formGroup(),\r\n formBuilderFunctions: formBuilderFunctions(),\r\n }\">\r\n </ng-container>\r\n </div>\r\n }\r\n </ng-container>\r\n }\r\n @if (!!editorMode() && innerInputs().length === 0) {\r\n <div class=\"tree-instructions\">\r\n <mat-icon class=\"info-icon\" color=\"primary\">info</mat-icon>\r\n <span>\r\n <strong>Add Form Input</strong>\r\n <br>\r\n Manage your list by adding, editing, or removing items. Each item is customizable through a form.\r\n </span>\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n @if (innerInputs().length !== 0) {\r\n <mat-divider></mat-divider>\r\n <mat-card-actions align=\"end\" class=\"edit-card-actions\">\r\n <button [color]=\"areYouSure ? 'warn' : ''\"\r\n [class.confirm-leave]=\"areYouSure\" mat-button\r\n (click)=\"closeMultipleInput()\">\r\n {{ areYouSure ? \"leave without saving\" : \"cancel\" }}\r\n </button>\r\n @if (!inputConfig().readonly) {\r\n <button [disabled]=\"!!formInvalid()\" class=\"save-button\" color=\"primary\"\r\n (click)=\"saveMultipleInputForm()\" mat-raised-button>\r\n {{ rowInUpdate() ? \"Update\" : \"Save\" }}\r\n </button>\r\n }\r\n </mat-card-actions>\r\n }\r\n</mat-card>\r\n\r\n\r\n<mat-menu #calculationMenu=\"matMenu\">\r\n <ng-template matMenuContent let-inputId=\"sectionId\">\r\n @for (func of calculationFunctions; track func) {\r\n <button (click)=\"toggleFunction(func, inputId)\" mat-menu-item>\r\n {{ func }}\r\n @if (selectedFunction(func)) {\r\n <mat-icon color=\"primary\">check_circle</mat-icon>\r\n }\r\n </button>\r\n }\r\n </ng-template>\r\n</mat-menu>\r\n", styles: [".edit-card{margin-top:.5rem;background:var(--mat-sys-surface-container, #f3edf7);border-radius:12px}.inputCardElevated{background:var(--mat-sys-surface, #fef7ff);box-shadow:var(--mdc-elevated-card-container-elevation);transition:box-shadow .3s cubic-bezier(.16,1,.3,1)}.inputCard{box-shadow:none;transition:box-shadow .3s cubic-bezier(.16,1,.3,1)}.list{min-height:60px}.box{padding:.25rem;cursor:move}.input-actions{display:flex;align-items:center;gap:.125rem}.action-divider{width:1px;align-self:stretch;margin:.25rem;background:color-mix(in srgb,var(--mat-sys-outline, #79747e) 25%,transparent)}.countdown-button{display:flex;align-items:center}.cdk-drag-preview{box-sizing:border-box;border:none;border-radius:8px;box-shadow:0 5px 5px -3px color-mix(in srgb,var(--mat-sys-shadow, #000) 20%,transparent),0 8px 10px 1px color-mix(in srgb,var(--mat-sys-shadow, #000) 14%,transparent),0 3px 14px 2px color-mix(in srgb,var(--mat-sys-shadow, #000) 12%,transparent)}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.box:last-child{border:none}.list.cdk-drop-list-dragging .box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.cancelProgress{height:24px!important;width:24px!important;margin-right:.3125rem}.edit-card-actions{gap:.5rem;padding:.5rem .75rem .75rem}.confirm-leave{text-decoration:underline}.save-button{min-width:10em}.tree-instructions{display:flex;align-items:center;gap:.5rem;padding:.75rem;background:color-mix(in srgb,var(--mat-sys-primary, #6750a4) 6%,transparent);border:1px solid color-mix(in srgb,var(--mat-sys-primary, #6750a4) 14%,transparent);border-radius:8px;margin-bottom:1rem;font-size:.8125rem;color:var(--mat-sys-on-surface-variant, #49454f)}.info-icon{min-width:38px!important;display:block;margin-top:4px;margin-bottom:auto}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3$2.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i1.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatCardModule }, { kind: "component", type: i3$3.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i3$3.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "directive", type: i3$3.MatCardContent, selector: "mat-card-content" }, { kind: "ngmodule", type: MatDividerModule }, { kind: "component", type: i6$1.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i6.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i6.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i6.MatMenuContent, selector: "ng-template[matMenuContent]" }, { kind: "directive", type: i6.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i4$2.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i5$1.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
983
+ }
984
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputTableEditComponent, decorators: [{
985
+ type: Component,
986
+ args: [{ selector: 'lib-multiple-input-table-edit', imports: [
987
+ CommonModule,
988
+ DragDropModule,
989
+ MatButtonModule,
990
+ MatCardModule,
991
+ MatDividerModule,
992
+ MatIconModule,
993
+ MatMenuModule,
994
+ MatProgressSpinnerModule,
995
+ MatTooltipModule,
996
+ ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, template: "<mat-card appearance=\"outlined\" class=\"edit-card mat-elevation-z4\">\r\n <mat-card-content>\r\n <div class=\"list row\" (cdkDropListDropped)=\"dropItems($event)\"\r\n [cdkDropListData]=\"innerInputs()\" cdkDropList #InputList=\"cdkDropList\">\r\n @for (innerInput of innerInputs(); track innerInput.id) {\r\n <ng-container>\r\n @if (editorMode()) {\r\n @if (!!formGroup()) {\r\n <mat-card (mouseover)=\"activeInput = innerInput.id\" cdkDrag\r\n (cdkDragStarted)=\"dragging = true\" (cdkDragReleased)=\"dragging = false\"\r\n [class.inputCardElevated]=\"activeInput === innerInput.id\"\r\n [class.inputCard]=\"activeInput !== innerInput.id\"\r\n [class]=\"'col-md-' + (dragging ? '12' : innerInput.colSize)\" class=\"box\">\r\n <ng-container *ngComponentOutlet=\"InputComponent;\r\n inputs: {\r\n inputConfig: innerInput,\r\n formGroup: formGroup(),\r\n formBuilderFunctions: formBuilderFunctions(),\r\n }\">\r\n </ng-container>\r\n @if (activeInput === innerInput.id) {\r\n <mat-card-actions class=\"input-actions\">\r\n <span class=\"spacer\"></span>\r\n <button [matTooltip]=\"'Edit Input: ' + innerInput.label\"\r\n (click)=\"editInput(innerInput)\" mat-icon-button>\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n @if (!!inputWillBeRemovedIn(innerInput.id)) {\r\n <button (mouseover)=\"overId = innerInput.id\" (mouseout)=\"overId = null\"\r\n (click)=\"removeInput(innerInput)\" color=\"warn\" mat-stroked-button>\r\n <div class=\"countdown-button\">\r\n <mat-progress-spinner class=\"cancelProgress\" color=\"primary\"\r\n [value]=\"((inputWillBeRemovedIn(innerInput.id) || 0) / 5) * 100\">\r\n </mat-progress-spinner>\r\n {{ overId === innerInput.id ? 'Click to cancel' : 'Deleting in' }}\r\n {{ inputWillBeRemovedIn(innerInput.id) }}\r\n </div>\r\n </button>\r\n } @else if (inputConfig().systemDefault !== true && innerInput.systemDefault !== true) {\r\n <button [matTooltip]=\"'Delete input ' + innerInput.label\"\r\n (click)=\"removeInput(innerInput)\" mat-icon-button>\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n }\r\n <span class=\"action-divider\"></span>\r\n @if (!!innerInput.showAsLabel && innerInput.dataType === 'number' || !!innerInput.showAsLabel && innerInput.type === 'number') {\r\n <button\r\n [matMenuTriggerFor]=\"calculationMenu\"\r\n [matMenuTriggerData]=\"{inputId:innerInput.originalId || innerInput.id}\"\r\n [matTooltip]=\"'calculate sum,avg,min,max'\"\r\n mat-icon-button>\r\n <mat-icon>calculate</mat-icon>\r\n </button>\r\n }\r\n <button [color]=\"innerInput.showAsLabel ? 'primary' : ''\"\r\n (click)=\"toggleLabel(innerInput)\"\r\n [matTooltip]=\"innerInput.showAsLabel ? 'Hide as label' : 'Show as label'\"\r\n mat-icon-button>\r\n <mat-icon>label</mat-icon>\r\n </button>\r\n <span class=\"spacer\"></span>\r\n </mat-card-actions>\r\n }\r\n </mat-card>\r\n }\r\n } @else {\r\n <div [class]=\"'col-md-' + (dragging ? '12' : innerInput.colSize)\" class=\"box\">\r\n <ng-container *ngComponentOutlet=\"InputComponent;\r\n inputs: {\r\n inputConfig: innerInput,\r\n formGroup: formGroup(),\r\n formBuilderFunctions: formBuilderFunctions(),\r\n }\">\r\n </ng-container>\r\n </div>\r\n }\r\n </ng-container>\r\n }\r\n @if (!!editorMode() && innerInputs().length === 0) {\r\n <div class=\"tree-instructions\">\r\n <mat-icon class=\"info-icon\" color=\"primary\">info</mat-icon>\r\n <span>\r\n <strong>Add Form Input</strong>\r\n <br>\r\n Manage your list by adding, editing, or removing items. Each item is customizable through a form.\r\n </span>\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n @if (innerInputs().length !== 0) {\r\n <mat-divider></mat-divider>\r\n <mat-card-actions align=\"end\" class=\"edit-card-actions\">\r\n <button [color]=\"areYouSure ? 'warn' : ''\"\r\n [class.confirm-leave]=\"areYouSure\" mat-button\r\n (click)=\"closeMultipleInput()\">\r\n {{ areYouSure ? \"leave without saving\" : \"cancel\" }}\r\n </button>\r\n @if (!inputConfig().readonly) {\r\n <button [disabled]=\"!!formInvalid()\" class=\"save-button\" color=\"primary\"\r\n (click)=\"saveMultipleInputForm()\" mat-raised-button>\r\n {{ rowInUpdate() ? \"Update\" : \"Save\" }}\r\n </button>\r\n }\r\n </mat-card-actions>\r\n }\r\n</mat-card>\r\n\r\n\r\n<mat-menu #calculationMenu=\"matMenu\">\r\n <ng-template matMenuContent let-inputId=\"sectionId\">\r\n @for (func of calculationFunctions; track func) {\r\n <button (click)=\"toggleFunction(func, inputId)\" mat-menu-item>\r\n {{ func }}\r\n @if (selectedFunction(func)) {\r\n <mat-icon color=\"primary\">check_circle</mat-icon>\r\n }\r\n </button>\r\n }\r\n </ng-template>\r\n</mat-menu>\r\n", styles: [".edit-card{margin-top:.5rem;background:var(--mat-sys-surface-container, #f3edf7);border-radius:12px}.inputCardElevated{background:var(--mat-sys-surface, #fef7ff);box-shadow:var(--mdc-elevated-card-container-elevation);transition:box-shadow .3s cubic-bezier(.16,1,.3,1)}.inputCard{box-shadow:none;transition:box-shadow .3s cubic-bezier(.16,1,.3,1)}.list{min-height:60px}.box{padding:.25rem;cursor:move}.input-actions{display:flex;align-items:center;gap:.125rem}.action-divider{width:1px;align-self:stretch;margin:.25rem;background:color-mix(in srgb,var(--mat-sys-outline, #79747e) 25%,transparent)}.countdown-button{display:flex;align-items:center}.cdk-drag-preview{box-sizing:border-box;border:none;border-radius:8px;box-shadow:0 5px 5px -3px color-mix(in srgb,var(--mat-sys-shadow, #000) 20%,transparent),0 8px 10px 1px color-mix(in srgb,var(--mat-sys-shadow, #000) 14%,transparent),0 3px 14px 2px color-mix(in srgb,var(--mat-sys-shadow, #000) 12%,transparent)}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.box:last-child{border:none}.list.cdk-drop-list-dragging .box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.cancelProgress{height:24px!important;width:24px!important;margin-right:.3125rem}.edit-card-actions{gap:.5rem;padding:.5rem .75rem .75rem}.confirm-leave{text-decoration:underline}.save-button{min-width:10em}.tree-instructions{display:flex;align-items:center;gap:.5rem;padding:.75rem;background:color-mix(in srgb,var(--mat-sys-primary, #6750a4) 6%,transparent);border:1px solid color-mix(in srgb,var(--mat-sys-primary, #6750a4) 14%,transparent);border-radius:8px;margin-bottom:1rem;font-size:.8125rem;color:var(--mat-sys-on-surface-variant, #49454f)}.info-icon{min-width:38px!important;display:block;margin-top:4px;margin-bottom:auto}\n"] }]
997
+ }], propDecorators: { inputConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputConfig", required: true }] }], editorMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "editorMode", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }], formBuilderFunctions: [{ type: i0.Input, args: [{ isSignal: true, alias: "formBuilderFunctions", required: false }] }], onSaveMultipleInputForm: [{ type: i0.Output, args: ["onSaveMultipleInputForm"] }], editMultipleInput: [{ type: i0.Output, args: ["editMultipleInput"] }], deleteInput: [{ type: i0.Output, args: ["deleteInput"] }], showItemAsLabel: [{ type: i0.Output, args: ["showItemAsLabel"] }], addFunction: [{ type: i0.Output, args: ["addFunction"] }], reorderItems: [{ type: i0.Output, args: ["reorderItems"] }] } });
998
+
999
+ function getCaluculatedTableData(inputConfig, data) {
1000
+ try {
1001
+ if (!Array.isArray(data) || !inputConfig)
1002
+ return data;
1003
+ const input = inputConfig;
1004
+ const funcs = (input?.calculateListFunctions || []);
1005
+ const allUniqueFunctionNames = [
1006
+ ...new Set(funcs.map((f) => f.func)),
1007
+ ];
1008
+ const calculatedData = allUniqueFunctionNames.map((func) => {
1009
+ const newCalculatedData = {
1010
+ SYSTEM_KEY_PROPERTY_FOR_MULTIPLE_INPUTS_CALCULATION_FUNCTION: func,
1011
+ };
1012
+ funcs.filter((f) => f.func === func).forEach((f) => {
1013
+ const arrayValues = data.map((d) => Number(d[f.inputId]));
1014
+ newCalculatedData[f.inputId] = calculateListOveralFunctions(func, arrayValues);
1015
+ });
1016
+ return newCalculatedData;
1017
+ });
1018
+ return [...data, ...calculatedData];
1019
+ }
1020
+ catch (error) {
1021
+ return data;
1022
+ }
1023
+ }
1024
+
1025
+ /**
1026
+ * Pure helpers behind the multiple-input spreadsheet import.
1027
+ *
1028
+ * Four concerns, all Angular-free so they can be tested directly:
1029
+ *
1030
+ * 1. {@link describeImportColumns} — which spreadsheet columns a field expects,
1031
+ * derived from its child inputs the way the bulk-import template is: an
1032
+ * mSCOA child expands into one debit/credit column per segment per active
1033
+ * basis, a date range into start/end, and binary inputs (files, signatures,
1034
+ * images) are listed so the user knows they are not importable. Each column
1035
+ * carries a hint — what to type into its cells — read off the child's type
1036
+ * and constraints. A choice column says its options may be named as the
1037
+ * form shows them (the import swaps a label, or a table row's column value,
1038
+ * for the stored value).
1039
+ * 2. {@link buildImportTemplate} — the workbook a host's writer serialises: a
1040
+ * data sheet with exactly those headers, and a `Guide` sheet of the hints.
1041
+ * 3. {@link mapSpreadsheetRows} — matches a sheet's headers to those columns and
1042
+ * re-keys the rows by `formControlName`, the shape `TFormImportController`
1043
+ * validates.
1044
+ * 4. {@link coerceImportedRow} + {@link toMultipleInputRow} — turn a settled,
1045
+ * valid row into the composite-keyed record the table stores, with cells
1046
+ * coerced to the child's declared data type.
1047
+ */
1048
+ /** Name of the template sheet that explains the data sheet's columns. */
1049
+ const TEMPLATE_GUIDE_SHEET = 'Guide';
1050
+ /** Headers of the guide sheet, in order. */
1051
+ const GUIDE_HEADERS = ['Column', 'Label', 'Required', 'What to enter'];
1052
+ /** Elements whose value is binary and cannot be typed into a cell. */
1053
+ const BINARY_ELEMENTS = new Set([
1054
+ ElementTypes.FileUpload,
1055
+ ElementTypes.Signature,
1056
+ ElementTypes.ImageCapture,
1057
+ ]);
1058
+ /** Cap on how many static option values a hint spells out. */
1059
+ const MAX_LISTED_OPTIONS = 10;
1060
+ /** Hint for a column whose value cannot travel through a cell. */
1061
+ const NOT_IMPORTABLE_HINT = 'Cannot be imported from a spreadsheet — add it in the row editor once the rows are in.';
1062
+ /** Header comparison key: trimmed and case-folded. */
1063
+ const normalise = (header) => header.trim().toLowerCase();
1064
+ const isBlank = (value) => value === null || value === undefined || (typeof value === 'string' && value.trim() === '');
1065
+ const hasUsableId = (candidate) => candidate !== undefined &&
1066
+ candidate !== null &&
1067
+ !(typeof candidate === 'string' && candidate.trim().length === 0);
1068
+ /**
1069
+ * Lists the columns a sheet should carry to fill `input`, one per child input
1070
+ * (or per expanded leaf for mSCOA and date-range children).
1071
+ *
1072
+ * Section titles and children without a `formControlName` own no column. The
1073
+ * order follows `formInputs`, so the list reads like the row editor.
1074
+ */
1075
+ function describeImportColumns(input) {
1076
+ const columns = [];
1077
+ for (const child of input.formInputs ?? []) {
1078
+ if (!child?.formControlName || child.element === ElementTypes.SectionTitle)
1079
+ continue;
1080
+ const label = child.label || child.formControlName;
1081
+ const required = !!child.required;
1082
+ const aliases = label === child.formControlName ? [] : [label];
1083
+ if (BINARY_ELEMENTS.has(child.element)) {
1084
+ columns.push({ key: child.formControlName, label, required, importable: false, aliases, hint: NOT_IMPORTABLE_HINT });
1085
+ continue;
1086
+ }
1087
+ if (child.element === ElementTypes.MscoaSelection) {
1088
+ columns.push(...describeMscoaColumns(child, label, required));
1089
+ continue;
1090
+ }
1091
+ if (child.element === ElementTypes.DateRangePicker) {
1092
+ const { startKey, endKey } = resolveDateRangeControlNames(child);
1093
+ columns.push({
1094
+ key: startKey,
1095
+ label: `${label} start date`,
1096
+ required,
1097
+ importable: true,
1098
+ aliases: [`${label} start date`],
1099
+ hint: `Date (YYYY-MM-DD). The start of the "${label}" range.`,
1100
+ }, {
1101
+ key: endKey,
1102
+ label: `${label} end date`,
1103
+ required,
1104
+ importable: true,
1105
+ aliases: [`${label} end date`],
1106
+ hint: `Date (YYYY-MM-DD). The end of the "${label}" range, on or after its start.`,
1107
+ });
1108
+ continue;
1109
+ }
1110
+ columns.push({ key: child.formControlName, label, required, importable: true, aliases, hint: describeEntry(child) });
1111
+ }
1112
+ return columns;
1113
+ }
1114
+ /**
1115
+ * One `.debit` / `.credit` column per configured segment, per active accounting
1116
+ * basis — the keys `TFormImportController`'s mSCOA pre-processor reads
1117
+ * (`{formControlName}.{basis}.{SEGMENT}.{debit|credit}`).
1118
+ */
1119
+ function describeMscoaColumns(child, label, required) {
1120
+ const cfg = child.mscoaConfig;
1121
+ if (!cfg)
1122
+ return [];
1123
+ const basis = (cfg.accountingBasis ?? '').toLowerCase();
1124
+ const isDual = basis === 'dual';
1125
+ const isCashOnly = basis === 'cash';
1126
+ const accountLabel = cfg.accountValueLabel || 'mSCOA account';
1127
+ const bases = [];
1128
+ if (!isCashOnly || isDual)
1129
+ bases.push({ basisKey: 'accrual', segments: cfg.segments ?? [] });
1130
+ if (isCashOnly || isDual)
1131
+ bases.push({ basisKey: 'cash', segments: cfg.cashSegments ?? [] });
1132
+ const columns = [];
1133
+ for (const { basisKey, segments } of bases) {
1134
+ for (const seg of segments) {
1135
+ const segKey = (seg.customSegment || seg.segment || '').toUpperCase();
1136
+ if (!segKey)
1137
+ continue;
1138
+ const segLabel = seg.label || segKey;
1139
+ const pairRule = seg.singleSelect
1140
+ ? 'Either the debit or the credit column of the segment is enough.'
1141
+ : 'Both the debit and the credit column of the segment are expected.';
1142
+ for (const side of ['debit', 'credit']) {
1143
+ columns.push({
1144
+ key: `${child.formControlName}.${basisKey}.${segKey}.${side}`,
1145
+ label: `${label} · ${segLabel} ${basisKey} ${side}`,
1146
+ required,
1147
+ importable: true,
1148
+ aliases: [],
1149
+ hint: `The ${accountLabel} value of the "${segLabel}" segment, ${basisKey} basis, ${side} side. ${pairRule}`,
1150
+ });
1151
+ }
1152
+ }
1153
+ }
1154
+ return columns;
1155
+ }
1156
+ /**
1157
+ * What to type into a cell of `child`: the kind of value its declared type
1158
+ * calls for, then every constraint its configuration states — allowed values,
1159
+ * bounds, length, pattern — and a note when the form normally works the value
1160
+ * out itself.
1161
+ */
1162
+ function describeEntry(child) {
1163
+ const parts = [`${describeValueKind(child)}.`];
1164
+ const options = staticOptionLabels(child);
1165
+ if (child.element === ElementTypes.PaginatedSelectionTable) {
1166
+ parts.push(describeTableEntry(child));
1167
+ }
1168
+ else if (options.length > 0) {
1169
+ const shown = options.slice(0, MAX_LISTED_OPTIONS);
1170
+ const tail = options.length > shown.length ? `, … (${options.length} in total)` : '';
1171
+ parts.push(`One of: ${shown.join(' | ')}${tail} — as the form shows it, or its stored value.`);
1172
+ }
1173
+ else if (child.matOptions?.fetch?.options) {
1174
+ parts.push('The options are loaded by the form — enter one as its picker shows it, or its stored value.');
1175
+ }
1176
+ if (child.allowMultipleSelection || child.multiSelect) {
1177
+ parts.push('Several values may be given as a JSON array.');
1178
+ }
1179
+ const min = describeBound(child.min);
1180
+ const max = describeBound(child.max);
1181
+ if (min && max)
1182
+ parts.push(`Between ${min} and ${max}.`);
1183
+ else if (min)
1184
+ parts.push(`At least ${min}.`);
1185
+ else if (max)
1186
+ parts.push(`At most ${max}.`);
1187
+ const minLength = describeLength(child.minLength);
1188
+ const maxLength = describeLength(child.maxLength);
1189
+ if (minLength && maxLength)
1190
+ parts.push(`${minLength}–${maxLength} characters.`);
1191
+ else if (minLength)
1192
+ parts.push(`At least ${minLength} characters.`);
1193
+ else if (maxLength)
1194
+ parts.push(`At most ${maxLength} characters.`);
1195
+ if (child.pattern)
1196
+ parts.push(`Must match the pattern ${child.pattern}.`);
1197
+ if (child.isCalculatedField)
1198
+ parts.push('Normally calculated from the other columns — leave blank to let the form work it out.');
1199
+ if (child.placeholder)
1200
+ parts.push(`Example: ${child.placeholder}.`);
1201
+ return parts.join(' ');
1202
+ }
1203
+ /** The kind of value a cell should hold, from the HTML input type first, then the data type. */
1204
+ function describeValueKind(child) {
1205
+ switch (child.type) {
1206
+ case InputTypes.Email:
1207
+ return 'Email address';
1208
+ case InputTypes.Tel:
1209
+ return 'Phone number';
1210
+ case InputTypes.Url:
1211
+ return 'URL';
1212
+ case InputTypes.Time:
1213
+ return 'Time (HH:mm)';
1214
+ case InputTypes.Month:
1215
+ return 'Month (YYYY-MM)';
1216
+ case InputTypes.Week:
1217
+ return 'Week (YYYY-Www)';
1218
+ case InputTypes.DateTimeLocal:
1219
+ return 'Date and time (YYYY-MM-DDTHH:mm)';
1220
+ case InputTypes.Color:
1221
+ return 'Colour (#RRGGBB)';
1222
+ default:
1223
+ break;
1224
+ }
1225
+ switch (child.dataType) {
1226
+ case InputDataTypes.Number:
1227
+ return 'Number (digits only — no currency symbol or thousands separator)';
1228
+ case InputDataTypes.Boolean:
1229
+ return 'TRUE or FALSE';
1230
+ case InputDataTypes.Date:
1231
+ return 'Date (YYYY-MM-DD)';
1232
+ case InputDataTypes.Array:
1233
+ return 'JSON array, e.g. ["A","B"]';
1234
+ case InputDataTypes.Object:
1235
+ return 'JSON object, e.g. {"key":"value"}';
1236
+ case InputDataTypes.NumberOrString:
1237
+ return 'Number or text';
1238
+ default:
1239
+ return 'Text';
1240
+ }
1241
+ }
1242
+ /**
1243
+ * What the form shows for each option of a static list — the label, falling
1244
+ * back to the value; empty when options are fetched or absent. The import
1245
+ * accepts either, so the guide lists what the user recognises.
1246
+ */
1247
+ function staticOptionLabels(child) {
1248
+ const options = child.matOptions?.options;
1249
+ if (!Array.isArray(options))
1250
+ return [];
1251
+ return options
1252
+ .map((option) => {
1253
+ if (typeof option === 'string' || typeof option === 'number')
1254
+ return String(option);
1255
+ if (!option || typeof option !== 'object')
1256
+ return '';
1257
+ const record = option;
1258
+ const label = typeof record['label'] === 'string' ? record['label'].trim() : '';
1259
+ if (label)
1260
+ return label;
1261
+ const value = record['value'];
1262
+ return value === undefined || value === null ? '' : String(value);
1263
+ })
1264
+ .filter((value) => value.length > 0);
1265
+ }
1266
+ /**
1267
+ * What to type for a paginated selection table: any value of the columns the
1268
+ * table shows names its row; the import stores the row's identifier. A value
1269
+ * found in several rows is settled in the review.
1270
+ */
1271
+ function describeTableEntry(child) {
1272
+ const columns = (child.paginationSelectionConfig?.columns ?? [])
1273
+ .map((column) => (column?.label || column?.key || '').trim())
1274
+ .filter((name) => name.length > 0);
1275
+ const where = columns.length > 0 ? ` (${columns.join(', ')})` : '';
1276
+ return `A row of the table — enter a value from one of its columns${where}, or the row's stored identifier. A value found in several rows is picked from in the review.`;
1277
+ }
1278
+ /**
1279
+ * A `min` / `max` bound as text. Numbers and dates are printed; any other
1280
+ * string is a script key resolved when the form is captured, so there is
1281
+ * nothing useful to print.
1282
+ */
1283
+ function describeBound(value) {
1284
+ if (value === undefined || value === null || value === '')
1285
+ return null;
1286
+ if (value instanceof Date)
1287
+ return Number.isNaN(value.getTime()) ? null : value.toISOString().slice(0, 10);
1288
+ if (typeof value === 'number')
1289
+ return String(value);
1290
+ const text = String(value).trim();
1291
+ if (text === '')
1292
+ return null;
1293
+ if (Number.isFinite(Number(text)))
1294
+ return text;
1295
+ return /^\d{4}-\d{2}-\d{2}/.test(text) ? text.slice(0, 10) : null;
1296
+ }
1297
+ function describeLength(value) {
1298
+ if (value === undefined || value === null || value === '')
1299
+ return null;
1300
+ return String(value);
1301
+ }
1302
+ /**
1303
+ * Builds the import template for `input`: a data sheet named after the field
1304
+ * that carries the importable headers and no rows, and a `Guide` sheet with one
1305
+ * row per column — key, label, whether it is required, what to enter.
1306
+ *
1307
+ * The data sheet leads so a workbook with the guide still opens on the sheet
1308
+ * to fill in, and it is named after the field so re-importing the template
1309
+ * picks it automatically.
1310
+ */
1311
+ function buildImportTemplate(input) {
1312
+ const columns = describeImportColumns(input);
1313
+ const name = (input.formControlName ?? '').trim() || 'rows';
1314
+ const data = {
1315
+ name,
1316
+ headers: columns.filter((column) => column.importable).map((column) => column.key),
1317
+ rows: [],
1318
+ };
1319
+ const guide = {
1320
+ name: TEMPLATE_GUIDE_SHEET,
1321
+ headers: [...GUIDE_HEADERS],
1322
+ rows: columns.map((column) => ({
1323
+ [GUIDE_HEADERS[0]]: column.key,
1324
+ [GUIDE_HEADERS[1]]: column.label,
1325
+ [GUIDE_HEADERS[2]]: !column.importable ? 'Not importable' : column.required ? 'Yes' : 'No',
1326
+ [GUIDE_HEADERS[3]]: column.hint,
1327
+ })),
1328
+ };
1329
+ return { baseName: `Template-${name}`, sheets: [data, guide] };
1330
+ }
1331
+ /**
1332
+ * Matches a sheet's headers to `columns` and re-keys every row by column key.
1333
+ *
1334
+ * A header is claimed by the first column it matches — by exact key, then by
1335
+ * key or alias case-insensitively — and never by a second one. Headers that
1336
+ * claim nothing are reported as ignored rather than carried along, so an `id`
1337
+ * column or a bulk template's `$index` can never leak into a row. Cells that are
1338
+ * `null` / `undefined` are omitted (the field keeps its default); empty strings
1339
+ * are passed through, exactly as the bulk import receives them. A row whose
1340
+ * every mapped cell is blank is dropped.
1341
+ */
1342
+ function mapSpreadsheetRows(columns, rawRows) {
1343
+ const headers = [...new Set(rawRows.flatMap((row) => (row && typeof row === 'object' ? Object.keys(row) : [])))];
1344
+ const headerByNorm = new Map();
1345
+ for (const header of headers) {
1346
+ const key = normalise(header);
1347
+ if (key && !headerByNorm.has(key))
1348
+ headerByNorm.set(key, header);
1349
+ }
1350
+ const claimed = new Set();
1351
+ const headerFor = new Map();
1352
+ for (const column of columns) {
1353
+ if (!column.importable)
1354
+ continue;
1355
+ let header;
1356
+ if (headers.includes(column.key) && !claimed.has(column.key)) {
1357
+ header = column.key;
1358
+ }
1359
+ else {
1360
+ for (const candidate of [column.key, ...column.aliases]) {
1361
+ const found = headerByNorm.get(normalise(candidate));
1362
+ if (found && !claimed.has(found)) {
1363
+ header = found;
1364
+ break;
1365
+ }
1366
+ }
1367
+ }
1368
+ if (header) {
1369
+ claimed.add(header);
1370
+ headerFor.set(column.key, header);
1371
+ }
1372
+ }
1373
+ const rows = [];
1374
+ for (const raw of rawRows) {
1375
+ if (!raw || typeof raw !== 'object')
1376
+ continue;
1377
+ const row = {};
1378
+ let hasValue = false;
1379
+ for (const [key, header] of headerFor) {
1380
+ const value = raw[header];
1381
+ if (value === null || value === undefined)
1382
+ continue;
1383
+ if (!isBlank(value))
1384
+ hasValue = true;
1385
+ row[key] = value;
1386
+ }
1387
+ if (hasValue)
1388
+ rows.push(row);
1389
+ }
1390
+ return {
1391
+ rows,
1392
+ matched: [...headerFor.keys()],
1393
+ ignored: headers.filter((header) => !claimed.has(header)),
1394
+ missingRequired: columns
1395
+ .filter((column) => column.importable && column.required && !headerFor.has(column.key))
1396
+ .map((column) => column.label),
1397
+ };
1398
+ }
1399
+ /**
1400
+ * Coerces one settled cell to the child's declared data type.
1401
+ *
1402
+ * Spreadsheet cells arrive as text; the form stores what its own inputs would
1403
+ * have produced — a number input a number, a toggle a boolean, a structured
1404
+ * input a parsed object. Anything that does not parse is returned unchanged
1405
+ * rather than blanked, and dates are left as the tower settled them (the
1406
+ * tower already accepts the string forms an export produces).
1407
+ */
1408
+ function coerceCell(value, dataType) {
1409
+ if (value === null || value === undefined)
1410
+ return value;
1411
+ switch (dataType) {
1412
+ case InputDataTypes.Number: {
1413
+ if (typeof value !== 'string')
1414
+ return value;
1415
+ const text = value.trim();
1416
+ if (text === '')
1417
+ return value;
1418
+ const parsed = Number(text);
1419
+ return Number.isFinite(parsed) ? parsed : value;
1420
+ }
1421
+ case InputDataTypes.Boolean: {
1422
+ if (typeof value === 'boolean')
1423
+ return value;
1424
+ if (typeof value === 'number')
1425
+ return value !== 0;
1426
+ if (typeof value !== 'string')
1427
+ return value;
1428
+ const text = value.trim().toLowerCase();
1429
+ if (['true', 'yes', 'y', '1'].includes(text))
1430
+ return true;
1431
+ if (['false', 'no', 'n', '0'].includes(text))
1432
+ return false;
1433
+ return value;
1434
+ }
1435
+ case InputDataTypes.Array:
1436
+ case InputDataTypes.Object: {
1437
+ if (typeof value !== 'string')
1438
+ return value;
1439
+ const text = value.trim();
1440
+ const looksStructured = (text.startsWith('[') && text.endsWith(']')) || (text.startsWith('{') && text.endsWith('}'));
1441
+ if (!looksStructured)
1442
+ return value;
1443
+ try {
1444
+ return JSON.parse(text);
1445
+ }
1446
+ catch {
1447
+ return value;
1448
+ }
1449
+ }
1450
+ default:
1451
+ return value;
1452
+ }
1453
+ }
1454
+ /** Applies {@link coerceCell} to every cell of a settled row, by the matching child's `dataType`. */
1455
+ function coerceImportedRow(input, settled) {
1456
+ const byKey = childrenByFormControlName(input);
1457
+ const out = {};
1458
+ for (const [key, value] of Object.entries(settled)) {
1459
+ out[key] = coerceCell(value, byKey.get(key)?.dataType);
1460
+ }
1461
+ return out;
1462
+ }
1463
+ /**
1464
+ * Converts a settled row (keyed by child `formControlName`, plus `id`) into the
1465
+ * composite-keyed record the multiple-input table stores:
1466
+ * `{ "<inputId>.id": …, "<inputId>.<childId>": … }` — the same rewrite the tower
1467
+ * applies in `initializeFormValues`. A key that matches no child is kept
1468
+ * verbatim so nothing the tower produced is silently lost; a row without a
1469
+ * usable id is given a fresh one.
1470
+ */
1471
+ function toMultipleInputRow(input, settled) {
1472
+ const byKey = childrenByFormControlName(input);
1473
+ const row = {};
1474
+ for (const [key, value] of Object.entries(settled)) {
1475
+ if (key === 'id')
1476
+ continue;
1477
+ const child = byKey.get(key);
1478
+ row[child ? `${input.id}.${child.id}` : key] = value;
1479
+ }
1480
+ const id = settled['id'];
1481
+ row[multipleInputRowIdKey(input.id)] = hasUsableId(id) ? id : v4();
1482
+ return row;
1483
+ }
1484
+ function childrenByFormControlName(input) {
1485
+ return new Map((input.formInputs ?? [])
1486
+ .filter((child) => !!child?.formControlName && !!child.id)
1487
+ .map((child) => [child.formControlName, child]));
1488
+ }
1489
+
1490
+ /** Type offered to the browser when the writer reported none. */
1491
+ const FALLBACK_MIME_TYPE = 'application/octet-stream';
1492
+ /**
1493
+ * Offers the import template of a multiple-input field for download.
1494
+ *
1495
+ * Builds the template the library defines for the field (a data sheet with
1496
+ * the headers the import matches, plus a `Guide` sheet), has the host's writer
1497
+ * serialise it, and hands the file to the browser. Only reachable when the host
1498
+ * bound a writer through `withSpreadsheetImport(parser, { writer })`; the
1499
+ * add-row menu and the import dialog both ask {@link available} before
1500
+ * offering the download. Config-free, so root-provided.
1501
+ */
1502
+ class SpreadsheetTemplateService {
1503
+ #writer = inject(SPREADSHEET_WRITER, { optional: true });
1504
+ #platformId = inject(PLATFORM_ID);
1505
+ #document = inject(DOCUMENT);
1506
+ /** Whether the host bound a writer, so a template can be offered at all. */
1507
+ get available() {
1508
+ return this.#writer !== null;
1509
+ }
1510
+ /**
1511
+ * Builds the template for `input`, has the writer serialise it and offers the
1512
+ * file for download. Rejects with the writer's error verbatim (its message is
1513
+ * meant for the user) and does nothing outside a browser.
1514
+ */
1515
+ async download(input) {
1516
+ if (!this.#writer) {
1517
+ throw new Error('No spreadsheet writer is bound — pass one to withSpreadsheetImport().');
1518
+ }
1519
+ if (!isPlatformBrowser(this.#platformId))
1520
+ return;
1521
+ const file = await this.#writer(buildImportTemplate(input));
1522
+ saveFile(this.#document, file);
1523
+ }
1524
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: SpreadsheetTemplateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1525
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: SpreadsheetTemplateService, providedIn: 'root' }); }
1526
+ }
1527
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: SpreadsheetTemplateService, decorators: [{
1528
+ type: Injectable,
1529
+ args: [{ providedIn: 'root' }]
1530
+ }] });
1531
+ /** Hands `file` to the browser as a download, through a transient anchor. */
1532
+ function saveFile(document, file) {
1533
+ const win = document.defaultView;
1534
+ if (!win)
1535
+ return;
1536
+ const blob = new Blob([file.data], { type: file.mimeType || FALLBACK_MIME_TYPE });
1537
+ const url = win.URL.createObjectURL(blob);
1538
+ const link = document.createElement('a');
1539
+ link.href = url;
1540
+ link.download = file.fileName;
1541
+ link.rel = 'noopener';
1542
+ document.body.appendChild(link);
1543
+ link.click();
1544
+ link.remove();
1545
+ win.URL.revokeObjectURL(url);
1546
+ }
1547
+
1548
+ /** Chip label + icon per row status. Colour is never the only signal (GDP §2c). */
1549
+ const STATUS_META = {
1550
+ pending: { label: 'Queued', icon: 'schedule' },
1551
+ processing: { label: 'Checking', icon: 'hourglass_top' },
1552
+ valid: { label: 'Ready', icon: 'check_circle' },
1553
+ overridable: { label: 'Needs attention', icon: 'flag' },
1554
+ invalid: { label: 'Invalid', icon: 'error' },
1555
+ error: { label: 'Failed', icon: 'report' },
1556
+ duplicate: { label: 'Duplicate', icon: 'content_copy' },
1557
+ choice: { label: 'Pick a match', icon: 'rule' },
1558
+ };
1559
+ /** Error key prefix of a choice cell whose text fits several options; shown as a picker, not as an error. */
1560
+ const AMBIGUOUS_OPTION_KEY = 'ambiguousOption:';
1561
+ /** Short, user-facing wording for the validator keys the tower reports. */
1562
+ const ERROR_LABELS = {
1563
+ required: 'Required',
1564
+ min: 'Too low',
1565
+ max: 'Too high',
1566
+ minlength: 'Too short',
1567
+ maxlength: 'Too long',
1568
+ pattern: 'Wrong format',
1569
+ email: 'Not an email',
1570
+ invalidDate: 'Not a date',
1571
+ invalidOption: 'Not an option',
1572
+ ambiguousOption: 'Several matches',
1573
+ };
1574
+ const EMPTY_PROGRESS = {
1575
+ total: 0,
1576
+ pending: 0,
1577
+ processing: 0,
1578
+ complete: 0,
1579
+ valid: 0,
1580
+ overridable: 0,
1581
+ invalid: 0,
1582
+ error: 0,
1583
+ duplicate: 0,
1584
+ rows: [],
1585
+ };
1586
+ /** Longest cell text rendered before it is cut with an ellipsis. */
1587
+ const MAX_CELL_TEXT = 80;
1588
+ /**
1589
+ * Modal that fills a multiple-input table from a spreadsheet.
1590
+ *
1591
+ * Three steps on one surface: what the sheet should carry — a template to
1592
+ * download when the host bound a writer, otherwise the list of columns — the
1593
+ * file picker (with a sheet chooser when the workbook has several), and a
1594
+ * review table that fills in as
1595
+ * {@link TFormImportController.runMultipleInputImport} settles each row. Only
1596
+ * rows that settle `valid` can be added — the same bar the row editor's Save
1597
+ * button applies — so the dialog never puts a row in the table that the form
1598
+ * would have refused. Rows that need attention stay visible with their errors
1599
+ * against the user's own column headers. A choice cell whose text fits several
1600
+ * options — a label two options share, a table value found in two rows — gets
1601
+ * a picker in place; a pick re-checks that row alone.
1602
+ *
1603
+ * The parser comes from {@link SPREADSHEET_PARSER}; this component is only
1604
+ * reachable when one is bound. Internal to the multiple-input element; not part
1605
+ * of the public API.
1606
+ */
1607
+ class MultipleInputImportDialogComponent {
1608
+ constructor() {
1609
+ this.#platformId = inject(PLATFORM_ID);
1610
+ this.#data = inject(MAT_DIALOG_DATA);
1611
+ this.#dialogRef = inject(MatDialogRef);
1612
+ this.#parser = inject(SPREADSHEET_PARSER);
1613
+ this.#importCtrl = inject(TFormImportController);
1614
+ this.#templates = inject(SpreadsheetTemplateService);
1615
+ /** The columns the sheet should carry — frozen for the dialog's lifetime. */
1616
+ this.columns = describeImportColumns(this.#data.input);
1617
+ /** The field's label, for the subtitle. */
1618
+ this.fieldLabel = this.#data.input.label || this.#data.input.formControlName || 'this list';
1619
+ /** File types offered by the picker. The host's parser decides what it actually reads. */
1620
+ this.accept = '.xlsx,.xlsm,.xls,.csv';
1621
+ /**
1622
+ * Whether a template can be downloaded (the host bound a writer). When it
1623
+ * can, the template stands in for the column list: the workbook carries the
1624
+ * headers and a guide, so there is nothing left to read off the dialog.
1625
+ */
1626
+ this.canDownloadTemplate = this.#templates.available;
1627
+ /** Name of the template's guide sheet, for the wording beside the download. */
1628
+ this.guideSheet = TEMPLATE_GUIDE_SHEET;
1629
+ this.stage = signal('idle', ...(ngDevMode ? [{ debugName: "stage" }] : /* istanbul ignore next */ []));
1630
+ this.fileName = signal(undefined, ...(ngDevMode ? [{ debugName: "fileName" }] : /* istanbul ignore next */ []));
1631
+ this.error = signal(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
1632
+ this.sheets = signal([], ...(ngDevMode ? [{ debugName: "sheets" }] : /* istanbul ignore next */ []));
1633
+ this.activeSheet = signal(undefined, ...(ngDevMode ? [{ debugName: "activeSheet" }] : /* istanbul ignore next */ []));
1634
+ this.mapping = signal(undefined, ...(ngDevMode ? [{ debugName: "mapping" }] : /* istanbul ignore next */ []));
1635
+ this.downloadingTemplate = signal(false, ...(ngDevMode ? [{ debugName: "downloadingTemplate" }] : /* istanbul ignore next */ []));
1636
+ this.templateError = signal(undefined, ...(ngDevMode ? [{ debugName: "templateError" }] : /* istanbul ignore next */ []));
1637
+ /** Rows being re-checked after an option pick; their pickers and the add button wait. */
1638
+ this.rechecking = signal(new Set(), ...(ngDevMode ? [{ debugName: "rechecking" }] : /* istanbul ignore next */ []));
1639
+ /** Live per-row states from the controller; only read while a run belongs to this dialog. */
1640
+ this.progress = toSignal(this.#importCtrl.progress$, { initialValue: EMPTY_PROGRESS });
1641
+ /** Reading the file or validating its rows — the picker and the sheet chooser wait. */
1642
+ this.busy = computed(() => this.stage() === 'reading' || this.stage() === 'validating', ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
1643
+ this.progressPct = computed(() => {
1644
+ const p = this.progress();
1645
+ return p.total ? Math.round(((p.complete + p.error) / p.total) * 100) : 0;
1646
+ }, ...(ngDevMode ? [{ debugName: "progressPct" }] : /* istanbul ignore next */ []));
1647
+ /** Row states of the current run, or none until the sheet has been mapped. */
1648
+ this.#states = computed(() => this.stage() === 'validating' || this.stage() === 'reviewed' ? this.progress().rows : [], ...(ngDevMode ? [{ debugName: "#states" }] : /* istanbul ignore next */ []));
1649
+ /** Columns shown in the review: those a header fed, plus any that carry an error somewhere. */
1650
+ this.reviewColumns = computed(() => {
1651
+ const matched = new Set(this.mapping()?.matched ?? []);
1652
+ const withErrors = new Set(this.#states().flatMap((s) => Object.keys(s.colErrors ?? {})));
1653
+ return this.columns.filter((c) => matched.has(c.key) || withErrors.has(c.key));
1654
+ }, ...(ngDevMode ? [{ debugName: "reviewColumns" }] : /* istanbul ignore next */ []));
1655
+ this.reviewRows = computed(() => {
1656
+ const columns = this.reviewColumns();
1657
+ const known = new Set(columns.map((c) => c.key));
1658
+ return this.#states().map((state) => {
1659
+ const status = awaitsPick(state) ? 'choice' : state.status;
1660
+ const meta = STATUS_META[status];
1661
+ const strays = Object.entries(state.colErrors ?? {})
1662
+ .filter(([key]) => !known.has(key))
1663
+ .map(([key, keys]) => `${key}: ${formatErrorKeys(keys)}`);
1664
+ const overridable = Object.values(state.overridableErrors ?? {}).flat();
1665
+ const repeats = state.duplicateOf === undefined ? [] : [`Same record as row ${state.duplicateOf + 1} — left out`];
1666
+ const message = state.errorMessage ?? [...repeats, ...strays, ...overridable].join(' · ');
1667
+ return {
1668
+ index: state.rowIndex,
1669
+ status,
1670
+ label: meta.label,
1671
+ icon: meta.icon,
1672
+ cells: columns.map((column) => cellFor(state, column)),
1673
+ message: message || undefined,
1674
+ };
1675
+ });
1676
+ }, ...(ngDevMode ? [{ debugName: "reviewRows" }] : /* istanbul ignore next */ []));
1677
+ /** The rows that can be added: settled with no error of any kind, and not a repeat of an earlier row. */
1678
+ this.#ready = computed(() => this.#states()
1679
+ .filter((s) => s.status === 'valid' && s.duplicateOf === undefined && !!s.settledValue)
1680
+ .map((s) => s.settledValue), ...(ngDevMode ? [{ debugName: "#ready" }] : /* istanbul ignore next */ []));
1681
+ this.canAdd = computed(() => this.stage() === 'reviewed' && this.rechecking().size === 0 && this.#ready().length > 0, ...(ngDevMode ? [{ debugName: "canAdd" }] : /* istanbul ignore next */ []));
1682
+ this.addLabel = computed(() => {
1683
+ const n = this.#ready().length;
1684
+ return n === 1 ? 'Add 1 row' : `Add ${n} rows`;
1685
+ }, ...(ngDevMode ? [{ debugName: "addLabel" }] : /* istanbul ignore next */ []));
1686
+ this.summary = computed(() => {
1687
+ const p = this.progress();
1688
+ const stage = this.stage();
1689
+ if (stage === 'validating') {
1690
+ return `Checking row ${Math.min(p.complete + p.error + 1, p.total)} of ${p.total}…`;
1691
+ }
1692
+ if (stage !== 'reviewed')
1693
+ return '';
1694
+ const ready = this.#ready().length;
1695
+ const picking = this.#states().filter(awaitsPick).length;
1696
+ const repeats = this.#states().filter((s) => s.status === 'duplicate').length;
1697
+ const held = p.total - ready - picking - repeats;
1698
+ const existing = this.#data.existingRowCount;
1699
+ const parts = [`${ready} of ${p.total} ${p.total === 1 ? 'row' : 'rows'} can be added`];
1700
+ if (picking > 0)
1701
+ parts.push(`${picking} ${picking === 1 ? 'needs' : 'need'} a match picked`);
1702
+ if (repeats > 0)
1703
+ parts.push(`${repeats} ${repeats === 1 ? 'repeats' : 'repeat'} an earlier row and will be left out`);
1704
+ if (held > 0)
1705
+ parts.push(`${held} ${held === 1 ? 'needs' : 'need'} attention and will be left out`);
1706
+ if (ready > 0 && existing > 0)
1707
+ parts.push(`the table already holds ${existing}`);
1708
+ return `${parts.join(' · ')}.`;
1709
+ }, ...(ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []));
1710
+ }
1711
+ #platformId;
1712
+ #data;
1713
+ #dialogRef;
1714
+ #parser;
1715
+ #importCtrl;
1716
+ #templates;
1717
+ /** Row states of the current run, or none until the sheet has been mapped. */
1718
+ #states;
1719
+ /** The rows that can be added: settled with no error of any kind, and not a repeat of an earlier row. */
1720
+ #ready;
1721
+ /** Tooltip for an expected column: what to type, and whether it is required. */
1722
+ columnTooltip(column) {
1723
+ if (!column.importable)
1724
+ return `${column.label} cannot be imported from a cell — add it in the row editor.`;
1725
+ return `${column.label} — ${column.required ? 'required' : 'optional'}. ${column.hint}`;
1726
+ }
1727
+ /** Downloads the field's import template; the writer's failure is shown beside the button. */
1728
+ async downloadTemplate() {
1729
+ if (!this.canDownloadTemplate || this.downloadingTemplate())
1730
+ return;
1731
+ this.templateError.set(undefined);
1732
+ this.downloadingTemplate.set(true);
1733
+ try {
1734
+ await this.#templates.download(this.#data.input);
1735
+ }
1736
+ catch (e) {
1737
+ this.templateError.set(messageOf(e, 'The template could not be created.'));
1738
+ }
1739
+ finally {
1740
+ this.downloadingTemplate.set(false);
1741
+ }
1742
+ }
1743
+ /** Reads the picked file. The input is cleared so choosing the same file again re-fires. */
1744
+ async onFileSelected(event) {
1745
+ const target = event.target instanceof HTMLInputElement ? event.target : null;
1746
+ const file = target?.files?.[0];
1747
+ if (target)
1748
+ target.value = '';
1749
+ if (!file || this.busy())
1750
+ return;
1751
+ await this.#load(file);
1752
+ }
1753
+ /** Switches to another sheet of the loaded workbook and validates it. */
1754
+ async chooseSheet(sheet) {
1755
+ if (this.busy() || sheet.name === this.activeSheet())
1756
+ return;
1757
+ await this.#useSheet(sheet);
1758
+ }
1759
+ /**
1760
+ * Applies the user's pick for a choice cell whose text fits several options
1761
+ * and re-checks that row alone. The pick goes into the row's raw data under
1762
+ * the column's key — the whole cell of a single select, the one matching
1763
+ * entry of a multi-select — so the re-run resolves it by stored value while
1764
+ * every other row stands.
1765
+ */
1766
+ async pickOption(rowIndex, cell, choice, event) {
1767
+ const select = event.target instanceof HTMLSelectElement ? event.target : null;
1768
+ const candidate = select && select.value !== '' ? choice.candidates[Number(select.value)] : undefined;
1769
+ const state = this.#states().find((s) => s.rowIndex === rowIndex);
1770
+ if (!candidate || !state || this.rechecking().has(rowIndex))
1771
+ return;
1772
+ const child = (this.#data.input.formInputs ?? []).find((c) => c?.formControlName === cell.key);
1773
+ const multi = !!child && isMultiSelectInput(child);
1774
+ const row = applyOptionChoice(state.originalData, cell.key, choice.text, candidate.value, multi);
1775
+ this.error.set(undefined);
1776
+ this.rechecking.update((set) => new Set([...set, rowIndex]));
1777
+ try {
1778
+ await this.#importCtrl.rerunMultipleInputRow(rowIndex, row);
1779
+ }
1780
+ catch (e) {
1781
+ this.error.set(messageOf(e, 'The row could not be re-checked.'));
1782
+ }
1783
+ finally {
1784
+ this.rechecking.update((set) => {
1785
+ const next = new Set(set);
1786
+ next.delete(rowIndex);
1787
+ return next;
1788
+ });
1789
+ }
1790
+ }
1791
+ cancel() {
1792
+ if (this.busy())
1793
+ return;
1794
+ this.#dialogRef.close(undefined);
1795
+ }
1796
+ add() {
1797
+ if (!this.canAdd())
1798
+ return;
1799
+ this.#dialogRef.close(this.#ready());
1800
+ }
1801
+ async #load(file) {
1802
+ if (!isPlatformBrowser(this.#platformId))
1803
+ return;
1804
+ this.error.set(undefined);
1805
+ this.mapping.set(undefined);
1806
+ this.sheets.set([]);
1807
+ this.activeSheet.set(undefined);
1808
+ this.fileName.set(file.name);
1809
+ this.stage.set('reading');
1810
+ let sheets;
1811
+ try {
1812
+ const data = await readAsArrayBuffer(file);
1813
+ sheets = await this.#parser({ fileName: file.name, mimeType: file.type || '', data });
1814
+ }
1815
+ catch (e) {
1816
+ this.#fail(messageOf(e, 'Could not read the spreadsheet.'));
1817
+ return;
1818
+ }
1819
+ const usable = (sheets ?? []).filter((sheet) => !!sheet && Array.isArray(sheet.rows));
1820
+ if (usable.length === 0) {
1821
+ this.#fail('The spreadsheet has no sheets.');
1822
+ return;
1823
+ }
1824
+ this.sheets.set(usable);
1825
+ await this.#useSheet(this.#preferredSheet(usable));
1826
+ }
1827
+ /**
1828
+ * The sheet named after the field's `formControlName` when there is one —
1829
+ * the template's data sheet, or a bulk-import template's detail sheet —
1830
+ * otherwise the first.
1831
+ */
1832
+ #preferredSheet(sheets) {
1833
+ const wanted = (this.#data.input.formControlName ?? '').trim().toLowerCase();
1834
+ const first = sheets[0];
1835
+ if (!wanted)
1836
+ return first;
1837
+ return sheets.find((sheet) => sheet.name.trim().toLowerCase() === wanted) ?? first;
1838
+ }
1839
+ async #useSheet(sheet) {
1840
+ this.error.set(undefined);
1841
+ this.activeSheet.set(sheet.name);
1842
+ const mapping = mapSpreadsheetRows(this.columns, sheet.rows);
1843
+ this.mapping.set(mapping);
1844
+ if (mapping.rows.length === 0) {
1845
+ this.#fail(sheet.rows.length === 0
1846
+ ? `"${sheet.name}" has no rows below its headers.`
1847
+ : mapping.matched.length === 0
1848
+ ? `No header in "${sheet.name}" matches a column of ${this.fieldLabel}.`
1849
+ : `"${sheet.name}" has no rows with a value in a recognised column.`);
1850
+ return;
1851
+ }
1852
+ this.stage.set('validating');
1853
+ this.#importCtrl.reset();
1854
+ try {
1855
+ await this.#importCtrl.runMultipleInputImport(this.#data.input, mapping.rows);
1856
+ }
1857
+ catch (e) {
1858
+ this.#fail(messageOf(e, 'The rows could not be checked.'));
1859
+ return;
1860
+ }
1861
+ this.stage.set('reviewed');
1862
+ }
1863
+ #fail(message) {
1864
+ this.error.set(message);
1865
+ this.stage.set('idle');
1866
+ }
1867
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputImportDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1868
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: MultipleInputImportDialogComponent, isStandalone: true, selector: "lib-multiple-input-import-dialog", host: { properties: { "attr.data-stage": "stage()" }, classAttribute: "lib-multiple-input-import-dialog" }, ngImport: i0, template: "<div mat-dialog-title class=\"mii__header\">\n <span class=\"mii__title\">Import rows from a spreadsheet</span>\n <span class=\"mii__subtitle\">\n {{ fieldLabel }} \u00B7 every row is checked the way the form checks it, and only rows that pass are added.\n </span>\n</div>\n\n<mat-dialog-content class=\"mii__content\">\n <!-- 1 \u00B7 What the sheet should carry: the template when the host can write one, else the columns -->\n @if (canDownloadTemplate) {\n <section class=\"mii-section\" aria-labelledby=\"mii-template-label\">\n <span class=\"mii-section__label\" id=\"mii-template-label\">Template</span>\n <div class=\"mii-template\">\n <div class=\"mii-template__text\">\n <span class=\"mii-template__title\">Start from the template</span>\n <span class=\"mii-template__hint\">\n Its first sheet carries the headers to fill in; the {{ guideSheet }} sheet says what goes in each column.\n Other columns are ignored.\n </span>\n </div>\n <button\n type=\"button\"\n mat-stroked-button\n class=\"mii-template__button\"\n [disabled]=\"downloadingTemplate()\"\n (click)=\"downloadTemplate()\"\n >\n <mat-icon aria-hidden=\"true\">download</mat-icon>\n Download template\n </button>\n </div>\n @if (templateError(); as message) {\n <p class=\"mii-alert mii-alert--error mii-template__error\" role=\"alert\">\n <mat-icon aria-hidden=\"true\">error</mat-icon>\n <span>{{ message }}</span>\n </p>\n }\n </section>\n } @else {\n <section class=\"mii-section\" aria-labelledby=\"mii-columns-label\">\n <span class=\"mii-section__label\" id=\"mii-columns-label\">Columns</span>\n <ul class=\"mii-columns\" aria-describedby=\"mii-columns-hint\">\n @for (column of columns; track column.key) {\n <li\n class=\"mii-column\"\n [class.mii-column--required]=\"column.required && column.importable\"\n [class.mii-column--skipped]=\"!column.importable\"\n [matTooltip]=\"columnTooltip(column)\"\n >\n <span class=\"mii-column__key\">{{ column.key }}</span>\n @if (column.label !== column.key) {\n <span class=\"mii-column__label\">{{ column.label }}</span>\n }\n @if (column.required && column.importable) {\n <span class=\"mii-column__flag\">required</span>\n } @else if (!column.importable) {\n <span class=\"mii-column__flag\">not importable</span>\n }\n </li>\n }\n </ul>\n <p class=\"mii-section__hint\" id=\"mii-columns-hint\">\n Row 1 holds the headers. A header may be the column name above or the field's label; other columns are ignored.\n </p>\n </section>\n }\n\n <!-- 2 \u00B7 The file -->\n <section class=\"mii-section\" aria-labelledby=\"mii-file-label\">\n <span class=\"mii-section__label\" id=\"mii-file-label\">Spreadsheet</span>\n\n <label class=\"mii-pick\" [class.mii-pick--busy]=\"busy()\">\n <mat-icon class=\"mii-pick__icon\" aria-hidden=\"true\">upload_file</mat-icon>\n <span class=\"mii-pick__text\">\n @if (fileName(); as name) {\n <span class=\"mii-pick__name\">{{ name }}</span>\n <span class=\"mii-pick__hint\">Choose another file to start over</span>\n } @else {\n <span class=\"mii-pick__name\">Choose a file</span>\n <span class=\"mii-pick__hint\">A workbook or CSV, with the headers in row 1</span>\n }\n </span>\n <input\n type=\"file\"\n class=\"mii-pick__input\"\n [accept]=\"accept\"\n [disabled]=\"busy()\"\n (change)=\"onFileSelected($event)\"\n aria-label=\"Choose a spreadsheet file\"\n />\n </label>\n\n @if (sheets().length > 1) {\n <div class=\"mii-sheets\" role=\"group\" aria-label=\"Sheet to import\">\n <span class=\"mii-sheets__label\">Sheet</span>\n @for (sheet of sheets(); track sheet.name) {\n <button\n type=\"button\"\n class=\"mii-sheet\"\n [class.mii-sheet--active]=\"sheet.name === activeSheet()\"\n [attr.aria-pressed]=\"sheet.name === activeSheet()\"\n [disabled]=\"busy()\"\n (click)=\"chooseSheet(sheet)\"\n >\n {{ sheet.name }}\n </button>\n }\n </div>\n }\n\n @if (error(); as message) {\n <p class=\"mii-alert mii-alert--error\" role=\"alert\">\n <mat-icon aria-hidden=\"true\">error</mat-icon>\n <span>{{ message }}</span>\n </p>\n }\n\n @if (mapping(); as m) {\n @if (m.missingRequired.length > 0) {\n <p class=\"mii-alert mii-alert--warn\" role=\"status\">\n <mat-icon aria-hidden=\"true\">warning</mat-icon>\n <span>\n No column for the required {{ m.missingRequired.length === 1 ? 'field' : 'fields' }}\n {{ m.missingRequired.join(', ') }}. Rows will not pass until the sheet carries\n {{ m.missingRequired.length === 1 ? 'it' : 'them' }}.\n </span>\n </p>\n }\n @if (m.ignored.length > 0) {\n <p class=\"mii-note\" role=\"status\">\n Ignored {{ m.ignored.length === 1 ? 'column' : 'columns' }}: {{ m.ignored.join(', ') }}\n </p>\n }\n }\n </section>\n\n <!-- 3 \u00B7 Review -->\n @if (stage() === 'validating' || stage() === 'reviewed') {\n <section class=\"mii-section\" aria-labelledby=\"mii-review-label\">\n <span class=\"mii-section__label\" id=\"mii-review-label\">Review</span>\n\n @if (stage() === 'validating') {\n <mat-progress-bar\n class=\"mii-progress\"\n mode=\"determinate\"\n [value]=\"progressPct()\"\n aria-label=\"Validation progress\"\n />\n }\n <p class=\"mii-summary\" role=\"status\" aria-live=\"polite\">{{ summary() }}</p>\n\n <div class=\"mii-scroll\">\n <table class=\"mii-table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"mii-th mii-th--index\">\n <span aria-hidden=\"true\">#</span>\n <span class=\"mii-sr-only\">Row</span>\n </th>\n <th scope=\"col\" class=\"mii-th\">Status</th>\n @for (column of reviewColumns(); track column.key) {\n <th scope=\"col\" class=\"mii-th\">{{ column.label }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of reviewRows(); track row.index) {\n <tr\n class=\"mii-row\"\n [class.mii-row--held]=\"row.status === 'invalid' || row.status === 'error' || row.status === 'overridable' || row.status === 'duplicate'\"\n >\n <td class=\"mii-td mii-td--index\">{{ row.index + 1 }}</td>\n <td class=\"mii-td\">\n <span class=\"mii-status\" [attr.data-status]=\"row.status\">\n <mat-icon aria-hidden=\"true\">{{ row.icon }}</mat-icon>\n <span>{{ row.label }}</span>\n </span>\n </td>\n @for (cell of row.cells; track cell.key) {\n <td class=\"mii-td\" [class.mii-td--error]=\"!!cell.error\" [class.mii-td--choice]=\"!!cell.choices\">\n @if (cell.choices; as choices) {\n <!--\n The text fits several options. The pick is the whole\n cell of a single select, or the one matching entry of a\n multi-select; the row is re-checked as soon as it lands.\n -->\n <div class=\"mii-choice\" role=\"group\" [attr.aria-label]=\"'Pick a match for ' + cell.label\">\n @for (choice of choices; track choice.text) {\n <label class=\"mii-choice__item\">\n <span class=\"mii-choice__text\">\u201C{{ choice.text }}\u201D</span>\n <span class=\"mii-choice__field\">\n <select\n class=\"mii-choice__select\"\n [disabled]=\"rechecking().has(row.index)\"\n (change)=\"pickOption(row.index, cell, choice, $event)\"\n >\n <option value=\"\" selected disabled>{{ choice.candidates.length }} matches \u2014 pick one</option>\n @for (candidate of choice.candidates; track $index) {\n <option [value]=\"$index\">{{ candidate.label }}</option>\n }\n </select>\n <mat-icon class=\"mii-choice__chevron\" aria-hidden=\"true\">expand_more</mat-icon>\n </span>\n </label>\n }\n </div>\n }\n @if (cell.error) {\n <span class=\"mii-cell-error\" [matTooltip]=\"cell.text ? 'Value: ' + cell.text : ''\">\n <mat-icon aria-hidden=\"true\">error</mat-icon>\n <span>{{ cell.error }}</span>\n </span>\n } @else if (!cell.choices) {\n <span class=\"mii-cell\" [attr.title]=\"cell.text\">{{ cell.text }}</span>\n }\n </td>\n }\n </tr>\n @if (row.message) {\n <tr class=\"mii-row-detail\">\n <td class=\"mii-td mii-td--detail\" [attr.colspan]=\"reviewColumns().length + 2\">\n {{ row.message }}\n </td>\n </tr>\n }\n }\n </tbody>\n </table>\n </div>\n </section>\n }\n</mat-dialog-content>\n\n<mat-dialog-actions class=\"mii__actions\">\n <button type=\"button\" mat-button class=\"mii__cancel\" [disabled]=\"busy()\" (click)=\"cancel()\">Cancel</button>\n <button\n type=\"button\"\n mat-flat-button\n color=\"primary\"\n class=\"mii__add\"\n [disabled]=\"!canAdd()\"\n (click)=\"add()\"\n >\n {{ addLabel() }}\n </button>\n</mat-dialog-actions>\n", styles: [":host{--mii-outline-12: color-mix(in srgb, var(--lib-forms-outline) 12%, transparent);--mii-outline-20: color-mix(in srgb, var(--lib-forms-outline) 20%, transparent);--mii-primary-06: color-mix(in srgb, var(--lib-forms-primary) 6%, transparent);--mii-primary-10: color-mix(in srgb, var(--lib-forms-primary) 10%, transparent);--mii-primary-14: color-mix(in srgb, var(--lib-forms-primary) 14%, transparent);--mii-primary-25: color-mix(in srgb, var(--lib-forms-primary) 25%, transparent);display:block;color:var(--lib-forms-on-surface)}.mii__header{display:flex;flex-direction:column;gap:.5rem;margin:0;padding:2.5rem 2.5rem 0}.mii__header:before{display:none}.mii__title{font-size:1.25rem;font-weight:500;letter-spacing:-.01em;line-height:1.3;color:var(--lib-forms-on-surface)}.mii__subtitle{font-size:.875rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii__content{display:flex;flex-direction:column;gap:2rem;padding:2rem 2.5rem 1rem;max-height:70vh}.mii-section{display:flex;flex-direction:column;gap:.75rem}.mii-section__label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mii-section__hint{margin:0;font-size:.8125rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-columns{display:flex;flex-wrap:wrap;gap:.5rem;margin:0;padding:0;list-style:none}.mii-column{display:inline-flex;align-items:baseline;gap:.5rem;padding:.375rem .75rem;border:1px solid var(--mii-outline-20);border-radius:var(--lib-forms-radius-pill);background:var(--lib-forms-surface-container-low);font-size:.8125rem;line-height:1.2;color:var(--lib-forms-on-surface);transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),background-color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-column:hover{border-color:color-mix(in srgb,var(--lib-forms-primary) 40%,transparent);background:var(--mii-primary-06)}.mii-column--required{border-color:color-mix(in srgb,var(--lib-forms-primary) 30%,transparent)}.mii-column--skipped{color:var(--lib-forms-on-surface-variant);border-style:dashed}.mii-column__key{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.75rem}.mii-column__label{font-size:.75rem;color:var(--lib-forms-on-surface-variant)}.mii-column__flag{font-size:.625rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--lib-forms-primary)}.mii-column--skipped .mii-column__flag{color:var(--lib-forms-on-surface-variant)}.mii-template{display:flex;align-items:center;justify-content:space-between;gap:1.5rem;padding:1.25rem 1.5rem;border:1px solid var(--mii-outline-12);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface-container-low)}.mii-template__text{display:flex;flex-direction:column;gap:.25rem;min-width:0}.mii-template__title{font-size:.9375rem;font-weight:500;color:var(--lib-forms-on-surface)}.mii-template__hint{font-size:.8125rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-template__button{flex-shrink:0}@media(max-width:40rem){.mii-template{flex-direction:column;align-items:stretch}}.mii-pick{display:flex;align-items:center;gap:1rem;padding:1.25rem 1.5rem;border:1px dashed var(--mii-outline-20);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface);color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:border-color var(--lib-forms-duration) var(--lib-forms-easing),background-color var(--lib-forms-duration) var(--lib-forms-easing),color var(--lib-forms-duration) var(--lib-forms-easing)}.mii-pick:hover,.mii-pick:focus-within{border-color:var(--lib-forms-primary);background:var(--mii-primary-06);color:var(--lib-forms-primary)}.mii-pick:focus-within{border-style:solid;box-shadow:0 0 0 2px var(--mii-primary-25)}.mii-pick--busy{cursor:progress;opacity:.7}.mii-pick__icon{flex-shrink:0;font-size:1.25rem;width:1.25rem;height:1.25rem}.mii-pick__text{display:flex;flex-direction:column;gap:.25rem;min-width:0}.mii-pick__name{font-size:.9375rem;font-weight:500;color:var(--lib-forms-on-surface);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mii-pick__hint{font-size:.8125rem}.mii-pick__input{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.mii-sheets{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem}.mii-sheets__label{margin-right:.25rem;font-size:.75rem;color:var(--lib-forms-on-surface-variant)}.mii-sheet{padding:.375rem .875rem;border:1px solid var(--mii-outline-20);border-radius:var(--lib-forms-radius-pill);background:var(--lib-forms-surface);font:inherit;font-size:.8125rem;font-weight:500;color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),background-color var(--lib-forms-duration-hover) var(--lib-forms-easing),color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-sheet:hover,.mii-sheet:focus-visible{border-color:color-mix(in srgb,var(--lib-forms-primary) 40%,transparent);background:var(--mii-primary-06);color:var(--lib-forms-primary)}.mii-sheet:focus-visible{outline:3px solid var(--mii-primary-25);outline-offset:1px}.mii-sheet--active{border-color:var(--lib-forms-primary);background:var(--mii-primary-10);color:var(--lib-forms-primary)}.mii-sheet:disabled{cursor:default;opacity:.6}.mii-alert{display:flex;align-items:flex-start;gap:.5rem;margin:0;padding:.75rem 1rem;border-radius:var(--lib-forms-radius-sm);font-size:.8125rem;line-height:1.5}.mii-alert mat-icon{flex-shrink:0;font-size:1rem;width:1rem;height:1rem;margin-top:.125rem}.mii-alert--error{color:var(--sem-error);background:var(--sem-error-surface)}.mii-alert--warn{color:var(--sem-amber);background:var(--sem-amber-surface)}.mii-note{margin:0;font-size:.75rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-progress{--mdc-linear-progress-track-height: .25rem;--mdc-linear-progress-active-indicator-height: .25rem;border-radius:var(--lib-forms-radius-pill);overflow:hidden}.mii-summary{margin:0;font-size:.875rem;line-height:1.5;color:var(--lib-forms-on-surface)}.mii-scroll{max-height:40vh;overflow:auto;border:1px solid var(--mii-outline-12);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface)}.mii-table{width:100%;border-collapse:separate;border-spacing:0;font-size:.8125rem}.mii-th{position:sticky;top:0;z-index:1;padding:.75rem 1rem;text-align:left;font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;white-space:nowrap;color:var(--lib-forms-on-surface-variant);background:var(--lib-forms-surface-container-low)}.mii-th--index{width:2.5rem;text-align:right}.mii-td{padding:.625rem 1rem;vertical-align:middle;white-space:nowrap;color:var(--lib-forms-on-surface);transition:background-color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-td--index{text-align:right;font-variant-numeric:tabular-nums;color:var(--lib-forms-on-surface-variant)}.mii-row:hover .mii-td{background:var(--mii-primary-06)}.mii-row--held .mii-td{background:color-mix(in srgb,var(--lib-forms-on-surface-variant) 4%,transparent)}.mii-cell{display:inline-block;max-width:18rem;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}.mii-cell-error{display:inline-flex;align-items:center;gap:.375rem;color:var(--sem-red);font-weight:500}.mii-cell-error mat-icon{font-size:1rem;width:1rem;height:1rem}.mii-td--detail{padding-top:0;padding-left:3.5rem;white-space:normal;font-size:.75rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-td--choice{white-space:normal;vertical-align:top}.mii-choice{display:flex;flex-direction:column;gap:.75rem;min-width:14rem}.mii-choice__item{display:flex;flex-direction:column;gap:.375rem}.mii-choice__text{font-size:.75rem;color:var(--lib-forms-on-surface-variant)}.mii-choice__field{position:relative;display:block}.mii-choice__select{width:100%;min-height:2.25rem;padding:.375rem 2.25rem .375rem .75rem;border:1px solid var(--mii-outline-20);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface);font:inherit;font-size:.8125rem;color:var(--lib-forms-on-surface);appearance:none;cursor:pointer;transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),box-shadow var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-choice__select:hover{border-color:color-mix(in srgb,var(--lib-forms-primary) 40%,transparent)}.mii-choice__select:focus-visible{outline:none;border-color:var(--lib-forms-primary);box-shadow:0 0 0 3px var(--mii-primary-14)}.mii-choice__select:disabled{cursor:progress;opacity:.6}.mii-choice__chevron{position:absolute;top:50%;right:.625rem;width:1.125rem;height:1.125rem;font-size:1.125rem;transform:translateY(-50%);pointer-events:none;color:var(--lib-forms-on-surface-variant)}.mii-td--choice .mii-cell-error{margin-top:.5rem}.mii-status{display:inline-flex;align-items:center;gap:.375rem;padding:.3125rem .75rem;border:1px solid transparent;border-radius:var(--lib-forms-radius-pill);font-size:.6875rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;white-space:nowrap;line-height:1;color:var(--sem-slate);background:var(--sem-slate-surface);border-color:color-mix(in srgb,var(--sem-slate) 30%,transparent);transition:color var(--lib-forms-duration) var(--lib-forms-easing),background-color var(--lib-forms-duration) var(--lib-forms-easing),border-color var(--lib-forms-duration) var(--lib-forms-easing)}.mii-status mat-icon{font-size:1rem;width:1rem;height:1rem}.mii-status[data-status=valid]{color:var(--sem-emerald);background:var(--sem-emerald-surface);border-color:color-mix(in srgb,var(--sem-emerald) 30%,transparent)}.mii-status[data-status=overridable],.mii-status[data-status=choice]{color:var(--sem-amber);background:var(--sem-amber-surface);border-color:color-mix(in srgb,var(--sem-amber) 30%,transparent)}.mii-status[data-status=invalid]{color:var(--sem-red);background:var(--sem-red-surface);border-color:color-mix(in srgb,var(--sem-red) 30%,transparent)}.mii-status[data-status=error]{color:var(--sem-rust);background:var(--sem-rust-surface);border-color:color-mix(in srgb,var(--sem-rust) 30%,transparent)}.mii-status[data-status=duplicate]{color:var(--sem-slate);background:var(--sem-slate-surface);border-color:color-mix(in srgb,var(--sem-slate) 30%,transparent)}.mii__actions{display:flex;justify-content:flex-end;gap:1rem;padding:1rem 2.5rem 2.5rem}.mii-sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}@media(prefers-reduced-motion:reduce){.mii-column,.mii-pick,.mii-sheet,.mii-td,.mii-choice__select,.mii-status{transition:none}}\n"], dependencies: [{ kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i1$1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1$1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1$1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i4$1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i5$1.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1869
+ }
1870
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputImportDialogComponent, decorators: [{
1871
+ type: Component,
1872
+ args: [{ selector: 'lib-multiple-input-import-dialog', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, host: {
1873
+ 'class': 'lib-multiple-input-import-dialog',
1874
+ '[attr.data-stage]': 'stage()',
1875
+ }, imports: [MatDialogModule, MatButtonModule, MatIconModule, MatProgressBarModule, MatTooltipModule], template: "<div mat-dialog-title class=\"mii__header\">\n <span class=\"mii__title\">Import rows from a spreadsheet</span>\n <span class=\"mii__subtitle\">\n {{ fieldLabel }} \u00B7 every row is checked the way the form checks it, and only rows that pass are added.\n </span>\n</div>\n\n<mat-dialog-content class=\"mii__content\">\n <!-- 1 \u00B7 What the sheet should carry: the template when the host can write one, else the columns -->\n @if (canDownloadTemplate) {\n <section class=\"mii-section\" aria-labelledby=\"mii-template-label\">\n <span class=\"mii-section__label\" id=\"mii-template-label\">Template</span>\n <div class=\"mii-template\">\n <div class=\"mii-template__text\">\n <span class=\"mii-template__title\">Start from the template</span>\n <span class=\"mii-template__hint\">\n Its first sheet carries the headers to fill in; the {{ guideSheet }} sheet says what goes in each column.\n Other columns are ignored.\n </span>\n </div>\n <button\n type=\"button\"\n mat-stroked-button\n class=\"mii-template__button\"\n [disabled]=\"downloadingTemplate()\"\n (click)=\"downloadTemplate()\"\n >\n <mat-icon aria-hidden=\"true\">download</mat-icon>\n Download template\n </button>\n </div>\n @if (templateError(); as message) {\n <p class=\"mii-alert mii-alert--error mii-template__error\" role=\"alert\">\n <mat-icon aria-hidden=\"true\">error</mat-icon>\n <span>{{ message }}</span>\n </p>\n }\n </section>\n } @else {\n <section class=\"mii-section\" aria-labelledby=\"mii-columns-label\">\n <span class=\"mii-section__label\" id=\"mii-columns-label\">Columns</span>\n <ul class=\"mii-columns\" aria-describedby=\"mii-columns-hint\">\n @for (column of columns; track column.key) {\n <li\n class=\"mii-column\"\n [class.mii-column--required]=\"column.required && column.importable\"\n [class.mii-column--skipped]=\"!column.importable\"\n [matTooltip]=\"columnTooltip(column)\"\n >\n <span class=\"mii-column__key\">{{ column.key }}</span>\n @if (column.label !== column.key) {\n <span class=\"mii-column__label\">{{ column.label }}</span>\n }\n @if (column.required && column.importable) {\n <span class=\"mii-column__flag\">required</span>\n } @else if (!column.importable) {\n <span class=\"mii-column__flag\">not importable</span>\n }\n </li>\n }\n </ul>\n <p class=\"mii-section__hint\" id=\"mii-columns-hint\">\n Row 1 holds the headers. A header may be the column name above or the field's label; other columns are ignored.\n </p>\n </section>\n }\n\n <!-- 2 \u00B7 The file -->\n <section class=\"mii-section\" aria-labelledby=\"mii-file-label\">\n <span class=\"mii-section__label\" id=\"mii-file-label\">Spreadsheet</span>\n\n <label class=\"mii-pick\" [class.mii-pick--busy]=\"busy()\">\n <mat-icon class=\"mii-pick__icon\" aria-hidden=\"true\">upload_file</mat-icon>\n <span class=\"mii-pick__text\">\n @if (fileName(); as name) {\n <span class=\"mii-pick__name\">{{ name }}</span>\n <span class=\"mii-pick__hint\">Choose another file to start over</span>\n } @else {\n <span class=\"mii-pick__name\">Choose a file</span>\n <span class=\"mii-pick__hint\">A workbook or CSV, with the headers in row 1</span>\n }\n </span>\n <input\n type=\"file\"\n class=\"mii-pick__input\"\n [accept]=\"accept\"\n [disabled]=\"busy()\"\n (change)=\"onFileSelected($event)\"\n aria-label=\"Choose a spreadsheet file\"\n />\n </label>\n\n @if (sheets().length > 1) {\n <div class=\"mii-sheets\" role=\"group\" aria-label=\"Sheet to import\">\n <span class=\"mii-sheets__label\">Sheet</span>\n @for (sheet of sheets(); track sheet.name) {\n <button\n type=\"button\"\n class=\"mii-sheet\"\n [class.mii-sheet--active]=\"sheet.name === activeSheet()\"\n [attr.aria-pressed]=\"sheet.name === activeSheet()\"\n [disabled]=\"busy()\"\n (click)=\"chooseSheet(sheet)\"\n >\n {{ sheet.name }}\n </button>\n }\n </div>\n }\n\n @if (error(); as message) {\n <p class=\"mii-alert mii-alert--error\" role=\"alert\">\n <mat-icon aria-hidden=\"true\">error</mat-icon>\n <span>{{ message }}</span>\n </p>\n }\n\n @if (mapping(); as m) {\n @if (m.missingRequired.length > 0) {\n <p class=\"mii-alert mii-alert--warn\" role=\"status\">\n <mat-icon aria-hidden=\"true\">warning</mat-icon>\n <span>\n No column for the required {{ m.missingRequired.length === 1 ? 'field' : 'fields' }}\n {{ m.missingRequired.join(', ') }}. Rows will not pass until the sheet carries\n {{ m.missingRequired.length === 1 ? 'it' : 'them' }}.\n </span>\n </p>\n }\n @if (m.ignored.length > 0) {\n <p class=\"mii-note\" role=\"status\">\n Ignored {{ m.ignored.length === 1 ? 'column' : 'columns' }}: {{ m.ignored.join(', ') }}\n </p>\n }\n }\n </section>\n\n <!-- 3 \u00B7 Review -->\n @if (stage() === 'validating' || stage() === 'reviewed') {\n <section class=\"mii-section\" aria-labelledby=\"mii-review-label\">\n <span class=\"mii-section__label\" id=\"mii-review-label\">Review</span>\n\n @if (stage() === 'validating') {\n <mat-progress-bar\n class=\"mii-progress\"\n mode=\"determinate\"\n [value]=\"progressPct()\"\n aria-label=\"Validation progress\"\n />\n }\n <p class=\"mii-summary\" role=\"status\" aria-live=\"polite\">{{ summary() }}</p>\n\n <div class=\"mii-scroll\">\n <table class=\"mii-table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"mii-th mii-th--index\">\n <span aria-hidden=\"true\">#</span>\n <span class=\"mii-sr-only\">Row</span>\n </th>\n <th scope=\"col\" class=\"mii-th\">Status</th>\n @for (column of reviewColumns(); track column.key) {\n <th scope=\"col\" class=\"mii-th\">{{ column.label }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of reviewRows(); track row.index) {\n <tr\n class=\"mii-row\"\n [class.mii-row--held]=\"row.status === 'invalid' || row.status === 'error' || row.status === 'overridable' || row.status === 'duplicate'\"\n >\n <td class=\"mii-td mii-td--index\">{{ row.index + 1 }}</td>\n <td class=\"mii-td\">\n <span class=\"mii-status\" [attr.data-status]=\"row.status\">\n <mat-icon aria-hidden=\"true\">{{ row.icon }}</mat-icon>\n <span>{{ row.label }}</span>\n </span>\n </td>\n @for (cell of row.cells; track cell.key) {\n <td class=\"mii-td\" [class.mii-td--error]=\"!!cell.error\" [class.mii-td--choice]=\"!!cell.choices\">\n @if (cell.choices; as choices) {\n <!--\n The text fits several options. The pick is the whole\n cell of a single select, or the one matching entry of a\n multi-select; the row is re-checked as soon as it lands.\n -->\n <div class=\"mii-choice\" role=\"group\" [attr.aria-label]=\"'Pick a match for ' + cell.label\">\n @for (choice of choices; track choice.text) {\n <label class=\"mii-choice__item\">\n <span class=\"mii-choice__text\">\u201C{{ choice.text }}\u201D</span>\n <span class=\"mii-choice__field\">\n <select\n class=\"mii-choice__select\"\n [disabled]=\"rechecking().has(row.index)\"\n (change)=\"pickOption(row.index, cell, choice, $event)\"\n >\n <option value=\"\" selected disabled>{{ choice.candidates.length }} matches \u2014 pick one</option>\n @for (candidate of choice.candidates; track $index) {\n <option [value]=\"$index\">{{ candidate.label }}</option>\n }\n </select>\n <mat-icon class=\"mii-choice__chevron\" aria-hidden=\"true\">expand_more</mat-icon>\n </span>\n </label>\n }\n </div>\n }\n @if (cell.error) {\n <span class=\"mii-cell-error\" [matTooltip]=\"cell.text ? 'Value: ' + cell.text : ''\">\n <mat-icon aria-hidden=\"true\">error</mat-icon>\n <span>{{ cell.error }}</span>\n </span>\n } @else if (!cell.choices) {\n <span class=\"mii-cell\" [attr.title]=\"cell.text\">{{ cell.text }}</span>\n }\n </td>\n }\n </tr>\n @if (row.message) {\n <tr class=\"mii-row-detail\">\n <td class=\"mii-td mii-td--detail\" [attr.colspan]=\"reviewColumns().length + 2\">\n {{ row.message }}\n </td>\n </tr>\n }\n }\n </tbody>\n </table>\n </div>\n </section>\n }\n</mat-dialog-content>\n\n<mat-dialog-actions class=\"mii__actions\">\n <button type=\"button\" mat-button class=\"mii__cancel\" [disabled]=\"busy()\" (click)=\"cancel()\">Cancel</button>\n <button\n type=\"button\"\n mat-flat-button\n color=\"primary\"\n class=\"mii__add\"\n [disabled]=\"!canAdd()\"\n (click)=\"add()\"\n >\n {{ addLabel() }}\n </button>\n</mat-dialog-actions>\n", styles: [":host{--mii-outline-12: color-mix(in srgb, var(--lib-forms-outline) 12%, transparent);--mii-outline-20: color-mix(in srgb, var(--lib-forms-outline) 20%, transparent);--mii-primary-06: color-mix(in srgb, var(--lib-forms-primary) 6%, transparent);--mii-primary-10: color-mix(in srgb, var(--lib-forms-primary) 10%, transparent);--mii-primary-14: color-mix(in srgb, var(--lib-forms-primary) 14%, transparent);--mii-primary-25: color-mix(in srgb, var(--lib-forms-primary) 25%, transparent);display:block;color:var(--lib-forms-on-surface)}.mii__header{display:flex;flex-direction:column;gap:.5rem;margin:0;padding:2.5rem 2.5rem 0}.mii__header:before{display:none}.mii__title{font-size:1.25rem;font-weight:500;letter-spacing:-.01em;line-height:1.3;color:var(--lib-forms-on-surface)}.mii__subtitle{font-size:.875rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii__content{display:flex;flex-direction:column;gap:2rem;padding:2rem 2.5rem 1rem;max-height:70vh}.mii-section{display:flex;flex-direction:column;gap:.75rem}.mii-section__label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.mii-section__hint{margin:0;font-size:.8125rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-columns{display:flex;flex-wrap:wrap;gap:.5rem;margin:0;padding:0;list-style:none}.mii-column{display:inline-flex;align-items:baseline;gap:.5rem;padding:.375rem .75rem;border:1px solid var(--mii-outline-20);border-radius:var(--lib-forms-radius-pill);background:var(--lib-forms-surface-container-low);font-size:.8125rem;line-height:1.2;color:var(--lib-forms-on-surface);transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),background-color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-column:hover{border-color:color-mix(in srgb,var(--lib-forms-primary) 40%,transparent);background:var(--mii-primary-06)}.mii-column--required{border-color:color-mix(in srgb,var(--lib-forms-primary) 30%,transparent)}.mii-column--skipped{color:var(--lib-forms-on-surface-variant);border-style:dashed}.mii-column__key{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.75rem}.mii-column__label{font-size:.75rem;color:var(--lib-forms-on-surface-variant)}.mii-column__flag{font-size:.625rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--lib-forms-primary)}.mii-column--skipped .mii-column__flag{color:var(--lib-forms-on-surface-variant)}.mii-template{display:flex;align-items:center;justify-content:space-between;gap:1.5rem;padding:1.25rem 1.5rem;border:1px solid var(--mii-outline-12);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface-container-low)}.mii-template__text{display:flex;flex-direction:column;gap:.25rem;min-width:0}.mii-template__title{font-size:.9375rem;font-weight:500;color:var(--lib-forms-on-surface)}.mii-template__hint{font-size:.8125rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-template__button{flex-shrink:0}@media(max-width:40rem){.mii-template{flex-direction:column;align-items:stretch}}.mii-pick{display:flex;align-items:center;gap:1rem;padding:1.25rem 1.5rem;border:1px dashed var(--mii-outline-20);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface);color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:border-color var(--lib-forms-duration) var(--lib-forms-easing),background-color var(--lib-forms-duration) var(--lib-forms-easing),color var(--lib-forms-duration) var(--lib-forms-easing)}.mii-pick:hover,.mii-pick:focus-within{border-color:var(--lib-forms-primary);background:var(--mii-primary-06);color:var(--lib-forms-primary)}.mii-pick:focus-within{border-style:solid;box-shadow:0 0 0 2px var(--mii-primary-25)}.mii-pick--busy{cursor:progress;opacity:.7}.mii-pick__icon{flex-shrink:0;font-size:1.25rem;width:1.25rem;height:1.25rem}.mii-pick__text{display:flex;flex-direction:column;gap:.25rem;min-width:0}.mii-pick__name{font-size:.9375rem;font-weight:500;color:var(--lib-forms-on-surface);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mii-pick__hint{font-size:.8125rem}.mii-pick__input{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.mii-sheets{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem}.mii-sheets__label{margin-right:.25rem;font-size:.75rem;color:var(--lib-forms-on-surface-variant)}.mii-sheet{padding:.375rem .875rem;border:1px solid var(--mii-outline-20);border-radius:var(--lib-forms-radius-pill);background:var(--lib-forms-surface);font:inherit;font-size:.8125rem;font-weight:500;color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),background-color var(--lib-forms-duration-hover) var(--lib-forms-easing),color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-sheet:hover,.mii-sheet:focus-visible{border-color:color-mix(in srgb,var(--lib-forms-primary) 40%,transparent);background:var(--mii-primary-06);color:var(--lib-forms-primary)}.mii-sheet:focus-visible{outline:3px solid var(--mii-primary-25);outline-offset:1px}.mii-sheet--active{border-color:var(--lib-forms-primary);background:var(--mii-primary-10);color:var(--lib-forms-primary)}.mii-sheet:disabled{cursor:default;opacity:.6}.mii-alert{display:flex;align-items:flex-start;gap:.5rem;margin:0;padding:.75rem 1rem;border-radius:var(--lib-forms-radius-sm);font-size:.8125rem;line-height:1.5}.mii-alert mat-icon{flex-shrink:0;font-size:1rem;width:1rem;height:1rem;margin-top:.125rem}.mii-alert--error{color:var(--sem-error);background:var(--sem-error-surface)}.mii-alert--warn{color:var(--sem-amber);background:var(--sem-amber-surface)}.mii-note{margin:0;font-size:.75rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-progress{--mdc-linear-progress-track-height: .25rem;--mdc-linear-progress-active-indicator-height: .25rem;border-radius:var(--lib-forms-radius-pill);overflow:hidden}.mii-summary{margin:0;font-size:.875rem;line-height:1.5;color:var(--lib-forms-on-surface)}.mii-scroll{max-height:40vh;overflow:auto;border:1px solid var(--mii-outline-12);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface)}.mii-table{width:100%;border-collapse:separate;border-spacing:0;font-size:.8125rem}.mii-th{position:sticky;top:0;z-index:1;padding:.75rem 1rem;text-align:left;font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;white-space:nowrap;color:var(--lib-forms-on-surface-variant);background:var(--lib-forms-surface-container-low)}.mii-th--index{width:2.5rem;text-align:right}.mii-td{padding:.625rem 1rem;vertical-align:middle;white-space:nowrap;color:var(--lib-forms-on-surface);transition:background-color var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-td--index{text-align:right;font-variant-numeric:tabular-nums;color:var(--lib-forms-on-surface-variant)}.mii-row:hover .mii-td{background:var(--mii-primary-06)}.mii-row--held .mii-td{background:color-mix(in srgb,var(--lib-forms-on-surface-variant) 4%,transparent)}.mii-cell{display:inline-block;max-width:18rem;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}.mii-cell-error{display:inline-flex;align-items:center;gap:.375rem;color:var(--sem-red);font-weight:500}.mii-cell-error mat-icon{font-size:1rem;width:1rem;height:1rem}.mii-td--detail{padding-top:0;padding-left:3.5rem;white-space:normal;font-size:.75rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.mii-td--choice{white-space:normal;vertical-align:top}.mii-choice{display:flex;flex-direction:column;gap:.75rem;min-width:14rem}.mii-choice__item{display:flex;flex-direction:column;gap:.375rem}.mii-choice__text{font-size:.75rem;color:var(--lib-forms-on-surface-variant)}.mii-choice__field{position:relative;display:block}.mii-choice__select{width:100%;min-height:2.25rem;padding:.375rem 2.25rem .375rem .75rem;border:1px solid var(--mii-outline-20);border-radius:var(--lib-forms-radius-md);background:var(--lib-forms-surface);font:inherit;font-size:.8125rem;color:var(--lib-forms-on-surface);appearance:none;cursor:pointer;transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),box-shadow var(--lib-forms-duration-hover) var(--lib-forms-easing)}.mii-choice__select:hover{border-color:color-mix(in srgb,var(--lib-forms-primary) 40%,transparent)}.mii-choice__select:focus-visible{outline:none;border-color:var(--lib-forms-primary);box-shadow:0 0 0 3px var(--mii-primary-14)}.mii-choice__select:disabled{cursor:progress;opacity:.6}.mii-choice__chevron{position:absolute;top:50%;right:.625rem;width:1.125rem;height:1.125rem;font-size:1.125rem;transform:translateY(-50%);pointer-events:none;color:var(--lib-forms-on-surface-variant)}.mii-td--choice .mii-cell-error{margin-top:.5rem}.mii-status{display:inline-flex;align-items:center;gap:.375rem;padding:.3125rem .75rem;border:1px solid transparent;border-radius:var(--lib-forms-radius-pill);font-size:.6875rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;white-space:nowrap;line-height:1;color:var(--sem-slate);background:var(--sem-slate-surface);border-color:color-mix(in srgb,var(--sem-slate) 30%,transparent);transition:color var(--lib-forms-duration) var(--lib-forms-easing),background-color var(--lib-forms-duration) var(--lib-forms-easing),border-color var(--lib-forms-duration) var(--lib-forms-easing)}.mii-status mat-icon{font-size:1rem;width:1rem;height:1rem}.mii-status[data-status=valid]{color:var(--sem-emerald);background:var(--sem-emerald-surface);border-color:color-mix(in srgb,var(--sem-emerald) 30%,transparent)}.mii-status[data-status=overridable],.mii-status[data-status=choice]{color:var(--sem-amber);background:var(--sem-amber-surface);border-color:color-mix(in srgb,var(--sem-amber) 30%,transparent)}.mii-status[data-status=invalid]{color:var(--sem-red);background:var(--sem-red-surface);border-color:color-mix(in srgb,var(--sem-red) 30%,transparent)}.mii-status[data-status=error]{color:var(--sem-rust);background:var(--sem-rust-surface);border-color:color-mix(in srgb,var(--sem-rust) 30%,transparent)}.mii-status[data-status=duplicate]{color:var(--sem-slate);background:var(--sem-slate-surface);border-color:color-mix(in srgb,var(--sem-slate) 30%,transparent)}.mii__actions{display:flex;justify-content:flex-end;gap:1rem;padding:1rem 2.5rem 2.5rem}.mii-sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}@media(prefers-reduced-motion:reduce){.mii-column,.mii-pick,.mii-sheet,.mii-td,.mii-choice__select,.mii-status{transition:none}}\n"] }]
1876
+ }] });
1877
+ /** Reads a file's bytes through `FileReader`, the API the rest of the library already relies on. */
1878
+ function readAsArrayBuffer(file) {
1879
+ return new Promise((resolve, reject) => {
1880
+ const reader = new FileReader();
1881
+ reader.onload = () => {
1882
+ const result = reader.result;
1883
+ if (result instanceof ArrayBuffer)
1884
+ resolve(result);
1885
+ else
1886
+ reject(new Error('Could not read the file.'));
1887
+ };
1888
+ reader.onerror = () => reject(reader.error ?? new Error('Could not read the file.'));
1889
+ reader.readAsArrayBuffer(file);
1890
+ });
1891
+ }
1892
+ function messageOf(error, fallback) {
1893
+ return error instanceof Error && error.message ? error.message : fallback;
1894
+ }
1895
+ /** `'required.min'` → `'Required, Too low'`. Unknown keys are shown as they are. */
1896
+ function formatErrorKeys(keys) {
1897
+ return keys
1898
+ .split('.')
1899
+ .filter(Boolean)
1900
+ .map((key) => {
1901
+ const [head, ...rest] = key.split(':');
1902
+ const label = ERROR_LABELS[head ?? ''] ?? key;
1903
+ return rest.length ? `${label} (${rest.join(':')})` : label;
1904
+ })
1905
+ .join(', ');
1906
+ }
1907
+ function cellFor(state, column) {
1908
+ const base = { key: column.key, label: column.label };
1909
+ const source = state.settledValue ?? state.originalData;
1910
+ const text = formatCell(source?.[column.key]);
1911
+ const choices = state.optionChoices?.[column.key];
1912
+ if (choices?.length) {
1913
+ // The tie itself is shown as the picker; only the cell's OTHER errors read as errors.
1914
+ const others = (state.colErrors?.[column.key] ?? '')
1915
+ .split('.')
1916
+ .filter((key) => key && !key.startsWith(AMBIGUOUS_OPTION_KEY))
1917
+ .join('.');
1918
+ return { ...base, text, error: others ? formatErrorKeys(others) : undefined, choices: choices.map(tellApart) };
1919
+ }
1920
+ const errorKeys = state.colErrors?.[column.key];
1921
+ return errorKeys ? { ...base, text, error: formatErrorKeys(errorKeys) } : { ...base, text };
1922
+ }
1923
+ /** `true` while a row waits on the user to settle a choice cell (its only route out of `invalid` is a pick). */
1924
+ function awaitsPick(state) {
1925
+ return state.status === 'invalid' && Object.values(state.optionChoices ?? {}).some((choices) => choices.length > 0);
1926
+ }
1927
+ /**
1928
+ * Makes a choice's candidates tell apart in a picker: two candidates that read
1929
+ * the same (two options labelled "Beta") show their stored value as well.
1930
+ */
1931
+ function tellApart(choice) {
1932
+ const labels = choice.candidates.map((candidate) => normaliseOptionText(candidate.label));
1933
+ return {
1934
+ text: choice.text,
1935
+ candidates: choice.candidates.map((candidate, index) => {
1936
+ const clashes = labels.some((label, other) => other !== index && label === labels[index]);
1937
+ const label = clashes ? `${candidate.label} (${String(candidate.value)})` : candidate.label;
1938
+ return { value: candidate.value, label: label.length > MAX_CELL_TEXT ? `${label.slice(0, MAX_CELL_TEXT - 1)}…` : label };
1939
+ }),
1940
+ };
1941
+ }
1942
+ function formatCell(value) {
1943
+ if (value === null || value === undefined)
1944
+ return '';
1945
+ let text;
1946
+ if (value instanceof Date) {
1947
+ text = Number.isNaN(value.getTime()) ? '' : value.toISOString().slice(0, 10);
1948
+ }
1949
+ else if (typeof value === 'object') {
1950
+ try {
1951
+ text = JSON.stringify(value);
1952
+ }
1953
+ catch {
1954
+ text = '';
1955
+ }
1956
+ }
1957
+ else {
1958
+ text = String(value);
1959
+ }
1960
+ return text.length > MAX_CELL_TEXT ? `${text.slice(0, MAX_CELL_TEXT - 1)}…` : text;
1961
+ }
1962
+
1963
+ const customInputConfig = {
1964
+ controlType: 'app-multiple-input-table',
1965
+ nextId: 0,
1966
+ };
1967
+ class MultipleInputTableComponent extends BaseCustomInput {
1968
+ #destroyRef;
1969
+ #dialog;
1970
+ /** The host's spreadsheet parser, when it opted in through `withSpreadsheetImport()`. */
1971
+ #spreadsheetParser;
1972
+ #templates;
1973
+ #errorHandler;
1974
+ constructor() {
1975
+ super(inject(NgControl, { self: true, optional: true }), inject(ElementRef), customInputConfig);
1976
+ this.editorMode = input(false, ...(ngDevMode ? [{ debugName: "editorMode" }] : /* istanbul ignore next */ []));
1977
+ this.formGroup = input.required(...(ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []));
1978
+ this.inputConfig = input.required(...(ngDevMode ? [{ debugName: "inputConfig" }] : /* istanbul ignore next */ []));
1979
+ this.formBuilderFunctions = input(undefined, ...(ngDevMode ? [{ debugName: "formBuilderFunctions" }] : /* istanbul ignore next */ []));
1980
+ this.#destroyRef = inject(DestroyRef);
1981
+ this.#dialog = inject(MatDialog);
1982
+ /** The host's spreadsheet parser, when it opted in through `withSpreadsheetImport()`. */
1983
+ this.#spreadsheetParser = inject(SPREADSHEET_PARSER, { optional: true });
1984
+ this.#templates = inject(SpreadsheetTemplateService);
1985
+ this.#errorHandler = inject(ErrorHandler);
1986
+ this.rowInViewOnly = undefined;
1987
+ this.listenToValueChanges();
1988
+ }
1989
+ /**
1990
+ * Manages custom validation errors on the form control.
1991
+ * Intended to be called from the ngDoCheck lifecycle hook.
1992
+ * This function handles both the 'required' error and the new
1993
+ * 'multipleInputListMissingSomeFields' custom error.
1994
+ */
1995
+ checkValidationsAnErrors() {
1996
+ const control = this.ngControl?.control;
1997
+ // 1. Early exit if there's no form control to work with.
1998
+ if (!control) {
1999
+ return;
2000
+ }
2001
+ // --- DEFINE THE DESIRED ERROR STATE ---
2002
+ // 2. Determine if the custom "multiple fields" error should exist.
2003
+ const missingFields = this.#missingRequiredFields();
2004
+ // 3. Determine if the standard 'required' error should exist.
2005
+ const shouldHaveRequiredError = this.required && this._isNilOrEmpty(this.value);
2006
+ // --- APPLY THE ERROR STATE TO THE CONTROL ---
2007
+ // 4. Preserve other errors that might be on the control (e.g., minlength, pattern).
2008
+ const newErrors = { ...control.errors };
2009
+ delete newErrors['required'];
2010
+ delete newErrors['multipleInputListMissingSomeFields'];
2011
+ // 5. Add our managed errors back if their conditions are met.
2012
+ if (shouldHaveRequiredError) {
2013
+ newErrors['required'] = true;
2014
+ }
2015
+ if (missingFields.length > 0) {
2016
+ // `missing` names the offending rows/fields so the rendered message can
2017
+ // tell the user exactly what to fix — see inputErrorMessage.ts.
2018
+ newErrors['multipleInputListMissingSomeFields'] = { value: true, missing: missingFields };
2019
+ }
2020
+ // 6. Finalize the error object. If no errors, it must be null.
2021
+ const finalErrors = Object.keys(newErrors).length > 0 ? newErrors : null;
2022
+ // 7. IMPORTANT: Only update the control if the errors have actually changed.
2023
+ // This prevents infinite loops within ngDoCheck. A simple stringify is a
2024
+ // dependency-free way to compare the error objects.
2025
+ if (JSON.stringify(control.errors) !== JSON.stringify(finalErrors)) {
2026
+ control.setErrors(finalErrors);
2027
+ }
2028
+ }
2029
+ get empty() {
2030
+ return !this.value;
2031
+ }
2032
+ get shouldLabelFloat() {
2033
+ return this.focused || !this.empty;
2034
+ }
2035
+ get errorState() {
2036
+ // 1. Check for standard validation errors from Angular's Forms API.
2037
+ const hasStandardError = !!this.ngControl?.errors;
2038
+ // 2. Check for custom validation errors specific to 'IMultiple' type.
2039
+ const hasCustomError = this.#missingRequiredFields().length > 0;
2040
+ // 3. The final error state is true if *any* validation fails,
2041
+ // AND the control has been "touched" by the user.
2042
+ return (hasStandardError || hasCustomError) && this.touched;
2043
+ }
2044
+ _isNilOrEmpty(value) {
2045
+ return value === null || value === undefined || value === '';
2046
+ }
2047
+ /**
2048
+ * Rows (1-based, in value order) whose required child inputs are empty,
2049
+ * each with the labels of the inputs still missing. Drives both `errorState`
2050
+ * and the `multipleInputListMissingSomeFields` error payload.
2051
+ */
2052
+ #missingRequiredFields() {
2053
+ const formInputs = this.inputConfig()?.formInputs;
2054
+ if (!Array.isArray(formInputs) || !Array.isArray(this.value))
2055
+ return [];
2056
+ const requiredFields = formInputs.filter(i => i.required);
2057
+ if (requiredFields.length === 0)
2058
+ return [];
2059
+ const configId = this.inputConfig().id;
2060
+ const missing = [];
2061
+ this.value.forEach((item, index) => {
2062
+ const fields = requiredFields
2063
+ .filter(f => this._isNilOrEmpty(item?.[`${configId}.${f.id}`]))
2064
+ .map(f => f.label || f.id);
2065
+ if (fields.length > 0) {
2066
+ missing.push({ row: index + 1, fields });
2067
+ }
2068
+ });
2069
+ return missing;
2070
+ }
2071
+ listenToValueChanges() {
2072
+ this.stateChanges
2073
+ .pipe(takeUntilDestroyed(this.#destroyRef))
2074
+ .subscribe(() => {
2075
+ this.checkItemList();
2076
+ });
2077
+ }
2078
+ checkItemList() {
2079
+ try {
2080
+ if (this.value) {
2081
+ const config = this.inputConfig();
2082
+ const TableData = (config.groupBy?.length ?? 0) > 0
2083
+ ? addGroups(this.value, config.groupBy)
2084
+ : this.value;
2085
+ const data = getCaluculatedTableData(config, TableData);
2086
+ if (!this.dataSource) {
2087
+ this.dataSource = new MatTableDataSource(data);
2088
+ this.dataSource;
2089
+ }
2090
+ else {
2091
+ this.dataSource.data = data;
2092
+ }
2093
+ }
2094
+ return true;
2095
+ }
2096
+ catch {
2097
+ return false;
2098
+ }
2099
+ }
2100
+ multipleInputRemoveItem(item) {
2101
+ if (!item)
2102
+ return;
2103
+ if (!this.value)
2104
+ return;
2105
+ this.value = this.value.filter((i) => !_isEqual(i, item));
2106
+ this.applyOptionsTo = undefined;
2107
+ this.onChange(this.value);
2108
+ this.stateChanges.next();
2109
+ }
2110
+ generateMultipleInputForm() {
2111
+ const id = this.inputConfig()?.id;
2112
+ if (!id)
2113
+ return;
2114
+ this.formBuilderFunctions()?.multipleInputToggleForm(id, true);
2115
+ }
2116
+ editRow(rowId) {
2117
+ if (!rowId) {
2118
+ throw new Error('Row id not provided');
2119
+ }
2120
+ const config = this.inputConfig();
2121
+ const fbf = this.formBuilderFunctions();
2122
+ if (!fbf || !config)
2123
+ return;
2124
+ fbf.multipleInputEditRow(config.id, rowId);
2125
+ // if( !this.inputConfig?.multipleInputController){
2126
+ // return
2127
+ // }
2128
+ // this.inputConfig.multipleInputInEditId = this.applyOptionsTo.id;
2129
+ // this.inputConfig.applyMultipleInputValuesToForm(
2130
+ // this.applyOptionsTo
2131
+ // );
2132
+ }
2133
+ copy(rowId) {
2134
+ const config = this.inputConfig();
2135
+ const fbf = this.formBuilderFunctions();
2136
+ if (!fbf || !config)
2137
+ return;
2138
+ fbf.multipleInputDuplicateRow(config.id, rowId);
2139
+ // this.generateMultipleInputForm();
2140
+ // this.inputConfig?.applyMultipleInputValuesToForm(
2141
+ // this.applyOptionsTo
2142
+ // );
2143
+ // this.applyOptionsTo = undefined;
2144
+ }
2145
+ get handleLabel() {
2146
+ return this.inputConfig()?.handleLabel;
2147
+ }
2148
+ handleIcon() {
2149
+ // NOTE(phase-4): `handleIcon` is declared on `IBasicFormInput` but not on `IMultiple` directly;
2150
+ // narrow through `ITowerStepColumn` (which extends FormColumnInputs) and provide a string fallback.
2151
+ const cfg = this.inputConfig();
2152
+ return cfg?.handleIcon || 'add';
2153
+ }
2154
+ saveMultipleInputForm() {
2155
+ this.formBuilderFunctions()?.multipleInputSaveForm(this.inputConfig().id);
2156
+ // const value: any = this.inputConfig?.multipleInputFormValue();
2157
+ // value['id'] = uuidv4();
2158
+ // if (!this.inputConfig) {
2159
+ // return
2160
+ // }
2161
+ // const previousValue = this.value
2162
+ // if (!previousValue) {
2163
+ // this.value = [value];
2164
+ // this.inputConfig.multipleInputController = undefined;
2165
+ // } else {
2166
+ // if (this.inputConfig?.multipleInputInEditId) {
2167
+ // let inEdit = previousValue.find(
2168
+ // (i: { id: any }) =>
2169
+ // i.id === this.inputConfig?.multipleInputInEditId
2170
+ // );
2171
+ // Object.keys(inEdit).every((s) => {
2172
+ // s;
2173
+ // inEdit[s] = value[s];
2174
+ // return !!inEdit[s];
2175
+ // });
2176
+ // this.value = [...previousValue],
2177
+ // this.inputConfig.multipleInputController = undefined;
2178
+ // } else {
2179
+ // this.value = [...previousValue, value];
2180
+ // this.inputConfig.multipleInputController = undefined;
2181
+ // }
2182
+ // }
2183
+ // this.onChange(this.value);
2184
+ // this.stateChanges.next();
2185
+ // this.checkItemList(this.value || []);
2186
+ // return
2187
+ }
2188
+ editInput(input) {
2189
+ const fbf = this.formBuilderFunctions();
2190
+ if (typeof fbf?.editInput !== 'function') {
2191
+ throw new Error('editInput function not defined in formBuilderFunctions');
2192
+ }
2193
+ fbf.editInput(input);
2194
+ }
2195
+ deleteItemInput(input) {
2196
+ this.formBuilderFunctions()?.deleteInput(input);
2197
+ }
2198
+ showItemAsLabel(input) {
2199
+ this.formBuilderFunctions()?.multipleInputToggleLabel(input);
2200
+ }
2201
+ addFunction(func) {
2202
+ this.formBuilderFunctions()?.addFunction(func, this.inputConfig()?.id);
2203
+ }
2204
+ // `FormBuilderFunctions.reorderItems` is now generic over the row shape; the
2205
+ // container/data slots stay `unknown` (opaque drag payload).
2206
+ reorderItems(event) {
2207
+ const config = this.inputConfig();
2208
+ const fbf = this.formBuilderFunctions();
2209
+ if (!fbf || !config)
2210
+ return;
2211
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Phase-4 TODO: deduplicate @angular/cdk peer dep in typings package; CdkDragDrop types are nominally distinct across copies.
2212
+ fbf.reorderItems(event, config.id);
2213
+ }
2214
+ /**
2215
+ * Whether the add button carries its menu (with "Import from spreadsheet"):
2216
+ * the host bound a parser and the field allows adding rows. The template
2217
+ * additionally hides the whole add-row bar for readonly / disabled /
2218
+ * open-form fields.
2219
+ */
2220
+ get canImportRows() {
2221
+ return this.#spreadsheetParser !== null && this.canAddRecords;
2222
+ }
2223
+ /**
2224
+ * Whether the menu also offers "Download import template": the host bound a
2225
+ * writer beside its parser. Never true without the import itself.
2226
+ */
2227
+ get canDownloadTemplate() {
2228
+ return this.canImportRows && this.#templates.available;
2229
+ }
2230
+ /**
2231
+ * Downloads the import template for this field: a workbook with the headers
2232
+ * the import matches and a guide to each column. The writer's failure, if
2233
+ * any, goes to the app's `ErrorHandler` — the menu has no surface of its own.
2234
+ */
2235
+ downloadImportTemplate() {
2236
+ const config = this.inputConfig();
2237
+ if (!this.canDownloadTemplate || !config)
2238
+ return;
2239
+ void this.#templates.download(config).catch((error) => this.#errorHandler.handleError(error));
2240
+ }
2241
+ /**
2242
+ * Opens the spreadsheet import for this field and appends the rows that
2243
+ * validate. Each row is checked by the same per-row tower the bulk import
2244
+ * uses for this field's sub-rows; only rows that settle valid come back.
2245
+ */
2246
+ importRowsFromSpreadsheet() {
2247
+ const config = this.inputConfig();
2248
+ if (!this.canImportRows || !config)
2249
+ return;
2250
+ this.#dialog
2251
+ .open(MultipleInputImportDialogComponent, {
2252
+ data: { input: config, existingRowCount: this.value?.length ?? 0 },
2253
+ width: 'min(72rem, 94vw)',
2254
+ maxWidth: '94vw',
2255
+ maxHeight: '90vh',
2256
+ autoFocus: 'first-tabbable',
2257
+ restoreFocus: true,
2258
+ // The dialog owns its own close paths; a stray Escape mid-validation
2259
+ // must not orphan a running session.
2260
+ disableClose: true,
2261
+ panelClass: 'lib-multiple-input-import-dialog__panel',
2262
+ })
2263
+ .afterClosed()
2264
+ .pipe(takeUntilDestroyed(this.#destroyRef))
2265
+ .subscribe((rows) => this.#appendImportedRows(rows));
2266
+ }
2267
+ /**
2268
+ * Appends settled rows (keyed by child `formControlName`) to the value in the
2269
+ * composite shape the table stores, cells coerced to the child's data type.
2270
+ * Goes through the same value path as delete, so the tower sees one change.
2271
+ */
2272
+ #appendImportedRows(rows) {
2273
+ if (!rows?.length)
2274
+ return;
2275
+ const config = this.inputConfig();
2276
+ const converted = rows.map((row) => toMultipleInputRow(config, coerceImportedRow(config, row)));
2277
+ this.value = [...(this.value ?? []), ...converted];
2278
+ this.markAsTouched();
2279
+ }
2280
+ get parentFormGroup() {
2281
+ return this.ngControl?.control?.parent;
2282
+ }
2283
+ get canAddRecords() {
2284
+ const config = this.inputConfig();
2285
+ if (!config)
2286
+ return false;
2287
+ //NOTE: Temporary backward compatibility for older versions of the config that might not have the new property
2288
+ if (!config.multipleInputAvailableOperations)
2289
+ return true;
2290
+ return config.multipleInputAvailableOperations?.includes(MultipleInputAvailableOperations.Add);
2291
+ }
2292
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2293
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: MultipleInputTableComponent, isStandalone: true, selector: "lib-multiple-input-table", inputs: { editorMode: { classPropertyName: "editorMode", publicName: "editorMode", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: true, transformFunction: null }, inputConfig: { classPropertyName: "inputConfig", publicName: "inputConfig", isSignal: true, isRequired: true, transformFunction: null }, formBuilderFunctions: { classPropertyName: "formBuilderFunctions", publicName: "formBuilderFunctions", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: MatFormFieldControl, useExisting: MultipleInputTableComponent }], usesInheritance: true, ngImport: i0, template: "<lib-multiple-input-table-view\n [inputConfig]=\"inputConfig()\"\n [dataSource]=\"dataSource\"\n [applyOptionsTo]=\"applyOptionsTo\"\n [formGroup]=\"parentFormGroup\"\n (onEditItem)=\"editRow($event)\"\n (showItemAsLabel)=\"showItemAsLabel(inputConfig())\"\n (onDeleteItem)=\"multipleInputRemoveItem(applyOptionsTo)\"\n (onCopy)=\"copy($event)\"\n (onApplyOptionsTo)=\"applyOptionsTo = $event\"\n></lib-multiple-input-table-view>\n\n@if (!!inputConfig().formIsOpen || !!rowInViewOnly) {\n <lib-multiple-input-table-edit\n [editorMode]=\"editorMode()\"\n (editMultipleInput)=\"editInput($event)\"\n (deleteInput)=\"deleteItemInput($event)\"\n (addFunction)=\"addFunction($event)\"\n (showItemAsLabel)=\"showItemAsLabel($event)\"\n (onSaveMultipleInputForm)=\"saveMultipleInputForm()\"\n (reorderItems)=\"reorderItems($event)\"\n [formBuilderFunctions]=\"formBuilderFunctions()\"\n [formGroup]=\"parentFormGroup\"\n [inputConfig]=\"inputConfig()\"\n ></lib-multiple-input-table-edit>\n}\n\n@if (!inputConfig().readonly && !inputConfig().disabled && !inputConfig().formIsOpen && canAddRecords) {\n <section class=\"add-row-bar\">\n <!--\n One dashed pill. The add button is the everyday action; once the host has\n bound a spreadsheet parser a narrow chevron segment joins it, opening the\n menu of other ways to add rows. Without a parser the pill is exactly the\n add button it always was.\n -->\n <div class=\"add-row-group\" [class.add-row-group--split]=\"canImportRows\">\n <button class=\"add-row-button\" (click)=\"generateMultipleInputForm()\" mat-stroked-button>\n <mat-icon class=\"add-row-icon\">{{ handleIcon() }}</mat-icon>\n <span class=\"add-row-label\">{{ handleLabel }}</span>\n </button>\n @if (canImportRows) {\n <button\n type=\"button\"\n class=\"add-row-more\"\n mat-stroked-button\n aria-label=\"More ways to add rows\"\n [attr.aria-expanded]=\"addRowMenuTrigger.menuOpen\"\n [matMenuTriggerFor]=\"addRowMenu\"\n #addRowMenuTrigger=\"matMenuTrigger\"\n >\n <mat-icon class=\"add-row-more-icon\">arrow_drop_down</mat-icon>\n </button>\n }\n </div>\n </section>\n}\n\n<mat-menu #addRowMenu=\"matMenu\">\n <ng-template matMenuContent>\n <button\n type=\"button\"\n mat-menu-item\n class=\"add-row-menu-item add-row-menu-item--import\"\n (click)=\"importRowsFromSpreadsheet()\"\n >\n <mat-icon>upload_file</mat-icon>\n <div class=\"add-row-menu__text\">\n <div class=\"add-row-menu__main\">Import from spreadsheet</div>\n <div class=\"add-row-menu__sub\">Check the rows of a workbook and add the ones that pass</div>\n </div>\n </button>\n @if (canDownloadTemplate) {\n <button\n type=\"button\"\n mat-menu-item\n class=\"add-row-menu-item add-row-menu-item--template\"\n (click)=\"downloadImportTemplate()\"\n >\n <mat-icon>download</mat-icon>\n <div class=\"add-row-menu__text\">\n <div class=\"add-row-menu__main\">Download import template</div>\n <div class=\"add-row-menu__sub\">A workbook with the headers to fill in and a guide to each column</div>\n </div>\n </button>\n }\n </ng-template>\n</mat-menu>\n", styles: [".table-container{position:relative;max-height:400px;overflow:auto}table{width:100%}.add-row-bar{margin-top:.5rem}.add-row-group{display:flex;align-items:stretch;width:100%}.add-row-button{flex:1 1 auto;width:100%;min-height:2.25rem;display:inline-flex;align-items:center;justify-content:center;gap:.375rem;border:1px dashed color-mix(in srgb,var(--mat-sys-outline, #79747e) 60%,transparent);border-radius:8px;color:var(--mat-sys-on-surface-variant, #49454f);background:transparent;font-size:.8125rem;font-weight:500;letter-spacing:.01em;transition:border-color .3s cubic-bezier(.16,1,.3,1),color .3s cubic-bezier(.16,1,.3,1),background .3s cubic-bezier(.16,1,.3,1)}.add-row-button:hover{border-color:var(--mat-sys-primary, #6750a4);color:var(--mat-sys-primary, #6750a4);background:color-mix(in srgb,var(--mat-sys-primary, #6750a4) 6%,transparent)}.add-row-button:focus-visible{border-style:solid;border-color:var(--mat-sys-primary, #6750a4);box-shadow:0 0 0 2px color-mix(in srgb,var(--mat-sys-primary, #6750a4) 25%,transparent)}.add-row-group--split .add-row-button{border-top-right-radius:0;border-bottom-right-radius:0;border-right:none}.add-row-more{flex:0 0 auto;width:2.25rem;min-width:0;min-height:2.25rem;padding:0;display:inline-flex;align-items:center;justify-content:center;border:1px dashed color-mix(in srgb,var(--lib-forms-outline) 60%,transparent);border-left:1px solid color-mix(in srgb,var(--lib-forms-outline) 40%,transparent);border-radius:0 var(--lib-forms-radius-sm) var(--lib-forms-radius-sm) 0;color:var(--lib-forms-on-surface-variant);background:transparent;transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),color var(--lib-forms-duration-hover) var(--lib-forms-easing),background var(--lib-forms-duration-hover) var(--lib-forms-easing)}.add-row-more:hover,.add-row-more[aria-expanded=true]{border-color:var(--lib-forms-primary);color:var(--lib-forms-primary);background:color-mix(in srgb,var(--lib-forms-primary) 6%,transparent)}.add-row-more:focus-visible{border-style:solid;border-color:var(--lib-forms-primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--lib-forms-primary) 25%,transparent)}.add-row-more-icon{margin:0;font-size:1.25rem;width:1.25rem;height:1.25rem;line-height:1.25rem}.add-row-icon{font-size:1.125rem;width:1.125rem;height:1.125rem;line-height:1.125rem}.add-row-label{line-height:1}.add-row-menu__text{display:flex;flex-direction:column;margin-left:.5rem}.add-row-menu__main{font-size:.875rem;font-weight:500;margin-bottom:2px;line-height:normal}.add-row-menu__sub{font-size:.75rem;font-weight:400;line-height:1.2;color:var(--lib-forms-on-surface-variant)}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i6.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i6.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i6.MatMenuContent, selector: "ng-template[matMenuContent]" }, { kind: "directive", type: i6.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "component", type: MultipleInputTableEditComponent, selector: "lib-multiple-input-table-edit", inputs: ["inputConfig", "editorMode", "formGroup", "formBuilderFunctions"], outputs: ["onSaveMultipleInputForm", "editMultipleInput", "deleteInput", "showItemAsLabel", "addFunction", "reorderItems"] }, { kind: "component", type: MultipleInputTableViewComponent, selector: "lib-multiple-input-table-view", inputs: ["inputConfig", "dataSource", "applyOptionsTo", "formGroup"], outputs: ["onEditItem", "onDeleteItem", "onCopy", "onApplyOptionsTo", "showItemAsLabel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2294
+ }
2295
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputTableComponent, decorators: [{
2296
+ type: Component,
2297
+ args: [{ selector: 'lib-multiple-input-table', imports: [
2298
+ MatButtonModule,
2299
+ MatIconModule,
2300
+ MatMenuModule,
2301
+ MultipleInputTableEditComponent,
2302
+ MultipleInputTableViewComponent,
2303
+ ], providers: [{ provide: MatFormFieldControl, useExisting: MultipleInputTableComponent }], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, template: "<lib-multiple-input-table-view\n [inputConfig]=\"inputConfig()\"\n [dataSource]=\"dataSource\"\n [applyOptionsTo]=\"applyOptionsTo\"\n [formGroup]=\"parentFormGroup\"\n (onEditItem)=\"editRow($event)\"\n (showItemAsLabel)=\"showItemAsLabel(inputConfig())\"\n (onDeleteItem)=\"multipleInputRemoveItem(applyOptionsTo)\"\n (onCopy)=\"copy($event)\"\n (onApplyOptionsTo)=\"applyOptionsTo = $event\"\n></lib-multiple-input-table-view>\n\n@if (!!inputConfig().formIsOpen || !!rowInViewOnly) {\n <lib-multiple-input-table-edit\n [editorMode]=\"editorMode()\"\n (editMultipleInput)=\"editInput($event)\"\n (deleteInput)=\"deleteItemInput($event)\"\n (addFunction)=\"addFunction($event)\"\n (showItemAsLabel)=\"showItemAsLabel($event)\"\n (onSaveMultipleInputForm)=\"saveMultipleInputForm()\"\n (reorderItems)=\"reorderItems($event)\"\n [formBuilderFunctions]=\"formBuilderFunctions()\"\n [formGroup]=\"parentFormGroup\"\n [inputConfig]=\"inputConfig()\"\n ></lib-multiple-input-table-edit>\n}\n\n@if (!inputConfig().readonly && !inputConfig().disabled && !inputConfig().formIsOpen && canAddRecords) {\n <section class=\"add-row-bar\">\n <!--\n One dashed pill. The add button is the everyday action; once the host has\n bound a spreadsheet parser a narrow chevron segment joins it, opening the\n menu of other ways to add rows. Without a parser the pill is exactly the\n add button it always was.\n -->\n <div class=\"add-row-group\" [class.add-row-group--split]=\"canImportRows\">\n <button class=\"add-row-button\" (click)=\"generateMultipleInputForm()\" mat-stroked-button>\n <mat-icon class=\"add-row-icon\">{{ handleIcon() }}</mat-icon>\n <span class=\"add-row-label\">{{ handleLabel }}</span>\n </button>\n @if (canImportRows) {\n <button\n type=\"button\"\n class=\"add-row-more\"\n mat-stroked-button\n aria-label=\"More ways to add rows\"\n [attr.aria-expanded]=\"addRowMenuTrigger.menuOpen\"\n [matMenuTriggerFor]=\"addRowMenu\"\n #addRowMenuTrigger=\"matMenuTrigger\"\n >\n <mat-icon class=\"add-row-more-icon\">arrow_drop_down</mat-icon>\n </button>\n }\n </div>\n </section>\n}\n\n<mat-menu #addRowMenu=\"matMenu\">\n <ng-template matMenuContent>\n <button\n type=\"button\"\n mat-menu-item\n class=\"add-row-menu-item add-row-menu-item--import\"\n (click)=\"importRowsFromSpreadsheet()\"\n >\n <mat-icon>upload_file</mat-icon>\n <div class=\"add-row-menu__text\">\n <div class=\"add-row-menu__main\">Import from spreadsheet</div>\n <div class=\"add-row-menu__sub\">Check the rows of a workbook and add the ones that pass</div>\n </div>\n </button>\n @if (canDownloadTemplate) {\n <button\n type=\"button\"\n mat-menu-item\n class=\"add-row-menu-item add-row-menu-item--template\"\n (click)=\"downloadImportTemplate()\"\n >\n <mat-icon>download</mat-icon>\n <div class=\"add-row-menu__text\">\n <div class=\"add-row-menu__main\">Download import template</div>\n <div class=\"add-row-menu__sub\">A workbook with the headers to fill in and a guide to each column</div>\n </div>\n </button>\n }\n </ng-template>\n</mat-menu>\n", styles: [".table-container{position:relative;max-height:400px;overflow:auto}table{width:100%}.add-row-bar{margin-top:.5rem}.add-row-group{display:flex;align-items:stretch;width:100%}.add-row-button{flex:1 1 auto;width:100%;min-height:2.25rem;display:inline-flex;align-items:center;justify-content:center;gap:.375rem;border:1px dashed color-mix(in srgb,var(--mat-sys-outline, #79747e) 60%,transparent);border-radius:8px;color:var(--mat-sys-on-surface-variant, #49454f);background:transparent;font-size:.8125rem;font-weight:500;letter-spacing:.01em;transition:border-color .3s cubic-bezier(.16,1,.3,1),color .3s cubic-bezier(.16,1,.3,1),background .3s cubic-bezier(.16,1,.3,1)}.add-row-button:hover{border-color:var(--mat-sys-primary, #6750a4);color:var(--mat-sys-primary, #6750a4);background:color-mix(in srgb,var(--mat-sys-primary, #6750a4) 6%,transparent)}.add-row-button:focus-visible{border-style:solid;border-color:var(--mat-sys-primary, #6750a4);box-shadow:0 0 0 2px color-mix(in srgb,var(--mat-sys-primary, #6750a4) 25%,transparent)}.add-row-group--split .add-row-button{border-top-right-radius:0;border-bottom-right-radius:0;border-right:none}.add-row-more{flex:0 0 auto;width:2.25rem;min-width:0;min-height:2.25rem;padding:0;display:inline-flex;align-items:center;justify-content:center;border:1px dashed color-mix(in srgb,var(--lib-forms-outline) 60%,transparent);border-left:1px solid color-mix(in srgb,var(--lib-forms-outline) 40%,transparent);border-radius:0 var(--lib-forms-radius-sm) var(--lib-forms-radius-sm) 0;color:var(--lib-forms-on-surface-variant);background:transparent;transition:border-color var(--lib-forms-duration-hover) var(--lib-forms-easing),color var(--lib-forms-duration-hover) var(--lib-forms-easing),background var(--lib-forms-duration-hover) var(--lib-forms-easing)}.add-row-more:hover,.add-row-more[aria-expanded=true]{border-color:var(--lib-forms-primary);color:var(--lib-forms-primary);background:color-mix(in srgb,var(--lib-forms-primary) 6%,transparent)}.add-row-more:focus-visible{border-style:solid;border-color:var(--lib-forms-primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--lib-forms-primary) 25%,transparent)}.add-row-more-icon{margin:0;font-size:1.25rem;width:1.25rem;height:1.25rem;line-height:1.25rem}.add-row-icon{font-size:1.125rem;width:1.125rem;height:1.125rem;line-height:1.125rem}.add-row-label{line-height:1}.add-row-menu__text{display:flex;flex-direction:column;margin-left:.5rem}.add-row-menu__main{font-size:.875rem;font-weight:500;margin-bottom:2px;line-height:normal}.add-row-menu__sub{font-size:.75rem;font-weight:400;line-height:1.2;color:var(--lib-forms-on-surface-variant)}\n"] }]
2304
+ }], ctorParameters: () => [], propDecorators: { editorMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "editorMode", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: true }] }], inputConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputConfig", required: true }] }], formBuilderFunctions: [{ type: i0.Input, args: [{ isSignal: true, alias: "formBuilderFunctions", required: false }] }] } });
2305
+ function addGroups(tableValue, groupBy) {
2306
+ throw new Error('Function not implemented.');
2307
+ }
2308
+
2309
+ /** Wraps a multi-row input table inside a `mat-form-field`. */
2310
+ class MultipleInputInputElementComponent {
2311
+ constructor() {
2312
+ this.inputConfig = input.required(...(ngDevMode ? [{ debugName: "inputConfig" }] : /* istanbul ignore next */ []));
2313
+ this.formGroup = input.required(...(ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []));
2314
+ this.editorMode = input(false, ...(ngDevMode ? [{ debugName: "editorMode" }] : /* istanbul ignore next */ []));
2315
+ this.formBuilderFunctions = input(undefined, ...(ngDevMode ? [{ debugName: "formBuilderFunctions" }] : /* istanbul ignore next */ []));
2316
+ this.reload = output();
2317
+ this.errorMessage = computed(() => getInputErrorMessage(this.inputConfig(), this.formGroup()), ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
2318
+ }
2319
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputInputElementComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2320
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: MultipleInputInputElementComponent, isStandalone: true, selector: "lib-multiple-input-input-element", inputs: { inputConfig: { classPropertyName: "inputConfig", publicName: "inputConfig", isSignal: true, isRequired: true, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: true, transformFunction: null }, editorMode: { classPropertyName: "editorMode", publicName: "editorMode", isSignal: true, isRequired: false, transformFunction: null }, formBuilderFunctions: { classPropertyName: "formBuilderFunctions", publicName: "formBuilderFunctions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { reload: "reload" }, ngImport: i0, template: "<form [formGroup]=\"formGroup()\">\r\n @if (inputConfig(); as inputConfig) {\r\n <mat-form-field\r\n class=\"multiple-input-field\"\r\n [appearance]=\"inputConfig.appearance || 'fill'\"\r\n subscriptSizing=\"dynamic\"\r\n floatLabel=\"always\"\r\n >\r\n <mat-label>\r\n {{ inputConfig.label }}\r\n <lib-t-form-input-status [inputConfig]=\"inputConfig\"></lib-t-form-input-status>\r\n </mat-label>\r\n\r\n @if (inputConfig.id) {\r\n <lib-multiple-input-table\r\n [editorMode]=\"editorMode()\"\r\n [required]=\"inputConfig.required\"\r\n [formGroup]=\"formGroup()\"\r\n [formBuilderFunctions]=\"formBuilderFunctions()\"\r\n [formControlName]=\"inputConfig.id\"\r\n [inputConfig]=\"inputConfig\"\r\n ></lib-multiple-input-table>\r\n }\r\n\r\n @if (inputConfig.hintLabel || inputConfig.temporaryHint) {\r\n <mat-hint class=\"inputHint\">\r\n {{ inputConfig.temporaryHint || inputConfig.hintLabel }}\r\n </mat-hint>\r\n }\r\n\r\n @if (!!errorMessage()) {\r\n <mat-error class=\"oneLineTextEllipsis\" matTooltipClass=\"errorToolTip\">{{ errorMessage() }}</mat-error>\r\n }\r\n\r\n @if (inputConfig.prefixIcon) {\r\n <mat-icon matPrefix>{{ inputConfig.prefixIcon }}</mat-icon>\r\n }\r\n\r\n @if (inputConfig.suffixIcon && inputConfig.id !== 'password') {\r\n <mat-icon matSuffix>{{ inputConfig.suffixIcon }}</mat-icon>\r\n }\r\n\r\n @if (inputConfig.prefixText) {\r\n <span class=\"affix-text\" matPrefix>{{ inputConfig.prefixText }}</span>\r\n }\r\n @if (inputConfig.suffixText) {\r\n <span class=\"affix-text affix-text--suffix\" matSuffix>{{ inputConfig.suffixText }}</span>\r\n }\r\n\r\n @if (inputConfig.maxLength && formGroup()) {\r\n <mat-hint align=\"end\">\r\n {{ (formGroup().controls[inputConfig.id]?.value?.length || 0) + '/' + inputConfig.maxLength }}\r\n </mat-hint>\r\n }\r\n </mat-form-field>\r\n }\r\n</form>\r\n", styles: [":host{display:block}.multiple-input-field{width:100%}.affix-text{top:0;color:var(--mat-sys-on-surface-variant, #49454f);font-size:.8125rem}.affix-text--suffix{padding-left:.3125rem}:host ::ng-deep .multiple-input-field .mat-mdc-form-field-flex{padding-left:.5rem;padding-right:.5rem}:host ::ng-deep .multiple-input-field .mat-mdc-form-field-infix{width:100%;min-height:0;padding-top:1.5rem;padding-bottom:.5rem}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i2$1.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i2$1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i2$1.MatPrefix, selector: "[matPrefix], [matIconPrefix], [matTextPrefix]", inputs: ["matTextPrefix"] }, { kind: "directive", type: i2$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "component", type: TFormInputStatusComponent, selector: "lib-t-form-input-status", inputs: ["inputConfig"] }, { kind: "component", type: MultipleInputTableComponent, selector: "lib-multiple-input-table", inputs: ["editorMode", "formGroup", "inputConfig", "formBuilderFunctions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2321
+ }
2322
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: MultipleInputInputElementComponent, decorators: [{
2323
+ type: Component,
2324
+ args: [{ selector: 'lib-multiple-input-input-element', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
2325
+ ReactiveFormsModule,
2326
+ MatFormFieldModule,
2327
+ MatIconModule,
2328
+ MatButtonModule,
2329
+ MatTooltipModule,
2330
+ TFormInputStatusComponent,
2331
+ MultipleInputTableComponent,
2332
+ ], template: "<form [formGroup]=\"formGroup()\">\r\n @if (inputConfig(); as inputConfig) {\r\n <mat-form-field\r\n class=\"multiple-input-field\"\r\n [appearance]=\"inputConfig.appearance || 'fill'\"\r\n subscriptSizing=\"dynamic\"\r\n floatLabel=\"always\"\r\n >\r\n <mat-label>\r\n {{ inputConfig.label }}\r\n <lib-t-form-input-status [inputConfig]=\"inputConfig\"></lib-t-form-input-status>\r\n </mat-label>\r\n\r\n @if (inputConfig.id) {\r\n <lib-multiple-input-table\r\n [editorMode]=\"editorMode()\"\r\n [required]=\"inputConfig.required\"\r\n [formGroup]=\"formGroup()\"\r\n [formBuilderFunctions]=\"formBuilderFunctions()\"\r\n [formControlName]=\"inputConfig.id\"\r\n [inputConfig]=\"inputConfig\"\r\n ></lib-multiple-input-table>\r\n }\r\n\r\n @if (inputConfig.hintLabel || inputConfig.temporaryHint) {\r\n <mat-hint class=\"inputHint\">\r\n {{ inputConfig.temporaryHint || inputConfig.hintLabel }}\r\n </mat-hint>\r\n }\r\n\r\n @if (!!errorMessage()) {\r\n <mat-error class=\"oneLineTextEllipsis\" matTooltipClass=\"errorToolTip\">{{ errorMessage() }}</mat-error>\r\n }\r\n\r\n @if (inputConfig.prefixIcon) {\r\n <mat-icon matPrefix>{{ inputConfig.prefixIcon }}</mat-icon>\r\n }\r\n\r\n @if (inputConfig.suffixIcon && inputConfig.id !== 'password') {\r\n <mat-icon matSuffix>{{ inputConfig.suffixIcon }}</mat-icon>\r\n }\r\n\r\n @if (inputConfig.prefixText) {\r\n <span class=\"affix-text\" matPrefix>{{ inputConfig.prefixText }}</span>\r\n }\r\n @if (inputConfig.suffixText) {\r\n <span class=\"affix-text affix-text--suffix\" matSuffix>{{ inputConfig.suffixText }}</span>\r\n }\r\n\r\n @if (inputConfig.maxLength && formGroup()) {\r\n <mat-hint align=\"end\">\r\n {{ (formGroup().controls[inputConfig.id]?.value?.length || 0) + '/' + inputConfig.maxLength }}\r\n </mat-hint>\r\n }\r\n </mat-form-field>\r\n }\r\n</form>\r\n", styles: [":host{display:block}.multiple-input-field{width:100%}.affix-text{top:0;color:var(--mat-sys-on-surface-variant, #49454f);font-size:.8125rem}.affix-text--suffix{padding-left:.3125rem}:host ::ng-deep .multiple-input-field .mat-mdc-form-field-flex{padding-left:.5rem;padding-right:.5rem}:host ::ng-deep .multiple-input-field .mat-mdc-form-field-infix{width:100%;min-height:0;padding-top:1.5rem;padding-bottom:.5rem}\n"] }]
2333
+ }], propDecorators: { inputConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputConfig", required: true }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: true }] }], editorMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "editorMode", required: false }] }], formBuilderFunctions: [{ type: i0.Input, args: [{ isSignal: true, alias: "formBuilderFunctions", required: false }] }], reload: [{ type: i0.Output, args: ["reload"] }] } });
2334
+
2335
+ export { MultipleInputInputElementComponent };
2336
+ //# sourceMappingURL=ngx-t-forms-multiple-input-input-element.component-BbbRpwPw.mjs.map