zenit-sdk 0.1.8 → 0.1.9

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/index.js CHANGED
@@ -2008,6 +2008,55 @@ function useGeolocation(options) {
2008
2008
 
2009
2009
  // src/react/map/map-utils.ts
2010
2010
  var import_leaflet2 = __toESM(require("leaflet"));
2011
+
2012
+ // src/config/modalWhitelist.ts
2013
+ var SECTOR_MODAL_WHITELIST = [
2014
+ { key: "Sector", label: "Sector" },
2015
+ { key: "Promotor", label: "Promotor" },
2016
+ { key: "Capital Total", label: "Capital Total" },
2017
+ { key: "Total Capital Mora", label: "Capital en Mora" },
2018
+ { key: "Tendencia Mora", label: "Tendencia de Mora", hint: "trend_icon" },
2019
+ { key: "Tendencia Capital", label: "Tendencia de Capital", hint: "trend_icon" },
2020
+ { key: "Tendencia Castigos", label: "Tendencia de Castigos", hint: "trend_icon" },
2021
+ { key: "Impacto Sector", label: "Impacto del Sector" },
2022
+ { key: "Total Clientes Sector", label: "Total de Clientes" },
2023
+ { key: "Total Clientes Sanos", label: "Clientes Sanos" },
2024
+ { key: "Total Clientes Morosos", label: "Clientes en Mora" },
2025
+ { key: "Total Clientes Castigados", label: "Clientes Castigados" },
2026
+ { key: "Total Clientes Nuevos", label: "Clientes Nuevos" },
2027
+ { key: "Total Clientes Salidos", label: "Clientes Salidos" },
2028
+ { key: "Insights", label: "An\xE1lisis IA", hint: "collapsible" },
2029
+ { key: "Recomendaciones", label: "Recomendaciones IA", hint: "collapsible" }
2030
+ ];
2031
+ var CLIENTE_MODAL_WHITELIST = [
2032
+ { key: "nombre del cliente", label: "Nombre del Cliente" },
2033
+ { key: "dpi", label: "DPI" },
2034
+ { key: "kpi", label: "Estado", hint: "kpi_badge" },
2035
+ { key: "tel principal", label: "Tel\xE9fono", hint: "phone_link" },
2036
+ { key: "capital concedido", label: "Capital Concedido" },
2037
+ { key: "mora", label: "Monto en Mora", hint: "mora_alert" },
2038
+ { key: "etapa", label: "Etapa del Cr\xE9dito" },
2039
+ { key: "prestamo", label: "No. de Pr\xE9stamo" },
2040
+ { key: "sucursal", label: "Sucursal", aliases: ["nombre sucursal"] }
2041
+ ];
2042
+ function applyModalWhitelist(rawData, whitelist) {
2043
+ const keys = Object.keys(rawData ?? {});
2044
+ return whitelist.map(({ key, label, hint, aliases = [] }) => {
2045
+ const keysToTry = [key, ...aliases];
2046
+ let value = void 0;
2047
+ for (const k of keysToTry) {
2048
+ const match = keys.find((rawKey) => rawKey.toLowerCase() === k.toLowerCase());
2049
+ if (match !== void 0 && rawData[match] !== null && rawData[match] !== void 0) {
2050
+ value = rawData[match];
2051
+ break;
2052
+ }
2053
+ }
2054
+ if (value === void 0) return null;
2055
+ return { label, value, hint: hint ?? null };
2056
+ }).filter((entry) => Boolean(entry));
2057
+ }
2058
+
2059
+ // src/react/map/map-utils.ts
2011
2060
  var POPUP_STYLE_ID = "zenit-leaflet-popup-styles";
2012
2061
  var POPUP_EXCLUDED_KEYS = /* @__PURE__ */ new Set(["geom", "geometry", "_private"]);
2013
2062
  var POPUP_TITLE_KEYS = ["id", "nombre", "name", "title", "titulo", "cluster"];
@@ -2244,6 +2293,10 @@ function shouldIncludePopupEntry(key, value) {
2244
2293
  return true;
2245
2294
  }
2246
2295
  function createPopupContent(properties) {
2296
+ const whitelistedRows = buildWhitelistedRows(properties);
2297
+ if (whitelistedRows) {
2298
+ return whitelistedRows;
2299
+ }
2247
2300
  const header = findHeaderProperties(properties);
2248
2301
  const headerText = header.title?.value ?? extractPopupHeader(properties);
2249
2302
  const usedKeys = new Set([header.title?.key, header.badge?.key, header.description?.key].filter(Boolean));
@@ -2283,6 +2336,37 @@ function createPopupContent(properties) {
2283
2336
  }).join("");
2284
2337
  return `<div>${colorBar}${headerHtml}${descriptionHtml}${rowsHtml}</div>`;
2285
2338
  }
2339
+ function buildWhitelistedRows(properties) {
2340
+ const whitelist = selectModalWhitelist(properties);
2341
+ if (!whitelist) return null;
2342
+ const entries = applyModalWhitelist(properties, whitelist);
2343
+ if (entries.length === 0) {
2344
+ return '<div style="padding:8px 0; color:#64748b; text-align:center;">Sin datos disponibles</div>';
2345
+ }
2346
+ const rowsHtml = entries.map(({ label, value }) => {
2347
+ const valueHtml = renderPopupValue(value);
2348
+ return `
2349
+ <div style="display:grid; grid-template-columns:minmax(90px, 35%) 1fr; gap:8px; padding:6px 0; border-bottom:1px solid #e2e8f0;">
2350
+ <div style="font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.04em; color:#64748b;">${escapeHtml(label)}</div>
2351
+ <div style="font-size:13px; color:#0f172a; word-break:break-word;">${valueHtml}</div>
2352
+ </div>
2353
+ `;
2354
+ }).join("");
2355
+ return `<div>${rowsHtml}</div>`;
2356
+ }
2357
+ function countWhitelistMatches(properties, whitelist) {
2358
+ const keys = Object.keys(properties).map((key) => key.toLowerCase());
2359
+ return whitelist.reduce((count, item) => {
2360
+ const candidates = [item.key, ...item.aliases ?? []].map((candidate) => candidate.toLowerCase());
2361
+ return candidates.some((candidate) => keys.includes(candidate)) ? count + 1 : count;
2362
+ }, 0);
2363
+ }
2364
+ function selectModalWhitelist(properties) {
2365
+ const sectorMatches = countWhitelistMatches(properties, SECTOR_MODAL_WHITELIST);
2366
+ const clienteMatches = countWhitelistMatches(properties, CLIENTE_MODAL_WHITELIST);
2367
+ if (sectorMatches === 0 && clienteMatches === 0) return null;
2368
+ return sectorMatches >= clienteMatches ? SECTOR_MODAL_WHITELIST : CLIENTE_MODAL_WHITELIST;
2369
+ }
2286
2370
  function isPolygonType(layerType, geometryType) {
2287
2371
  const candidate = (layerType ?? geometryType ?? "").toLowerCase();
2288
2372
  return candidate === "polygon" || candidate === "multipolygon";