@caribeng/ui 22.1.1 → 22.4.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.
- package/README.md +134 -12
- package/fesm2022/caribeng-ui-accordion.mjs +4 -4
- package/fesm2022/caribeng-ui-anchor.mjs +169 -0
- package/fesm2022/caribeng-ui-autocomplete.mjs +10 -8
- package/fesm2022/caribeng-ui-avatar.mjs +2 -2
- package/fesm2022/caribeng-ui-avatargroup.mjs +9 -3
- package/fesm2022/caribeng-ui-badge.mjs +8 -2
- package/fesm2022/caribeng-ui-blockui.mjs +12 -4
- package/fesm2022/caribeng-ui-breadcrumb.mjs +17 -7
- package/fesm2022/caribeng-ui-button.mjs +22 -2
- package/fesm2022/caribeng-ui-caribe-alert.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-animation-lottie.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-button-group.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-calendar.mjs +11 -6
- package/fesm2022/caribeng-ui-caribe-card-content.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-card-move.mjs +29 -7
- package/fesm2022/caribeng-ui-caribe-card-select.mjs +56 -14
- package/fesm2022/caribeng-ui-caribe-circle-loading.mjs +10 -7
- package/fesm2022/caribeng-ui-caribe-coachmark.mjs +42 -19
- package/fesm2022/caribeng-ui-caribe-data-table.mjs +15 -9
- package/fesm2022/caribeng-ui-caribe-dots-indicator.mjs +38 -5
- package/fesm2022/caribeng-ui-caribe-expansion-panel.mjs +16 -5
- package/fesm2022/caribeng-ui-caribe-fab-menu.mjs +56 -7
- package/fesm2022/caribeng-ui-caribe-file-download.mjs +68 -27
- package/fesm2022/caribeng-ui-caribe-file-select.mjs +22 -17
- package/fesm2022/caribeng-ui-caribe-float-menu.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-footer.mjs +8 -4
- package/fesm2022/caribeng-ui-caribe-header.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-icon-button.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-illustration.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-inline-alert.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-input-search.mjs +14 -10
- package/fesm2022/caribeng-ui-caribe-input-select.mjs +12 -10
- package/fesm2022/caribeng-ui-caribe-input-token.mjs +61 -11
- package/fesm2022/caribeng-ui-caribe-link.mjs +7 -2
- package/fesm2022/caribeng-ui-caribe-loader.mjs +8 -5
- package/fesm2022/caribeng-ui-caribe-modal.mjs +32 -16
- package/fesm2022/caribeng-ui-caribe-off-canvas.mjs +26 -12
- package/fesm2022/caribeng-ui-caribe-onboarding.mjs +44 -19
- package/fesm2022/caribeng-ui-caribe-pictogram.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-pop-over.mjs +34 -10
- package/fesm2022/caribeng-ui-caribe-preloader.mjs +9 -6
- package/fesm2022/caribeng-ui-caribe-progress-bar.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-shortcut.mjs +8 -3
- package/fesm2022/caribeng-ui-caribe-step-indicator.mjs +12 -5
- package/fesm2022/caribeng-ui-caribe-stroke.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-switch.mjs +5 -3
- package/fesm2022/caribeng-ui-caribe-tag-button.mjs +1 -1
- package/fesm2022/caribeng-ui-caribe-tracker.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-transaction-status.mjs +1 -1
- package/fesm2022/caribeng-ui-caribe-voucher.mjs +11 -8
- package/fesm2022/caribeng-ui-carousel.mjs +49 -14
- package/fesm2022/caribeng-ui-cascadeselect.mjs +22 -8
- package/fesm2022/caribeng-ui-chart.mjs +2601 -303
- package/fesm2022/caribeng-ui-chat.mjs +1303 -0
- package/fesm2022/caribeng-ui-chip.mjs +9 -4
- package/fesm2022/caribeng-ui-chips.mjs +9 -5
- package/fesm2022/caribeng-ui-code-block.mjs +332 -0
- package/fesm2022/caribeng-ui-colorpicker.mjs +107 -11
- package/fesm2022/caribeng-ui-command-palette.mjs +476 -0
- package/fesm2022/caribeng-ui-confirmdialog.mjs +140 -10
- package/fesm2022/caribeng-ui-confirmpopup.mjs +209 -9
- package/fesm2022/caribeng-ui-contextmenu.mjs +13 -6
- package/fesm2022/caribeng-ui-copy-button.mjs +230 -0
- package/fesm2022/caribeng-ui-dataview.mjs +214 -6
- package/fesm2022/caribeng-ui-datepicker.mjs +1630 -393
- package/fesm2022/caribeng-ui-descriptions.mjs +124 -0
- package/fesm2022/caribeng-ui-dialog.mjs +10 -7
- package/fesm2022/caribeng-ui-dock.mjs +58 -15
- package/fesm2022/caribeng-ui-drawer.mjs +17 -9
- package/fesm2022/caribeng-ui-dynamicdialog.mjs +210 -6
- package/fesm2022/caribeng-ui-editor.mjs +4413 -243
- package/fesm2022/caribeng-ui-empty.mjs +80 -0
- package/fesm2022/caribeng-ui-fieldset.mjs +2 -2
- package/fesm2022/caribeng-ui-file-card.mjs +136 -19
- package/fesm2022/caribeng-ui-fileupload.mjs +96 -19
- package/fesm2022/caribeng-ui-floatlabel.mjs +4 -2
- package/fesm2022/caribeng-ui-folder-card.mjs +132 -15
- package/fesm2022/caribeng-ui-galleria.mjs +76 -45
- package/fesm2022/caribeng-ui-image.mjs +52 -29
- package/fesm2022/caribeng-ui-inlinemessage.mjs +2 -2
- package/fesm2022/caribeng-ui-inplace.mjs +22 -6
- package/fesm2022/caribeng-ui-input-number.mjs +9 -7
- package/fesm2022/caribeng-ui-inputgroup.mjs +2 -2
- package/fesm2022/caribeng-ui-inputmask.mjs +22 -13
- package/fesm2022/caribeng-ui-inputotp.mjs +12 -6
- package/fesm2022/caribeng-ui-kanban.mjs +4612 -0
- package/fesm2022/caribeng-ui-kbd.mjs +122 -0
- package/fesm2022/caribeng-ui-keyfilter.mjs +72 -0
- package/fesm2022/caribeng-ui-listbox.mjs +13 -11
- package/fesm2022/caribeng-ui-megamenu.mjs +228 -32
- package/fesm2022/caribeng-ui-mentions.mjs +495 -0
- package/fesm2022/caribeng-ui-menu.mjs +18 -8
- package/fesm2022/caribeng-ui-menubar.mjs +17 -8
- package/fesm2022/caribeng-ui-message.mjs +13 -7
- package/fesm2022/caribeng-ui-metergroup.mjs +29 -11
- package/fesm2022/caribeng-ui-multiselect.mjs +399 -97
- package/fesm2022/caribeng-ui-orderlist.mjs +230 -11
- package/fesm2022/caribeng-ui-organizationchart.mjs +16 -15
- package/fesm2022/caribeng-ui-paginator.mjs +18 -15
- package/fesm2022/caribeng-ui-panel.mjs +11 -8
- package/fesm2022/caribeng-ui-panelmenu.mjs +14 -8
- package/fesm2022/caribeng-ui-password.mjs +8 -6
- package/fesm2022/caribeng-ui-pdfviewer.mjs +1553 -0
- package/fesm2022/caribeng-ui-phone-input.mjs +688 -0
- package/fesm2022/caribeng-ui-picklist.mjs +251 -14
- package/fesm2022/caribeng-ui-pricing.mjs +272 -75
- package/fesm2022/caribeng-ui-qrcode.mjs +564 -0
- package/fesm2022/caribeng-ui-rating.mjs +7 -3
- package/fesm2022/caribeng-ui-repeater.mjs +223 -0
- package/fesm2022/caribeng-ui-result.mjs +91 -0
- package/fesm2022/caribeng-ui-ripple.mjs +2 -0
- package/fesm2022/caribeng-ui-scrollpanel.mjs +6 -3
- package/fesm2022/caribeng-ui-scrolltop.mjs +9 -4
- package/fesm2022/caribeng-ui-select.mjs +379 -87
- package/fesm2022/caribeng-ui-selectbutton.mjs +2 -2
- package/fesm2022/caribeng-ui-sidebar.mjs +573 -0
- package/fesm2022/caribeng-ui-slider.mjs +171 -75
- package/fesm2022/caribeng-ui-speeddial.mjs +7 -4
- package/fesm2022/caribeng-ui-spinner.mjs +5 -2
- package/fesm2022/caribeng-ui-splitbutton.mjs +163 -0
- package/fesm2022/caribeng-ui-splitter.mjs +5 -2
- package/fesm2022/caribeng-ui-statistic.mjs +183 -0
- package/fesm2022/caribeng-ui-stepper.mjs +17 -7
- package/fesm2022/caribeng-ui-steps.mjs +6 -3
- package/fesm2022/caribeng-ui-table.mjs +716 -84
- package/fesm2022/caribeng-ui-tabmenu.mjs +13 -6
- package/fesm2022/caribeng-ui-tag.mjs +2 -2
- package/fesm2022/caribeng-ui-terminal.mjs +45 -9
- package/fesm2022/caribeng-ui-themetoggle.mjs +82 -0
- package/fesm2022/caribeng-ui-tieredmenu.mjs +113 -20
- package/fesm2022/caribeng-ui-timeline.mjs +175 -6
- package/fesm2022/caribeng-ui-toast.mjs +7 -4
- package/fesm2022/caribeng-ui-togglebutton.mjs +8 -6
- package/fesm2022/caribeng-ui-toolbar.mjs +6 -3
- package/fesm2022/caribeng-ui-tree.mjs +302 -6
- package/fesm2022/caribeng-ui-treeselect.mjs +26 -10
- package/fesm2022/caribeng-ui-treetable.mjs +269 -6
- package/fesm2022/caribeng-ui-virtualscroller.mjs +123 -10
- package/fesm2022/caribeng-ui.mjs +1216 -6
- package/package.json +93 -3
- package/schematics/collection.json +15 -0
- package/schematics/migrate-from-primeng/core-icons.json +1 -0
- package/schematics/migrate-from-primeng/icons.js +269 -0
- package/schematics/migrate-from-primeng/index.js +290 -0
- package/schematics/migrate-from-primeng/mappings/button.js +93 -0
- package/schematics/migrate-from-primeng/mappings/card.js +33 -0
- package/schematics/migrate-from-primeng/mappings/checkbox.js +44 -0
- package/schematics/migrate-from-primeng/mappings/confirm.js +221 -0
- package/schematics/migrate-from-primeng/mappings/datepicker.js +121 -0
- package/schematics/migrate-from-primeng/mappings/dialog.js +84 -0
- package/schematics/migrate-from-primeng/mappings/index.js +88 -0
- package/schematics/migrate-from-primeng/mappings/inputnumber.js +62 -0
- package/schematics/migrate-from-primeng/mappings/inputtext.js +60 -0
- package/schematics/migrate-from-primeng/mappings/menu.js +468 -0
- package/schematics/migrate-from-primeng/mappings/multiselect.js +49 -0
- package/schematics/migrate-from-primeng/mappings/radiobutton.js +22 -0
- package/schematics/migrate-from-primeng/mappings/rules.js +206 -0
- package/schematics/migrate-from-primeng/mappings/select.js +97 -0
- package/schematics/migrate-from-primeng/mappings/service-calls.js +100 -0
- package/schematics/migrate-from-primeng/mappings/table.js +613 -0
- package/schematics/migrate-from-primeng/mappings/tabs.js +225 -0
- package/schematics/migrate-from-primeng/mappings/tag.js +29 -0
- package/schematics/migrate-from-primeng/mappings/textarea.js +44 -0
- package/schematics/migrate-from-primeng/mappings/toast.js +173 -0
- package/schematics/migrate-from-primeng/mappings/toggleswitch.js +37 -0
- package/schematics/migrate-from-primeng/mappings/tooltip.js +44 -0
- package/schematics/migrate-from-primeng/mappings/types.js +10 -0
- package/schematics/migrate-from-primeng/report.js +79 -0
- package/schematics/migrate-from-primeng/schema.js +2 -0
- package/schematics/migrate-from-primeng/schema.json +34 -0
- package/schematics/migrate-from-primeng/template.js +387 -0
- package/schematics/migrate-from-primeng/todo.js +5 -0
- package/schematics/migrate-from-primeng/typescript.js +442 -0
- package/schematics/migrate-from-primeng/workspace.js +117 -0
- package/schematics/ng-add/index.js +140 -0
- package/schematics/ng-add/schema.js +2 -0
- package/schematics/ng-add/schema.json +66 -0
- package/types/caribeng-ui-anchor.d.ts +50 -0
- package/types/caribeng-ui-autocomplete.d.ts +4 -2
- package/types/caribeng-ui-avatargroup.d.ts +3 -1
- package/types/caribeng-ui-badge.d.ts +3 -1
- package/types/caribeng-ui-blockui.d.ts +9 -4
- package/types/caribeng-ui-breadcrumb.d.ts +11 -0
- package/types/caribeng-ui-button.d.ts +9 -1
- package/types/caribeng-ui-caribe-alert.d.ts +3 -0
- package/types/caribeng-ui-caribe-animation-lottie.d.ts +4 -1
- package/types/caribeng-ui-caribe-button-group.d.ts +4 -1
- package/types/caribeng-ui-caribe-calendar.d.ts +5 -1
- package/types/caribeng-ui-caribe-card-content.d.ts +4 -1
- package/types/caribeng-ui-caribe-card-move.d.ts +13 -13
- package/types/caribeng-ui-caribe-card-select.d.ts +10 -1
- package/types/caribeng-ui-caribe-circle-loading.d.ts +4 -1
- package/types/caribeng-ui-caribe-coachmark.d.ts +6 -0
- package/types/caribeng-ui-caribe-data-table.d.ts +7 -2
- package/types/caribeng-ui-caribe-dots-indicator.d.ts +9 -0
- package/types/caribeng-ui-caribe-expansion-panel.d.ts +7 -10
- package/types/caribeng-ui-caribe-fab-menu.d.ts +10 -1
- package/types/caribeng-ui-caribe-file-download.d.ts +8 -10
- package/types/caribeng-ui-caribe-file-select.d.ts +7 -1
- package/types/caribeng-ui-caribe-float-menu.d.ts +4 -1
- package/types/caribeng-ui-caribe-header.d.ts +3 -0
- package/types/caribeng-ui-caribe-icon-button.d.ts +4 -1
- package/types/caribeng-ui-caribe-illustration.d.ts +4 -1
- package/types/caribeng-ui-caribe-inline-alert.d.ts +3 -0
- package/types/caribeng-ui-caribe-input-search.d.ts +4 -2
- package/types/caribeng-ui-caribe-input-select.d.ts +4 -2
- package/types/caribeng-ui-caribe-input-token.d.ts +16 -1
- package/types/caribeng-ui-caribe-link.d.ts +3 -0
- package/types/caribeng-ui-caribe-loader.d.ts +4 -1
- package/types/caribeng-ui-caribe-modal.d.ts +7 -10
- package/types/caribeng-ui-caribe-off-canvas.d.ts +6 -1
- package/types/caribeng-ui-caribe-onboarding.d.ts +6 -0
- package/types/caribeng-ui-caribe-pictogram.d.ts +4 -1
- package/types/caribeng-ui-caribe-pop-over.d.ts +7 -10
- package/types/caribeng-ui-caribe-preloader.d.ts +4 -1
- package/types/caribeng-ui-caribe-progress-bar.d.ts +3 -0
- package/types/caribeng-ui-caribe-shortcut.d.ts +3 -1
- package/types/caribeng-ui-caribe-step-indicator.d.ts +6 -0
- package/types/caribeng-ui-caribe-stroke.d.ts +4 -1
- package/types/caribeng-ui-caribe-switch.d.ts +3 -1
- package/types/caribeng-ui-caribe-tracker.d.ts +3 -0
- package/types/caribeng-ui-caribe-voucher.d.ts +5 -2
- package/types/caribeng-ui-carousel.d.ts +10 -1
- package/types/caribeng-ui-cascadeselect.d.ts +7 -2
- package/types/caribeng-ui-chart.d.ts +471 -44
- package/types/caribeng-ui-chat.d.ts +299 -0
- package/types/caribeng-ui-chip.d.ts +6 -0
- package/types/caribeng-ui-chips.d.ts +6 -2
- package/types/caribeng-ui-code-block.d.ts +65 -0
- package/types/caribeng-ui-colorpicker.d.ts +8 -2
- package/types/caribeng-ui-command-palette.d.ts +133 -0
- package/types/caribeng-ui-confirmdialog.d.ts +57 -6
- package/types/caribeng-ui-confirmpopup.d.ts +74 -5
- package/types/caribeng-ui-contextmenu.d.ts +11 -1
- package/types/caribeng-ui-copy-button.d.ts +90 -0
- package/types/caribeng-ui-dataview.d.ts +65 -5
- package/types/caribeng-ui-datepicker.d.ts +186 -21
- package/types/caribeng-ui-descriptions.d.ts +63 -0
- package/types/caribeng-ui-dialog.d.ts +4 -1
- package/types/caribeng-ui-dock.d.ts +17 -2
- package/types/caribeng-ui-drawer.d.ts +7 -2
- package/types/caribeng-ui-dynamicdialog.d.ts +93 -3
- package/types/caribeng-ui-editor.d.ts +486 -13
- package/types/caribeng-ui-empty.d.ts +34 -0
- package/types/caribeng-ui-file-card.d.ts +28 -3
- package/types/caribeng-ui-fileupload.d.ts +27 -4
- package/types/caribeng-ui-folder-card.d.ts +31 -6
- package/types/caribeng-ui-galleria.d.ts +9 -0
- package/types/caribeng-ui-image.d.ts +10 -0
- package/types/caribeng-ui-inplace.d.ts +8 -0
- package/types/caribeng-ui-input-number.d.ts +3 -1
- package/types/caribeng-ui-inputmask.d.ts +8 -1
- package/types/caribeng-ui-inputotp.d.ts +7 -2
- package/types/caribeng-ui-kanban.d.ts +783 -0
- package/types/caribeng-ui-kbd.d.ts +36 -0
- package/types/caribeng-ui-keyfilter.d.ts +30 -0
- package/types/caribeng-ui-listbox.d.ts +5 -3
- package/types/caribeng-ui-megamenu.d.ts +37 -2
- package/types/caribeng-ui-mentions.d.ts +127 -0
- package/types/caribeng-ui-menu.d.ts +14 -2
- package/types/caribeng-ui-menubar.d.ts +12 -1
- package/types/caribeng-ui-message.d.ts +5 -0
- package/types/caribeng-ui-metergroup.d.ts +9 -1
- package/types/caribeng-ui-multiselect.d.ts +71 -10
- package/types/caribeng-ui-orderlist.d.ts +58 -6
- package/types/caribeng-ui-organizationchart.d.ts +7 -1
- package/types/caribeng-ui-paginator.d.ts +3 -0
- package/types/caribeng-ui-panel.d.ts +3 -0
- package/types/caribeng-ui-panelmenu.d.ts +11 -1
- package/types/caribeng-ui-password.d.ts +4 -2
- package/types/caribeng-ui-pdfviewer.d.ts +258 -0
- package/types/caribeng-ui-phone-input.d.ts +168 -0
- package/types/caribeng-ui-picklist.d.ts +67 -7
- package/types/caribeng-ui-pricing.d.ts +49 -9
- package/types/caribeng-ui-qrcode.d.ts +88 -0
- package/types/caribeng-ui-rating.d.ts +6 -2
- package/types/caribeng-ui-repeater.d.ts +79 -0
- package/types/caribeng-ui-result.d.ts +35 -0
- package/types/caribeng-ui-scrollpanel.d.ts +4 -1
- package/types/caribeng-ui-scrolltop.d.ts +4 -1
- package/types/caribeng-ui-select.d.ts +73 -9
- package/types/caribeng-ui-sidebar.d.ts +167 -0
- package/types/caribeng-ui-slider.d.ts +63 -10
- package/types/caribeng-ui-speeddial.d.ts +5 -2
- package/types/caribeng-ui-spinner.d.ts +3 -0
- package/types/caribeng-ui-splitbutton.d.ts +49 -0
- package/types/caribeng-ui-splitter.d.ts +3 -0
- package/types/caribeng-ui-statistic.d.ts +65 -0
- package/types/caribeng-ui-stepper.d.ts +5 -0
- package/types/caribeng-ui-steps.d.ts +4 -1
- package/types/caribeng-ui-table.d.ts +185 -17
- package/types/caribeng-ui-tabmenu.d.ts +11 -1
- package/types/caribeng-ui-terminal.d.ts +10 -0
- package/types/caribeng-ui-themetoggle.d.ts +32 -0
- package/types/caribeng-ui-tieredmenu.d.ts +22 -3
- package/types/caribeng-ui-timeline.d.ts +63 -4
- package/types/caribeng-ui-toast.d.ts +3 -0
- package/types/caribeng-ui-togglebutton.d.ts +5 -3
- package/types/caribeng-ui-toolbar.d.ts +7 -4
- package/types/caribeng-ui-tree.d.ts +76 -4
- package/types/caribeng-ui-treeselect.d.ts +10 -2
- package/types/caribeng-ui-treetable.d.ts +68 -4
- package/types/caribeng-ui-virtualscroller.d.ts +45 -5
- package/types/caribeng-ui.d.ts +775 -12
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "caribeng-migrate-from-primeng",
|
|
4
|
+
"title": "Migrar de PrimeNG a CaribeNG",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"path": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Carpeta a migrar (p. ej. src/app/ventas). Por defecto, todo el workspace. Permite migrar por partes.",
|
|
10
|
+
"default": "/"
|
|
11
|
+
},
|
|
12
|
+
"removePrimeng": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "Quitar primeng, primeicons y @primeuix/* de package.json cuando ya no quede ninguna referencia.",
|
|
15
|
+
"default": true
|
|
16
|
+
},
|
|
17
|
+
"report": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Escribir caribeng-migration-report.md con los avisos y las referencias pendientes.",
|
|
20
|
+
"default": true
|
|
21
|
+
},
|
|
22
|
+
"skipInstall": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "No ejecutar la instalación de dependencias al terminar.",
|
|
25
|
+
"default": false
|
|
26
|
+
},
|
|
27
|
+
"force": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "Migrar aunque falte @caribeng/ui o la versión de PrimeNG no esté soportada.",
|
|
30
|
+
"default": false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"required": []
|
|
34
|
+
}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TODO_MARK = void 0;
|
|
4
|
+
exports.loadCompiler = loadCompiler;
|
|
5
|
+
exports.rewriteTemplate = rewriteTemplate;
|
|
6
|
+
exports.applyEdits = applyEdits;
|
|
7
|
+
exports.classify = classify;
|
|
8
|
+
const icons_1 = require("./icons");
|
|
9
|
+
const todo_1 = require("./todo");
|
|
10
|
+
Object.defineProperty(exports, "TODO_MARK", { enumerable: true, get: function () { return todo_1.TODO_MARK; } });
|
|
11
|
+
const mappings_1 = require("./mappings");
|
|
12
|
+
const rules_1 = require("./mappings/rules");
|
|
13
|
+
function loadCompiler() {
|
|
14
|
+
return import('@angular/compiler');
|
|
15
|
+
}
|
|
16
|
+
/** Traduce los selectores PrimeNG de una plantilla Angular a CaribeNG. */
|
|
17
|
+
function rewriteTemplate(compiler, text, url) {
|
|
18
|
+
const parsed = new compiler.HtmlParser().parse(text, url, {
|
|
19
|
+
tokenizeExpansionForms: true,
|
|
20
|
+
tokenizeBlocks: true,
|
|
21
|
+
tokenizeLet: true,
|
|
22
|
+
});
|
|
23
|
+
if (parsed.errors.length) {
|
|
24
|
+
return { text, changed: false, icons: new Set(), error: parsed.errors.map((e) => e.toString()).join('\n') };
|
|
25
|
+
}
|
|
26
|
+
const edits = [];
|
|
27
|
+
const icons = new Set();
|
|
28
|
+
// Nodos que una reestructuración eliminó: no se visitan.
|
|
29
|
+
const removed = new Set();
|
|
30
|
+
// Elementos ya traducidos por una reestructuración: no se vuelven a traducir (sus hijos sí se visitan).
|
|
31
|
+
const converted = new Set();
|
|
32
|
+
const visit = (nodes) => {
|
|
33
|
+
for (const node of nodes) {
|
|
34
|
+
if (removed.has(node))
|
|
35
|
+
continue;
|
|
36
|
+
if (node instanceof compiler.Element) {
|
|
37
|
+
if (!converted.has(node))
|
|
38
|
+
visitElement(node);
|
|
39
|
+
// Si la reestructuración sustituyó el elemento entero, su contenido ya está migrado.
|
|
40
|
+
if (!removed.has(node))
|
|
41
|
+
visit(node.children);
|
|
42
|
+
}
|
|
43
|
+
else if (node instanceof compiler.Block) {
|
|
44
|
+
visit(node.children);
|
|
45
|
+
}
|
|
46
|
+
else if (node instanceof compiler.Expansion) {
|
|
47
|
+
for (const expansionCase of node.cases)
|
|
48
|
+
visit(expansionCase.expression);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const visitElement = (element) => {
|
|
53
|
+
const directives = directivesOf(element);
|
|
54
|
+
const mapping = mappings_1.ELEMENTS_BY_TAG.get(element.name) ?? element.attrs.map((attr) => mappings_1.ELEMENTS_BY_ATTR.get(attr.name)).find(Boolean);
|
|
55
|
+
if (mapping?.manual) {
|
|
56
|
+
edits.push(todoEdit(text, element.sourceSpan.start.offset, mapping.manual));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (mapping?.restructure) {
|
|
60
|
+
const nodes = new Map();
|
|
61
|
+
const pending = [];
|
|
62
|
+
const pendingRemoved = [];
|
|
63
|
+
const pendingConverted = [];
|
|
64
|
+
const reason = mapping.restructure(templateNode(compiler, text, element, nodes), {
|
|
65
|
+
convert: (node, nodeMapping) => {
|
|
66
|
+
const html = nodes.get(node);
|
|
67
|
+
rewriteElement(text, html, nodeMapping, directivesOf(html), pending, icons);
|
|
68
|
+
rewriteChildren(compiler, text, html, nodeMapping, pending);
|
|
69
|
+
pendingConverted.push(html);
|
|
70
|
+
},
|
|
71
|
+
remove: (node) => {
|
|
72
|
+
const html = nodes.get(node);
|
|
73
|
+
pending.push({ ...lineRange(text, html.sourceSpan.start.offset, html.sourceSpan.end.offset), text: '' });
|
|
74
|
+
pendingRemoved.push(html);
|
|
75
|
+
},
|
|
76
|
+
replace: (node, replacement) => {
|
|
77
|
+
const html = nodes.get(node);
|
|
78
|
+
pending.push({ start: html.sourceSpan.start.offset, end: html.sourceSpan.end.offset, text: replacement });
|
|
79
|
+
pendingRemoved.push(html);
|
|
80
|
+
},
|
|
81
|
+
migrate: (fragment) => {
|
|
82
|
+
const result = rewriteTemplate(compiler, fragment, url);
|
|
83
|
+
result.icons.forEach((icon) => icons.add(icon));
|
|
84
|
+
return result.text;
|
|
85
|
+
},
|
|
86
|
+
rules: (node, nodeMapping) => {
|
|
87
|
+
const html = nodes.get(node);
|
|
88
|
+
const el = applyRules(text, html, nodeMapping, directivesOf(html));
|
|
89
|
+
el.icons.forEach((icon) => icons.add(icon));
|
|
90
|
+
return { attrs: el.attrs, todos: el.todos };
|
|
91
|
+
},
|
|
92
|
+
eol: text.includes('\r\n') ? '\r\n' : '\n',
|
|
93
|
+
unwrap: (node) => {
|
|
94
|
+
const html = nodes.get(node);
|
|
95
|
+
pending.push({ ...lineRange(text, html.startSourceSpan.start.offset, html.startSourceSpan.end.offset), text: '' });
|
|
96
|
+
if (html.endSourceSpan && !html.isSelfClosing)
|
|
97
|
+
pending.push({ ...lineRange(text, html.endSourceSpan.start.offset, html.endSourceSpan.end.offset), text: '' });
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
if (reason === null) {
|
|
101
|
+
edits.push(...pending);
|
|
102
|
+
pendingRemoved.forEach((node) => removed.add(node));
|
|
103
|
+
pendingConverted.forEach((node) => converted.add(node));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
edits.push(todoEdit(text, element.sourceSpan.start.offset, reason));
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (mapping?.attr && mapping.on && !mapping.on.includes(element.name)) {
|
|
111
|
+
const hint = mapping.otherTags ?? `usa un <${mapping.to}> o el componente CaribeNG equivalente.`;
|
|
112
|
+
edits.push(todoEdit(text, element.sourceSpan.start.offset, `${mapping.attr} en <${element.name}> no se migra automáticamente: ${hint}`));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (mapping || directives.length) {
|
|
116
|
+
rewriteElement(text, element, mapping ?? null, directives, edits, icons);
|
|
117
|
+
if (mapping)
|
|
118
|
+
rewriteChildren(compiler, text, element, mapping, edits);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
rewriteIcon(compiler, text, element, edits, icons);
|
|
122
|
+
};
|
|
123
|
+
visit(parsed.rootNodes);
|
|
124
|
+
const result = edits.length ? applyEdits(text, edits) : text;
|
|
125
|
+
return { text: result, changed: result !== text, icons };
|
|
126
|
+
}
|
|
127
|
+
/** Directivas de atributo PrimeNG (`pTooltip`) presentes en el elemento. */
|
|
128
|
+
function directivesOf(element) {
|
|
129
|
+
return element.attrs
|
|
130
|
+
.map((attr) => mappings_1.DIRECTIVES_BY_ATTR.get(attr.name.replace(/^\[(.+)\]$/, '$1')))
|
|
131
|
+
.filter((directive) => directive !== undefined);
|
|
132
|
+
}
|
|
133
|
+
/** Árbol simplificado de un elemento para `restructure`; `nodes` guarda el nodo del parser de cada uno. */
|
|
134
|
+
function templateNode(compiler, text, node, nodes) {
|
|
135
|
+
let result;
|
|
136
|
+
if (node instanceof compiler.Element) {
|
|
137
|
+
const inner = node.endSourceSpan && !node.isSelfClosing ? text.slice(node.startSourceSpan.end.offset, node.endSourceSpan.start.offset) : '';
|
|
138
|
+
result = {
|
|
139
|
+
kind: 'element',
|
|
140
|
+
name: node.name,
|
|
141
|
+
parameters: [],
|
|
142
|
+
bindings: node.attrs.map((attr) => classify(text, attr)).filter((b) => b !== null),
|
|
143
|
+
attrs: node.attrs.map((attr) => ({ name: attr.name, value: attr.value, source: text.slice(attr.sourceSpan.start.offset, attr.sourceSpan.end.offset) })),
|
|
144
|
+
children: node.children.map((child) => templateNode(compiler, text, child, nodes)),
|
|
145
|
+
inner,
|
|
146
|
+
indent: lineIndent(text, node.sourceSpan.start.offset) ?? '',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
else if (node instanceof compiler.Block) {
|
|
150
|
+
result = {
|
|
151
|
+
kind: 'block',
|
|
152
|
+
name: node.name,
|
|
153
|
+
parameters: node.parameters.map((parameter) => parameter.expression),
|
|
154
|
+
bindings: [],
|
|
155
|
+
attrs: [],
|
|
156
|
+
children: node.children.map((child) => templateNode(compiler, text, child, nodes)),
|
|
157
|
+
inner: node.endSourceSpan ? text.slice(node.startSourceSpan.end.offset, node.endSourceSpan.start.offset) : '',
|
|
158
|
+
indent: lineIndent(text, node.sourceSpan.start.offset) ?? '',
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
result = {
|
|
163
|
+
kind: node instanceof compiler.Text ? 'text' : 'other',
|
|
164
|
+
name: '',
|
|
165
|
+
parameters: [],
|
|
166
|
+
bindings: [],
|
|
167
|
+
attrs: [],
|
|
168
|
+
children: [],
|
|
169
|
+
inner: text.slice(node.sourceSpan.start.offset, node.sourceSpan.end.offset),
|
|
170
|
+
indent: lineIndent(text, node.sourceSpan.start.offset) ?? '',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
nodes.set(result, node);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
/** `[start, end)` ampliado a sus líneas completas si no comparte línea con nada más (para borrar sin dejar líneas vacías). */
|
|
177
|
+
function lineRange(text, start, end) {
|
|
178
|
+
const lineStart = text.lastIndexOf('\n', start - 1) + 1;
|
|
179
|
+
const after = /^[ \t]*(\r?\n|$)/.exec(text.slice(end));
|
|
180
|
+
if (/^[ \t]*$/.test(text.slice(lineStart, start)) && after)
|
|
181
|
+
return { start: lineStart, end: end + after[0].length };
|
|
182
|
+
return { start, end };
|
|
183
|
+
}
|
|
184
|
+
/** Aplica ediciones (sin solapes) de atrás hacia delante. */
|
|
185
|
+
function applyEdits(text, edits) {
|
|
186
|
+
const sorted = [...edits].sort((a, b) => b.start - a.start || b.end - a.end);
|
|
187
|
+
let result = text;
|
|
188
|
+
let limit = Number.POSITIVE_INFINITY;
|
|
189
|
+
for (const edit of sorted) {
|
|
190
|
+
if (edit.end > limit)
|
|
191
|
+
throw new Error(`Ediciones solapadas en ${edit.start}-${edit.end}`);
|
|
192
|
+
result = result.slice(0, edit.start) + edit.text + result.slice(edit.end);
|
|
193
|
+
limit = edit.start;
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
/** Clasifica un atributo de plantilla. `null` para referencias, directivas estructurales, `[attr.x]`… */
|
|
198
|
+
function classify(text, attr) {
|
|
199
|
+
const source = text.slice(attr.sourceSpan.start.offset, attr.sourceSpan.end.offset);
|
|
200
|
+
const value = attr.value;
|
|
201
|
+
const bare = attr.valueSpan === undefined;
|
|
202
|
+
const name = attr.name;
|
|
203
|
+
let match;
|
|
204
|
+
if ((match = /^\[\((.+)\)\]$/.exec(name)) || (match = /^bindon-(.+)$/.exec(name)))
|
|
205
|
+
return { kind: 'twoWay', name: match[1], value, bare, source };
|
|
206
|
+
if ((match = /^\[(.+)\]$/.exec(name)) || (match = /^bind-(.+)$/.exec(name))) {
|
|
207
|
+
return /^(attr|class|style)\./.test(match[1]) ? null : { kind: 'property', name: match[1], value, bare, source };
|
|
208
|
+
}
|
|
209
|
+
if ((match = /^\((.+)\)$/.exec(name)) || (match = /^on-(.+)$/.exec(name)))
|
|
210
|
+
return { kind: 'event', name: match[1], value, bare, source };
|
|
211
|
+
if (/^(#|\*|@|let-|ref-|i18n)/.test(name))
|
|
212
|
+
return null;
|
|
213
|
+
return { kind: 'static', name, value, bare, source };
|
|
214
|
+
}
|
|
215
|
+
/** Aplica las reglas del mapeo y de las directivas a los atributos del elemento (sin editar el texto). */
|
|
216
|
+
function applyRules(text, element, mapping, directives) {
|
|
217
|
+
const tag = mapping?.to ?? element.name;
|
|
218
|
+
const bindings = [];
|
|
219
|
+
const attrs = [];
|
|
220
|
+
const order = [];
|
|
221
|
+
for (const attr of element.attrs) {
|
|
222
|
+
const binding = classify(text, attr);
|
|
223
|
+
if (binding)
|
|
224
|
+
bindings.push(binding);
|
|
225
|
+
order.push(binding ?? text.slice(attr.sourceSpan.start.offset, attr.sourceSpan.end.offset));
|
|
226
|
+
}
|
|
227
|
+
const el = {
|
|
228
|
+
tag,
|
|
229
|
+
attrs,
|
|
230
|
+
before: [],
|
|
231
|
+
after: [],
|
|
232
|
+
todos: [],
|
|
233
|
+
icons: new Set(),
|
|
234
|
+
bindings,
|
|
235
|
+
find: (name) => bindings.find((b) => b.name === name && b.kind !== 'event') ?? bindings.find((b) => b.kind === 'event' && `(${b.name})` === name),
|
|
236
|
+
};
|
|
237
|
+
for (const item of order) {
|
|
238
|
+
if (typeof item === 'string') {
|
|
239
|
+
attrs.push(item);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
// La propia directiva PrimeNG del componente (`pButton`) desaparece.
|
|
243
|
+
if (mapping?.attr && item.kind === 'static' && item.name === mapping.attr)
|
|
244
|
+
continue;
|
|
245
|
+
// La de una directiva (`pTooltip`) pasa a la de CaribeNG (`cbTooltip`).
|
|
246
|
+
const directive = directives.find((d) => d.attr === item.name && item.kind !== 'event');
|
|
247
|
+
if (directive) {
|
|
248
|
+
attrs.push((0, rules_1.renderAttr)(item.kind, directive.to, item.value, item.bare));
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const key = item.kind === 'event' ? `(${item.name})` : item.name;
|
|
252
|
+
const rule = directives.find((d) => d.rules[key])?.rules[key] ?? mapping?.rules[key];
|
|
253
|
+
if (rule)
|
|
254
|
+
rule(item, el);
|
|
255
|
+
else
|
|
256
|
+
attrs.push(item.source);
|
|
257
|
+
}
|
|
258
|
+
mapping?.finalize?.(el);
|
|
259
|
+
mergeClasses(attrs);
|
|
260
|
+
return el;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Reescribe un elemento: con `mapping` cambia el tag (`p-button` →
|
|
264
|
+
* `cb-button`); sin él solo traduce los atributos de sus directivas
|
|
265
|
+
* (`pTooltip` → `cbTooltip`) y conserva el tag y su contenido.
|
|
266
|
+
*/
|
|
267
|
+
function rewriteElement(text, element, mapping, directives, edits, icons) {
|
|
268
|
+
const tag = mapping?.to ?? element.name;
|
|
269
|
+
const el = applyRules(text, element, mapping, directives);
|
|
270
|
+
const { attrs } = el;
|
|
271
|
+
el.icons.forEach((icon) => icons.add(icon));
|
|
272
|
+
const start = element.sourceSpan.start.offset;
|
|
273
|
+
const startTag = text.slice(start, element.startSourceSpan.end.offset);
|
|
274
|
+
// Atributos en varias líneas: se conserva la sangría de la primera línea de atributos.
|
|
275
|
+
const separator = /\r?\n[ \t]*(?=[^\s/>])/.exec(startTag)?.[0] ?? ' ';
|
|
276
|
+
// `/>` o `>` en su propia línea se conserva; un simple espacio antes de `/>` no.
|
|
277
|
+
const closingSpace = /(\s*)\/?>$/.exec(startTag)?.[1].match(/\r?\n[ \t]*$/)?.[0] ?? '';
|
|
278
|
+
const head = `<${tag}${attrs.map((attr) => separator + attr).join('')}`;
|
|
279
|
+
const todos = el.todos.map((todo) => todoPrefix(text, start, todo)).join('');
|
|
280
|
+
const content = [...el.before, ...el.after];
|
|
281
|
+
if (!mapping) {
|
|
282
|
+
// Solo directivas: el elemento, su cierre y su contenido no cambian.
|
|
283
|
+
const close = startTag.endsWith('/>') ? `${closingSpace || ' '}/>` : `${closingSpace}>`;
|
|
284
|
+
edits.push({ start, end: element.startSourceSpan.end.offset, text: `${todos}${head}${close}` });
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const hasEndTag = !element.isSelfClosing && !element.isVoid && element.endSourceSpan && element.endSourceSpan.start.offset !== element.startSourceSpan.start.offset;
|
|
288
|
+
if (mapping.selfClosing) {
|
|
289
|
+
edits.push({ start, end: element.sourceSpan.end.offset, text: `${todos}${head}${closingSpace || ' '}/>` });
|
|
290
|
+
}
|
|
291
|
+
else if (!hasEndTag) {
|
|
292
|
+
const body = content.length ? `${closingSpace}>${content.join('')}</${mapping.to}>` : `${closingSpace || ' '}/>`;
|
|
293
|
+
edits.push({ start, end: element.sourceSpan.end.offset, text: `${todos}${head}${body}` });
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
edits.push({ start, end: element.startSourceSpan.end.offset, text: `${todos}${head}${closingSpace}>${el.before.join('')}` });
|
|
297
|
+
edits.push({ start: element.endSourceSpan.start.offset, end: element.endSourceSpan.end.offset, text: `${el.after.join('')}</${mapping.to}>` });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** Hijos directos con reescritura propia (p. ej. `<ng-template #footer>` de un diálogo). */
|
|
301
|
+
function rewriteChildren(compiler, text, element, mapping, edits) {
|
|
302
|
+
if (!mapping.child)
|
|
303
|
+
return;
|
|
304
|
+
for (const node of element.children) {
|
|
305
|
+
if (!(node instanceof compiler.Element))
|
|
306
|
+
continue;
|
|
307
|
+
const child = {
|
|
308
|
+
name: node.name,
|
|
309
|
+
bindings: node.attrs.map((attr) => classify(text, attr)).filter((b) => b !== null),
|
|
310
|
+
references: node.attrs.filter((attr) => /^(#|ref-)/.test(attr.name)).map((attr) => attr.name.replace(/^(#|ref-)/, '')),
|
|
311
|
+
};
|
|
312
|
+
const rewrite = mapping.child(child);
|
|
313
|
+
if (!rewrite)
|
|
314
|
+
continue;
|
|
315
|
+
if ('todo' in rewrite) {
|
|
316
|
+
edits.push(todoEdit(text, node.sourceSpan.start.offset, rewrite.todo));
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const head = `<${rewrite.tag}${rewrite.attrs.map((attr) => ` ${attr}`).join('')}`;
|
|
320
|
+
if (node.endSourceSpan && !node.isSelfClosing) {
|
|
321
|
+
edits.push({ start: node.startSourceSpan.start.offset, end: node.startSourceSpan.end.offset, text: `${head}>` });
|
|
322
|
+
edits.push({ start: node.endSourceSpan.start.offset, end: node.endSourceSpan.end.offset, text: `</${rewrite.tag}>` });
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
edits.push({ start: node.sourceSpan.start.offset, end: node.sourceSpan.end.offset, text: `${head}></${rewrite.tag}>` });
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** `<i class="pi pi-check"></i>` → `<cb-icon name="check" />`. */
|
|
330
|
+
function rewriteIcon(compiler, text, element, edits, icons) {
|
|
331
|
+
if (!['i', 'span', 'em'].includes(element.name))
|
|
332
|
+
return;
|
|
333
|
+
const classAttr = element.attrs.find((attr) => attr.name === 'class');
|
|
334
|
+
const parsed = classAttr && (0, icons_1.parsePrimeIcon)(classAttr.value);
|
|
335
|
+
if (!parsed)
|
|
336
|
+
return;
|
|
337
|
+
const start = element.sourceSpan.start.offset;
|
|
338
|
+
const empty = element.children.every((child) => child instanceof compiler.Text && !child.value.trim());
|
|
339
|
+
if (!parsed.name || !empty) {
|
|
340
|
+
const why = parsed.name ? 'el elemento tiene contenido' : `pi-${parsed.prime} no tiene equivalente conocido`;
|
|
341
|
+
edits.push(todoEdit(text, start, `icono de PrimeIcons sin migrar (${why}): usa <cb-icon name="…" />.`));
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
icons.add(parsed.name);
|
|
345
|
+
const attrs = [`name="${parsed.name}"`];
|
|
346
|
+
if (parsed.spin)
|
|
347
|
+
attrs.push('spin');
|
|
348
|
+
if (parsed.rest.length)
|
|
349
|
+
attrs.push(`class="${parsed.rest.join(' ')}"`);
|
|
350
|
+
for (const attr of element.attrs) {
|
|
351
|
+
if (attr !== classAttr)
|
|
352
|
+
attrs.push(text.slice(attr.sourceSpan.start.offset, attr.sourceSpan.end.offset));
|
|
353
|
+
}
|
|
354
|
+
edits.push({ start, end: element.sourceSpan.end.offset, text: `<cb-icon ${attrs.join(' ')} />` });
|
|
355
|
+
}
|
|
356
|
+
/** Une varios `class="…"` estáticos en uno (p. ej. `class` + `styleClass`). */
|
|
357
|
+
function mergeClasses(attrs) {
|
|
358
|
+
const indexes = attrs.map((attr, i) => (/^class=(["'])/.test(attr) ? i : -1)).filter((i) => i >= 0);
|
|
359
|
+
if (indexes.length < 2)
|
|
360
|
+
return;
|
|
361
|
+
const merged = indexes.map((i) => attrs[i].slice(7, -1)).join(' ');
|
|
362
|
+
for (const i of indexes.slice(1).reverse())
|
|
363
|
+
attrs.splice(i, 1);
|
|
364
|
+
attrs[indexes[0]] = (0, rules_1.renderAttr)('static', 'class', merged);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Aviso para colocar justo antes de un elemento: en su propia línea y con la
|
|
368
|
+
* misma sangría si el elemento empieza la línea; si no, en la misma línea.
|
|
369
|
+
*/
|
|
370
|
+
function todoPrefix(text, offset, message) {
|
|
371
|
+
const indent = lineIndent(text, offset);
|
|
372
|
+
const comment = `<!-- ${todo_1.TODO_MARK}: ${message.replace(/--+/g, '-').replace(/\s+/g, ' ')} -->`;
|
|
373
|
+
const newline = text.includes('\r\n') ? '\r\n' : '\n';
|
|
374
|
+
return comment + (indent === null ? ' ' : newline + indent);
|
|
375
|
+
}
|
|
376
|
+
/** Aviso sobre un elemento que no se convierte. Si ya está (segunda ejecución), no se repite. */
|
|
377
|
+
function todoEdit(text, offset, message) {
|
|
378
|
+
const prefix = todoPrefix(text, offset, message);
|
|
379
|
+
const comment = prefix.slice(0, prefix.indexOf('-->') + 3);
|
|
380
|
+
const already = text.slice(0, offset).trimEnd().endsWith(comment);
|
|
381
|
+
return { start: offset, end: offset, text: already ? '' : prefix };
|
|
382
|
+
}
|
|
383
|
+
/** Sangría de la línea si el elemento es lo primero de ella; `null` si va detrás de otro contenido. */
|
|
384
|
+
function lineIndent(text, offset) {
|
|
385
|
+
const prefix = text.slice(text.lastIndexOf('\n', offset - 1) + 1, offset);
|
|
386
|
+
return /^[ \t]*$/.test(prefix) ? prefix : null;
|
|
387
|
+
}
|