@onpe/ui 1.1.0 → 1.1.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.
package/dist/cli.esm.js CHANGED
@@ -5863,83 +5863,213 @@ var lib = {
5863
5863
 
5864
5864
  /**
5865
5865
  * Crea archivos de barril (barrel exports) para simplificar las importaciones
5866
+ * Solo crea las carpetas y archivos que realmente existen
5866
5867
  */
5867
5868
  function createBarrelFiles() {
5868
5869
  return __awaiter(this, void 0, void 0, function () {
5869
- var componentsDir, mainIndexContent, uiIndexContent, modalsIndexContent, iconsIndexContent, actionsIndexContent, browsersIndexContent, systemsIndexContent, onpeIndexContent;
5870
+ var componentsDir, folderExists, getFilesInFolder, mainExports, mainIndexContent, uiPath, uiFiles, uiExports, uiIndexContent, modalsPath, modalFiles, modalExports, modalsIndexContent, iconsPath, iconExports, iconsIndexContent, iconCategories, _i, iconCategories_1, category, categoryPath, categoryFiles, categoryExports, categoryIndexContent;
5871
+ var _this = this;
5870
5872
  return __generator(this, function (_a) {
5871
5873
  switch (_a.label) {
5872
5874
  case 0:
5873
5875
  componentsDir = path$d.join(process.cwd(), "src", "components", "onpe");
5874
- // Crear estructura de carpetas si no existe
5875
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "ui"))];
5876
+ // Solo crear la carpeta principal si no existe
5877
+ return [4 /*yield*/, lib.ensureDir(componentsDir)];
5876
5878
  case 1:
5877
- // Crear estructura de carpetas si no existe
5879
+ // Solo crear la carpeta principal si no existe
5878
5880
  _a.sent();
5879
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "modals"))];
5881
+ folderExists = function (folderPath) { return __awaiter(_this, void 0, void 0, function () {
5882
+ var exists, files;
5883
+ return __generator(this, function (_b) {
5884
+ switch (_b.label) {
5885
+ case 0:
5886
+ _b.trys.push([0, 3, , 4]);
5887
+ return [4 /*yield*/, lib.pathExists(folderPath)];
5888
+ case 1:
5889
+ exists = _b.sent();
5890
+ if (!exists)
5891
+ return [2 /*return*/, false];
5892
+ return [4 /*yield*/, lib.readdir(folderPath)];
5893
+ case 2:
5894
+ files = _b.sent();
5895
+ return [2 /*return*/, files.some(function (file) { return file.endsWith(".tsx") && !file.includes(".stories"); })];
5896
+ case 3:
5897
+ _b.sent();
5898
+ return [2 /*return*/, false];
5899
+ case 4: return [2 /*return*/];
5900
+ }
5901
+ });
5902
+ }); };
5903
+ getFilesInFolder = function (folderPath) { return __awaiter(_this, void 0, void 0, function () {
5904
+ var files;
5905
+ return __generator(this, function (_b) {
5906
+ switch (_b.label) {
5907
+ case 0:
5908
+ _b.trys.push([0, 2, , 3]);
5909
+ return [4 /*yield*/, lib.readdir(folderPath)];
5910
+ case 1:
5911
+ files = _b.sent();
5912
+ return [2 /*return*/, files.filter(function (file) { return file.endsWith(".tsx") && !file.includes(".stories"); }).map(function (file) { return file.replace(".tsx", ""); })];
5913
+ case 2:
5914
+ _b.sent();
5915
+ return [2 /*return*/, []];
5916
+ case 3: return [2 /*return*/];
5917
+ }
5918
+ });
5919
+ }); };
5920
+ mainExports = [];
5921
+ return [4 /*yield*/, folderExists(path$d.join(componentsDir, "ui"))];
5880
5922
  case 2:
5881
- _a.sent();
5882
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "actions"))];
5923
+ if (_a.sent()) {
5924
+ mainExports.push("export * from './ui';");
5925
+ }
5926
+ return [4 /*yield*/, folderExists(path$d.join(componentsDir, "modals"))];
5883
5927
  case 3:
5884
- _a.sent();
5885
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "browsers"))];
5928
+ if (_a.sent()) {
5929
+ mainExports.push("export * from './modals';");
5930
+ }
5931
+ return [4 /*yield*/, folderExists(path$d.join(componentsDir, "icons"))];
5886
5932
  case 4:
5887
- _a.sent();
5888
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "systems"))];
5933
+ if (_a.sent()) {
5934
+ mainExports.push("export * from './icons';");
5935
+ }
5936
+ if (!(mainExports.length > 0)) return [3 /*break*/, 6];
5937
+ mainIndexContent = "// ONPE UI - Punto de entrada principal\n".concat(mainExports.join("\n"));
5938
+ return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "index.ts"), mainIndexContent)];
5889
5939
  case 5:
5890
5940
  _a.sent();
5891
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "onpe"))];
5941
+ _a.label = 6;
5892
5942
  case 6:
