@funnest/charts-ui 0.9.4 → 0.10.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.
@@ -4,11 +4,6 @@ import type { WidgetContext } from '../context.js';
4
4
  export declare function DrawingToolbar({ ctx }: {
5
5
  ctx: WidgetContext;
6
6
  }): JSX.Element;
7
- /**
8
- * Floating bar for the selected drawing: move it by its grip (remembered; double-click resets),
9
- * color (swatches, a custom one, recent customs), line width and style, text for text tools,
10
- * lock, duplicate, delete (also the only way to delete on touch).
11
- */
12
7
  export declare function SelectionBar({ ctx }: {
13
8
  ctx: WidgetContext;
14
9
  }): JSX.Element | null;
@@ -0,0 +1,13 @@
1
+ import type { WidgetContext } from '../context.js';
2
+ import { type Strings } from '../i18n.js';
3
+ export declare function IndicatorSettings({ ctx, id, Dialog }: {
4
+ ctx: WidgetContext;
5
+ id: string;
6
+ Dialog: (p: {
7
+ title: string;
8
+ onClose: () => void;
9
+ wide?: boolean;
10
+ children: preact.ComponentChildren;
11
+ }) => preact.JSX.Element;
12
+ }): import("preact").JSX.Element | null;
13
+ export type { Strings };
@@ -0,0 +1,16 @@
1
+ /** @jsxImportSource preact */
2
+ import type { IntervalUnit, IntervalVisibility } from '@funnest/charts';
3
+ import type { Strings } from '../i18n.js';
4
+ /** 보임: each interval unit, on or off, and the range of it (TradingView's Visibility tab). */
5
+ export declare const INTERVAL_UNITS: {
6
+ unit: IntervalUnit;
7
+ max: number;
8
+ label: (t: Strings) => string;
9
+ }[];
10
+ /** Drops units left at "all of it": nothing left → undefined (shown everywhere). */
11
+ export declare function cleanIntervals(v: IntervalVisibility | undefined): IntervalVisibility | undefined;
12
+ export declare function IntervalVisibilityEditor({ t, value, onChange }: {
13
+ t: Strings;
14
+ value: IntervalVisibility | undefined;
15
+ onChange: (v: IntervalVisibility) => void;
16
+ }): import("preact").JSX.Element;
package/dist/i18n.d.ts CHANGED
@@ -107,6 +107,11 @@ export declare const STRINGS: {
107
107
  resetColors: string;
108
108
  templates: string;
109
109
  levels: string;
110
+ drawingOrder: string;
111
+ bringToFront: string;
112
+ bringForward: string;
113
+ sendBackward: string;
114
+ sendToBack: string;
110
115
  drawingOptions: string;
111
116
  resetOptions: string;
112
117
  levelShown: string;
@@ -156,6 +161,63 @@ export declare const STRINGS: {
156
161
  source: string;
157
162
  inputs: string;
158
163
  style: string;
164
+ tabInputs: string;
165
+ tabStyle: string;
166
+ tabVisibility: string;
167
+ calculation: string;
168
+ timeframe: string;
169
+ timeframeChart: string;
170
+ waitClose: string;
171
+ timeframeHint: string;
172
+ plotType: string;
173
+ kindLine: string;
174
+ kindStep: string;
175
+ kindArea: string;
176
+ kindHistogram: string;
177
+ kindColumns: string;
178
+ kindCircles: string;
179
+ kindCross: string;
180
+ indLevels: string;
181
+ fillBand: string;
182
+ outputValues: string;
183
+ precision: string;
184
+ precisionDefault: string;
185
+ axisLabels: string;
186
+ statusValues: string;
187
+ inputValues: string;
188
+ statusInputs: string;
189
+ visibilityHint: string;
190
+ visSeconds: string;
191
+ visMinutes: string;
192
+ visHours: string;
193
+ visDays: string;
194
+ visWeeks: string;
195
+ visMonths: string;
196
+ rangeFrom: string;
197
+ rangeTo: string;
198
+ defaults: string;
199
+ resetIndicator: string;
200
+ saveDefaults: string;
201
+ forgetDefaults: string;
202
+ ok: string;
203
+ levelValuesLabel: string;
204
+ note: string;
205
+ noteText: string;
206
+ bold: string;
207
+ italic: string;
208
+ noteH: string;
209
+ noteV: string;
210
+ alignLeft: string;
211
+ alignCenter: string;
212
+ alignRight: string;
213
+ alignTop: string;
214
+ alignMiddle: string;
215
+ alignBottom: string;
216
+ textColor: string;
217
+ coordinates: string;
218
+ point: string;
219
+ price: string;
220
+ time: string;
159
221
  intervalMinutes: string;
160
222
  intervalHours: string;
161
223
  intervalDays: string;
@@ -329,6 +391,11 @@ export declare const STRINGS: {
329
391
  resetColors: string;
330
392
  templates: string;
331
393
  levels: string;
394
+ drawingOrder: string;
395
+ bringToFront: string;
396
+ bringForward: string;
397
+ sendBackward: string;
398
+ sendToBack: string;
332
399
  drawingOptions: string;
333
400
  resetOptions: string;
334
401
  levelShown: string;
@@ -378,6 +445,63 @@ export declare const STRINGS: {
378
445
  source: string;
379
446
  inputs: string;
380
447
  style: string;
448
+ tabInputs: string;
449
+ tabStyle: string;
450
+ tabVisibility: string;
451
+ calculation: string;
452
+ timeframe: string;
453
+ timeframeChart: string;
454
+ waitClose: string;
455
+ timeframeHint: string;
456
+ plotType: string;
457
+ kindLine: string;
458
+ kindStep: string;
459
+ kindArea: string;
460
+ kindHistogram: string;
461
+ kindColumns: string;
462
+ kindCircles: string;
463
+ kindCross: string;
464
+ indLevels: string;
465
+ fillBand: string;
466
+ outputValues: string;
467
+ precision: string;
468
+ precisionDefault: string;
469
+ axisLabels: string;
470
+ statusValues: string;
471
+ inputValues: string;
472
+ statusInputs: string;
473
+ visibilityHint: string;
474
+ visSeconds: string;
475
+ visMinutes: string;
476
+ visHours: string;
477
+ visDays: string;
478
+ visWeeks: string;
479
+ visMonths: string;
480
+ rangeFrom: string;
481
+ rangeTo: string;
482
+ defaults: string;
483
+ resetIndicator: string;
484
+ saveDefaults: string;
485
+ forgetDefaults: string;
486
+ ok: string;
487
+ levelValuesLabel: string;
488
+ note: string;
489
+ noteText: string;
490
+ bold: string;
491
+ italic: string;
492
+ noteH: string;
493
+ noteV: string;
494
+ alignLeft: string;
495
+ alignCenter: string;
496
+ alignRight: string;
497
+ alignTop: string;
498
+ alignMiddle: string;
499
+ alignBottom: string;
500
+ textColor: string;
501
+ coordinates: string;
502
+ point: string;
503
+ price: string;
504
+ time: string;
381
505
  intervalMinutes: string;
382
506
  intervalHours: string;
383
507
  intervalDays: string;
package/dist/icons.d.ts CHANGED
@@ -34,6 +34,8 @@ export declare const LineBreakIcon: () => import("preact").JSX.Element;
34
34
  export declare const PointFigureIcon: () => import("preact").JSX.Element;
35
35
  export declare const IndicatorIcon: () => import("preact").JSX.Element;
36
36
  export declare const GearIcon: () => import("preact").JSX.Element;
37
+ /** 순서 (layers): two stacked sheets, the top one filled. */
38
+ export declare const LayersIcon: () => import("preact").JSX.Element;
37
39
  /** 레벨 설정: lines at different heights with a value tick. */
38
40
  export declare const LevelsIcon: () => import("preact").JSX.Element;
39
41
  /** 그리기 템플릿: stacked cards. */
package/dist/index.js CHANGED
@@ -270,7 +270,7 @@ n = { __e: function(n2, t3, r3, u3) {
270
270
  }, e = /* @__PURE__ */ Symbol(), l = /(PointerCapture)$|Capture$/i, c = 0, a = {}, s = 0;
271
271
 
272
272
  // src/components/drawing-toolbar.tsx
273
- import { drawingLevels, drawingOption } from "@funnest/charts";
273
+ import { drawingLevels, drawingOption, timeZoneOffset } from "@funnest/charts";
274
274
 
275
275
  // ../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/hooks/dist/hooks.mjs
276
276
  var t2;
@@ -536,6 +536,11 @@ var STRINGS = {
536
536
  resetColors: "\uAE30\uBCF8 \uC0C9\uC73C\uB85C",
537
537
  templates: "\uD15C\uD50C\uB9BF",
538
538
  levels: "\uB808\uBCA8 \uC124\uC815",
539
+ drawingOrder: "\uC21C\uC11C",
540
+ bringToFront: "\uB9E8 \uC55E\uC73C\uB85C",
541
+ bringForward: "\uC55E\uC73C\uB85C",
542
+ sendBackward: "\uB4A4\uB85C",
543
+ sendToBack: "\uB9E8 \uB4A4\uB85C",
539
544
  drawingOptions: "\uB3C4\uAD6C \uC124\uC815",
540
545
  resetOptions: "\uAE30\uBCF8 \uC124\uC815\uC73C\uB85C",
541
546
  levelShown: "\uB808\uBCA8 \uBCF4\uC774\uAE30",
@@ -585,6 +590,63 @@ var STRINGS = {
585
590
  source: "\uAC00\uACA9 \uAE30\uC900",
586
591
  inputs: "\uC785\uB825\uAC12",
587
592
  style: "\uC2A4\uD0C0\uC77C",
593
+ tabInputs: "\uC778\uD48B",
594
+ tabStyle: "\uBAA8\uC2B5",
595
+ tabVisibility: "\uBCF4\uC784",
596
+ calculation: "\uACC4\uC0B0",
597
+ timeframe: "\uD0C0\uC784\uD504\uB808\uC784",
598
+ timeframeChart: "\uCC28\uD2B8",
599
+ waitClose: "\uD0C0\uC784\uD504\uB808\uC784 \uB9C8\uAC10 \uB300\uAE30",
600
+ timeframeHint: "\uC774 \uC9C0\uD45C\uB97C \uACE0\uB978 \uC2DC\uAC04 \uB2E8\uC704\uC758 \uBD09\uC73C\uB85C \uACC4\uC0B0\uD574\uC694. \uB9C8\uAC10 \uB300\uAE30\uB97C \uCF1C\uBA74 \uB2E4 \uB05D\uB09C \uBD09\uC758 \uAC12\uB9CC \uADF8\uB824\uC11C, \uADF8\uB824\uC9C4 \uC120\uC774 \uB098\uC911\uC5D0 \uBC14\uB00C\uC9C0 \uC54A\uC544\uC694.",
601
+ plotType: "\uADF8\uB9AC\uB294 \uBC29\uC2DD",
602
+ kindLine: "\uC120",
603
+ kindStep: "\uACC4\uB2E8",
604
+ kindArea: "\uC601\uC5ED",
605
+ kindHistogram: "\uD788\uC2A4\uD1A0\uADF8\uB7A8",
606
+ kindColumns: "\uB9C9\uB300",
607
+ kindCircles: "\uC810",
608
+ kindCross: "\uC2ED\uC790",
609
+ indLevels: "\uAE30\uC900\uC120",
610
+ fillBand: "\uBC30\uACBD",
611
+ outputValues: "\uCD9C\uB825 \uAC12",
612
+ precision: "\uC815\uBC00\uB3C4",
613
+ precisionDefault: "\uAE30\uBCF8\uC124\uC815",
614
+ axisLabels: "\uD504\uB77C\uC774\uC2A4 \uC2A4\uCF00\uC77C \uB77C\uBCA8",
615
+ statusValues: "\uC0C1\uD0DC \uB77C\uC778 \uBC38\uB958",
616
+ inputValues: "\uC785\uB825 \uAC12",
617
+ statusInputs: "\uC0C1\uD0DC \uD45C\uC2DC\uC904\uC758 \uC785\uB825\uAC12",
618
+ visibilityHint: "\uCCB4\uD06C\uD55C \uC2DC\uAC04 \uB2E8\uC704\uC758 \uCC28\uD2B8\uC5D0\uC11C\uB9CC \uBCF4\uC5EC\uC694. \uBC94\uC704\uB97C \uC881\uD788\uBA74 \uADF8 \uC548\uC758 \uC8FC\uAE30\uC5D0\uC11C\uB9CC \uBCF4\uC5EC\uC694 (\uC608: \uBD84 1\u201315).",
619
+ visSeconds: "\uCD08",
620
+ visMinutes: "\uBD84",
621
+ visHours: "\uC2DC\uAC04",
622
+ visDays: "\uC77C",
623
+ visWeeks: "\uC8FC",
624
+ visMonths: "\uAC1C\uC6D4",
625
+ rangeFrom: "\uBD80\uD130",
626
+ rangeTo: "\uAE4C\uC9C0",
627
+ defaults: "\uAE30\uBCF8\uC124\uC815",
628
+ resetIndicator: "\uAE30\uBCF8\uAC12\uC73C\uB85C \uC7AC\uC124\uC815",
629
+ saveDefaults: "\uAE30\uBCF8\uAC12\uC73C\uB85C \uC800\uC7A5",
630
+ forgetDefaults: "\uC800\uC7A5\uD55C \uAE30\uBCF8\uAC12 \uC9C0\uC6B0\uAE30",
631
+ ok: "\uD655\uC778",
632
+ levelValuesLabel: "\uAE30\uC900\uC120 \uAC12",
633
+ note: "\uD14D\uC2A4\uD2B8",
634
+ noteText: "\uD14D\uC2A4\uD2B8 \uC785\uB825",
635
+ bold: "\uAD75\uAC8C",
636
+ italic: "\uAE30\uC6B8\uC784",
637
+ noteH: "\uAC00\uB85C \uC704\uCE58",
638
+ noteV: "\uC138\uB85C \uC704\uCE58",
639
+ alignLeft: "\uC67C\uCABD",
640
+ alignCenter: "\uAC00\uC6B4\uB370",
641
+ alignRight: "\uC624\uB978\uCABD",
642
+ alignTop: "\uC704",
643
+ alignMiddle: "\uAC00\uC6B4\uB370",
644
+ alignBottom: "\uC544\uB798",
645
+ textColor: "\uAE00\uC790 \uC0C9",
646
+ coordinates: "\uC88C\uD45C",
647
+ point: "\uC810",
648
+ price: "\uAC00\uACA9",
649
+ time: "\uC2DC\uAC04",
588
650
  // intervals
589
651
  intervalMinutes: "\uBD84",
590
652
  intervalHours: "\uC2DC\uAC04",
@@ -760,6 +822,11 @@ var STRINGS = {
760
822
  resetColors: "Reset colors",
761
823
  templates: "Templates",
762
824
  levels: "Levels",
825
+ drawingOrder: "Order",
826
+ bringToFront: "Bring to front",
827
+ bringForward: "Bring forward",
828
+ sendBackward: "Send backward",
829
+ sendToBack: "Send to back",
763
830
  drawingOptions: "Settings",
764
831
  resetOptions: "Default settings",
765
832
  levelShown: "Show level",
@@ -809,6 +876,63 @@ var STRINGS = {
809
876
  source: "Source",
810
877
  inputs: "Inputs",
811
878
  style: "Style",
879
+ tabInputs: "Inputs",
880
+ tabStyle: "Style",
881
+ tabVisibility: "Visibility",
882
+ calculation: "Calculation",
883
+ timeframe: "Timeframe",
884
+ timeframeChart: "Chart",
885
+ waitClose: "Wait for timeframe closes",
886
+ timeframeHint: "Computed on bars of the chosen interval. Waiting for closes draws only finished bars, so what is drawn never changes.",
887
+ plotType: "Plot type",
888
+ kindLine: "Line",
889
+ kindStep: "Step line",
890
+ kindArea: "Area",
891
+ kindHistogram: "Histogram",
892
+ kindColumns: "Columns",
893
+ kindCircles: "Circles",
894
+ kindCross: "Cross",
895
+ indLevels: "Levels",
896
+ fillBand: "Background",
897
+ outputValues: "Output values",
898
+ precision: "Precision",
899
+ precisionDefault: "Default",
900
+ axisLabels: "Labels on price scale",
901
+ statusValues: "Values in status line",
902
+ inputValues: "Input values",
903
+ statusInputs: "Inputs in status line",
904
+ visibilityHint: "Shown only on charts of the checked units; narrow a range to show it only on those intervals (e.g. minutes 1\u201315).",
905
+ visSeconds: "Seconds",
906
+ visMinutes: "Minutes",
907
+ visHours: "Hours",
908
+ visDays: "Days",
909
+ visWeeks: "Weeks",
910
+ visMonths: "Months",
911
+ rangeFrom: "from",
912
+ rangeTo: "to",
913
+ defaults: "Defaults",
914
+ resetIndicator: "Reset settings",
915
+ saveDefaults: "Save as default",
916
+ forgetDefaults: "Forget saved default",
917
+ ok: "Ok",
918
+ levelValuesLabel: "Level values",
919
+ note: "Text",
920
+ noteText: "Type text",
921
+ bold: "Bold",
922
+ italic: "Italic",
923
+ noteH: "Horizontal",
924
+ noteV: "Vertical",
925
+ alignLeft: "Left",
926
+ alignCenter: "Center",
927
+ alignRight: "Right",
928
+ alignTop: "Top",
929
+ alignMiddle: "Middle",
930
+ alignBottom: "Bottom",
931
+ textColor: "Text color",
932
+ coordinates: "Coordinates",
933
+ point: "Point",
934
+ price: "Price",
935
+ time: "Time",
812
936
  intervalMinutes: "Minutes",
813
937
  intervalHours: "Hours",
814
938
  intervalDays: "Days",
@@ -895,6 +1019,74 @@ function a3(t3, e3, n2, u3, a4, i3) {
895
1019
  return (a4 || i3) && (s3.__source = a4, s3.__self = i3), n.vnode && n.vnode(s3), s3;
896
1020
  }
897
1021
 
1022
+ // src/components/interval-visibility.tsx
1023
+ var INTERVAL_UNITS = [
1024
+ { unit: "seconds", max: 59, label: (t3) => t3.visSeconds },
1025
+ { unit: "minutes", max: 59, label: (t3) => t3.visMinutes },
1026
+ { unit: "hours", max: 24, label: (t3) => t3.visHours },
1027
+ { unit: "days", max: 366, label: (t3) => t3.visDays },
1028
+ { unit: "weeks", max: 52, label: (t3) => t3.visWeeks },
1029
+ { unit: "months", max: 12, label: (t3) => t3.visMonths }
1030
+ ];
1031
+ function cleanIntervals(v3) {
1032
+ if (!v3) return void 0;
1033
+ const out = {};
1034
+ for (const { unit, max } of INTERVAL_UNITS) {
1035
+ const rule = v3[unit];
1036
+ if (rule === void 0) continue;
1037
+ if (rule === false) out[unit] = false;
1038
+ else {
1039
+ const lo = Math.max(1, Math.min(max, Math.round(rule[0]) || 1));
1040
+ const hi = Math.max(lo, Math.min(max, Math.round(rule[1]) || max));
1041
+ if (lo !== 1 || hi !== max) out[unit] = [lo, hi];
1042
+ }
1043
+ }
1044
+ return Object.keys(out).length ? out : void 0;
1045
+ }
1046
+ function IntervalVisibilityEditor({ t: t3, value, onChange }) {
1047
+ const v3 = value ?? {};
1048
+ const set = (unit, rule) => {
1049
+ const next = { ...v3 };
1050
+ if (rule === void 0) delete next[unit];
1051
+ else next[unit] = rule;
1052
+ onChange(next);
1053
+ };
1054
+ return /* @__PURE__ */ a3("div", { class: "fnc-rows fnc-vis", children: INTERVAL_UNITS.map(({ unit, max, label }) => {
1055
+ const rule = v3[unit];
1056
+ const on = rule !== false;
1057
+ const [lo, hi] = Array.isArray(rule) ? rule : [1, max];
1058
+ return /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
1059
+ /* @__PURE__ */ a3("label", { class: "fnc-vis-unit", children: [
1060
+ /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked: on, onChange: (e3) => set(unit, e3.currentTarget.checked ? void 0 : false) }),
1061
+ label(t3)
1062
+ ] }),
1063
+ /* @__PURE__ */ a3(
1064
+ "input",
1065
+ {
1066
+ class: "fnc-input fnc-input-num",
1067
+ inputMode: "numeric",
1068
+ value: String(lo),
1069
+ disabled: !on,
1070
+ "aria-label": `${label(t3)} ${t3.rangeFrom}`,
1071
+ onChange: (e3) => set(unit, [Number(e3.currentTarget.value) || 1, hi])
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ a3("span", { class: "fnc-vis-dash", children: "\u2013" }),
1075
+ /* @__PURE__ */ a3(
1076
+ "input",
1077
+ {
1078
+ class: "fnc-input fnc-input-num",
1079
+ inputMode: "numeric",
1080
+ value: String(hi),
1081
+ disabled: !on,
1082
+ "aria-label": `${label(t3)} ${t3.rangeTo}`,
1083
+ onChange: (e3) => set(unit, [lo, Number(e3.currentTarget.value) || max])
1084
+ }
1085
+ )
1086
+ ] });
1087
+ }) });
1088
+ }
1089
+
898
1090
  // src/icons.tsx
899
1091
  function Icon({ children, size = 20 }) {
900
1092
  return /* @__PURE__ */ a3(
@@ -1018,6 +1210,10 @@ var GearIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
1018
1210
  /* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.4" }),
1019
1211
  /* @__PURE__ */ a3("path", { d: "M10 3v2M10 15v2M3 10h2M15 10h2M5 5l1.4 1.4M13.6 13.6L15 15M5 15l1.4-1.4M13.6 6.4L15 5" })
1020
1212
  ] });
1213
+ var LayersIcon = () => /* @__PURE__ */ a3(Icon, { children: [
1214
+ /* @__PURE__ */ a3("path", { d: "M10 4 3 7.5 10 11l7-3.5z", fill: "currentColor", "fill-opacity": "0.25" }),
1215
+ /* @__PURE__ */ a3("path", { d: "M3 11l7 3.5 7-3.5" })
1216
+ ] });
1021
1217
  var LevelsIcon = () => /* @__PURE__ */ a3(Icon, { children: [
1022
1218
  /* @__PURE__ */ a3("path", { d: "M3 5h9M3 10h14M3 15h11" }),
1023
1219
  /* @__PURE__ */ a3("circle", { cx: "15", cy: "5", r: "1.4" }),
@@ -1050,6 +1246,10 @@ var CalendarIcon = () => /* @__PURE__ */ a3(Icon, { size: 16, children: [
1050
1246
  /* @__PURE__ */ a3("rect", { x: "3.5", y: "4.5", width: "13", height: "12", rx: "2" }),
1051
1247
  /* @__PURE__ */ a3("path", { d: "M3.5 8.5h13M7 3v3M13 3v3" })
1052
1248
  ] });
1249
+ var ClockIcon = () => /* @__PURE__ */ a3(Icon, { size: 13, children: [
1250
+ /* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "7" }),
1251
+ /* @__PURE__ */ a3("path", { d: "M10 6v4l2.5 1.5" })
1252
+ ] });
1053
1253
  var SettingsIcon = () => /* @__PURE__ */ a3(Icon, { children: [
1054
1254
  /* @__PURE__ */ a3("path", { d: "M10 12.6a2.6 2.6 0 1 0 0-5.2 2.6 2.6 0 0 0 0 5.2z" }),
1055
1255
  /* @__PURE__ */ a3("path", { d: "M16.2 12a1.3 1.3 0 0 0 .26 1.43l.05.05a1.6 1.6 0 1 1-2.26 2.26l-.05-.05a1.3 1.3 0 0 0-1.43-.26 1.3 1.3 0 0 0-.79 1.19v.14a1.6 1.6 0 0 1-3.2 0v-.07a1.3 1.3 0 0 0-.85-1.19 1.3 1.3 0 0 0-1.43.26l-.05.05a1.6 1.6 0 1 1-2.26-2.26l.05-.05A1.3 1.3 0 0 0 4.5 12a1.3 1.3 0 0 0-1.19-.79h-.14a1.6 1.6 0 0 1 0-3.2h.07a1.3 1.3 0 0 0 1.19-.85 1.3 1.3 0 0 0-.26-1.43l-.05-.05a1.6 1.6 0 1 1 2.26-2.26l.05.05a1.3 1.3 0 0 0 1.43.26h.06a1.3 1.3 0 0 0 .79-1.19v-.14a1.6 1.6 0 0 1 3.2 0v.07a1.3 1.3 0 0 0 .79 1.19 1.3 1.3 0 0 0 1.43-.26l.05-.05a1.6 1.6 0 1 1 2.26 2.26l-.05.05a1.3 1.3 0 0 0-.26 1.43v.06a1.3 1.3 0 0 0 1.19.79h.14a1.6 1.6 0 0 1 0 3.2h-.07a1.3 1.3 0 0 0-1.19.79z" })
@@ -1128,6 +1328,7 @@ var CopyIcon = () => /* @__PURE__ */ a3(Icon, { children: [
1128
1328
  /* @__PURE__ */ a3("rect", { x: "7", y: "7", width: "9.5", height: "9.5", rx: "1.8" }),
1129
1329
  /* @__PURE__ */ a3("path", { d: "M13 7V5a1.5 1.5 0 0 0-1.5-1.5h-6A1.5 1.5 0 0 0 4 5v6a1.5 1.5 0 0 0 1.5 1.5H7" })
1130
1330
  ] });
1331
+ var TextIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("path", { d: "M4.5 5V3.8h11V5M10 3.8v12.5M7.5 16.3h5" }) });
1131
1332
 
1132
1333
  // src/store.ts
1133
1334
  var Store = class {
@@ -1469,6 +1670,47 @@ function DashGlyph({ dash }) {
1469
1670
  const pattern = dash === "dashed" ? "4 3" : dash === "dotted" ? "1 3" : void 0;
1470
1671
  return /* @__PURE__ */ a3("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "aria-hidden": "true", children: /* @__PURE__ */ a3("path", { d: "M3 10h14", "stroke-dasharray": pattern }) });
1471
1672
  }
1673
+ function DrawingCoords({ ctx, drawing, t: t3 }) {
1674
+ const tz = ctx.chart.timeZone;
1675
+ const toLocal = (time) => new Date(time + timeZoneOffset(time, tz)).toISOString().slice(0, 16);
1676
+ const fromLocal = (text) => {
1677
+ const asUtc = Date.parse(`${text}:00Z`);
1678
+ if (!Number.isFinite(asUtc)) return null;
1679
+ const guess = asUtc - timeZoneOffset(asUtc, tz);
1680
+ return asUtc - timeZoneOffset(guess, tz);
1681
+ };
1682
+ const setPoint = (i3, patch) => ctx.chart.updateDrawing(drawing.id, { points: drawing.points.map((p3, j2) => j2 === i3 ? { ...p3, ...patch } : p3) });
1683
+ return /* @__PURE__ */ a3("div", { class: "fnc-coords", children: drawing.points.map((p3, i3) => /* @__PURE__ */ a3("div", { class: "fnc-coord-row", children: [
1684
+ /* @__PURE__ */ a3("span", { class: "fnc-coord-name", children: drawing.points.length > 1 ? `${t3.point} ${i3 + 1}` : t3.point }),
1685
+ /* @__PURE__ */ a3(
1686
+ "input",
1687
+ {
1688
+ class: "fnc-input fnc-coord-price",
1689
+ type: "number",
1690
+ step: "any",
1691
+ defaultValue: String(p3.price),
1692
+ "aria-label": `${t3.point} ${i3 + 1} ${t3.price}`,
1693
+ onChange: (e3) => {
1694
+ const v3 = Number(e3.target.value);
1695
+ if (Number.isFinite(v3)) setPoint(i3, { price: v3 });
1696
+ }
1697
+ }
1698
+ ),
1699
+ /* @__PURE__ */ a3(
1700
+ "input",
1701
+ {
1702
+ class: "fnc-input fnc-coord-time",
1703
+ type: "datetime-local",
1704
+ defaultValue: toLocal(p3.time),
1705
+ "aria-label": `${t3.point} ${i3 + 1} ${t3.time}`,
1706
+ onChange: (e3) => {
1707
+ const time = fromLocal(e3.target.value);
1708
+ if (time !== null) setPoint(i3, { time });
1709
+ }
1710
+ }
1711
+ )
1712
+ ] }, `${drawing.id}:${i3}:${p3.time}:${p3.price}`)) });
1713
+ }
1472
1714
  function SelectionBar({ ctx }) {
1473
1715
  const s3 = useStore(ctx.store);
1474
1716
  const t3 = stringsOf(s3);
@@ -1876,6 +2118,117 @@ function SelectionBar({ ctx }) {
1876
2118
  }
1877
2119
  )),
1878
2120
  /* @__PURE__ */ a3("div", { class: "fnc-sep" }),
2121
+ /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
2122
+ /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.drawingOrder, "aria-label": t3.drawingOrder, "aria-expanded": menu === "order", onClick: () => setMenu(menu === "order" ? null : "order"), children: /* @__PURE__ */ a3(LayersIcon, {}) }),
2123
+ menu === "order" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop", role: "menu", children: [
2124
+ ["front", t3.bringToFront],
2125
+ ["forward", t3.bringForward],
2126
+ ["backward", t3.sendBackward],
2127
+ ["back", t3.sendToBack]
2128
+ ].map(([where, label]) => /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", disabled: !ctx.chart.canMoveDrawing(d3.id, where), onClick: () => ctx.chart.moveDrawing(d3.id, where), children: label })) })
2129
+ ] }),
2130
+ def && !def.text && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
2131
+ /* @__PURE__ */ a3(
2132
+ "button",
2133
+ {
2134
+ class: style.text ? "fnc-btn fnc-btn-on" : "fnc-btn",
2135
+ "data-tip": t3.note,
2136
+ "aria-label": t3.note,
2137
+ "aria-expanded": menu === "note",
2138
+ onClick: () => setMenu(menu === "note" ? null : "note"),
2139
+ children: /* @__PURE__ */ a3(TextIcon, {})
2140
+ }
2141
+ ),
2142
+ menu === "note" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-note-menu", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
2143
+ /* @__PURE__ */ a3(
2144
+ "textarea",
2145
+ {
2146
+ defaultValue: style.text ?? "",
2147
+ placeholder: t3.noteText,
2148
+ "aria-label": t3.noteText,
2149
+ onInput: (e3) => {
2150
+ const text = e3.target.value;
2151
+ const { text: _drop, ...rest } = style;
2152
+ setStyleRaw(text.trim() ? { ...rest, text } : rest);
2153
+ }
2154
+ },
2155
+ d3.id
2156
+ ),
2157
+ /* @__PURE__ */ a3("div", { class: "fnc-note-row", children: [
2158
+ /* @__PURE__ */ a3(
2159
+ "input",
2160
+ {
2161
+ type: "color",
2162
+ class: "fnc-color",
2163
+ "aria-label": t3.textColor,
2164
+ value: /^#[0-9a-f]{6}$/i.test(style.textColor ?? d3.color ?? "") ? style.textColor ?? d3.color : "#3182f6",
2165
+ onInput: (e3) => setStyle({ textColor: e3.target.value })
2166
+ }
2167
+ ),
2168
+ /* @__PURE__ */ a3("select", { class: "fnc-select", "aria-label": t3.fontSize, value: String(style.fontSize ?? 14), onChange: (e3) => setStyle({ fontSize: Number(e3.target.value) }), children: [10, 11, 12, 14, 16, 20, 24, 28, 32, 40].map((n2) => /* @__PURE__ */ a3("option", { value: String(n2), children: [
2169
+ n2,
2170
+ "px"
2171
+ ] })) }),
2172
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-note-toggle", "aria-pressed": !!style.bold, "aria-label": t3.bold, onClick: () => setStyle({ bold: !style.bold }), children: /* @__PURE__ */ a3("b", { children: "B" }) }),
2173
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-note-toggle", "aria-pressed": !!style.italic, "aria-label": t3.italic, onClick: () => setStyle({ italic: !style.italic }), children: /* @__PURE__ */ a3("i", { children: "I" }) })
2174
+ ] }),
2175
+ /* @__PURE__ */ a3("div", { class: "fnc-note-row", children: [
2176
+ /* @__PURE__ */ a3("span", { children: t3.noteH }),
2177
+ /* @__PURE__ */ a3("select", { class: "fnc-select", "aria-label": t3.noteH, value: style.textH ?? "center", onChange: (e3) => setStyle({ textH: e3.target.value }), children: [
2178
+ /* @__PURE__ */ a3("option", { value: "left", children: t3.alignLeft }),
2179
+ /* @__PURE__ */ a3("option", { value: "center", children: t3.alignCenter }),
2180
+ /* @__PURE__ */ a3("option", { value: "right", children: t3.alignRight })
2181
+ ] }),
2182
+ /* @__PURE__ */ a3("span", { children: t3.noteV }),
2183
+ /* @__PURE__ */ a3(
2184
+ "select",
2185
+ {
2186
+ class: "fnc-select",
2187
+ "aria-label": t3.noteV,
2188
+ value: style.textV ?? (def.note === "line" ? "top" : "middle"),
2189
+ onChange: (e3) => setStyle({ textV: e3.target.value }),
2190
+ children: [
2191
+ /* @__PURE__ */ a3("option", { value: "top", children: t3.alignTop }),
2192
+ /* @__PURE__ */ a3("option", { value: "middle", children: t3.alignMiddle }),
2193
+ /* @__PURE__ */ a3("option", { value: "bottom", children: t3.alignBottom })
2194
+ ]
2195
+ }
2196
+ )
2197
+ ] })
2198
+ ] })
2199
+ ] }),
2200
+ /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
2201
+ /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.coordinates, "aria-label": t3.coordinates, "aria-expanded": menu === "coords", onClick: () => setMenu(menu === "coords" ? null : "coords"), children: /* @__PURE__ */ a3(CrossCursorIcon, {}) }),
2202
+ menu === "coords" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-coords-menu", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: /* @__PURE__ */ a3(DrawingCoords, { ctx, drawing: d3, t: t3 }) })
2203
+ ] }),
2204
+ /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
2205
+ /* @__PURE__ */ a3(
2206
+ "button",
2207
+ {
2208
+ class: style.intervals ? "fnc-btn fnc-btn-on" : "fnc-btn",
2209
+ "data-tip": t3.tabVisibility,
2210
+ "aria-label": t3.tabVisibility,
2211
+ "aria-expanded": menu === "visibility",
2212
+ onClick: () => setMenu(menu === "visibility" ? null : "visibility"),
2213
+ children: /* @__PURE__ */ a3(ClockIcon, {})
2214
+ }
2215
+ ),
2216
+ menu === "visibility" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-visibility-menu", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
2217
+ /* @__PURE__ */ a3("p", { class: "fnc-hint", children: t3.visibilityHint }),
2218
+ /* @__PURE__ */ a3(
2219
+ IntervalVisibilityEditor,
2220
+ {
2221
+ t: t3,
2222
+ value: style.intervals,
2223
+ onChange: (v3) => {
2224
+ const intervals = cleanIntervals(v3);
2225
+ const { intervals: _drop, ...rest } = style;
2226
+ setStyleRaw(intervals ? { ...rest, intervals } : rest);
2227
+ }
2228
+ }
2229
+ )
2230
+ ] })
2231
+ ] }),
1879
2232
  /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": locked ? t3.unlock : t3.lock, "aria-label": locked ? t3.unlock : t3.lock, "aria-pressed": locked, onClick: () => setStyle({ locked: !locked }), children: /* @__PURE__ */ a3(LockIcon, { open: !locked }) }),
