Functions
register_colors
1
None
▼
Register semantic color names (e.g. Pokémon types) for `resolve_color`().
register_colors
1
None
▼
def register_colors(mapping: Mapping[str, str]) -> None
Parameters
| Name | Type | Description |
|---|---|---|
mapping |
Mapping[str, str] |
sanitize_color
1
str | None
▼
Return the color if it matches a safe CSS color pattern, else None.
sanitize_color
1
str | None
▼
def sanitize_color(value: object) -> str | None
Parameters
| Name | Type | Description |
|---|---|---|
value |
object |
Returns
str | None
contrast_text
1
str
▼
Return ``white`` or ``#1a1a1a`` for readable text on solid ``css_color`` (hex).
contrast_text
1
str
▼
def contrast_text(css_color: str) -> str
Returnwhite or #1a1a1a for readable text on solid css_color(hex).
Parameters
| Name | Type | Description |
|---|---|---|
css_color |
str |
Returns
str
resolve_color
1
str | None
▼
Resolve a named color from the registry, then validate as a CSS color string.
resolve_color
1
str | None
▼
def resolve_color(value: object) -> str | None
Parameters
| Name | Type | Description |
|---|---|---|
value |
object |
Returns
str | None
bem
4
str
▼
Build chirpui BEM class string: chirpui-{block} chirpui-{block}--{variant} etc.
bem
4
str
▼
def bem(block: str, variant: str = '', modifier: str = '', cls: str = '') -> str
Build chirpui BEM class string: chirpui-{block} chirpui-{block}--{variant} etc.
Parameters
| Name | Type | Description |
|---|---|---|
block |
str |
|
variant |
str |
Default:''
|
modifier |
str |
Default:''
|
cls |
str |
Default:''
|
Returns
str
validate_variant
3
str
▼
Return value if in allowed, else default. When strict, log warning.
validate_variant
3
str
▼
def validate_variant(value: str, allowed: tuple[str, ...], default: str = '') -> str
Parameters
| Name | Type | Description |
|---|---|---|
value |
str |
|
allowed |
tuple[str, ...] |
|
default |
str |
Default:''
|
Returns
str
validate_variant_block
3
str
▼
Return value if in VARIANT_REGISTRY for block, else default. When strict, log w…
validate_variant_block
3
str
▼
def validate_variant_block(value: str, block: str, default: str = '') -> str
Return value if in VARIANT_REGISTRY for block, else default. When strict, log warning.
Parameters
| Name | Type | Description |
|---|---|---|
value |
str |
|
block |
str |
|
default |
str |
Default:''
|
Returns
str
value_type
1
str
▼
Map Python types to ChirpUI CSS variant names for description_item.
Returns: "…
value_type
1
str
▼
def value_type(value: Any) -> str
Map Python types to ChirpUI CSS variant names for description_item.
Returns: "unset" | "bool" | "number" | "path" | "" (plain string).
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
Returns
str
validate_size
3
str
▼
Return value if in SIZE_REGISTRY for block, else default. When strict, log warn…
validate_size
3
str
▼
def validate_size(value: str, block: str, default: str = '') -> str
Return value if in SIZE_REGISTRY for block, else default. When strict, log warning.
Parameters
| Name | Type | Description |
|---|---|---|
value |
str |
|
block |
str |
|
default |
str |
Default:''
|
Returns
str
icon
1
str
▼
Resolve icon name to glyph; unknown names pass through. When strict, log warnin…
icon
1
str
▼
def icon(name: str) -> str
Resolve icon name to glyph; unknown names pass through. When strict, log warning.
Parameters
| Name | Type | Description |
|---|---|---|
name |
str |
Returns
str
field_errors
2
list[str]
▼
Extract error messages for a field from a ValidationError-style dict.
Returns …
field_errors
2
list[str]
▼
def field_errors(errors: dict[str, object] | None, field_name: str) -> list[str]
Extract error messages for a field from a ValidationError-style dict.
Returns empty list if errors is None, not a dict, or field has no errors.
Parameters
| Name | Type | Description |
|---|---|---|
errors |
dict[str, object] | None |
|
field_name |
str |
Returns
list[str]
html_attrs
1
str | Markup
▼
Render HTML attrs from mapping or legacy raw string.
html_attrs
1
str | Markup
▼
def html_attrs(value: Any) -> str | Markup
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
Returns
str | Markup