@funnest/charts-ui 0.10.1 → 0.10.2

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/i18n.d.ts CHANGED
@@ -200,6 +200,8 @@ export declare const STRINGS: {
200
200
  saveDefaults: string;
201
201
  forgetDefaults: string;
202
202
  ok: string;
203
+ moreToolsUp: string;
204
+ moreToolsDown: string;
203
205
  lockView: string;
204
206
  unlockView: string;
205
207
  lockRatio: string;
@@ -487,6 +489,8 @@ export declare const STRINGS: {
487
489
  saveDefaults: string;
488
490
  forgetDefaults: string;
489
491
  ok: string;
492
+ moreToolsUp: string;
493
+ moreToolsDown: string;
490
494
  lockView: string;
491
495
  unlockView: string;
492
496
  lockRatio: string;
package/dist/index.js CHANGED
@@ -629,6 +629,8 @@ var STRINGS = {
629
629
  saveDefaults: "\uAE30\uBCF8\uAC12\uC73C\uB85C \uC800\uC7A5",
630
630
  forgetDefaults: "\uC800\uC7A5\uD55C \uAE30\uBCF8\uAC12 \uC9C0\uC6B0\uAE30",
631
631
  ok: "\uD655\uC778",
632
+ moreToolsUp: "\uC704 \uB3C4\uAD6C \uB354 \uBCF4\uAE30",
633
+ moreToolsDown: "\uC544\uB798 \uB3C4\uAD6C \uB354 \uBCF4\uAE30",
632
634
  lockView: "\uCC28\uD2B8 \uACE0\uC815",
633
635
  unlockView: "\uCC28\uD2B8 \uACE0\uC815 \uD480\uAE30",
634
636
  lockRatio: "\uAC00\uACA9 \uCD95 \uBE44\uC728 \uACE0\uC815",
@@ -918,6 +920,8 @@ var STRINGS = {
918
920
  saveDefaults: "Save as default",
919
921
  forgetDefaults: "Forget saved default",
920
922
  ok: "Ok",
923
+ moreToolsUp: "More tools above",
924
+ moreToolsDown: "More tools below",
921
925
  lockView: "Lock chart",
922
926
  unlockView: "Unlock chart",
923
927
  lockRatio: "Lock price to bar ratio",
@@ -1512,20 +1516,31 @@ function DrawingToolbar({ ctx }) {
1512
1516
  const t3 = stringsOf(s3);
1513
1517
  const [openGroup, setOpenGroup] = d2(null);
1514
1518
  const barRef = T2(null);
1519
+ const [more, setMore] = d2({ up: false, down: false });
1520
+ const checkMore = () => {
1521
+ const el = barRef.current;
1522
+ if (!el) return;
1523
+ const scrolls = el.dataset.fit === "scroll";
1524
+ const next = { up: scrolls && el.scrollTop > 2, down: scrolls && el.scrollTop + el.clientHeight < el.scrollHeight - 2 };
1525
+ setMore((m3) => m3.up === next.up && m3.down === next.down ? m3 : next);
1526
+ };
1515
1527
  F2(() => {
1516
1528
  const el = barRef.current;
1517
1529
  if (!el) return;
1518
1530
  const fit2 = () => {
1519
1531
  el.removeAttribute("data-fit");
1520
- if (el.scrollHeight <= el.clientHeight) return;
1521
- el.dataset.fit = "compact";
1522
- if (el.scrollHeight > el.clientHeight) el.dataset.fit = "scroll";
1532
+ if (el.scrollHeight > el.clientHeight) {
1533
+ el.dataset.fit = "compact";
1534
+ if (el.scrollHeight > el.clientHeight) el.dataset.fit = "scroll";
1535
+ }
1536
+ checkMore();
1523
1537
  };
1524
1538
  fit2();
1525
1539
  const ro = new ResizeObserver(fit2);
1526
1540
  ro.observe(el);
1527
1541
  return () => ro.disconnect();
1528
1542
  }, []);
1543
+ const scrollBar = (by) => barRef.current?.scrollBy({ top: by, behavior: "smooth" });
1529
1544
  const defs = ctx.chart.drawingDefinitions();
1530
1545
  const groups = toolGroups(defs);
1531
1546
  const favorites = s3.favoriteTools.map((type) => defs.find((d3) => d3.type === type)).filter((d3) => !!d3);
@@ -1547,7 +1562,9 @@ function DrawingToolbar({ ctx }) {
1547
1562
  "aria-orientation": "vertical",
1548
1563
  "data-open": s3.drawbarOpen,
1549
1564
  "data-collapsed": s3.drawbarCollapsed,
1565
+ onScroll: checkMore,
1550
1566
  children: [
1567
+ more.up && /* @__PURE__ */ a3("button", { class: "fnc-drawbar-more is-up", "aria-label": t3.moreToolsUp, onClick: () => scrollBar(-160), children: /* @__PURE__ */ a3(ChevronUpIcon, {}) }),
1551
1568
  /* @__PURE__ */ a3(CursorGroup, { ctx, open: openGroup === "__cursor", onOpen: (open) => setOpenGroup(open ? "__cursor" : null), onPick: () => pick(null) }),
1552
1569
  favorites.length > 0 && /* @__PURE__ */ a3($, { children: [
1553
1570
  favorites.map((def) => /* @__PURE__ */ a3(
@@ -1633,7 +1650,8 @@ function DrawingToolbar({ ctx }) {
1633
1650
  onClick: () => ctx.setDrawbarCollapsed(true),
1634
1651
  children: /* @__PURE__ */ a3(ChevronLeftIcon, {})
1635
1652
  }
1636
- )
1653
+ ),
1654
+ more.down && /* @__PURE__ */ a3("button", { class: "fnc-drawbar-more is-down", "aria-label": t3.moreToolsDown, onClick: () => scrollBar(160), children: /* @__PURE__ */ a3(ChevronDownIcon, {}) })
1637
1655
  ]
1638
1656
  }
1639
1657
  )
@@ -4180,7 +4198,7 @@ function PriceAxisPlus({ ctx }) {
4180
4198
  var ZOOM_STEP = 1.25;
4181
4199
  var CONTROL_OFFSET = 52;
4182
4200
  var dirClass = (v3) => v3 > 0 ? "fnc-up" : v3 < 0 ? "fnc-down" : "fnc-flat";
4183
- function IndicatorItem({ ctx, item }) {
4201
+ function IndicatorItem({ ctx, item, values = true }) {
4184
4202
  const t3 = stringsOf(ctx.store.get());
4185
4203
  return /* @__PURE__ */ a3(
4186
4204
  "div",
@@ -4210,7 +4228,7 @@ function IndicatorItem({ ctx, item }) {
4210
4228
  }
4211
4229
  ),
4212
4230
  /* @__PURE__ */ a3("span", { class: "fnc-ind-title", children: item.title }),
4213
- item.visible && item.values.map((v3) => /* @__PURE__ */ a3("b", { style: { color: v3.color }, "data-tip": v3.label, children: v3.value })),
4231
+ values && item.visible && item.values.map((v3) => /* @__PURE__ */ a3("b", { style: { color: v3.color }, "data-tip": v3.label, children: v3.value })),
4214
4232
  /* @__PURE__ */ a3("span", { class: "fnc-ind-actions", children: [
4215
4233
  ctx.chart.canMoveIndicator(item.id, -1) && /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.moveIndicatorUp, "aria-label": `${item.title} ${t3.moveIndicatorUp}`, onClick: (e3) => {
4216
4234
  e3.stopPropagation();
@@ -4320,10 +4338,13 @@ function Legend({ ctx }) {
4320
4338
  return () => offs.forEach((off) => off());
4321
4339
  }, [ctx.chart]);
4322
4340
  const ref = T2(null);
4341
+ const tracking = T2(false);
4342
+ tracking.current = ctx.legendValues === "crosshair" && !!hover;
4323
4343
  A2(() => {
4324
4344
  const el = ref.current;
4325
4345
  if (!el) return;
4326
4346
  const update = () => {
4347
+ if (tracking.current) return;
4327
4348
  const floating = ctx.legendValues === "crosshair" ? el.querySelector(".fnc-legend-values") : null;
4328
4349
  ctx.chart.setTopInset(el.offsetTop + el.offsetHeight - (floating ? floating.offsetHeight + 2 : 0) + 4);
4329
4350
  };
@@ -4379,11 +4400,12 @@ function Legend({ ctx }) {
4379
4400
  ] });
4380
4401
  }
4381
4402
  const items = s3.indicators.length ? ctx.chart.indicatorLegend(hover?.index) : [];
4403
+ const showValues = ctx.legendValues === "always" || !!hover;
4382
4404
  const overlayItems = items.filter((i3) => i3.overlay);
4383
4405
  const paneLegends = s3.layout.panes.filter((p3) => p3.kind === "indicator").map((pane) => ({ pane, item: items.find((i3) => i3.id === pane.id), kids: items.filter((i3) => i3.parent === pane.id) }));
4384
4406
  const volumePane = s3.layout.panes.find((p3) => p3.kind === "volume");
4385
4407
  return /* @__PURE__ */ a3($, { children: [
4386
- /* @__PURE__ */ a3("div", { class: "fnc-legend", ref, children: [
4408
+ /* @__PURE__ */ a3("div", { class: tracking.current ? "fnc-legend is-tracking" : "fnc-legend", ref, children: [
4387
4409
  /* @__PURE__ */ a3("div", { class: "fnc-legend-title", children: [
4388
4410
  ctx.showLogo && /* @__PURE__ */ a3(SymbolAvatar, { info: s3.symbol, size: 18 }),
4389
4411
  /* @__PURE__ */ a3("b", { children: s3.symbol.name }),
@@ -4409,15 +4431,15 @@ function Legend({ ctx }) {
4409
4431
  }
4410
4432
  )
4411
4433
  ] })),
4412
- !collapsed && overlayItems.map((item) => /* @__PURE__ */ a3(IndicatorItem, { ctx, item })),
4434
+ !collapsed && overlayItems.map((item) => /* @__PURE__ */ a3(IndicatorItem, { ctx, item, values: showValues })),
4413
4435
  !collapsed && s3.legendItems.map((item) => /* @__PURE__ */ a3(AppItem, { ctx, item })),
4414
4436
  overlayItems.length + s3.legendItems.length > 0 && (collapsed ? /* @__PURE__ */ a3("button", { class: "fnc-ind-handle", "aria-expanded": "false", "aria-label": t3.expand, "data-tip": t3.expand, onClick: () => setCollapsed(false), children: /* @__PURE__ */ a3("span", {}) }) : /* @__PURE__ */ a3("button", { class: "fnc-ind-collapse", "aria-expanded": "true", "aria-label": t3.collapse, "data-tip": t3.collapse, onClick: () => setCollapsed(true), children: /* @__PURE__ */ a3(ChevronUpIcon, {}) }))
4415
4437
  ] }),
4416
4438
  volumePane && /* @__PURE__ */ a3("div", { class: "fnc-legend fnc-pane-legend", style: { top: `${volumePane.top + 4}px` }, children: /* @__PURE__ */ a3(VolumeItem, { ctx, value: bar?.volume !== void 0 ? formatCompact(bar.volume, s3.locale) : null }) }),
4417
4439
  paneLegends.map(
4418
- ({ pane, item, kids }) => item && /* @__PURE__ */ a3("div", { class: "fnc-legend fnc-pane-legend", style: { top: `${pane.top + 4}px` }, children: [
4419
- /* @__PURE__ */ a3(IndicatorItem, { ctx, item }),
4420
- kids.map((kid) => /* @__PURE__ */ a3(IndicatorItem, { ctx, item: kid }))
4440
+ ({ pane, item, kids }) => item && /* @__PURE__ */ a3("div", { class: tracking.current ? "fnc-legend fnc-pane-legend is-tracking" : "fnc-legend fnc-pane-legend", style: { top: `${pane.top + 4}px` }, children: [
4441
+ /* @__PURE__ */ a3(IndicatorItem, { ctx, item, values: showValues }),
4442
+ kids.map((kid) => /* @__PURE__ */ a3(IndicatorItem, { ctx, item: kid, values: showValues }))
4421
4443
  ] })
4422
4444
  )
4423
4445
  ] });
@@ -4866,6 +4888,22 @@ var CSS = (
4866
4888
  .fnc-drawbar[data-fit] .fnc-hsep { margin: 2px 0; }
4867
4889
  .fnc-drawbar[data-fit='scroll'] { overflow-y: auto; scrollbar-width: none; }
4868
4890
  .fnc-drawbar[data-fit='scroll']::-webkit-scrollbar { display: none; }
4891
+ /* More tools that way: a strip stuck to the bar's top / bottom edge, fading the tools under it. */
4892
+ .fnc-drawbar-more {
4893
+ position: sticky;
4894
+ z-index: 1;
4895
+ flex: none;
4896
+ display: grid;
4897
+ place-items: center;
4898
+ width: 100%;
4899
+ height: 24px;
4900
+ margin: -4px 0;
4901
+ color: var(--fnc-text-2);
4902
+ background: var(--fnc-bg);
4903
+ }
4904
+ .fnc-drawbar-more.is-up { top: -4px; box-shadow: 0 6px 8px -4px var(--fnc-bg); }
4905
+ .fnc-drawbar-more.is-down { bottom: -4px; box-shadow: 0 -6px 8px -4px var(--fnc-bg); }
4906
+ .fnc-drawbar-more:hover { color: var(--fnc-text); }
4869
4907
 
4870
4908
  /* Selected drawing: floating color/delete bar */
4871
4909
  .fnc-selbar {
@@ -4935,6 +4973,14 @@ var CSS = (
4935
4973
  border-radius: 6px;
4936
4974
  background: color-mix(in srgb, var(--fnc-bg) 88%, transparent);
4937
4975
  }
4976
+ /* \u2026and the indicator rows' values with it: each row gets the same backing while they show. */
4977
+ .fnc-legend.is-tracking .fnc-ind {
4978
+ width: fit-content;
4979
+ margin-left: -4px;
4980
+ padding: 0 4px;
4981
+ border-radius: 6px;
4982
+ background: color-mix(in srgb, var(--fnc-bg) 88%, transparent);
4983
+ }
4938
4984
  /* Indicator legend rows */
4939
4985
  .fnc-ind {
4940
4986
  display: flex;
@@ -5511,8 +5557,13 @@ var CSS = (
5511
5557
  .fnc-coords { display: flex; flex-direction: column; gap: 8px; }
5512
5558
  .fnc-coord-row { display: flex; align-items: center; gap: 6px; }
5513
5559
  .fnc-coord-name { width: 40px; flex: none; font-size: 12px; color: var(--fnc-text-2); }
5514
- .fnc-coord-price { flex: 0 0 110px; height: 32px; font-size: 13px; }
5515
- .fnc-coord-time { flex: 0 0 180px; height: 32px; font-size: 13px; }
5560
+ .fnc-coord-price { flex: 1 1 96px; min-width: 0; height: 32px; font-size: 13px; }
5561
+ .fnc-coord-time { flex: 1.6 1 150px; min-width: 0; height: 32px; font-size: 13px; }
5562
+ /* Narrow phones: the time goes under the price (a date-time field needs the width). */
5563
+ @media (max-width: 400px) {
5564
+ .fnc-coord-row { flex-wrap: wrap; row-gap: 4px; }
5565
+ .fnc-coord-time { flex: 1 1 100%; margin-left: 46px; }
5566
+ }
5516
5567
  .fnc-btn-on { color: var(--fnc-accent); }
5517
5568
  /* \uCC28\uD2B8 \uACE0\uC815: the bar shows just the lock, always (not only on hover). */
5518
5569
  .fnc-nav.fnc-nav-locked { opacity: 1; display: flex; }
@@ -5931,7 +5982,53 @@ var CSS = (
5931
5982
  .fnc-ind-search { height: 48px; padding: 0 16px; }
5932
5983
  .fnc-ind-search input { font-size: 15px; }
5933
5984
 
5985
+ /* Touch: the legend's small buttons and the \xD7s in lists are hard to hit with a finger \u2014 a larger
5986
+ invisible area around each (they look the same); the period chips grow a little. */
5987
+ @media (pointer: coarse) {
5988
+ .fnc-ind-btn, .fnc-ind-collapse { position: relative; }
5989
+ .fnc-ind-btn::after, .fnc-ind-collapse::after { content: ''; position: absolute; inset: -6px; }
5990
+ .fnc-ranges { height: 40px; }
5991
+ .fnc-range { height: 32px; }
5992
+ }
5993
+
5934
5994
  /* \u2500\u2500 Mobile \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
5995
+ /* A phone turned sideways (short, touch): the tool bar slides in from the pencil instead of
5996
+ taking the chart's width all the time. */
5997
+ @media (max-height: 500px) and (pointer: coarse) {
5998
+ .fnc-btn-drawbar { display: flex; }
5999
+ .fnc-drawbar-tab, .fnc-drawbar-collapse { display: none; }
6000
+ .fnc-drawbar[data-collapsed='true'] { display: flex; }
6001
+ .fnc-drawbar-host { position: absolute; left: 0; top: 0; bottom: 0; z-index: 5; pointer-events: none; }
6002
+ .fnc-drawbar {
6003
+ pointer-events: auto;
6004
+ transform: translateX(-100%);
6005
+ transition: transform 0.18s ease;
6006
+ box-shadow: 4px 0 16px rgb(0 0 0 / 0.08);
6007
+ }
6008
+ .fnc-drawbar[data-open='true'] { transform: none; }
6009
+ .fnc-selbar-menu { position: static; }
6010
+ .fnc-selbar-pop {
6011
+ left: 0;
6012
+ right: 0;
6013
+ transform: none;
6014
+ min-width: 0;
6015
+ /* Ends above the period bar under the chart. */
6016
+ max-height: max(120px, calc(100dvh - 210px));
6017
+ overflow-y: auto;
6018
+ z-index: 30;
6019
+ }
6020
+ .fnc-levels-list { max-height: none; }
6021
+ /* Thin indicator panes: their legend stays on one line (not over the pane below). */
6022
+ .fnc-pane-legend .fnc-ind { flex-wrap: nowrap; white-space: nowrap; }
6023
+ .fnc-backdrop { padding: 0; align-items: stretch; }
6024
+ .fnc-dialog { max-height: none; height: 100%; border-radius: 0; }
6025
+ .fnc-dialog-head { height: 44px; }
6026
+ .fnc-settings-tabs { padding: 4px 16px; }
6027
+ .fnc-form { padding: 12px 16px; gap: 10px; }
6028
+ .fnc-form-actions { bottom: -12px; margin: 4px -16px -12px; padding: 8px 16px; }
6029
+ .fnc-action { height: 40px; }
6030
+ }
6031
+
5935
6032
  @media (max-width: 640px) {
5936
6033
  .fnc-toolbar { padding: 0 4px; gap: 2px; }
5937
6034
  .fnc-toolbar .fnc-btn { width: 32px; height: 32px; }
@@ -5957,7 +6054,30 @@ var CSS = (
5957
6054
  box-shadow: 4px 0 16px rgb(0 0 0 / 0.08);
5958
6055
  }
5959
6056
  .fnc-drawbar[data-open='true'] { transform: none; }
5960
- .fnc-selbar { top: auto; bottom: 56px; }
6057
+ /* The selected drawing's bar: the width of the chart, at its bottom, in as many rows as it takes;
6058
+ its menus open upward over the chart, as wide as the bar. */
6059
+ .fnc-selbar {
6060
+ top: auto !important;
6061
+ bottom: 56px;
6062
+ left: 8px !important;
6063
+ right: 8px;
6064
+ transform: none;
6065
+ flex-wrap: wrap;
6066
+ justify-content: center;
6067
+ row-gap: 4px;
6068
+ }
6069
+ .fnc-selbar-grip { display: none; }
6070
+ .fnc-selbar-menu { position: static; }
6071
+ .fnc-selbar-pop {
6072
+ top: auto;
6073
+ bottom: calc(100% + 6px);
6074
+ left: 0;
6075
+ right: 0;
6076
+ transform: none;
6077
+ min-width: 0;
6078
+ max-height: 55vh;
6079
+ overflow-y: auto;
6080
+ }
5961
6081
  .fnc-legend { left: 10px; right: 64px; }
5962
6082
  .fnc-backdrop { padding: 0; align-items: stretch; }
5963
6083
  .fnc-dialog { width: 100%; max-height: none; border-radius: 0; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
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.10.1"
45
+ "@funnest/charts": "0.10.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"