ui-core-abv 0.10.1 → 0.10.2

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.
@@ -1926,14 +1926,29 @@ class UicFileInputComponent extends base$b {
1926
1926
  if (!this.templateUrl) {
1927
1927
  return;
1928
1928
  }
1929
- const link = document.createElement('a');
1930
- link.href = this.templateUrl;
1931
- link.target = '_blank';
1932
- link.rel = 'noopener';
1933
- link.download = this.getTemplateFileName();
1934
- document.body.appendChild(link);
1935
- link.click();
1936
- link.remove();
1929
+ const fileName = this.getTemplateFileName();
1930
+ fetch(this.templateUrl)
1931
+ .then((response) => {
1932
+ if (!response.ok) {
1933
+ throw new Error('template fetch failed');
1934
+ }
1935
+ return response.blob();
1936
+ })
1937
+ .then((blob) => {
1938
+ const url = URL.createObjectURL(blob);
1939
+ const link = document.createElement('a');
1940
+ link.href = url;
1941
+ link.download = fileName;
1942
+ link.rel = 'noopener';
1943
+ document.body.appendChild(link);
1944
+ link.click();
1945
+ link.remove();
1946
+ setTimeout(() => URL.revokeObjectURL(url), 0);
1947
+ })
1948
+ .catch(() => {
1949
+ this.push.error('No se pudo renombrar el archivo, se abrirá con su nombre original');
1950
+ window.open(this.templateUrl, '_blank', 'noopener');
1951
+ });
1937
1952
  }
1938
1953
  getTemplateFileName() {
1939
1954
  const baseName = (this.label || 'formato').trim().replace(/[\\/]/g, '-');