1880
2233
  /* @__PURE__ */ a3(
1881
2234
  "button",
@@ -1990,11 +2343,7 @@ function RangeBar({ ctx }) {
1990
2343
  }
1991
2344
 
1992
2345
  // src/components/indicator-dialogs.tsx
1993
- import {
1994
- maLines,
1995
- PRICE_SOURCES,
1996
- SERIES_COLORS
1997
- } from "@funnest/charts";
2346
+ import "@funnest/charts";
1998
2347
 
1999
2348
  // src/components/go-to-date.tsx
2000
2349
  var DAY2 = 864e5;
@@ -2129,6 +2478,364 @@ function GoToDateDialog({ ctx }) {
2129
2478
  ] }) });
2130
2479
  }
2131
2480
 
2481
+ // src/components/indicator-settings.tsx
2482
+ import {
2483
+ maLines,
2484
+ PRICE_SOURCES,
2485
+ resolutionLabel as resolutionLabel2,
2486
+ resolutionToMs,
2487
+ SERIES_COLORS
2488
+ } from "@funnest/charts";
2489
+ var WIDTHS2 = [1, 2, 3, 4];
2490
+ var KINDS = ["line", "step", "area", "histogram", "columns", "circles", "cross"];
2491
+ var STYLES = ["solid", "dashed", "dotted"];
2492
+ var PRECISIONS = [0, 1, 2, 3, 4, 5, 6, 7, 8];
2493
+ var TIMEFRAMES = ["3", "5", "15", "30", "60", "120", "240", "1D", "1W", "1M"];
2494
+ var hex6 = (c3) => /^#[0-9a-f]{6}/i.test(c3) ? c3.slice(0, 7) : "#3182f6";
2495
+ var alphaOf = (c3) => /^#[0-9a-f]{8}$/i.test(c3) ? Math.round(parseInt(c3.slice(7, 9), 16) / 255 * 100) : 100;
2496
+ var withAlpha = (hex, pct) => {
2497
+ const base = hex6(hex);
2498
+ return pct >= 100 ? base : `${base}${Math.round(Math.max(0, pct) / 100 * 255).toString(16).padStart(2, "0")}`;
2499
+ };
2500
+ function ColorField({ value, label, onChange }) {
2501
+ const pct = alphaOf(value);
2502
+ return /* @__PURE__ */ a3("span", { class: "fnc-color-field", children: [
2503
+ /* @__PURE__ */ a3("input", { type: "color", class: "fnc-color", value: hex6(value), "aria-label": label, onInput: (e3) => onChange(withAlpha(e3.currentTarget.value, pct)) }),
2504
+ /* @__PURE__ */ a3(
2505
+ "input",
2506
+ {
2507
+ type: "range",
2508
+ class: "fnc-opacity",
2509
+ min: 0,
2510
+ max: 100,
2511
+ step: 5,
2512
+ value: pct,
2513
+ "aria-label": `${label} %`,
2514
+ title: `${pct}%`,
2515
+ onInput: (e3) => onChange(withAlpha(value, Number(e3.currentTarget.value)))
2516
+ }
2517
+ )
2518
+ ] });
2519
+ }
2520
+ function seriesRows(def, params, styles, lines) {
2521
+ const own = def.compute([], params).series;
2522
+ if (lines) {
2523
+ return lines.map((l3, i3) => {
2524
+ const key = `l${i3}`;
2525
+ const s3 = own[i3];
2526
+ const st = styles?.[key];
2527
+ const color = st?.color ?? s3?.color ?? SERIES_COLORS[i3 % SERIES_COLORS.length];
2528
+ return { key, label: `${l3.period || "?"}`, color, width: st?.width ?? s3?.width ?? 1, visible: st?.visible ?? true, lineStyle: st?.lineStyle ?? s3?.lineStyle ?? "solid", kind: st?.kind ?? "line", ownKind: "line" };
2529
+ });
2530
+ }
2531
+ return own.map((s3) => {
2532
+ const st = styles?.[s3.key];
2533
+ return {
2534
+ key: s3.key,
2535
+ label: s3.label,
2536
+ color: st?.color ?? s3.color,
2537
+ width: st?.width ?? s3.width,
2538
+ visible: st?.visible ?? s3.visible,
2539
+ lineStyle: st?.lineStyle ?? s3.lineStyle ?? "solid",
2540
+ kind: st?.kind ?? s3.kind,
2541
+ ownKind: s3.kind
2542
+ };
2543
+ });
2544
+ }
2545
+ function SourceSelect({ value, locale, label, onChange }) {
2546
+ return /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-source", value, "aria-label": label, onChange: (e3) => onChange(e3.currentTarget.value), children: PRICE_SOURCES.map((s3) => /* @__PURE__ */ a3("option", { value: s3.value, children: s3.label[locale] })) });
2547
+ }
2548
+ function Check({ label, checked, onChange }) {
2549
+ return /* @__PURE__ */ a3("label", { class: "fnc-row fnc-check-row", children: [
2550
+ /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked, onChange: (e3) => onChange(e3.currentTarget.checked) }),
2551
+ /* @__PURE__ */ a3("span", { children: label })
2552
+ ] });
2553
+ }
2554
+ function IndicatorSettings({ ctx, id, Dialog: Dialog2 }) {
2555
+ const { locale, indicators, resolution, customIntervals, symbol } = useStore(ctx.store);
2556
+ const t3 = stringsOf(ctx.store.get());
2557
+ const config = indicators.find((c3) => c3.id === id);
2558
+ const def = config ? ctx.chart.indicatorDefinition(config.type) ?? null : null;
2559
+ const hasLines = !!def?.params.some((p3) => p3.kind === "lines");
2560
+ const onIndicator = !!config?.on;
2561
+ const initLines = (c3, params = c3?.params) => params && hasLines ? maLines(params).map((l3) => ({ period: String(l3.period), source: l3.source })) : [];
2562
+ const [tab, setTab] = d2("inputs");
2563
+ const [lines, setLines] = d2(() => initLines(config));
2564
+ const [values, setValues] = d2(
2565
+ () => Object.fromEntries(Object.entries(config?.params ?? {}).filter(([, v3]) => !Array.isArray(v3)).map(([k2, v3]) => [k2, String(v3)]))
2566
+ );
2567
+ const [rows, setRows] = d2(() => config && def ? seriesRows(def, config.params, config.styles, hasLines ? initLines(config) : null) : []);
2568
+ const [display, setDisplay] = d2(() => ({ ...config?.display ?? {} }));
2569
+ const [timeframe, setTimeframe] = d2(config?.timeframe ?? "");
2570
+ const [waitClose, setWaitClose] = d2(config?.waitClose !== false);
2571
+ const [menu, setMenu] = d2(false);
2572
+ const close = () => ctx.store.set({ dialog: null });
2573
+ if (!config || !def) return null;
2574
+ const probe = def.compute([], config.params);
2575
+ const hasLevels = !!probe.levels?.length;
2576
+ const hasFill = !!probe.fill || !!probe.fills?.length;
2577
+ const chartMs = (() => {
2578
+ try {
2579
+ return resolutionToMs(resolution);
2580
+ } catch {
2581
+ return 0;
2582
+ }
2583
+ })();
2584
+ const supported = symbol?.supportedResolutions;
2585
+ const timeframes = [.../* @__PURE__ */ new Set([...TIMEFRAMES, ...customIntervals])].filter((r3) => {
2586
+ try {
2587
+ return resolutionToMs(r3) > chartMs && (!supported?.length || supported.includes(r3));
2588
+ } catch {
2589
+ return false;
2590
+ }
2591
+ }).sort((a4, b) => resolutionToMs(a4) - resolutionToMs(b));
2592
+ if (timeframe && !timeframes.includes(timeframe)) timeframes.push(timeframe);
2593
+ const patchRow = (i3, p3) => setRows(rows.map((r3, j2) => j2 === i3 ? { ...r3, ...p3 } : r3));
2594
+ const setLinesAndRows = (next) => {
2595
+ setLines(next);
2596
+ setRows(
2597
+ next.map((l3, i3) => {
2598
+ const r3 = rows[i3];
2599
+ return r3 ? { ...r3, label: l3.period || "?" } : { key: `l${i3}`, label: l3.period || "?", color: SERIES_COLORS[i3 % SERIES_COLORS.length], width: 1, visible: true, lineStyle: "solid", kind: "line", ownKind: "line" };
2600
+ })
2601
+ );
2602
+ };
2603
+ const collect = () => {
2604
+ const params = {};
2605
+ for (const spec of def.params) {
2606
+ const clamp = (n2) => Math.min(spec.max ?? Infinity, Math.max(spec.min ?? -Infinity, n2));
2607
+ if (spec.kind === "lines") params[spec.key] = lines.filter((l3) => Number(l3.period) > 0).map((l3) => ({ period: clamp(Math.round(Number(l3.period))), source: l3.source }));
2608
+ else if (spec.kind === "source") params[spec.key] = values[spec.key] ?? "close";
2609
+ else {
2610
+ const n2 = Number(values[spec.key]);
2611
+ if (Number.isFinite(n2)) params[spec.key] = clamp(n2);
2612
+ }
2613
+ }
2614
+ const kept = hasLines ? rows.filter((_3, i3) => Number(lines[i3]?.period) > 0) : rows;
2615
+ const styles = {};
2616
+ kept.forEach((r3, i3) => {
2617
+ const key = hasLines ? `l${i3}` : r3.key;
2618
+ styles[key] = { color: r3.color, width: r3.width, visible: r3.visible, ...r3.lineStyle !== "solid" ? { lineStyle: r3.lineStyle } : {}, ...r3.kind !== r3.ownKind ? { kind: r3.kind } : {} };
2619
+ });
2620
+ const d3 = { ...display };
2621
+ const intervals = cleanIntervals(d3.intervals);
2622
+ if (intervals) d3.intervals = intervals;
2623
+ else delete d3.intervals;
2624
+ for (const k2 of Object.keys(d3)) if (d3[k2] === void 0) delete d3[k2];
2625
+ return { params, styles, display: d3, timeframe, waitClose };
2626
+ };
2627
+ const apply = (e3) => {
2628
+ e3.preventDefault();
2629
+ const c3 = collect();
2630
+ ctx.chart.updateIndicator(id, { params: c3.params, styles: c3.styles, display: c3.display, timeframe: c3.timeframe, waitClose: c3.waitClose });
2631
+ close();
2632
+ };
2633
+ const reset = () => {
2634
+ const params = { ...def.defaults };
2635
+ const l3 = hasLines ? maLines(params).map((x2) => ({ period: String(x2.period), source: x2.source })) : [];
2636
+ setLines(l3);
2637
+ setValues(Object.fromEntries(Object.entries(params).filter(([, v3]) => !Array.isArray(v3)).map(([k2, v3]) => [k2, String(v3)])));
2638
+ setRows(seriesRows(def, params, void 0, hasLines ? l3 : null));
2639
+ setDisplay({});
2640
+ setTimeframe("");
2641
+ setWaitClose(true);
2642
+ setMenu(false);
2643
+ };
2644
+ const saveDefaults = () => {
2645
+ const c3 = collect();
2646
+ ctx.chart.saveIndicatorDefaults(config.type, { params: c3.params, styles: c3.styles, display: c3.display, ...c3.timeframe ? { timeframe: c3.timeframe } : {}, ...c3.waitClose ? {} : { waitClose: false } });
2647
+ setMenu(false);
2648
+ };
2649
+ const hasSaved = !!ctx.chart.indicatorDefaults(config.type);
2650
+ const forgetDefaults = () => {
2651
+ ctx.chart.saveIndicatorDefaults(config.type, null);
2652
+ setMenu(false);
2653
+ };
2654
+ const setD = (p3) => {
2655
+ const next = { ...display, ...p3 };
2656
+ for (const k2 of Object.keys(next)) if (next[k2] === void 0) delete next[k2];
2657
+ setDisplay(next);
2658
+ };
2659
+ const kindLabel = (k2) => ({ line: t3.kindLine, step: t3.kindStep, area: t3.kindArea, histogram: t3.kindHistogram, columns: t3.kindColumns, circles: t3.kindCircles, cross: t3.kindCross })[k2];
2660
+ const styleLabel = (s3) => ({ solid: t3.lineSolid, dashed: t3.lineDashed, dotted: t3.lineDotted })[s3];
2661
+ return /* @__PURE__ */ a3(Dialog2, { title: def.name[locale], onClose: close, wide: true, children: [
2662
+ /* @__PURE__ */ a3("div", { class: "fnc-tabs fnc-settings-tabs", role: "tablist", children: [
2663
+ ["inputs", t3.tabInputs],
2664
+ ["style", t3.tabStyle],
2665
+ ["visibility", t3.tabVisibility]
2666
+ ].map(([k2, label]) => /* @__PURE__ */ a3("button", { type: "button", class: "fnc-tab", role: "tab", "aria-selected": tab === k2, onClick: () => setTab(k2), children: label })) }),
2667
+ /* @__PURE__ */ a3("form", { class: "fnc-form", onSubmit: apply, children: [
2668
+ tab === "inputs" && /* @__PURE__ */ a3($, { children: [
2669
+ hasLines ? /* @__PURE__ */ a3("div", { class: "fnc-rows", children: [
2670
+ lines.map((l3, i3) => /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2671
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label", children: [
2672
+ t3.period,
2673
+ i3 + 1
2674
+ ] }),
2675
+ /* @__PURE__ */ a3(
2676
+ "input",
2677
+ {
2678
+ class: "fnc-input fnc-input-period",
2679
+ inputMode: "numeric",
2680
+ value: l3.period,
2681
+ "aria-label": `${t3.period}${i3 + 1}`,
2682
+ onInput: (e3) => setLinesAndRows(lines.map((x2, j2) => j2 === i3 ? { ...x2, period: e3.currentTarget.value.replace(/\D/g, "") } : x2))
2683
+ }
2684
+ ),
2685
+ !onIndicator && /* @__PURE__ */ a3(SourceSelect, { value: l3.source, locale, label: t3.source, onChange: (source) => setLines(lines.map((x2, j2) => j2 === i3 ? { ...x2, source } : x2)) }),
2686
+ /* @__PURE__ */ a3(
2687
+ "button",
2688
+ {
2689
+ type: "button",
2690
+ class: "fnc-ind-btn",
2691
+ "aria-label": t3.removePeriod,
2692
+ "data-tip": t3.removePeriod,
2693
+ onClick: () => {
2694
+ setLines(lines.filter((_3, j2) => j2 !== i3));
2695
+ setRows(rows.filter((_3, j2) => j2 !== i3));
2696
+ },
2697
+ children: /* @__PURE__ */ a3(SmallCloseIcon, {})
2698
+ }
2699
+ )
2700
+ ] })),
2701
+ /* @__PURE__ */ a3(
2702
+ "button",
2703
+ {
2704
+ type: "button",
2705
+ class: "fnc-add-row",
2706
+ onClick: () => {
2707
+ const last = lines[lines.length - 1];
2708
+ setLinesAndRows([...lines, { period: String(last ? Number(last.period) * 2 || 10 : 5), source: "close" }]);
2709
+ },
2710
+ children: [
2711
+ "+ ",
2712
+ t3.addPeriod
2713
+ ]
2714
+ }
2715
+ )
2716
+ ] }) : def.params.filter((spec) => !(onIndicator && spec.kind === "source")).map((spec) => /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2717
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: spec.label[locale] }),
2718
+ spec.kind === "source" ? /* @__PURE__ */ a3(SourceSelect, { value: values[spec.key] ?? "close", locale, label: spec.label[locale], onChange: (v3) => setValues({ ...values, [spec.key]: v3 }) }) : /* @__PURE__ */ a3("input", { class: "fnc-input", inputMode: "decimal", value: values[spec.key] ?? "", "aria-label": spec.label[locale], onInput: (e3) => setValues({ ...values, [spec.key]: e3.currentTarget.value }) })
2719
+ ] })),
2720
+ /* @__PURE__ */ a3($, { children: [
2721
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.calculation }),
2722
+ /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2723
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.timeframe }),
2724
+ /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-source", value: timeframe, "aria-label": t3.timeframe, onChange: (e3) => setTimeframe(e3.currentTarget.value), children: [
2725
+ /* @__PURE__ */ a3("option", { value: "", children: t3.timeframeChart }),
2726
+ timeframes.map((r3) => /* @__PURE__ */ a3("option", { value: r3, children: resolutionLabel2(r3, locale, "long") }))
2727
+ ] })
2728
+ ] }),
2729
+ /* @__PURE__ */ a3(Check, { label: t3.waitClose, checked: waitClose, onChange: setWaitClose }),
2730
+ timeframe && /* @__PURE__ */ a3("p", { class: "fnc-hint", children: t3.timeframeHint })
2731
+ ] })
2732
+ ] }),
2733
+ tab === "style" && /* @__PURE__ */ a3($, { children: [
2734
+ /* @__PURE__ */ a3("div", { class: "fnc-rows", children: rows.map((r3, i3) => /* @__PURE__ */ a3("div", { class: "fnc-row fnc-style-row", children: [
2735
+ /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked: r3.visible, "aria-label": r3.visible ? t3.hide : t3.show, onChange: (e3) => patchRow(i3, { visible: e3.currentTarget.checked }) }),
2736
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", title: r3.label, children: r3.label }),
2737
+ /* @__PURE__ */ a3(ColorField, { value: /^#[0-9a-f]{6}/i.test(r3.color) ? r3.color : hex6(r3.color), label: t3.color, onChange: (color) => patchRow(i3, { color }) }),
2738
+ /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-width", value: r3.width, "aria-label": t3.lineWidth, onChange: (e3) => patchRow(i3, { width: Number(e3.currentTarget.value) }), children: WIDTHS2.map((w3) => /* @__PURE__ */ a3("option", { value: w3, children: [
2739
+ w3,
2740
+ "px"
2741
+ ] })) }),
2742
+ /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-style", value: r3.lineStyle, "aria-label": t3.lineStyle, onChange: (e3) => patchRow(i3, { lineStyle: e3.currentTarget.value }), children: STYLES.map((s3) => /* @__PURE__ */ a3("option", { value: s3, children: styleLabel(s3) })) }),
2743
+ /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-kind", value: r3.kind, "aria-label": t3.plotType, onChange: (e3) => patchRow(i3, { kind: e3.currentTarget.value }), children: KINDS.map((k2) => /* @__PURE__ */ a3("option", { value: k2, children: kindLabel(k2) })) })
2744
+ ] })) }),
2745
+ (hasLevels || hasFill) && /* @__PURE__ */ a3($, { children: [
2746
+ hasLevels && /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2747
+ /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked: display.levels !== false, "aria-label": t3.indLevels, onChange: (e3) => setD({ levels: e3.currentTarget.checked ? void 0 : false }) }),
2748
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.indLevels }),
2749
+ /* @__PURE__ */ a3(ColorField, { value: display.levelColor ?? "#8b95a1", label: t3.color, onChange: (levelColor) => setD({ levelColor }) })
2750
+ ] }),
2751
+ hasLevels && display.levels !== false && /* @__PURE__ */ a3("div", { class: "fnc-row fnc-level-values", children: [
2752
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.levelValuesLabel }),
2753
+ probe.levels.map((l3, i3) => {
2754
+ const own = typeof l3 === "number" ? l3 : l3.value;
2755
+ const v3 = display.levelValues?.[i3];
2756
+ return /* @__PURE__ */ a3(
2757
+ "input",
2758
+ {
2759
+ class: "fnc-input fnc-input-num",
2760
+ inputMode: "decimal",
2761
+ defaultValue: String(v3 ?? own),
2762
+ "aria-label": `${t3.levelValuesLabel} ${i3 + 1}`,
2763
+ onChange: (e3) => {
2764
+ const n2 = Number(e3.currentTarget.value);
2765
+ const next = probe.levels.map((x2, j2) => display.levelValues?.[j2] ?? (typeof x2 === "number" ? x2 : x2.value));
2766
+ next[i3] = Number.isFinite(n2) ? n2 : own;
2767
+ const same = next.every((x2, j2) => x2 === (typeof probe.levels[j2] === "number" ? probe.levels[j2] : probe.levels[j2].value));
2768
+ setD({ levelValues: same ? void 0 : next });
2769
+ }
2770
+ },
2771
+ `${i3}:${v3 ?? own}`
2772
+ );
2773
+ })
2774
+ ] }),
2775
+ hasFill && /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2776
+ /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked: display.fill !== false, "aria-label": t3.fillBand, onChange: (e3) => setD({ fill: e3.currentTarget.checked ? void 0 : false }) }),
2777
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.fillBand }),
2778
+ /* @__PURE__ */ a3(ColorField, { value: display.fillColor ?? (/^#[0-9a-f]{6}$/i.test(probe.fill?.color ?? "") ? `${probe.fill.color}26` : "#3182f626"), label: t3.color, onChange: (fillColor) => setD({ fillColor }) })
2779
+ ] })
2780
+ ] }),
2781
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.outputValues }),
2782
+ /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2783
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.precision }),
2784
+ /* @__PURE__ */ a3(
2785
+ "select",
2786
+ {
2787
+ class: "fnc-select fnc-select-source",
2788
+ value: display.precision === void 0 ? "" : String(display.precision),
2789
+ "aria-label": t3.precision,
2790
+ onChange: (e3) => setD({ precision: e3.currentTarget.value === "" ? void 0 : Number(e3.currentTarget.value) }),
2791
+ children: [
2792
+ /* @__PURE__ */ a3("option", { value: "", children: t3.precisionDefault }),
2793
+ PRECISIONS.map((n2) => /* @__PURE__ */ a3("option", { value: String(n2), children: n2 === 0 ? "1" : `0.${"0".repeat(n2 - 1)}1` }))
2794
+ ]
2795
+ }
2796
+ )
2797
+ ] }),
2798
+ /* @__PURE__ */ a3(Check, { label: t3.axisLabels, checked: display.axisLabels !== false, onChange: (v3) => setD({ axisLabels: v3 ? void 0 : false }) }),
2799
+ /* @__PURE__ */ a3(Check, { label: t3.statusValues, checked: display.statusValues !== false, onChange: (v3) => setD({ statusValues: v3 ? void 0 : false }) }),
2800
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.inputValues }),
2801
+ /* @__PURE__ */ a3(Check, { label: t3.statusInputs, checked: display.statusInputs !== false, onChange: (v3) => setD({ statusInputs: v3 ? void 0 : false }) })
2802
+ ] }),
2803
+ tab === "visibility" && /* @__PURE__ */ a3($, { children: [
2804
+ /* @__PURE__ */ a3("p", { class: "fnc-hint", children: t3.visibilityHint }),
2805
+ /* @__PURE__ */ a3(IntervalVisibilityEditor, { t: t3, value: display.intervals, onChange: (intervals) => setD({ intervals }) })
2806
+ ] }),
2807
+ /* @__PURE__ */ a3("div", { class: "fnc-form-actions fnc-form-actions-split", children: [
2808
+ /* @__PURE__ */ a3("div", { class: "fnc-defaults", children: [
2809
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-action fnc-action-menu", "aria-haspopup": "menu", "aria-expanded": menu, onClick: () => setMenu(!menu), children: [
2810
+ t3.defaults,
2811
+ " \u25BE"
2812
+ ] }),
2813
+ menu && /* @__PURE__ */ a3("div", { class: "fnc-defaults-menu", role: "menu", children: [
2814
+ /* @__PURE__ */ a3("button", { type: "button", role: "menuitem", onClick: reset, children: t3.resetIndicator }),
2815
+ /* @__PURE__ */ a3("button", { type: "button", role: "menuitem", onClick: saveDefaults, children: t3.saveDefaults }),
2816
+ hasSaved && /* @__PURE__ */ a3("button", { type: "button", role: "menuitem", onClick: forgetDefaults, children: t3.forgetDefaults }),
2817
+ /* @__PURE__ */ a3(
2818
+ "button",
2819
+ {
2820
+ type: "button",
2821
+ role: "menuitem",
2822
+ class: "fnc-danger",
2823
+ onClick: () => {
2824
+ ctx.chart.removeIndicator(id);
2825
+ close();
2826
+ },
2827
+ children: t3.remove
2828
+ }
2829
+ )
2830
+ ] })
2831
+ ] }),
2832
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-action", onClick: close, children: t3.cancel }),
2833
+ /* @__PURE__ */ a3("button", { type: "submit", class: "fnc-action fnc-action-primary", children: t3.ok })
2834
+ ] })
2835
+ ] })
2836
+ ] });
2837
+ }
2838
+
2132
2839
  // src/components/settings-dialog.tsx
