flexablelib-components 3.7.4__tar.gz → 3.7.5__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 (22) hide show
  1. {flexablelib_components-3.7.4/flexablelib_components.egg-info → flexablelib_components-3.7.5}/PKG-INFO +3 -3
  2. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/__init__.py +1 -1
  3. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/base.py +19 -6
  4. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5/flexablelib_components.egg-info}/PKG-INFO +3 -3
  5. flexablelib_components-3.7.5/flexablelib_components.egg-info/requires.txt +2 -0
  6. flexablelib_components-3.7.4/flexablelib_components.egg-info/requires.txt +0 -2
  7. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/LICENSE +0 -0
  8. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/MANIFEST.in +0 -0
  9. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/README.md +0 -0
  10. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/data.py +0 -0
  11. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/dates.py +0 -0
  12. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/display.py +0 -0
  13. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/inputs.py +0 -0
  14. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/media.py +0 -0
  15. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/navigation.py +0 -0
  16. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/overlays.py +0 -0
  17. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components/py.typed +0 -0
  18. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components.egg-info/SOURCES.txt +0 -0
  19. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components.egg-info/dependency_links.txt +0 -0
  20. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/flexablelib_components.egg-info/top_level.txt +0 -0
  21. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/setup.cfg +0 -0
  22. {flexablelib_components-3.7.4 → flexablelib_components-3.7.5}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-components
3
- Version: 3.7.4
3
+ Version: 3.7.5
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.4
21
- Requires-Dist: flexablelib-tui>=3.7.4
20
+ Requires-Dist: flexablelib>=3.7.5
21
+ Requires-Dist: flexablelib-tui>=3.7.5
22
22
  Dynamic: author
23
23
  Dynamic: author-email
24
24
  Dynamic: classifier
@@ -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.4'
21
+ __version__ = '3.7.5'
22
22
 
23
23
  from .base import Theme, DEFAULT_THEME, Input, Box, Button, frame
24
24
  from .inputs import (TextInput, PasswordInput, NumberInput, ExpressionInput,
@@ -4,7 +4,7 @@ labels, help text and validation, and a few drawing helpers.
4
4
  """
5
5
 
6
6
  from flexablelib import _frames as _fx
7
- from flexablelib.colors import RESET, parse_spec
7
+ from flexablelib.colors import RESET, color_depth, parse_spec
8
8
  from flexablelib_tui import Component
9
9
 
10
10
  __all__ = ['Theme', 'DEFAULT_THEME', 'THEMES', 'Input', 'frame',
@@ -30,8 +30,8 @@ class Theme(object):
30
30
 
31
31
  def __init__(self, accent='cyan', muted='bright_black', text=None,
32
32
  selection='bold black on cyan', border='bright_black',
33
- info='blue', success='green', warning='yellow',
34
- error='red', title='bold', field='on #262626',
33
+ info='#5f87ff', success='green', warning='yellow',
34
+ error='bright_red', title='bold', field='on #262626',
35
35
  background='#000000', foreground='#e5e5e5', marker=False,
36
36
  name='custom'):
37
37
  self.name = name
@@ -134,6 +134,17 @@ THEMES = {
134
134
 
135
135
  DEFAULT_THEME = Theme(name='default')
136
136
 
137
+
138
+ def _text_on(colour):
139
+ """``'black'`` or ``'white'``, whichever reads better on ``colour``."""
140
+ from flexablelib_tui.accessibility import spec_colors, contrast_ratio
141
+ rgb = spec_colors(colour)[0]
142
+ if rgb is None:
143
+ return 'white'
144
+ black = contrast_ratio((0, 0, 0), rgb)
145
+ white = contrast_ratio(spec_colors('white')[0], rgb)
146
+ return 'black' if black > white else 'white'
147
+
137
148
  _SPEC_CACHE = {}
138
149
 
139
150
  _BOXES = {
@@ -234,9 +245,10 @@ class _Themed(Component):
234
245
  def paint(self, text, spec):
235
246
  if not text or not spec or not self._active():
236
247
  return text
237
- prefix = _SPEC_CACHE.get(spec)
248
+ key = (spec, color_depth())
249
+ prefix = _SPEC_CACHE.get(key)
238
250
  if prefix is None:
239
- prefix = _SPEC_CACHE[spec] = parse_spec(spec)
251
+ prefix = _SPEC_CACHE[key] = parse_spec(spec)
240
252
  if not prefix:
241
253
  return text
242
254
  return prefix + text.replace(RESET, RESET + prefix) + RESET
@@ -547,7 +559,8 @@ class Button(_Themed):
547
559
  if self.disabled:
548
560
  return theme.muted
549
561
  base = {'primary': 'black on ' + theme.accent,
550
- 'danger': 'white on ' + theme.error}.get(self.kind)
562
+ 'danger': _text_on(theme.error) + ' on ' + theme.error
563
+ }.get(self.kind)
551
564
  if self.focused:
552
565
  return 'bold reverse' if base is None else 'bold ' + base
553
566
  return base or 'on bright_black'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-components
3
- Version: 3.7.4
3
+ Version: 3.7.5
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.4
21
- Requires-Dist: flexablelib-tui>=3.7.4
20
+ Requires-Dist: flexablelib>=3.7.5
21
+ Requires-Dist: flexablelib-tui>=3.7.5
22
22
  Dynamic: author
23
23
  Dynamic: author-email
24
24
  Dynamic: classifier
@@ -0,0 +1,2 @@
1
+ flexablelib>=3.7.5
2
+ flexablelib-tui>=3.7.5
@@ -1,2 +0,0 @@
1
- flexablelib>=3.7.4
2
- flexablelib-tui>=3.7.4