humanmap-vas 1.0.21 → 1.0.22
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.
- package/humanmap-vas-standalone.js +52 -1
- package/package.json +1 -1
@@ -118,6 +118,10 @@
|
|
118
118
|
this._zones=ZONES;
|
119
119
|
this._selected=new Set();
|
120
120
|
|
121
|
+
this._upgradeProperty('selectedIds');
|
122
|
+
this._upgradeProperty('selectedZones');
|
123
|
+
|
124
|
+
|
121
125
|
// Detectar automáticamente la ruta base del script (compatible con todos los entornos)
|
122
126
|
let scriptBase = '';
|
123
127
|
try {
|
@@ -148,8 +152,19 @@
|
|
148
152
|
};
|
149
153
|
}
|
150
154
|
|
151
|
-
|
155
|
+
// Captura valores asignados *antes* de que el custom element se registre
|
156
|
+
_upgradeProperty(prop) {
|
157
|
+
if (this.hasOwnProperty(prop)) {
|
158
|
+
const value = this[prop];
|
159
|
+
delete this[prop]; // elimina la propiedad “propia” del elemento “no mejorado”
|
160
|
+
this[prop] = value; // re-ejecuta el setter ya del elemento mejorado
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
connectedCallback(){this._renderShell();this._renderCanvas();this.dispatchEvent(new CustomEvent('human-map-vas:ready'));}
|
165
|
+
|
152
166
|
static get observedAttributes() { return ['view', 'img-root']; }
|
167
|
+
|
153
168
|
attributeChangedCallback (name, oldValue, newValue) {
|
154
169
|
if (oldValue === newValue) return;
|
155
170
|
|
@@ -174,6 +189,42 @@
|
|
174
189
|
}
|
175
190
|
}
|
176
191
|
|
192
|
+
// Devuelve solo IDs seleccionados
|
193
|
+
get selectedIds() {
|
194
|
+
return Array.from(this._selected);
|
195
|
+
}
|
196
|
+
|
197
|
+
// Asigna selección por IDs (array de strings)
|
198
|
+
set selectedIds(ids) {
|
199
|
+
if (!Array.isArray(ids)) return;
|
200
|
+
this._selected = new Set(ids);
|
201
|
+
if (this._root) { this._renderZones(); this._emit(); }
|
202
|
+
}
|
203
|
+
|
204
|
+
// Devuelve objetos completos (id, code, label, view)
|
205
|
+
get selectedZones() {
|
206
|
+
const map = new Map(this._zones.map(z => [z.id, z]));
|
207
|
+
return this.selectedIds.map(id => {
|
208
|
+
const z = map.get(id);
|
209
|
+
return z ? { id: z.id, code: z.code, label: z.label, view: z.view } : { id };
|
210
|
+
});
|
211
|
+
}
|
212
|
+
|
213
|
+
// Asigna selección pasando objetos (tomamos los IDs)
|
214
|
+
set selectedZones(zones) {
|
215
|
+
if (!Array.isArray(zones)) return;
|
216
|
+
const ids = zones.map(z => z && z.id).filter(Boolean);
|
217
|
+
this.selectedIds = ids; // reutiliza el setter de IDs para redibujar y emitir
|
218
|
+
}
|
219
|
+
|
220
|
+
get selectedCodes() {
|
221
|
+
const map = new Map(this._zones.map(z => [z.id, z]));
|
222
|
+
return this.selectedIds.map(id => {
|
223
|
+
const z = map.get(id);
|
224
|
+
return z ? z.code : { id };
|
225
|
+
});
|
226
|
+
}
|
227
|
+
|
177
228
|
getSelected(){
|
178
229
|
const map=new Map(this._zones.map(z=>[z.id,z]));
|
179
230
|
return Array.from(this._selected).map(id=>{
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "humanmap-vas",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.22",
|
4
4
|
"description": "**HumanMap VAS** es una librería web que permite graficar el cuerpo humano con vistas anatómicas interactivas para identificar zonas según el sistema VAS. Desarrollada como *Web Component standalone*, puede integrarse fácilmente en proyectos **HTML**, **Django**, o **Vue.js**.",
|
5
5
|
"main": "humanmap-vas-standalone.js",
|
6
6
|
"files": [
|