5893
- _a.sent();
5894
- mainIndexContent = "// ONPE UI - Punto de entrada principal\nexport * from './ui';\nexport * from './modals';\nexport * from './icons';\n\n// Re-exportar todo para importaciones f\u00E1ciles\nexport * from './ui/index';\nexport * from './modals/index';\nexport * from './icons/index';\n";
5895
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "index.ts"), mainIndexContent)];
5943
+ uiPath = path$d.join(componentsDir, "ui");
5944
+ return [4 /*yield*/, folderExists(uiPath)];
5896
5945
  case 7:
5897
- _a.sent();
5898
- uiIndexContent = "// Componentes UI b\u00E1sicos\nexport * from './Button';\nexport * from './Modal';\nexport * from './Overlay';\nexport * from './Portal';\nexport * from './Show';\n";
5899
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "ui", "index.ts"), uiIndexContent)];
5946
+ if (!_a.sent()) return [3 /*break*/, 10];
5947
+ return [4 /*yield*/, getFilesInFolder(uiPath)];
5900
5948
  case 8:
5901
- _a.sent();
5902
- modalsIndexContent = "// Modales especializados\nexport * from './ModalConfirm';\nexport * from './ModalLoading';\nexport * from './ModalBrowserIncompatible';\nexport * from './ModalSystemIncompatible';\n";
5903
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "modals", "index.ts"), modalsIndexContent)];
5949
+ uiFiles = _a.sent();
5950
+ if (!(uiFiles.length > 0)) return [3 /*break*/, 10];
5951
+ uiExports = uiFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
5952
+ uiIndexContent = "// Componentes b\u00E1sicos ONPE UI\n".concat(uiExports);
5953
+ return [4 /*yield*/, lib.writeFile(path$d.join(uiPath, "index.ts"), uiIndexContent)];
5904
5954
  case 9:
5905
5955
  _a.sent();
5906
- iconsIndexContent = "// Todos los iconos organizados por categor\u00EDas\nexport * from './actions';\nexport * from './browsers';\nexport * from './systems';\nexport * from './onpe';\n";
5907
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "index.ts"), iconsIndexContent)];
5956
+ _a.label = 10;
5908
5957
  case 10:
5909
- _a.sent();
5910
- actionsIndexContent = "// Iconos de Acciones\nexport * from './IconCheck';\nexport * from './IconClose';\nexport * from './IconWarning';\nexport * from './IconSpinnerDesktop';\nexport * from './IconSpinnerMobile';\nexport * from './IconHome';\n";
5911
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "actions", "index.ts"), actionsIndexContent)];
5958
+ modalsPath = path$d.join(componentsDir, "modals");
5959
+ return [4 /*yield*/, folderExists(modalsPath)];
5912
5960
  case 11:
5913
- _a.sent();
5914
- browsersIndexContent = "// Iconos de Navegadores\nexport * from './IconChrome';\nexport * from './IconChromeColor';\nexport * from './IconEdge';\nexport * from './IconEdgeColor';\nexport * from './IconMozilla';\nexport * from './IconMozillaColor';\nexport * from './IconSafari';\nexport * from './IconSafariColor';\n";
5915
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "browsers", "index.ts"), browsersIndexContent)];
5961
+ if (!_a.sent()) return [3 /*break*/, 14];
5962
+ return [4 /*yield*/, getFilesInFolder(modalsPath)];
5916
5963
  case 12:
5917
- _a.sent();
5918
- systemsIndexContent = "// Iconos de Sistemas Operativos\nexport * from './IconAndroid';\nexport * from './IconApple';\nexport * from './IconWindow';\n";
5919
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "systems", "index.ts"), systemsIndexContent)];
5964
+ modalFiles = _a.sent();
5965
+ if (!(modalFiles.length > 0)) return [3 /*break*/, 14];
5966
+ modalExports = modalFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
5967
+ modalsIndexContent = "// Modales especializados ONPE\n".concat(modalExports);
5968
+ return [4 /*yield*/, lib.writeFile(path$d.join(modalsPath, "index.ts"), modalsIndexContent)];
5920
5969
  case 13:
5921
5970
  _a.sent();
5922
- onpeIndexContent = "// Iconos de ONPE\nexport * from './IconVotoDigital';\nexport * from './IconElectionsGeneral';\nexport * from './IconElections';\n";
5923
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "onpe", "index.ts"), onpeIndexContent)];
5971
+ _a.label = 14;
5924
5972
  case 14:
