streamlit-rtr-components 1.0.1__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 (28) hide show
  1. streamlit_rtr_components-1.0.1/LICENSE +19 -0
  2. streamlit_rtr_components-1.0.1/MANIFEST.in +4 -0
  3. streamlit_rtr_components-1.0.1/PKG-INFO +281 -0
  4. streamlit_rtr_components-1.0.1/README.md +263 -0
  5. streamlit_rtr_components-1.0.1/pyproject.toml +34 -0
  6. streamlit_rtr_components-1.0.1/rtr_componentes/__init__.py +5 -0
  7. streamlit_rtr_components-1.0.1/setup.cfg +4 -0
  8. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/__init__.py +39 -0
  9. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/assets/html2canvas.esm-CBrSDip1.js +22 -0
  10. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/assets/index-C41nEHc_.css +1 -0
  11. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/assets/index-a2xDwSvX.js +306 -0
  12. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/assets/index.es-DeVzaJkH.js +18 -0
  13. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/assets/purify.es-CQJ0hv7W.js +2 -0
  14. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/bootstrap.min.css +9501 -0
  15. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/index.html +14 -0
  16. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/dist/vite.svg +1 -0
  17. streamlit_rtr_components-1.0.1/st_hierarchicalGrid/frontend/node_modules/flatted/python/flatted.py +149 -0
  18. streamlit_rtr_components-1.0.1/st_orgChart/__init__.py +37 -0
  19. streamlit_rtr_components-1.0.1/st_orgChart/frontend/dist/assets/index-C9AqA9Xs.css +1 -0
  20. streamlit_rtr_components-1.0.1/st_orgChart/frontend/dist/assets/index-CBINCtcC.js +63 -0
  21. streamlit_rtr_components-1.0.1/st_orgChart/frontend/dist/index.html +14 -0
  22. streamlit_rtr_components-1.0.1/st_orgChart/frontend/dist/vite.svg +1 -0
  23. streamlit_rtr_components-1.0.1/st_orgChart/frontend/node_modules/flatted/python/flatted.py +149 -0
  24. streamlit_rtr_components-1.0.1/streamlit_rtr_components.egg-info/PKG-INFO +281 -0
  25. streamlit_rtr_components-1.0.1/streamlit_rtr_components.egg-info/SOURCES.txt +26 -0
  26. streamlit_rtr_components-1.0.1/streamlit_rtr_components.egg-info/dependency_links.txt +1 -0
  27. streamlit_rtr_components-1.0.1/streamlit_rtr_components.egg-info/requires.txt +9 -0
  28. streamlit_rtr_components-1.0.1/streamlit_rtr_components.egg-info/top_level.txt +3 -0
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018-2021 Streamlit Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ recursive-include st_orgChart/frontend/dist *
2
+ recursive-include st_hierarchicalGrid/frontend/dist *
3
+ include README.md
4
+ include LICENSE
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: streamlit-rtr-components
3
+ Version: 1.0.1
4
+ Summary: Streamlit components: Org Chart e Hierarchical Grid
5
+ Author-email: "Artur R. Oliveira" <arturroliveira87@gmail.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: streamlit>=1.24
10
+ Provides-Extra: devel
11
+ Requires-Dist: wheel; extra == "devel"
12
+ Requires-Dist: pytest==7.4.0; extra == "devel"
13
+ Requires-Dist: playwright==1.48.0; extra == "devel"
14
+ Requires-Dist: requests==2.31.0; extra == "devel"
15
+ Requires-Dist: pytest-playwright-snapshot==1.0; extra == "devel"
16
+ Requires-Dist: pytest-rerunfailures==12.0; extra == "devel"
17
+ Dynamic: license-file
18
+
19
+ <!-- PROJECT: streamlit-rtr-components -->
20
+ <!-- BADGES: start -->
21
+ <p align="center">
22
+ <!-- Substitua o href se já estiver no PyPI -->
23
+ <a href="https://pypi.org/project/streamlit-rtr-components/"><img alt="PyPI" src="https://img.shields.io/pypi/v/streamlit-rtr-components.svg"></a>
24
+ <img alt="Python" src="https://img.shields.io/pypi/pyversions/streamlit-rtr-components.svg">
25
+ <img alt="Streamlit" src="https://img.shields.io/badge/streamlit-%E2%89%A51.24-FF4B4B">
26
+ <img alt="License" src="https://img.shields.io/badge/license-MIT-green">
27
+ </p>
28
+ <!-- BADGES: end -->
29
+
30
+ <h1 align="center">streamlit-rtr-components</h1>
31
+ <p align="center">Componentes customizados para <b>Streamlit</b>: organograma e grid hierárquico.</p>
32
+
33
+ <!-- TOC: start -->
34
+ ## Sumário
35
+ - [Visão geral](#visão-geral)
36
+ - [Instalação](#instalação)
37
+ - [Exemplo rápido](#exemplo-rápido)
38
+ - [API](#api)
39
+ - [Formato de dados](#formato-de-dados)
40
+ - [Estrutura do repositório](#estrutura-do-repositório)
41
+ - [Desenvolvimento (Vite + Tailwind v4)](#desenvolvimento-vite--tailwind-v4)
42
+ - [Build de produção (frontend)](#build-de-produção-frontend)
43
+ - [Empacotamento Python](#empacotamento-python)
44
+ - [Solução de problemas](#solução-de-problemas)
45
+ - [Changelog](#changelog)
46
+ - [Contribuição](#contribuição)
47
+ - [Licença](#licença)
48
+ <!-- TOC: end -->
49
+
50
+ ## Visão geral
51
+ Dois componentes prontos para uso em Streamlit:
52
+ - `st_orgChart` — organograma (árvore hierárquica).
53
+ - `st_hierarchicalGrid` — grid hierárquico com colunas configuráveis e suporte a imagens (PNG/SVG via data URL).
54
+
55
+ > **Stack**: Python (Streamlit) + React/TypeScript (Vite) + Tailwind v4.
56
+ > **Artefatos**: cada frontend gera `frontend/dist` e é empacotado junto ao wheel.
57
+
58
+ ## Instalação
59
+ ```bash
60
+ pip install streamlit-rtr-components
61
+
62
+
63
+ <!-- USAGE: start -->
64
+
65
+ ## Exemplo rápido
66
+
67
+ import streamlit as st
68
+ from rtr_componentes import st_orgChart, st_hierarchicalGrid
69
+
70
+ st.title("Demo • RTR Components")
71
+
72
+ st.subheader("Org Chart")
73
+ st_orgChart(
74
+ data={
75
+ "id": "CEO",
76
+ "children": [{"id": "CTO"}, {"id": "CFO"}]
77
+ }
78
+ )
79
+
80
+ st.subheader("Hierarchical Grid")
81
+ data = [
82
+ {
83
+ "estrutura": "Presidência",
84
+ "avatar": "data:image/png;base64,....", # PNG opcional (data URL)
85
+ "quantidade_funcionarios": 2167,
86
+ "salario_total": "R$ 5.239.551,21",
87
+ "salario_medio": "R$ 2.417,88",
88
+ "children": [
89
+ {
90
+ "estrutura": "Assessoria Financeira",
91
+ "avatar": "data:image/svg+xml;base64,....", # SVG opcional (data URL)
92
+ "quantidade_funcionarios": 1,
93
+ "salario_total": "R$ 5.184,00",
94
+ "salario_medio": "R$ 5.184,00",
95
+ "children": []
96
+ }
97
+ ]
98
+ }
99
+ ]
100
+ columns = [
101
+ {"label": "Estrutura", "field": "estrutura"},
102
+ {"label": "Quantidade Funcionarios", "field": "quantidade_funcionarios"},
103
+ {"label": "Salario Total", "field": "salario_total", "secret": True},
104
+ {"label": "Salario Medio", "field": "salario_medio"}
105
+ ]
106
+
107
+ st_hierarchicalGrid(data=data, columns=columns, expanded=True)
108
+
109
+ <!-- USAGE: end -->
110
+
111
+ ## API
112
+
113
+ from rtr_componentes import st_orgChart, st_hierarchicalGrid
114
+
115
+ st_orgChart(
116
+ data: dict | list | None = None,
117
+ key: str | None = None,
118
+ **kwargs
119
+ ) -> Any
120
+
121
+
122
+ st_hierarchicalGrid(
123
+ data: dict | list | None = None,
124
+ columns: list[dict] | None = None,
125
+ expanded: bool = False,
126
+ key: str | None = None,
127
+ **kwargs
128
+ ) -> Any
129
+
130
+ # data
131
+ # Org: objeto/array hierárquico com id, children, etc.
132
+ # Grid: nós com campos livres e children: [].
133
+ # columns (Grid): {"label": str, "field": str, "secret"?: bool, "type"?: "text"|"number"|"currency"|...}.
134
+ # expanded (Grid): expande nós por padrão.
135
+ # Retorno: se o frontend chamar Streamlit.setComponentValue(...), o valor retorna via função Python.
136
+
137
+
138
+ <!-- DATA-FORMAT: start -->
139
+
140
+ Formato de dados
141
+ Imagens: envie como data URL
142
+
143
+ PNG → data:image/png;base64,<...>
144
+
145
+ SVG → data:image/svg+xml;base64,<...>
146
+
147
+ Perfomance: prefira miniaturas (ex.: 64–128 px) para reduzir payload.
148
+
149
+ Grid: garanta que os nomes em columns[].field existam em cada nó.
150
+
151
+ <!-- DATA-FORMAT: end -->
152
+
153
+
154
+ ## Estrutura do repositório
155
+
156
+ .
157
+ ├─ st_orgChart/
158
+ │ ├─ __init__.py # wrapper Python (usa frontend/dist)
159
+ │ └─ frontend/ # Vite/React/TS
160
+ │ ├─ index.html
161
+ │ ├─ src/
162
+ │ │ ├─ main.tsx
163
+ │ │ ├─ StOrgChart.tsx
164
+ │ │ └─ index.css # @import "tailwindcss";
165
+ │ └─ dist/ # gerado por vite build
166
+ ├─ st_hierarchicalGrid/
167
+ │ ├─ __init__.py
168
+ │ └─ frontend/
169
+ │ ├─ index.html
170
+ │ ├─ src/
171
+ │ │ ├─ main.tsx
172
+ │ │ ├─ RtrHierarchicalGrid.tsx
173
+ │ │ └─ index.css
174
+ │ └─ dist/
175
+ ├─ rtr_componentes/
176
+ │ └─ __init__.py # reexporta os dois componentes
177
+ ├─ pyproject.toml
178
+ ├─ MANIFEST.in
179
+ ├─ README.md
180
+ └─ LICENSE
181
+
182
+
183
+ ## Desenvolvimento (Vite + Tailwind v4)
184
+ # Em cada frontend:
185
+
186
+ npm i
187
+ npm run dev
188
+
189
+ ## No seu app Streamlit (dev hot-reload):
190
+
191
+ # Windows PowerShell
192
+ $env:DEV_MODE="true"
193
+ $env:FRONTEND_HOST="http://localhost:5173" # altere a porta conforme o componente
194
+ streamlit run seu_app.py
195
+
196
+ # Em dev, o wrapper usa DEV_MODE/FRONTEND_HOST. Em produção (sem envs), ele lê frontend/dist.
197
+
198
+
199
+ <!-- BUILD-FRONTEND: start -->
200
+
201
+ ## Build de produção (frontend)
202
+
203
+ cd st_orgChart/frontend && npm run build
204
+ cd ../../st_hierarchicalGrid/frontend && npm run build
205
+
206
+
207
+ # vite.config.ts (recomendado nos dois):
208
+
209
+ import { defineConfig } from "vite";
210
+ import react from "@vitejs/plugin-react";
211
+ import tailwind from "@tailwindcss/vite";
212
+
213
+ export default defineConfig(({ command }) => ({
214
+ base: command === "build" ? "./" : "/",
215
+ plugins: [react(), tailwind()],
216
+ build: { outDir: "dist" }
217
+ }));
218
+
219
+ <!-- BUILD-FRONTEND: end --> <!-- PACKAGING: start -->
220
+
221
+
222
+ ## Empacotamento Python
223
+
224
+ # MANIFEST.in
225
+
226
+ recursive-include st_orgChart/frontend/dist *
227
+ recursive-include st_hierarchicalGrid/frontend/dist *
228
+ include README.md
229
+ include LICENSE
230
+
231
+
232
+ # pyproject.toml (trechos)
233
+
234
+ [tool.setuptools]
235
+ include-package-data = true
236
+
237
+ [tool.setuptools.packages.find]
238
+ where = ["."]
239
+ include = ["st_orgChart*", "st_hierarchicalGrid*", "rtr_componentes*"]
240
+
241
+ [tool.setuptools.package-data]
242
+ "st_orgChart" = ["frontend/dist/**"]
243
+ "st_hierarchicalGrid" = ["frontend/dist/**"]
244
+
245
+
246
+ # Build & teste:
247
+
248
+ python -m build
249
+ pip install -e .
250
+
251
+ <!-- PACKAGING: end --> <!-- TROUBLESHOOT: start -->
252
+
253
+ # Solução de problemas
254
+ # Tela branca/404 em produção → confirme base: "./" no Vite e que frontend/dist existe e foi incluído no wheel.
255
+
256
+ # RuntimeError: Build não encontrado → rode npm run build em cada frontend antes de instalar.
257
+
258
+ # Erros de JSX/TS no editor → use TS 5, moduleResolution: "bundler", jsx: "react-jsx", types: ["vite/client"].
259
+
260
+ # Conflitos NPM (ERESOLVE) → se migrou de CRA, remova react-scripts, apague node_modules/package-lock.json e reinstale.
261
+
262
+ # Bundle grande (Grid) → faça import dinâmico de html2canvas/jspdf somente na ação de exportar.
263
+
264
+ # <!-- TROUBLESHOOT: end -->
265
+ # Changelog
266
+ # <!-- CHANGELOG: start -->
267
+ # 1.0.0 — release inicial com st_orgChart e st_hierarchicalGrid.
268
+
269
+ # <!-- CHANGELOG: end -->
270
+ # Contribuição
271
+ # Issues e PRs são bem-vindos. Antes de abrir PR:
272
+
273
+ # Rode npm run build em ambos os frontends.
274
+
275
+ # Rode npm run lint (se estiver usando ESLint).
276
+
277
+ # Adicione/atualize exemplos no README quando necessário.
278
+
279
+
280
+ ## Licença
281
+ # MIT — veja LICENSE.
@@ -0,0 +1,263 @@
1
+ <!-- PROJECT: streamlit-rtr-components -->
2
+ <!-- BADGES: start -->
3
+ <p align="center">
4
+ <!-- Substitua o href se já estiver no PyPI -->
5
+ <a href="https://pypi.org/project/streamlit-rtr-components/"><img alt="PyPI" src="https://img.shields.io/pypi/v/streamlit-rtr-components.svg"></a>
6
+ <img alt="Python" src="https://img.shields.io/pypi/pyversions/streamlit-rtr-components.svg">
7
+ <img alt="Streamlit" src="https://img.shields.io/badge/streamlit-%E2%89%A51.24-FF4B4B">
8
+ <img alt="License" src="https://img.shields.io/badge/license-MIT-green">
9
+ </p>
10
+ <!-- BADGES: end -->
11
+
12
+ <h1 align="center">streamlit-rtr-components</h1>
13
+ <p align="center">Componentes customizados para <b>Streamlit</b>: organograma e grid hierárquico.</p>
14
+
15
+ <!-- TOC: start -->
16
+ ## Sumário
17
+ - [Visão geral](#visão-geral)
18
+ - [Instalação](#instalação)
19
+ - [Exemplo rápido](#exemplo-rápido)
20
+ - [API](#api)
21
+ - [Formato de dados](#formato-de-dados)
22
+ - [Estrutura do repositório](#estrutura-do-repositório)
23
+ - [Desenvolvimento (Vite + Tailwind v4)](#desenvolvimento-vite--tailwind-v4)
24
+ - [Build de produção (frontend)](#build-de-produção-frontend)
25
+ - [Empacotamento Python](#empacotamento-python)
26
+ - [Solução de problemas](#solução-de-problemas)
27
+ - [Changelog](#changelog)
28
+ - [Contribuição](#contribuição)
29
+ - [Licença](#licença)
30
+ <!-- TOC: end -->
31
+
32
+ ## Visão geral
33
+ Dois componentes prontos para uso em Streamlit:
34
+ - `st_orgChart` — organograma (árvore hierárquica).
35
+ - `st_hierarchicalGrid` — grid hierárquico com colunas configuráveis e suporte a imagens (PNG/SVG via data URL).
36
+
37
+ > **Stack**: Python (Streamlit) + React/TypeScript (Vite) + Tailwind v4.
38
+ > **Artefatos**: cada frontend gera `frontend/dist` e é empacotado junto ao wheel.
39
+
40
+ ## Instalação
41
+ ```bash
42
+ pip install streamlit-rtr-components
43
+
44
+
45
+ <!-- USAGE: start -->
46
+
47
+ ## Exemplo rápido
48
+
49
+ import streamlit as st
50
+ from rtr_componentes import st_orgChart, st_hierarchicalGrid
51
+
52
+ st.title("Demo • RTR Components")
53
+
54
+ st.subheader("Org Chart")
55
+ st_orgChart(
56
+ data={
57
+ "id": "CEO",
58
+ "children": [{"id": "CTO"}, {"id": "CFO"}]
59
+ }
60
+ )
61
+
62
+ st.subheader("Hierarchical Grid")
63
+ data = [
64
+ {
65
+ "estrutura": "Presidência",
66
+ "avatar": "data:image/png;base64,....", # PNG opcional (data URL)
67
+ "quantidade_funcionarios": 2167,
68
+ "salario_total": "R$ 5.239.551,21",
69
+ "salario_medio": "R$ 2.417,88",
70
+ "children": [
71
+ {
72
+ "estrutura": "Assessoria Financeira",
73
+ "avatar": "data:image/svg+xml;base64,....", # SVG opcional (data URL)
74
+ "quantidade_funcionarios": 1,
75
+ "salario_total": "R$ 5.184,00",
76
+ "salario_medio": "R$ 5.184,00",
77
+ "children": []
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+ columns = [
83
+ {"label": "Estrutura", "field": "estrutura"},
84
+ {"label": "Quantidade Funcionarios", "field": "quantidade_funcionarios"},
85
+ {"label": "Salario Total", "field": "salario_total", "secret": True},
86
+ {"label": "Salario Medio", "field": "salario_medio"}
87
+ ]
88
+
89
+ st_hierarchicalGrid(data=data, columns=columns, expanded=True)
90
+
91
+ <!-- USAGE: end -->
92
+
93
+ ## API
94
+
95
+ from rtr_componentes import st_orgChart, st_hierarchicalGrid
96
+
97
+ st_orgChart(
98
+ data: dict | list | None = None,
99
+ key: str | None = None,
100
+ **kwargs
101
+ ) -> Any
102
+
103
+
104
+ st_hierarchicalGrid(
105
+ data: dict | list | None = None,
106
+ columns: list[dict] | None = None,
107
+ expanded: bool = False,
108
+ key: str | None = None,
109
+ **kwargs
110
+ ) -> Any
111
+
112
+ # data
113
+ # Org: objeto/array hierárquico com id, children, etc.
114
+ # Grid: nós com campos livres e children: [].
115
+ # columns (Grid): {"label": str, "field": str, "secret"?: bool, "type"?: "text"|"number"|"currency"|...}.
116
+ # expanded (Grid): expande nós por padrão.
117
+ # Retorno: se o frontend chamar Streamlit.setComponentValue(...), o valor retorna via função Python.
118
+
119
+
120
+ <!-- DATA-FORMAT: start -->
121
+
122
+ Formato de dados
123
+ Imagens: envie como data URL
124
+
125
+ PNG → data:image/png;base64,<...>
126
+
127
+ SVG → data:image/svg+xml;base64,<...>
128
+
129
+ Perfomance: prefira miniaturas (ex.: 64–128 px) para reduzir payload.
130
+
131
+ Grid: garanta que os nomes em columns[].field existam em cada nó.
132
+
133
+ <!-- DATA-FORMAT: end -->
134
+
135
+
136
+ ## Estrutura do repositório
137
+
138
+ .
139
+ ├─ st_orgChart/
140
+ │ ├─ __init__.py # wrapper Python (usa frontend/dist)
141
+ │ └─ frontend/ # Vite/React/TS
142
+ │ ├─ index.html
143
+ │ ├─ src/
144
+ │ │ ├─ main.tsx
145
+ │ │ ├─ StOrgChart.tsx
146
+ │ │ └─ index.css # @import "tailwindcss";
147
+ │ └─ dist/ # gerado por vite build
148
+ ├─ st_hierarchicalGrid/
149
+ │ ├─ __init__.py
150
+ │ └─ frontend/
151
+ │ ├─ index.html
152
+ │ ├─ src/
153
+ │ │ ├─ main.tsx
154
+ │ │ ├─ RtrHierarchicalGrid.tsx
155
+ │ │ └─ index.css
156
+ │ └─ dist/
157
+ ├─ rtr_componentes/
158
+ │ └─ __init__.py # reexporta os dois componentes
159
+ ├─ pyproject.toml
160
+ ├─ MANIFEST.in
161
+ ├─ README.md
162
+ └─ LICENSE
163
+
164
+
165
+ ## Desenvolvimento (Vite + Tailwind v4)
166
+ # Em cada frontend:
167
+
168
+ npm i
169
+ npm run dev
170
+
171
+ ## No seu app Streamlit (dev hot-reload):
172
+
173
+ # Windows PowerShell
174
+ $env:DEV_MODE="true"
175
+ $env:FRONTEND_HOST="http://localhost:5173" # altere a porta conforme o componente
176
+ streamlit run seu_app.py
177
+
178
+ # Em dev, o wrapper usa DEV_MODE/FRONTEND_HOST. Em produção (sem envs), ele lê frontend/dist.
179
+
180
+
181
+ <!-- BUILD-FRONTEND: start -->
182
+
183
+ ## Build de produção (frontend)
184
+
185
+ cd st_orgChart/frontend && npm run build
186
+ cd ../../st_hierarchicalGrid/frontend && npm run build
187
+
188
+
189
+ # vite.config.ts (recomendado nos dois):
190
+
191
+ import { defineConfig } from "vite";
192
+ import react from "@vitejs/plugin-react";
193
+ import tailwind from "@tailwindcss/vite";
194
+
195
+ export default defineConfig(({ command }) => ({
196
+ base: command === "build" ? "./" : "/",
197
+ plugins: [react(), tailwind()],
198
+ build: { outDir: "dist" }
199
+ }));
200
+
201
+ <!-- BUILD-FRONTEND: end --> <!-- PACKAGING: start -->
202
+
203
+
204
+ ## Empacotamento Python
205
+
206
+ # MANIFEST.in
207
+
208
+ recursive-include st_orgChart/frontend/dist *
209
+ recursive-include st_hierarchicalGrid/frontend/dist *
210
+ include README.md
211
+ include LICENSE
212
+
213
+
214
+ # pyproject.toml (trechos)
215
+
216
+ [tool.setuptools]
217
+ include-package-data = true
218
+
219
+ [tool.setuptools.packages.find]
220
+ where = ["."]
221
+ include = ["st_orgChart*", "st_hierarchicalGrid*", "rtr_componentes*"]
222
+
223
+ [tool.setuptools.package-data]
224
+ "st_orgChart" = ["frontend/dist/**"]
225
+ "st_hierarchicalGrid" = ["frontend/dist/**"]
226
+
227
+
228
+ # Build & teste:
229
+
230
+ python -m build
231
+ pip install -e .
232
+
233
+ <!-- PACKAGING: end --> <!-- TROUBLESHOOT: start -->
234
+
235
+ # Solução de problemas
236
+ # Tela branca/404 em produção → confirme base: "./" no Vite e que frontend/dist existe e foi incluído no wheel.
237
+
238
+ # RuntimeError: Build não encontrado → rode npm run build em cada frontend antes de instalar.
239
+
240
+ # Erros de JSX/TS no editor → use TS 5, moduleResolution: "bundler", jsx: "react-jsx", types: ["vite/client"].
241
+
242
+ # Conflitos NPM (ERESOLVE) → se migrou de CRA, remova react-scripts, apague node_modules/package-lock.json e reinstale.
243
+
244
+ # Bundle grande (Grid) → faça import dinâmico de html2canvas/jspdf somente na ação de exportar.
245
+
246
+ # <!-- TROUBLESHOOT: end -->
247
+ # Changelog
248
+ # <!-- CHANGELOG: start -->
249
+ # 1.0.0 — release inicial com st_orgChart e st_hierarchicalGrid.
250
+
251
+ # <!-- CHANGELOG: end -->
252
+ # Contribuição
253
+ # Issues e PRs são bem-vindos. Antes de abrir PR:
254
+
255
+ # Rode npm run build em ambos os frontends.
256
+
257
+ # Rode npm run lint (se estiver usando ESLint).
258
+
259
+ # Adicione/atualize exemplos no README quando necessário.
260
+
261
+
262
+ ## Licença
263
+ # MIT — veja LICENSE.
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "streamlit-rtr-components"
7
+ version = "1.0.1"
8
+ description = "Streamlit components: Org Chart e Hierarchical Grid"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ authors = [{ name = "Artur R. Oliveira", email = "arturroliveira87@gmail.com" }]
12
+ dependencies = ["streamlit>=1.24"]
13
+
14
+ [project.optional-dependencies]
15
+ devel = [
16
+ "wheel",
17
+ "pytest==7.4.0",
18
+ "playwright==1.48.0",
19
+ "requests==2.31.0",
20
+ "pytest-playwright-snapshot==1.0",
21
+ "pytest-rerunfailures==12.0",
22
+ ]
23
+
24
+ [tool.setuptools]
25
+ include-package-data = true
26
+
27
+ [tool.setuptools.packages.find]
28
+ where = ["."]
29
+ include = ["st_orgChart*", "st_hierarchicalGrid*", "rtr_componentes*"]
30
+
31
+ # Garante que os artefatos do frontend (dist) entrem no wheel/sdist
32
+ [tool.setuptools.package-data]
33
+ "st_orgChart" = ["frontend/dist/**"]
34
+ "st_hierarchicalGrid" = ["frontend/dist/**"]
@@ -0,0 +1,5 @@
1
+ # rtr_componentes/__init__.py
2
+ from st_orgChart import st_orgChart
3
+ from st_hierarchicalGrid import st_hierarchicalGrid
4
+
5
+ __all__ = ["st_orgChart", "st_hierarchicalGrid"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,39 @@
1
+ import os
2
+ from pathlib import Path
3
+ import streamlit
4
+ import streamlit.components.v1 as components
5
+
6
+ _COMPONENT_NAME = "st_hierarchicalGrid"
7
+
8
+ def _declare_component():
9
+ if os.getenv("DEV_MODE", "").lower() == "true":
10
+ host = os.getenv("FRONTEND_HOST_GRID", "http://localhost:3001")
11
+ return components.declare_component(_COMPONENT_NAME, url=host)
12
+
13
+ base = Path(__file__).parent / "frontend"
14
+ dist = base / "dist" # Vite
15
+ if dist.exists():
16
+ return components.declare_component(_COMPONENT_NAME, path=str(dist))
17
+
18
+ build = base / "build" # fallback se algum ainda for CRA
19
+ if build.exists():
20
+ return components.declare_component(_COMPONENT_NAME, path=str(build))
21
+
22
+ raise RuntimeError(f"Nenhum build encontrado em {dist} ou {build}. Rode `npm run build`.")
23
+
24
+ _component_func = _declare_component()
25
+
26
+ def st_hierarchicalGrid(data, columns, expanded, key=None):
27
+ """
28
+ Função que exibe o Grid Hierárquico.
29
+
30
+ Args:
31
+ data (list|dict): Dados hierárquicos.
32
+ columns (list|dict): Definição de colunas.
33
+ expanded (bool): Expandir nós por padrão.
34
+ key (str): Chave do componente.
35
+ Returns:
36
+ any: Valor retornado pelo front-end (se houver).
37
+ """
38
+ component_value = _component_func(data=data,columns=columns,expanded=expanded, key=key, default=0)
39
+ return component_value