type Constructor = new (...args: any[]) => T import { Component } from '@hatiolab/things-scene' import MCSMachine from '../mcs-machine' import MCSUnit from '../mcs-unit' /** * parentObjectId 는 generic property builder 가 아니라 property-sidebar 의 모델 참조 * 룩업(ox-input-entity-id, parentObjectTypes 기준 씬 머신/유닛 선택)으로 렌더한다. * 따라서 NATURE 속성 목록에서는 제외 — 빈 배열. */ export const ParentObjectMixinProperties: any[] = [] export function ParentObjectMixin>(Base: TBase): any { return class extends Base { get parentObject(): MCSMachine | MCSUnit | undefined { const { id, parentObjectId } = this.state if (parentObjectId || id) { //@ts-ignore const targets = this.root?.findAllById(parentObjectId || id) || [] for (const target of targets) { if (target instanceof MCSMachine || target instanceof MCSUnit) { return target } } } const parent = this.parent if (parent instanceof MCSMachine || parent instanceof MCSUnit) { return parent } } /** * parentObjectId 가 참조하는 모델 컴포넌트 타입들 — parentObject 후보를 모델(씬)에서 * 수집할 때 이 타입들로 거른다 (머신/유닛 무관, 복수 허용). * 빈 배열(기본) 이면 모델의 모든 머신 (폴백). 참조 타입이 정해진 컴포넌트는 override: * AGV→['AGVLine'], OHT→['OHTLine'], Crane/Shelf→['STOCKER'], PortFlow→['Port']. */ get parentObjectTypes(): string[] { return [] } } }