5973
+ iconsPath = path$d.join(componentsDir, "icons");
5974
+ return [4 /*yield*/, folderExists(iconsPath)];
5975
+ case 15:
5976
+ if (!_a.sent()) return [3 /*break*/, 27];
5977
+ iconExports = [];
5978
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "actions"))];
5979
+ case 16:
5980
+ if (_a.sent()) {
5981
+ iconExports.push("export * from './actions';");
5982
+ }
5983
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "browsers"))];
5984
+ case 17:
5985
+ if (_a.sent()) {
5986
+ iconExports.push("export * from './browsers';");
5987
+ }
5988
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "systems"))];
5989
+ case 18:
5990
+ if (_a.sent()) {
5991
+ iconExports.push("export * from './systems';");
5992
+ }
5993
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "onpe"))];
5994
+ case 19:
5995
+ if (_a.sent()) {
5996
+ iconExports.push("export * from './onpe';");
5997
+ }
5998
+ if (!(iconExports.length > 0)) return [3 /*break*/, 21];
5999
+ iconsIndexContent = "// Iconos ONPE organizados por categor\u00EDas\n".concat(iconExports.join("\n"));
6000
+ return [4 /*yield*/, lib.writeFile(path$d.join(iconsPath, "index.ts"), iconsIndexContent)];
6001
+ case 20:
6002
+ _a.sent();
6003
+ _a.label = 21;
6004
+ case 21:
6005
+ iconCategories = ["actions", "browsers", "systems", "onpe"];
6006
+ _i = 0, iconCategories_1 = iconCategories;
6007
+ _a.label = 22;
6008
+ case 22:
6009
+ if (!(_i < iconCategories_1.length)) return [3 /*break*/, 27];
6010
+ category = iconCategories_1[_i];
6011
+ categoryPath = path$d.join(iconsPath, category);
6012
+ return [4 /*yield*/, folderExists(categoryPath)];
6013
+ case 23:
6014
+ if (!_a.sent()) return [3 /*break*/, 26];
6015
+ return [4 /*yield*/, getFilesInFolder(categoryPath)];
6016
+ case 24:
6017
+ categoryFiles = _a.sent();
6018
+ if (!(categoryFiles.length > 0)) return [3 /*break*/, 26];
6019
+ categoryExports = categoryFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
6020
+ categoryIndexContent = "// Iconos de ".concat(category, "\n").concat(categoryExports);
6021
+ return [4 /*yield*/, lib.writeFile(path$d.join(categoryPath, "index.ts"), categoryIndexContent)];
6022
+ case 25:
5925
6023
  _a.sent();
5926
- console.log("✅ Archivos de barril creados exitosamente!");
5927
- console.log("📁 Estructura creada:");
5928
- console.log(" onpe/");
5929
- console.log(" ├── index.ts (principal)");
5930
- console.log(" ├── ui/index.ts");
5931
- console.log(" ├── modals/index.ts");
5932
- console.log(" └── icons/");
5933
- console.log(" ├── index.ts");
5934
- console.log(" ├── actions/index.ts");
5935
- console.log(" ├── browsers/index.ts");
5936
- console.log(" ├── systems/index.ts");
5937
- console.log(" └── onpe/index.ts");
6024
+ _a.label = 26;
6025
+ case 26:
6026
+ _i++;
6027
+ return [3 /*break*/, 22];
6028
+ case 27:
6029
+ console.log(" Archivos de barril actualizados exitosamente!");
6030
+ console.log("📁 Solo se crearon archivos para carpetas que existen");
5938
6031
  return [2 /*return*/];
5939
6032
  }
5940
6033
  });
5941
6034
  });
5942
6035
  }
6036
+ /**
6037
+ * Crea archivos de barril solo para una carpeta específica
6038
+ */
6039
+ function createBarrelForFolder(folderPath) {
6040
+ return __awaiter(this, void 0, void 0, function () {
6041
+ var exists, files, componentFiles, exports_1, indexContent, error_1;
6042
+ return __generator(this, function (_a) {
6043
+ switch (_a.label) {
6044
+ case 0:
6045
+ _a.trys.push([0, 4, , 5]);
6046
+ return [4 /*yield*/, lib.pathExists(folderPath)];
6047
+ case 1:
6048
+ exists = _a.sent();
6049
+ if (!exists)
6050
+ return [2 /*return*/];
6051
+ return [4 /*yield*/, lib.readdir(folderPath)];
6052
+ case 2:
6053
+ files = _a.sent();
6054
+ componentFiles = files.filter(function (file) { return file.endsWith(".tsx") && !file.includes(".stories"); }).map(function (file) { return file.replace(".tsx", ""); });
6055
+ if (componentFiles.length === 0)
6056
+ return [2 /*return*/];
6057
+ exports_1 = componentFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
6058
+ indexContent = "// Componentes en esta carpeta\n".concat(exports_1);
6059
+ return [4 /*yield*/, lib.writeFile(path$d.join(folderPath, "index.ts"), indexContent)];
6060
+ case 3:
6061
+ _a.sent();
6062
+ console.log("\u2705 Archivo de barril creado para: ".concat(path$d.basename(folderPath)));
6063
+ return [3 /*break*/, 5];
6064
+ case 4:
6065
+ error_1 = _a.sent();
6066
+ console.warn("\u26A0\uFE0F No se pudo crear el archivo de barril: ".concat(error_1.message));
6067
+ return [3 /*break*/, 5];
6068
+ case 5: return [2 /*return*/];
6069
+ }
6070
+ });
6071
+ });
6072
+ }
5943
6073
 
5944
6074
  var COMPONENTS_URL = "https://raw.githubusercontent.com/ricardosv46/onpe-ui/main/src/components";
5945
6075
  var ICONS_URL = "https://raw.githubusercontent.com/ricardosv46/onpe-ui/main/src/icons";
