fh-pydantic-form 0.3.6__py3-none-any.whl → 0.3.8__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fh-pydantic-form
3
- Version: 0.3.6
3
+ Version: 0.3.8
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
@@ -18,9 +18,9 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Content Management System
19
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
20
  Requires-Python: >=3.10
21
- Requires-Dist: monsterui>=1.0.19
21
+ Requires-Dist: monsterui>=1.0.29
22
22
  Requires-Dist: pydantic>=2.0
23
- Requires-Dist: python-fasthtml>=0.12.12
23
+ Requires-Dist: python-fasthtml>=0.12.29
24
24
  Description-Content-Type: text/markdown
25
25
 
26
26
  # fh-pydantic-form
@@ -480,6 +480,83 @@ form_renderer = PydanticForm(
480
480
 
481
481
  This automatic default injection means you can safely exclude fields that shouldn't be user-editable while maintaining data integrity.
482
482
 
483
+ ### SkipJsonSchema Fields
484
+
485
+ `fh-pydantic-form` provides advanced handling for `SkipJsonSchema` fields with selective visibility control. By default, fields marked with `SkipJsonSchema` are hidden from forms, but you can selectively show specific ones using the `keep_skip_json_fields` parameter.
486
+
487
+ ```python
488
+ from pydantic.json_schema import SkipJsonSchema
489
+
490
+ class DocumentModel(BaseModel):
491
+ title: str
492
+ content: str
493
+
494
+ # Hidden by default - system fields
495
+ document_id: SkipJsonSchema[str] = Field(
496
+ default_factory=lambda: f"doc_{uuid4().hex[:12]}",
497
+ description="Internal document ID"
498
+ )
499
+ created_at: SkipJsonSchema[datetime.datetime] = Field(
500
+ default_factory=datetime.datetime.now,
501
+ description="Creation timestamp"
502
+ )
503
+ version: SkipJsonSchema[int] = Field(
504
+ default=1,
505
+ description="Document version"
506
+ )
507
+
508
+ # Normal form - all SkipJsonSchema fields hidden
509
+ form_normal = PydanticForm("doc_form", DocumentModel)
510
+
511
+ # Admin form - selectively show some SkipJsonSchema fields
512
+ form_admin = PydanticForm(
513
+ "admin_form",
514
+ DocumentModel,
515
+ keep_skip_json_fields=[
516
+ "document_id", # Show document ID
517
+ "version", # Show version number
518
+ # created_at remains hidden
519
+ ]
520
+ )
521
+ ```
522
+
523
+ #### Nested SkipJsonSchema Fields
524
+
525
+ The feature supports dot notation for nested objects and list items:
526
+
527
+ ```python
528
+ class Address(BaseModel):
529
+ street: str
530
+ city: str
531
+ # Hidden system field
532
+ internal_id: SkipJsonSchema[str] = Field(default_factory=lambda: f"addr_{uuid4().hex[:8]}")
533
+
534
+ class UserModel(BaseModel):
535
+ name: str
536
+ main_address: Address
537
+ other_addresses: List[Address]
538
+
539
+ # Show specific nested SkipJsonSchema fields
540
+ form = PydanticForm(
541
+ "user_form",
542
+ UserModel,
543
+ keep_skip_json_fields=[
544
+ "main_address.internal_id", # Show main address ID
545
+ "other_addresses.internal_id", # Show all address IDs in the list
546
+ ]
547
+ )
548
+ ```
549
+
550
+ **Key Features:**
551
+ - **Hidden by default:** SkipJsonSchema fields are automatically excluded from forms
552
+ - **Selective visibility:** Use `keep_skip_json_fields` to show specific fields
553
+ - **Nested support:** Access nested fields with dot notation (`"main_address.internal_id"`)
554
+ - **List support:** Show fields in all list items (`"addresses.internal_id"`)
555
+ - **Smart defaults:** Non-kept fields use model defaults, kept fields retain initial values
556
+ - **Admin interfaces:** Perfect for admin panels or debugging where you need to see system fields
557
+
558
+ See `examples/complex_example.py` for a comprehensive demonstration of SkipJsonSchema field handling.
559
+
483
560
  ## Refreshing & Resetting
484
561
 
485
562
  Forms support dynamic refresh and reset functionality:
@@ -824,6 +901,38 @@ comparison_form.register_routes(app)
824
901
  - **Metrics Integration**: Right side typically shows LLM output quality scores
825
902
  - **Flexible Layout**: Responsive design works on desktop and mobile
826
903
  - **Form Validation**: Standard validation works with either form
904
+ - **Intelligent List Copying**: Copy lists between forms with automatic length adjustment
905
+
906
+ ### Copying Between Forms
907
+
908
+ The ComparisonForm provides granular copy functionality at multiple levels. When you enable copy buttons (via `copy_left=True` or `copy_right=True`), each field, nested model, and list item gets its own copy button for maximum flexibility:
909
+
910
+ ```python
911
+ # Enable copy buttons (copy FROM right TO left)
912
+ comparison_form = ComparisonForm(
913
+ name="extraction_evaluation",
914
+ left_form=left_form,
915
+ right_form=right_form,
916
+ left_label="Ground Truth",
917
+ right_label="LLM Output",
918
+ copy_left=True, # Show copy buttons on right form to copy TO left
919
+ )
920
+ ```
921
+
922
+ **Copy Granularity Levels:**
923
+
924
+ The copy feature works at five different levels of granularity:
925
+
926
+ 1. **Individual Fields** - Copy a single field value (e.g., `name`, `price`, `status`)
927
+
928
+ 2. **Nested BaseModel (Entire Object)** - Copy all fields within a nested model at once
929
+
930
+ 3. **Individual Fields in Nested Models** - Copy a specific field within a nested object
931
+
932
+ 4. **Full List Fields** - Copy entire lists with automatic length adjustment
933
+
934
+ 5. **Individual List Items** - Add a single item from one list to another
935
+
827
936
 
828
937
  ### Common Patterns
829
938
 
@@ -1007,6 +1116,7 @@ form_renderer = PydanticForm(
1007
1116
  | `disabled_fields` | `Optional[List[str]]` | `None` | List of specific field names to disable |
1008
1117
  | `label_colors` | `Optional[Dict[str, str]]` | `None` | Mapping of field names to CSS colors or Tailwind classes |
1009
1118
  | `exclude_fields` | `Optional[List[str]]` | `None` | List of field names to exclude from rendering (auto-injected on submission) |
1119
+ | `keep_skip_json_fields` | `Optional[List[str]]` | `None` | List of SkipJsonSchema field paths to selectively show (supports dot notation for nested fields) |
1010
1120
  | `spacing` | `SpacingValue` | `"normal"` | Spacing theme: `"normal"`, `"compact"`, or `SpacingTheme` enum |
1011
1121
  | `metrics_dict` | `Optional[Dict[str, Dict]]` | `None` | Field metrics for highlighting and tooltips |
1012
1122
 
@@ -1025,7 +1135,7 @@ form_renderer = PydanticForm(
1025
1135
  | Method | Purpose |
1026
1136
  |--------|---------|
1027
1137
  | `render_inputs()` | Generate the HTML form inputs (without `<form>` wrapper) |
1028
- | `with_initial_values(initial_values)` | Create a new form instance with same configuration but different initial values |
1138
+ | `with_initial_values(initial_values, metrics_dict=None)` | Create a new form instance with same configuration but different initial values |
1029
1139
  | `refresh_button(text=None, **kwargs)` | Create a refresh button component |
1030
1140
  | `reset_button(text=None, **kwargs)` | Create a reset button component |
1031
1141
  | `register_routes(app)` | Register HTMX endpoints for list manipulation |
@@ -1,17 +1,17 @@
1
1
  fh_pydantic_form/__init__.py,sha256=uPN0pwErHoe69tDoCDdIYD_iCslMKRgfYw6pvL4McHE,4608
2
2
  fh_pydantic_form/color_utils.py,sha256=M0HSXX0i-lSHkcsgesxw7d3PEAnLsZ46i_STymZAM_k,18271
3
- fh_pydantic_form/comparison_form.py,sha256=Y-OKAjTxMiixBC05SK1ofZ_A3zkvjUFp8tTE-_wUn60,21660
3
+ fh_pydantic_form/comparison_form.py,sha256=UuA9QOM9V1hsg3oxZrO99Jp4xIi1if7uEuPN9U-SLqg,63793
4
4
  fh_pydantic_form/constants.py,sha256=-N9wzkibFNn-V6cO8iWTQ7_xBvwSr2hBdq-m3apmW4M,169
5
5
  fh_pydantic_form/defaults.py,sha256=9vV0f4PapTOgqNsIxoW6rEbpYO66O4uiKvpd6hzR1-M,6189
6
- fh_pydantic_form/field_renderers.py,sha256=twAqHvWkDL6M-HRcdi_JrR2BgzkPmMyF_vojId5ABa0,83574
7
- fh_pydantic_form/form_parser.py,sha256=DsOMiCXRRHswL37Vqv7bvMv3Q7nQdXp0oP3_ZoIJfVc,26172
8
- fh_pydantic_form/form_renderer.py,sha256=G_pO3rQrv3lCpiqfZfPkT96duDLp466CWU1PTOy9U4E,36619
6
+ fh_pydantic_form/field_renderers.py,sha256=SYBXbFTrnZ9qQnEongrMUMaTu0OWKVluiZiA4lK8A3U,92747
7
+ fh_pydantic_form/form_parser.py,sha256=LKeGiCeyYJ0eIZE6oETcxl1DpKjk1MpoCSh_VAvUgGk,29701
8
+ fh_pydantic_form/form_renderer.py,sha256=looOW7nabPeQH3R7t5ZO_QMpBfoQtTO48p0QqZIhpfA,39175
9
9
  fh_pydantic_form/list_path.py,sha256=AA8bmDmaYy4rlGIvQOOZ0fP2tgcimNUB2Re5aVGnYc8,5182
10
10
  fh_pydantic_form/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  fh_pydantic_form/registry.py,sha256=b5zIjOpfmCUCs2njgp4PdDu70ioDIAfl49oU-Nf2pg4,4810
12
- fh_pydantic_form/type_helpers.py,sha256=JUzHT8YrWj2_g7f_Wr2GL9i3BgP1zZftFrrO8xDPeis,7409
12
+ fh_pydantic_form/type_helpers.py,sha256=C6Oem1frgj_T_CqiE-9yyVKI7YpFFEAKAGVXe04OkJU,8245
13
13
  fh_pydantic_form/ui_style.py,sha256=UPK5OBwUVVTLnfvQ-yKukz2vbKZaT_GauaNB7OGc-Uw,3848
14
- fh_pydantic_form-0.3.6.dist-info/METADATA,sha256=cdQwkkDEOFsqTvZVbGTIZjhgRk_vx4PK0MKtds79oYU,38420
15
- fh_pydantic_form-0.3.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- fh_pydantic_form-0.3.6.dist-info/licenses/LICENSE,sha256=AOi2eNK3D2aDycRHfPRiuACZ7WPBsKHTV2tTYNl7cls,577
17
- fh_pydantic_form-0.3.6.dist-info/RECORD,,
14
+ fh_pydantic_form-0.3.8.dist-info/METADATA,sha256=MdCq-9oxeFcKs3FZ6FY7MAQJWF55p-NiyMvJL9Nuu9w,42391
15
+ fh_pydantic_form-0.3.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ fh_pydantic_form-0.3.8.dist-info/licenses/LICENSE,sha256=AOi2eNK3D2aDycRHfPRiuACZ7WPBsKHTV2tTYNl7cls,577
17
+ fh_pydantic_form-0.3.8.dist-info/RECORD,,