2133
2840
  import { CHART_THEMES, DEFAULT_CHART_SETTINGS, matchChartTheme } from "@funnest/charts";
2134
2841
  function toHex(color) {
@@ -2387,197 +3094,17 @@ function IndicatorPicker({ ctx }) {
2387
3094
  ] })
2388
3095
  ] });
2389
3096
  }
2390
- var WIDTHS2 = [1, 2, 3, 4];
2391
- function defaultSeries(def, params) {
2392
- return def.compute([], params).series.filter((s3) => s3.kind === "line");
2393
- }
2394
- function StyleControls({
2395
- t: t3,
2396
- row: row2,
2397
- onChange
2398
- }) {
2399
- return /* @__PURE__ */ a3($, { children: [
2400
- /* @__PURE__ */ a3(
2401
- "input",
2402
- {
2403
- type: "checkbox",
2404
- class: "fnc-check",
2405
- checked: row2.visible,
2406
- "aria-label": row2.visible ? t3.hide : t3.show,
2407
- onChange: (e3) => onChange({ visible: e3.currentTarget.checked })
2408
- }
2409
- ),
2410
- /* @__PURE__ */ a3(
2411
- "input",
2412
- {
2413
- type: "color",
2414
- class: "fnc-color",
2415
- value: row2.color,
2416
- "aria-label": t3.color,
2417
- onInput: (e3) => onChange({ color: e3.currentTarget.value })
2418
- }
2419
- ),
2420
- /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-width", value: row2.width, "aria-label": t3.lineWidth, onChange: (e3) => onChange({ width: Number(e3.currentTarget.value) }), children: WIDTHS2.map((w3) => /* @__PURE__ */ a3("option", { value: w3, children: [
2421
- w3,
2422
- "px"
2423
- ] })) })
2424
- ] });
2425
- }
2426
- function SourceSelect({ value, locale, label, onChange }) {
2427
- return /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-source", value, "aria-label": label, onChange: (e3) => onChange(e3.currentTarget.value), children: PRICE_SOURCES.map((s3) => /* @__PURE__ */ a3("option", { value: s3.value, children: s3.label[locale] })) });
2428
- }
2429
- function IndicatorSettings({ ctx, id }) {
2430
- const { locale, indicators } = useStore(ctx.store);
2431
- const t3 = stringsOf(ctx.store.get());
2432
- const config = indicators.find((c3) => c3.id === id);
2433
- const def = config ? ctx.chart.indicatorDefinition(config.type) ?? null : null;
2434
- const hasLines = !!def?.params.some((p3) => p3.kind === "lines");
2435
- const onIndicator = !!config?.on;
2436
- const [lines, setLines] = d2(() => {
2437
- if (!config || !def || !hasLines) return [];
2438
- const defaults = defaultSeries(def, config.params);
2439
- return maLines(config.params).map((l3, i3) => {
2440
- const style = config.styles?.[`l${i3}`];
2441
- return {
2442
- period: String(l3.period),
2443
- source: l3.source,
2444
- color: style?.color ?? defaults[i3]?.color ?? SERIES_COLORS[i3 % SERIES_COLORS.length],
2445
- width: style?.width ?? defaults[i3]?.width ?? 1,
2446
- visible: style?.visible ?? true
2447
- };
2448
- });
2449
- });
2450
- const [values, setValues] = d2(
2451
- () => Object.fromEntries(Object.entries(config?.params ?? {}).filter(([, v3]) => !Array.isArray(v3)).map(([k2, v3]) => [k2, String(v3)]))
2452
- );
2453
- const [styles, setStyles] = d2(() => {
2454
- if (!config || !def || hasLines) return [];
2455
- return defaultSeries(def, config.params).map((s3) => {
2456
- const style = config.styles?.[s3.key];
2457
- return { key: s3.key, label: s3.label, color: style?.color ?? s3.color, width: style?.width ?? s3.width, visible: style?.visible ?? true };
2458
- });
2459
- });
2460
- const close = () => ctx.store.set({ dialog: null });
2461
- if (!config || !def) return null;
2462
- const updateLine = (i3, patch) => setLines(lines.map((l3, j2) => j2 === i3 ? { ...l3, ...patch } : l3));
2463
- const addLine = () => {
2464
- const i3 = lines.length;
2465
- const last = lines[i3 - 1];
2466
- setLines([
2467
- ...lines,
2468
- {
2469
- period: String(last ? Number(last.period) * 2 || 10 : 5),
2470
- source: "close",
2471
- color: SERIES_COLORS[i3 % SERIES_COLORS.length],
2472
- width: 1,
2473
- visible: true
2474
- }
2475
- ]);
2476
- };
2477
- const apply = (e3) => {
2478
- e3.preventDefault();
2479
- const params = {};
2480
- const nextStyles = {};
2481
- for (const spec of def.params) {
2482
- const clamp = (n2) => Math.min(spec.max ?? Infinity, Math.max(spec.min ?? -Infinity, n2));
2483
- if (spec.kind === "lines") {
2484
- const valid = lines.filter((l3) => Number(l3.period) > 0);
2485
- params[spec.key] = valid.map((l3) => ({ period: clamp(Math.round(Number(l3.period))), source: l3.source }));
2486
- valid.forEach((l3, i3) => nextStyles[`l${i3}`] = { color: l3.color, width: l3.width, visible: l3.visible });
2487
- } else if (spec.kind === "source") {
2488
- params[spec.key] = values[spec.key] ?? "close";
2489
- } else {
2490
- const n2 = Number(values[spec.key]);
2491
- if (Number.isFinite(n2)) params[spec.key] = clamp(n2);
2492
- }
2493
- }
2494
- for (const s3 of styles) nextStyles[s3.key] = { color: s3.color, width: s3.width, visible: s3.visible };
2495
- ctx.chart.updateIndicator(id, { params, styles: nextStyles });
2496
- close();
2497
- };
2498
- return /* @__PURE__ */ a3(Dialog, { title: `${def.name[locale]} \xB7 ${t3.indicatorSettings}`, onClose: close, wide: true, children: /* @__PURE__ */ a3("form", { class: "fnc-form", onSubmit: apply, children: [
2499
- hasLines ? /* @__PURE__ */ a3("div", { class: "fnc-rows", children: [
2500
- lines.map((l3, i3) => /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2501
- /* @__PURE__ */ a3("span", { class: "fnc-row-label", children: [
2502
- t3.period,
2503
- i3 + 1
2504
- ] }),
2505
- /* @__PURE__ */ a3(StyleControls, { t: t3, row: l3, onChange: (p3) => updateLine(i3, p3) }),
2506
- !onIndicator && /* @__PURE__ */ a3(SourceSelect, { value: l3.source, locale, label: t3.source, onChange: (source) => updateLine(i3, { source }) }),
2507
- /* @__PURE__ */ a3(
2508
- "input",
2509
- {
2510
- class: "fnc-input fnc-input-period",
2511
- inputMode: "numeric",
2512
- value: l3.period,
2513
- "aria-label": `${t3.period}${i3 + 1}`,
2514
- onInput: (e3) => updateLine(i3, { period: e3.currentTarget.value.replace(/\D/g, "") })
2515
- }
2516
- ),
2517
- /* @__PURE__ */ a3("button", { type: "button", class: "fnc-ind-btn", "aria-label": t3.removePeriod, "data-tip": t3.removePeriod, onClick: () => setLines(lines.filter((_3, j2) => j2 !== i3)), children: /* @__PURE__ */ a3(SmallCloseIcon, {}) })
2518
- ] })),
2519
- /* @__PURE__ */ a3("button", { type: "button", class: "fnc-add-row", onClick: addLine, children: [
2520
- "+ ",
2521
- t3.addPeriod
2522
- ] })
2523
- ] }) : /* @__PURE__ */ a3($, { children: [
2524
- /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.inputs }),
2525
- def.params.filter((spec) => !(onIndicator && spec.kind === "source")).map((spec) => /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2526
- /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: spec.label[locale] }),
2527
- spec.kind === "source" ? /* @__PURE__ */ a3(
2528
- SourceSelect,
2529
- {
2530
- value: values[spec.key] ?? "close",
2531
- locale,
2532
- label: spec.label[locale],
2533
- onChange: (v3) => setValues({ ...values, [spec.key]: v3 })
2534
- }
2535
- ) : /* @__PURE__ */ a3(
2536
- "input",
2537
- {
2538
- class: "fnc-input",
2539
- inputMode: "decimal",
2540
- value: values[spec.key] ?? "",
2541
- "aria-label": spec.label[locale],
2542
- onInput: (e3) => setValues({ ...values, [spec.key]: e3.currentTarget.value })
2543
- }
2544
- )
2545
- ] })),
2546
- styles.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.style }),
2547
- styles.map((row2, i3) => /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2548
- /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: row2.label }),
2549
- /* @__PURE__ */ a3(StyleControls, { t: t3, row: row2, onChange: (p3) => setStyles(styles.map((s3, j2) => j2 === i3 ? { ...s3, ...p3 } : s3)) })
2550
- ] }))
2551
- ] }),
2552
- /* @__PURE__ */ a3("div", { class: "fnc-form-actions", children: [
2553
- /* @__PURE__ */ a3(
2554
- "button",
2555
- {
2556
- type: "button",
2557
- class: "fnc-action fnc-action-danger",
2558
- onClick: () => {
2559
- ctx.chart.removeIndicator(id);
2560
- close();
2561
- },
2562
- children: t3.remove
2563
- }
2564
- ),
2565
- /* @__PURE__ */ a3("button", { type: "button", class: "fnc-action", onClick: close, children: t3.cancel }),
2566
- /* @__PURE__ */ a3("button", { type: "submit", class: "fnc-action fnc-action-primary", children: t3.apply })
2567
- ] })
2568
- ] }) });
2569
- }
2570
3097
  function Dialogs({ ctx }) {
2571
3098
  const { dialog } = useStore(ctx.store);
2572
3099
  if (dialog?.kind === "indicators") return dialog.on ? /* @__PURE__ */ a3(IndicatorOnPicker, { ctx, on: dialog.on }) : /* @__PURE__ */ a3(IndicatorPicker, { ctx });
2573
- if (dialog?.kind === "indicatorSettings") return /* @__PURE__ */ a3(IndicatorSettings, { ctx, id: dialog.id });
3100
+ if (dialog?.kind === "indicatorSettings") return /* @__PURE__ */ a3(IndicatorSettings, { ctx, id: dialog.id, Dialog }, dialog.id);
2574
3101
  if (dialog?.kind === "chartSettings") return /* @__PURE__ */ a3(SettingsDialog, { ctx });
2575
3102
  if (dialog?.kind === "goToDate") return /* @__PURE__ */ a3(GoToDateDialog, { ctx });
2576
3103
  return null;
2577
3104
  }