@@ -6016,7 +6146,7 @@ function addComponent(componentName) {
6016
6146
  }
6017
6147
  _a.label = 2;
6018
6148
  case 2:
6019
- _a.trys.push([2, 16, , 17]);
6149
+ _a.trys.push([2, 17, , 18]);
6020
6150
  if (!(!isIcon && componentDependencies[componentName.toLowerCase()])) return [3 /*break*/, 8];
6021
6151
  dependencies = componentDependencies[componentName.toLowerCase()];
6022
6152
  console.log("\uD83D\uDD17 Instalando dependencias: ".concat(dependencies.join(", ")));
@@ -6059,17 +6189,21 @@ function addComponent(componentName) {
6059
6189
  console.log("\uD83D\uDCC1 ".concat(isIcon ? "Icono" : "Componente", " guardado en: ").concat(filePath));
6060
6190
  _a.label = 12;
6061
6191
  case 12:
6062
- _a.trys.push([12, 14, , 15]);
6063
- return [4 /*yield*/, createBarrelFiles()];
6192
+ _a.trys.push([12, 15, , 16]);
6193
+ return [4 /*yield*/, createBarrelForFolder(componentPath)];
6064
6194
  case 13:
6065
6195
  _a.sent();
6066
- console.log("🔄 Archivos de barril actualizados");
6067
- return [3 /*break*/, 15];
6196
+ // También actualizar el archivo de barril principal si existe
6197
+ return [4 /*yield*/, createBarrelFiles()];
6068
6198
  case 14:
6199
+ // También actualizar el archivo de barril principal si existe
6200
+ _a.sent();
6201
+ return [3 /*break*/, 16];
6202
+ case 15:
6069
6203
  barrelError_1 = _a.sent();
6070
6204
  console.warn("\u26A0\uFE0F No se pudieron actualizar los archivos de barril: ".concat(barrelError_1.message));
6071
- return [3 /*break*/, 15];
6072
- case 15:
6205
+ return [3 /*break*/, 16];
6206
+ case 16:
6073
6207
  // Mostrar instrucciones
6074
6208
  console.log("\n📋 Próximos pasos:");
6075
6209
  console.log("1. Importa el ".concat(isIcon ? "icono" : "componente", ":"));
@@ -6127,11 +6261,11 @@ function addComponent(componentName) {
6127
6261
  console.log("2. Usa el ".concat(isIcon ? "icono" : "componente", ":"));
6128
6262
  }
6129
6263
  console.log(" <".concat(componentNamePascal, " />"));
6130
- return [3 /*break*/, 17];
6131
- case 16:
6264
+ return [3 /*break*/, 18];
6265
+ case 17:
6132
6266
  error_1 = _a.sent();
6133
6267
  throw new Error("Error al instalar el ".concat(isIcon ? "icono" : "componente", ": ").concat(error_1.message));
6134
- case 17: return [2 /*return*/];
6268
+ case 18: return [2 /*return*/];
6135
6269
  }
6136
6270
  });
6137
6271
  });
@@ -6247,6 +6381,20 @@ function personalizeComponent(code, componentName) {
6247
6381
  personalizedCode = personalizedCode.replace(pattern, "from \"".concat(newPath, "\""));
6248
6382
  });
6249
6383
  });
