react-klinecharts-ui 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -15
- package/dist/index.cjs +91 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +91 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -534,6 +534,22 @@ interface DrawingCategoryItem {
|
|
|
534
534
|
key: string;
|
|
535
535
|
tools: DrawingToolItem[];
|
|
536
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Реактивный snapshot одного рисунка из группы `drawing_tools`.
|
|
539
|
+
* Поля соответствуют публичным свойствам `Overlay` в klinecharts v10.
|
|
540
|
+
*/
|
|
541
|
+
interface DrawingOverlayInfo {
|
|
542
|
+
/** Stable id из klinecharts (chart.getOverlays()[].id). */
|
|
543
|
+
id: string;
|
|
544
|
+
/** Имя overlay'я, напр. "segment", "fibonacciLine", "arrow". */
|
|
545
|
+
name: string;
|
|
546
|
+
/** Pane id, где нарисован. */
|
|
547
|
+
paneId: string;
|
|
548
|
+
/** Текущее состояние блокировки. */
|
|
549
|
+
locked: boolean;
|
|
550
|
+
/** Текущая видимость. */
|
|
551
|
+
visible: boolean;
|
|
552
|
+
}
|
|
537
553
|
interface UseDrawingToolsReturn {
|
|
538
554
|
categories: DrawingCategoryItem[];
|
|
539
555
|
activeTool: string | null;
|
|
@@ -542,6 +558,12 @@ interface UseDrawingToolsReturn {
|
|
|
542
558
|
isVisible: boolean;
|
|
543
559
|
/** Whether drawing tools auto-retrigger after completing a shape. Default: true. */
|
|
544
560
|
autoRetrigger: boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Реактивный список рисунков группы `drawing_tools`. Обновляется при
|
|
563
|
+
* добавлении/удалении/изменении свойств как через сам хук, так и при
|
|
564
|
+
* внешних изменениях (клавиша Delete, undo/redo) — см. polling-fallback.
|
|
565
|
+
*/
|
|
566
|
+
overlays: DrawingOverlayInfo[];
|
|
545
567
|
selectTool: (name: string) => void;
|
|
546
568
|
clearActiveTool: () => void;
|
|
547
569
|
setMagnetMode: (mode: MagnetMode) => void;
|
|
@@ -550,7 +572,20 @@ interface UseDrawingToolsReturn {
|
|
|
550
572
|
removeAllDrawings: () => void;
|
|
551
573
|
/** Enable/disable auto-retrigger mode. */
|
|
552
574
|
setAutoRetrigger: (enabled: boolean) => void;
|
|
575
|
+
/** Удалить один рисунок по id. No-op если id нет в группе drawing_tools. */
|
|
576
|
+
removeDrawing: (id: string) => void;
|
|
577
|
+
/** Скрыть/показать один рисунок. */
|
|
578
|
+
setDrawingVisible: (id: string, visible: boolean) => void;
|
|
579
|
+
/** Заблокировать/разблокировать один рисунок. */
|
|
580
|
+
setDrawingLocked: (id: string, locked: boolean) => void;
|
|
553
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Вернуть localeKey для имени инструмента (напр. "segment" → "segment",
|
|
584
|
+
* "fibonacciLine" → "fibonacci_line"). Если имя не найдено в
|
|
585
|
+
* `DRAWING_CATEGORIES` — вернуть само имя как fallback, чтобы потребитель
|
|
586
|
+
* всегда получал человекочитаемую строку без дублирования таблицы категорий.
|
|
587
|
+
*/
|
|
588
|
+
declare function drawingLabel(name: string): string;
|
|
554
589
|
declare function useDrawingTools(): UseDrawingToolsReturn;
|
|
555
590
|
|
|
556
591
|
interface CandleTypeOption {
|
|
@@ -1323,4 +1358,4 @@ declare const superTrend: IndicatorTemplate;
|
|
|
1323
1358
|
|
|
1324
1359
|
declare const vwap: IndicatorTemplate;
|
|
1325
1360
|
|
|
1326
|
-
export { type AddIndicatorOptions, type Alert, type AlertCondition, AlertLineExtendData, type AlertTarget, type Annotation, CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartCell, type ChartLayoutState, type CompareRule, type CompareSymbol, type CrosshairBarData, DEFAULT_PERIODS, DEFAULT_STORAGE_KEY_PREFIX, DEFAULT_STORAGE_NAMESPACES, DEFAULT_SYNC_CONFIG, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, type ExportFormat, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, type MeasurePoint, type MeasureResult, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, type ReplaySpeed, type ResolvedStorage, SUB_INDICATORS, type ScriptPlacement, type StorageAdapter, type StorageNamespace, type StorageOptions, type SyncChannel, type SyncConfig, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseAlertsReturn, type UseAnnotationsReturn, type UseChartAxesReturn, type UseChartSyncOptions, type UseCompareReturn, type UseCrosshairReturn, type UseDataExportReturn, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseHotkeysReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseMeasureReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseReplayReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, type UseWatchlistReturn, type WatchlistItem, type WorkspaceAction, type WorkspaceContextValue, WorkspaceProvider, type WorkspaceProviderProps, type WorkspaceState, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, createDefaultStorage, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, resolveStorage, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useAlerts, useAnnotations, useChartAxes, useChartSync, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useHotkeys, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, useWorkspace, vwap, xabcd };
|
|
1361
|
+
export { type AddIndicatorOptions, type Alert, type AlertCondition, AlertLineExtendData, type AlertTarget, type Annotation, CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartCell, type ChartLayoutState, type CompareRule, type CompareSymbol, type CrosshairBarData, DEFAULT_PERIODS, DEFAULT_STORAGE_KEY_PREFIX, DEFAULT_STORAGE_NAMESPACES, DEFAULT_SYNC_CONFIG, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingOverlayInfo, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, type ExportFormat, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, type MeasurePoint, type MeasureResult, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, type ReplaySpeed, type ResolvedStorage, SUB_INDICATORS, type ScriptPlacement, type StorageAdapter, type StorageNamespace, type StorageOptions, type SyncChannel, type SyncConfig, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseAlertsReturn, type UseAnnotationsReturn, type UseChartAxesReturn, type UseChartSyncOptions, type UseCompareReturn, type UseCrosshairReturn, type UseDataExportReturn, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseHotkeysReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseMeasureReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseReplayReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, type UseWatchlistReturn, type WatchlistItem, type WorkspaceAction, type WorkspaceContextValue, WorkspaceProvider, type WorkspaceProviderProps, type WorkspaceState, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, createDefaultStorage, drawingLabel, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, resolveStorage, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useAlerts, useAnnotations, useChartAxes, useChartSync, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useHotkeys, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, useWorkspace, vwap, xabcd };
|
package/dist/index.d.ts
CHANGED
|
@@ -534,6 +534,22 @@ interface DrawingCategoryItem {
|
|
|
534
534
|
key: string;
|
|
535
535
|
tools: DrawingToolItem[];
|
|
536
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Реактивный snapshot одного рисунка из группы `drawing_tools`.
|
|
539
|
+
* Поля соответствуют публичным свойствам `Overlay` в klinecharts v10.
|
|
540
|
+
*/
|
|
541
|
+
interface DrawingOverlayInfo {
|
|
542
|
+
/** Stable id из klinecharts (chart.getOverlays()[].id). */
|
|
543
|
+
id: string;
|
|
544
|
+
/** Имя overlay'я, напр. "segment", "fibonacciLine", "arrow". */
|
|
545
|
+
name: string;
|
|
546
|
+
/** Pane id, где нарисован. */
|
|
547
|
+
paneId: string;
|
|
548
|
+
/** Текущее состояние блокировки. */
|
|
549
|
+
locked: boolean;
|
|
550
|
+
/** Текущая видимость. */
|
|
551
|
+
visible: boolean;
|
|
552
|
+
}
|
|
537
553
|
interface UseDrawingToolsReturn {
|
|
538
554
|
categories: DrawingCategoryItem[];
|
|
539
555
|
activeTool: string | null;
|
|
@@ -542,6 +558,12 @@ interface UseDrawingToolsReturn {
|
|
|
542
558
|
isVisible: boolean;
|
|
543
559
|
/** Whether drawing tools auto-retrigger after completing a shape. Default: true. */
|
|
544
560
|
autoRetrigger: boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Реактивный список рисунков группы `drawing_tools`. Обновляется при
|
|
563
|
+
* добавлении/удалении/изменении свойств как через сам хук, так и при
|
|
564
|
+
* внешних изменениях (клавиша Delete, undo/redo) — см. polling-fallback.
|
|
565
|
+
*/
|
|
566
|
+
overlays: DrawingOverlayInfo[];
|
|
545
567
|
selectTool: (name: string) => void;
|
|
546
568
|
clearActiveTool: () => void;
|
|
547
569
|
setMagnetMode: (mode: MagnetMode) => void;
|
|
@@ -550,7 +572,20 @@ interface UseDrawingToolsReturn {
|
|
|
550
572
|
removeAllDrawings: () => void;
|
|
551
573
|
/** Enable/disable auto-retrigger mode. */
|
|
552
574
|
setAutoRetrigger: (enabled: boolean) => void;
|
|
575
|
+
/** Удалить один рисунок по id. No-op если id нет в группе drawing_tools. */
|
|
576
|
+
removeDrawing: (id: string) => void;
|
|
577
|
+
/** Скрыть/показать один рисунок. */
|
|
578
|
+
setDrawingVisible: (id: string, visible: boolean) => void;
|
|
579
|
+
/** Заблокировать/разблокировать один рисунок. */
|
|
580
|
+
setDrawingLocked: (id: string, locked: boolean) => void;
|
|
553
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Вернуть localeKey для имени инструмента (напр. "segment" → "segment",
|
|
584
|
+
* "fibonacciLine" → "fibonacci_line"). Если имя не найдено в
|
|
585
|
+
* `DRAWING_CATEGORIES` — вернуть само имя как fallback, чтобы потребитель
|
|
586
|
+
* всегда получал человекочитаемую строку без дублирования таблицы категорий.
|
|
587
|
+
*/
|
|
588
|
+
declare function drawingLabel(name: string): string;
|
|
554
589
|
declare function useDrawingTools(): UseDrawingToolsReturn;
|
|
555
590
|
|
|
556
591
|
interface CandleTypeOption {
|
|
@@ -1323,4 +1358,4 @@ declare const superTrend: IndicatorTemplate;
|
|
|
1323
1358
|
|
|
1324
1359
|
declare const vwap: IndicatorTemplate;
|
|
1325
1360
|
|
|
1326
|
-
export { type AddIndicatorOptions, type Alert, type AlertCondition, AlertLineExtendData, type AlertTarget, type Annotation, CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartCell, type ChartLayoutState, type CompareRule, type CompareSymbol, type CrosshairBarData, DEFAULT_PERIODS, DEFAULT_STORAGE_KEY_PREFIX, DEFAULT_STORAGE_NAMESPACES, DEFAULT_SYNC_CONFIG, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, type ExportFormat, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, type MeasurePoint, type MeasureResult, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, type ReplaySpeed, type ResolvedStorage, SUB_INDICATORS, type ScriptPlacement, type StorageAdapter, type StorageNamespace, type StorageOptions, type SyncChannel, type SyncConfig, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseAlertsReturn, type UseAnnotationsReturn, type UseChartAxesReturn, type UseChartSyncOptions, type UseCompareReturn, type UseCrosshairReturn, type UseDataExportReturn, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseHotkeysReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseMeasureReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseReplayReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, type UseWatchlistReturn, type WatchlistItem, type WorkspaceAction, type WorkspaceContextValue, WorkspaceProvider, type WorkspaceProviderProps, type WorkspaceState, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, createDefaultStorage, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, resolveStorage, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useAlerts, useAnnotations, useChartAxes, useChartSync, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useHotkeys, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, useWorkspace, vwap, xabcd };
|
|
1361
|
+
export { type AddIndicatorOptions, type Alert, type AlertCondition, AlertLineExtendData, type AlertTarget, type Annotation, CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartCell, type ChartLayoutState, type CompareRule, type CompareSymbol, type CrosshairBarData, DEFAULT_PERIODS, DEFAULT_STORAGE_KEY_PREFIX, DEFAULT_STORAGE_NAMESPACES, DEFAULT_SYNC_CONFIG, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingOverlayInfo, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, type ExportFormat, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, type MeasurePoint, type MeasureResult, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, type ReplaySpeed, type ResolvedStorage, SUB_INDICATORS, type ScriptPlacement, type StorageAdapter, type StorageNamespace, type StorageOptions, type SyncChannel, type SyncConfig, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseAlertsReturn, type UseAnnotationsReturn, type UseChartAxesReturn, type UseChartSyncOptions, type UseCompareReturn, type UseCrosshairReturn, type UseDataExportReturn, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseHotkeysReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseMeasureReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseReplayReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, type UseWatchlistReturn, type WatchlistItem, type WorkspaceAction, type WorkspaceContextValue, WorkspaceProvider, type WorkspaceProviderProps, type WorkspaceState, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, createDefaultStorage, drawingLabel, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, resolveStorage, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useAlerts, useAnnotations, useChartAxes, useChartSync, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useHotkeys, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, useWorkspace, vwap, xabcd };
|
package/dist/index.js
CHANGED
|
@@ -1358,6 +1358,25 @@ var DRAWING_CATEGORIES = [
|
|
|
1358
1358
|
|
|
1359
1359
|
// src/hooks/useDrawingTools.ts
|
|
1360
1360
|
var DRAWING_GROUP_ID = "drawing_tools";
|
|
1361
|
+
var DRAWING_NAME_TO_LOCALE_KEY = new Map(
|
|
1362
|
+
DRAWING_CATEGORIES.flatMap(
|
|
1363
|
+
(cat) => cat.tools.map((tool) => [tool.name, tool.localeKey])
|
|
1364
|
+
)
|
|
1365
|
+
);
|
|
1366
|
+
function drawingLabel(name) {
|
|
1367
|
+
return DRAWING_NAME_TO_LOCALE_KEY.get(name) ?? name;
|
|
1368
|
+
}
|
|
1369
|
+
function overlaysEqual(a, b) {
|
|
1370
|
+
if (a.length !== b.length) return false;
|
|
1371
|
+
for (let i = 0; i < a.length; i++) {
|
|
1372
|
+
const x = a[i];
|
|
1373
|
+
const y = b[i];
|
|
1374
|
+
if (x.id !== y.id || x.name !== y.name || x.paneId !== y.paneId || x.locked !== y.locked || x.visible !== y.visible) {
|
|
1375
|
+
return false;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return true;
|
|
1379
|
+
}
|
|
1361
1380
|
function useDrawingTools() {
|
|
1362
1381
|
const { state } = useKlinechartsUI();
|
|
1363
1382
|
const { undoRedoListenerRef } = useKlinechartsUIDispatch();
|
|
@@ -1378,6 +1397,34 @@ function useDrawingTools() {
|
|
|
1378
1397
|
isVisibleRef.current = isVisible;
|
|
1379
1398
|
magnetModeRef.current = magnetMode;
|
|
1380
1399
|
});
|
|
1400
|
+
const [overlays2, setOverlays] = useState([]);
|
|
1401
|
+
const refreshOverlays = useCallback(() => {
|
|
1402
|
+
if (!state.chart) {
|
|
1403
|
+
setOverlays((prev) => prev.length === 0 ? prev : []);
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
const list = state.chart.getOverlays({ groupId: DRAWING_GROUP_ID });
|
|
1407
|
+
const next = list.map((o) => ({
|
|
1408
|
+
id: o.id,
|
|
1409
|
+
name: o.name,
|
|
1410
|
+
paneId: o.paneId,
|
|
1411
|
+
locked: !!o.lock,
|
|
1412
|
+
visible: o.visible !== false
|
|
1413
|
+
// klinecharts default = true
|
|
1414
|
+
}));
|
|
1415
|
+
setOverlays((prev) => overlaysEqual(prev, next) ? prev : next);
|
|
1416
|
+
}, [state.chart]);
|
|
1417
|
+
const refreshOverlaysRef = useRef(() => {
|
|
1418
|
+
});
|
|
1419
|
+
useEffect(() => {
|
|
1420
|
+
refreshOverlaysRef.current = refreshOverlays;
|
|
1421
|
+
});
|
|
1422
|
+
useEffect(() => {
|
|
1423
|
+
if (!state.chart) return;
|
|
1424
|
+
queueMicrotask(() => refreshOverlaysRef.current());
|
|
1425
|
+
const interval = setInterval(() => refreshOverlaysRef.current(), 1e3);
|
|
1426
|
+
return () => clearInterval(interval);
|
|
1427
|
+
}, [state.chart, refreshOverlays]);
|
|
1381
1428
|
const categories = useMemo(
|
|
1382
1429
|
() => DRAWING_CATEGORIES.map((cat) => ({
|
|
1383
1430
|
key: cat.key,
|
|
@@ -1413,6 +1460,7 @@ function useDrawingTools() {
|
|
|
1413
1460
|
}
|
|
1414
1461
|
}
|
|
1415
1462
|
});
|
|
1463
|
+
refreshOverlaysRef.current();
|
|
1416
1464
|
if (autoRetriggerRef.current && activeToolRef.current === name) {
|
|
1417
1465
|
requestAnimationFrame(() => {
|
|
1418
1466
|
createOverlayForToolRef.current(name);
|
|
@@ -1439,49 +1487,52 @@ function useDrawingTools() {
|
|
|
1439
1487
|
const setMagnetMode = useCallback(
|
|
1440
1488
|
(mode) => {
|
|
1441
1489
|
setMagnetModeState(mode);
|
|
1442
|
-
const
|
|
1443
|
-
if (
|
|
1490
|
+
const overlays3 = state.chart?.getOverlays({ groupId: DRAWING_GROUP_ID });
|
|
1491
|
+
if (overlays3) {
|
|
1444
1492
|
const overlayMode = mode === "strong" ? "strong_magnet" : mode === "weak" ? "weak_magnet" : "normal";
|
|
1445
|
-
|
|
1493
|
+
overlays3.forEach((overlay) => {
|
|
1446
1494
|
state.chart?.overrideOverlay({
|
|
1447
1495
|
id: overlay.id,
|
|
1448
1496
|
mode: overlayMode
|
|
1449
1497
|
});
|
|
1450
1498
|
});
|
|
1451
1499
|
}
|
|
1500
|
+
refreshOverlaysRef.current();
|
|
1452
1501
|
},
|
|
1453
1502
|
[state.chart]
|
|
1454
1503
|
);
|
|
1455
1504
|
const toggleLock = useCallback(() => {
|
|
1456
1505
|
const newLocked = !isLocked;
|
|
1457
1506
|
setIsLocked(newLocked);
|
|
1458
|
-
const
|
|
1459
|
-
if (
|
|
1460
|
-
|
|
1507
|
+
const overlays3 = state.chart?.getOverlays({ groupId: DRAWING_GROUP_ID });
|
|
1508
|
+
if (overlays3) {
|
|
1509
|
+
overlays3.forEach((overlay) => {
|
|
1461
1510
|
state.chart?.overrideOverlay({
|
|
1462
1511
|
id: overlay.id,
|
|
1463
1512
|
lock: newLocked
|
|
1464
1513
|
});
|
|
1465
1514
|
});
|
|
1466
1515
|
}
|
|
1516
|
+
refreshOverlaysRef.current();
|
|
1467
1517
|
}, [state.chart, isLocked]);
|
|
1468
1518
|
const toggleVisibility = useCallback(() => {
|
|
1469
1519
|
const newVisible = !isVisible;
|
|
1470
1520
|
setIsVisible(newVisible);
|
|
1471
|
-
const
|
|
1472
|
-
if (
|
|
1473
|
-
|
|
1521
|
+
const overlays3 = state.chart?.getOverlays({ groupId: DRAWING_GROUP_ID });
|
|
1522
|
+
if (overlays3) {
|
|
1523
|
+
overlays3.forEach((overlay) => {
|
|
1474
1524
|
state.chart?.overrideOverlay({
|
|
1475
1525
|
id: overlay.id,
|
|
1476
1526
|
visible: newVisible
|
|
1477
1527
|
});
|
|
1478
1528
|
});
|
|
1479
1529
|
}
|
|
1530
|
+
refreshOverlaysRef.current();
|
|
1480
1531
|
}, [state.chart, isVisible]);
|
|
1481
1532
|
const removeAllDrawings = useCallback(() => {
|
|
1482
|
-
const
|
|
1483
|
-
if (
|
|
1484
|
-
const snapshot =
|
|
1533
|
+
const overlays3 = state.chart?.getOverlays({ groupId: DRAWING_GROUP_ID });
|
|
1534
|
+
if (overlays3 && overlays3.length > 0) {
|
|
1535
|
+
const snapshot = overlays3.map((o) => ({
|
|
1485
1536
|
name: o.name,
|
|
1486
1537
|
id: o.id,
|
|
1487
1538
|
points: o.points,
|
|
@@ -1495,7 +1546,29 @@ function useDrawingTools() {
|
|
|
1495
1546
|
}
|
|
1496
1547
|
state.chart?.removeOverlay({ groupId: DRAWING_GROUP_ID });
|
|
1497
1548
|
setActiveTool(null);
|
|
1549
|
+
refreshOverlaysRef.current();
|
|
1498
1550
|
}, [state.chart, undoRedoListenerRef]);
|
|
1551
|
+
const removeDrawing = useCallback(
|
|
1552
|
+
(id) => {
|
|
1553
|
+
state.chart?.removeOverlay({ id, groupId: DRAWING_GROUP_ID });
|
|
1554
|
+
refreshOverlaysRef.current();
|
|
1555
|
+
},
|
|
1556
|
+
[state.chart]
|
|
1557
|
+
);
|
|
1558
|
+
const setDrawingVisible = useCallback(
|
|
1559
|
+
(id, visible) => {
|
|
1560
|
+
state.chart?.overrideOverlay({ id, visible });
|
|
1561
|
+
refreshOverlaysRef.current();
|
|
1562
|
+
},
|
|
1563
|
+
[state.chart]
|
|
1564
|
+
);
|
|
1565
|
+
const setDrawingLocked = useCallback(
|
|
1566
|
+
(id, locked) => {
|
|
1567
|
+
state.chart?.overrideOverlay({ id, lock: locked });
|
|
1568
|
+
refreshOverlaysRef.current();
|
|
1569
|
+
},
|
|
1570
|
+
[state.chart]
|
|
1571
|
+
);
|
|
1499
1572
|
return {
|
|
1500
1573
|
categories,
|
|
1501
1574
|
activeTool,
|
|
@@ -1503,13 +1576,17 @@ function useDrawingTools() {
|
|
|
1503
1576
|
isLocked,
|
|
1504
1577
|
isVisible,
|
|
1505
1578
|
autoRetrigger,
|
|
1579
|
+
overlays: overlays2,
|
|
1506
1580
|
selectTool,
|
|
1507
1581
|
clearActiveTool,
|
|
1508
1582
|
setMagnetMode,
|
|
1509
1583
|
toggleLock,
|
|
1510
1584
|
toggleVisibility,
|
|
1511
1585
|
removeAllDrawings,
|
|
1512
|
-
setAutoRetrigger
|
|
1586
|
+
setAutoRetrigger,
|
|
1587
|
+
removeDrawing,
|
|
1588
|
+
setDrawingVisible,
|
|
1589
|
+
setDrawingLocked
|
|
1513
1590
|
};
|
|
1514
1591
|
}
|
|
1515
1592
|
|
|
@@ -3735,6 +3812,6 @@ function useChartSync({ cellId }) {
|
|
|
3735
3812
|
}, [state.period]);
|
|
3736
3813
|
}
|
|
3737
3814
|
|
|
3738
|
-
export { CANDLE_TYPES, COMPARE_RULES, DEFAULT_PERIODS, DEFAULT_STORAGE_KEY_PREFIX, DEFAULT_STORAGE_NAMESPACES, DEFAULT_SYNC_CONFIG, DRAWING_CATEGORIES, INDICATOR_PARAMS, KlinechartsUIProvider, MAIN_INDICATORS, PRICE_AXIS_TYPES, SUB_INDICATORS, TIMEZONES, TOOLTIP_SHOW_RULES, WorkspaceProvider, YAXIS_POSITIONS, createDefaultStorage, resolveStorage, useAlerts, useAnnotations, useChartAxes, useChartSync, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useHotkeys, useIndicators, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, useWorkspace };
|
|
3815
|
+
export { CANDLE_TYPES, COMPARE_RULES, DEFAULT_PERIODS, DEFAULT_STORAGE_KEY_PREFIX, DEFAULT_STORAGE_NAMESPACES, DEFAULT_SYNC_CONFIG, DRAWING_CATEGORIES, INDICATOR_PARAMS, KlinechartsUIProvider, MAIN_INDICATORS, PRICE_AXIS_TYPES, SUB_INDICATORS, TIMEZONES, TOOLTIP_SHOW_RULES, WorkspaceProvider, YAXIS_POSITIONS, createDefaultStorage, drawingLabel, resolveStorage, useAlerts, useAnnotations, useChartAxes, useChartSync, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useHotkeys, useIndicators, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, useWorkspace };
|
|
3739
3816
|
//# sourceMappingURL=index.js.map
|
|
3740
3817
|
//# sourceMappingURL=index.js.map
|