@funnest/charts-ui 0.11.62 → 0.11.63

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.
Files changed (2) hide show
  1. package/dist/index.js +46 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -3276,12 +3276,14 @@ var CSS = (
3276
3276
  bottom: 56px;
3277
3277
  left: 8px !important;
3278
3278
  right: 8px;
3279
- transform: none;
3279
+ /* Docked: its grip (first, on the left) lifts it up the chart and back. */
3280
+ --fnc-selbar-dock: bottom;
3281
+ transform: translateY(calc(-1 * var(--fnc-selbar-lift, 0px)));
3280
3282
  flex-wrap: wrap;
3281
3283
  justify-content: center;
3282
3284
  row-gap: 4px;
3283
3285
  }
3284
- .fnc-selbar-grip { display: none; }
3286
+ .fnc-selbar-grip { width: 24px !important; }
3285
3287
  .fnc-selbar-menu { position: static; }
3286
3288
  .fnc-selbar-pop {
3287
3289
  top: auto;
@@ -4478,6 +4480,7 @@ var WIDTHS = [1, 2, 3, 4];
4478
4480
  var FONT_SIZES = [10, 12, 14, 16, 20, 24, 32];
4479
4481
  var DASH_ORDER = ["solid", "dashed", "dotted"];
4480
4482
  var POS_KEY = "fnc-selbar-pos";
4483
+ var LIFT_KEY = "fnc-selbar-lift";
4481
4484
  var TEMPLATES_KEY = "fnc-drawing-templates";
4482
4485
  var TEMPLATES_MAX = 20;
4483
4486
  var lookOf = (style) => {
@@ -4562,6 +4565,7 @@ function SelectionBar({ ctx }) {
4562
4565
  const t3 = stringsOf(s3);
4563
4566
  const d3 = s3.selection;
4564
4567
  const [offset, setOffset] = d2(() => readJson(POS_KEY, [0, 0]));
4568
+ const [lift, setLift] = d2(() => readJson(LIFT_KEY, 0));
4565
4569
  const [recent, setRecent] = d2(() => recentColors().slice(0, 3));
4566
4570
  const [menu, setMenu] = d2(null);
4567
4571
  const [sheet, setSheet] = d2(false);
@@ -4572,15 +4576,30 @@ function SelectionBar({ ctx }) {
4572
4576
  const pop = bar.current?.querySelector(".fnc-selbar-pop");
4573
4577
  if (!pop || !bar.current) return;
4574
4578
  pop.style.maxHeight = "";
4579
+ pop.style.top = "";
4580
+ pop.style.bottom = "";
4575
4581
  const host = ctx.root.getBoundingClientRect();
4576
- const r3 = pop.getBoundingClientRect();
4577
- const up = r3.bottom <= bar.current.getBoundingClientRect().top + 1;
4582
+ let r3 = pop.getBoundingClientRect();
4583
+ const b = bar.current.getBoundingClientRect();
4584
+ let up = r3.bottom <= b.top + 1;
4585
+ if (up && r3.height > r3.bottom - Math.max(host.top, 0) - 8 && Math.min(host.bottom, innerHeight) - b.bottom > b.top - Math.max(host.top, 0)) {
4586
+ pop.style.top = "calc(100% + 6px)";
4587
+ pop.style.bottom = "auto";
4588
+ r3 = pop.getBoundingClientRect();
4589
+ up = false;
4590
+ }
4578
4591
  const room = up ? r3.bottom - Math.max(host.top, 0) - 8 : Math.min(host.bottom, innerHeight) - r3.top - 8;
4579
4592
  if (r3.height > room) {
4580
4593
  pop.style.maxHeight = `${Math.max(120, Math.floor(room))}px`;
4581
4594
  pop.style.overflowY = "auto";
4582
4595
  }
4583
4596
  }, [menu]);
4597
+ F2(() => {
4598
+ const el = bar.current;
4599
+ if (!el || !lift) return;
4600
+ const over = Math.max(ctx.root.getBoundingClientRect().top, 0) + 8 - el.getBoundingClientRect().top;
4601
+ if (over > 0) setLift(Math.max(0, lift - Math.ceil(over)));
4602
+ });
4584
4603
  if (!d3 || s3.layout.plotWidth <= 0) return null;
4585
4604
  const def = ctx.chart.drawingDefinitions().find((x2) => x2.type === d3.type);
4586
4605
  const style = d3.style ?? {};
@@ -4640,6 +4659,26 @@ function SelectionBar({ ctx }) {
4640
4659
  const actions = ctx.drawingActions?.(d3, ctx.chart) ?? [];
4641
4660
  const startMove = (e3) => {
4642
4661
  e3.preventDefault();
4662
+ const el = bar.current;
4663
+ if (el && getComputedStyle(el).getPropertyValue("--fnc-selbar-dock").trim() === "bottom") {
4664
+ const y0 = e3.clientY;
4665
+ const from2 = lift;
4666
+ const top = el.getBoundingClientRect().top + from2 - Math.max(ctx.root.getBoundingClientRect().top, 0) - 8;
4667
+ const at = (ev) => Math.round(Math.min(Math.max(0, from2 + y0 - ev.clientY), Math.max(0, top)));
4668
+ const move2 = (ev) => setLift(at(ev));
4669
+ const up2 = (ev) => {
4670
+ document.removeEventListener("pointermove", move2);
4671
+ document.removeEventListener("pointerup", up2);
4672
+ document.removeEventListener("pointercancel", up2);
4673
+ const next = at(ev);
4674
+ setLift(next);
4675
+ writeJson(LIFT_KEY, next);
4676
+ };
4677
+ document.addEventListener("pointermove", move2);
4678
+ document.addEventListener("pointerup", up2);
4679
+ document.addEventListener("pointercancel", up2);
4680
+ return;
4681
+ }
4643
4682
  const start = [e3.clientX, e3.clientY];
4644
4683
  const from = offset;
4645
4684
  const move = (ev) => setOffset([from[0] + ev.clientX - start[0], from[1] + ev.clientY - start[1]]);
@@ -4927,7 +4966,7 @@ function SelectionBar({ ctx }) {
4927
4966
  }
4928
4967
  )
4929
4968
  ] });
4930
- return /* @__PURE__ */ a3("div", { ref: bar, class: "fnc-selbar", role: "toolbar", style: { left: `${s3.layout.plotWidth / 2 + offset[0]}px`, top: `${8 + offset[1]}px` }, children: [
4969
+ return /* @__PURE__ */ a3("div", { ref: bar, class: "fnc-selbar", role: "toolbar", style: { left: `${s3.layout.plotWidth / 2 + offset[0]}px`, top: `${8 + offset[1]}px`, "--fnc-selbar-lift": `${lift}px` }, children: [
4931
4970
  /* @__PURE__ */ a3(
4932
4971
  "button",
4933
4972
  {
@@ -4938,6 +4977,8 @@ function SelectionBar({ ctx }) {
4938
4977
  onDblClick: () => {
4939
4978
  setOffset([0, 0]);
4940
4979
  writeJson(POS_KEY, [0, 0]);
4980
+ setLift(0);
4981
+ writeJson(LIFT_KEY, 0);
4941
4982
  },
4942
4983
  children: /* @__PURE__ */ a3(GripIcon, {})
4943
4984
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.11.62",
3
+ "version": "0.11.63",
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.62"
45
+ "@funnest/charts": "0.11.63"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"