6384
+ // Arreglar importaciones relativas dentro de la misma carpeta
6385
+ // Para componentes UI que importan otros componentes UI
6386
+ if (componentName.toLowerCase() === "modal") {
6387
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/ui\/(Portal|Overlay)"/g, function (match, component) { return "from \"./".concat(component, "\""); });
6388
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/icons\/actions\/(IconClose)"/g, function (match, component) { return "from \"../icons/actions/".concat(component, "\""); });
6389
+ }
6390
+ // Para otros componentes UI
6391
+ if (!componentName.toLowerCase().startsWith("icon-") && !componentName.toLowerCase().startsWith("modal")) {
6392
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/ui\/([^"]+)"/g, function (match, component) { return "from \"./".concat(component, "\""); });
6393
+ }
6394
+ // Para modales que importan componentes UI
6395
+ if (componentName.toLowerCase().startsWith("modal") && componentName !== "modal") {
6396
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/ui\/([^"]+)"/g, function (match, component) { return "from \"../ui/".concat(component, "\""); });
6397
+ }
6250
6398
  // Agregar export default si no existe
6251
6399
  if (!personalizedCode.includes("export default")) {
6252
6400
  personalizedCode += "\n\nexport default ".concat(componentNamePascal, ";");
package/dist/cli.js CHANGED
@@ -5863,83 +5863,213 @@ var lib = {
5863
5863
 
5864
5864
  /**
5865
5865
  * Crea archivos de barril (barrel exports) para simplificar las importaciones
5866
+ * Solo crea las carpetas y archivos que realmente existen
5866
5867
  */
5867
5868
  function createBarrelFiles() {
5868
5869
  return __awaiter(this, void 0, void 0, function () {
5869
- var componentsDir, mainIndexContent, uiIndexContent, modalsIndexContent, iconsIndexContent, actionsIndexContent, browsersIndexContent, systemsIndexContent, onpeIndexContent;
5870
+ var componentsDir, folderExists, getFilesInFolder, mainExports, mainIndexContent, uiPath, uiFiles, uiExports, uiIndexContent, modalsPath, modalFiles, modalExports, modalsIndexContent, iconsPath, iconExports, iconsIndexContent, iconCategories, _i, iconCategories_1, category, categoryPath, categoryFiles, categoryExports, categoryIndexContent;
5871
+ var _this = this;
5870
5872
  return __generator(this, function (_a) {
5871
5873
  switch (_a.label) {
5872
5874
  case 0:
5873
5875
  componentsDir = path$d.join(process.cwd(), "src", "components", "onpe");
5874
- // Crear estructura de carpetas si no existe
5875
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "ui"))];
5876
+ // Solo crear la carpeta principal si no existe
5877
+ return [4 /*yield*/, lib.ensureDir(componentsDir)];
5876
5878
  case 1:
5877
- // Crear estructura de carpetas si no existe
5879
+ // Solo crear la carpeta principal si no existe
5878
5880
  _a.sent();
5879
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "modals"))];
5881
+ folderExists = function (folderPath) { return __awaiter(_this, void 0, void 0, function () {
5882
+ var exists, files;
5883
+ return __generator(this, function (_b) {
5884
+ switch (_b.label) {
5885
+ case 0:
5886
+ _b.trys.push([0, 3, , 4]);
5887
+ return [4 /*yield*/, lib.pathExists(folderPath)];
5888
+ case 1:
5889
+ exists = _b.sent();
5890
+ if (!exists)
5891
+ return [2 /*return*/, false];
5892
+ return [4 /*yield*/, lib.readdir(folderPath)];
5893
+ case 2:
5894
+ files = _b.sent();
5895
+ return [2 /*return*/, files.some(function (file) { return file.endsWith(".tsx") && !file.includes(".stories"); })];
5896
+ case 3:
5897
+ _b.sent();
5898
+ return [2 /*return*/, false];
5899
+ case 4: return [2 /*return*/];
5900
+ }
5901
+ });
5902
+ }); };
5903
+ getFilesInFolder = function (folderPath) { return __awaiter(_this, void 0, void 0, function () {
5904
+ var files;
5905
+ return __generator(this, function (_b) {
5906
+ switch (_b.label) {
5907
+ case 0:
5908
+ _b.trys.push([0, 2, , 3]);
5909
+ return [4 /*yield*/, lib.readdir(folderPath)];
5910
+ case 1:
5911
+ files = _b.sent();
5912
+ return [2 /*return*/, files.filter(function (file) { return file.endsWith(".tsx") && !file.includes(".stories"); }).map(function (file) { return file.replace(".tsx", ""); })];
5913
+ case 2:
5914
+ _b.sent();
5915
+ return [2 /*return*/, []];
5916
+ case 3: return [2 /*return*/];
5917
+ }
5918
+ });
5919
+ }); };
5920
+ mainExports = [];
5921
+ return [4 /*yield*/, folderExists(path$d.join(componentsDir, "ui"))];
5880
5922
  case 2:
5881
- _a.sent();
5882
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "actions"))];
5923
+ if (_a.sent()) {
5924
+ mainExports.push("export * from './ui';");
5925
+ }
5926
+ return [4 /*yield*/, folderExists(path$d.join(componentsDir, "modals"))];
5883
5927
  case 3:
5884
- _a.sent();
5885
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "browsers"))];
5928
+ if (_a.sent()) {
5929
+ mainExports.push("export * from './modals';");
5930
+ }
5931
+ return [4 /*yield*/, folderExists(path$d.join(componentsDir, "icons"))];
5886
5932
  case 4:
5887
- _a.sent();
5888
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "systems"))];
5933
+ if (_a.sent()) {
5934
+ mainExports.push("export * from './icons';");
5935
+ }
5936
+ if (!(mainExports.length > 0)) return [3 /*break*/, 6];
5937
+ mainIndexContent = "// ONPE UI - Punto de entrada principal\n".concat(mainExports.join("\n"));
5938
+ return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "index.ts"), mainIndexContent)];
5889
5939
  case 5:
5890
5940
  _a.sent();
5891
- return [4 /*yield*/, lib.ensureDir(path$d.join(componentsDir, "icons", "onpe"))];
5941
+ _a.label = 6;
5892
5942
  case 6:
5893
- _a.sent();
5894
- mainIndexContent = "// ONPE UI - Punto de entrada principal\nexport * from './ui';\nexport * from './modals';\nexport * from './icons';\n\n// Re-exportar todo para importaciones f\u00E1ciles\nexport * from './ui/index';\nexport * from './modals/index';\nexport * from './icons/index';\n";
5895
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "index.ts"), mainIndexContent)];
5943
+ uiPath = path$d.join(componentsDir, "ui");
5944
+ return [4 /*yield*/, folderExists(uiPath)];
5896
5945
  case 7:
