import React, { useEffect, useRef } from 'react'; import type { ConditionDSL } from '../../utils/strategyTypes'; import { getDefaultConditionFields, type DefType } from '../../utils/strategyEditorShared'; import { getCompositeLeftCandleType, getCompositeRightCandleType, getConditionRightPeriod, getConditionThreshold, getChartReferenceThreshold, isThresholdOverridden, getConditionValuePeriod, getCompositePeriodPresetOptions, getPeriodPresetOptions, getPeriodSettingsLabel, getThresholdBounds, getThresholdPresetOptions, hasEditableThreshold, setCompositeLeftCandleType, setCompositeRightCandleType, setConditionRightPeriod, setConditionThreshold, setConditionValuePeriod, usesValuePeriodField, } from '../../utils/conditionPeriods'; import { compositeDisplayName, compositeElementLabel, COMPOSITE_INDICATOR_ITEMS, switchCompositeIndicatorType } from '../../utils/compositeIndicators'; import { STRATEGY_CANDLE_TYPE_OPTIONS } from '../../utils/strategyStartNodes'; import ComboNumberInput from './ComboNumberInput'; interface Props { condition: ConditionDSL; def: DefType; signalType?: 'buy' | 'sell'; onChange: (c: ConditionDSL) => void; onClose: () => void; popoverClassName?: string; } export default function ConditionNodeSettings({ condition, def, signalType = 'buy', 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 inheritedThreshold = getDefaultConditionFields(condition.indicatorType, signalType, def).r; const chartRef = getChartReferenceThreshold(condition, 'right', inheritedThreshold, def); const strategyThreshold = getConditionThreshold(condition, 'right', inheritedThreshold, def); const showThreshold = hasEditableThreshold(condition) && chartRef != 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 && chartRef != null && ( <> )} {condition.composite && (

{compositeDisplayName(condition.indicatorType)}

)}
); }