lmdiagram 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +82 -47
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,79 +1,114 @@
1
- ![GitHub](https://img.shields.io/github/license/lmoraobando/lmdiagram?color=green)
2
- ![GitHub last commit](https://img.shields.io/github/last-commit/lmoraobando/lmdiagram)
3
- ![GitHub top language](https://img.shields.io/github/languages/top/lmoraobando/lmdiagram)
1
+ # lmdiagram
4
2
 
5
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
4
+ [![npm version](https://img.shields.io/npm/v/lmdiagram.svg)](https://www.npmjs.com/package/lmdiagram)
6
5
 
7
- ![image](https://user-images.githubusercontent.com/11163835/133908185-0e1d3cc9-fdcf-4e65-b0b5-c30cda81c212.png)
6
+ Componente React para diagramas con **modelos enlazados** (nodos arrastrables y **asociaciones** con curvas SVG). Incluye API basada en clases de datos (`DiagramModel`, `AssociationModel`, `ControllerLM`) y una UI actualizable con variables CSS.
8
7
 
9
- ## A basic example shown on the gif
8
+ **Versión actual:** 0.2.x · React 17+ (peer dependency)
10
9
 
11
- ![test](https://user-images.githubusercontent.com/11163835/133908159-bffd8e10-7386-4336-b008-9d7696b5bcee.gif)
10
+ ---
12
11
 
12
+ ## Instalación
13
13
 
14
- ## Available Scripts
14
+ ```bash
15
+ npm install lmdiagram
16
+ ```
15
17
 
16
- In the project directory, you can run:
18
+ Asegúrate de tener React en tu proyecto:
17
19
 
18
- ### `npm start`
20
+ ```bash
21
+ npm install react react-dom
22
+ ```
19
23
 
20
- Runs the app in the development mode.<br>
21
- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
24
+ ## Uso rápido
22
25
 
23
- The page will reload if you make edits.<br>
24
- You will also see any lint errors in the console.
26
+ ```jsx
27
+ import { LMDiagram } from 'lmdiagram';
28
+ import 'lmdiagram/styles.css';
25
29
 
26
- ### `npm test`
30
+ export function App() {
31
+ return <LMDiagram />;
32
+ }
33
+ ```
27
34
 
28
- Launches the test runner in the interactive watch mode.<br>
29
- See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
35
+ El componente `LMDiagram` incluye un ejemplo por defecto (tres modelos y dos enlaces). Para un grafo propio, usa `buildDiagram` (idealmente con `useCallback` para no recrear el objeto en cada render).
30
36
 
31
- ### `npm run build`
37
+ ```jsx
38
+ import { useCallback } from 'react';
39
+ import {
40
+ LMDiagram,
41
+ DiagramModel,
42
+ AssociationModel,
43
+ ControllerLM,
44
+ } from 'lmdiagram';
45
+ import 'lmdiagram/styles.css';
32
46
 
33
- Builds the app for production to the `build` folder.<br>
34
- It correctly bundles React in production mode and optimizes the build for the best performance.
47
+ export function App() {
48
+ const buildDiagram = useCallback(() => {
49
+ const a = new DiagramModel('Origen', 'Detalle A');
50
+ a.setPosition(120, 80);
51
+ const b = new DiagramModel('Destino', 'Detalle B');
52
+ b.setPosition(120, 280);
35
53
 
36
- The build is minified and the filenames include the hashes.<br>
37
- Your app is ready to be deployed!
54
+ const assoc = new AssociationModel();
55
+ assoc.setLink(a, b, 'Mi etiqueta'); // tercer argumento opcional: texto sobre el trazo
38
56
 
39
- See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
57
+ const controller = new ControllerLM();
58
+ controller.setAssociations(assoc);
59
+ return controller;
60
+ }, []);
40
61
 
41
- ### `npm run eject`
62
+ return <LMDiagram buildDiagram={buildDiagram} />;
63
+ }
64
+ ```
42
65
 
43
- **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
66
+ ## API exportada
44
67
 
45
- If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
68
+ | Export | Descripción |
69
+ |-------------------|-------------|
70
+ | `LMDiagram` | Componente principal. Props: `className`, `buildDiagram` (opcional). |
71
+ | `ModalDiagrama` | Alias de `LMDiagram` (deprecado). |
72
+ | `DiagramModel` | Nodo: `header`, `body`, `setPosition(top, left)`, `width`, `height`, etc. |
73
+ | `AssociationModel` | `setLink(modeloA, modeloB, etiquetaOpcional)` — enlaces y etiqueta en SVG. |
74
+ | `ControllerLM` | `setAssociations(association)` — contenedor que usa el diagrama. |
46
75
 
47
- Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
76
+ ## Estados y estilos
48
77
 
49
- You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
78
+ Los estilos viven en `lmdiagram/styles.css`. Puedes personalizar el aspecto desde un contenedor padre usando variables CSS, por ejemplo:
50
79
 
51
- ## Learn More
80
+ ```css
81
+ .mi-contenedor {
82
+ --lm-header: linear-gradient(135deg, #0d9488, #14b8a6);
83
+ --lm-line: #0d9488;
84
+ --lm-link-label: #115e59;
85
+ --lm-link-label-stroke: #ffffff;
86
+ }
87
+ ```
52
88
 
53
- You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
89
+ ## Desarrollo en este repositorio
54
90
 
55
- To learn React, check out the [React documentation](https://reactjs.org/).
91
+ | Comando | Descripción |
92
+ |----------------|-------------|
93
+ | `npm run dev` | Servidor de desarrollo (demo con Vite). |
94
+ | `npm run build` | Genera la librería en `dist/` (ESM + CJS + CSS). |
95
+ | `npm run build:demo` | Build estático de la demo en `demo-dist/`. |
96
+ | `npm run preview` | Previsualiza el último build de demo. |
56
97
 
57
- ### Code Splitting
98
+ Antes de publicar en npm, `prepublishOnly` ejecuta automáticamente `npm run build`.
58
99
 
59
- This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
100
+ ## Publicar en npm
60
101
 
61
- ### Analyzing the Bundle Size
102
+ 1. `npm login`
103
+ 2. `npm version patch` (o `minor` / `major`)
104
+ 3. `npm publish`
62
105
 
63
- This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
106
+ Comprueba que el nombre `lmdiagram` esté libre o usa un nombre con scope, por ejemplo `@tu-usuario/lmdiagram`.
64
107
 
65
- ### Making a Progressive Web App
108
+ ## Licencia
66
109
 
67
- This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
110
+ MIT
68
111
 
69
- ### Advanced Configuration
112
+ ---
70
113
 
71
- This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
72
-
73
- ### Deployment
74
-
75
- This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
76
-
77
- ### `npm run build` fails to minify
78
-
79
- This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
114
+ *Capturas o GIF antiguos del proyecto pueden aparecer en issues; la demo actual se ejecuta con `npm run dev`.*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lmdiagram",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React diagram component for linked models and associations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",