5897
- _a.sent();
5898
- uiIndexContent = "// Componentes UI b\u00E1sicos\nexport * from './Button';\nexport * from './Modal';\nexport * from './Overlay';\nexport * from './Portal';\nexport * from './Show';\n";
5899
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "ui", "index.ts"), uiIndexContent)];
5946
+ if (!_a.sent()) return [3 /*break*/, 10];
5947
+ return [4 /*yield*/, getFilesInFolder(uiPath)];
5900
5948
  case 8:
5901
- _a.sent();
5902
- modalsIndexContent = "// Modales especializados\nexport * from './ModalConfirm';\nexport * from './ModalLoading';\nexport * from './ModalBrowserIncompatible';\nexport * from './ModalSystemIncompatible';\n";
5903
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "modals", "index.ts"), modalsIndexContent)];
5949
+ uiFiles = _a.sent();
5950
+ if (!(uiFiles.length > 0)) return [3 /*break*/, 10];
5951
+ uiExports = uiFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
5952
+ uiIndexContent = "// Componentes b\u00E1sicos ONPE UI\n".concat(uiExports);
5953
+ return [4 /*yield*/, lib.writeFile(path$d.join(uiPath, "index.ts"), uiIndexContent)];
5904
5954
  case 9:
5905
5955
  _a.sent();
5906
- iconsIndexContent = "// Todos los iconos organizados por categor\u00EDas\nexport * from './actions';\nexport * from './browsers';\nexport * from './systems';\nexport * from './onpe';\n";
5907
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "index.ts"), iconsIndexContent)];
5956
+ _a.label = 10;
5908
5957
  case 10:
5909
- _a.sent();
5910
- actionsIndexContent = "// Iconos de Acciones\nexport * from './IconCheck';\nexport * from './IconClose';\nexport * from './IconWarning';\nexport * from './IconSpinnerDesktop';\nexport * from './IconSpinnerMobile';\nexport * from './IconHome';\n";
5911
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "actions", "index.ts"), actionsIndexContent)];
5958
+ modalsPath = path$d.join(componentsDir, "modals");
5959
+ return [4 /*yield*/, folderExists(modalsPath)];
5912
5960
  case 11:
5913
- _a.sent();
5914
- browsersIndexContent = "// Iconos de Navegadores\nexport * from './IconChrome';\nexport * from './IconChromeColor';\nexport * from './IconEdge';\nexport * from './IconEdgeColor';\nexport * from './IconMozilla';\nexport * from './IconMozillaColor';\nexport * from './IconSafari';\nexport * from './IconSafariColor';\n";
5915
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "browsers", "index.ts"), browsersIndexContent)];
5961
+ if (!_a.sent()) return [3 /*break*/, 14];
5962
+ return [4 /*yield*/, getFilesInFolder(modalsPath)];
5916
5963
  case 12:
5917
- _a.sent();
5918
- systemsIndexContent = "// Iconos de Sistemas Operativos\nexport * from './IconAndroid';\nexport * from './IconApple';\nexport * from './IconWindow';\n";
5919
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "systems", "index.ts"), systemsIndexContent)];
5964
+ modalFiles = _a.sent();
5965
+ if (!(modalFiles.length > 0)) return [3 /*break*/, 14];
5966
+ modalExports = modalFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
5967
+ modalsIndexContent = "// Modales especializados ONPE\n".concat(modalExports);
5968
+ return [4 /*yield*/, lib.writeFile(path$d.join(modalsPath, "index.ts"), modalsIndexContent)];
5920
5969
  case 13:
5921
5970
  _a.sent();
5922
- onpeIndexContent = "// Iconos de ONPE\nexport * from './IconVotoDigital';\nexport * from './IconElectionsGeneral';\nexport * from './IconElections';\n";
5923
- return [4 /*yield*/, lib.writeFile(path$d.join(componentsDir, "icons", "onpe", "index.ts"), onpeIndexContent)];
5971
+ _a.label = 14;
5924
5972
  case 14:
