flexablelib 3.0.3__tar.gz → 3.1.0__tar.gz

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.
Files changed (82) hide show
  1. {flexablelib-3.0.3 → flexablelib-3.1.0}/CHANGELOG.md +28 -0
  2. {flexablelib-3.0.3/flexablelib.egg-info → flexablelib-3.1.0}/PKG-INFO +89 -1
  3. {flexablelib-3.0.3 → flexablelib-3.1.0}/README.md +88 -0
  4. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/__init__.py +3 -1
  5. flexablelib-3.1.0/flexablelib/layout.py +1177 -0
  6. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/table.py +540 -56
  7. {flexablelib-3.0.3 → flexablelib-3.1.0/flexablelib.egg-info}/PKG-INFO +89 -1
  8. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib.egg-info/SOURCES.txt +2 -0
  9. {flexablelib-3.0.3 → flexablelib-3.1.0}/package.json +1 -1
  10. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/conftest.py +13 -10
  11. flexablelib-3.1.0/tests/test_v310_layout.py +573 -0
  12. {flexablelib-3.0.3 → flexablelib-3.1.0}/LICENSE +0 -0
  13. {flexablelib-3.0.3 → flexablelib-3.1.0}/MANIFEST.in +0 -0
  14. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/_speedups.c +0 -0
  15. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/_width_tables.h +0 -0
  16. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/box_topology.py +0 -0
  17. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/cells.py +0 -0
  18. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/colors.py +0 -0
  19. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/columns.py +0 -0
  20. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/fast.py +0 -0
  21. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/merges.py +0 -0
  22. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/options.py +0 -0
  23. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/py.typed +0 -0
  24. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/readers.py +0 -0
  25. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/style_compositions.py +0 -0
  26. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/table_strings.py +0 -0
  27. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/text_width.py +0 -0
  28. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/utils.py +0 -0
  29. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib/writers.py +0 -0
  30. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib.egg-info/dependency_links.txt +0 -0
  31. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib.egg-info/requires.txt +0 -0
  32. {flexablelib-3.0.3 → flexablelib-3.1.0}/flexablelib.egg-info/top_level.txt +0 -0
  33. {flexablelib-3.0.3 → flexablelib-3.1.0}/pytest.ini +0 -0
  34. {flexablelib-3.0.3 → flexablelib-3.1.0}/setup.cfg +0 -0
  35. {flexablelib-3.0.3 → flexablelib-3.1.0}/setup.py +0 -0
  36. {flexablelib-3.0.3 → flexablelib-3.1.0}/style_examples.md +0 -0
  37. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/helpers.py +0 -0
  38. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_align_indicators.py +0 -0
  39. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_box_topology.py +0 -0
  40. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_cells.py +0 -0
  41. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_columns.py +0 -0
  42. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_excel.py +0 -0
  43. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_features.py +0 -0
  44. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_issues.py +0 -0
  45. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_merge_edge_matrix.py +0 -0
  46. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_merge_fill.py +0 -0
  47. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_merges.py +0 -0
  48. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_public_api_edges.py +0 -0
  49. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_readme_examples.py +0 -0
  50. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_stress_matrix.py +0 -0
  51. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_style_line_widths.py +0 -0
  52. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_styles.py +0 -0
  53. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_text_width.py +0 -0
  54. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_two_pass_measurement.py +0 -0
  55. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_upstream_issues.py +0 -0
  56. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v2021_fixes.py +0 -0
  57. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v210_rows_copy.py +0 -0
  58. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v2110_fixes.py +0 -0
  59. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v211_fixes.py +0 -0
  60. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v213_features.py +0 -0
  61. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v214_features.py +0 -0
  62. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v215_features.py +0 -0
  63. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v216_features.py +0 -0
  64. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v217_features.py +0 -0
  65. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v218_features.py +0 -0
  66. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v219_coverage.py +0 -0
  67. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v219_fixes.py +0 -0
  68. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v220_exports.py +0 -0
  69. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v221_fixes.py +0 -0
  70. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v222_fixes.py +0 -0
  71. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v223_fixes.py +0 -0
  72. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v224_fixes.py +0 -0
  73. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v230_none.py +0 -0
  74. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v231_fixes.py +0 -0
  75. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v232_merge_ansi.py +0 -0
  76. {flexablelib-3.0.3 → flexablelib-3.1.0}/tests/test_v300_style_names.py +0 -0
  77. {flexablelib-3.0.3 → flexablelib-3.1.0}/tools/benchmark.py +0 -0
  78. {flexablelib-3.0.3 → flexablelib-3.1.0}/tools/generate_width_tables.py +0 -0
  79. {flexablelib-3.0.3 → flexablelib-3.1.0}/tools/readme_gallery.py +0 -0
  80. {flexablelib-3.0.3 → flexablelib-3.1.0}/tools/stress_matrix.py +0 -0
  81. {flexablelib-3.0.3 → flexablelib-3.1.0}/tools/style_examples.py +0 -0
  82. {flexablelib-3.0.3 → flexablelib-3.1.0}/tools/text_to_png.py +0 -0
