Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix Idiomorph ESM import, update typings

Alexander Brandon Coles95c36ac162c3
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts
index f0e3d289e04..30023fa505a 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts
@@ -29,7 +29,7 @@
*/
import { Controller } from '@hotwired/stimulus';
-import Idiomorph from 'idiomorph/dist/idiomorph.cjs';
+import { Idiomorph } from 'idiomorph';
interface TurboBeforeFrameRenderEventDetail {
render:(currentElement:HTMLElement, newElement:HTMLElement) => void;
diff --git a/frontend/src/turbo/dialog-stream-action.ts b/frontend/src/turbo/dialog-stream-action.ts
index 73ed411e1e4..d7268b92725 100644
--- a/frontend/src/turbo/dialog-stream-action.ts
+++ b/frontend/src/turbo/dialog-stream-action.ts
@@ -1,5 +1,5 @@
import { StreamActions, StreamElement } from '@hotwired/turbo';
-import Idiomorph from 'idiomorph/dist/idiomorph.cjs';
+import { Idiomorph } from 'idiomorph';
export function registerDialogStreamAction() {
StreamActions.closeDialog = function closeDialogStreamAction(this:StreamElement) {
diff --git a/frontend/src/typings/idiomorph.d.ts b/frontend/src/typings/idiomorph.d.ts
index f47298369a0..41f00c0565f 100644
--- a/frontend/src/typings/idiomorph.d.ts
+++ b/frontend/src/typings/idiomorph.d.ts
@@ -28,25 +28,43 @@
* ++
*/
-declare module 'idiomorph/dist/idiomorph.cjs' {
+declare module 'idiomorph' {
+ interface ConfigHeadInternal {
+ style:'merge'|'append'|'morph'|'none';
+ block:boolean;
+ ignore:boolean;
+ shouldPreserve:(element:Element) => boolean;
+ shouldReAppend:(element:Element) => boolean;
+ shouldRemove:(element:Element) => boolean;
+ afterHeadMorphed:(oldHead:Element, options?:{ added?:Node[]; kept?:Element[]; removed?:Element[] }) => void;
+ }
+ interface ConfigCallbacksInternal {
+ beforeNodeAdded:(node:Node) => boolean;
+ afterNodeAdded:(node:Node) => void;
+ beforeNodeMorphed:(oldNode:Element, newNode:Node) => boolean;
+ afterNodeMorphed:(oldNode:Element, newNode:Node) => void;
+ beforeNodeRemoved:(node:Element) => boolean;
+ afterNodeRemoved:(node:Element) => void;
+ beforeAttributeUpdated:(attr:string, element:Element, updateType:'update'|'remove') => boolean;
+ }
+ interface ConfigBase<Head, Callbacks> {
+ morphStyle:'innerHTML'|'outerHTML';
+ ignoreActive:boolean;
+ ignoreActiveValue:boolean;
+ restoreFocus:boolean;
+ head:Head;
+ callbacks:Callbacks;
+ }
+
+ type ConfigInternal = ConfigBase<ConfigHeadInternal, ConfigCallbacksInternal>;
+ type ConfigHead = Partial<ConfigHeadInternal>;
+ type ConfigCallbacks = Partial<ConfigCallbacksInternal>;
+ type Config = Partial<ConfigInternal<ConfigHead, ConfigCallbacks>>;
+
export const Idiomorph:{
- morph(oldNode:Element|Document, newContent?:string|Element|Iterable<Element>|null, options?:{
- morphStyle?:'innerHTML'|'outerHTML';
- ignoreActive?:boolean;
- ignoreActiveValue?:boolean;
- head?:{
- style?:'merge'|'append'|'morph'|'none';
- };
- callbacks?:{
- beforeNodeAdded?:(node:ChildNode) => void|boolean;
- afterNodeAdded?:(node:ChildNode) => void;
- beforeNodeMorphed?:(oldNode:Element, newNode:Element) => void|boolean;
- afterNodeMorphed?:(oldNode:Element, newNode:Element) => void;
- beforeNodeRemoved?:(node:ChildNode) => void|boolean;
- afterNodeRemoved?:(node:ChildNode) => void;
- };
- })
+ morph(ldNode:Element|Document, newContent?:Element|Node|HTMLCollection|Node[]|string|null, options?:Config);
+ defaults:ConfigInternal;
};
- export = Idiomorph;
+ export { Idiomorph };
}