@funnest/charts-ui 0.9.1 → 0.9.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
@@ -106,6 +106,13 @@ export declare const STRINGS: {
106
106
  partColors: string;
107
107
  resetColors: string;
108
108
  templates: string;
109
+ levels: string;
110
+ levelShown: string;
111
+ levelValue: string;
112
+ levelColor: string;
113
+ removeLevel: string;
114
+ addLevel: string;
115
+ resetLevels: string;
109
116
  saveTemplate: string;
110
117
  templateName: string;
111
118
  noTemplates: string;
@@ -318,6 +325,13 @@ export declare const STRINGS: {
318
325
  partColors: string;
319
326
  resetColors: string;
320
327
  templates: string;
328
+ levels: string;
329
+ levelShown: string;
330
+ levelValue: string;
331
+ levelColor: string;
332
+ removeLevel: string;
333
+ addLevel: string;
334
+ resetLevels: string;
321
335
  saveTemplate: string;
322
336
  templateName: string;
323
337
  noTemplates: 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
+ /** 레벨 설정: lines at different heights with a value tick. */
38
+ export declare const LevelsIcon: () => import("preact").JSX.Element;
37
39
  /** 그리기 템플릿: stacked cards. */
38
40
  export declare const TemplateIcon: () => import("preact").JSX.Element;
39
41
  export declare const SmallPlusIcon: () => import("preact").JSX.Element;
package/dist/index.js CHANGED
@@ -269,6 +269,9 @@ n = { __e: function(n2, t3, r3, u3) {
269
269
  return n2.__v.__b - t3.__v.__b;
270
270
  }, e = /* @__PURE__ */ Symbol(), l = /(PointerCapture)$|Capture$/i, c = 0, a = {}, s = 0;
271
271
 
272
+ // src/components/drawing-toolbar.tsx
273
+ import { drawingLevels } from "@funnest/charts";
274
+
272
275
  // ../../node_modules/.pnpm/preact@11.2.0/node_modules/preact/hooks/dist/hooks.mjs
273
276
  var t2;
274
277
  var r2;
@@ -532,6 +535,13 @@ var STRINGS = {
532
535
  partColors: "\uBD80\uBD84 \uC0C9\uC0C1",
533
536
  resetColors: "\uAE30\uBCF8 \uC0C9\uC73C\uB85C",
534
537
  templates: "\uD15C\uD50C\uB9BF",
538
+ levels: "\uB808\uBCA8 \uC124\uC815",
539
+ levelShown: "\uB808\uBCA8 \uBCF4\uC774\uAE30",
540
+ levelValue: "\uB808\uBCA8 \uAC12",
541
+ levelColor: "\uB808\uBCA8 \uC0C9",
542
+ removeLevel: "\uB808\uBCA8 \uBE7C\uAE30",
543
+ addLevel: "\uB808\uBCA8 \uCD94\uAC00",
544
+ resetLevels: "\uAE30\uBCF8 \uB808\uBCA8\uB85C",
535
545
  saveTemplate: "\uC9C0\uAE08 \uBAA8\uC591\uC744 \uD15C\uD50C\uB9BF\uC73C\uB85C \uC800\uC7A5",
536
546
  templateName: "\uD15C\uD50C\uB9BF \uC774\uB984",
537
547
  noTemplates: "\uC774 \uB3C4\uAD6C\uB85C \uC800\uC7A5\uD55C \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC5B4\uC694",
@@ -746,6 +756,13 @@ var STRINGS = {
746
756
  partColors: "Part colors",
747
757
  resetColors: "Reset colors",
748
758
  templates: "Templates",
759
+ levels: "Levels",
760
+ levelShown: "Show level",
761
+ levelValue: "Level value",
762
+ levelColor: "Level color",
763
+ removeLevel: "Remove level",
764
+ addLevel: "Add level",
765
+ resetLevels: "Default levels",
749
766
  saveTemplate: "Save this look as a template",
750
767
  templateName: "Template name",
751
768
  noTemplates: "No templates for this tool yet",
@@ -995,6 +1012,11 @@ var GearIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
995
1012
  /* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.4" }),
996
1013
  /* @__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" })
997
1014
  ] });
1015
+ var LevelsIcon = () => /* @__PURE__ */ a3(Icon, { children: [
1016
+ /* @__PURE__ */ a3("path", { d: "M3 5h9M3 10h14M3 15h11" }),
1017
+ /* @__PURE__ */ a3("circle", { cx: "15", cy: "5", r: "1.4" }),
1018
+ /* @__PURE__ */ a3("circle", { cx: "17", cy: "15", r: "1.4" })
1019
+ ] });
998
1020
  var TemplateIcon = () => /* @__PURE__ */ a3(Icon, { children: [
999
1021
  /* @__PURE__ */ a3("rect", { x: "3", y: "7", width: "10", height: "10", rx: "2" }),
1000
1022
  /* @__PURE__ */ a3("path", { d: "M7 4h8a2 2 0 0 1 2 2v8" })
@@ -1413,8 +1435,14 @@ var POS_KEY = "fnc-selbar-pos";
1413
1435
  var TEMPLATES_KEY = "fnc-drawing-templates";
1414
1436
  var TEMPLATES_MAX = 20;
1415
1437
  var lookOf = (style) => {
1416
- const { width, dash, fontSize, colors } = style;
1417
- return { ...width ? { width } : {}, ...dash ? { dash } : {}, ...fontSize ? { fontSize } : {}, ...colors ? { colors: { ...colors } } : {} };
1438
+ const { width, dash, fontSize, colors, levels } = style;
1439
+ return {
1440
+ ...width ? { width } : {},
1441
+ ...dash ? { dash } : {},
1442
+ ...fontSize ? { fontSize } : {},
1443
+ ...colors ? { colors: { ...colors } } : {},
1444
+ ...levels ? { levels: levels.map((l3) => ({ ...l3 })) } : {}
1445
+ };
1418
1446
  };
1419
1447
  var readJson = (key, fallback) => {
1420
1448
  try {
@@ -1448,14 +1476,25 @@ function SelectionBar({ ctx }) {
1448
1476
  const def = ctx.chart.drawingDefinitions().find((x2) => x2.type === d3.type);
1449
1477
  const style = d3.style ?? {};
1450
1478
  const setStyle = (patch) => ctx.chart.updateDrawing(d3.id, { style: { ...style, ...patch } });
1479
+ const setStyleRaw = (next) => ctx.chart.updateDrawing(d3.id, { style: next });
1451
1480
  const current = d3.color ?? SWATCHES[0];
1452
1481
  const pickColor = (color) => {
1453
- if (style.colors) {
1482
+ if (style.colors || style.levels?.some((l3) => l3.color)) {
1454
1483
  const { colors: _drop, ...rest } = style;
1455
- ctx.chart.updateDrawing(d3.id, { color, style: rest });
1484
+ const levels = rest.levels?.map(({ color: _c, ...l3 }) => l3);
1485
+ ctx.chart.updateDrawing(d3.id, { color, style: { ...rest, ...levels ? { levels } : {} } });
1456
1486
  } else ctx.chart.updateDrawing(d3.id, { color });
1457
1487
  };
1458
- const slots = def?.colors ?? [];
1488
+ const slots = def?.levels ? [] : def?.colors ?? [];
1489
+ const levelRows = def?.levels ? drawingLevels(def, d3) : [];
1490
+ const setLevels = (next) => {
1491
+ const { colors: _drop, ...rest } = style;
1492
+ setStyleRaw({ ...rest, levels: next });
1493
+ };
1494
+ const resetLevels = () => {
1495
+ const { colors: _c, levels: _l, ...rest } = style;
1496
+ setStyleRaw(rest);
1497
+ };
1459
1498
  const slotColor = (key, fallback) => style.colors?.[key] ?? d3.color ?? fallback;
1460
1499
  const addRecent = (color) => {
1461
1500
  const next = [color, ...recent.filter((c3) => c3 !== color)].slice(0, 3);
@@ -1565,6 +1604,65 @@ function SelectionBar({ ctx }) {
1565
1604
  )
1566
1605
  ] })
1567
1606
  ] }),
1607
+ def?.levels && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
1608
+ /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.levels, "aria-label": t3.levels, "aria-expanded": menu === "levels", onClick: () => setMenu(menu === "levels" ? null : "levels"), children: /* @__PURE__ */ a3(LevelsIcon, {}) }),
1609
+ menu === "levels" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-levels-menu", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
1610
+ /* @__PURE__ */ a3("div", { class: "fnc-levels-list fnc-scroll", children: levelRows.map((l3, i3) => /* @__PURE__ */ a3("div", { class: "fnc-level-row", children: [
1611
+ /* @__PURE__ */ a3(
1612
+ "input",
1613
+ {
1614
+ type: "checkbox",
1615
+ checked: l3.on !== false,
1616
+ "aria-label": `${t3.levelShown} ${l3.value}`,
1617
+ onChange: (e3) => setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, on: e3.target.checked } : x2))
1618
+ }
1619
+ ),
1620
+ /* @__PURE__ */ a3(
1621
+ "input",
1622
+ {
1623
+ class: "fnc-input fnc-level-value",
1624
+ type: "number",
1625
+ step: "any",
1626
+ defaultValue: String(l3.value),
1627
+ "aria-label": t3.levelValue,
1628
+ onChange: (e3) => {
1629
+ const v3 = Number(e3.target.value);
1630
+ if (Number.isFinite(v3) && Math.abs(v3) <= 1e3) setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, value: v3 } : x2));
1631
+ }
1632
+ }
1633
+ ),
1634
+ /* @__PURE__ */ a3("label", { class: "fnc-swatch fnc-level-color", style: { background: l3.color }, "data-tip": t3.levelColor, children: /* @__PURE__ */ a3(
1635
+ "input",
1636
+ {
1637
+ type: "color",
1638
+ "aria-label": `${t3.levelColor} ${l3.value}`,
1639
+ value: /^#[0-9a-f]{6}$/i.test(l3.color ?? "") ? l3.color : "#3182f6",
1640
+ onInput: (e3) => setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, color: e3.target.value } : x2))
1641
+ }
1642
+ ) }),
1643
+ /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.removeLevel, "aria-label": `${l3.value} ${t3.removeLevel}`, onClick: () => setLevels(levelRows.filter((_3, j2) => j2 !== i3)), children: /* @__PURE__ */ a3(SmallCloseIcon, {}) })
1644
+ ] }, `${i3}:${l3.value}`)) }),
1645
+ /* @__PURE__ */ a3("div", { class: "fnc-menu-sep" }),
1646
+ /* @__PURE__ */ a3(
1647
+ "button",
1648
+ {
1649
+ class: "fnc-menu-item",
1650
+ role: "menuitem",
1651
+ onClick: () => {
1652
+ const values = levelRows.map((x2) => x2.value);
1653
+ const top = values.length ? Math.max(...values) : 0;
1654
+ const gap = values.length > 1 ? Math.abs(values[values.length - 1] - values[values.length - 2]) || 1 : 1;
1655
+ setLevels([...levelRows, { value: Number((top + gap).toFixed(4)), on: true, color: current }]);
1656
+ },
1657
+ children: [
1658
+ "+ ",
1659
+ t3.addLevel
1660
+ ]
1661
+ }
1662
+ ),
1663
+ /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", onClick: resetLevels, children: t3.resetLevels })
1664
+ ] })
1665
+ ] }),
1568
1666
  /* @__PURE__ */ a3("div", { class: "fnc-sep" }),