@@ -2,6 +2,34 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [3.1.0] - 2026-11-11
6
+
7
+ ### Added
8
+ - `Card`: one record in a frame, in any of the 54 styles and the 15
9
+ themes. The title goes into the top border (`╭─ Title ───╮`) when the
10
+ style draws one; subtitle, `label value` fields (or a grid of tiles with
11
+ `field_columns=2`/`'auto'`), any renderable as `body`, footer and
12
+ `[ action ]` chips. Colours fill the card frame to frame; panel and
13
+ shadow work as on tables.
14
+ - `Grid` and `GridCell`: lay cards, tables, text and other grids out in
15
+ columns that reflow with the width (`columns='auto'` or n, `min_width`,
16
+ spans, nesting, equal-height rows) -- a grid of cards or a whole terminal
17
+ screen.
18
+ - `Table.render(width)` / `responsive=True`: the table when it fits, then
19
+ squeezed, then without low-priority columns (`column_priority`), then as
20
+ cards (`to_cards()`) in a responsive grid. `breakpoints`,
21
+ `card_options`, `render_mode()` and `natural_width()`.
22
+ - `Table.subtitle`, `title_position='border'`, `caption_position='border'`,
23
+ `title_align`, `title_color`. A border title never covers a corner or a
24
+ column junction; it falls back to a line above.
25
+ - `flexablelib.layout.wrap_panel` / `add_shadow`, shared by tables and
26
+ cards.
27
+
28
+ ### Fixed
29
+ - Columns in `hide_columns` no longer count toward the width the fit pass
30
+ has to save, so a table that fits once they are hidden is no longer
31
+ squeezed as if they were still drawn.
32
+
5
33
  ## [3.0.3] - 2026-11-11
6
34
 
7
35
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib
3
- Version: 3.0.3
3
+ Version: 3.1.0
4
4
  Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez
@@ -504,6 +504,94 @@ table.merge_cells(0, 0, 2, 2, value='Total', align='r')
504
504
  A merge never widens the table -- columns are still sized by their unmerged
505
505
  content -- so text longer than its span is truncated.
506
506
 
