- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
71 lines
2.5 KiB
JavaScript
71 lines
2.5 KiB
JavaScript
import FocusEvent from '../../event/events/FocusEvent.js';
|
|
import * as PropertySymbol from '../../PropertySymbol.js';
|
|
/**
|
|
* HTMLElement utility.
|
|
*/
|
|
export default class HTMLElementUtility {
|
|
/**
|
|
* Triggers a blur event.
|
|
*
|
|
* @param element Element.
|
|
*/
|
|
static blur(element) {
|
|
const target = element[PropertySymbol.proxy] || element;
|
|
const document = target[PropertySymbol.ownerDocument];
|
|
if (document[PropertySymbol.activeElement] !== target ||
|
|
!target[PropertySymbol.isConnected] ||
|
|
target.disabled) {
|
|
return;
|
|
}
|
|
const relatedTarget = document[PropertySymbol.nextActiveElement] ?? null;
|
|
document[PropertySymbol.activeElement] = null;
|
|
document[PropertySymbol.clearCache]();
|
|
target.dispatchEvent(new FocusEvent('blur', {
|
|
relatedTarget,
|
|
bubbles: false,
|
|
composed: true,
|
|
cancelable: true
|
|
}));
|
|
target.dispatchEvent(new FocusEvent('focusout', {
|
|
relatedTarget,
|
|
bubbles: true,
|
|
composed: true,
|
|
cancelable: true
|
|
}));
|
|
}
|
|
/**
|
|
* Triggers a focus event.
|
|
*
|
|
* @param element Element.
|
|
*/
|
|
static focus(element) {
|
|
const target = element[PropertySymbol.proxy] || element;
|
|
const document = target[PropertySymbol.ownerDocument];
|
|
if (document[PropertySymbol.activeElement] === target ||
|
|
!target[PropertySymbol.isConnected] ||
|
|
target.disabled) {
|
|
return;
|
|
}
|
|
// Set the next active element so `blur` can use it for `relatedTarget`.
|
|
document[PropertySymbol.nextActiveElement] = target;
|
|
const relatedTarget = document[PropertySymbol.activeElement];
|
|
if (document[PropertySymbol.activeElement] !== null) {
|
|
document[PropertySymbol.activeElement].blur();
|
|
}
|
|
// Clean up after blur, so it does not affect next blur call.
|
|
document[PropertySymbol.nextActiveElement] = null;
|
|
document[PropertySymbol.activeElement] = target;
|
|
document[PropertySymbol.clearCache]();
|
|
target.dispatchEvent(new FocusEvent('focus', {
|
|
relatedTarget,
|
|
bubbles: false,
|
|
composed: true
|
|
}));
|
|
target.dispatchEvent(new FocusEvent('focusin', {
|
|
relatedTarget,
|
|
bubbles: true,
|
|
composed: true
|
|
}));
|
|
}
|
|
}
|
|
//# sourceMappingURL=HTMLElementUtility.js.map
|