@caribeng/ui 22.4.0 → 22.6.0

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 (186) hide show
  1. package/README.md +313 -313
  2. package/fesm2022/caribeng-ui-account-picker.mjs +533 -0
  3. package/fesm2022/caribeng-ui-aging.mjs +488 -0
  4. package/fesm2022/{caribeng-ui-caribe-alert.mjs → caribeng-ui-alert.mjs} +45 -45
  5. package/fesm2022/caribeng-ui-amount.mjs +249 -0
  6. package/fesm2022/caribeng-ui-anchor.mjs +2 -2
  7. package/fesm2022/{caribeng-ui-caribe-animation-lottie.mjs → caribeng-ui-animation-lottie.mjs} +41 -41
  8. package/fesm2022/caribeng-ui-audit-log.mjs +323 -0
  9. package/fesm2022/caribeng-ui-avatar.mjs +2 -2
  10. package/fesm2022/caribeng-ui-breadcrumb.mjs +13 -3
  11. package/fesm2022/{caribeng-ui-caribe-button-group.mjs → caribeng-ui-button-group.mjs} +15 -15
  12. package/fesm2022/caribeng-ui-button.mjs +2 -2
  13. package/fesm2022/{caribeng-ui-caribe-card-content.mjs → caribeng-ui-card-content.mjs} +39 -39
  14. package/fesm2022/{caribeng-ui-caribe-card-move.mjs → caribeng-ui-card-move.mjs} +65 -65
  15. package/fesm2022/{caribeng-ui-caribe-card-primary.mjs → caribeng-ui-card-primary.mjs} +31 -31
  16. package/fesm2022/{caribeng-ui-caribe-card-select.mjs → caribeng-ui-card-select.mjs} +67 -67
  17. package/fesm2022/caribeng-ui-carousel.mjs +2 -2
  18. package/fesm2022/caribeng-ui-cascadeselect.mjs +45 -9
  19. package/fesm2022/caribeng-ui-chat.mjs +2 -2
  20. package/fesm2022/{caribeng-ui-caribe-coachmark.mjs → caribeng-ui-coachmark.mjs} +85 -85
  21. package/fesm2022/caribeng-ui-command-palette.mjs +2 -2
  22. package/fesm2022/caribeng-ui-comments.mjs +864 -0
  23. package/fesm2022/caribeng-ui-datagrid.mjs +1635 -0
  24. package/fesm2022/caribeng-ui-dataview.mjs +2 -2
  25. package/fesm2022/caribeng-ui-datepicker.mjs +2 -2
  26. package/fesm2022/caribeng-ui-document.mjs +495 -0
  27. package/fesm2022/{caribeng-ui-caribe-dots-indicator.mjs → caribeng-ui-dots-indicator.mjs} +41 -41
  28. package/fesm2022/caribeng-ui-dynamic-form.mjs +1581 -0
  29. package/fesm2022/caribeng-ui-editor.mjs +2303 -1311
  30. package/fesm2022/{caribeng-ui-caribe-expansion-panel.mjs → caribeng-ui-expansion-panel.mjs} +39 -39
  31. package/fesm2022/{caribeng-ui-caribe-fab-menu.mjs → caribeng-ui-fab-menu.mjs} +75 -75
  32. package/fesm2022/caribeng-ui-file-card.mjs +2 -2
  33. package/fesm2022/{caribeng-ui-caribe-file-download.mjs → caribeng-ui-file-download.mjs} +63 -63
  34. package/fesm2022/caribeng-ui-financial-report.mjs +380 -0
  35. package/fesm2022/{caribeng-ui-caribe-float-menu.mjs → caribeng-ui-float-menu.mjs} +31 -31
  36. package/fesm2022/caribeng-ui-floatlabel.mjs +2 -2
  37. package/fesm2022/caribeng-ui-flow.mjs +1508 -0
  38. package/fesm2022/{caribeng-ui-caribe-footer.mjs → caribeng-ui-footer.mjs} +19 -19
  39. package/fesm2022/caribeng-ui-gantt.mjs +1094 -0
  40. package/fesm2022/{caribeng-ui-caribe-header.mjs → caribeng-ui-header.mjs} +49 -49
  41. package/fesm2022/{caribeng-ui-caribe-icon-button.mjs → caribeng-ui-icon-button.mjs} +23 -23
  42. package/fesm2022/caribeng-ui-image-cropper.mjs +671 -0
  43. package/fesm2022/caribeng-ui-import-wizard.mjs +746 -0
  44. package/fesm2022/caribeng-ui-infinite-scroll.mjs +226 -0
  45. package/fesm2022/caribeng-ui-input-number.mjs +22 -6
  46. package/fesm2022/{caribeng-ui-caribe-input-search.mjs → caribeng-ui-input-search.mjs} +65 -65
  47. package/fesm2022/{caribeng-ui-caribe-input-token.mjs → caribeng-ui-input-token.mjs} +59 -59
  48. package/fesm2022/caribeng-ui-inputotp.mjs +2 -2
  49. package/fesm2022/caribeng-ui-journal-entry.mjs +340 -0
  50. package/fesm2022/caribeng-ui-kanban.mjs +6 -6
  51. package/fesm2022/caribeng-ui-kpi.mjs +189 -0
  52. package/fesm2022/{caribeng-ui-caribe-link.mjs → caribeng-ui-link.mjs} +37 -37
  53. package/fesm2022/caribeng-ui-masonry.mjs +93 -0
  54. package/fesm2022/caribeng-ui-media-player.mjs +821 -0
  55. package/fesm2022/caribeng-ui-mentions.mjs +2 -2
  56. package/fesm2022/caribeng-ui-notification-center.mjs +636 -0
  57. package/fesm2022/{caribeng-ui-caribe-off-canvas.mjs → caribeng-ui-off-canvas.mjs} +55 -55
  58. package/fesm2022/{caribeng-ui-caribe-onboarding.mjs → caribeng-ui-onboarding.mjs} +105 -105
  59. package/fesm2022/caribeng-ui-orderlist.mjs +2 -2
  60. package/fesm2022/caribeng-ui-pdfviewer.mjs +1755 -25
  61. package/fesm2022/caribeng-ui-period-picker.mjs +637 -0
  62. package/fesm2022/caribeng-ui-phone-input.mjs +2 -2
  63. package/fesm2022/caribeng-ui-picklist.mjs +2 -2
  64. package/fesm2022/caribeng-ui-pivot.mjs +419 -0
  65. package/fesm2022/caribeng-ui-pricing.mjs +2 -2
  66. package/fesm2022/caribeng-ui-rating.mjs +14 -17
  67. package/fesm2022/caribeng-ui-reconciliation.mjs +386 -0
  68. package/fesm2022/caribeng-ui-scheduler.mjs +1027 -0
  69. package/fesm2022/caribeng-ui-select.mjs +2 -2
  70. package/fesm2022/{caribeng-ui-caribe-shortcut.mjs → caribeng-ui-shortcut.mjs} +29 -29
  71. package/fesm2022/caribeng-ui-sidebar.mjs +2 -2
  72. package/fesm2022/caribeng-ui-signature-pad.mjs +654 -0
  73. package/fesm2022/{caribeng-ui-caribe-status.mjs → caribeng-ui-status.mjs} +11 -11
  74. package/fesm2022/{caribeng-ui-caribe-step-indicator.mjs → caribeng-ui-step-indicator.mjs} +53 -53
  75. package/fesm2022/caribeng-ui-stepper.mjs +2 -2
  76. package/fesm2022/caribeng-ui-steps.mjs +2 -2
  77. package/fesm2022/caribeng-ui-table.mjs +323 -15
  78. package/fesm2022/caribeng-ui-tabmenu.mjs +2 -2
  79. package/fesm2022/caribeng-ui-tabs.mjs +2 -2
  80. package/fesm2022/{caribeng-ui-caribe-tag-button.mjs → caribeng-ui-tag-button.mjs} +25 -25
  81. package/fesm2022/caribeng-ui-tag.mjs +2 -2
  82. package/fesm2022/caribeng-ui-tieredmenu.mjs +6 -6
  83. package/fesm2022/{caribeng-ui-caribe-tracker.mjs → caribeng-ui-tracker.mjs} +29 -29
  84. package/fesm2022/{caribeng-ui-caribe-transaction-status.mjs → caribeng-ui-transaction-status.mjs} +11 -11
  85. package/fesm2022/caribeng-ui-treeselect.mjs +44 -9
  86. package/fesm2022/caribeng-ui-treetable.mjs +236 -17
  87. package/fesm2022/{caribeng-ui-caribe-voucher.mjs → caribeng-ui-voucher.mjs} +45 -45
  88. package/fesm2022/caribeng-ui-xlsx.mjs +486 -0
  89. package/fesm2022/caribeng-ui.mjs +1185 -5
  90. package/package.json +217 -177
  91. package/types/caribeng-ui-account-picker.d.ts +142 -0
  92. package/types/caribeng-ui-aging.d.ts +123 -0
  93. package/types/{caribeng-ui-caribe-alert.d.ts → caribeng-ui-alert.d.ts} +2 -2
  94. package/types/caribeng-ui-amount.d.ts +82 -0
  95. package/types/{caribeng-ui-caribe-animation-lottie.d.ts → caribeng-ui-animation-lottie.d.ts} +2 -2
  96. package/types/caribeng-ui-audit-log.d.ts +86 -0
  97. package/types/caribeng-ui-breadcrumb.d.ts +2 -2
  98. package/types/{caribeng-ui-caribe-button-group.d.ts → caribeng-ui-button-group.d.ts} +2 -2
  99. package/types/{caribeng-ui-caribe-card-content.d.ts → caribeng-ui-card-content.d.ts} +2 -2
  100. package/types/{caribeng-ui-caribe-card-move.d.ts → caribeng-ui-card-move.d.ts} +1 -1
  101. package/types/{caribeng-ui-caribe-card-primary.d.ts → caribeng-ui-card-primary.d.ts} +2 -2
  102. package/types/{caribeng-ui-caribe-card-select.d.ts → caribeng-ui-card-select.d.ts} +2 -2
  103. package/types/caribeng-ui-cascadeselect.d.ts +6 -0
  104. package/types/{caribeng-ui-caribe-coachmark.d.ts → caribeng-ui-coachmark.d.ts} +2 -2
  105. package/types/caribeng-ui-comments.d.ts +214 -0
  106. package/types/caribeng-ui-datagrid.d.ts +269 -0
  107. package/types/caribeng-ui-document.d.ts +138 -0
  108. package/types/{caribeng-ui-caribe-dots-indicator.d.ts → caribeng-ui-dots-indicator.d.ts} +2 -2
  109. package/types/caribeng-ui-dynamic-form.d.ts +409 -0
  110. package/types/caribeng-ui-editor.d.ts +110 -12
  111. package/types/{caribeng-ui-caribe-expansion-panel.d.ts → caribeng-ui-expansion-panel.d.ts} +1 -1
  112. package/types/{caribeng-ui-caribe-fab-menu.d.ts → caribeng-ui-fab-menu.d.ts} +2 -2
  113. package/types/{caribeng-ui-caribe-file-download.d.ts → caribeng-ui-file-download.d.ts} +1 -1
  114. package/types/caribeng-ui-financial-report.d.ts +102 -0
  115. package/types/{caribeng-ui-caribe-float-menu.d.ts → caribeng-ui-float-menu.d.ts} +2 -2
  116. package/types/caribeng-ui-flow.d.ts +228 -0
  117. package/types/{caribeng-ui-caribe-footer.d.ts → caribeng-ui-footer.d.ts} +2 -2
  118. package/types/caribeng-ui-gantt.d.ts +244 -0
  119. package/types/{caribeng-ui-caribe-header.d.ts → caribeng-ui-header.d.ts} +2 -2
  120. package/types/{caribeng-ui-caribe-icon-button.d.ts → caribeng-ui-icon-button.d.ts} +2 -2
  121. package/types/{caribeng-ui-caribe-illustration.d.ts → caribeng-ui-illustration.d.ts} +1 -1
  122. package/types/caribeng-ui-image-cropper.d.ts +169 -0
  123. package/types/caribeng-ui-import-wizard.d.ts +149 -0
  124. package/types/caribeng-ui-infinite-scroll.d.ts +75 -0
  125. package/types/caribeng-ui-input-number.d.ts +1 -1
  126. package/types/{caribeng-ui-caribe-input-search.d.ts → caribeng-ui-input-search.d.ts} +2 -2
  127. package/types/{caribeng-ui-caribe-input-token.d.ts → caribeng-ui-input-token.d.ts} +2 -2
  128. package/types/caribeng-ui-journal-entry.d.ts +110 -0
  129. package/types/caribeng-ui-kpi.d.ts +64 -0
  130. package/types/{caribeng-ui-caribe-link.d.ts → caribeng-ui-link.d.ts} +2 -2
  131. package/types/{caribeng-ui-caribe-logo.d.ts → caribeng-ui-logo.d.ts} +1 -1
  132. package/types/caribeng-ui-masonry.d.ts +32 -0
  133. package/types/caribeng-ui-media-player.d.ts +140 -0
  134. package/types/caribeng-ui-notification-center.d.ts +153 -0
  135. package/types/{caribeng-ui-caribe-off-canvas.d.ts → caribeng-ui-off-canvas.d.ts} +2 -2
  136. package/types/{caribeng-ui-caribe-onboarding.d.ts → caribeng-ui-onboarding.d.ts} +2 -2
  137. package/types/caribeng-ui-pdfviewer.d.ts +245 -5
  138. package/types/caribeng-ui-period-picker.d.ts +148 -0
  139. package/types/caribeng-ui-pivot.d.ts +116 -0
  140. package/types/caribeng-ui-reconciliation.d.ts +109 -0
  141. package/types/caribeng-ui-scheduler.d.ts +188 -0
  142. package/types/{caribeng-ui-caribe-shortcut.d.ts → caribeng-ui-shortcut.d.ts} +2 -2
  143. package/types/caribeng-ui-signature-pad.d.ts +151 -0
  144. package/types/{caribeng-ui-caribe-status.d.ts → caribeng-ui-status.d.ts} +2 -2
  145. package/types/{caribeng-ui-caribe-step-indicator.d.ts → caribeng-ui-step-indicator.d.ts} +2 -2
  146. package/types/caribeng-ui-table.d.ts +66 -2
  147. package/types/{caribeng-ui-caribe-tag-button.d.ts → caribeng-ui-tag-button.d.ts} +2 -2
  148. package/types/{caribeng-ui-caribe-tracker.d.ts → caribeng-ui-tracker.d.ts} +2 -2
  149. package/types/{caribeng-ui-caribe-transaction-status.d.ts → caribeng-ui-transaction-status.d.ts} +2 -2
  150. package/types/caribeng-ui-treeselect.d.ts +6 -0
  151. package/types/caribeng-ui-treetable.d.ts +67 -2
  152. package/types/{caribeng-ui-caribe-voucher.d.ts → caribeng-ui-voucher.d.ts} +2 -2
  153. package/types/caribeng-ui-xlsx.d.ts +79 -0
  154. package/types/caribeng-ui.d.ts +713 -4
  155. package/fesm2022/caribeng-ui-caribe-calendar.mjs +0 -92
  156. package/fesm2022/caribeng-ui-caribe-circle-loading.mjs +0 -130
  157. package/fesm2022/caribeng-ui-caribe-data-table.mjs +0 -94
  158. package/fesm2022/caribeng-ui-caribe-file-select.mjs +0 -88
  159. package/fesm2022/caribeng-ui-caribe-inline-alert.mjs +0 -100
  160. package/fesm2022/caribeng-ui-caribe-input-date.mjs +0 -138
  161. package/fesm2022/caribeng-ui-caribe-input-select.mjs +0 -154
  162. package/fesm2022/caribeng-ui-caribe-loader.mjs +0 -48
  163. package/fesm2022/caribeng-ui-caribe-modal.mjs +0 -119
  164. package/fesm2022/caribeng-ui-caribe-pictogram.mjs +0 -52
  165. package/fesm2022/caribeng-ui-caribe-pop-over.mjs +0 -104
  166. package/fesm2022/caribeng-ui-caribe-preloader.mjs +0 -57
  167. package/fesm2022/caribeng-ui-caribe-progress-bar.mjs +0 -84
  168. package/fesm2022/caribeng-ui-caribe-stroke.mjs +0 -69
  169. package/fesm2022/caribeng-ui-caribe-switch.mjs +0 -182
  170. package/types/caribeng-ui-caribe-calendar.d.ts +0 -27
  171. package/types/caribeng-ui-caribe-circle-loading.d.ts +0 -28
  172. package/types/caribeng-ui-caribe-data-table.d.ts +0 -26
  173. package/types/caribeng-ui-caribe-file-select.d.ts +0 -31
  174. package/types/caribeng-ui-caribe-inline-alert.d.ts +0 -28
  175. package/types/caribeng-ui-caribe-input-date.d.ts +0 -40
  176. package/types/caribeng-ui-caribe-input-select.d.ts +0 -47
  177. package/types/caribeng-ui-caribe-loader.d.ts +0 -22
  178. package/types/caribeng-ui-caribe-modal.d.ts +0 -21
  179. package/types/caribeng-ui-caribe-pictogram.d.ts +0 -15
  180. package/types/caribeng-ui-caribe-pop-over.d.ts +0 -17
  181. package/types/caribeng-ui-caribe-preloader.d.ts +0 -24
  182. package/types/caribeng-ui-caribe-progress-bar.d.ts +0 -28
  183. package/types/caribeng-ui-caribe-stroke.d.ts +0 -17
  184. package/types/caribeng-ui-caribe-switch.d.ts +0 -55
  185. /package/fesm2022/{caribeng-ui-caribe-illustration.mjs → caribeng-ui-illustration.mjs} +0 -0
  186. /package/fesm2022/{caribeng-ui-caribe-logo.mjs → caribeng-ui-logo.mjs} +0 -0