507
+ ## Cards, grids and responsive tables
508
+
509
+ `Card` draws one record in a frame, in any of the table styles. The title goes
510
+ into the top border when the style draws one:
511
+
512
+ ```python
513
+ from flexablelib import Card
514
+
515
+ card = Card(title='Ana', subtitle='Norte',
516
+ fields={'Edad': 28, 'Ciudad': 'Guadalajara'},
517
+ footer='actualizado hoy')
518
+ print(card.render(width=30))
519
+ ```
520
+
521
+ ```
522
+ ╭─ Ana ──────────────────────╮
523
+ │ Norte │
524
+ ├────────────────────────────┤
525
+ │ Edad 28 │
526
+ │ Ciudad Guadalajara │
527
+ ├────────────────────────────┤
528
+ │ actualizado hoy │
529
+ ╰────────────────────────────╯
530
+ ```
531
+
532
+ `field_columns=2` (or `'auto'`) lays the fields out as a grid of tiles, and
533
+ `actions` adds `[ Action ]` chips:
534
+
535
+ ```
536
+ ╭─ Pedido 42 ────────────────────╮
537
+ │ Cliente Total │
538
+ │ José $1,200 │
539
+ │ Estado Fecha │
540
+ │ Enviado 11/11 │
541
+ ├────────────────────────────────┤
542
+ │ [ Ver ] [ Editar ] │
543
+ ╰────────────────────────────────╯
544
+ ```
545
+
546
+ Cards take `style_name`, `theme` (the table themes), `border_color`,
547
+ `title_color`, `label_color`, `value_colors`, `color` (a background for the
548
+ whole card), `zebra`, `panel` and `shadow`.
549
+
550
+ `table.render(width)` makes a table responsive: the normal table when it fits,
551
+ without its low-priority columns next, squeezed and wrapped after that, and
552
+ one card per row when nothing else fits. `width` defaults to
553
+ `max_width`, then the terminal width; `responsive=True` makes `print(table)` do
554
+ the same.
555
+
556
+ ```python
557
+ table.title, table.title_position = 'Personas', 'border'
558
+ table.column_priority = {'Correo': 3} # hidden first
559
+ table.card_options = {'subtitle_field': 'Grupo', 'fields': ['Edad', 'Ciudad']}
560
+ table.render(width=80) # table
561
+ table.render(width=46) # table without "Correo"
562
+ table.render(width=30) # cards
563
+ ```
564
+
565
+ ```
566
+ ╭─────────┬────────┬──────┬─ Personas ──┬──────────────────╮
567
+ │ Nombre │ Grupo │ Edad │ Ciudad │ Correo │
568
+ ├─────────┼────────┼──────┼─────────────┼──────────────────┤
569
+ │ Ana │ Norte │ 28 │ Guadalajara │ ana@example.com │
570
+ │ Luna 🌸 │ Centro │ 22 │ Mérida │ luna@example.com │
571
+ ╰─────────┴────────┴──────┴─────────────┴──────────────────╯
572
+
573
+ Personas
574
+ ╭─ Ana ──────────────────────╮
575
+ │ Norte │
576
+ ├────────────────────────────┤
577
+ │ Edad 28 │
578
+ │ Ciudad Guadalajara │
579
+ ╰────────────────────────────╯
580
+ ```
581
+
582
+ `Grid` places cards, tables, text and other grids in columns that reflow with
583
+ the width -- a grid of cards or a whole terminal screen:
584
+
585
+ ```python
586
+ from flexablelib import Grid, GridCell
587
+
588
+ Grid(table.to_cards(), min_width=28).render(width=100) # 3 columns, 2 at 62, 1 at 40
589
+ Grid([GridCell('Ventas de noviembre', span=3),
590
+ GridCell(table, span=2), Grid(cards, columns=1)], columns=3)
591
+ ```
592
+
593
+ More in [docs/LAYOUT.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/LAYOUT.md).
594
+
507
595
  ## Notes
508
596
 
509
597
  - A column named ``"i"`` does not collide with the index column (`utils.IndexColumnTitle`).
@@ -439,6 +439,94 @@ table.merge_cells(0, 0, 2, 2, value='Total', align='r')
439
439
  A merge never widens the table -- columns are still sized by their unmerged
440
440
  content -- so text longer than its span is truncated.
441
441
 
