dars-framework 1.2.3__py3-none-any.whl
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.
- dars/__init__.py +0 -0
- dars/all.py +69 -0
- dars/cli/__init__.py +0 -0
- dars/cli/doctor/__init__.py +1 -0
- dars/cli/doctor/detect.py +154 -0
- dars/cli/doctor/doctor.py +176 -0
- dars/cli/doctor/installers.py +100 -0
- dars/cli/doctor/persist.py +62 -0
- dars/cli/doctor/preflight.py +33 -0
- dars/cli/doctor/ui.py +54 -0
- dars/cli/hot_reload.py +33 -0
- dars/cli/main.py +1107 -0
- dars/cli/preview.py +448 -0
- dars/cli/translations.py +531 -0
- dars/components/__init__.py +0 -0
- dars/components/advanced/__init__.py +8 -0
- dars/components/advanced/accordion.py +26 -0
- dars/components/advanced/card.py +33 -0
- dars/components/advanced/modal.py +45 -0
- dars/components/advanced/navbar.py +44 -0
- dars/components/advanced/table.py +25 -0
- dars/components/advanced/tabs.py +31 -0
- dars/components/basic/__init__.py +34 -0
- dars/components/basic/button.py +55 -0
- dars/components/basic/checkbox.py +35 -0
- dars/components/basic/container.py +29 -0
- dars/components/basic/datepicker.py +139 -0
- dars/components/basic/image.py +36 -0
- dars/components/basic/input.py +57 -0
- dars/components/basic/link.py +31 -0
- dars/components/basic/markdown.py +86 -0
- dars/components/basic/page.py +20 -0
- dars/components/basic/progressbar.py +18 -0
- dars/components/basic/radiobutton.py +35 -0
- dars/components/basic/select.py +82 -0
- dars/components/basic/slider.py +63 -0
- dars/components/basic/spinner.py +12 -0
- dars/components/basic/text.py +23 -0
- dars/components/basic/textarea.py +46 -0
- dars/components/basic/tooltip.py +19 -0
- dars/components/layout/__init__.py +0 -0
- dars/components/layout/anchor.py +13 -0
- dars/components/layout/flex.py +26 -0
- dars/components/layout/grid.py +45 -0
- dars/config.py +134 -0
- dars/core/__init__.py +0 -0
- dars/core/app.py +957 -0
- dars/core/component.py +284 -0
- dars/core/events.py +102 -0
- dars/core/js_bridge.py +99 -0
- dars/core/properties.py +127 -0
- dars/core/state.py +309 -0
- dars/dars_tests/apps_test/health_check.py +56 -0
- dars/dars_tests/run_tests.py +275 -0
- dars/dars_tests/tests/test_advanced_components.py +69 -0
- dars/dars_tests/tests/test_basic_components.py +88 -0
- dars/dars_tests/tests/test_core_and_cli.py +17 -0
- dars/dars_tests/tests/test_layout_components.py +58 -0
- dars/dars_tests/tests/test_version_check.py +21 -0
- dars/docs/__init__.py +0 -0
- dars/docs/app.md +290 -0
- dars/docs/cli.md +80 -0
- dars/docs/components.md +1679 -0
- dars/docs/custom_components.md +30 -0
- dars/docs/events.md +45 -0
- dars/docs/exporters.md +162 -0
- dars/docs/getting_started.md +79 -0
- dars/docs/index.md +18 -0
- dars/docs/scripts.md +593 -0
- dars/docs/state_management.md +57 -0
- dars/exporters/__init__.py +0 -0
- dars/exporters/base.py +96 -0
- dars/exporters/web/OLD/html_css_js_OLD4.py +1538 -0
- dars/exporters/web/OLD/html_css_js_old.py +1406 -0
- dars/exporters/web/OLD/html_css_js_old2.py +1406 -0
- dars/exporters/web/__init__.py +0 -0
- dars/exporters/web/html_css_js.py +2675 -0
- dars/exporters/web/vdom.py +251 -0
- dars/js_lib.py +206 -0
- dars/scripts/__init__.py +0 -0
- dars/scripts/dscript.py +26 -0
- dars/scripts/script.py +39 -0
- dars/security.py +195 -0
- dars/templates/__init__.py +0 -0
- dars/templates/__pycache__/__init__.cpython-311.pyc +0 -0
- dars/templates/examples/README.md +4 -0
- dars/templates/examples/__pycache__/dynamic_event_demo.cpython-311.pyc +0 -0
- dars/templates/examples/advanced/Modal_Demo/advanced_modal_demo.py +275 -0
- dars/templates/examples/advanced/SimpleDashboard/dashboard.py +437 -0
- dars/templates/examples/advanced/SimpleModermWeb/modern_web_app.py +452 -0
- dars/templates/examples/advanced/VariousComponents/all_components_demo.py +87 -0
- dars/templates/examples/advanced/__init__.py +0 -0
- dars/templates/examples/advanced/dState/state_mods_demo.py +68 -0
- dars/templates/examples/basic/Forms/form_components.py +516 -0
- dars/templates/examples/basic/Forms/simple_form.py +379 -0
- dars/templates/examples/basic/HelloWorld/hello_world.py +56 -0
- dars/templates/examples/basic/Layouts/flex_layout_responsive.py +13 -0
- dars/templates/examples/basic/Layouts/grid_layout_responsive.py +12 -0
- dars/templates/examples/basic/Layouts/layout_multipage_demo.py +23 -0
- dars/templates/examples/basic/Multipage/multipage_example.py +67 -0
- dars/templates/examples/basic/PWA/icon-192x192.png +0 -0
- dars/templates/examples/basic/PWA/icon-512x512.png +0 -0
- dars/templates/examples/basic/PWA/pwa_custom_icons.py +33 -0
- dars/templates/examples/basic/__init__.py +0 -0
- dars/templates/examples/demo/__pycache__/complete_app.cpython-311.pyc +0 -0
- dars/templates/examples/demo/complete_app.py +21 -0
- dars/templates/examples/markdown/MarkdownTemplate/README.md +159 -0
- dars/templates/examples/markdown/MarkdownTemplate/markdown_template.py +21 -0
- dars/templates/examples/markdown/MarkdownTemplate/other_docs.md +1 -0
- dars/templates/examples/markdown/__init__.py +0 -0
- dars/templates/html/__init__.py +0 -0
- dars/version.py +2 -0
- dars_framework-1.2.3.dist-info/METADATA +15 -0
- dars_framework-1.2.3.dist-info/RECORD +118 -0
- dars_framework-1.2.3.dist-info/WHEEL +5 -0
- dars_framework-1.2.3.dist-info/entry_points.txt +2 -0
- dars_framework-1.2.3.dist-info/licenses/LICENSE +21 -0
- dars_framework-1.2.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Template: Aplicación Web Moderna con Propiedades Extendidas
|
|
4
|
+
===========================================================
|
|
5
|
+
|
|
6
|
+
Este template demuestra todas las nuevas propiedades extendidas de la clase App:
|
|
7
|
+
- SEO completo (meta tags, keywords, description, robots)
|
|
8
|
+
- Open Graph para redes sociales (Facebook, LinkedIn, etc.)
|
|
9
|
+
- Twitter Cards para compartir en Twitter
|
|
10
|
+
- Progressive Web App (PWA) con manifest y configuración móvil
|
|
11
|
+
- Favicon y iconos para diferentes dispositivos
|
|
12
|
+
- Colores de tema y configuración visual
|
|
13
|
+
- URL canónica y configuración de robots
|
|
14
|
+
|
|
15
|
+
Además incluye todos los nuevos componentes básicos:
|
|
16
|
+
- Checkbox, RadioButton, Select, Slider, DatePicker
|
|
17
|
+
|
|
18
|
+
Uso:
|
|
19
|
+
dars init mi_app_moderna --template advanced/modern_web_app
|
|
20
|
+
dars export mi_app_moderna.py --format html --output ./mi_app_moderna
|
|
21
|
+
dars preview ./mi_app_moderna
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from dars.core.app import App
|
|
25
|
+
from dars.components.basic.container import Container
|
|
26
|
+
from dars.components.basic.text import Text
|
|
27
|
+
from dars.components.basic.button import Button
|
|
28
|
+
from dars.components.basic.input import Input
|
|
29
|
+
from dars.components.basic.checkbox import Checkbox
|
|
30
|
+
from dars.components.basic.radiobutton import RadioButton
|
|
31
|
+
from dars.components.basic.select import Select, SelectOption
|
|
32
|
+
from dars.components.basic.slider import Slider
|
|
33
|
+
from dars.components.basic.datepicker import DatePicker
|
|
34
|
+
from dars.components.advanced.card import Card
|
|
35
|
+
from dars.scripts.script import InlineScript
|
|
36
|
+
|
|
37
|
+
# Crear aplicación con todas las propiedades extendidas modernas
|
|
38
|
+
app = App(
|
|
39
|
+
# === PROPIEDADES BÁSICAS ===
|
|
40
|
+
title="Mi Aplicación Web Moderna | Dars Framework",
|
|
41
|
+
description="Una aplicación web moderna creada con Dars Framework que demuestra SEO avanzado, Open Graph, Twitter Cards, PWA y todos los componentes básicos disponibles.",
|
|
42
|
+
author="Tu Nombre",
|
|
43
|
+
keywords=["dars", "framework", "python", "web", "moderna", "seo", "pwa", "responsive"],
|
|
44
|
+
language="es",
|
|
45
|
+
|
|
46
|
+
# === ICONOS Y FAVICON ===
|
|
47
|
+
favicon="/assets/favicon.ico",
|
|
48
|
+
icon="/assets/icon-192x192.png",
|
|
49
|
+
apple_touch_icon="/assets/apple-touch-icon.png",
|
|
50
|
+
manifest="/assets/manifest.json",
|
|
51
|
+
|
|
52
|
+
# === COLORES DE TEMA (PWA) ===
|
|
53
|
+
theme_color="#1e3a8a", # Azul profesional
|
|
54
|
+
background_color="#f8fafc", # Gris claro
|
|
55
|
+
|
|
56
|
+
# === OPEN GRAPH (REDES SOCIALES) ===
|
|
57
|
+
og_title="Mi Aplicación Web Moderna - Dars Framework",
|
|
58
|
+
og_description="Descubre cómo crear aplicaciones web modernas con Python usando Dars Framework. SEO optimizado, PWA, y componentes interactivos.",
|
|
59
|
+
og_image="https://mi-dominio.com/assets/og-image-1200x630.jpg",
|
|
60
|
+
og_url="https://mi-dominio.com",
|
|
61
|
+
og_type="website",
|
|
62
|
+
og_site_name="Mi Aplicación Moderna",
|
|
63
|
+
|
|
64
|
+
# === TWITTER CARDS ===
|
|
65
|
+
twitter_card="summary_large_image",
|
|
66
|
+
twitter_site="@mi_usuario",
|
|
67
|
+
twitter_creator="@desarrollador",
|
|
68
|
+
|
|
69
|
+
# === SEO AVANZADO ===
|
|
70
|
+
robots="index, follow, max-snippet:-1, max-image-preview:large",
|
|
71
|
+
canonical_url="https://mi-dominio.com",
|
|
72
|
+
|
|
73
|
+
# === PWA CONFIGURACIÓN ===
|
|
74
|
+
pwa_enabled=True,
|
|
75
|
+
pwa_name="Mi App Moderna",
|
|
76
|
+
pwa_short_name="AppModerna",
|
|
77
|
+
pwa_display="standalone",
|
|
78
|
+
pwa_orientation="portrait-primary"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# === CONTENEDOR PRINCIPAL ===
|
|
82
|
+
main_container = Container(style={
|
|
83
|
+
'max-width': '1200px',
|
|
84
|
+
'margin': '0 auto',
|
|
85
|
+
'padding': '20px',
|
|
86
|
+
'font-family': 'system-ui, -apple-system, sans-serif'
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
# === SECCIÓN HERO ===
|
|
90
|
+
hero_section = Container(style={
|
|
91
|
+
'text-align': 'center',
|
|
92
|
+
'padding': '60px 20px',
|
|
93
|
+
'background': 'linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%)',
|
|
94
|
+
'border-radius': '20px',
|
|
95
|
+
'margin-bottom': '40px',
|
|
96
|
+
'box-shadow': '0 10px 40px rgba(0,0,0,0.1)'
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
hero_title = Text(
|
|
100
|
+
text="🌟 Aplicación Web Moderna",
|
|
101
|
+
style={
|
|
102
|
+
'font-size': '48px',
|
|
103
|
+
'font-weight': '800',
|
|
104
|
+
'color': '#1e3a8a',
|
|
105
|
+
'margin-bottom': '20px',
|
|
106
|
+
'display': 'block'
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
hero_subtitle = Text(
|
|
111
|
+
text="Demostrando todas las características modernas del framework Dars",
|
|
112
|
+
style={
|
|
113
|
+
'font-size': '20px',
|
|
114
|
+
'color': '#64748b',
|
|
115
|
+
'margin-bottom': '30px',
|
|
116
|
+
'display': 'block'
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
cta_button = Button(
|
|
121
|
+
text="🚀 Explorar Componentes",
|
|
122
|
+
style={
|
|
123
|
+
'background': 'linear-gradient(45deg, #1e3a8a, #3b82f6)',
|
|
124
|
+
'color': 'white',
|
|
125
|
+
'padding': '15px 30px',
|
|
126
|
+
'font-size': '18px',
|
|
127
|
+
'font-weight': 'bold',
|
|
128
|
+
'border': 'none',
|
|
129
|
+
'border-radius': '25px',
|
|
130
|
+
'cursor': 'pointer',
|
|
131
|
+
'box-shadow': '0 8px 25px rgba(30, 58, 138, 0.4)'
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# === SECCIÓN DE CARACTERÍSTICAS ===
|
|
136
|
+
features_section = Container(style={
|
|
137
|
+
'padding': '60px 20px',
|
|
138
|
+
'background': 'white',
|
|
139
|
+
'border-radius': '20px',
|
|
140
|
+
'margin-bottom': '40px',
|
|
141
|
+
'box-shadow': '0 5px 30px rgba(0,0,0,0.08)'
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
features_title = Text(
|
|
145
|
+
text="✨ Características Modernas",
|
|
146
|
+
style={
|
|
147
|
+
'font-size': '36px',
|
|
148
|
+
'font-weight': '700',
|
|
149
|
+
'color': '#1e3a8a',
|
|
150
|
+
'text-align': 'center',
|
|
151
|
+
'margin-bottom': '40px',
|
|
152
|
+
'display': 'block'
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
features_grid = Container(style={
|
|
157
|
+
'display': 'grid',
|
|
158
|
+
'grid-template-columns': 'repeat(auto-fit, minmax(300px, 1fr))',
|
|
159
|
+
'gap': '30px'
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
# Crear tarjetas de características
|
|
163
|
+
features_data = [
|
|
164
|
+
('🔍', 'SEO Avanzado', 'Meta tags completos, keywords, description, robots.txt y URL canónica.'),
|
|
165
|
+
('📱', 'Progressive Web App', 'Configuración PWA completa con manifest, iconos y colores de tema.'),
|
|
166
|
+
('🌐', 'Open Graph & Twitter', 'Integración completa con redes sociales para compartir perfectamente.'),
|
|
167
|
+
('🎨', 'Componentes Modernos', 'Checkbox, RadioButton, Select, Slider, DatePicker con diseño moderno.')
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
for icon, title, description in features_data:
|
|
171
|
+
feature_card = Card(
|
|
172
|
+
title=f"{icon} {title}",
|
|
173
|
+
style={
|
|
174
|
+
'border': 'none',
|
|
175
|
+
'border-radius': '15px',
|
|
176
|
+
'box-shadow': '0 8px 30px rgba(0,0,0,0.12)',
|
|
177
|
+
'border-left': '5px solid #3b82f6'
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
feature_description = Text(
|
|
182
|
+
text=description,
|
|
183
|
+
style={
|
|
184
|
+
'color': '#64748b',
|
|
185
|
+
'line-height': '1.6'
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
feature_card.add_child(feature_description)
|
|
190
|
+
features_grid.add_child(feature_card)
|
|
191
|
+
|
|
192
|
+
# === SECCIÓN DE FORMULARIO ===
|
|
193
|
+
form_section = Container(style={
|
|
194
|
+
'padding': '60px 20px',
|
|
195
|
+
'background': 'linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%)',
|
|
196
|
+
'border-radius': '20px',
|
|
197
|
+
'margin-bottom': '40px'
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
form_title = Text(
|
|
201
|
+
text="📝 Formulario Interactivo",
|
|
202
|
+
style={
|
|
203
|
+
'font-size': '36px',
|
|
204
|
+
'font-weight': '700',
|
|
205
|
+
'color': '#1e3a8a',
|
|
206
|
+
'text-align': 'center',
|
|
207
|
+
'margin-bottom': '40px',
|
|
208
|
+
'display': 'block'
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
form_container = Container(style={
|
|
213
|
+
'max-width': '600px',
|
|
214
|
+
'margin': '0 auto',
|
|
215
|
+
'background': 'white',
|
|
216
|
+
'padding': '40px',
|
|
217
|
+
'border-radius': '15px',
|
|
218
|
+
'box-shadow': '0 10px 40px rgba(0,0,0,0.1)'
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
# Campos del formulario
|
|
222
|
+
name_input = Input(
|
|
223
|
+
placeholder="Tu nombre completo",
|
|
224
|
+
style={
|
|
225
|
+
'width': '100%',
|
|
226
|
+
'padding': '12px',
|
|
227
|
+
'margin-bottom': '20px',
|
|
228
|
+
'border': '2px solid #e2e8f0',
|
|
229
|
+
'border-radius': '8px'
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
email_input = Input(
|
|
234
|
+
placeholder="tu@email.com",
|
|
235
|
+
input_type="email",
|
|
236
|
+
style={
|
|
237
|
+
'width': '100%',
|
|
238
|
+
'padding': '12px',
|
|
239
|
+
'margin-bottom': '20px',
|
|
240
|
+
'border': '2px solid #e2e8f0',
|
|
241
|
+
'border-radius': '8px'
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
terms_checkbox = Checkbox(
|
|
246
|
+
label="Acepto los términos y condiciones",
|
|
247
|
+
style={'margin': '20px 0'}
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# RadioButtons
|
|
251
|
+
user_type_title = Text(
|
|
252
|
+
text="Tipo de usuario:",
|
|
253
|
+
style={'font-weight': 'bold', 'margin': '20px 0 10px 0', 'display': 'block'}
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
developer_radio = RadioButton(
|
|
257
|
+
label="Desarrollador",
|
|
258
|
+
name="user_type",
|
|
259
|
+
value="developer",
|
|
260
|
+
style={'margin': '5px 0'}
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
designer_radio = RadioButton(
|
|
264
|
+
label="Diseñador",
|
|
265
|
+
name="user_type",
|
|
266
|
+
value="designer",
|
|
267
|
+
style={'margin': '5px 0'}
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
# Select
|
|
271
|
+
country_select = Select(
|
|
272
|
+
placeholder="Selecciona tu país",
|
|
273
|
+
style={
|
|
274
|
+
'width': '100%',
|
|
275
|
+
'padding': '12px',
|
|
276
|
+
'margin': '20px 0',
|
|
277
|
+
'border': '2px solid #e2e8f0',
|
|
278
|
+
'border-radius': '8px'
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
country_select.add_option(SelectOption(value="es", label="España"))
|
|
283
|
+
country_select.add_option(SelectOption(value="mx", label="México"))
|
|
284
|
+
country_select.add_option(SelectOption(value="ar", label="Argentina"))
|
|
285
|
+
country_select.add_option(SelectOption(value="us", label="Estados Unidos"))
|
|
286
|
+
|
|
287
|
+
# Slider
|
|
288
|
+
experience_title = Text(
|
|
289
|
+
text="Años de experiencia:",
|
|
290
|
+
style={'font-weight': 'bold', 'margin': '20px 0 10px 0', 'display': 'block'}
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
experience_slider = Slider(
|
|
294
|
+
min_value=0,
|
|
295
|
+
max_value=20,
|
|
296
|
+
value=5,
|
|
297
|
+
show_value=True,
|
|
298
|
+
label="años",
|
|
299
|
+
style={'margin': '10px 0 20px 0'}
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
# DatePicker
|
|
303
|
+
birth_date_title = Text(
|
|
304
|
+
text="Fecha de nacimiento:",
|
|
305
|
+
style={'font-weight': 'bold', 'margin': '20px 0 10px 0', 'display': 'block'}
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
birth_date_picker = DatePicker(
|
|
309
|
+
format="DD/MM/YYYY",
|
|
310
|
+
style={
|
|
311
|
+
'width': '100%',
|
|
312
|
+
'padding': '12px',
|
|
313
|
+
'margin': '10px 0 20px 0',
|
|
314
|
+
'border': '2px solid #e2e8f0',
|
|
315
|
+
'border-radius': '8px'
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
submit_button = Button(
|
|
320
|
+
text="🚀 Enviar Formulario",
|
|
321
|
+
style={
|
|
322
|
+
'background': 'linear-gradient(45deg, #10b981, #059669)',
|
|
323
|
+
'color': 'white',
|
|
324
|
+
'padding': '15px 30px',
|
|
325
|
+
'font-size': '16px',
|
|
326
|
+
'font-weight': 'bold',
|
|
327
|
+
'border': 'none',
|
|
328
|
+
'border-radius': '8px',
|
|
329
|
+
'cursor': 'pointer',
|
|
330
|
+
'width': '100%',
|
|
331
|
+
'margin-top': '20px'
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
# Script interactivo
|
|
336
|
+
interactive_script = InlineScript("""
|
|
337
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
338
|
+
console.log('🚀 Aplicación Web Moderna cargada');
|
|
339
|
+
|
|
340
|
+
// Mostrar información de meta tags
|
|
341
|
+
const metaInfo = {
|
|
342
|
+
title: document.title,
|
|
343
|
+
description: document.querySelector('meta[name="description"]')?.content,
|
|
344
|
+
themeColor: document.querySelector('meta[name="theme-color"]')?.content,
|
|
345
|
+
manifest: document.querySelector('link[rel="manifest"]')?.href
|
|
346
|
+
};
|
|
347
|
+
console.log('🔍 Meta Tags:', metaInfo);
|
|
348
|
+
|
|
349
|
+
// Manejar formulario
|
|
350
|
+
const submitButton = document.querySelector('button[style*="10b981"]');
|
|
351
|
+
if (submitButton) {
|
|
352
|
+
submitButton.addEventListener('click', function(e) {
|
|
353
|
+
e.preventDefault();
|
|
354
|
+
|
|
355
|
+
const formData = {
|
|
356
|
+
name: document.querySelector('input[placeholder*="nombre"]')?.value,
|
|
357
|
+
email: document.querySelector('input[type="email"]')?.value,
|
|
358
|
+
terms: document.querySelector('input[type="checkbox"]')?.checked,
|
|
359
|
+
userType: document.querySelector('input[type="radio"]:checked')?.value,
|
|
360
|
+
country: document.querySelector('select')?.value,
|
|
361
|
+
experience: document.querySelector('input[type="range"]')?.value,
|
|
362
|
+
birthDate: document.querySelector('input[type="date"]')?.value
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
if (!formData.name || !formData.email || !formData.terms) {
|
|
366
|
+
alert('⚠️ Por favor completa todos los campos obligatorios');
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
alert(`✅ ¡Formulario enviado exitosamente!
|
|
371
|
+
|
|
372
|
+
Datos recibidos:
|
|
373
|
+
• Nombre: ${formData.name}
|
|
374
|
+
• Email: ${formData.email}
|
|
375
|
+
• Tipo: ${formData.userType || 'No especificado'}
|
|
376
|
+
• País: ${formData.country || 'No especificado'}
|
|
377
|
+
• Experiencia: ${formData.experience || 0} años
|
|
378
|
+
|
|
379
|
+
¡Gracias por probar la aplicación!`);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// PWA Installation
|
|
384
|
+
window.addEventListener('beforeinstallprompt', (e) => {
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
const installBtn = document.createElement('button');
|
|
387
|
+
installBtn.textContent = '📲 Instalar App';
|
|
388
|
+
installBtn.style.cssText = `
|
|
389
|
+
position: fixed; bottom: 20px; right: 20px;
|
|
390
|
+
background: linear-gradient(45deg, #8b5cf6, #a855f7);
|
|
391
|
+
color: white; border: none; padding: 12px 20px;
|
|
392
|
+
border-radius: 25px; cursor: pointer; font-weight: bold;
|
|
393
|
+
box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4); z-index: 1000;
|
|
394
|
+
`;
|
|
395
|
+
installBtn.addEventListener('click', () => e.prompt());
|
|
396
|
+
document.body.appendChild(installBtn);
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
""")
|
|
400
|
+
|
|
401
|
+
# === ENSAMBLAR APLICACIÓN ===
|
|
402
|
+
hero_section.add_child(hero_title)
|
|
403
|
+
hero_section.add_child(hero_subtitle)
|
|
404
|
+
hero_section.add_child(cta_button)
|
|
405
|
+
|
|
406
|
+
features_section.add_child(features_title)
|
|
407
|
+
features_section.add_child(features_grid)
|
|
408
|
+
|
|
409
|
+
form_container.add_child(name_input)
|
|
410
|
+
form_container.add_child(email_input)
|
|
411
|
+
form_container.add_child(terms_checkbox)
|
|
412
|
+
form_container.add_child(user_type_title)
|
|
413
|
+
form_container.add_child(developer_radio)
|
|
414
|
+
form_container.add_child(designer_radio)
|
|
415
|
+
form_container.add_child(country_select)
|
|
416
|
+
form_container.add_child(experience_title)
|
|
417
|
+
form_container.add_child(experience_slider)
|
|
418
|
+
form_container.add_child(birth_date_title)
|
|
419
|
+
form_container.add_child(birth_date_picker)
|
|
420
|
+
form_container.add_child(submit_button)
|
|
421
|
+
|
|
422
|
+
form_section.add_child(form_title)
|
|
423
|
+
form_section.add_child(form_container)
|
|
424
|
+
|
|
425
|
+
main_container.add_child(hero_section)
|
|
426
|
+
main_container.add_child(features_section)
|
|
427
|
+
main_container.add_child(form_section)
|
|
428
|
+
|
|
429
|
+
# Configurar aplicación
|
|
430
|
+
app.set_root(main_container)
|
|
431
|
+
app.add_script(interactive_script)
|
|
432
|
+
|
|
433
|
+
# Usar métodos extendidos
|
|
434
|
+
app.add_keywords(["responsive", "interactivo", "moderno"])
|
|
435
|
+
app.set_theme_colors("#1e3a8a", "#f8fafc")
|
|
436
|
+
app.enable_pwa("Mi App Moderna", "AppModerna")
|
|
437
|
+
|
|
438
|
+
# Estilos globales
|
|
439
|
+
app.add_global_style('body', {
|
|
440
|
+
'margin': '0',
|
|
441
|
+
'padding': '20px',
|
|
442
|
+
'background': 'linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%)',
|
|
443
|
+
'font-family': 'system-ui, -apple-system, sans-serif'
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
app.add_global_style('button:hover', {
|
|
447
|
+
'transform': 'translateY(-2px)',
|
|
448
|
+
'transition': 'all 0.3s ease'
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
if __name__ == "__main__":
|
|
452
|
+
app.rTimeCompile() # Preview/compilación rápida
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Plantilla: Todos los Componentes Dars - Básicos y Avanzados
|
|
4
|
+
Demuestra el uso completo e integrado de todos los componentes básicos y avanzados:
|
|
5
|
+
Text, Button, Input, Container, Image, Link, Textarea, Checkbox, RadioButton, Select, Slider, DatePicker,
|
|
6
|
+
Table, Tabs, Accordion, ProgressBar, Spinner, Tooltip
|
|
7
|
+
|
|
8
|
+
Uso:
|
|
9
|
+
dars init mi_proyecto -t advanced/all_components_demo
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from dars.core.app import App
|
|
13
|
+
from dars.components.basic.container import Container
|
|
14
|
+
from dars.components.basic.text import Text
|
|
15
|
+
from dars.components.basic.button import Button
|
|
16
|
+
from dars.components.basic.input import Input
|
|
17
|
+
from dars.components.basic.image import Image
|
|
18
|
+
from dars.components.basic.link import Link
|
|
19
|
+
from dars.components.basic.textarea import Textarea
|
|
20
|
+
from dars.components.basic.checkbox import Checkbox
|
|
21
|
+
from dars.components.basic.radiobutton import RadioButton
|
|
22
|
+
from dars.components.basic.select import Select, SelectOption
|
|
23
|
+
from dars.components.basic.slider import Slider
|
|
24
|
+
from dars.components.basic.datepicker import DatePicker
|
|
25
|
+
from dars.components.advanced.table import Table
|
|
26
|
+
from dars.components.advanced.tabs import Tabs
|
|
27
|
+
from dars.components.advanced.accordion import Accordion
|
|
28
|
+
from dars.components.basic.progressbar import ProgressBar
|
|
29
|
+
from dars.components.basic.spinner import Spinner
|
|
30
|
+
from dars.components.basic.tooltip import Tooltip
|
|
31
|
+
|
|
32
|
+
# App principal
|
|
33
|
+
app = App(title="Dars - Todos los Componentes Básicos y Avanzados")
|
|
34
|
+
|
|
35
|
+
main = Container(style={
|
|
36
|
+
'max-width': '900px',
|
|
37
|
+
'margin': '40px auto',
|
|
38
|
+
'padding': '32px',
|
|
39
|
+
'background': 'white',
|
|
40
|
+
'border-radius': '12px',
|
|
41
|
+
'box-shadow': '0 2px 12px rgba(0,0,0,0.08)'
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
main.children += [
|
|
45
|
+
Text("Demostración de TODOS los componentes de Dars", style={"font-size": "2rem", "font-weight": "bold", "margin-bottom": "24px"}),
|
|
46
|
+
# Básicos
|
|
47
|
+
Text("Componentes Básicos", style={"font-size": "1.3rem", "margin": "24px 0 12px 0", "color": "#007bff"}),
|
|
48
|
+
Text("Texto de ejemplo", style={"margin-bottom": "8px"}),
|
|
49
|
+
Button("Botón primario"),
|
|
50
|
+
Input(placeholder="Campo de texto"),
|
|
51
|
+
Image(src="https://via.placeholder.com/120x60.png?text=Logo", alt="Logo Demo", style={"margin": "10px 0"}),
|
|
52
|
+
Link("Ir a Dars Framework", href="https://github.com/ZtaMDev/Dars-Framework", target="_blank"),
|
|
53
|
+
Textarea(value="Texto multilinea de ejemplo", rows=3),
|
|
54
|
+
Checkbox(label="Acepto términos y condiciones", checked=True),
|
|
55
|
+
RadioButton(label="Opción A", name="grupo1", checked=True),
|
|
56
|
+
RadioButton(label="Opción B", name="grupo1"),
|
|
57
|
+
Select(options=[SelectOption("uno", "Uno"), SelectOption("dos", "Dos")], value="uno", placeholder="Selecciona una opción"),
|
|
58
|
+
Slider(min_value=0, max_value=100, value=50, label="Volumen", show_value=True),
|
|
59
|
+
DatePicker(value="2025-08-06"),
|
|
60
|
+
# Avanzados
|
|
61
|
+
Text("Componentes Avanzados", style={"font-size": "1.3rem", "margin": "32px 0 12px 0", "color": "#4a90e2"}),
|
|
62
|
+
Table(
|
|
63
|
+
columns=[{"title": "Nombre", "field": "nombre"}, {"title": "Edad", "field": "edad"}],
|
|
64
|
+
data=[{"nombre": "Ana", "edad": 28}, {"nombre": "Luis", "edad": 34}],
|
|
65
|
+
page_size=10
|
|
66
|
+
),
|
|
67
|
+
Tabs(
|
|
68
|
+
tabs=["Tab 1", "Tab 2"],
|
|
69
|
+
panels=[Text("Contenido de la pestaña 1"), Text("Contenido de la pestaña 2")],
|
|
70
|
+
selected=0
|
|
71
|
+
),
|
|
72
|
+
Accordion(
|
|
73
|
+
sections=[
|
|
74
|
+
("Sección 1", Text("Contenido de la sección 1")),
|
|
75
|
+
("Sección 2", Text("Contenido de la sección 2"))
|
|
76
|
+
],
|
|
77
|
+
open_indices=[0]
|
|
78
|
+
),
|
|
79
|
+
ProgressBar(value=70, max_value=100),
|
|
80
|
+
Spinner(),
|
|
81
|
+
Tooltip(child=Button("Pasa el mouse"), text="¡Tooltip de ejemplo!", position="top")
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
app.root = main
|
|
85
|
+
|
|
86
|
+
if __name__ == "__main__":
|
|
87
|
+
app.rTimeCompile()
|
|
File without changes
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from dars.all import *
|
|
2
|
+
from dars.core.state import dState, Mod
|
|
3
|
+
|
|
4
|
+
app = App(title="Dars State Mods Demo", theme="dark")
|
|
5
|
+
# Base components
|
|
6
|
+
counter_text = Text("0", id="Counter", style={
|
|
7
|
+
'font-size': '48px',
|
|
8
|
+
'font-weight': 'bold',
|
|
9
|
+
'margin-bottom': '16px'
|
|
10
|
+
})
|
|
11
|
+
status_text = Text("State: 0", id="Status", style={'margin-bottom': '16px'})
|
|
12
|
+
|
|
13
|
+
# Define a state bound to the counter_text element
|
|
14
|
+
counter = dState("counter", component=counter_text, states=[0,1,2,3])
|
|
15
|
+
|
|
16
|
+
# cState rules (compact Mod specs)
|
|
17
|
+
# - When entering state 1: increment text by +1
|
|
18
|
+
counter.cState(1, mods=[
|
|
19
|
+
Mod.inc(counter_text, prop='text', by=1),
|
|
20
|
+
Mod.set(status_text, text='State: 1'),
|
|
21
|
+
])
|
|
22
|
+
# - When entering state 2: decrement text by -1
|
|
23
|
+
counter.cState(2, mods=[
|
|
24
|
+
Mod.dec(counter_text, prop='text', by=1),
|
|
25
|
+
Mod.set(status_text, text='State: 2'),
|
|
26
|
+
])
|
|
27
|
+
# - When entering state 3: toggle CSS class and append text
|
|
28
|
+
counter.cState(3, mods=[
|
|
29
|
+
Mod.toggle_class(counter_text, name='highlight', on=None),
|
|
30
|
+
Mod.append_text(counter_text, value='!'),
|
|
31
|
+
# Prepare status to show state 0 upon auto-cycle (state 0 is immutable, no rules)
|
|
32
|
+
Mod.set(status_text, text='State: 0'),
|
|
33
|
+
])
|
|
34
|
+
# Auto-cycle back to 0 after applying state 3 mods
|
|
35
|
+
counter.cState(3).goto(0)
|
|
36
|
+
|
|
37
|
+
# Controls
|
|
38
|
+
inc_btn = Button("Next (+1)", id="NextBtn", on_click=counter.state(goto='+1'))
|
|
39
|
+
dec_btn = Button("Prev (-1)", id="PrevBtn", on_click=counter.state(goto='-1'))
|
|
40
|
+
# Full replace example (cComp=True) using deferred mod to avoid mutating at authoring time
|
|
41
|
+
swap_btn = Button(
|
|
42
|
+
"Swap HTML",
|
|
43
|
+
id="SwapBtn",
|
|
44
|
+
on_click=counter.state(2, cComp=True, render=counter_text.mod(text="SWAPPED"))
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# Layout
|
|
48
|
+
index = Page(
|
|
49
|
+
Container(
|
|
50
|
+
counter_text,
|
|
51
|
+
status_text,
|
|
52
|
+
Container(
|
|
53
|
+
inc_btn,
|
|
54
|
+
dec_btn,
|
|
55
|
+
swap_btn,
|
|
56
|
+
class_name="controls",
|
|
57
|
+
style={'display': 'flex', 'gap': '8px'}
|
|
58
|
+
),
|
|
59
|
+
class_name="wrapper",
|
|
60
|
+
style={'display': 'flex', 'flex-direction': 'column', 'align-items': 'center', 'padding': '40px'}
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
app.add_page("index", index, title="State Mods Demo", index=True)
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
app.rTimeCompile()
|