# 🔧 Foundations


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## 📦 VEnum

Base class for creating enums that work seamlessly with FastHTML
components.

<table>
<colgroup>
<col style="width: 40%" />
<col style="width: 59%" />
</colgroup>
<thead>
<tr>
<th>Feature</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>__str__</code></td>
<td>Returns the enum’s value as a string</td>
</tr>
<tr>
<td><code>__add__</code> / <code>__radd__</code></td>
<td>Concatenates with other values via <a
href="https://abhisheksreesaila.github.io/fh-matui/foundations.html#stringify"><code>stringify</code></a></td>
</tr>
</tbody>
</table>

> 💡 **Use case**: Define CSS class enums that can be combined with `+`
> operator.

------------------------------------------------------------------------

<a
href="https://github.com/abhisheksreesaila/fh-matui/blob/master/fh_matui/foundations.py#L17"
target="_blank" style="float:right; font-size:smaller">source</a>

### VEnum

``` python

def VEnum(
    args:VAR_POSITIONAL, kwds:VAR_KEYWORD
):

```

*Enum with string conversion and concatenation support*

``` python
# Example: Define a Size enum
class Size(VEnum):
    SMALL = "small"
    MEDIUM = "medium"
    LARGE = "large"

# Concatenate enums with strings
Size.SMALL + "primary"  # Returns: "small primary"
"btn " + Size.LARGE     # Returns: "btn large"
```

## 🔄 stringify

Converts various input types into space-separated strings for FT
component class attributes.

<table>
<thead>
<tr>
<th>Input</th>
<th>Output</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>None</code> / empty list</td>
<td><code>""</code></td>
</tr>
<tr>
<td>Single value</td>
<td><code>str(value)</code></td>
</tr>
<tr>
<td>List/tuple</td>
<td>Space-joined string</td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/abhisheksreesaila/fh-matui/blob/master/fh_matui/foundations.py#L26"
target="_blank" style="float:right; font-size:smaller">source</a>

### stringify

``` python

def stringify(
    o
):

```

*Converts input types into strings that can be passed to FT components*

``` python
stringify(["primary", "large", "rounded"])  # "primary large rounded"
stringify(Size.SMALL)                        # "small"
stringify((Size.MEDIUM, "filled"))           # "medium filled"
```

## 🧹 Token Utilities

Functions for normalizing and deduplicating CSS class tokens.

<table>
<colgroup>
<col style="width: 52%" />
<col style="width: 47%" />
</colgroup>
<thead>
<tr>
<th>Function</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><a
href="https://abhisheksreesaila.github.io/fh-matui/foundations.html#normalize_tokens"><code>normalize_tokens</code></a></td>
<td>Converts mixed inputs (strings, enums, lists) into a flat list of
tokens</td>
</tr>
<tr>
<td><a
href="https://abhisheksreesaila.github.io/fh-matui/foundations.html#dedupe_preserve_order"><code>dedupe_preserve_order</code></a></td>
<td>Removes duplicate tokens while keeping original order</td>
</tr>
</tbody>
</table>

> 💡 **Use case**: Clean up class attributes before passing to
> components — handles `"btn primary"`, `[Size.LARGE, "btn"]`, or mixed
> inputs.

------------------------------------------------------------------------

<a
href="https://github.com/abhisheksreesaila/fh-matui/blob/master/fh_matui/foundations.py#L35"
target="_blank" style="float:right; font-size:smaller">source</a>

### normalize_tokens

``` python

def normalize_tokens(
    cls
):

```

*Normalize class input to list of string tokens*

------------------------------------------------------------------------

<a
href="https://github.com/abhisheksreesaila/fh-matui/blob/master/fh_matui/foundations.py#L54"
target="_blank" style="float:right; font-size:smaller">source</a>

### dedupe_preserve_order

``` python

def dedupe_preserve_order(
    tokens
):

```

*Remove duplicates while preserving order*

``` python
# Pipeline: normalize → dedupe → stringify
tokens = normalize_tokens(["btn primary", Size.LARGE, "primary"])  # ['btn', 'primary', 'large', 'primary']
unique = dedupe_preserve_order(tokens)                              # ['btn', 'primary', 'large']
stringify(unique)                                                   # "btn primary large"
```