5973
+ iconsPath = path$d.join(componentsDir, "icons");
5974
+ return [4 /*yield*/, folderExists(iconsPath)];
5975
+ case 15:
5976
+ if (!_a.sent()) return [3 /*break*/, 27];
5977
+ iconExports = [];
5978
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "actions"))];
5979
+ case 16:
5980
+ if (_a.sent()) {
5981
+ iconExports.push("export * from './actions';");
5982
+ }
5983
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "browsers"))];
5984
+ case 17:
5985
+ if (_a.sent()) {
5986
+ iconExports.push("export * from './browsers';");
5987
+ }
5988
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "systems"))];
5989
+ case 18:
5990
+ if (_a.sent()) {
5991
+ iconExports.push("export * from './systems';");
5992
+ }
5993
+ return [4 /*yield*/, folderExists(path$d.join(iconsPath, "onpe"))];
5994
+ case 19:
5995
+ if (_a.sent()) {
5996
+ iconExports.push("export * from './onpe';");
5997
+ }
5998
+ if (!(iconExports.length > 0)) return [3 /*break*/, 21];
5999
+ iconsIndexContent = "// Iconos ONPE organizados por categor\u00EDas\n".concat(iconExports.join("\n"));
6000
+ return [4 /*yield*/, lib.writeFile(path$d.join(iconsPath, "index.ts"), iconsIndexContent)];
6001
+ case 20:
6002
+ _a.sent();
6003
+ _a.label = 21;
6004
+ case 21:
6005
+ iconCategories = ["actions", "browsers", "systems", "onpe"];
6006
+ _i = 0, iconCategories_1 = iconCategories;
6007
+ _a.label = 22;
6008
+ case 22:
6009
+ if (!(_i < iconCategories_1.length)) return [3 /*break*/, 27];
6010
+ category = iconCategories_1[_i];
6011
+ categoryPath = path$d.join(iconsPath, category);
6012
+ return [4 /*yield*/, folderExists(categoryPath)];
6013
+ case 23:
6014
+ if (!_a.sent()) return [3 /*break*/, 26];
6015
+ return [4 /*yield*/, getFilesInFolder(categoryPath)];
6016
+ case 24:
6017
+ categoryFiles = _a.sent();
6018
+ if (!(categoryFiles.length > 0)) return [3 /*break*/, 26];
6019
+ categoryExports = categoryFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
6020
+ categoryIndexContent = "// Iconos de ".concat(category, "\n").concat(categoryExports);
6021
+ return [4 /*yield*/, lib.writeFile(path$d.join(categoryPath, "index.ts"), categoryIndexContent)];
6022
+ case 25:
5925
6023
  _a.sent();
5926
- console.log("✅ Archivos de barril creados exitosamente!");
5927
- console.log("📁 Estructura creada:");
5928
- console.log(" onpe/");
5929
- console.log(" ├── index.ts (principal)");
5930
- console.log(" ├── ui/index.ts");
5931
- console.log(" ├── modals/index.ts");
5932
- console.log(" └── icons/");
5933
- console.log(" ├── index.ts");
5934
- console.log(" ├── actions/index.ts");
5935
- console.log(" ├── browsers/index.ts");
5936
- console.log(" ├── systems/index.ts");
5937
- console.log(" └── onpe/index.ts");
6024
+ _a.label = 26;
6025
+ case 26:
6026
+ _i++;
6027
+ return [3 /*break*/, 22];
6028
+ case 27:
6029
+ console.log(" Archivos de barril actualizados exitosamente!");
6030
+ console.log("📁 Solo se crearon archivos para carpetas que existen");
5938
6031
  return [2 /*return*/];
5939
6032
  }
5940
6033
  });
5941
6034
  });
5942
6035
  }
6036
+ /**
6037
+ * Crea archivos de barril solo para una carpeta específica
6038
+ */
6039
+ function createBarrelForFolder(folderPath) {
6040
+ return __awaiter(this, void 0, void 0, function () {
6041
+ var exists, files, componentFiles, exports_1, indexContent, error_1;
6042
+ return __generator(this, function (_a) {
6043
+ switch (_a.label) {
6044
+ case 0:
6045
+ _a.trys.push([0, 4, , 5]);
6046
+ return [4 /*yield*/, lib.pathExists(folderPath)];
6047
+ case 1:
6048
+ exists = _a.sent();
6049
+ if (!exists)
6050
+ return [2 /*return*/];
6051
+ return [4 /*yield*/, lib.readdir(folderPath)];
6052
+ case 2:
6053
+ files = _a.sent();
6054
+ componentFiles = files.filter(function (file) { return file.endsWith(".tsx") && !file.includes(".stories"); }).map(function (file) { return file.replace(".tsx", ""); });
6055
+ if (componentFiles.length === 0)
6056
+ return [2 /*return*/];
6057
+ exports_1 = componentFiles.map(function (file) { return "export * from './".concat(file, "';"); }).join("\n");
6058
+ indexContent = "// Componentes en esta carpeta\n".concat(exports_1);
6059
+ return [4 /*yield*/, lib.writeFile(path$d.join(folderPath, "index.ts"), indexContent)];
6060
+ case 3:
6061
+ _a.sent();
6062
+ console.log("\u2705 Archivo de barril creado para: ".concat(path$d.basename(folderPath)));
6063
+ return [3 /*break*/, 5];
6064
+ case 4:
6065
+ error_1 = _a.sent();
6066
+ console.warn("\u26A0\uFE0F No se pudo crear el archivo de barril: ".concat(error_1.message));
6067
+ return [3 /*break*/, 5];
6068
+ case 5: return [2 /*return*/];
6069
+ }
6070
+ });
6071
+ });
6072
+ }
5943
6073
 
5944
6074
  var COMPONENTS_URL = "https://raw.githubusercontent.com/ricardosv46/onpe-ui/main/src/components";
5945
6075
  var ICONS_URL = "https://raw.githubusercontent.com/ricardosv46/onpe-ui/main/src/icons";
@@ -6016,7 +6146,7 @@ function addComponent(componentName) {
6016
6146
  }
6017
6147
  _a.label = 2;
6018
6148
  case 2:
