@funnest/charts-ui 0.11.15 → 0.11.17
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/components/indicator-templates.d.ts +13 -0
- package/dist/context.d.ts +1 -1
- package/dist/i18n.d.ts +10 -0
- package/dist/index.js +131 -5
- package/dist/trading-chart.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsxImportSource preact */
|
|
2
|
+
import type { IndicatorConfig } from '@funnest/charts';
|
|
3
|
+
import type { WidgetContext } from '../context.js';
|
|
4
|
+
export interface IndicatorTemplate {
|
|
5
|
+
name: string;
|
|
6
|
+
indicators: IndicatorConfig[];
|
|
7
|
+
/** What it holds, as the legend names them (for the list). */
|
|
8
|
+
titles: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function readIndicatorTemplates(): IndicatorTemplate[];
|
|
11
|
+
export declare function IndicatorTemplates({ ctx }: {
|
|
12
|
+
ctx: WidgetContext;
|
|
13
|
+
}): import("preact").JSX.Element;
|
package/dist/context.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ export type ToolsMenuItems = (chart: Chart) => ToolsMenuItem[];
|
|
|
126
126
|
*/
|
|
127
127
|
export type LegendValues = 'always' | 'crosshair';
|
|
128
128
|
export interface IntervalGroup {
|
|
129
|
-
id: 'minutes' | 'hours' | 'days';
|
|
129
|
+
id: 'ticks' | 'minutes' | 'hours' | 'days';
|
|
130
130
|
intervals: Resolution[];
|
|
131
131
|
}
|
|
132
132
|
/** A tab in the symbol search dialog. */
|
package/dist/i18n.d.ts
CHANGED
|
@@ -164,6 +164,10 @@ export declare const STRINGS: {
|
|
|
164
164
|
saveTemplate: string;
|
|
165
165
|
templateName: string;
|
|
166
166
|
noTemplates: string;
|
|
167
|
+
indicatorTemplates: string;
|
|
168
|
+
saveIndicatorTemplate: string;
|
|
169
|
+
noIndicatorTemplates: string;
|
|
170
|
+
noIndicatorsToSave: string;
|
|
167
171
|
deleteTemplate: string;
|
|
168
172
|
lineWidth: string;
|
|
169
173
|
lineStyle: string;
|
|
@@ -263,6 +267,7 @@ export declare const STRINGS: {
|
|
|
263
267
|
point: string;
|
|
264
268
|
price: string;
|
|
265
269
|
time: string;
|
|
270
|
+
intervalTicks: string;
|
|
266
271
|
intervalMinutes: string;
|
|
267
272
|
intervalHours: string;
|
|
268
273
|
intervalDays: string;
|
|
@@ -493,6 +498,10 @@ export declare const STRINGS: {
|
|
|
493
498
|
saveTemplate: string;
|
|
494
499
|
templateName: string;
|
|
495
500
|
noTemplates: string;
|
|
501
|
+
indicatorTemplates: string;
|
|
502
|
+
saveIndicatorTemplate: string;
|
|
503
|
+
noIndicatorTemplates: string;
|
|
504
|
+
noIndicatorsToSave: string;
|
|
496
505
|
deleteTemplate: string;
|
|
497
506
|
lineWidth: string;
|
|
498
507
|
lineStyle: string;
|
|
@@ -592,6 +601,7 @@ export declare const STRINGS: {
|
|
|
592
601
|
point: string;
|
|
593
602
|
price: string;
|
|
594
603
|
time: string;
|
|
604
|
+
intervalTicks: string;
|
|
595
605
|
intervalMinutes: string;
|
|
596
606
|
intervalHours: string;
|
|
597
607
|
intervalDays: string;
|
package/dist/index.js
CHANGED
|
@@ -599,6 +599,10 @@ var STRINGS = {
|
|
|
599
599
|
saveTemplate: "\uC9C0\uAE08 \uBAA8\uC591\uC744 \uD15C\uD50C\uB9BF\uC73C\uB85C \uC800\uC7A5",
|
|
600
600
|
templateName: "\uD15C\uD50C\uB9BF \uC774\uB984",
|
|
601
601
|
noTemplates: "\uC774 \uB3C4\uAD6C\uB85C \uC800\uC7A5\uD55C \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC5B4\uC694",
|
|
602
|
+
indicatorTemplates: "\uC9C0\uD45C \uD15C\uD50C\uB9BF",
|
|
603
|
+
saveIndicatorTemplate: "\uC9C0\uAE08 \uC9C0\uD45C\uB97C \uD15C\uD50C\uB9BF\uC73C\uB85C \uC800\uC7A5",
|
|
604
|
+
noIndicatorTemplates: "\uC800\uC7A5\uD55C \uC9C0\uD45C \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC5B4\uC694. \uC9C0\uD45C\uB97C \uB123\uC740 \uB4A4 \uC544\uB798\uC5D0\uC11C \uC800\uC7A5\uD558\uBA74 \uB2E4\uB978 \uCC28\uD2B8\uC5D0\uB3C4 \uD55C \uBC88\uC5D0 \uB123\uC744 \uC218 \uC788\uC5B4\uC694.",
|
|
605
|
+
noIndicatorsToSave: "\uC800\uC7A5\uD560 \uC9C0\uD45C\uAC00 \uC5C6\uC5B4\uC694",
|
|
602
606
|
deleteTemplate: "\uD15C\uD50C\uB9BF \uC9C0\uC6B0\uAE30",
|
|
603
607
|
lineWidth: "\uC120 \uAD75\uAE30",
|
|
604
608
|
lineStyle: "\uC120 \uBAA8\uC591",
|
|
@@ -699,6 +703,7 @@ var STRINGS = {
|
|
|
699
703
|
price: "\uAC00\uACA9",
|
|
700
704
|
time: "\uC2DC\uAC04",
|
|
701
705
|
// intervals
|
|
706
|
+
intervalTicks: "\uD2F1",
|
|
702
707
|
intervalMinutes: "\uBD84",
|
|
703
708
|
intervalHours: "\uC2DC\uAC04",
|
|
704
709
|
intervalDays: "\uC77C",
|
|
@@ -930,6 +935,10 @@ var STRINGS = {
|
|
|
930
935
|
saveTemplate: "Save this look as a template",
|
|
931
936
|
templateName: "Template name",
|
|
932
937
|
noTemplates: "No templates for this tool yet",
|
|
938
|
+
indicatorTemplates: "Indicator templates",
|
|
939
|
+
saveIndicatorTemplate: "Save these indicators as a template",
|
|
940
|
+
noIndicatorTemplates: "No indicator templates yet. Add indicators, save them below, and put them on any chart in one go.",
|
|
941
|
+
noIndicatorsToSave: "No indicators to save",
|
|
933
942
|
deleteTemplate: "Delete template",
|
|
934
943
|
lineWidth: "Line width",
|
|
935
944
|
lineStyle: "Line style",
|
|
@@ -1029,6 +1038,7 @@ var STRINGS = {
|
|
|
1029
1038
|
point: "Point",
|
|
1030
1039
|
price: "Price",
|
|
1031
1040
|
time: "Time",
|
|
1041
|
+
intervalTicks: "Ticks",
|
|
1032
1042
|
intervalMinutes: "Minutes",
|
|
1033
1043
|
intervalHours: "Hours",
|
|
1034
1044
|
intervalDays: "Days",
|
|
@@ -3508,8 +3518,9 @@ function Dialogs({ ctx }) {
|
|
|
3508
3518
|
}
|
|
3509
3519
|
|
|
3510
3520
|
// src/components/interval-picker.tsx
|
|
3511
|
-
import { derivedBase as derivedBase2, resolutionToMs as resolutionToMs3 } from "@funnest/charts";
|
|
3521
|
+
import { derivedBase as derivedBase2, resolutionToMs as resolutionToMs3, tickCount } from "@funnest/charts";
|
|
3512
3522
|
var GROUP_LABEL = {
|
|
3523
|
+
ticks: "intervalTicks",
|
|
3513
3524
|
minutes: "intervalMinutes",
|
|
3514
3525
|
hours: "intervalHours",
|
|
3515
3526
|
days: "intervalDays"
|
|
@@ -3539,7 +3550,8 @@ function IntervalPicker({ ctx }) {
|
|
|
3539
3550
|
};
|
|
3540
3551
|
}, [open]);
|
|
3541
3552
|
const supported = s3.symbol?.supportedResolutions;
|
|
3542
|
-
const isSupported = (r3) => !supported || supported.includes(r3) || !!derivedBase2(r3, supported);
|
|
3553
|
+
const isSupported = (r3) => tickCount(r3) !== null ? !!supported?.includes(r3) : !supported || supported.includes(r3) || !!derivedBase2(r3, supported);
|
|
3554
|
+
const groups = ctx.intervalGroups.filter((g3) => g3.id !== "ticks" || g3.intervals.some(isSupported));
|
|
3543
3555
|
const listed = new Set(ctx.intervalGroups.flatMap((g3) => g3.intervals));
|
|
3544
3556
|
const custom = s3.customIntervals.filter((r3) => !listed.has(r3)).sort((a4, b) => resolutionToMs3(a4) - resolutionToMs3(b));
|
|
3545
3557
|
const order = [...ctx.intervalGroups.flatMap((g3) => g3.intervals), ...custom];
|
|
@@ -3587,7 +3599,7 @@ function IntervalPicker({ ctx }) {
|
|
|
3587
3599
|
}
|
|
3588
3600
|
),
|
|
3589
3601
|
open && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-interval-menu", role: "menu", ref: menuRef, children: [
|
|
3590
|
-
|
|
3602
|
+
groups.map((group) => /* @__PURE__ */ a3("div", { class: "fnc-menu-group", role: "group", "aria-label": t3[GROUP_LABEL[group.id]], children: [
|
|
3591
3603
|
/* @__PURE__ */ a3("div", { class: "fnc-menu-title", children: t3[GROUP_LABEL[group.id]] }),
|
|
3592
3604
|
group.intervals.map((r3) => {
|
|
3593
3605
|
const favorite = s3.favoriteIntervals.includes(r3);
|
|
@@ -4294,6 +4306,108 @@ function ToolsMenu({ ctx }) {
|
|
|
4294
4306
|
] });
|
|
4295
4307
|
}
|
|
4296
4308
|
|
|
4309
|
+
// src/components/indicator-templates.tsx
|
|
4310
|
+
var KEY = "fnc-indicator-templates";
|
|
4311
|
+
var MAX = 30;
|
|
4312
|
+
function readIndicatorTemplates() {
|
|
4313
|
+
try {
|
|
4314
|
+
const raw = localStorage.getItem(KEY);
|
|
4315
|
+
const list = raw ? JSON.parse(raw) : [];
|
|
4316
|
+
return Array.isArray(list) ? list.filter((x2) => !!x2 && typeof x2.name === "string" && Array.isArray(x2.indicators)) : [];
|
|
4317
|
+
} catch {
|
|
4318
|
+
return [];
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
function writeIndicatorTemplates(list) {
|
|
4322
|
+
try {
|
|
4323
|
+
localStorage.setItem(KEY, JSON.stringify(list));
|
|
4324
|
+
} catch {
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
function IndicatorTemplates({ ctx }) {
|
|
4328
|
+
const s3 = useStore(ctx.store);
|
|
4329
|
+
const t3 = stringsOf(s3);
|
|
4330
|
+
const [open, setOpen] = d2(false);
|
|
4331
|
+
const [list, setList] = d2(() => readIndicatorTemplates());
|
|
4332
|
+
const [naming, setNaming] = d2(null);
|
|
4333
|
+
const ref = T2(null);
|
|
4334
|
+
const menuRef = useKeepInView(open);
|
|
4335
|
+
A2(() => {
|
|
4336
|
+
if (!open) return;
|
|
4337
|
+
setList(readIndicatorTemplates());
|
|
4338
|
+
const onDown = (e3) => !ref.current?.contains(e3.target) && setOpen(false);
|
|
4339
|
+
const onKey = (e3) => e3.key === "Escape" && setOpen(false);
|
|
4340
|
+
document.addEventListener("pointerdown", onDown);
|
|
4341
|
+
document.addEventListener("keydown", onKey);
|
|
4342
|
+
return () => {
|
|
4343
|
+
document.removeEventListener("pointerdown", onDown);
|
|
4344
|
+
document.removeEventListener("keydown", onKey);
|
|
4345
|
+
};
|
|
4346
|
+
}, [open]);
|
|
4347
|
+
const keep = (next) => {
|
|
4348
|
+
setList(next);
|
|
4349
|
+
writeIndicatorTemplates(next);
|
|
4350
|
+
};
|
|
4351
|
+
const current = ctx.chart.getIndicators();
|
|
4352
|
+
const save = () => {
|
|
4353
|
+
const name = (naming ?? "").trim().slice(0, 30);
|
|
4354
|
+
if (!name || current.length === 0) return setNaming(null);
|
|
4355
|
+
const titles = ctx.chart.indicatorLegend().map((i3) => i3.title);
|
|
4356
|
+
keep([{ name, indicators: JSON.parse(JSON.stringify(current)), titles }, ...list.filter((x2) => x2.name !== name)].slice(0, MAX));
|
|
4357
|
+
setNaming(null);
|
|
4358
|
+
};
|
|
4359
|
+
const apply = (tpl) => {
|
|
4360
|
+
ctx.chart.setIndicators(JSON.parse(JSON.stringify(tpl.indicators)));
|
|
4361
|
+
setOpen(false);
|
|
4362
|
+
};
|
|
4363
|
+
return /* @__PURE__ */ a3("div", { class: "fnc-menu-wrap fnc-indtpl-wrap", ref, children: [
|
|
4364
|
+
/* @__PURE__ */ a3(
|
|
4365
|
+
"button",
|
|
4366
|
+
{
|
|
4367
|
+
class: "fnc-btn fnc-btn-indtpl",
|
|
4368
|
+
"data-tip": t3.indicatorTemplates,
|
|
4369
|
+
"aria-label": t3.indicatorTemplates,
|
|
4370
|
+
"aria-haspopup": "menu",
|
|
4371
|
+
"aria-expanded": open,
|
|
4372
|
+
onClick: () => {
|
|
4373
|
+
setNaming(null);
|
|
4374
|
+
setOpen(!open);
|
|
4375
|
+
},
|
|
4376
|
+
children: /* @__PURE__ */ a3(TemplateIcon, {})
|
|
4377
|
+
}
|
|
4378
|
+
),
|
|
4379
|
+
open && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-template-menu fnc-indtpl-menu", role: "menu", "aria-label": t3.indicatorTemplates, ref: menuRef, children: [
|
|
4380
|
+
/* @__PURE__ */ a3("div", { class: "fnc-menu-title", children: t3.indicatorTemplates }),
|
|
4381
|
+
list.length === 0 && /* @__PURE__ */ a3("div", { class: "fnc-menu-note", children: t3.noIndicatorTemplates }),
|
|
4382
|
+
list.map((tpl) => /* @__PURE__ */ a3("div", { class: "fnc-template-row", children: [
|
|
4383
|
+
/* @__PURE__ */ a3("button", { class: "fnc-menu-item fnc-indtpl-item", role: "menuitem", onClick: () => apply(tpl), children: [
|
|
4384
|
+
/* @__PURE__ */ a3("span", { class: "fnc-indtpl-name", children: tpl.name }),
|
|
4385
|
+
/* @__PURE__ */ a3("small", { class: "fnc-indtpl-sub", children: tpl.titles.length ? tpl.titles.join(" \xB7 ") : `${tpl.indicators.length}` })
|
|
4386
|
+
] }),
|
|
4387
|
+
/* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.deleteTemplate, "aria-label": `${tpl.name} ${t3.deleteTemplate}`, onClick: () => keep(list.filter((x2) => x2 !== tpl)), children: /* @__PURE__ */ a3(SmallCloseIcon, {}) })
|
|
4388
|
+
] })),
|
|
4389
|
+
/* @__PURE__ */ a3("div", { class: "fnc-menu-sep" }),
|
|
4390
|
+
naming === null ? /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", disabled: current.length === 0, onClick: () => setNaming(""), children: current.length === 0 ? t3.noIndicatorsToSave : t3.saveIndicatorTemplate }) : /* @__PURE__ */ a3(
|
|
4391
|
+
"input",
|
|
4392
|
+
{
|
|
4393
|
+
class: "fnc-selbar-text fnc-template-name",
|
|
4394
|
+
value: naming,
|
|
4395
|
+
placeholder: t3.templateName,
|
|
4396
|
+
"aria-label": t3.templateName,
|
|
4397
|
+
maxLength: 30,
|
|
4398
|
+
autoFocus: true,
|
|
4399
|
+
onInput: (e3) => setNaming(e3.target.value),
|
|
4400
|
+
onKeyDown: (e3) => {
|
|
4401
|
+
e3.stopPropagation();
|
|
4402
|
+
if (e3.key === "Enter") save();
|
|
4403
|
+
if (e3.key === "Escape") setNaming(null);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
)
|
|
4407
|
+
] })
|
|
4408
|
+
] });
|
|
4409
|
+
}
|
|
4410
|
+
|
|
4297
4411
|
// src/components/toolbar.tsx
|
|
4298
4412
|
function Toolbar({ ctx }) {
|
|
4299
4413
|
const s3 = useStore(ctx.store);
|
|
@@ -4334,6 +4448,7 @@ function Toolbar({ ctx }) {
|
|
|
4334
4448
|
]
|
|
4335
4449
|
}
|
|
4336
4450
|
),
|
|
4451
|
+
/* @__PURE__ */ a3(IndicatorTemplates, { ctx }),
|
|
4337
4452
|
/* @__PURE__ */ a3(ToolsMenu, { ctx })
|
|
4338
4453
|
] }),
|
|
4339
4454
|
/* @__PURE__ */ a3("div", { class: "fnc-sep" }),
|
|
@@ -6223,6 +6338,11 @@ var CSS = (
|
|
|
6223
6338
|
.fnc-tools-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0 6px; }
|
|
6224
6339
|
.fnc-tools-seg svg { width: 16px; height: 16px; flex: none; }
|
|
6225
6340
|
.fnc-template-menu { min-width: 220px; }
|
|
6341
|
+
.fnc-indtpl-menu { width: 280px; max-height: 60vh; overflow-y: auto; }
|
|
6342
|
+
.fnc-indtpl-menu .fnc-menu-note { line-height: 1.5; }
|
|
6343
|
+
.fnc-indtpl-item { flex-direction: column; align-items: flex-start !important; gap: 1px !important; padding-top: 6px; padding-bottom: 6px; }
|
|
6344
|
+
.fnc-indtpl-name { font-weight: 600; }
|
|
6345
|
+
.fnc-template-row .fnc-menu-item .fnc-indtpl-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--fnc-text-2); }
|
|
6226
6346
|
.fnc-levels-menu { min-width: 340px; }
|
|
6227
6347
|
.fnc-level-text { flex: 1; min-width: 0; width: 110px; height: 28px; padding: 0 8px; font-size: 13px; }
|
|
6228
6348
|
.fnc-options-menu { min-width: 280px; max-height: min(70vh, 560px); overflow-y: auto; }
|
|
@@ -7091,6 +7211,7 @@ function createPane(shell, config) {
|
|
|
7091
7211
|
|
|
7092
7212
|
// src/trading-chart.tsx
|
|
7093
7213
|
var DEFAULT_INTERVAL_GROUPS = [
|
|
7214
|
+
{ id: "ticks", intervals: ["10T", "100T", "1000T"] },
|
|
7094
7215
|
{ id: "minutes", intervals: ["1", "5", "15", "30"] },
|
|
7095
7216
|
{ id: "hours", intervals: ["60", "240"] },
|
|
7096
7217
|
{ id: "days", intervals: ["1D", "1W", "1M", "3M", "6M", "12M"] }
|
|
@@ -7382,12 +7503,17 @@ function createMultiChart(container, options) {
|
|
|
7382
7503
|
function ensurePanes(count) {
|
|
7383
7504
|
for (let i3 = panes.length; i3 < count; i3++) {
|
|
7384
7505
|
const src = panes[store.get().active] ?? panes[0];
|
|
7385
|
-
const
|
|
7506
|
+
const given = paneSpecs[i3];
|
|
7507
|
+
const spec = given ?? {
|
|
7386
7508
|
symbol: src?.chart.symbolInfo?.symbol ?? paneSpecs[0].symbol,
|
|
7387
7509
|
resolution: src?.chart.currentResolution ?? src?.store.get().resolution ?? resolution
|
|
7388
7510
|
};
|
|
7389
7511
|
const pane = makePane(i3, spec);
|
|
7390
|
-
if (src)
|
|
7512
|
+
if (!src) continue;
|
|
7513
|
+
if (!given && src.chart.symbolInfo) {
|
|
7514
|
+
const state = src.chart.save();
|
|
7515
|
+
void pane.chart.load({ ...state, drawings: {} });
|
|
7516
|
+
} else {
|
|
7391
7517
|
const { symbolWatermark, replayWatermark } = src.chart.settings;
|
|
7392
7518
|
pane.chart.setSettings({ symbolWatermark, replayWatermark });
|
|
7393
7519
|
}
|
package/dist/trading-chart.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ContextMenuItems, DrawingActions, IntervalGroup, LegendValues, Pri
|
|
|
4
4
|
import type { Strings } from './i18n.js';
|
|
5
5
|
import { type ColorScheme, type TradingChartSlots } from './shell.js';
|
|
6
6
|
export type { ColorScheme, TradingChartSlots } from './shell.js';
|
|
7
|
-
/** Interval menu: 분 | 시간 | 일. '12M' is shown as 1년. */
|
|
7
|
+
/** Interval menu: 틱 | 분 | 시간 | 일. '12M' is shown as 1년. 틱 shows only on a feed that lists tick intervals. */
|
|
8
8
|
export declare const DEFAULT_INTERVAL_GROUPS: readonly IntervalGroup[];
|
|
9
9
|
/** Toolbar chips until the user stars their own. */
|
|
10
10
|
export declare const DEFAULT_FAVORITE_INTERVALS: readonly Resolution[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnest/charts-ui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.17",
|
|
4
4
|
"description": "Pro trading UI (toolbar, drawing tools, sheets) for Funnest Charts. Framework-agnostic.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chart",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"NOTICE"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@funnest/charts": "0.11.
|
|
45
|
+
"@funnest/charts": "0.11.17"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"preact": "^11.2.0"
|