( element: T, unsizedIds?: Set<string> )
| 85 | * @private |
| 86 | */ |
| 87 | export function processElement<T extends dia.Element | GraphElement>( |
| 88 | element: T, |
| 89 | unsizedIds?: Set<string> |
| 90 | ): dia.Element | dia.Cell.JSON { |
| 91 | const stringId = String(element.id); |
| 92 | if (isCellInstance(element)) { |
| 93 | const size = element.size(); |
| 94 | if (isReactElement(element) && isUnsized(size.width, size.height)) { |
| 95 | unsizedIds?.add(stringId); |
| 96 | } |
| 97 | return element; |
| 98 | } |
| 99 | const { type = REACT_TYPE, x, y, width, height } = element; |
| 100 | if (isUnsized(width, height)) { |
| 101 | unsizedIds?.add(stringId); |
| 102 | } |
| 103 | |
| 104 | return { |
| 105 | type, |
| 106 | position: { x, y }, |
| 107 | size: { width, height }, |
| 108 | ...element, |
| 109 | } as dia.Cell.JSON; |
| 110 | } |
| 111 | /** |
| 112 | * Set elements to the graph. |
| 113 | * @param options - The options for setting elements. |
no test coverage detected