|
18 | 18 | Optional,
|
19 | 19 | Sequence,
|
20 | 20 | Tuple,
|
| 21 | + TypedDict, |
21 | 22 | Union,
|
22 | 23 | )
|
23 | 24 | from uuid import uuid4
|
24 | 25 |
|
25 | 26 | import numpy as np
|
26 |
| -from typing_extensions import TypedDict |
27 | 27 |
|
28 | 28 | from pandas._config import get_option
|
29 | 29 |
|
@@ -1233,19 +1233,19 @@ def set_table_styles(
|
1233 | 1233 | obj, idf = self.data.index, ".row"
|
1234 | 1234 |
|
1235 | 1235 | table_styles = [
|
1236 |
| - { |
1237 |
| - "selector": str(s["selector"]) + idf + str(obj.get_loc(key)), |
1238 |
| - "props": _maybe_convert_css_to_tuples(s["props"]), |
1239 |
| - } |
| 1236 | + CSSDict( |
| 1237 | + selector=str(s["selector"]) + idf + str(obj.get_loc(key)), |
| 1238 | + props=_maybe_convert_css_to_tuples(s["props"]), |
| 1239 | + ) |
1240 | 1240 | for key, styles in table_styles.items()
|
1241 | 1241 | for s in styles
|
1242 | 1242 | ]
|
1243 | 1243 | else:
|
1244 | 1244 | table_styles = [
|
1245 |
| - { |
1246 |
| - "selector": s["selector"], |
1247 |
| - "props": _maybe_convert_css_to_tuples(s["props"]), |
1248 |
| - } |
| 1245 | + CSSDict( |
| 1246 | + selector=s["selector"], |
| 1247 | + props=_maybe_convert_css_to_tuples(s["props"]), |
| 1248 | + ) |
1249 | 1249 | for s in table_styles
|
1250 | 1250 | ]
|
1251 | 1251 |
|
@@ -1875,10 +1875,10 @@ def _class_styles(self):
|
1875 | 1875 | styles : List
|
1876 | 1876 | """
|
1877 | 1877 | return [
|
1878 |
| - { |
1879 |
| - "selector": f".{self.class_name}", |
1880 |
| - "props": _maybe_convert_css_to_tuples(self.class_properties), |
1881 |
| - } |
| 1878 | + CSSDict( |
| 1879 | + selector=f".{self.class_name}", |
| 1880 | + props=_maybe_convert_css_to_tuples(self.class_properties), |
| 1881 | + ) |
1882 | 1882 | ]
|
1883 | 1883 |
|
1884 | 1884 | def _pseudo_css(self, uuid: str, name: str, row: int, col: int, text: str):
|
@@ -1912,27 +1912,16 @@ def _pseudo_css(self, uuid: str, name: str, row: int, col: int, text: str):
|
1912 | 1912 | -------
|
1913 | 1913 | pseudo_css : List
|
1914 | 1914 | """
|
| 1915 | + selector_id = "#T_" + uuid + "row" + str(row) + "_col" + str(col) |
1915 | 1916 | return [
|
1916 |
| - { |
1917 |
| - "selector": "#T_" |
1918 |
| - + uuid |
1919 |
| - + "row" |
1920 |
| - + str(row) |
1921 |
| - + "_col" |
1922 |
| - + str(col) |
1923 |
| - + f":hover .{name}", |
1924 |
| - "props": [("visibility", "visible")], |
1925 |
| - }, |
1926 |
| - { |
1927 |
| - "selector": "#T_" |
1928 |
| - + uuid |
1929 |
| - + "row" |
1930 |
| - + str(row) |
1931 |
| - + "_col" |
1932 |
| - + str(col) |
1933 |
| - + f" .{name}::after", |
1934 |
| - "props": [("content", f'"{text}"')], |
1935 |
| - }, |
| 1917 | + CSSDict( |
| 1918 | + selector=selector_id + f":hover .{name}", |
| 1919 | + props=[("visibility", "visible")], |
| 1920 | + ), |
| 1921 | + CSSDict( |
| 1922 | + selector=selector_id + f" .{name}::after", |
| 1923 | + props=[("content", f'"{text}"')], |
| 1924 | + ), |
1936 | 1925 | ]
|
1937 | 1926 |
|
1938 | 1927 | def _translate(self, styler_data: FrameOrSeriesUnion, uuid: str, d: Dict):
|
|
0 commit comments