@funnest/charts-ui 0.9.1 → 0.9.3
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 +18 -0
- package/dist/icons.d.ts +2 -0
- package/dist/index.js +174 -5
- package/package.json +2 -2
package/dist/i18n.d.ts
CHANGED
|
@@ -106,6 +106,15 @@ export declare const STRINGS: {
|
|
|
106
106
|
partColors: string;
|
|
107
107
|
resetColors: string;
|
|
108
108
|
templates: string;
|
|
109
|
+
levels: string;
|
|
110
|
+
drawingOptions: string;
|
|
111
|
+
resetOptions: string;
|
|
112
|
+
levelShown: string;
|
|
113
|
+
levelValue: string;
|
|
114
|
+
levelColor: string;
|
|
115
|
+
removeLevel: string;
|
|
116
|
+
addLevel: string;
|
|
117
|
+
resetLevels: string;
|
|
109
118
|
saveTemplate: string;
|
|
110
119
|
templateName: string;
|
|
111
120
|
noTemplates: string;
|
|
@@ -318,6 +327,15 @@ export declare const STRINGS: {
|
|
|
318
327
|
partColors: string;
|
|
319
328
|
resetColors: string;
|
|
320
329
|
templates: string;
|
|
330
|
+
levels: string;
|
|
331
|
+
drawingOptions: string;
|
|
332
|
+
resetOptions: string;
|
|
333
|
+
levelShown: string;
|
|
334
|
+
levelValue: string;
|
|
335
|
+
levelColor: string;
|
|
336
|
+
removeLevel: string;
|
|
337
|
+
addLevel: string;
|
|
338
|
+
resetLevels: string;
|
|
321
339
|
saveTemplate: string;
|
|
322
340
|
templateName: string;
|
|
323
341
|
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, drawingOption } 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,15 @@ 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
|
+
drawingOptions: "\uB3C4\uAD6C \uC124\uC815",
|
|
540
|
+
resetOptions: "\uAE30\uBCF8 \uC124\uC815\uC73C\uB85C",
|
|
541
|
+
levelShown: "\uB808\uBCA8 \uBCF4\uC774\uAE30",
|
|
542
|
+
levelValue: "\uB808\uBCA8 \uAC12",
|
|
543
|
+
levelColor: "\uB808\uBCA8 \uC0C9",
|
|
544
|
+
removeLevel: "\uB808\uBCA8 \uBE7C\uAE30",
|
|
545
|
+
addLevel: "\uB808\uBCA8 \uCD94\uAC00",
|
|
546
|
+
resetLevels: "\uAE30\uBCF8 \uB808\uBCA8\uB85C",
|
|
535
547
|
saveTemplate: "\uC9C0\uAE08 \uBAA8\uC591\uC744 \uD15C\uD50C\uB9BF\uC73C\uB85C \uC800\uC7A5",
|
|
536
548
|
templateName: "\uD15C\uD50C\uB9BF \uC774\uB984",
|
|
537
549
|
noTemplates: "\uC774 \uB3C4\uAD6C\uB85C \uC800\uC7A5\uD55C \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC5B4\uC694",
|
|
@@ -746,6 +758,15 @@ var STRINGS = {
|
|
|
746
758
|
partColors: "Part colors",
|
|
747
759
|
resetColors: "Reset colors",
|
|
748
760
|
templates: "Templates",
|
|
761
|
+
levels: "Levels",
|
|
762
|
+
drawingOptions: "Settings",
|
|
763
|
+
resetOptions: "Default settings",
|
|
764
|
+
levelShown: "Show level",
|
|
765
|
+
levelValue: "Level value",
|
|
766
|
+
levelColor: "Level color",
|
|
767
|
+
removeLevel: "Remove level",
|
|
768
|
+
addLevel: "Add level",
|
|
769
|
+
resetLevels: "Default levels",
|
|
749
770
|
saveTemplate: "Save this look as a template",
|
|
750
771
|
templateName: "Template name",
|
|
751
772
|
noTemplates: "No templates for this tool yet",
|
|
@@ -995,6 +1016,11 @@ var GearIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
|
|
|
995
1016
|
/* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.4" }),
|
|
996
1017
|
/* @__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
1018
|
] });
|
|
1019
|
+
var LevelsIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
1020
|
+
/* @__PURE__ */ a3("path", { d: "M3 5h9M3 10h14M3 15h11" }),
|
|
1021
|
+
/* @__PURE__ */ a3("circle", { cx: "15", cy: "5", r: "1.4" }),
|
|
1022
|
+
/* @__PURE__ */ a3("circle", { cx: "17", cy: "15", r: "1.4" })
|
|
1023
|
+
] });
|
|
998
1024
|
var TemplateIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
999
1025
|
/* @__PURE__ */ a3("rect", { x: "3", y: "7", width: "10", height: "10", rx: "2" }),
|
|
1000
1026
|
/* @__PURE__ */ a3("path", { d: "M7 4h8a2 2 0 0 1 2 2v8" })
|
|
@@ -1413,8 +1439,15 @@ var POS_KEY = "fnc-selbar-pos";
|
|
|
1413
1439
|
var TEMPLATES_KEY = "fnc-drawing-templates";
|
|
1414
1440
|
var TEMPLATES_MAX = 20;
|
|
1415
1441
|
var lookOf = (style) => {
|
|
1416
|
-
const { width, dash, fontSize, colors } = style;
|
|
1417
|
-
return {
|
|
1442
|
+
const { width, dash, fontSize, colors, levels, options } = style;
|
|
1443
|
+
return {
|
|
1444
|
+
...width ? { width } : {},
|
|
1445
|
+
...dash ? { dash } : {},
|
|
1446
|
+
...fontSize ? { fontSize } : {},
|
|
1447
|
+
...colors ? { colors: { ...colors } } : {},
|
|
1448
|
+
...levels ? { levels: levels.map((l3) => ({ ...l3 })) } : {},
|
|
1449
|
+
...options ? { options: { ...options } } : {}
|
|
1450
|
+
};
|
|
1418
1451
|
};
|
|
1419
1452
|
var readJson = (key, fallback) => {
|
|
1420
1453
|
try {
|
|
@@ -1448,14 +1481,25 @@ function SelectionBar({ ctx }) {
|
|
|
1448
1481
|
const def = ctx.chart.drawingDefinitions().find((x2) => x2.type === d3.type);
|
|
1449
1482
|
const style = d3.style ?? {};
|
|
1450
1483
|
const setStyle = (patch) => ctx.chart.updateDrawing(d3.id, { style: { ...style, ...patch } });
|
|
1484
|
+
const setStyleRaw = (next) => ctx.chart.updateDrawing(d3.id, { style: next });
|
|
1451
1485
|
const current = d3.color ?? SWATCHES[0];
|
|
1452
1486
|
const pickColor = (color) => {
|
|
1453
|
-
if (style.colors) {
|
|
1487
|
+
if (style.colors || style.levels?.some((l3) => l3.color)) {
|
|
1454
1488
|
const { colors: _drop, ...rest } = style;
|
|
1455
|
-
|
|
1489
|
+
const levels = rest.levels?.map(({ color: _c, ...l3 }) => l3);
|
|
1490
|
+
ctx.chart.updateDrawing(d3.id, { color, style: { ...rest, ...levels ? { levels } : {} } });
|
|
1456
1491
|
} else ctx.chart.updateDrawing(d3.id, { color });
|
|
1457
1492
|
};
|
|
1458
|
-
const slots = def?.colors ?? [];
|
|
1493
|
+
const slots = def?.levels ? [] : def?.colors ?? [];
|
|
1494
|
+
const levelRows = def?.levels ? drawingLevels(def, d3) : [];
|
|
1495
|
+
const setLevels = (next) => {
|
|
1496
|
+
const { colors: _drop, ...rest } = style;
|
|
1497
|
+
setStyleRaw({ ...rest, levels: next });
|
|
1498
|
+
};
|
|
1499
|
+
const resetLevels = () => {
|
|
1500
|
+
const { colors: _c, levels: _l, ...rest } = style;
|
|
1501
|
+
setStyleRaw(rest);
|
|
1502
|
+
};
|
|
1459
1503
|
const slotColor = (key, fallback) => style.colors?.[key] ?? d3.color ?? fallback;
|
|
1460
1504
|
const addRecent = (color) => {
|
|
1461
1505
|
const next = [color, ...recent.filter((c3) => c3 !== color)].slice(0, 3);
|
|
@@ -1565,6 +1609,116 @@ function SelectionBar({ ctx }) {
|
|
|
1565
1609
|
)
|
|
1566
1610
|
] })
|
|
1567
1611
|
] }),
|
|
1612
|
+
def?.options && def.options.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
|
|
1613
|
+
/* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.drawingOptions, "aria-label": t3.drawingOptions, "aria-expanded": menu === "options", onClick: () => setMenu(menu === "options" ? null : "options"), children: /* @__PURE__ */ a3(GearIcon, {}) }),
|
|
1614
|
+
menu === "options" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-options-menu", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
|
|
1615
|
+
def.options.map((o4) => {
|
|
1616
|
+
const value = drawingOption(def, d3, o4.key);
|
|
1617
|
+
const set = (v3) => setStyle({ options: { ...style.options, [o4.key]: v3 } });
|
|
1618
|
+
if (o4.kind === "toggle")
|
|
1619
|
+
return /* @__PURE__ */ a3("label", { class: "fnc-menu-item fnc-option-row", children: [
|
|
1620
|
+
/* @__PURE__ */ a3("input", { type: "checkbox", checked: value === true, onChange: (e3) => set(e3.target.checked) }),
|
|
1621
|
+
/* @__PURE__ */ a3("span", { children: o4.label[s3.locale] })
|
|
1622
|
+
] });
|
|
1623
|
+
if (o4.kind === "choice")
|
|
1624
|
+
return /* @__PURE__ */ a3("label", { class: "fnc-option-row fnc-option-field", children: [
|
|
1625
|
+
/* @__PURE__ */ a3("span", { children: o4.label[s3.locale] }),
|
|
1626
|
+
/* @__PURE__ */ a3("select", { class: "fnc-select", value: String(value), onChange: (e3) => set(e3.target.value), children: o4.choices?.map((c3) => /* @__PURE__ */ a3("option", { value: c3.value, children: c3.label[s3.locale] })) })
|
|
1627
|
+
] });
|
|
1628
|
+
return /* @__PURE__ */ a3("label", { class: "fnc-option-row fnc-option-field", children: [
|
|
1629
|
+
/* @__PURE__ */ a3("span", { children: o4.label[s3.locale] }),
|
|
1630
|
+
/* @__PURE__ */ a3(
|
|
1631
|
+
"input",
|
|
1632
|
+
{
|
|
1633
|
+
class: "fnc-input fnc-option-number",
|
|
1634
|
+
type: "number",
|
|
1635
|
+
step: o4.step ?? "any",
|
|
1636
|
+
min: o4.min,
|
|
1637
|
+
max: o4.max,
|
|
1638
|
+
defaultValue: String(value),
|
|
1639
|
+
onChange: (e3) => {
|
|
1640
|
+
const v3 = Number(e3.target.value);
|
|
1641
|
+
if (Number.isFinite(v3)) set(v3);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
),
|
|
1645
|
+
o4.unit && /* @__PURE__ */ a3("span", { class: "fnc-option-unit", children: o4.unit })
|
|
1646
|
+
] }, `${o4.key}:${String(value)}`);
|
|
1647
|
+
}),
|
|
1648
|
+
/* @__PURE__ */ a3("div", { class: "fnc-menu-sep" }),
|
|
1649
|
+
/* @__PURE__ */ a3(
|
|
1650
|
+
"button",
|
|
1651
|
+
{
|
|
1652
|
+
class: "fnc-menu-item",
|
|
1653
|
+
role: "menuitem",
|
|
1654
|
+
onClick: () => {
|
|
1655
|
+
const { options: _drop, ...rest } = style;
|
|
1656
|
+
setStyleRaw(rest);
|
|
1657
|
+
},
|
|
1658
|
+
children: t3.resetOptions
|
|
1659
|
+
}
|
|
1660
|
+
)
|
|
1661
|
+
] })
|
|
1662
|
+
] }),
|
|
1663
|
+
def?.levels && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
|
|
1664
|
+
/* @__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, {}) }),
|
|
1665
|
+
menu === "levels" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-levels-menu", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
|
|
1666
|
+
/* @__PURE__ */ a3("div", { class: "fnc-levels-list fnc-scroll", children: levelRows.map((l3, i3) => /* @__PURE__ */ a3("div", { class: "fnc-level-row", children: [
|
|
1667
|
+
/* @__PURE__ */ a3(
|
|
1668
|
+
"input",
|
|
1669
|
+
{
|
|
1670
|
+
type: "checkbox",
|
|
1671
|
+
checked: l3.on !== false,
|
|
1672
|
+
"aria-label": `${t3.levelShown} ${l3.value}`,
|
|
1673
|
+
onChange: (e3) => setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, on: e3.target.checked } : x2))
|
|
1674
|
+
}
|
|
1675
|
+
),
|
|
1676
|
+
/* @__PURE__ */ a3(
|
|
1677
|
+
"input",
|
|
1678
|
+
{
|
|
1679
|
+
class: "fnc-input fnc-level-value",
|
|
1680
|
+
type: "number",
|
|
1681
|
+
step: "any",
|
|
1682
|
+
defaultValue: String(l3.value),
|
|
1683
|
+
"aria-label": t3.levelValue,
|
|
1684
|
+
onChange: (e3) => {
|
|
1685
|
+
const v3 = Number(e3.target.value);
|
|
1686
|
+
if (Number.isFinite(v3) && Math.abs(v3) <= 1e3) setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, value: v3 } : x2));
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
),
|
|
1690
|
+
/* @__PURE__ */ a3("label", { class: "fnc-swatch fnc-level-color", style: { background: l3.color }, "data-tip": t3.levelColor, children: /* @__PURE__ */ a3(
|
|
1691
|
+
"input",
|
|
1692
|
+
{
|
|
1693
|
+
type: "color",
|
|
1694
|
+
"aria-label": `${t3.levelColor} ${l3.value}`,
|
|
1695
|
+
value: /^#[0-9a-f]{6}$/i.test(l3.color ?? "") ? l3.color : "#3182f6",
|
|
1696
|
+
onInput: (e3) => setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, color: e3.target.value } : x2))
|
|
1697
|
+
}
|
|
1698
|
+
) }),
|
|
1699
|
+
/* @__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, {}) })
|
|
1700
|
+
] }, `${i3}:${l3.value}`)) }),
|
|
1701
|
+
/* @__PURE__ */ a3("div", { class: "fnc-menu-sep" }),
|
|
1702
|
+
/* @__PURE__ */ a3(
|
|
1703
|
+
"button",
|
|
1704
|
+
{
|
|
1705
|
+
class: "fnc-menu-item",
|
|
1706
|
+
role: "menuitem",
|
|
1707
|
+
onClick: () => {
|
|
1708
|
+
const values = levelRows.map((x2) => x2.value);
|
|
1709
|
+
const top = values.length ? Math.max(...values) : 0;
|
|
1710
|
+
const gap = values.length > 1 ? Math.abs(values[values.length - 1] - values[values.length - 2]) || 1 : 1;
|
|
1711
|
+
setLevels([...levelRows, { value: Number((top + gap).toFixed(4)), on: true, color: current }]);
|
|
1712
|
+
},
|
|
1713
|
+
children: [
|
|
1714
|
+
"+ ",
|
|
1715
|
+
t3.addLevel
|
|
1716
|
+
]
|
|
1717
|
+
}
|
|
1718
|
+
),
|
|
1719
|
+
/* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", onClick: resetLevels, children: t3.resetLevels })
|
|
1720
|
+
] })
|
|
1721
|
+
] }),
|
|
1568
1722
|
/* @__PURE__ */ a3("div", { class: "fnc-sep" }),
|
|
1569
1723
|
/* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
|
|
1570
1724
|
/* @__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 +5141,21 @@ var CSS = (
|
|
|
4987
5141
|
.fnc-tools-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0 6px; }
|
|
4988
5142
|
.fnc-tools-seg svg { width: 16px; height: 16px; flex: none; }
|
|
4989
5143
|
.fnc-template-menu { min-width: 220px; }
|
|
5144
|
+
.fnc-levels-menu { min-width: 230px; }
|
|
5145
|
+
.fnc-options-menu { min-width: 250px; }
|
|
5146
|
+
.fnc-option-row { display: flex; align-items: center; gap: 8px; }
|
|
5147
|
+
.fnc-option-row input[type='checkbox'] { width: 15px; height: 15px; margin: 0; accent-color: var(--fnc-accent, #3182f6); }
|
|
5148
|
+
.fnc-option-field { justify-content: space-between; padding: 4px 10px; font-size: 13px; color: var(--fnc-text); }
|
|
5149
|
+
.fnc-option-field > span:first-child { flex: 1; }
|
|
5150
|
+
.fnc-option-number { flex: none; width: 90px; height: 28px; padding: 0 8px; font-size: 13px; }
|
|
5151
|
+
.fnc-option-unit { color: var(--fnc-text-2); font-size: 12px; }
|
|
5152
|
+
.fnc-option-field .fnc-select { height: 28px; font-size: 13px; }
|
|
5153
|
+
.fnc-levels-list { max-height: 300px; overflow-y: auto; padding: 2px 0; }
|
|
5154
|
+
.fnc-level-row { display: flex; align-items: center; gap: 8px; padding: 3px 8px; }
|
|
5155
|
+
.fnc-level-row input[type='checkbox'] { width: 15px; height: 15px; margin: 0; accent-color: var(--fnc-accent, #3182f6); }
|
|
5156
|
+
.fnc-level-value { flex: none; width: 84px; height: 28px; padding: 0 8px; font-size: 13px; }
|
|
5157
|
+
.fnc-level-color { position: relative; flex: none; overflow: hidden; }
|
|
5158
|
+
.fnc-level-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
|
|
4990
5159
|
.fnc-template-row { display: flex; align-items: center; }
|
|
4991
5160
|
.fnc-template-row .fnc-menu-item { flex: 1; min-width: 0; gap: 8px; }
|
|
4992
5161
|
.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.
|
|
3
|
+
"version": "0.9.3",
|
|
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.
|
|
45
|
+
"@funnest/charts": "0.9.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"preact": "^11.2.0"
|