1569
1667
  /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
1570
1668
  /* @__PURE__ */ a3("button", { class: "fnc-btn fnc-selbar-width", "data-tip": t3.lineWidth, "aria-label": t3.lineWidth, "aria-expanded": menu === "width", onClick: () => setMenu(menu === "width" ? null : "width"), children: /* @__PURE__ */ a3("svg", { width: "20", height: "20", viewBox: "0 0 20 20", "aria-hidden": "true", children: /* @__PURE__ */ a3("path", { d: "M3 10h14", stroke: "currentColor", "stroke-width": style.width ?? 2, "stroke-linecap": "round" }) }) }),
@@ -4987,6 +5085,13 @@ var CSS = (
4987
5085
  .fnc-tools-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0 6px; }
4988
5086
  .fnc-tools-seg svg { width: 16px; height: 16px; flex: none; }
4989
5087
  .fnc-template-menu { min-width: 220px; }
5088
+ .fnc-levels-menu { min-width: 230px; }
5089
+ .fnc-levels-list { max-height: 300px; overflow-y: auto; padding: 2px 0; }
5090
+ .fnc-level-row { display: flex; align-items: center; gap: 8px; padding: 3px 8px; }
5091
+ .fnc-level-row input[type='checkbox'] { width: 15px; height: 15px; margin: 0; accent-color: var(--fnc-accent, #3182f6); }
5092
+ .fnc-level-value { flex: none; width: 84px; height: 28px; padding: 0 8px; font-size: 13px; }
5093
+ .fnc-level-color { position: relative; flex: none; overflow: hidden; }
5094
+ .fnc-level-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
4990
5095
  .fnc-template-row { display: flex; align-items: center; }
4991
5096
  .fnc-template-row .fnc-menu-item { flex: 1; min-width: 0; gap: 8px; }
4992
5097
  .fnc-template-row .fnc-menu-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.9.1",
3
+ "version": "0.9.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.9.1"
45
+ "@funnest/charts": "0.9.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"