Metadata-Version: 2.4
Name: urban-json-editor
Version: 0.1.1
Summary: Composant d'édition jslt réutilisable (Web Component : coloration syntaxique + intellisense).
Author-email: Gael Beard <gaelgael5@gmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/gaelgael5/Jslt
Project-URL: Repository, https://github.com/gaelgael5/Jslt
Keywords: json,transform,template,jslt,editor,web-component
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Editors
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: urban-json
Provides-Extra: test
Requires-Dist: starlette; extra == "test"
Dynamic: license-file

# urban-json-editor

Composant d'édition **jslt** réutilisable : un Web Component `<jslt-editor>` avec
**coloration syntaxique** et **intellisense** (auto-complétion des fonctions),
livré pour être intégré dans n'importe quel projet web Python.

- **Sans dépendance côté navigateur** (vanilla Web Component) → aucun build node,
  drop-in dans un projet existant.
- **Intellisense** alimentée par le catalogue de fonctions de `urban-json`
  (`registry.catalog()`), donc toujours à jour — y compris les fonctions de
  plugins installés.

## Installation

```bash
pip install urban-json-editor
```

## Intégration (FastAPI)

```python
from fastapi import FastAPI
from fastapi.responses import JSONResponse
import urban_json_editor

app = FastAPI()
urban_json_editor.mount(app, "/jslt-editor")          # sert les assets JS/CSS

@app.get("/api/functions")
def functions():
    return JSONResponse({"functions": urban_json_editor.catalog()})
```

Dans la page :

```html
<link rel="stylesheet" href="/jslt-editor/jslt-editor.css">
<script type="module" src="/jslt-editor/jslt-editor.js"></script>

<jslt-editor id="ed" catalog-url="/api/functions"></jslt-editor>
<script>
  const ed = document.getElementById("ed");
  ed.value = '{ "n": $.x }';
  ed.addEventListener("input", () => console.log(ed.value));
</script>
```

## API Python

| Fonction | Rôle |
|---|---|
| `assets_dir()` | dossier des assets statiques (pour servir à la main, hors FastAPI) |
| `catalog(registry=None)` | catalogue de fonctions (intellisense) depuis un registre urban-json |
| `mount(app, url_path="/jslt-editor")` | monte les assets sur une app FastAPI/Starlette |

## API du composant

- Propriété `value` (get/set) — le texte du template (source de vérité).
- `setCatalog(list)` — fournit le catalogue d'intellisense par programme.
- Attribut `catalog-url` — URL d'où charger le catalogue (`{functions:[...]}`).
- Événement `input` — émis à chaque modification.
- Variables CSS `--jslt-ed-*` surchargeables (couleurs, police, hauteur).

## Licence

Apache-2.0.
