Metadata-Version: 2.3
Name: mcms-components
Version: 0.1.0
Summary: Defines the reusable, declarative components that make up an MCMS site
Author: MikemathuKE
Author-email: MikemathuKE <michaelmathu6@gmail.com>
Requires-Dist: django>=6.0
Requires-Dist: mcms-core
Requires-Dist: mcms-content
Requires-Dist: mcms-design
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# MCMS Components

`mcms_components` defines the reusable, declarative components that make up an MCMS site. Components describe structure, composition, values, and behaviour; they do not render HTML or retrieve application data themselves.

## Responsibilities

- Define component schemas and runtime component definitions.
- Support primitive components such as text, image, button, link, and icon.
- Support structural components such as container, grid, row, column, stack, and section.
- Represent component composition consistently, including page-root structures.
- Declare component values as literals or data bindings.
- Declare component styling configuration and variants without owning visual presentation.
- Resolve component definitions into the runtime representation consumed by `mcms_render`.

Components may be supplied by built-in Python definitions, JSON definitions, database-backed definitions, or future external providers. Built-in and runtime-defined components should be treated consistently by the resolution pipeline.

## Architecture

```text
Component definitions
        |
        v
Component resolution
        |
        v
RenderTree / RenderNode
        |
        v
mcms_render
        |
        v
Output
```

A component definition is not itself a rendered element. The renderer operates on the resolved render tree, not on component registries or source definitions.

### Component categories

| Category | Purpose | Examples |
|---|---|---|
| Content | Represents an individual element or simple UI element often in reference to text and text layout | Text, Code, List, Link, Break |
| Structure | Defines structural components that have specific tasks | Article, Badge, Header, Section, Main, Table |
| Layout | Defines composition and accepts child components | Column, Container, Empty, Grid, Stack |
| Form | Refers to any form elements especially for accepting input from the user | Form, Button, FieldSet, Input, Label |
| Media | Refers to any media form such as audio, images and video | Image, Audio, Video |
| Navigation | Refers Pagination navigation tools | NavigationButton, CurrentPage |
| Popup | Refers to any elements that appear on condition of events such as clicks | Dialog, Alert, Toast, Modal |


## Values and data binding

Component values may be static or data-driven. The component architecture supports literal values and declarative bindings. Components declare the values they need; they do not query Django models, databases, APIs, or other providers directly.

The current data-binding architecture is implemented by `mcms_data`. See [MCMS Data](../mcms_data/README.md).

## Styling

Components define structure and behaviour, not visual design decisions. Colours, typography, spacing, effects, themes, and CSS generation belong to `mcms_design`.

A component may expose styling configuration or variants, but visual definitions are resolved by the design system.

## Architectural integrations

| Package | Relationship |
|---|---|
| `mcms_core` | Shared infrastructure, including the common registry convention |
| `mcms_design` | Resolves component and instance presentation |
| `mcms_content` | Provides definitions for Field Types |

These are architectural relationships from the ADRs. Confirm the actual runtime dependency declarations in the package `pyproject.toml` files.

## Application configuration

This package contains a component registry in its app settings which stores all active and usable components.

## Dependencies

### Architectural integrations

See the integration table above. In particular, component definitions must remain independent of data retrieval and HTML rendering.

### Python distribution dependencies

All MCMS Packages rely on django

## Development

Run the package tests from the repository root using the project's configured test command:

```bash
uv run pytest packages/mcms-components/tests
```

Use the repository's configured Ruff and mypy checks where applicable.
