@coderyo/ui-shell 1.0.1 → 1.0.3
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/dist/index.d.ts +70 -5
- package/dist/index.js +412 -68
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
import * as _coderyo_data from '@coderyo/data';
|
|
2
2
|
import { Interval, SymbolSearchHit } from '@coderyo/data';
|
|
3
|
+
import { Locale, I18nDictionary } from '@coderyo/i18n';
|
|
3
4
|
import { IndicatorConfig } from '@coderyo/indicators';
|
|
4
5
|
import * as _coderyo_drawings from '@coderyo/drawings';
|
|
5
6
|
import { DrawingRecord } from '@coderyo/drawings';
|
|
6
7
|
import { StreamLanguage } from '@codemirror/language';
|
|
7
8
|
|
|
9
|
+
interface I18nProvider {
|
|
10
|
+
t(key: string, fallback?: string, params?: Record<string, string | number>): string;
|
|
11
|
+
getLocale(): Locale;
|
|
12
|
+
setLocale(locale: Locale): void;
|
|
13
|
+
registerLocale(locale: Locale, dictionary: I18nDictionary): void;
|
|
14
|
+
subscribe(listener: (locale: Locale) => void): () => void;
|
|
15
|
+
}
|
|
16
|
+
declare function createI18nProvider(defaultLocale?: Locale): I18nProvider;
|
|
17
|
+
|
|
18
|
+
interface LogoSlotOptions {
|
|
19
|
+
label?: string;
|
|
20
|
+
href?: string;
|
|
21
|
+
imageSrc?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function mountLogoSlot(parent: HTMLElement, opts?: LogoSlotOptions): HTMLElement;
|
|
24
|
+
|
|
8
25
|
declare const GRID_SETTING_KEY = "tradview:settings:showGrid";
|
|
9
26
|
declare const RETURN_CURSOR_KEY = "tradview:settings:returnToCursorAfterDraw";
|
|
10
27
|
declare function loadShowGridPreference(): boolean;
|
|
11
28
|
declare function saveShowGridPreference(show: boolean): void;
|
|
12
29
|
declare function loadReturnToCursorPreference(): boolean;
|
|
13
30
|
declare function saveReturnToCursorPreference(v: boolean): void;
|
|
31
|
+
/** @deprecated Prefer `@coderyo/core` `loadIndicatorConfig(storage, …)` when not using ui-shell. */
|
|
14
32
|
declare function loadIndicatorConfig(symbol: string, interval: string): IndicatorConfig;
|
|
33
|
+
/** @deprecated Prefer `@coderyo/core` `saveIndicatorConfig(storage, …)` when not using ui-shell. */
|
|
15
34
|
declare function saveIndicatorConfig(symbol: string, interval: string, config: IndicatorConfig): void;
|
|
16
35
|
|
|
17
36
|
interface SettingsPanelOptions {
|
|
@@ -21,10 +40,25 @@ interface SettingsPanelOptions {
|
|
|
21
40
|
onReturnToCursorChange?: (v: boolean) => void;
|
|
22
41
|
indicatorConfig?: IndicatorConfig;
|
|
23
42
|
onIndicatorConfigChange?: (config: IndicatorConfig) => void;
|
|
43
|
+
onClearAllIndicators?: () => void;
|
|
44
|
+
onClearAllDrawings?: () => void;
|
|
24
45
|
}
|
|
25
46
|
declare function mountSettingsPanel(parent: HTMLElement, opts?: SettingsPanelOptions): HTMLElement;
|
|
26
47
|
|
|
27
|
-
type
|
|
48
|
+
type ThemeId = 'dark' | 'light';
|
|
49
|
+
declare const THEME_STORAGE_KEY = "tradview:theme";
|
|
50
|
+
declare function loadTheme(): ThemeId;
|
|
51
|
+
declare function saveTheme(theme: ThemeId): void;
|
|
52
|
+
declare function applyThemeToDocument(theme: ThemeId, root?: HTMLElement): void;
|
|
53
|
+
interface ThemeProvider {
|
|
54
|
+
getTheme(): ThemeId;
|
|
55
|
+
setTheme(theme: ThemeId): void;
|
|
56
|
+
toggle(): ThemeId;
|
|
57
|
+
subscribe(listener: (theme: ThemeId) => void): () => void;
|
|
58
|
+
}
|
|
59
|
+
declare function createThemeProvider(initial?: ThemeId): ThemeProvider;
|
|
60
|
+
|
|
61
|
+
type SymbolInputMode = 'manual' | 'search' | 'dialog' | 'none';
|
|
28
62
|
interface TopBarOptions {
|
|
29
63
|
intervals?: Interval[];
|
|
30
64
|
/** Highlighted interval button (defaults to first in `intervals`). */
|
|
@@ -34,6 +68,10 @@ interface TopBarOptions {
|
|
|
34
68
|
onSymbolSelect?: (symbol: string) => void;
|
|
35
69
|
onIntervalChange?: (interval: Interval) => void;
|
|
36
70
|
onThemeToggle?: () => void;
|
|
71
|
+
onThemeChange?: (theme: 'dark' | 'light') => void;
|
|
72
|
+
themeProvider?: ThemeProvider;
|
|
73
|
+
i18n?: I18nProvider;
|
|
74
|
+
logo?: LogoSlotOptions | false;
|
|
37
75
|
onFullscreen?: () => void;
|
|
38
76
|
onScreenshot?: () => void;
|
|
39
77
|
settings?: SettingsPanelOptions;
|
|
@@ -45,6 +83,31 @@ declare function mountTopBar(parent: HTMLElement, opts?: TopBarOptions): {
|
|
|
45
83
|
setActiveInterval: (interval: Interval) => void;
|
|
46
84
|
};
|
|
47
85
|
|
|
86
|
+
interface ThemeToggleOptions {
|
|
87
|
+
themeProvider: ThemeProvider;
|
|
88
|
+
i18n?: I18nProvider;
|
|
89
|
+
onThemeChange?: (theme: ThemeId) => void;
|
|
90
|
+
}
|
|
91
|
+
declare function mountThemeToggle(parent: HTMLElement, opts: ThemeToggleOptions): HTMLButtonElement;
|
|
92
|
+
|
|
93
|
+
interface SymbolSearchDialogOptions {
|
|
94
|
+
onSearch: (query: string) => Promise<SymbolSearchHit[]>;
|
|
95
|
+
onSelect: (symbol: string) => void;
|
|
96
|
+
initialSymbol?: string;
|
|
97
|
+
i18n?: I18nProvider;
|
|
98
|
+
}
|
|
99
|
+
interface SymbolSearchDialogHandle {
|
|
100
|
+
open(): void;
|
|
101
|
+
close(): void;
|
|
102
|
+
destroy(): void;
|
|
103
|
+
}
|
|
104
|
+
declare function createSymbolSearchDialog(opts: SymbolSearchDialogOptions): SymbolSearchDialogHandle;
|
|
105
|
+
/** TopBar trigger: shows current symbol and opens the dialog. */
|
|
106
|
+
declare function mountSymbolSearchDialogTrigger(parent: HTMLElement, dialog: SymbolSearchDialogHandle, opts: {
|
|
107
|
+
initialSymbol?: string;
|
|
108
|
+
i18n?: I18nProvider;
|
|
109
|
+
}): HTMLElement;
|
|
110
|
+
|
|
48
111
|
interface ContextMenuAction {
|
|
49
112
|
id: string;
|
|
50
113
|
label: string;
|
|
@@ -112,7 +175,7 @@ interface LayoutFeatures {
|
|
|
112
175
|
showSettings?: boolean;
|
|
113
176
|
showShortcuts?: boolean;
|
|
114
177
|
/** When TopBar is on and no search API: manual symbol input (default). */
|
|
115
|
-
symbolInput?: 'manual' | 'search' | 'none';
|
|
178
|
+
symbolInput?: 'manual' | 'search' | 'dialog' | 'none';
|
|
116
179
|
}
|
|
117
180
|
interface ResolvedLayoutFeatures {
|
|
118
181
|
showTopBar: boolean;
|
|
@@ -124,7 +187,7 @@ interface ResolvedLayoutFeatures {
|
|
|
124
187
|
showContextMenu: boolean;
|
|
125
188
|
showSettings: boolean;
|
|
126
189
|
showShortcuts: boolean;
|
|
127
|
-
symbolInput: 'manual' | 'search' | 'none';
|
|
190
|
+
symbolInput: 'manual' | 'search' | 'dialog' | 'none';
|
|
128
191
|
}
|
|
129
192
|
declare const DEFAULT_LAYOUT_FEATURES: ResolvedLayoutFeatures;
|
|
130
193
|
declare function resolveLayoutFeatures(opts?: ChartLayoutOptions): ResolvedLayoutFeatures;
|
|
@@ -134,6 +197,8 @@ declare function createDemoLayoutOptions(partial?: ChartLayoutOptions): ChartLay
|
|
|
134
197
|
|
|
135
198
|
type DrawingToolId = 'cursor' | 'trendline' | 'hline' | 'vline' | 'rectangle' | 'fibonacci' | 'text';
|
|
136
199
|
interface ChartLayoutOptions extends TopBarOptions {
|
|
200
|
+
themeProvider?: ThemeProvider;
|
|
201
|
+
i18n?: I18nProvider;
|
|
137
202
|
showTopBar?: boolean;
|
|
138
203
|
showLeftToolbar?: boolean;
|
|
139
204
|
showBottomToolbar?: boolean;
|
|
@@ -148,7 +213,7 @@ interface ChartLayoutOptions extends TopBarOptions {
|
|
|
148
213
|
showContextMenu?: boolean;
|
|
149
214
|
showSettings?: boolean;
|
|
150
215
|
showShortcuts?: boolean;
|
|
151
|
-
symbolInput?: 'manual' | 'search' | 'none';
|
|
216
|
+
symbolInput?: 'manual' | 'search' | 'dialog' | 'none';
|
|
152
217
|
onDrawingStyleChange?: (patch: {
|
|
153
218
|
color?: string;
|
|
154
219
|
lineWidth?: number;
|
|
@@ -210,4 +275,4 @@ declare function mountPineEditorPanel(parent: HTMLElement, opts?: PineEditorPane
|
|
|
210
275
|
|
|
211
276
|
declare const pineLanguage: StreamLanguage<{}>;
|
|
212
277
|
|
|
213
|
-
export { type ChartLayoutOptions, type ContextMenuAction, type ContextMenuOptions, type CrosshairLegendOptions, DEFAULT_LAYOUT_FEATURES, type DrawingContextMenuHandlers, type DrawingPropertiesPanelOptions, type DrawingToolId, GRID_SETTING_KEY, type LayoutFeatures, type OhlcvSnapshot, PINE_SCRIPT_STORAGE_KEY, type PineEditorPanelOptions, RETURN_CURSOR_KEY, type ResolvedLayoutFeatures, type SettingsPanelOptions as SettingsMenuOptions, type SettingsPanelOptions, type StatusBarOptions, type SymbolInputMode, type SymbolSearchOptions, type TopBarOptions, attachChartContextMenu, bindShortcutsModal, createDemoLayoutOptions, loadIndicatorConfig, loadPineScriptPreference, loadReturnToCursorPreference, loadShowGridPreference, mergeLayoutFeatures, mountChartLayout, mountCodeSnippetPanel, mountCrosshairLegend, mountDrawingPropertiesPanel, mountPineEditorPanel, mountSettingsPanel as mountSettingsMenu, mountSettingsPanel, mountStatusBar, mountSymbolSearch, mountTopBar, openDrawingContextMenu, openShortcutsModal, pineLanguage, resolveLayoutFeatures, saveIndicatorConfig, savePineScriptPreference, saveReturnToCursorPreference, saveShowGridPreference };
|
|
278
|
+
export { type ChartLayoutOptions, type ContextMenuAction, type ContextMenuOptions, type CrosshairLegendOptions, DEFAULT_LAYOUT_FEATURES, type DrawingContextMenuHandlers, type DrawingPropertiesPanelOptions, type DrawingToolId, GRID_SETTING_KEY, type I18nProvider, type LayoutFeatures, type LogoSlotOptions, type OhlcvSnapshot, PINE_SCRIPT_STORAGE_KEY, type PineEditorPanelOptions, RETURN_CURSOR_KEY, type ResolvedLayoutFeatures, type SettingsPanelOptions as SettingsMenuOptions, type SettingsPanelOptions, type StatusBarOptions, type SymbolInputMode, type SymbolSearchDialogHandle, type SymbolSearchDialogOptions, type SymbolSearchOptions, THEME_STORAGE_KEY, type ThemeId, type ThemeProvider, type ThemeToggleOptions, type TopBarOptions, applyThemeToDocument, attachChartContextMenu, bindShortcutsModal, createDemoLayoutOptions, createI18nProvider, createSymbolSearchDialog, createThemeProvider, loadIndicatorConfig, loadPineScriptPreference, loadReturnToCursorPreference, loadShowGridPreference, loadTheme, mergeLayoutFeatures, mountChartLayout, mountCodeSnippetPanel, mountCrosshairLegend, mountDrawingPropertiesPanel, mountLogoSlot, mountPineEditorPanel, mountSettingsPanel as mountSettingsMenu, mountSettingsPanel, mountStatusBar, mountSymbolSearch, mountSymbolSearchDialogTrigger, mountThemeToggle, mountTopBar, openDrawingContextMenu, openShortcutsModal, pineLanguage, resolveLayoutFeatures, saveIndicatorConfig, savePineScriptPreference, saveReturnToCursorPreference, saveShowGridPreference, saveTheme };
|