dars-framework 1.0.0__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.
Files changed (68) hide show
  1. dars/__init__.py +0 -0
  2. dars/all.py +52 -0
  3. dars/cli/__init__.py +0 -0
  4. dars/cli/hot_reload.py +33 -0
  5. dars/cli/main.py +637 -0
  6. dars/cli/preview.py +419 -0
  7. dars/cli/translations.py +389 -0
  8. dars/components/__init__.py +0 -0
  9. dars/components/advanced/__init__.py +8 -0
  10. dars/components/advanced/accordion.py +21 -0
  11. dars/components/advanced/card.py +28 -0
  12. dars/components/advanced/modal.py +40 -0
  13. dars/components/advanced/navbar.py +31 -0
  14. dars/components/advanced/table.py +24 -0
  15. dars/components/advanced/tabs.py +26 -0
  16. dars/components/basic/__init__.py +34 -0
  17. dars/components/basic/button.py +29 -0
  18. dars/components/basic/checkbox.py +34 -0
  19. dars/components/basic/container.py +23 -0
  20. dars/components/basic/datepicker.py +139 -0
  21. dars/components/basic/image.py +36 -0
  22. dars/components/basic/input.py +50 -0
  23. dars/components/basic/link.py +31 -0
  24. dars/components/basic/page.py +20 -0
  25. dars/components/basic/progressbar.py +17 -0
  26. dars/components/basic/radiobutton.py +34 -0
  27. dars/components/basic/select.py +81 -0
  28. dars/components/basic/slider.py +63 -0
  29. dars/components/basic/spinner.py +11 -0
  30. dars/components/basic/text.py +22 -0
  31. dars/components/basic/textarea.py +46 -0
  32. dars/components/basic/tooltip.py +18 -0
  33. dars/components/layout/__init__.py +0 -0
  34. dars/components/layout/anchor.py +13 -0
  35. dars/components/layout/flex.py +26 -0
  36. dars/components/layout/grid.py +45 -0
  37. dars/core/__init__.py +0 -0
  38. dars/core/app.py +630 -0
  39. dars/core/component.py +25 -0
  40. dars/core/events.py +101 -0
  41. dars/core/properties.py +127 -0
  42. dars/docs/__init__.py +0 -0
  43. dars/exporters/__init__.py +0 -0
  44. dars/exporters/base.py +69 -0
  45. dars/exporters/web/__init__.py +0 -0
  46. dars/exporters/web/html_css_js.py +1406 -0
  47. dars/scripts/__init__.py +0 -0
  48. dars/scripts/script.py +38 -0
  49. dars/templates/__init__.py +0 -0
  50. dars/templates/examples/advanced/all_components_demo.py +87 -0
  51. dars/templates/examples/advanced/dashboard.py +440 -0
  52. dars/templates/examples/advanced/modern_web_app.py +452 -0
  53. dars/templates/examples/basic/flex_layout_responsive.py +13 -0
  54. dars/templates/examples/basic/form_components.py +516 -0
  55. dars/templates/examples/basic/grid_layout_responsive.py +13 -0
  56. dars/templates/examples/basic/hello_world.py +104 -0
  57. dars/templates/examples/basic/layout_multipage_demo.py +23 -0
  58. dars/templates/examples/basic/multipage_example.py +70 -0
  59. dars/templates/examples/basic/pwa_custom_icons.py +31 -0
  60. dars/templates/examples/basic/simple_form.py +377 -0
  61. dars/templates/examples/demo/complete_app.py +720 -0
  62. dars/templates/html/__init__.py +0 -0
  63. dars_framework-1.0.0.dist-info/METADATA +146 -0
  64. dars_framework-1.0.0.dist-info/RECORD +68 -0
  65. dars_framework-1.0.0.dist-info/WHEEL +5 -0
  66. dars_framework-1.0.0.dist-info/entry_points.txt +2 -0
  67. dars_framework-1.0.0.dist-info/licenses/LICENSE +21 -0
  68. dars_framework-1.0.0.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,13 @@
1
+ from dars.all import App, FlexLayout, Button, Text, Image, AnchorPoint
2
+
3
+ app = App(title="FlexLayout Responsive Example")
4
+
5
+ flex = FlexLayout(direction="row", wrap="wrap", gap="2vw", justify="center", align="center")
6
+ flex.add_child(Text("Start"), anchor="left")
7
+ flex.add_child(Button("Center"), anchor="center")
8
+ flex.add_child(Image(src="https://placehold.co/120x120", alt="Demo", style={"width": "100%"}), anchor=AnchorPoint(x="right", y="bottom"))
9
+
10
+ app.set_root(flex)
11
+
12
+ if __name__ == "__main__":
13
+ app.rTimeCompile()