@datosgeo-atdt/geo-ui 0.11.0 → 0.11.3

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 CHANGED
@@ -651,11 +651,7 @@ import { DataTable } from '@atdt/geo-ui';
651
651
 
652
652
  function App() {
653
653
  return (
654
- <DataTable
655
- csvPath="/alcaldias.csv"
656
- width="600px"
657
- height="400px"
658
- />
654
+ <DataTable csvPath="/alcaldias.csv" />
659
655
  );
660
656
  }
661
657
  ```
@@ -666,6 +662,7 @@ function App() {
666
662
  - Los usa como headers de la tabla
667
663
  - Parsea los datos y los muestra
668
664
  - Formatea números con separadores de miles (1,815,786)
665
+ - Distribuye las columnas equitativamente (50% cada una en este caso)
669
666
 
670
667
  #### Ejemplo 2: Personalizar nombres de columnas
671
668
 
@@ -682,8 +679,6 @@ function App() {
682
679
  { key: 'alcaldia', label: 'Alcaldía', width: '60%' },
683
680
  { key: 'poblacion', label: 'Población Total', width: '40%' }
684
681
  ]}
685
- width="800px"
686
- height="500px"
687
682
  showIndex={true}
688
683
  indexLabel="#"
689
684
  />
@@ -709,34 +704,41 @@ function App() {
709
704
  <DataTable
710
705
  data={datos}
711
706
  columns={[
712
- { key: 'nombre', label: 'Ciudad', width: '50%' },
713
- { key: 'habitantes', label: 'Habitantes', width: '50%' }
707
+ { key: 'nombre', label: 'Ciudad' },
708
+ { key: 'habitantes', label: 'Habitantes' }
714
709
  ]}
715
- width="100%"
716
710
  />
717
711
  );
718
712
  }
719
713
  ```
720
714
 
721
- #### Ejemplo 4: Con índice numérico
715
+ #### Ejemplo 4: Múltiples columnas con distribución automática
722
716
 
723
717
  ```tsx
718
+ // Con 4 columnas, cada una ocupa automáticamente 25% del ancho
724
719
  <DataTable
725
- csvPath="/datos.csv"
720
+ csvPath="/productos.csv"
721
+ columns={[
722
+ { key: 'nombre', label: 'Producto' },
723
+ { key: 'categoria', label: 'Categoría' },
724
+ { key: 'precio', label: 'Precio' },
725
+ { key: 'stock', label: 'Stock' }
726
+ ]}
726
727
  showIndex={true}
727
- indexLabel="#"
728
- width="700px"
729
728
  />
730
729
  ```
731
730
 
732
- #### Ejemplo 5: Tabla responsive
731
+ #### Ejemplo 5: Control manual de anchos de columnas
733
732
 
734
733
  ```tsx
735
- // Se adapta automáticamente a móvil
734
+ // Especifica anchos personalizados cuando necesites distribución no equitativa
736
735
  <DataTable
737
- csvPath="/estadisticas.csv"
738
- width="100%"
739
- height="auto"
736
+ csvPath="/datos.csv"
737
+ columns={[
738
+ { key: 'nombre', label: 'Nombre', width: '50%' },
739
+ { key: 'valor1', label: 'Valor 1', width: '25%' },
740
+ { key: 'valor2', label: 'Valor 2', width: '25%' }
741
+ ]}
740
742
  />
741
743
  ```
742
744
 