6019
- _a.trys.push([2, 16, , 17]);
6149
+ _a.trys.push([2, 17, , 18]);
6020
6150
  if (!(!isIcon && componentDependencies[componentName.toLowerCase()])) return [3 /*break*/, 8];
6021
6151
  dependencies = componentDependencies[componentName.toLowerCase()];
6022
6152
  console.log("\uD83D\uDD17 Instalando dependencias: ".concat(dependencies.join(", ")));
@@ -6059,17 +6189,21 @@ function addComponent(componentName) {
6059
6189
  console.log("\uD83D\uDCC1 ".concat(isIcon ? "Icono" : "Componente", " guardado en: ").concat(filePath));
6060
6190
  _a.label = 12;
6061
6191
  case 12:
6062
- _a.trys.push([12, 14, , 15]);
6063
- return [4 /*yield*/, createBarrelFiles()];
6192
+ _a.trys.push([12, 15, , 16]);
6193
+ return [4 /*yield*/, createBarrelForFolder(componentPath)];
6064
6194
  case 13:
6065
6195
  _a.sent();
6066
- console.log("🔄 Archivos de barril actualizados");
6067
- return [3 /*break*/, 15];
6196
+ // También actualizar el archivo de barril principal si existe
6197
+ return [4 /*yield*/, createBarrelFiles()];
6068
6198
  case 14:
6199
+ // También actualizar el archivo de barril principal si existe
6200
+ _a.sent();
6201
+ return [3 /*break*/, 16];
6202
+ case 15:
6069
6203
  barrelError_1 = _a.sent();
6070
6204
  console.warn("\u26A0\uFE0F No se pudieron actualizar los archivos de barril: ".concat(barrelError_1.message));
6071
- return [3 /*break*/, 15];
6072
- case 15:
6205
+ return [3 /*break*/, 16];
6206
+ case 16:
6073
6207
  // Mostrar instrucciones
6074
6208
  console.log("\n📋 Próximos pasos:");
6075
6209
  console.log("1. Importa el ".concat(isIcon ? "icono" : "componente", ":"));
@@ -6127,11 +6261,11 @@ function addComponent(componentName) {
6127
6261
  console.log("2. Usa el ".concat(isIcon ? "icono" : "componente", ":"));
6128
6262
  }
6129
6263
  console.log(" <".concat(componentNamePascal, " />"));
6130
- return [3 /*break*/, 17];
6131
- case 16:
6264
+ return [3 /*break*/, 18];
6265
+ case 17:
6132
6266
  error_1 = _a.sent();
6133
6267
  throw new Error("Error al instalar el ".concat(isIcon ? "icono" : "componente", ": ").concat(error_1.message));
6134
- case 17: return [2 /*return*/];
6268
+ case 18: return [2 /*return*/];
6135
6269
  }
6136
6270
  });
6137
6271
  });
@@ -6247,6 +6381,20 @@ function personalizeComponent(code, componentName) {
6247
6381
  personalizedCode = personalizedCode.replace(pattern, "from \"".concat(newPath, "\""));
6248
6382
  });
6249
6383
  });
6384
+ // Arreglar importaciones relativas dentro de la misma carpeta
6385
+ // Para componentes UI que importan otros componentes UI
6386
+ if (componentName.toLowerCase() === "modal") {
6387
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/ui\/(Portal|Overlay)"/g, function (match, component) { return "from \"./".concat(component, "\""); });
6388
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/icons\/actions\/(IconClose)"/g, function (match, component) { return "from \"../icons/actions/".concat(component, "\""); });
6389
+ }
6390
+ // Para otros componentes UI
6391
+ if (!componentName.toLowerCase().startsWith("icon-") && !componentName.toLowerCase().startsWith("modal")) {
6392
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/ui\/([^"]+)"/g, function (match, component) { return "from \"./".concat(component, "\""); });
6393
+ }
6394
+ // Para modales que importan componentes UI
6395
+ if (componentName.toLowerCase().startsWith("modal") && componentName !== "modal") {
6396
+ personalizedCode = personalizedCode.replace(/from "\.\.\/onpe\/ui\/([^"]+)"/g, function (match, component) { return "from \"../ui/".concat(component, "\""); });
6397
+ }
6250
6398
  // Agregar export default si no existe
6251
6399
  if (!personalizedCode.includes("export default")) {
6252
6400
  personalizedCode += "\n\nexport default ".concat(componentNamePascal, ";");
@@ -1,5 +1,10 @@
1
1
  /**
2
2
  * Crea archivos de barril (barrel exports) para simplificar las importaciones
3
+ * Solo crea las carpetas y archivos que realmente existen
3
4
  */
4
5
  export declare function createBarrelFiles(): Promise<void>;
6
+ /**
7
+ * Crea archivos de barril solo para una carpeta específica
8
+ */
9
+ export declare function createBarrelForFolder(folderPath: string): Promise<void>;
5
10
  //# sourceMappingURL=createBarrelFiles.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onpe/ui",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "description": "Librería completa de UI para ONPE - Componentes, Hooks, Utils y Librerías",
6
6
  "main": "dist/index.js",