reflex-components-gridjs 0.9.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.
@@ -0,0 +1,24 @@
1
+ **/.DS_Store
2
+ **/*.pyc
3
+ assets/external/*
4
+ dist/*
5
+ examples/
6
+ .web
7
+ .states
8
+ .idea
9
+ .vscode
10
+ .coverage
11
+ .coverage.*
12
+ .venv
13
+ venv
14
+ requirements.txt
15
+ .pyi_generator_last_run
16
+ .pyi_generator_diff
17
+ reflex.db
18
+ .codspeed
19
+ .env
20
+ .env.*
21
+ node_modules
22
+ package-lock.json
23
+ *.pyi
24
+ .pre-commit-config.yaml
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: reflex-components-gridjs
3
+ Version: 0.9.0
4
+ Summary: Reflex gridjs components.
5
+ Author-email: Khaleel Al-Adhami <khaleel@reflex.dev>
6
+ Maintainer-email: Khaleel Al-Adhami <khaleel@reflex.dev>
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+
10
+ # reflex-components-gridjs
11
+
12
+ Reflex gridjs components.
@@ -0,0 +1,3 @@
1
+ # reflex-components-gridjs
2
+
3
+ Reflex gridjs components.
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "reflex-components-gridjs"
3
+ dynamic = ["version"]
4
+ description = "Reflex gridjs components."
5
+ readme = "README.md"
6
+ authors = [{ name = "Khaleel Al-Adhami", email = "khaleel@reflex.dev" }]
7
+ maintainers = [{ name = "Khaleel Al-Adhami", email = "khaleel@reflex.dev" }]
8
+ requires-python = ">=3.10"
9
+ dependencies = []
10
+
11
+ [tool.hatch.version]
12
+ source = "uv-dynamic-versioning"
13
+
14
+ [tool.uv-dynamic-versioning]
15
+ pattern-prefix = "reflex-components-gridjs-"
16
+ fallback-version = "0.0.0dev0"
17
+
18
+ [tool.hatch.build]
19
+ targets.sdist.artifacts = ["*.pyi"]
20
+ targets.wheel.artifacts = ["*.pyi"]
21
+
22
+ [tool.hatch.build.hooks.reflex-pyi]
23
+ dependencies = ["ruff", "reflex-base"]
24
+
25
+ [build-system]
26
+ requires = ["hatchling", "uv-dynamic-versioning", "hatch-reflex-pyi"]
27
+ build-backend = "hatchling.build"
@@ -0,0 +1,5 @@
1
+ """Grid components."""
2
+
3
+ from .datatable import DataTable
4
+
5
+ data_table = DataTable.create
@@ -0,0 +1,128 @@
1
+ """Table components."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Sequence
6
+ from typing import Any
7
+
8
+ from reflex_base.components.component import NoSSRComponent, field
9
+ from reflex_base.components.tags import Tag
10
+ from reflex_base.utils import types
11
+ from reflex_base.utils.imports import ImportDict
12
+ from reflex_base.utils.serializers import serialize
13
+ from reflex_base.vars.base import LiteralVar, Var, is_computed_var
14
+
15
+
16
+ class Gridjs(NoSSRComponent):
17
+ """A component that wraps a nivo bar component."""
18
+
19
+ library = "gridjs-react@6.1.1"
20
+
21
+ lib_dependencies: list[str] = ["gridjs@6.2.0"]
22
+
23
+
24
+ class DataTable(Gridjs):
25
+ """A data table component."""
26
+
27
+ tag = "Grid"
28
+
29
+ alias = "DataTableGrid"
30
+
31
+ data: Any = field(
32
+ doc="The data to display. Either a list of lists or a pandas dataframe."
33
+ )
34
+
35
+ columns: Var[Sequence] = field(
36
+ doc="The list of columns to display. Required if data is a list and should not be provided if the data field is a dataframe"
37
+ )
38
+
39
+ search: Var[bool] = field(doc="Enable a search bar.")
40
+
41
+ sort: Var[bool] = field(doc="Enable sorting on columns.")
42
+
43
+ resizable: Var[bool] = field(doc="Enable resizable columns.")
44
+
45
+ pagination: Var[bool | dict] = field(doc="Enable pagination.")
46
+
47
+ @classmethod
48
+ def create(cls, *children, **props):
49
+ """Create a datatable component.
50
+
51
+ Args:
52
+ *children: The children of the component.
53
+ **props: The props to pass to the component.
54
+
55
+ Returns:
56
+ The datatable component.
57
+
58
+ Raises:
59
+ ValueError: If a pandas dataframe is passed in and columns are also provided.
60
+ """
61
+ data = props.get("data")
62
+ columns = props.get("columns")
63
+
64
+ # The annotation should be provided if data is a computed var. We need this to know how to
65
+ # render pandas dataframes.
66
+ if is_computed_var(data) and data._var_type == Any:
67
+ msg = "Annotation of the computed var assigned to the data field should be provided."
68
+ raise ValueError(msg)
69
+
70
+ if (
71
+ columns is not None
72
+ and is_computed_var(columns)
73
+ and columns._var_type == Any
74
+ ):
75
+ msg = "Annotation of the computed var assigned to the column field should be provided."
76
+ raise ValueError(msg)
77
+
78
+ # If data is a pandas dataframe and columns are provided throw an error.
79
+ if (
80
+ types.is_dataframe(type(data))
81
+ or (isinstance(data, Var) and types.is_dataframe(data._var_type))
82
+ ) and columns is not None:
83
+ msg = "Cannot pass in both a pandas dataframe and columns to the data_table component."
84
+ raise ValueError(msg)
85
+
86
+ # If data is a list and columns are not provided, throw an error
87
+ if (
88
+ (isinstance(data, Var) and types.typehint_issubclass(data._var_type, list))
89
+ or isinstance(data, list)
90
+ ) and columns is None:
91
+ msg = "column field should be specified when the data field is a list type"
92
+ raise ValueError(msg)
93
+
94
+ # Create the component.
95
+ return super().create(
96
+ *children,
97
+ **props,
98
+ )
99
+
100
+ def add_imports(self) -> ImportDict:
101
+ """Add the imports for the datatable component.
102
+
103
+ Returns:
104
+ The import dict for the component.
105
+ """
106
+ return {"": "gridjs/dist/theme/mermaid.css"}
107
+
108
+ def _render(self) -> Tag:
109
+ if isinstance(self.data, Var) and types.is_dataframe(self.data._var_type):
110
+ self.columns = self.data._replace(
111
+ _js_expr=f"{self.data._js_expr}.columns",
112
+ _var_type=list[Any],
113
+ )
114
+ self.data = self.data._replace(
115
+ _js_expr=f"{self.data._js_expr}.data",
116
+ _var_type=list[list[Any]],
117
+ )
118
+ if types.is_dataframe(type(self.data)):
119
+ # If given a pandas df break up the data and columns
120
+ data = serialize(self.data)
121
+ if not isinstance(data, dict):
122
+ msg = "Serialized dataframe should be a dict."
123
+ raise ValueError(msg)
124
+ self.columns = LiteralVar.create(data["columns"])
125
+ self.data = LiteralVar.create(data["data"])
126
+
127
+ # Render the table.
128
+ return super()._render()
@@ -0,0 +1,160 @@
1
+ """Stub file for reflex_components_gridjs/datatable.py"""
2
+
3
+ # ------------------- DO NOT EDIT ----------------------
4
+ # This file was generated by `reflex/utils/pyi_generator.py`!
5
+ # ------------------------------------------------------
6
+ from collections.abc import Mapping, Sequence
7
+ from typing import Any
8
+
9
+ from reflex_base.components.component import NoSSRComponent
10
+ from reflex_base.event import EventType, PointerEventInfo
11
+ from reflex_base.utils.imports import ImportDict
12
+ from reflex_base.vars.base import Var
13
+ from reflex_components_core.core.breakpoints import Breakpoints
14
+
15
+ class Gridjs(NoSSRComponent):
16
+ @classmethod
17
+ def create(
18
+ cls,
19
+ *children,
20
+ style: Sequence[Mapping[str, Any]]
21
+ | Mapping[str, Any]
22
+ | Var[Mapping[str, Any]]
23
+ | Breakpoints
24
+ | None = None,
25
+ key: Any | None = None,
26
+ id: Any | None = None,
27
+ ref: Var | None = None,
28
+ class_name: Any | None = None,
29
+ custom_attrs: dict[str, Any | Var] | None = None,
30
+ on_blur: EventType[()] | None = None,
31
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
32
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
33
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
34
+ on_focus: EventType[()] | None = None,
35
+ on_mount: EventType[()] | None = None,
36
+ on_mouse_down: EventType[()] | None = None,
37
+ on_mouse_enter: EventType[()] | None = None,
38
+ on_mouse_leave: EventType[()] | None = None,
39
+ on_mouse_move: EventType[()] | None = None,
40
+ on_mouse_out: EventType[()] | None = None,
41
+ on_mouse_over: EventType[()] | None = None,
42
+ on_mouse_up: EventType[()] | None = None,
43
+ on_scroll: EventType[()] | None = None,
44
+ on_scroll_end: EventType[()] | None = None,
45
+ on_unmount: EventType[()] | None = None,
46
+ **props,
47
+ ) -> Gridjs:
48
+ """Create the component.
49
+
50
+ Args:
51
+ *children: The children of the component.
52
+ style: The style of the component.
53
+ key: A unique key for the component.
54
+ id: The id for the component.
55
+ ref: The Var to pass as the ref to the component.
56
+ class_name: The class name for the component.
57
+ custom_attrs: Attributes passed directly to the component.
58
+ on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input.
59
+ on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input.
60
+ on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button.
61
+ on_context_menu: Fired when the user right-clicks on an element.
62
+ on_double_click: Fired when the user double-clicks on an element.
63
+ on_mouse_down: Fired when the user presses a mouse button on an element.
64
+ on_mouse_enter: Fired when the mouse pointer enters the element.
65
+ on_mouse_leave: Fired when the mouse pointer leaves the element.
66
+ on_mouse_move: Fired when the mouse pointer moves over the element.
67
+ on_mouse_out: Fired when the mouse pointer moves out of the element.
68
+ on_mouse_over: Fired when the mouse pointer moves onto the element.
69
+ on_mouse_up: Fired when the user releases a mouse button on an element.
70
+ on_scroll: Fired when the user scrolls the element.
71
+ on_scroll_end: Fired when scrolling ends on the element.
72
+ on_mount: Fired when the component is mounted to the page.
73
+ on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh.
74
+ **props: The props of the component.
75
+
76
+ Returns:
77
+ The component.
78
+ """
79
+
80
+ class DataTable(Gridjs):
81
+ @classmethod
82
+ def create(
83
+ cls,
84
+ *children,
85
+ data: Any | None = None,
86
+ columns: Sequence | Var[Sequence] | None = None,
87
+ search: Var[bool] | bool | None = None,
88
+ sort: Var[bool] | bool | None = None,
89
+ resizable: Var[bool] | bool | None = None,
90
+ pagination: Var[bool | dict] | bool | dict | None = None,
91
+ style: Sequence[Mapping[str, Any]]
92
+ | Mapping[str, Any]
93
+ | Var[Mapping[str, Any]]
94
+ | Breakpoints
95
+ | None = None,
96
+ key: Any | None = None,
97
+ id: Any | None = None,
98
+ ref: Var | None = None,
99
+ class_name: Any | None = None,
100
+ custom_attrs: dict[str, Any | Var] | None = None,
101
+ on_blur: EventType[()] | None = None,
102
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
103
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
104
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
105
+ on_focus: EventType[()] | None = None,
106
+ on_mount: EventType[()] | None = None,
107
+ on_mouse_down: EventType[()] | None = None,
108
+ on_mouse_enter: EventType[()] | None = None,
109
+ on_mouse_leave: EventType[()] | None = None,
110
+ on_mouse_move: EventType[()] | None = None,
111
+ on_mouse_out: EventType[()] | None = None,
112
+ on_mouse_over: EventType[()] | None = None,
113
+ on_mouse_up: EventType[()] | None = None,
114
+ on_scroll: EventType[()] | None = None,
115
+ on_scroll_end: EventType[()] | None = None,
116
+ on_unmount: EventType[()] | None = None,
117
+ **props,
118
+ ) -> DataTable:
119
+ """Create a datatable component.
120
+
121
+ Args:
122
+ *children: The children of the component.
123
+ data: The data to display. Either a list of lists or a pandas dataframe.
124
+ columns: The list of columns to display. Required if data is a list and should not be provided if the data field is a dataframe
125
+ search: Enable a search bar.
126
+ sort: Enable sorting on columns.
127
+ resizable: Enable resizable columns.
128
+ pagination: Enable pagination.
129
+ style: The style of the component.
130
+ key: A unique key for the component.
131
+ id: The id for the component.
132
+ ref: The Var to pass as the ref to the component.
133
+ class_name: The class name for the component.
134
+ custom_attrs: Attributes passed directly to the component.
135
+ on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input.
136
+ on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input.
137
+ on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button.
138
+ on_context_menu: Fired when the user right-clicks on an element.
139
+ on_double_click: Fired when the user double-clicks on an element.
140
+ on_mouse_down: Fired when the user presses a mouse button on an element.
141
+ on_mouse_enter: Fired when the mouse pointer enters the element.
142
+ on_mouse_leave: Fired when the mouse pointer leaves the element.
143
+ on_mouse_move: Fired when the mouse pointer moves over the element.
144
+ on_mouse_out: Fired when the mouse pointer moves out of the element.
145
+ on_mouse_over: Fired when the mouse pointer moves onto the element.
146
+ on_mouse_up: Fired when the user releases a mouse button on an element.
147
+ on_scroll: Fired when the user scrolls the element.
148
+ on_scroll_end: Fired when scrolling ends on the element.
149
+ on_mount: Fired when the component is mounted to the page.
150
+ on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh.
151
+ **props: The props to pass to the component.
152
+
153
+ Returns:
154
+ The datatable component.
155
+
156
+ Raises:
157
+ ValueError: If a pandas dataframe is passed in and columns are also provided.
158
+ """
159
+
160
+ def add_imports(self) -> ImportDict: ...