442
+ ## Cards, grids and responsive tables
443
+
444
+ `Card` draws one record in a frame, in any of the table styles. The title goes
445
+ into the top border when the style draws one:
446
+
447
+ ```python
448
+ from flexablelib import Card
449
+
450
+ card = Card(title='Ana', subtitle='Norte',
451
+ fields={'Edad': 28, 'Ciudad': 'Guadalajara'},
452
+ footer='actualizado hoy')
453
+ print(card.render(width=30))
454
+ ```
455
+
456
+ ```
457
+ ╭─ Ana ──────────────────────╮
458
+ │ Norte │
459
+ ├────────────────────────────┤
460
+ │ Edad 28 │
461
+ │ Ciudad Guadalajara │
462
+ ├────────────────────────────┤
463
+ │ actualizado hoy │
464
+ ╰────────────────────────────╯
465
+ ```
466
+
467
+ `field_columns=2` (or `'auto'`) lays the fields out as a grid of tiles, and
468
+ `actions` adds `[ Action ]` chips:
469
+
470
+ ```
471
+ ╭─ Pedido 42 ────────────────────╮
472
+ │ Cliente Total │
473
+ │ José $1,200 │
474
+ │ Estado Fecha │
475
+ │ Enviado 11/11 │
476
+ ├────────────────────────────────┤
477
+ │ [ Ver ] [ Editar ] │
478
+ ╰────────────────────────────────╯
479
+ ```
480
+
481
+ Cards take `style_name`, `theme` (the table themes), `border_color`,
482
+ `title_color`, `label_color`, `value_colors`, `color` (a background for the
483
+ whole card), `zebra`, `panel` and `shadow`.
484
+
485
+ `table.render(width)` makes a table responsive: the normal table when it fits,
486
+ without its low-priority columns next, squeezed and wrapped after that, and
487
+ one card per row when nothing else fits. `width` defaults to
488
+ `max_width`, then the terminal width; `responsive=True` makes `print(table)` do
489
+ the same.
490
+
491
+ ```python
492
+ table.title, table.title_position = 'Personas', 'border'
493
+ table.column_priority = {'Correo': 3} # hidden first
494
+ table.card_options = {'subtitle_field': 'Grupo', 'fields': ['Edad', 'Ciudad']}
495
+ table.render(width=80) # table
496
+ table.render(width=46) # table without "Correo"
497
+ table.render(width=30) # cards
498
+ ```
499
+
500
+ ```
501
+ ╭─────────┬────────┬──────┬─ Personas ──┬──────────────────╮
502
+ │ Nombre │ Grupo │ Edad │ Ciudad │ Correo │
503
+ ├─────────┼────────┼──────┼─────────────┼──────────────────┤
504
+ │ Ana │ Norte │ 28 │ Guadalajara │ ana@example.com │
505
+ │ Luna 🌸 │ Centro │ 22 │ Mérida │ luna@example.com │
506
+ ╰─────────┴────────┴──────┴─────────────┴──────────────────╯
507
+
508
+ Personas
509
+ ╭─ Ana ──────────────────────╮
510
+ │ Norte │
511
+ ├────────────────────────────┤
512
+ │ Edad 28 │
513
+ │ Ciudad Guadalajara │
514
+ ╰────────────────────────────╯
515
+ ```
516
+
517
+ `Grid` places cards, tables, text and other grids in columns that reflow with
518
+ the width -- a grid of cards or a whole terminal screen:
519
+
520
+ ```python
521
+ from flexablelib import Grid, GridCell
522
+
523
+ Grid(table.to_cards(), min_width=28).render(width=100) # 3 columns, 2 at 62, 1 at 40
524
+ Grid([GridCell('Ventas de noviembre', span=3),
525
+ GridCell(table, span=2), Grid(cards, columns=1)], columns=3)
526
+ ```
527
+
528
+ More in [docs/LAYOUT.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/LAYOUT.md).
529
+
442
530
  ## Notes
443
531
 
444
532
  - A column named ``"i"`` does not collide with the index column (`utils.IndexColumnTitle`).
@@ -1,6 +1,8 @@
1
1
  from .table import Table
2
2
  from .style_compositions import TableComposition, SeparatorLine
3
+ from .layout import Card, Grid, GridCell
3
4
 
4
5
  # Names, not the objects themselves: `from flexablelib import *` walks this
5
6
  # list and raises TypeError on anything that is not a string.
6
- __all__ = ['Table', 'TableComposition', 'SeparatorLine']
7
+ __all__ = ['Table', 'TableComposition', 'SeparatorLine', 'Card', 'Grid',
8
+ 'GridCell']