@@ -754,11 +756,12 @@ function App() {
754
756
  | Prop | Tipo | Default | Descripción |
755
757
  |------|------|---------|-------------|
756
758
  | `columns` | `DataTableColumn[]` | Auto-detectado | Definición de columnas a mostrar |
757
- | `width` | `string` | `"100%"` | Ancho de la tabla |
758
- | `height` | `string` | `"auto"` | Alto de la tabla |
759
+ | `width` | `string` | Controlado por CSS | Ancho del contenedor (por defecto 50% del viewport en desktop, 100% en móvil) |
760
+ | `height` | `string` | Controlado por CSS | Alto del contenedor (por defecto 100% con scroll interno cuando excede 70vh) |
759
761
  | `className` | `string` | `""` | Clases CSS adicionales |
760
762
  | `showIndex` | `boolean` | `false` | Mostrar columna con índice numérico |
761
763
  | `indexLabel` | `string` | `"#"` | Etiqueta para la columna de índice |
764
+ | `onRowClick` | `(row: Record<string, any>, index: number) => void` | `undefined` | Callback que se ejecuta al hacer click en una fila. Recibe los datos de la fila y su índice |
762
765
 
763
766
  #### Tipo DataTableColumn
764
767
 
@@ -831,13 +834,16 @@ function App() {
831
834
 
832
835
  #### Ejemplo integrando con MapaPMTiles
833
836
 
837
+ Layout tipo dashboard con mapa y tabla lado a lado:
838
+
834
839
  ```tsx
835
840
  import { MapaPMTiles, DataTable } from '@atdt/geo-ui';
836
841
  import '@atdt/geo-ui/style.css';
837
842
 
838
843
  function App() {
839
844
  return (
840
- <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '20px' }}>
845
+ <div style={{ display: 'flex', width: '100%', height: '100vh' }}>
846
+ {/* Mapa ocupa 50% */}
841
847
  <MapaPMTiles
842
848
  csvPath="/datos_entidades.csv"
843
849
  fitToIds={["09", "15", "14"]}
@@ -845,20 +851,96 @@ function App() {
845
851
  enablePopup={true}
846
852
  />
847
853
 
854
+ {/* DataTable ocupa 50% automáticamente */}
848
855
  <DataTable
849
856
  csvPath="/datos_entidades.csv"
850
857
  columns={[
851
- { key: 'entidad', label: 'Entidad', width: '60%' },
852
- { key: 'valor', label: 'Valor', width: '40%' }
858
+ { key: 'entidad', label: 'Entidad' },
859
+ { key: 'valor', label: 'Valor' }
853
860
  ]}
854
- width="100%"
855
- height="600px"
856
861
  />
857
862
  </div>
858
863
  );
859
864
  }
860
865
  ```
861
866
 
867
+ #### Ejemplo con interactividad bidireccional (Tabla ↔ Mapa)
868
+
869
+ Crea interacción entre la tabla y el mapa: click en tabla hace zoom en mapa, click en mapa cambia datos de tabla:
870
+
871
+ ```tsx
872
+ import { MapaPMTiles, DataTable } from '@atdt/geo-ui';
873
+ import { useState } from 'react';
874
+ import '@atdt/geo-ui/style.css';
875
+
876
+ function App() {
877
+ const [nivel, setNivel] = useState<'entidad' | 'municipio'>('entidad');
878
+ const [selectedEnt, setSelectedEnt] = useState<string | null>(null);
879
+
880
+ return (
881
+ <div style={{ display: 'flex', width: '100%', height: '100vh' }}>
882
+ {/* Mapa con click handler */}
883
+ <MapaPMTiles
884
+ csvPath={nivel === 'entidad' ? '/prueba_entidad.csv' : `/cdmx_prueba.csv`}
885
+ fitToIds={selectedEnt ? [selectedEnt] : undefined}
886
+ mode="jenks"
887
+ showMunicipios={nivel === 'municipio'}
888
+ enablePopup={true}
889
+ />
890
+
891
+ {/* Tabla con click handler */}
892
+ <DataTable
893
+ csvPath={nivel === 'entidad' ? '/prueba_entidad.csv' : `/cdmx_prueba.csv`}
894
+ columns={
895
+ nivel === 'entidad'
896
+ ? [
897
+ { key: 'entidad', label: 'Entidad' },
898
+ { key: 'total', label: 'Total' }
899
+ ]
900
+ : [
901
+ { key: 'municipio', label: 'Municipio' },
902
+ { key: 'valor', label: 'Valor' }
903
+ ]
904
+ }
905
+ onRowClick={(row) => {
906
+ if (nivel === 'entidad') {
907
+ // Click en tabla de entidades → zoom a esa entidad y muestra municipios
908
+ setSelectedEnt(row.cvegeo);
909
+ setNivel('municipio');
910
+ }
911
+ }}
912
+ />
913
+
914
+ {/* Botón para regresar */}
915
+ {nivel === 'municipio' && (
916
+ <button
917
+ style={{
918
+ position: 'absolute',
919
+ top: 20,
920
+ left: 20,
921
+ zIndex: 1000,
922
+ padding: '10px 20px'
923
+ }}
924
+ onClick={() => {
925
+ setNivel('entidad');
926
+ setSelectedEnt(null);
927
+ }}
928
+ >
929
+ ← Regresar a entidades
930
+ </button>
931
+ )}
932
+ </div>
933
+ );
934
+ }
935
+ ```
936
+
937
+ **Flujo de interacción:**
938
+ 1. **Vista inicial**: Muestra tabla con entidades (`prueba_entidad.csv`)
939
+ 2. **Click en fila de tabla**: Cambia a vista de municipios de esa entidad
940
+ 3. **Mapa hace zoom**: Automáticamente hacia la entidad seleccionada
941
+ 4. **Tabla cambia**: Muestra datos municipales (`cdmx_prueba.csv`)
942
+ 5. **Botón "Regresar"**: Vuelve a la vista de entidades
943
+
862
944
  ### Formato de Números
863
945
 
864
946
  Los números se formatean automáticamente con separadores de miles usando el formato mexicano:
@@ -876,15 +958,23 @@ El componente muestra diferentes estados:
876
958
  3. **Vacío**: "No hay datos para mostrar" si el CSV está vacío
877
959
  4. **Datos**: Tabla renderizada con los datos
878
960
 
879
- ### Responsive
961
+ ### Diseño y Layout
962
+
963
+ El componente está diseñado para integrarse con layouts tipo dashboard:
880
964
 
881
- El componente se adapta automáticamente a diferentes tamaños de pantalla:
965
+ - **Desktop**:
966
+ - Ocupa **50% del ancho** del contenedor padre por defecto
967
+ - Centrado vertical y horizontal
968
+ - Scroll interno cuando el contenido excede **70vh**
969
+ - Headers y celdas con tamaño `1.11vw`
970
+ - Columnas se distribuyen automáticamente usando flexbox
882
971
 
883
- - **Desktop**: Headers y celdas con tamaño `1.11vw`
884
972
  - **Mobile** (≤600px):
973
+ - Ocupa **100% del ancho**
885
974
  - Headers con tamaño `3.5vw`
886
975
  - Celdas con tamaño `4vw`
887
976
  - Padding ajustado para pantallas pequeñas
977
+ - Box shadow más pronunciado
888
978
 
889
979
  ### Personalización de Estilos
890
980
 
@@ -13,6 +13,7 @@ export interface DataTableProps {
13
13
  className?: string;
14
14
  showIndex?: boolean;
15
15
  indexLabel?: string;
16
+ onRowClick?: (row: Record<string, any>, index: number) => void;
16
17
  }
17
18
  declare const DataTable: React.FC<DataTableProps>;
18
19
  export default DataTable;
@@ -1 +1 @@
1
- {"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../src/components/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,MAAM,WAAW,eAAe;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqKvC,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