@@ -0,0 +1,746 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, booleanAttribute, output, signal, computed, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
4
+ import { FormsModule } from '@angular/forms';
5
+ import { injectCbTranslation, cbFormat } from '@caribeng/ui';
6
+ import { CbButton } from '@caribeng/ui/button';
7
+ import { CbCheckbox } from '@caribeng/ui/checkbox';
8
+ import { CbDataGrid } from '@caribeng/ui/datagrid';
9
+ import { CbIcon } from '@caribeng/ui/icon';
10
+ import { CbSelect } from '@caribeng/ui/select';
11
+ import { cbReadXlsx } from '@caribeng/ui/xlsx';
12
+
13
+ function fold(text) {
14
+ return text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/[^a-z0-9]/g, '');
15
+ }
16
+ /** Separador más probable de un texto delimitado (tabulador, punto y coma o coma). */
17
+ function detectDelimiter(text) {
18
+ const line = text.split(/\r?\n/).find((l) => l.trim()) ?? '';
19
+ const count = (sep) => {
20
+ let n = 0;
21
+ let quoted = false;
22
+ for (const ch of line) {
23
+ if (ch === '"')
24
+ quoted = !quoted;
25
+ else if (ch === sep && !quoted)
26
+ n++;
27
+ }
28
+ return n;
29
+ };
30
+ return ['\t', ';', ','].reduce((best, sep) => (count(sep) > count(best) ? sep : best), '\t');
31
+ }
32
+ /** CSV / TSV a filas (comillas dobles, saltos de línea dentro de comillas, BOM). */
33
+ function parseDelimited(text, delimiter = detectDelimiter(text)) {
34
+ const src = text.replace(/^/, '').replace(/\r\n?/g, '\n');
35
+ const out = [];
36
+ let row = [];
37
+ let cell = '';
38
+ let quoted = false;
39
+ for (let i = 0; i < src.length; i++) {
40
+ const ch = src[i];
41
+ if (quoted) {
42
+ if (ch === '"' && src[i + 1] === '"') {
43
+ cell += '"';
44
+ i++;
45
+ }
46
+ else if (ch === '"')
47
+ quoted = false;
48
+ else
49
+ cell += ch;
50
+ }
51
+ else if (ch === '"' && cell === '')
52
+ quoted = true;
53
+ else if (ch === delimiter) {
54
+ row.push(cell);
55
+ cell = '';
56
+ }
57
+ else if (ch === '\n') {
58
+ row.push(cell);
59
+ out.push(row);
60
+ row = [];
61
+ cell = '';
62
+ }
63
+ else
64
+ cell += ch;
65
+ }
66
+ if (cell !== '' || row.length) {
67
+ row.push(cell);
68
+ out.push(row);
69
+ }
70
+ // Sin filas totalmente vacías al final.
71
+ while (out.length && out[out.length - 1].every((c) => !c.trim()))
72
+ out.pop();
73
+ return out;
74
+ }
75
+ /**
76
+ * Importe a partir de texto: `$ 1.234,56`, `1,234.56`, `(1.234)` (negativo),
77
+ * `-1234`, `1.234.567`. Con un solo separador repetido, o seguido de 3 cifras,
78
+ * se toma como de miles.
79
+ */
80
+ function parseAmount(value) {
81
+ if (typeof value === 'number')
82
+ return Number.isFinite(value) ? value : undefined;
83
+ if (value === null || value === '' || typeof value === 'boolean')
84
+ return value === null || value === '' ? null : undefined;
85
+ let s = value.trim();
86
+ if (!s)
87
+ return null;
88
+ let negative = false;
89
+ if (/^\(.*\)$/.test(s)) {
90
+ negative = true;
91
+ s = s.slice(1, -1);
92
+ }
93
+ s = s.replace(/[\s$€£¥]|COP|USD|EUR/gi, '');
94
+ if (s.startsWith('-')) {
95
+ negative = !negative;
96
+ s = s.slice(1);
97
+ }
98
+ if (!/^[\d.,]+$/.test(s))
99
+ return undefined;
100
+ const comma = s.lastIndexOf(',');
101
+ const dot = s.lastIndexOf('.');
102
+ if (comma >= 0 && dot >= 0)
103
+ s = comma > dot ? s.replace(/\./g, '').replace(',', '.') : s.replace(/,/g, '');
104
+ else {
105
+ const sep = comma >= 0 ? ',' : dot >= 0 ? '.' : '';
106
+ if (sep) {
107
+ const parts = s.split(sep);
108
+ const thousands = parts.length > 2 || (parts.length === 2 && parts[1].length === 3 && parts[0].length <= 3 && parts[0] !== '0');
109
+ s = thousands ? parts.join('') : parts.join('.');
110
+ }
111
+ }
112
+ const n = Number(s);
113
+ return Number.isFinite(n) ? (negative ? -n : n) : undefined;
114
+ }
115
+ /** Fecha a partir de texto (`AAAA-MM-DD`, `DD/MM/AAAA`, `DD-MM-AAAA`) o de un número de serie de Excel. */
116
+ function parseDate(value) {
117
+ if (value === null || value === '')
118
+ return null;
119
+ if (typeof value === 'number') {
120
+ if (value < 1 || value > 2958465)
121
+ return undefined;
122
+ const utc = new Date(Math.round((value - 25569) * 86400000));
123
+ return new Date(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate());
124
+ }
125
+ if (typeof value !== 'string')
126
+ return undefined;
127
+ const s = value.trim();
128
+ let m = /^(\d{4})[-/.](\d{1,2})[-/.](\d{1,2})/.exec(s);
129
+ let y, mo, d;
130
+ if (m)
131
+ [y, mo, d] = [+m[1], +m[2], +m[3]];
132
+ else if ((m = /^(\d{1,2})[-/.](\d{1,2})[-/.](\d{2,4})$/.exec(s)))
133
+ [d, mo, y] = [+m[1], +m[2], +m[3] < 100 ? 2000 + +m[3] : +m[3]];
134
+ else
135
+ return undefined;
136
+ const date = new Date(y, mo - 1, d);
137
+ return date.getMonth() === mo - 1 && date.getDate() === d ? date : undefined;
138
+ }
139
+ const TRUE = new Set(['si', 'sí', 'yes', 'y', 's', 'true', 'verdadero', '1', 'x']);
140
+ const FALSE = new Set(['no', 'n', 'false', 'falso', '0']);
141
+ function parseBoolean(value) {
142
+ if (typeof value === 'boolean')
143
+ return value;
144
+ if (value === null || value === '')
145
+ return null;
146
+ const s = String(value).trim().toLowerCase();
147
+ return TRUE.has(s) ? true : FALSE.has(s) ? false : undefined;
148
+ }
149
+ /** Asigna cada campo a la columna cuyo encabezado coincide con su clave, etiqueta o alias. */
150
+ function autoMap(headers, fields) {
151
+ const folded = headers.map((h) => fold(String(h ?? '')));
152
+ const used = new Set();
153
+ const out = {};
154
+ for (const f of fields) {
155
+ const names = [f.key, f.label, ...(f.aliases ?? [])].map(fold);
156
+ const i = folded.findIndex((h, idx) => !used.has(idx) && h && names.includes(h));
157
+ out[f.key] = i >= 0 ? i : null;
158
+ if (i >= 0)
159
+ used.add(i);
160
+ }
161
+ return out;
162
+ }
163
+ /** Convierte las filas con la asignación de columnas: valores con tipo y errores por celda. */
164
+ function convertRows(rows, mapping, fields, texts) {
165
+ const out = [];
166
+ const errors = [];
167
+ rows.forEach((source, i) => {
168
+ const record = {};
169
+ const rowErrors = [];
170
+ for (const f of fields) {
171
+ const col = mapping[f.key];
172
+ const raw = col === null || col === undefined ? null : (source[col] ?? null);
173
+ const type = f.type ?? 'text';
174
+ let value;
175
+ let error = null;
176
+ if (type === 'number') {
177
+ value = parseAmount(raw);
178
+ if (value === undefined)
179
+ error = texts.number;
180
+ }
181
+ else if (type === 'date') {
182
+ value = parseDate(raw);
183
+ if (value === undefined)
184
+ error = texts.date;
185
+ }
186
+ else if (type === 'boolean') {
187
+ value = parseBoolean(raw);
188
+ if (value === undefined)
189
+ error = texts.boolean;
190
+ }
191
+ else
192
+ value = raw === null ? null : String(raw).trim();
193
+ if (error)
194
+ value = raw;
195
+ else if (f.required && (value === null || value === ''))
196
+ error = texts.required;
197
+ record[f.key] = value;
198
+ if (error)
199
+ rowErrors.push({ row: i + 1, field: f.key, message: error });
200
+ }
201
+ for (const f of fields) {
202
+ if (rowErrors.some((e) => e.field === f.key) || !f.validate)
203
+ continue;
204
+ const message = f.validate(record[f.key], record);
205
+ if (message)
206
+ rowErrors.push({ row: i + 1, field: f.key, message });
207
+ }
208
+ out.push(record);
209
+ errors.push(...rowErrors);
210
+ });
211
+ return { rows: out, errors };
212
+ }
213
+
214
+ let nextUid = 0;
215
+ /**
216
+ * Asistente de importación de CaribeNG: archivo (CSV, TSV, Excel o datos pegados),
217
+ * asignación de columnas y revisión con validación fila a fila antes de importar.
218
+ *
219
+ * - Lee .xlsx en el navegador (varias hojas), CSV con `,` o `;` y lo copiado de una hoja de cálculo.
220
+ * - Asigna sola cada columna cuyo encabezado coincide con el campo (o sus `aliases`).
221
+ * - Interpreta importes (`$ 1.234,56`, `(1.234)`), fechas (`DD/MM/AAAA`, serie de Excel)
222
+ * y casillas (Sí / No); marca cada celda con error y deja importar solo las filas válidas.
223
+ *
224
+ * @example
225
+ * ```html
226
+ * <cb-import-wizard [fields]="campos" (import)="guardar($event.rows)" />
227
+ * ```
228
+ */
229
+ class CbImportWizard {
230
+ constructor() {
231
+ this.t = injectCbTranslation();
232
+ this.fmt = cbFormat;
233
+ this.uid = `cb-import-wizard-${++nextUid}`;
234
+ this.steps = ['file', 'map', 'review'];
235
+ this.accept = '.csv,.tsv,.txt,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
236
+ /** Campos de destino (clave, etiqueta, tipo, obligatorio, alias y validación). */
237
+ this.fields = input([], /* @ts-ignore */
238
+ ...(ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []));
239
+ /** Importa también las filas con errores (marcadas en `errors`). */
240
+ this.allowInvalid = input(false, { ...(ngDevMode ? { debugName: "allowInvalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
241
+ /** Filas importadas (con tipo) y errores encontrados. */
242
+ this.import = output();
243
+ this.step = signal('file', /* @ts-ignore */
244
+ ...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
245
+ this.stepIndex = computed(() => this.steps.indexOf(this.step()), /* @ts-ignore */
246
+ ...(ngDevMode ? [{ debugName: "stepIndex" }] : /* istanbul ignore next */ []));
247
+ this.dragging = signal(false, /* @ts-ignore */
248
+ ...(ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []));
249
+ this.pasteOpen = signal(false, /* @ts-ignore */
250
+ ...(ngDevMode ? [{ debugName: "pasteOpen" }] : /* istanbul ignore next */ []));
251
+ this.fileName = signal('', /* @ts-ignore */
252
+ ...(ngDevMode ? [{ debugName: "fileName" }] : /* istanbul ignore next */ []));
253
+ this.error = signal('', /* @ts-ignore */
254
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
255
+ this.sheets = signal([], /* @ts-ignore */
256
+ ...(ngDevMode ? [{ debugName: "sheets" }] : /* istanbul ignore next */ []));
257
+ this.sheetIndex = signal(0, /* @ts-ignore */
258
+ ...(ngDevMode ? [{ debugName: "sheetIndex" }] : /* istanbul ignore next */ []));
259
+ this.text = signal([], /* @ts-ignore */
260
+ ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
261
+ this.hasHeader = signal(true, /* @ts-ignore */
262
+ ...(ngDevMode ? [{ debugName: "hasHeader" }] : /* istanbul ignore next */ []));
263
+ this.mapping = signal({}, /* @ts-ignore */
264
+ ...(ngDevMode ? [{ debugName: "mapping" }] : /* istanbul ignore next */ []));
265
+ this.onlyValid = signal(true, /* @ts-ignore */
266
+ ...(ngDevMode ? [{ debugName: "onlyValid" }] : /* istanbul ignore next */ []));
267
+ /** Filas leídas (de la hoja elegida o del texto). */
268
+ this.raw = computed(() => {
269
+ const sheets = this.sheets();
270
+ const rows = sheets.length ? (sheets[this.sheetIndex()]?.rows ?? []) : this.text();
271
+ return rows.filter((r) => r.some((c) => c !== null && c !== ''));
272
+ }, /* @ts-ignore */
273
+ ...(ngDevMode ? [{ debugName: "raw" }] : /* istanbul ignore next */ []));
274
+ this.headers = computed(() => {
275
+ const raw = this.raw();
276
+ const width = Math.max(0, ...raw.map((r) => r.length));
277
+ const first = raw[0] ?? [];
278
+ return Array.from({ length: width }, (_, i) => (this.hasHeader() ? String(first[i] ?? '').trim() || this.columnName(i) : this.columnName(i)));
279
+ }, /* @ts-ignore */
280
+ ...(ngDevMode ? [{ debugName: "headers" }] : /* istanbul ignore next */ []));
281
+ this.dataRows = computed(() => (this.hasHeader() ? this.raw().slice(1) : this.raw()), /* @ts-ignore */
282
+ ...(ngDevMode ? [{ debugName: "dataRows" }] : /* istanbul ignore next */ []));
283
+ this.sheetOptions = computed(() => this.sheets().map((s, i) => ({ label: s.name, value: i })), /* @ts-ignore */
284
+ ...(ngDevMode ? [{ debugName: "sheetOptions" }] : /* istanbul ignore next */ []));
285
+ this.columnOptions = computed(() => [{ label: this.t().importUnmapped, value: -1 }, ...this.headers().map((h, i) => ({ label: h, value: i }))], /* @ts-ignore */
286
+ ...(ngDevMode ? [{ debugName: "columnOptions" }] : /* istanbul ignore next */ []));
287
+ this.missing = computed(() => this.fields().filter((f) => f.required && this.mapping()[f.key] == null).map((f) => f.label), /* @ts-ignore */
288
+ ...(ngDevMode ? [{ debugName: "missing" }] : /* istanbul ignore next */ []));
289
+ this.texts = computed(() => {
290
+ const t = this.t();
291
+ return { required: t.importErrRequired, number: t.importErrNumber, date: t.importErrDate, boolean: t.importErrBoolean };
292
+ }, /* @ts-ignore */
293
+ ...(ngDevMode ? [{ debugName: "texts" }] : /* istanbul ignore next */ []));
294
+ this.converted = computed(() => convertRows(this.dataRows(), this.mapping(), this.fields(), this.texts()), /* @ts-ignore */
295
+ ...(ngDevMode ? [{ debugName: "converted" }] : /* istanbul ignore next */ []));
296
+ this.invalidRows = computed(() => new Set(this.converted().errors.map((e) => e.row)), /* @ts-ignore */
297
+ ...(ngDevMode ? [{ debugName: "invalidRows" }] : /* istanbul ignore next */ []));
298
+ this.validCount = computed(() => this.converted().rows.length - this.invalidRows().size, /* @ts-ignore */
299
+ ...(ngDevMode ? [{ debugName: "validCount" }] : /* istanbul ignore next */ []));
300
+ this.errorIndex = computed(() => {
301
+ const map = new Map();
302
+ for (const e of this.converted().errors)
303
+ map.set(`${e.row}|${e.field}`, e.message);
304
+ return map;
305
+ }, /* @ts-ignore */
306
+ ...(ngDevMode ? [{ debugName: "errorIndex" }] : /* istanbul ignore next */ []));
307
+ this.previewRows = computed(() => this.converted().rows.map((r, i) => {
308
+ const out = { __row: i + 1 };
309
+ for (const f of this.fields()) {
310
+ const v = r[f.key];
311
+ out[f.key] = v instanceof Date ? `${v.getFullYear()}-${String(v.getMonth() + 1).padStart(2, '0')}-${String(v.getDate()).padStart(2, '0')}` : v;
312
+ }
313
+ return out;
314
+ }), /* @ts-ignore */
315
+ ...(ngDevMode ? [{ debugName: "previewRows" }] : /* istanbul ignore next */ []));
316
+ this.previewColumns = computed(() => this.fields().map((f) => ({
317
+ field: f.key,
318
+ header: f.label,
319
+ type: f.type === 'number' ? 'number' : f.type === 'date' ? 'date' : f.type === 'boolean' ? 'checkbox' : 'text',
320
+ decimals: f.type === 'number' ? 2 : undefined,
321
+ sortable: false,
322
+ // Los errores vienen de la conversión (el valor original se muestra tal cual).
323
+ format: (value, row) => (this.errorIndex().has(`${row['__row']}|${f.key}`) ? String(value ?? '') : this.plain(value, f)),
324
+ validate: (_, row) => this.errorIndex().get(`${row['__row']}|${f.key}`) ?? null,
325
+ })), /* @ts-ignore */
326
+ ...(ngDevMode ? [{ debugName: "previewColumns" }] : /* istanbul ignore next */ []));
327
+ this.importable = computed(() => (this.onlyValid() && !this.allowInvalid() ? this.validCount() : this.converted().rows.length), /* @ts-ignore */
328
+ ...(ngDevMode ? [{ debugName: "importable" }] : /* istanbul ignore next */ []));
329
+ }
330
+ stepLabel(step) {
331
+ const t = this.t();
332
+ return step === 'file' ? t.importStepFile : step === 'map' ? t.importStepMap : t.importStepReview;
333
+ }
334
+ columnName(i) {
335
+ let n = i + 1;
336
+ let s = '';
337
+ while (n > 0) {
338
+ s = String.fromCharCode(65 + ((n - 1) % 26)) + s;
339
+ n = Math.floor((n - 1) / 26);
340
+ }
341
+ return cbFormat(this.t().importColumnN, s);
342
+ }
343
+ example(key) {
344
+ const col = this.mapping()[key];
345
+ if (col == null)
346
+ return '';
347
+ const v = this.dataRows().find((r) => r[col] !== null && r[col] !== '')?.[col];
348
+ if (v == null)
349
+ return '';
350
+ // El ejemplo se muestra ya interpretado (una fecha de Excel llega como número de serie).
351
+ const field = this.fields().find((f) => f.key === key);
352
+ if (field?.type === 'date') {
353
+ const d = parseDate(v);
354
+ if (d)
355
+ return new Intl.DateTimeFormat(this.t().intlLocale, { dateStyle: 'medium' }).format(d);
356
+ }
357
+ return String(v);
358
+ }
359
+ plain(value, f) {
360
+ if (value === null || value === undefined)
361
+ return '';
362
+ if (f.type === 'number' && typeof value === 'number')
363
+ return new Intl.NumberFormat(this.t().intlLocale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(value);
364
+ if (f.type === 'date' && typeof value === 'string') {
365
+ const [y, m, d] = value.split('-').map(Number);
366
+ return new Intl.DateTimeFormat(this.t().intlLocale, { dateStyle: 'medium' }).format(new Date(y, m - 1, d));
367
+ }
368
+ if (f.type === 'boolean')
369
+ return value ? this.t().yes : this.t().no;
370
+ return String(value);
371
+ }
372
+ // --- Archivo -----------------------------------------------------------------------------
373
+ onDrop(event) {
374
+ event.preventDefault();
375
+ this.dragging.set(false);
376
+ const file = event.dataTransfer?.files?.[0];
377
+ if (file)
378
+ void this.load(file);
379
+ }
380
+ onFile(event) {
381
+ const file = event.target.files?.[0];
382
+ if (file)
383
+ void this.load(file);
384
+ }
385
+ onPaste(event) {
386
+ const text = event.target.value;
387
+ this.fileName.set('');
388
+ this.sheets.set([]);
389
+ this.loadText(text);
390
+ }
391
+ /** Carga un archivo (.xlsx, .csv, .tsv, .txt). */
392
+ async load(file) {
393
+ this.error.set('');
394
+ this.fileName.set(file.name);
395
+ try {
396
+ if (/\.xlsx$/i.test(file.name) || file.type.includes('spreadsheetml')) {
397
+ const sheets = await cbReadXlsx(file);
398
+ if (!sheets.length)
399
+ throw new Error();
400
+ this.sheets.set(sheets);
401
+ this.sheetIndex.set(0);
402
+ this.text.set([]);
403
+ }
404
+ else {
405
+ this.sheets.set([]);
406
+ this.loadText(await file.text());
407
+ }
408
+ this.remap();
409
+ }
410
+ catch {
411
+ this.error.set(this.t().importErrFile);
412
+ }
413
+ }
414
+ /** Carga texto delimitado (CSV, TSV o lo pegado de una hoja de cálculo). */
415
+ loadText(text) {
416
+ this.text.set(parseDelimited(text));
417
+ this.remap();
418
+ }
419
+ setHeader(value) {
420
+ this.hasHeader.set(value);
421
+ this.remap();
422
+ }
423
+ setMapping(key, column) {
424
+ this.mapping.update((m) => ({ ...m, [key]: column < 0 ? null : column }));
425
+ }
426
+ remap() {
427
+ this.mapping.set(this.hasHeader() ? autoMap(this.headers(), this.fields()) : Object.fromEntries(this.fields().map((f) => [f.key, null])));
428
+ }
429
+ // --- Pasos -------------------------------------------------------------------------------
430
+ canNext() {
431
+ return this.step() === 'file' ? this.dataRows().length > 0 : this.missing().length === 0;
432
+ }
433
+ next() {
434
+ if (!this.canNext())
435
+ return;
436
+ this.step.set(this.step() === 'file' ? 'map' : 'review');
437
+ this.focusHeading();
438
+ }
439
+ back() {
440
+ this.step.set(this.step() === 'review' ? 'map' : 'file');
441
+ this.focusHeading();
442
+ }
443
+ finish() {
444
+ const only = this.onlyValid() && !this.allowInvalid();
445
+ const { rows, errors } = this.converted();
446
+ const invalid = this.invalidRows();
447
+ const kept = only ? rows.filter((_, i) => !invalid.has(i + 1)) : rows;
448
+ this.import.emit({ rows: kept, errors, skipped: rows.length - kept.length });
449
+ }
450
+ /** Vuelve al primer paso sin datos. */
451
+ reset() {
452
+ this.step.set('file');
453
+ this.text.set([]);
454
+ this.sheets.set([]);
455
+ this.fileName.set('');
456
+ this.error.set('');
457
+ this.mapping.set({});
458
+ }
459
+ focusHeading() {
460
+ queueMicrotask(() => document.getElementById(`${this.uid}-heading`)?.focus());
461
+ }
462
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbImportWizard, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
463
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbImportWizard, isStandalone: true, selector: "cb-import-wizard", inputs: { fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null }, allowInvalid: { classPropertyName: "allowInvalid", publicName: "allowInvalid", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { import: "import" }, host: { classAttribute: "cb-import-wizard" }, ngImport: i0, template: `
464
+ <ol class="cb-iw__steps">
465
+ @for (s of steps; track s; let i = $index) {
466
+ <li class="cb-iw__step" [class.cb-is-done]="stepIndex() > i" [attr.aria-current]="step() === s ? 'step' : null">
467
+ <span class="cb-iw__step-num" aria-hidden="true">
468
+ @if (stepIndex() > i) {
469
+ <cb-icon name="check" [size]="13" />
470
+ } @else {
471
+ {{ i + 1 }}
472
+ }
473
+ </span>
474
+ {{ stepLabel(s) }}
475
+ </li>
476
+ }
477
+ </ol>
478
+
479
+ <section class="cb-iw__panel" [attr.aria-labelledby]="uid + '-heading'">
480
+ <h3 class="cb-iw__heading" [id]="uid + '-heading'" tabindex="-1">{{ stepLabel(step()) }}</h3>
481
+
482
+ @switch (step()) {
483
+ @case ('file') {
484
+ <div
485
+ class="cb-iw__drop"
486
+ [class.cb-is-over]="dragging()"
487
+ (dragover)="$event.preventDefault(); dragging.set(true)"
488
+ (dragleave)="dragging.set(false)"
489
+ (drop)="onDrop($event)"
490
+ >
491
+ <cb-icon name="upload" [size]="28" aria-hidden="true" />
492
+ <p>{{ t().importDrop }}</p>
493
+ <label class="cb-iw__file">
494
+ <input type="file" [attr.accept]="accept" (change)="onFile($event)" />
495
+ <span>{{ t().importChoose }}</span>
496
+ </label>
497
+ @if (fileName()) {
498
+ <p class="cb-iw__file-name">{{ fileName() }}</p>
499
+ }
500
+ </div>
501
+ <details class="cb-iw__paste" [open]="pasteOpen()">
502
+ <summary (click)="$event.preventDefault(); pasteOpen.set(!pasteOpen())">{{ t().importPaste }}</summary>
503
+ <textarea class="cb-iw__textarea" rows="5" [attr.aria-label]="t().importPaste" [placeholder]="t().importPasteHint" (input)="onPaste($event)"></textarea>
504
+ </details>
505
+ @if (sheets().length > 1) {
506
+ <div class="cb-iw__row">
507
+ <span class="cb-iw__label" [id]="uid + '-sheet'">{{ t().importSheet }}</span>
508
+ <cb-select [ariaLabelledBy]="uid + '-sheet'" [options]="sheetOptions()" optionValue="value" [value]="sheetIndex()" (valueChange)="sheetIndex.set($any($event))" />
509
+ </div>
510
+ }
511
+ @if (error()) {
512
+ <p class="cb-iw__error" role="alert">{{ error() }}</p>
513
+ }
514
+ @if (raw().length) {
515
+ <cb-checkbox [label]="t().importHeader" [ngModel]="hasHeader()" (ngModelChange)="setHeader($event)" />
516
+ <p class="cb-iw__info">{{ fmt(t().importRowsRead, dataRows().length, headers().length) }}</p>
517
+ <div class="cb-iw__sample-wrap">
518
+ <table class="cb-iw__sample" [attr.aria-label]="t().importSample">
519
+ <thead>
520
+ <tr>
521
+ @for (h of headers(); track $index) {
522
+ <th scope="col">{{ h }}</th>
523
+ }
524
+ </tr>
525
+ </thead>
526
+ <tbody>
527
+ @for (r of dataRows().slice(0, 5); track $index) {
528
+ <tr>
529
+ @for (h of headers(); track $index; let c = $index) {
530
+ <td>{{ r[c] }}</td>
531
+ }
532
+ </tr>
533
+ }
534
+ </tbody>
535
+ </table>
536
+ </div>
537
+ }
538
+ }
539
+ @case ('map') {
540
+ <p class="cb-iw__info">{{ t().importMapHint }}</p>
541
+ <table class="cb-iw__map">
542
+ <thead>
543
+ <tr>
544
+ <th scope="col">{{ t().importField }}</th>
545
+ <th scope="col">{{ t().importColumn }}</th>
546
+ <th scope="col">{{ t().importExample }}</th>
547
+ </tr>
548
+ </thead>
549
+ <tbody>
550
+ @for (f of fields(); track f.key) {
551
+ <tr>
552
+ <th scope="row" [id]="uid + '-f-' + f.key">
553
+ {{ f.label }}
554
+ @if (f.required) {
555
+ <span class="cb-iw__req" aria-hidden="true">*</span>
556
+ <span class="cb-iw__sr">({{ t().required }})</span>
557
+ }
558
+ </th>
559
+ <td>
560
+ <cb-select [ariaLabelledBy]="uid + '-f-' + f.key" [options]="columnOptions()" optionValue="value" [value]="mapping()[f.key] ?? -1" (valueChange)="setMapping(f.key, $any($event))" [invalid]="!!f.required && mapping()[f.key] == null" />
561
+ </td>
562
+ <td class="cb-iw__example">{{ example(f.key) }}</td>
563
+ </tr>
564
+ }
565
+ </tbody>
566
+ </table>
567
+ @if (missing().length) {
568
+ <p class="cb-iw__error" role="alert">{{ fmt(t().importMissing, missing().join(', ')) }}</p>
569
+ }
570
+ }
571
+ @case ('review') {
572
+ <div class="cb-iw__summary" role="status">
573
+ <span class="cb-iw__badge cb-iw__badge--ok"><cb-icon name="check" [size]="14" aria-hidden="true" /> {{ fmt(t().importValid, validCount()) }}</span>
574
+ @if (invalidRows().size) {
575
+ <span class="cb-iw__badge cb-iw__badge--bad"><cb-icon name="circle-alert" [size]="14" aria-hidden="true" /> {{ fmt(t().importInvalid, invalidRows().size) }}</span>
576
+ }
577
+ </div>
578
+ @if (invalidRows().size) {
579
+ <cb-checkbox [label]="t().importOnlyValid" [ngModel]="onlyValid()" (ngModelChange)="onlyValid.set($event)" />
580
+ }
581
+ <cb-data-grid [rows]="previewRows()" [columns]="previewColumns()" dataKey="__row" [editable]="false" [toolbar]="false" scrollHeight="20rem" [ariaLabel]="t().importPreview" />
582
+ }
583
+ }
584
+ </section>
585
+
586
+ <div class="cb-iw__actions">
587
+ @if (step() !== 'file') {
588
+ <cb-button variant="text" severity="secondary" (click)="back()">{{ t().importBack }}</cb-button>
589
+ }
590
+ <span class="cb-iw__spacer"></span>
591
+ @if (step() !== 'review') {
592
+ <cb-button [disabled]="!canNext()" (click)="next()">{{ t().importNext }}</cb-button>
593
+ } @else {
594
+ <cb-button [disabled]="!importable()" (click)="finish()">{{ fmt(t().importDo, importable()) }}</cb-button>
595
+ }
596
+ </div>
597
+ `, isInline: true, styles: [":host{display:grid;gap:var(--cb-space-4, 1rem);width:100%;min-width:0;color:var(--cb-color-text);font-family:var(--cb-font-sans);font-size:var(--cb-text-sm, .875rem)}.cb-iw__steps{display:flex;flex-wrap:wrap;gap:.5rem 1.5rem;margin:0;padding:0;list-style:none}.cb-iw__step{display:inline-flex;align-items:center;gap:.5rem;color:var(--cb-color-text-muted)}.cb-iw__step-num{display:inline-flex;align-items:center;justify-content:center;width:1.6rem;height:1.6rem;border:1.5px solid var(--cb-color-border-strong);border-radius:999px;font-size:var(--cb-text-xs, .75rem);font-weight:var(--cb-font-weight-semibold, 600)}.cb-iw__step[aria-current=step]{color:var(--cb-color-text);font-weight:var(--cb-font-weight-semibold, 600)}.cb-iw__step[aria-current=step] .cb-iw__step-num{border-color:var(--cb-color-primary-500);background:var(--cb-color-primary-500);color:var(--cb-color-primary-contrast, #fff)}.cb-iw__step.cb-is-done .cb-iw__step-num{border-color:var(--cb-color-success-500, #10b981);color:var(--cb-color-success-text, #059669)}.cb-iw__panel{display:grid;gap:var(--cb-space-3, .75rem);min-width:0}.cb-iw__heading{margin:0;font-size:var(--cb-text-base, 1rem);font-weight:var(--cb-font-weight-semibold, 600);outline:none}.cb-iw__drop{display:grid;justify-items:center;gap:.4rem;padding:1.5rem 1rem;border:2px dashed var(--cb-color-border-strong);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-subtle);color:var(--cb-color-text-muted);text-align:center}.cb-iw__drop.cb-is-over{border-color:var(--cb-color-primary-500);background:color-mix(in srgb,var(--cb-color-primary-500) 8%,transparent)}.cb-iw__drop p{margin:0}.cb-iw__file input{position:absolute;width:1px;height:1px;opacity:0}.cb-iw__file span{display:inline-flex;align-items:center;height:2rem;padding:0 .85rem;border:1px solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background:var(--cb-color-bg);color:var(--cb-color-text);cursor:pointer}.cb-iw__file:focus-within span{outline:2px solid var(--cb-color-focus-ring);outline-offset:2px}.cb-iw__file-name{color:var(--cb-color-text);font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__paste summary{cursor:pointer;color:var(--cb-color-primary-text, var(--cb-color-primary-700))}.cb-iw__textarea{box-sizing:border-box;width:100%;margin-top:.5rem;padding:.5rem .65rem;border:1px solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background:var(--cb-color-bg);color:var(--cb-color-text);font-family:var(--cb-font-mono, monospace);font-size:var(--cb-text-xs, .75rem)}.cb-iw__row{display:grid;gap:.25rem;max-width:20rem}.cb-iw__label{font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__info{margin:0;color:var(--cb-color-text-muted)}.cb-iw__error{margin:0;color:var(--cb-color-danger-text, #dc2626)}.cb-iw__sample-wrap{overflow-x:auto;border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-md)}.cb-iw__sample,.cb-iw__map{width:100%;border-collapse:collapse}.cb-iw__sample th,.cb-iw__sample td,.cb-iw__map th,.cb-iw__map td{padding:.4rem .6rem;border-bottom:1px solid var(--cb-color-border);text-align:start;white-space:nowrap}.cb-iw__sample thead th,.cb-iw__map thead th{background:var(--cb-color-surface-subtle);color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem);font-weight:var(--cb-font-weight-semibold, 600)}.cb-iw__map tbody th{font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__map td:nth-child(2){width:16rem}.cb-iw__example{max-width:14rem;overflow:hidden;color:var(--cb-color-text-muted);text-overflow:ellipsis}.cb-iw__req{margin-left:.15rem;color:var(--cb-color-danger-500, #ef4444)}.cb-iw__summary{display:flex;flex-wrap:wrap;gap:.5rem}.cb-iw__badge{display:inline-flex;align-items:center;gap:.35rem;padding:.25rem .7rem;border-radius:999px;font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__badge--ok{background:color-mix(in srgb,var(--cb-color-success-500, #10b981) 12%,transparent);color:var(--cb-color-success-text, #047857)}.cb-iw__badge--bad{background:color-mix(in srgb,var(--cb-color-danger-500, #ef4444) 10%,transparent);color:var(--cb-color-danger-text, #b91c1c)}.cb-iw__actions{display:flex;align-items:center;gap:.5rem}.cb-iw__spacer{flex:1}.cb-iw__sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: CbButton, selector: "cb-button", inputs: ["severity", "variant", "size", "disabled", "loading", "fullWidth", "type", "ariaLabel", "ariaHaspopup", "ariaExpanded", "ariaControls"] }, { kind: "component", type: CbCheckbox, selector: "cb-checkbox", inputs: ["label", "ariaLabel", "size", "value", "indeterminate", "invalid", "required", "requiredIndicator", "disabled", "inputId"], outputs: ["changed"] }, { kind: "component", type: CbDataGrid, selector: "cb-data-grid", inputs: ["rows", "columns", "dataKey", "editable", "rowNumbers", "toolbar", "scrollHeight", "newRow", "emptyMessage", "ariaLabel", "currency", "negativeStyle"], outputs: ["rowsChange", "cellChange", "rowAdd", "rowsDelete"] }, { kind: "component", type: CbIcon, selector: "cb-icon", inputs: ["name", "size", "spin", "ariaLabel"] }, { kind: "component", type: CbSelect, selector: "cb-select", inputs: ["options", "optionLabel", "optionValue", "optionDisabled", "group", "optionGroupLabel", "optionGroupChildren", "placeholder", "size", "filter", "filterPlaceholder", "emptyMessage", "showClear", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "invalid", "disabled", "inputId", "ariaLabel", "ariaLabelledBy", "value"], outputs: ["valueChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
598
+ }
599
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbImportWizard, decorators: [{
600
+ type: Component,
601
+ args: [{ selector: 'cb-import-wizard', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [FormsModule, CbButton, CbCheckbox, CbDataGrid, CbIcon, CbSelect], host: { class: 'cb-import-wizard' }, template: `
602
+ <ol class="cb-iw__steps">
603
+ @for (s of steps; track s; let i = $index) {
604
+ <li class="cb-iw__step" [class.cb-is-done]="stepIndex() > i" [attr.aria-current]="step() === s ? 'step' : null">
605
+ <span class="cb-iw__step-num" aria-hidden="true">
606
+ @if (stepIndex() > i) {
607
+ <cb-icon name="check" [size]="13" />
608
+ } @else {
609
+ {{ i + 1 }}
610
+ }
611
+ </span>
612
+ {{ stepLabel(s) }}
613
+ </li>
614
+ }
615
+ </ol>
616
+
617
+ <section class="cb-iw__panel" [attr.aria-labelledby]="uid + '-heading'">
618
+ <h3 class="cb-iw__heading" [id]="uid + '-heading'" tabindex="-1">{{ stepLabel(step()) }}</h3>
619
+
620
+ @switch (step()) {
621
+ @case ('file') {
622
+ <div
623
+ class="cb-iw__drop"
624
+ [class.cb-is-over]="dragging()"
625
+ (dragover)="$event.preventDefault(); dragging.set(true)"
626
+ (dragleave)="dragging.set(false)"
627
+ (drop)="onDrop($event)"
628
+ >
629
+ <cb-icon name="upload" [size]="28" aria-hidden="true" />
630
+ <p>{{ t().importDrop }}</p>
631
+ <label class="cb-iw__file">
632
+ <input type="file" [attr.accept]="accept" (change)="onFile($event)" />
633
+ <span>{{ t().importChoose }}</span>
634
+ </label>
635
+ @if (fileName()) {
636
+ <p class="cb-iw__file-name">{{ fileName() }}</p>
637
+ }
638
+ </div>
639
+ <details class="cb-iw__paste" [open]="pasteOpen()">
640
+ <summary (click)="$event.preventDefault(); pasteOpen.set(!pasteOpen())">{{ t().importPaste }}</summary>
641
+ <textarea class="cb-iw__textarea" rows="5" [attr.aria-label]="t().importPaste" [placeholder]="t().importPasteHint" (input)="onPaste($event)"></textarea>
642
+ </details>
643
+ @if (sheets().length > 1) {
644
+ <div class="cb-iw__row">
645
+ <span class="cb-iw__label" [id]="uid + '-sheet'">{{ t().importSheet }}</span>
646
+ <cb-select [ariaLabelledBy]="uid + '-sheet'" [options]="sheetOptions()" optionValue="value" [value]="sheetIndex()" (valueChange)="sheetIndex.set($any($event))" />
647
+ </div>
648
+ }
649
+ @if (error()) {
650
+ <p class="cb-iw__error" role="alert">{{ error() }}</p>
651
+ }
652
+ @if (raw().length) {
653
+ <cb-checkbox [label]="t().importHeader" [ngModel]="hasHeader()" (ngModelChange)="setHeader($event)" />
654
+ <p class="cb-iw__info">{{ fmt(t().importRowsRead, dataRows().length, headers().length) }}</p>
655
+ <div class="cb-iw__sample-wrap">
656
+ <table class="cb-iw__sample" [attr.aria-label]="t().importSample">
657
+ <thead>
658
+ <tr>
659
+ @for (h of headers(); track $index) {
660
+ <th scope="col">{{ h }}</th>
661
+ }
662
+ </tr>
663
+ </thead>
664
+ <tbody>
665
+ @for (r of dataRows().slice(0, 5); track $index) {
666
+ <tr>
667
+ @for (h of headers(); track $index; let c = $index) {
668
+ <td>{{ r[c] }}</td>
669
+ }
670
+ </tr>
671
+ }
672
+ </tbody>
673
+ </table>
674
+ </div>
675
+ }
676
+ }
677
+ @case ('map') {
678
+ <p class="cb-iw__info">{{ t().importMapHint }}</p>
679
+ <table class="cb-iw__map">
680
+ <thead>
681
+ <tr>
682
+ <th scope="col">{{ t().importField }}</th>
683
+ <th scope="col">{{ t().importColumn }}</th>
684
+ <th scope="col">{{ t().importExample }}</th>
685
+ </tr>
686
+ </thead>
687
+ <tbody>
688
+ @for (f of fields(); track f.key) {
689
+ <tr>
690
+ <th scope="row" [id]="uid + '-f-' + f.key">
691
+ {{ f.label }}
692
+ @if (f.required) {
693
+ <span class="cb-iw__req" aria-hidden="true">*</span>
694
+ <span class="cb-iw__sr">({{ t().required }})</span>
695
+ }
696
+ </th>
697
+ <td>
698
+ <cb-select [ariaLabelledBy]="uid + '-f-' + f.key" [options]="columnOptions()" optionValue="value" [value]="mapping()[f.key] ?? -1" (valueChange)="setMapping(f.key, $any($event))" [invalid]="!!f.required && mapping()[f.key] == null" />
699
+ </td>
700
+ <td class="cb-iw__example">{{ example(f.key) }}</td>
701
+ </tr>
702
+ }
703
+ </tbody>
704
+ </table>
705
+ @if (missing().length) {
706
+ <p class="cb-iw__error" role="alert">{{ fmt(t().importMissing, missing().join(', ')) }}</p>
707
+ }
708
+ }
709
+ @case ('review') {
710
+ <div class="cb-iw__summary" role="status">
711
+ <span class="cb-iw__badge cb-iw__badge--ok"><cb-icon name="check" [size]="14" aria-hidden="true" /> {{ fmt(t().importValid, validCount()) }}</span>
712
+ @if (invalidRows().size) {
713
+ <span class="cb-iw__badge cb-iw__badge--bad"><cb-icon name="circle-alert" [size]="14" aria-hidden="true" /> {{ fmt(t().importInvalid, invalidRows().size) }}</span>
714
+ }
715
+ </div>
716
+ @if (invalidRows().size) {
717
+ <cb-checkbox [label]="t().importOnlyValid" [ngModel]="onlyValid()" (ngModelChange)="onlyValid.set($event)" />
718
+ }
719
+ <cb-data-grid [rows]="previewRows()" [columns]="previewColumns()" dataKey="__row" [editable]="false" [toolbar]="false" scrollHeight="20rem" [ariaLabel]="t().importPreview" />
720
+ }
721
+ }
722
+ </section>
723
+
724
+ <div class="cb-iw__actions">
725
+ @if (step() !== 'file') {
726
+ <cb-button variant="text" severity="secondary" (click)="back()">{{ t().importBack }}</cb-button>
727
+ }
728
+ <span class="cb-iw__spacer"></span>
729
+ @if (step() !== 'review') {
730
+ <cb-button [disabled]="!canNext()" (click)="next()">{{ t().importNext }}</cb-button>
731
+ } @else {
732
+ <cb-button [disabled]="!importable()" (click)="finish()">{{ fmt(t().importDo, importable()) }}</cb-button>
733
+ }
734
+ </div>
735
+ `, styles: [":host{display:grid;gap:var(--cb-space-4, 1rem);width:100%;min-width:0;color:var(--cb-color-text);font-family:var(--cb-font-sans);font-size:var(--cb-text-sm, .875rem)}.cb-iw__steps{display:flex;flex-wrap:wrap;gap:.5rem 1.5rem;margin:0;padding:0;list-style:none}.cb-iw__step{display:inline-flex;align-items:center;gap:.5rem;color:var(--cb-color-text-muted)}.cb-iw__step-num{display:inline-flex;align-items:center;justify-content:center;width:1.6rem;height:1.6rem;border:1.5px solid var(--cb-color-border-strong);border-radius:999px;font-size:var(--cb-text-xs, .75rem);font-weight:var(--cb-font-weight-semibold, 600)}.cb-iw__step[aria-current=step]{color:var(--cb-color-text);font-weight:var(--cb-font-weight-semibold, 600)}.cb-iw__step[aria-current=step] .cb-iw__step-num{border-color:var(--cb-color-primary-500);background:var(--cb-color-primary-500);color:var(--cb-color-primary-contrast, #fff)}.cb-iw__step.cb-is-done .cb-iw__step-num{border-color:var(--cb-color-success-500, #10b981);color:var(--cb-color-success-text, #059669)}.cb-iw__panel{display:grid;gap:var(--cb-space-3, .75rem);min-width:0}.cb-iw__heading{margin:0;font-size:var(--cb-text-base, 1rem);font-weight:var(--cb-font-weight-semibold, 600);outline:none}.cb-iw__drop{display:grid;justify-items:center;gap:.4rem;padding:1.5rem 1rem;border:2px dashed var(--cb-color-border-strong);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-subtle);color:var(--cb-color-text-muted);text-align:center}.cb-iw__drop.cb-is-over{border-color:var(--cb-color-primary-500);background:color-mix(in srgb,var(--cb-color-primary-500) 8%,transparent)}.cb-iw__drop p{margin:0}.cb-iw__file input{position:absolute;width:1px;height:1px;opacity:0}.cb-iw__file span{display:inline-flex;align-items:center;height:2rem;padding:0 .85rem;border:1px solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background:var(--cb-color-bg);color:var(--cb-color-text);cursor:pointer}.cb-iw__file:focus-within span{outline:2px solid var(--cb-color-focus-ring);outline-offset:2px}.cb-iw__file-name{color:var(--cb-color-text);font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__paste summary{cursor:pointer;color:var(--cb-color-primary-text, var(--cb-color-primary-700))}.cb-iw__textarea{box-sizing:border-box;width:100%;margin-top:.5rem;padding:.5rem .65rem;border:1px solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background:var(--cb-color-bg);color:var(--cb-color-text);font-family:var(--cb-font-mono, monospace);font-size:var(--cb-text-xs, .75rem)}.cb-iw__row{display:grid;gap:.25rem;max-width:20rem}.cb-iw__label{font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__info{margin:0;color:var(--cb-color-text-muted)}.cb-iw__error{margin:0;color:var(--cb-color-danger-text, #dc2626)}.cb-iw__sample-wrap{overflow-x:auto;border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-md)}.cb-iw__sample,.cb-iw__map{width:100%;border-collapse:collapse}.cb-iw__sample th,.cb-iw__sample td,.cb-iw__map th,.cb-iw__map td{padding:.4rem .6rem;border-bottom:1px solid var(--cb-color-border);text-align:start;white-space:nowrap}.cb-iw__sample thead th,.cb-iw__map thead th{background:var(--cb-color-surface-subtle);color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem);font-weight:var(--cb-font-weight-semibold, 600)}.cb-iw__map tbody th{font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__map td:nth-child(2){width:16rem}.cb-iw__example{max-width:14rem;overflow:hidden;color:var(--cb-color-text-muted);text-overflow:ellipsis}.cb-iw__req{margin-left:.15rem;color:var(--cb-color-danger-500, #ef4444)}.cb-iw__summary{display:flex;flex-wrap:wrap;gap:.5rem}.cb-iw__badge{display:inline-flex;align-items:center;gap:.35rem;padding:.25rem .7rem;border-radius:999px;font-weight:var(--cb-font-weight-medium, 500)}.cb-iw__badge--ok{background:color-mix(in srgb,var(--cb-color-success-500, #10b981) 12%,transparent);color:var(--cb-color-success-text, #047857)}.cb-iw__badge--bad{background:color-mix(in srgb,var(--cb-color-danger-500, #ef4444) 10%,transparent);color:var(--cb-color-danger-text, #b91c1c)}.cb-iw__actions{display:flex;align-items:center;gap:.5rem}.cb-iw__spacer{flex:1}.cb-iw__sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"] }]
736
+ }], propDecorators: { fields: [{ type: i0.Input, args: [{ isSignal: true, alias: "fields", required: false }] }], allowInvalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowInvalid", required: false }] }], import: [{ type: i0.Output, args: ["import"] }] } });
737
+
738
+ /*
739
+ * Public API Surface de @caribeng/ui/import-wizard
740
+ */
741
+
742
+ /**
743
+ * Generated bundle index. Do not edit.
744
+ */
745
+
746
+ export { CbImportWizard, autoMap, convertRows, detectDelimiter, parseAmount, parseBoolean, parseDate, parseDelimited };