import React, { useEffect, useRef } from 'react'; import type { ConditionDSL } from '../../utils/strategyTypes'; import type { DefType } from '../../utils/strategyEditorShared'; import { getConditionRightPeriod, getConditionThreshold, getConditionValuePeriod, getCompositePeriodPresetOptions, getPeriodPresetOptions, getThresholdBounds, getThresholdPresetOptions, hasEditableThreshold, setConditionRightPeriod, setConditionThreshold, setConditionValuePeriod, usesValuePeriodField, } from '../../utils/conditionPeriods'; import { compositeDisplayName, compositeElementLabel } from '../../utils/compositeIndicators'; import ComboNumberInput from './ComboNumberInput'; interface Props { condition: ConditionDSL; def: DefType; onChange: (c: ConditionDSL) => void; onClose: () => void; popoverClassName?: string; } export default function ConditionNodeSettings({ condition, def, onChange, onClose, popoverClassName = 'se-flow-settings-pop', }: Props) { const ref = useRef(null); useEffect(() => { const onDoc = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) onClose(); }; document.addEventListener('mousedown', onDoc); return () => document.removeEventListener('mousedown', onDoc); }, [onClose]); const rightThreshold = getConditionThreshold(condition, 'right'); const showThreshold = hasEditableThreshold(condition) && rightThreshold != null; const periodPresets = getPeriodPresetOptions(condition.indicatorType, def); const thresholdPresets = getThresholdPresetOptions(condition.indicatorType); const thresholdBounds = getThresholdBounds(condition.indicatorType); return (
e.stopPropagation()} >
지표 설정
{condition.composite ? ( <> ) : usesValuePeriodField(condition) ? ( ) : null} {showThreshold && rightThreshold != null && ( )} {condition.composite && (

{compositeDisplayName(condition.indicatorType)}

)}
); }