fh-pydantic-form 0.2.0__py3-none-any.whl → 0.2.2__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.
Potentially problematic release.
This version of fh-pydantic-form might be problematic. Click here for more details.
- fh_pydantic_form/field_renderers.py +237 -92
- fh_pydantic_form/form_parser.py +78 -45
- fh_pydantic_form/form_renderer.py +132 -119
- fh_pydantic_form/list_path.py +145 -0
- fh_pydantic_form/ui_style.py +78 -47
- {fh_pydantic_form-0.2.0.dist-info → fh_pydantic_form-0.2.2.dist-info}/METADATA +4 -14
- fh_pydantic_form-0.2.2.dist-info/RECORD +14 -0
- fh_pydantic_form-0.2.0.dist-info/RECORD +0 -13
- {fh_pydantic_form-0.2.0.dist-info → fh_pydantic_form-0.2.2.dist-info}/WHEEL +0 -0
- {fh_pydantic_form-0.2.0.dist-info → fh_pydantic_form-0.2.2.dist-info}/licenses/LICENSE +0 -0
fh_pydantic_form/ui_style.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from enum import Enum, auto
|
|
2
2
|
from typing import Dict, Literal, Union
|
|
3
|
+
|
|
3
4
|
import fasthtml.common as fh
|
|
4
5
|
|
|
5
6
|
|
|
@@ -50,15 +51,17 @@ SPACING_MAP: Dict[SpacingTheme, Dict[str, str]] = {
|
|
|
50
51
|
"accordion_content": "",
|
|
51
52
|
"input_size": "",
|
|
52
53
|
"input_padding": "",
|
|
54
|
+
"horizontal_gap": "gap-3",
|
|
55
|
+
"label_align": "items-start",
|
|
53
56
|
},
|
|
54
57
|
SpacingTheme.COMPACT: {
|
|
55
|
-
"outer_margin": "mb-0
|
|
56
|
-
"outer_margin_sm": "mb-0
|
|
57
|
-
"inner_gap": "",
|
|
58
|
-
"inner_gap_small": "",
|
|
59
|
-
"stack_gap": "",
|
|
60
|
-
"padding": "p-
|
|
61
|
-
"padding_sm": "p-
|
|
58
|
+
"outer_margin": "mb-0",
|
|
59
|
+
"outer_margin_sm": "mb-0",
|
|
60
|
+
"inner_gap": "space-y-1",
|
|
61
|
+
"inner_gap_small": "space-y-0.5",
|
|
62
|
+
"stack_gap": "space-y-1",
|
|
63
|
+
"padding": "p-1",
|
|
64
|
+
"padding_sm": "p-0.5",
|
|
62
65
|
"padding_card": "px-2 py-1",
|
|
63
66
|
"card_border": "",
|
|
64
67
|
"section_divider": "",
|
|
@@ -68,6 +71,8 @@ SPACING_MAP: Dict[SpacingTheme, Dict[str, str]] = {
|
|
|
68
71
|
"accordion_content": "uk-padding-remove-vertical",
|
|
69
72
|
"input_size": "uk-form-small",
|
|
70
73
|
"input_padding": "p-1",
|
|
74
|
+
"horizontal_gap": "gap-2",
|
|
75
|
+
"label_align": "items-start",
|
|
71
76
|
},
|
|
72
77
|
}
|
|
73
78
|
|
|
@@ -78,46 +83,72 @@ def spacing(token: str, spacing: SpacingValue) -> str:
|
|
|
78
83
|
return SPACING_MAP[theme][token]
|
|
79
84
|
|
|
80
85
|
|
|
81
|
-
# CSS
|
|
86
|
+
# Optional minimal CSS for compact mode - affects only form inputs, not layout
|
|
87
|
+
# Host applications can optionally inject this once at app level if desired
|
|
82
88
|
COMPACT_EXTRA_CSS = fh.Style("""
|
|
83
|
-
/*
|
|
84
|
-
.compact
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/*
|
|
117
|
-
|
|
118
|
-
.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
89
|
+
/* Compact polish – applies ONLY inside .fhpf-compact ------------------- */
|
|
90
|
+
.fhpf-compact {
|
|
91
|
+
/* Force full width and left alignment */
|
|
92
|
+
width: 100% !important;
|
|
93
|
+
|
|
94
|
+
/* Ensure all direct children are full width and left aligned */
|
|
95
|
+
& > * {
|
|
96
|
+
width: 100% !important;
|
|
97
|
+
justify-content: flex-start !important;
|
|
98
|
+
align-items: flex-start !important;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Target the field containers specifically */
|
|
102
|
+
& > div > div {
|
|
103
|
+
width: 100% !important;
|
|
104
|
+
justify-content: flex-start !important;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Ensure flex containers don't center */
|
|
108
|
+
.flex {
|
|
109
|
+
justify-content: flex-start !important;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* Accordion chrome: remove border and default 20 px gap */
|
|
113
|
+
.uk-accordion > li,
|
|
114
|
+
.uk-accordion > li + li { /* second & later items */
|
|
115
|
+
border-top: 0 !important;
|
|
116
|
+
margin-top: 0 !important;
|
|
117
|
+
}
|
|
118
|
+
.uk-accordion-title::after { /* the hair-line we still see */
|
|
119
|
+
border-top: 0 !important;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Tighter title and content padding */
|
|
123
|
+
li > a.uk-accordion-title,
|
|
124
|
+
.uk-accordion-content {
|
|
125
|
+
padding-top: 0.25rem !important;
|
|
126
|
+
padding-bottom: 0.25rem !important;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Remove residual card outline */
|
|
130
|
+
.uk-card,
|
|
131
|
+
.uk-card-body { border: 0 !important; }
|
|
132
|
+
|
|
133
|
+
/* Small-size inputs */
|
|
134
|
+
input, select, textarea {
|
|
135
|
+
line-height: 1.25rem !important;
|
|
136
|
+
font-size: 0.8125rem !important;
|
|
137
|
+
padding-top: 0.25rem !important;
|
|
138
|
+
padding-bottom: 0.25rem !important;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* Legacy uk-form-small support */
|
|
142
|
+
input.uk-form-small,
|
|
143
|
+
select.uk-form-small,
|
|
144
|
+
textarea.uk-textarea-small {
|
|
145
|
+
padding-top: 2px !important;
|
|
146
|
+
padding-bottom: 2px !important;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* Kill generic uk-margin utilities inside the form */
|
|
150
|
+
.uk-margin-small-bottom,
|
|
151
|
+
.uk-margin,
|
|
152
|
+
.uk-margin-bottom { margin-bottom: 2px !important; }
|
|
122
153
|
}
|
|
123
154
|
""")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fh-pydantic-form
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: a library to turn any pydantic BaseModel object into a fasthtml/monsterui input form
|
|
5
5
|
Project-URL: Homepage, https://github.com/Marcura/fh-pydantic-form
|
|
6
6
|
Project-URL: Repository, https://github.com/Marcura/fh-pydantic-form
|
|
@@ -32,7 +32,8 @@ Description-Content-Type: text/markdown
|
|
|
32
32
|
|
|
33
33
|
`fh-pydantic-form` simplifies creating web forms for [FastHTML](https://github.com/AnswerDotAI/fasthtml) by automatically generating the necessary HTML input elements based on your Pydantic model definitions. It integrates seamlessly with and leverages [MonsterUI](https://github.com/AnswerDotAI/monsterui) components for styling.
|
|
34
34
|
|
|
35
|
-
<img width="
|
|
35
|
+
<img width="1348" alt="image" src="https://github.com/user-attachments/assets/59cc4f10-6858-41cb-80ed-e735a883cf20" />
|
|
36
|
+
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
<details >
|
|
@@ -225,19 +226,8 @@ form_normal = PydanticForm("normal_form", MyModel, spacing="normal")
|
|
|
225
226
|
form_compact = PydanticForm("compact_form", MyModel, spacing="compact")
|
|
226
227
|
```
|
|
227
228
|
|
|
228
|
-
**Compact mode** automatically injects additional CSS (`COMPACT_EXTRA_CSS`) to minimize margins, borders, and padding throughout the form. You can also import and use this CSS independently:
|
|
229
|
-
|
|
230
|
-
```python
|
|
231
|
-
from fh_pydantic_form import COMPACT_EXTRA_CSS
|
|
232
229
|
|
|
233
|
-
|
|
234
|
-
hdrs=[
|
|
235
|
-
mui.Theme.blue.headers(),
|
|
236
|
-
COMPACT_EXTRA_CSS, # Apply compact styling globally
|
|
237
|
-
],
|
|
238
|
-
# ...
|
|
239
|
-
)
|
|
240
|
-
```
|
|
230
|
+
**Important:** The compact CSS is now scoped with `.fhpf-compact` classes and only affects form inputs, not layout containers. This prevents conflicts with your application's layout system.
|
|
241
231
|
|
|
242
232
|
## Working with Lists
|
|
243
233
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
fh_pydantic_form/__init__.py,sha256=auqrMQyy6WsEeiMIdXVrjHpSuW_L7CpW2AZ1FOXb8QE,4058
|
|
2
|
+
fh_pydantic_form/defaults.py,sha256=IzBA_soBOdXP_XAUqfFAtniDQaW6N23hiXmWJD2xq0c,5168
|
|
3
|
+
fh_pydantic_form/field_renderers.py,sha256=D0GGqVpUUsJMIyX3tQEgNGPIQ6x8S3OEMj8qp94YDnE,53561
|
|
4
|
+
fh_pydantic_form/form_parser.py,sha256=9jSJya4TR5q2LMGV_PK-xiAjoEhq-FYKDN27lFNn5n0,24389
|
|
5
|
+
fh_pydantic_form/form_renderer.py,sha256=2f1n--_DD891x1-2ci4JFBVmO8yO7X_b5Ol8W5SA42E,35580
|
|
6
|
+
fh_pydantic_form/list_path.py,sha256=AA8bmDmaYy4rlGIvQOOZ0fP2tgcimNUB2Re5aVGnYc8,5182
|
|
7
|
+
fh_pydantic_form/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
fh_pydantic_form/registry.py,sha256=sufK-85ST3rc3Vu0XmjjjdTqTAqgHr_ZbMGU0xRgTK8,4996
|
|
9
|
+
fh_pydantic_form/type_helpers.py,sha256=bWHOxu52yh9_79d_x5L3cfMqnZo856OsbL4sTttDoa4,4367
|
|
10
|
+
fh_pydantic_form/ui_style.py,sha256=tJWY3MYO7XLmP0nm5x6qllEywarkoS1R-6jdxxKnYlU,4749
|
|
11
|
+
fh_pydantic_form-0.2.2.dist-info/METADATA,sha256=FSBPbRTJ2FFWxnRPoUHsSnixeeO1L6ZdRTLuZB6q5kA,26356
|
|
12
|
+
fh_pydantic_form-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
13
|
+
fh_pydantic_form-0.2.2.dist-info/licenses/LICENSE,sha256=AOi2eNK3D2aDycRHfPRiuACZ7WPBsKHTV2tTYNl7cls,577
|
|
14
|
+
fh_pydantic_form-0.2.2.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
fh_pydantic_form/__init__.py,sha256=auqrMQyy6WsEeiMIdXVrjHpSuW_L7CpW2AZ1FOXb8QE,4058
|
|
2
|
-
fh_pydantic_form/defaults.py,sha256=IzBA_soBOdXP_XAUqfFAtniDQaW6N23hiXmWJD2xq0c,5168
|
|
3
|
-
fh_pydantic_form/field_renderers.py,sha256=rPzTvpDpXuy7H4rim6zlogTWNhFrh5mflxRcI4MbF_M,48508
|
|
4
|
-
fh_pydantic_form/form_parser.py,sha256=TcoN7IWilyC0JptigZzdd3ciyEO6ARiqHhiyQ3Ufr_o,23658
|
|
5
|
-
fh_pydantic_form/form_renderer.py,sha256=9ysQLLT6e8a5LbPHszEOUpyryJIYEev-3a3eZxBx6Zs,34892
|
|
6
|
-
fh_pydantic_form/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
fh_pydantic_form/registry.py,sha256=sufK-85ST3rc3Vu0XmjjjdTqTAqgHr_ZbMGU0xRgTK8,4996
|
|
8
|
-
fh_pydantic_form/type_helpers.py,sha256=bWHOxu52yh9_79d_x5L3cfMqnZo856OsbL4sTttDoa4,4367
|
|
9
|
-
fh_pydantic_form/ui_style.py,sha256=L_Z21nJ1YVKcDRMDphRcgHuQ33P4YHxa3oSjMwD55gw,3808
|
|
10
|
-
fh_pydantic_form-0.2.0.dist-info/METADATA,sha256=o7qPV16HL1dTYTgACd3Osr7FQ_L6XCuMq3wq7rZntl0,26566
|
|
11
|
-
fh_pydantic_form-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
12
|
-
fh_pydantic_form-0.2.0.dist-info/licenses/LICENSE,sha256=AOi2eNK3D2aDycRHfPRiuACZ7WPBsKHTV2tTYNl7cls,577
|
|
13
|
-
fh_pydantic_form-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|