2578
3105
 
2579
3106
  // src/components/interval-picker.tsx
2580
- import { derivedBase as derivedBase2, resolutionToMs } from "@funnest/charts";
3107
+ import { derivedBase as derivedBase2, resolutionToMs as resolutionToMs2 } from "@funnest/charts";
2581
3108
 
2582
3109
  // src/components/keep-in-view.ts
2583
3110
  var MARGIN = 8;
@@ -2644,7 +3171,7 @@ function IntervalPicker({ ctx }) {
2644
3171
  const supported = s3.symbol?.supportedResolutions;
2645
3172
  const isSupported = (r3) => !supported || supported.includes(r3) || !!derivedBase2(r3, supported);
2646
3173
  const listed = new Set(ctx.intervalGroups.flatMap((g3) => g3.intervals));
2647
- const custom = s3.customIntervals.filter((r3) => !listed.has(r3)).sort((a4, b) => resolutionToMs(a4) - resolutionToMs(b));
3174
+ const custom = s3.customIntervals.filter((r3) => !listed.has(r3)).sort((a4, b) => resolutionToMs2(a4) - resolutionToMs2(b));
2648
3175
  const order = [...ctx.intervalGroups.flatMap((g3) => g3.intervals), ...custom];
2649
3176
  const [amount, setAmount] = d2("2");
2650
3177
  const [unit, setUnit] = d2(1);
@@ -2656,7 +3183,7 @@ function IntervalPicker({ ctx }) {
2656
3183
  select(r3);
2657
3184
  };
2658
3185
  const favorites = s3.favoriteIntervals;
2659
- const byTime = (a4, b) => order.includes(a4) && order.includes(b) ? order.indexOf(a4) - order.indexOf(b) : resolutionToMs(a4) - resolutionToMs(b);
3186
+ const byTime = (a4, b) => order.includes(a4) && order.includes(b) ? order.indexOf(a4) - order.indexOf(b) : resolutionToMs2(a4) - resolutionToMs2(b);
2660
3187
  const chips = [.../* @__PURE__ */ new Set([...favorites, ...s3.resolution ? [s3.resolution] : []])].sort(byTime);
2661
3188
  const select = (r3) => {
2662
3189
  setOpen(false);
@@ -3648,7 +4175,7 @@ function IndicatorItem({ ctx, item }) {
3648
4175
  return /* @__PURE__ */ a3(
3649
4176
  "div",
3650
4177
  {
3651
- class: item.visible ? "fnc-ind" : "fnc-ind fnc-ind-hidden",
4178
+ class: item.visible && !item.offInterval ? "fnc-ind" : "fnc-ind fnc-ind-hidden",
3652
4179
  role: "button",
3653
4180
  tabIndex: 0,
3654
4181
  "aria-label": `${item.title} ${t3.indicatorSettings}`,
@@ -4938,6 +5465,68 @@ var CSS = (
4938
5465
  .fnc-input-period { flex: 0 0 72px; text-align: right; }
4939
5466
  .fnc-select-width { flex: 0 0 72px; }
4940
5467
  .fnc-select-source { flex: 1; }
5468
+ .fnc-select-style { flex: 0 0 76px; }
5469
+ .fnc-select-kind { flex: 1; min-width: 88px; }
5470
+ .fnc-settings-tabs { padding: 8px 16px; }
5471
+ .fnc-style-row .fnc-row-label-wide { overflow: hidden; text-overflow: ellipsis; }
5472
+ .fnc-check-row { gap: 10px; min-height: 34px; font-size: 14px; color: var(--fnc-text); cursor: pointer; }
5473
+ .fnc-hint { margin: 0; font-size: 12px; line-height: 1.5; color: var(--fnc-text-2); }
5474
+ .fnc-vis .fnc-row { min-height: 40px; }
5475
+ .fnc-vis-unit { display: flex; align-items: center; gap: 10px; width: 96px; flex: none; font-size: 14px; color: var(--fnc-text); cursor: pointer; }
5476
+ .fnc-input-num { flex: 0 0 72px; text-align: right; }
5477
+ .fnc-input-num:disabled { opacity: 0.4; }
5478
+ .fnc-vis-dash { color: var(--fnc-text-2); }
5479
+ .fnc-coords-menu, .fnc-visibility-menu { padding: 10px 12px; min-width: 300px; }
5480
+ .fnc-visibility-menu .fnc-hint { margin-bottom: 6px; max-width: 320px; }
5481
+ .fnc-visibility-menu .fnc-row { min-height: 34px; }
5482
+ .fnc-visibility-menu .fnc-input-num { height: 30px; flex-basis: 56px; font-size: 13px; }
5483
+ .fnc-coords { display: flex; flex-direction: column; gap: 8px; }
5484
+ .fnc-coord-row { display: flex; align-items: center; gap: 6px; }
5485
+ .fnc-coord-name { width: 40px; flex: none; font-size: 12px; color: var(--fnc-text-2); }
5486
+ .fnc-coord-price { flex: 0 0 110px; height: 32px; font-size: 13px; }
5487
+ .fnc-coord-time { flex: 0 0 180px; height: 32px; font-size: 13px; }
5488
+ .fnc-btn-on { color: var(--fnc-accent); }
5489
+ .fnc-color-field { display: flex; align-items: center; gap: 6px; flex: none; }
5490
+ .fnc-opacity { width: 64px; accent-color: var(--fnc-accent); }
5491
+ .fnc-level-values { flex-wrap: wrap; row-gap: 6px; }
5492
+ .fnc-level-values .fnc-input-num { flex: 0 0 64px; height: 34px; font-size: 14px; }
5493
+ .fnc-note-menu { padding: 10px 12px; width: 300px; display: flex; flex-direction: column; gap: 8px; }
5494
+ .fnc-note-menu textarea {
5495
+ min-height: 64px;
5496
+ padding: 8px 10px;
5497
+ border: 1px solid var(--fnc-border);
5498
+ border-radius: var(--fnc-radius);
5499
+ background: var(--fnc-bg);
5500
+ color: var(--fnc-text);
5501
+ font: inherit;
5502
+ font-size: 14px;
5503
+ resize: vertical;
5504
+ outline: none;
5505
+ }
5506
+ .fnc-note-menu textarea:focus { border-color: var(--fnc-accent); }
5507
+ .fnc-note-row { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fnc-text-2); }
5508
+ .fnc-note-row .fnc-select { height: 32px; font-size: 13px; flex: 1; }
5509
+ .fnc-note-toggle { height: 32px; min-width: 36px; padding: 0 8px; border: 1px solid var(--fnc-border); border-radius: 6px; font-size: 13px; color: var(--fnc-text); }
5510
+ .fnc-note-toggle[aria-pressed='true'] { background: var(--fnc-text); color: var(--fnc-bg); border-color: var(--fnc-text); }
5511
+ .fnc-form-actions-split .fnc-defaults { position: relative; flex: 1; display: flex; }
5512
+ .fnc-form-actions-split .fnc-defaults > .fnc-action { flex: 1; }
5513
+ .fnc-defaults-menu {
5514
+ position: absolute;
5515
+ left: 0;
5516
+ bottom: calc(100% + 6px);
5517
+ min-width: 200px;
5518
+ display: flex;
5519
+ flex-direction: column;
5520
+ padding: 6px;
5521
+ border: 1px solid var(--fnc-border);
5522
+ border-radius: var(--fnc-radius);
5523
+ background: var(--fnc-bg);
5524
+ box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
5525
+ z-index: 2;
5526
+ }
5527
+ .fnc-defaults-menu button { height: 38px; padding: 0 12px; border-radius: 6px; text-align: left; font-size: 14px; color: var(--fnc-text); }
5528
+ .fnc-defaults-menu button:hover { background: var(--fnc-surface); }
5529
+ .fnc-defaults-menu .fnc-danger { color: var(--fnc-down, #f04452); }
4941
5530
  .fnc-toggle-row { justify-content: space-between; min-height: 36px; cursor: pointer; font-size: 14px; }
4942
5531
  .fnc-switch {
4943
5532
  appearance: none;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
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.9.4"
45
+ "@funnest/charts": "0.10.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"