flexablelib-components 3.7.3__tar.gz → 3.7.4__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.
- {flexablelib_components-3.7.3/flexablelib_components.egg-info → flexablelib_components-3.7.4}/PKG-INFO +3 -3
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/__init__.py +1 -1
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/base.py +17 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/data.py +6 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/display.py +12 -12
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/inputs.py +9 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/navigation.py +18 -12
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4/flexablelib_components.egg-info}/PKG-INFO +3 -3
- flexablelib_components-3.7.4/flexablelib_components.egg-info/requires.txt +2 -0
- flexablelib_components-3.7.3/flexablelib_components.egg-info/requires.txt +0 -2
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/LICENSE +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/MANIFEST.in +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/README.md +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/dates.py +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/media.py +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/overlays.py +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/py.typed +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components.egg-info/SOURCES.txt +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components.egg-info/dependency_links.txt +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components.egg-info/top_level.txt +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/setup.cfg +0 -0
- {flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib-components
|
|
3
|
-
Version: 3.7.
|
|
3
|
+
Version: 3.7.4
|
|
4
4
|
Summary: Interactive terminal components for flexablelib: inputs, dates, tables, forms, menus, tabs, dialogs and more.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -17,8 +17,8 @@ Classifier: Topic :: Software Development :: User Interfaces
|
|
|
17
17
|
Requires-Python: >=3.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: flexablelib>=3.7.
|
|
21
|
-
Requires-Dist: flexablelib-tui>=3.7.
|
|
20
|
+
Requires-Dist: flexablelib>=3.7.4
|
|
21
|
+
Requires-Dist: flexablelib-tui>=3.7.4
|
|
22
22
|
Dynamic: author
|
|
23
23
|
Dynamic: author-email
|
|
24
24
|
Dynamic: classifier
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/__init__.py
RENAMED
|
@@ -18,7 +18,7 @@ keys to the focused component) and also renders on its own with
|
|
|
18
18
|
``render(width)``. See docs/COMPONENTS.md.
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
-
__version__ = '3.7.
|
|
21
|
+
__version__ = '3.7.4'
|
|
22
22
|
|
|
23
23
|
from .base import Theme, DEFAULT_THEME, Input, Box, Button, frame
|
|
24
24
|
from .inputs import (TextInput, PasswordInput, NumberInput, ExpressionInput,
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/base.py
RENAMED
|
@@ -281,6 +281,23 @@ def frame(lines, width, title=None, color=None, painter=None, style='rounded',
|
|
|
281
281
|
return out
|
|
282
282
|
|
|
283
283
|
|
|
284
|
+
def pairs(items):
|
|
285
|
+
"""``items`` (a mapping or a sequence) as a list of ``(key, value)``
|
|
286
|
+
pairs. A bare string, or a one-item tuple, is a key with no value
|
|
287
|
+
(``None``) -- not a pair made of the string's first two characters."""
|
|
288
|
+
if isinstance(items, dict):
|
|
289
|
+
return list(items.items())
|
|
290
|
+
out = []
|
|
291
|
+
for item in items:
|
|
292
|
+
if isinstance(item, str):
|
|
293
|
+
out.append((item, None))
|
|
294
|
+
elif len(item) < 2:
|
|
295
|
+
out.append((tuple(item) + (None, None))[:2])
|
|
296
|
+
else:
|
|
297
|
+
out.append(item)
|
|
298
|
+
return out
|
|
299
|
+
|
|
300
|
+
|
|
284
301
|
def join_columns(blocks, widths, gap=1):
|
|
285
302
|
"""Side-by-side blocks of lines, each fitted to its width."""
|
|
286
303
|
height = max((len(b) for b in blocks), default=0)
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/data.py
RENAMED
|
@@ -436,6 +436,9 @@ class DataTable(_Themed):
|
|
|
436
436
|
self.top = self.cursor_row
|
|
437
437
|
if self.cursor_row >= self.top + rows_h:
|
|
438
438
|
self.top = self.cursor_row - rows_h + 1
|
|
439
|
+
# Taller again (a resize): fill the room from above instead of
|
|
440
|
+
# keeping the rows the short layout scrolled to at the top.
|
|
441
|
+
self.top = max(0, min(self.top, len(view) - rows_h))
|
|
439
442
|
stop = self.top + rows_h
|
|
440
443
|
if self.page_size:
|
|
441
444
|
stop = min(stop, (self.page) * self.page_size)
|
|
@@ -919,6 +922,9 @@ class CatalogGrid(_Themed):
|
|
|
919
922
|
self.top_row = row_of
|
|
920
923
|
if row_of >= self.top_row + visible_rows:
|
|
921
924
|
self.top_row = row_of - visible_rows + 1
|
|
925
|
+
# More columns or rows of room (a resize): no empty rows of cards
|
|
926
|
+
# below while earlier ones stay scrolled out above.
|
|
927
|
+
self.top_row = max(0, min(self.top_row, n_rows - visible_rows))
|
|
922
928
|
out = []
|
|
923
929
|
for r in range(self.top_row, min(n_rows, self.top_row +
|
|
924
930
|
visible_rows)):
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/display.py
RENAMED
|
@@ -14,7 +14,7 @@ from flexablelib.text_width import wrap_to_width
|
|
|
14
14
|
|
|
15
15
|
from flexablelib_tui import accessibility as _a11y
|
|
16
16
|
|
|
17
|
-
from .base import _Themed, frame
|
|
17
|
+
from .base import _Themed, frame, pairs
|
|
18
18
|
|
|
19
19
|
__all__ = ['Badge', 'Tag', 'StatusBadge', 'Alert', 'Link', 'Breadcrumbs',
|
|
20
20
|
'EmptyState', 'ErrorPanel', 'Spinner', 'Skeleton', 'Code',
|
|
@@ -812,26 +812,26 @@ class HtmlView(MarkdownView):
|
|
|
812
812
|
class DetailView(_Themed):
|
|
813
813
|
"""
|
|
814
814
|
Labelled values in aligned columns -- a record's detail. ``fields`` is a
|
|
815
|
-
mapping or ``(label, value)`` pairs
|
|
816
|
-
section heading. ``columns=2`` lays the pairs out in two columns.
|
|
815
|
+
mapping or ``(label, value)`` pairs (a bare label has no value); a
|
|
816
|
+
label starting with ``#`` is a section heading. ``columns=2`` lays the pairs out in two columns.
|
|
817
817
|
"""
|
|
818
818
|
|
|
819
819
|
role = 'list'
|
|
820
820
|
|
|
821
821
|
def a11y_value(self):
|
|
822
|
-
return '; '.join('{0}: {1}'.format(k, v)
|
|
822
|
+
return '; '.join(str(k) if v is None else '{0}: {1}'.format(k, v)
|
|
823
|
+
for k, v in self.fields
|
|
823
824
|
if not str(k).startswith('#'))
|
|
824
825
|
|
|
825
826
|
def __init__(self, fields, columns=1, label_color=None, **kwargs):
|
|
826
827
|
super(DetailView, self).__init__(**kwargs)
|
|
827
|
-
self.fields =
|
|
828
|
-
else list(fields)
|
|
828
|
+
self.fields = pairs(fields)
|
|
829
829
|
self.columns = max(1, int(columns))
|
|
830
830
|
self.label_color = label_color
|
|
831
831
|
|
|
832
832
|
def natural_width(self):
|
|
833
|
-
widths = [_fx.visible_width(str(k)) + _fx.visible_width(
|
|
834
|
-
for k, v in self.fields]
|
|
833
|
+
widths = [_fx.visible_width(str(k)) + 2 + _fx.visible_width(
|
|
834
|
+
'' if v is None else str(v)) for k, v in self.fields]
|
|
835
835
|
return min(100, max(widths or [10]) * self.columns +
|
|
836
836
|
3 * (self.columns - 1))
|
|
837
837
|
|
|
@@ -1054,8 +1054,8 @@ def human_size(size):
|
|
|
1054
1054
|
|
|
1055
1055
|
|
|
1056
1056
|
class AttachmentList(_Themed):
|
|
1057
|
-
"""Files with an icon by type, name and size: ``(name, size)`` pairs
|
|
1058
|
-
dicts with ``name`` and ``size``."""
|
|
1057
|
+
"""Files with an icon by type, name and size: ``(name, size)`` pairs,
|
|
1058
|
+
bare names (no size) or dicts with ``name`` and ``size``."""
|
|
1059
1059
|
|
|
1060
1060
|
ICONS = {'pdf': '📕', 'xlsx': '📗', 'xls': '📗', 'csv': '📗', 'doc': '📘',
|
|
1061
1061
|
'docx': '📘', 'png': '🖼', 'jpg': '🖼', 'jpeg': '🖼', 'gif': '🖼',
|
|
@@ -1069,8 +1069,8 @@ class AttachmentList(_Themed):
|
|
|
1069
1069
|
|
|
1070
1070
|
def __init__(self, files, **kwargs):
|
|
1071
1071
|
super(AttachmentList, self).__init__(**kwargs)
|
|
1072
|
-
self.files =
|
|
1073
|
-
|
|
1072
|
+
self.files = pairs((f.get('name'), f.get('size'))
|
|
1073
|
+
if isinstance(f, dict) else f for f in files)
|
|
1074
1074
|
|
|
1075
1075
|
def draw(self, width, height):
|
|
1076
1076
|
out = []
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/inputs.py
RENAMED
|
@@ -267,6 +267,12 @@ class TextInput(Input):
|
|
|
267
267
|
self.scroll_x = cursor_col
|
|
268
268
|
if cursor_col >= self.scroll_x + avail:
|
|
269
269
|
self.scroll_x = cursor_col - avail + 1
|
|
270
|
+
# Never scrolled further than the text needs: once the field is
|
|
271
|
+
# wide enough again (a resize, a shorter value), it shows from the
|
|
272
|
+
# start instead of keeping only the tail it showed when narrow.
|
|
273
|
+
needed = sum(widths) + (1 if self.focused and
|
|
274
|
+
self.cursor_pos >= len(shown) else 0)
|
|
275
|
+
self.scroll_x = max(0, min(self.scroll_x, needed - avail))
|
|
270
276
|
out, col = [], 0
|
|
271
277
|
for i, (char, w) in enumerate(zip(shown, widths)):
|
|
272
278
|
if col >= self.scroll_x and col + w <= self.scroll_x + avail:
|
|
@@ -782,6 +788,9 @@ class TextArea(Input):
|
|
|
782
788
|
self.scroll_y = cur
|
|
783
789
|
if cur >= self.scroll_y + self.rows:
|
|
784
790
|
self.scroll_y = cur - self.rows + 1
|
|
791
|
+
# Wider again (fewer wrapped lines): fill the box from the top
|
|
792
|
+
# instead of keeping the offset the narrow layout needed.
|
|
793
|
+
self.scroll_y = max(0, min(self.scroll_y, len(segs) - self.rows))
|
|
785
794
|
out = []
|
|
786
795
|
if not self.text and not self.focused and self.placeholder:
|
|
787
796
|
out.append(marker + ' ' + self.paint(self.placeholder,
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/navigation.py
RENAMED
|
@@ -10,7 +10,7 @@ from flexablelib.layout import _accepts_height, _natural_width, _render_child
|
|
|
10
10
|
|
|
11
11
|
from flexablelib_tui import Key
|
|
12
12
|
|
|
13
|
-
from .base import Button, _Themed, frame, join_columns
|
|
13
|
+
from .base import Button, _Themed, frame, join_columns, pairs
|
|
14
14
|
|
|
15
15
|
_Enter = Key('enter')
|
|
16
16
|
|
|
@@ -39,7 +39,8 @@ def render_into(child, width, height=None):
|
|
|
39
39
|
|
|
40
40
|
class Tabs(_Themed):
|
|
41
41
|
"""
|
|
42
|
-
Tabbed panes: ``tabs`` is a mapping (or pairs) of title to content
|
|
42
|
+
Tabbed panes: ``tabs`` is a mapping (or pairs) of title to content; a
|
|
43
|
+
bare title is a tab with no content.
|
|
43
44
|
Left/Right (or 1-9) switch while the tab bar has the focus; the content's
|
|
44
45
|
own components follow it in the focus order. ``on_change(index)``.
|
|
45
46
|
"""
|
|
@@ -56,8 +57,7 @@ class Tabs(_Themed):
|
|
|
56
57
|
|
|
57
58
|
def __init__(self, tabs, index=0, on_change=None, **kwargs):
|
|
58
59
|
super(Tabs, self).__init__(**kwargs)
|
|
59
|
-
self.tabs =
|
|
60
|
-
else list(tabs)
|
|
60
|
+
self.tabs = pairs(tabs)
|
|
61
61
|
self.index = index
|
|
62
62
|
self.on_change = on_change
|
|
63
63
|
|
|
@@ -70,7 +70,8 @@ class Tabs(_Themed):
|
|
|
70
70
|
|
|
71
71
|
def form_children(self):
|
|
72
72
|
"""Every pane, shown or not (the fields a form collects)."""
|
|
73
|
-
return [c for _, c in self.tabs
|
|
73
|
+
return [c for _, c in self.tabs
|
|
74
|
+
if c is not None and not isinstance(c, str)]
|
|
74
75
|
|
|
75
76
|
def natural_width(self):
|
|
76
77
|
bar = sum(_fx.visible_width(t) + 3 for t, _ in self.tabs)
|
|
@@ -706,7 +707,8 @@ class Toolbar(_Themed):
|
|
|
706
707
|
class Wizard(_Themed):
|
|
707
708
|
"""
|
|
708
709
|
Steps with a stepper on top, the current step's content, and Back /
|
|
709
|
-
Next / Finish buttons. ``steps`` are ``(title, content)`` pairs
|
|
710
|
+
Next / Finish buttons. ``steps`` are ``(title, content)`` pairs (or bare
|
|
711
|
+
titles);
|
|
710
712
|
``validate(index) -> error or None`` guards Next; ``on_finish()``.
|
|
711
713
|
Ctrl-N / Ctrl-P move too.
|
|
712
714
|
"""
|
|
@@ -725,7 +727,7 @@ class Wizard(_Themed):
|
|
|
725
727
|
|
|
726
728
|
def __init__(self, steps, on_finish=None, validate=None, **kwargs):
|
|
727
729
|
super(Wizard, self).__init__(**kwargs)
|
|
728
|
-
self.steps =
|
|
730
|
+
self.steps = pairs(steps)
|
|
729
731
|
self.index = 0
|
|
730
732
|
self.on_finish = on_finish
|
|
731
733
|
self.check = validate
|
|
@@ -806,7 +808,8 @@ class Wizard(_Themed):
|
|
|
806
808
|
|
|
807
809
|
class Accordion(_Themed):
|
|
808
810
|
"""
|
|
809
|
-
Collapsible sections: ``sections`` are ``(title, content)`` pairs
|
|
811
|
+
Collapsible sections: ``sections`` are ``(title, content)`` pairs (or a
|
|
812
|
+
mapping; a bare title is a section with no content). Up/Down
|
|
810
813
|
move between headers, Enter/Space toggle; ``multiple=False`` keeps one
|
|
811
814
|
open at a time. A single section works as a collapsible panel.
|
|
812
815
|
"""
|
|
@@ -831,19 +834,20 @@ class Accordion(_Themed):
|
|
|
831
834
|
|
|
832
835
|
def __init__(self, sections, open=(0,), multiple=True, **kwargs):
|
|
833
836
|
super(Accordion, self).__init__(**kwargs)
|
|
834
|
-
self.sections =
|
|
835
|
-
else list(sections)
|
|
837
|
+
self.sections = pairs(sections)
|
|
836
838
|
self.opened = set(open or ())
|
|
837
839
|
self.multiple = bool(multiple)
|
|
838
840
|
self.index = 0
|
|
839
841
|
|
|
840
842
|
def children(self):
|
|
841
843
|
return [c for i, (_, c) in enumerate(self.sections)
|
|
842
|
-
if i in self.opened and not
|
|
844
|
+
if i in self.opened and c is not None
|
|
845
|
+
and not isinstance(c, str)]
|
|
843
846
|
|
|
844
847
|
def form_children(self):
|
|
845
848
|
"""Every section, open or not (the fields a form collects)."""
|
|
846
|
-
return [c for _, c in self.sections
|
|
849
|
+
return [c for _, c in self.sections
|
|
850
|
+
if c is not None and not isinstance(c, str)]
|
|
847
851
|
|
|
848
852
|
def natural_width(self):
|
|
849
853
|
return max([_natural_width(c) + 2 for _, c in self.sections] +
|
|
@@ -1108,6 +1112,8 @@ class Tree(_Themed):
|
|
|
1108
1112
|
self.top = self.index
|
|
1109
1113
|
if self.index >= self.top + view:
|
|
1110
1114
|
self.top = self.index - view + 1
|
|
1115
|
+
# Taller again, or nodes collapsed: fill the room from above.
|
|
1116
|
+
self.top = max(0, min(self.top, len(rows) - view))
|
|
1111
1117
|
out = []
|
|
1112
1118
|
for i in range(self.top, min(len(rows), self.top + view)):
|
|
1113
1119
|
path, key, value, depth, branch = rows[i]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib-components
|
|
3
|
-
Version: 3.7.
|
|
3
|
+
Version: 3.7.4
|
|
4
4
|
Summary: Interactive terminal components for flexablelib: inputs, dates, tables, forms, menus, tabs, dialogs and more.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -17,8 +17,8 @@ Classifier: Topic :: Software Development :: User Interfaces
|
|
|
17
17
|
Requires-Python: >=3.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: flexablelib>=3.7.
|
|
21
|
-
Requires-Dist: flexablelib-tui>=3.7.
|
|
20
|
+
Requires-Dist: flexablelib>=3.7.4
|
|
21
|
+
Requires-Dist: flexablelib-tui>=3.7.4
|
|
22
22
|
Dynamic: author
|
|
23
23
|
Dynamic: author-email
|
|
24
24
|
Dynamic: classifier
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/dates.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/media.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/overlays.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.3 → flexablelib_components-3.7.4}/flexablelib_components/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|