@funnest/charts-ui 0.9.0 → 0.9.1
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 +10 -0
- package/dist/icons.d.ts +2 -0
- package/dist/index.js +114 -0
- package/package.json +2 -2
package/dist/i18n.d.ts
CHANGED
|
@@ -105,6 +105,11 @@ export declare const STRINGS: {
|
|
|
105
105
|
customColor: string;
|
|
106
106
|
partColors: string;
|
|
107
107
|
resetColors: string;
|
|
108
|
+
templates: string;
|
|
109
|
+
saveTemplate: string;
|
|
110
|
+
templateName: string;
|
|
111
|
+
noTemplates: string;
|
|
112
|
+
deleteTemplate: string;
|
|
108
113
|
lineWidth: string;
|
|
109
114
|
lineStyle: string;
|
|
110
115
|
lineSolid: string;
|
|
@@ -312,6 +317,11 @@ export declare const STRINGS: {
|
|
|
312
317
|
customColor: string;
|
|
313
318
|
partColors: string;
|
|
314
319
|
resetColors: string;
|
|
320
|
+
templates: string;
|
|
321
|
+
saveTemplate: string;
|
|
322
|
+
templateName: string;
|
|
323
|
+
noTemplates: string;
|
|
324
|
+
deleteTemplate: string;
|
|
315
325
|
lineWidth: string;
|
|
316
326
|
lineStyle: string;
|
|
317
327
|
lineSolid: 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
|
+
/** 그리기 템플릿: stacked cards. */
|
|
38
|
+
export declare const TemplateIcon: () => import("preact").JSX.Element;
|
|
37
39
|
export declare const SmallPlusIcon: () => import("preact").JSX.Element;
|
|
38
40
|
export declare const SmallCloseIcon: () => import("preact").JSX.Element;
|
|
39
41
|
export declare const EyeIcon: () => import("preact").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -531,6 +531,11 @@ var STRINGS = {
|
|
|
531
531
|
customColor: "\uB2E4\uB978 \uC0C9",
|
|
532
532
|
partColors: "\uBD80\uBD84 \uC0C9\uC0C1",
|
|
533
533
|
resetColors: "\uAE30\uBCF8 \uC0C9\uC73C\uB85C",
|
|
534
|
+
templates: "\uD15C\uD50C\uB9BF",
|
|
535
|
+
saveTemplate: "\uC9C0\uAE08 \uBAA8\uC591\uC744 \uD15C\uD50C\uB9BF\uC73C\uB85C \uC800\uC7A5",
|
|
536
|
+
templateName: "\uD15C\uD50C\uB9BF \uC774\uB984",
|
|
537
|
+
noTemplates: "\uC774 \uB3C4\uAD6C\uB85C \uC800\uC7A5\uD55C \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC5B4\uC694",
|
|
538
|
+
deleteTemplate: "\uD15C\uD50C\uB9BF \uC9C0\uC6B0\uAE30",
|
|
534
539
|
lineWidth: "\uC120 \uAD75\uAE30",
|
|
535
540
|
lineStyle: "\uC120 \uBAA8\uC591",
|
|
536
541
|
lineSolid: "\uC2E4\uC120",
|
|
@@ -740,6 +745,11 @@ var STRINGS = {
|
|
|
740
745
|
customColor: "Other color",
|
|
741
746
|
partColors: "Part colors",
|
|
742
747
|
resetColors: "Reset colors",
|
|
748
|
+
templates: "Templates",
|
|
749
|
+
saveTemplate: "Save this look as a template",
|
|
750
|
+
templateName: "Template name",
|
|
751
|
+
noTemplates: "No templates for this tool yet",
|
|
752
|
+
deleteTemplate: "Delete template",
|
|
743
753
|
lineWidth: "Line width",
|
|
744
754
|
lineStyle: "Line style",
|
|
745
755
|
lineSolid: "Solid",
|
|
@@ -985,6 +995,10 @@ var GearIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
|
|
|
985
995
|
/* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.4" }),
|
|
986
996
|
/* @__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" })
|
|
987
997
|
] });
|
|
998
|
+
var TemplateIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
999
|
+
/* @__PURE__ */ a3("rect", { x: "3", y: "7", width: "10", height: "10", rx: "2" }),
|
|
1000
|
+
/* @__PURE__ */ a3("path", { d: "M7 4h8a2 2 0 0 1 2 2v8" })
|
|
1001
|
+
] });
|
|
988
1002
|
var SmallPlusIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M5 10h10M10 5v10" }) });
|
|
989
1003
|
var SmallCloseIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M6 6l8 8M14 6l-8 8" }) });
|
|
990
1004
|
var EyeIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
|
|
@@ -1396,6 +1410,12 @@ var FONT_SIZES = [10, 12, 14, 16, 20, 24, 32];
|
|
|
1396
1410
|
var DASH_ORDER = ["solid", "dashed", "dotted"];
|
|
1397
1411
|
var RECENT_KEY = "fnc-drawing-colors";
|
|
1398
1412
|
var POS_KEY = "fnc-selbar-pos";
|
|
1413
|
+
var TEMPLATES_KEY = "fnc-drawing-templates";
|
|
1414
|
+
var TEMPLATES_MAX = 20;
|
|
1415
|
+
var lookOf = (style) => {
|
|
1416
|
+
const { width, dash, fontSize, colors } = style;
|
|
1417
|
+
return { ...width ? { width } : {}, ...dash ? { dash } : {}, ...fontSize ? { fontSize } : {}, ...colors ? { colors: { ...colors } } : {} };
|
|
1418
|
+
};
|
|
1399
1419
|
var readJson = (key, fallback) => {
|
|
1400
1420
|
try {
|
|
1401
1421
|
const raw = localStorage.getItem(key);
|
|
@@ -1421,6 +1441,8 @@ function SelectionBar({ ctx }) {
|
|
|
1421
1441
|
const [offset, setOffset] = d2(() => readJson(POS_KEY, [0, 0]));
|
|
1422
1442
|
const [recent, setRecent] = d2(() => readJson(RECENT_KEY, []));
|
|
1423
1443
|
const [menu, setMenu] = d2(null);
|
|
1444
|
+
const [templates, setTemplates] = d2(() => readJson(TEMPLATES_KEY, {}));
|
|
1445
|
+
const [naming, setNaming] = d2(null);
|
|
1424
1446
|
const colorInput = T2(null);
|
|
1425
1447
|
if (!d3 || s3.layout.plotWidth <= 0) return null;
|
|
1426
1448
|
const def = ctx.chart.drawingDefinitions().find((x2) => x2.type === d3.type);
|
|
@@ -1442,6 +1464,28 @@ function SelectionBar({ ctx }) {
|
|
|
1442
1464
|
};
|
|
1443
1465
|
const locked = !!style.locked;
|
|
1444
1466
|
const dash = style.dash ?? "solid";
|
|
1467
|
+
const mine = templates[d3.type] ?? [];
|
|
1468
|
+
const keepTemplates = (next) => {
|
|
1469
|
+
const all = { ...templates, [d3.type]: next };
|
|
1470
|
+
if (!next.length) delete all[d3.type];
|
|
1471
|
+
setTemplates(all);
|
|
1472
|
+
writeJson(TEMPLATES_KEY, all);
|
|
1473
|
+
};
|
|
1474
|
+
const saveTemplate = () => {
|
|
1475
|
+
const name = (naming ?? "").trim().slice(0, 30);
|
|
1476
|
+
if (!name) return setNaming(null);
|
|
1477
|
+
keepTemplates([{ name, ...d3.color ? { color: d3.color } : {}, style: lookOf(style) }, ...mine.filter((x2) => x2.name !== name)].slice(0, TEMPLATES_MAX));
|
|
1478
|
+
setNaming(null);
|
|
1479
|
+
setMenu(null);
|
|
1480
|
+
};
|
|
1481
|
+
const applyTemplate = (tpl) => {
|
|
1482
|
+
const { text, locked: lock, hidden } = style;
|
|
1483
|
+
ctx.chart.updateDrawing(d3.id, {
|
|
1484
|
+
...tpl.color ? { color: tpl.color } : {},
|
|
1485
|
+
style: { ...tpl.style, ...text !== void 0 ? { text } : {}, ...lock ? { locked: lock } : {}, ...hidden ? { hidden } : {} }
|
|
1486
|
+
});
|
|
1487
|
+
setMenu(null);
|
|
1488
|
+
};
|
|
1445
1489
|
const actions = ctx.drawingActions?.(d3, ctx.chart) ?? [];
|
|
1446
1490
|
const startMove = (e3) => {
|
|
1447
1491
|
e3.preventDefault();
|
|
@@ -1585,6 +1629,69 @@ function SelectionBar({ ctx }) {
|
|
|
1585
1629
|
}
|
|
1586
1630
|
)) })
|
|
1587
1631
|
] }),
|
|
1632
|
+
/* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
|
|
1633
|
+
/* @__PURE__ */ a3(
|
|
1634
|
+
"button",
|
|
1635
|
+
{
|
|
1636
|
+
class: "fnc-btn",
|
|
1637
|
+
"data-tip": t3.templates,
|
|
1638
|
+
"aria-label": t3.templates,
|
|
1639
|
+
"aria-expanded": menu === "template",
|
|
1640
|
+
onClick: () => {
|
|
1641
|
+
setNaming(null);
|
|
1642
|
+
setMenu(menu === "template" ? null : "template");
|
|
1643
|
+
},
|
|
1644
|
+
children: /* @__PURE__ */ a3(TemplateIcon, {})
|
|
1645
|
+
}
|
|
1646
|
+
),
|
|
1647
|
+
menu === "template" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-template-menu", role: "menu", children: [
|
|
1648
|
+
mine.length === 0 && /* @__PURE__ */ a3("div", { class: "fnc-menu-note", children: t3.noTemplates }),
|
|
1649
|
+
mine.map((tpl) => /* @__PURE__ */ a3("div", { class: "fnc-template-row", children: [
|
|
1650
|
+
/* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", onClick: () => applyTemplate(tpl), children: [
|
|
1651
|
+
/* @__PURE__ */ a3("span", { class: "fnc-swatch", style: { background: tpl.color ?? current } }),
|
|
1652
|
+
/* @__PURE__ */ a3("svg", { width: "28", height: "12", viewBox: "0 0 28 12", "aria-hidden": "true", children: /* @__PURE__ */ a3(
|
|
1653
|
+
"path",
|
|
1654
|
+
{
|
|
1655
|
+
d: "M2 6h24",
|
|
1656
|
+
stroke: tpl.color ?? current,
|
|
1657
|
+
"stroke-width": tpl.style.width ?? 2,
|
|
1658
|
+
"stroke-linecap": "round",
|
|
1659
|
+
"stroke-dasharray": tpl.style.dash === "dashed" ? "4 3" : tpl.style.dash === "dotted" ? "1 3" : void 0
|
|
1660
|
+
}
|
|
1661
|
+
) }),
|
|
1662
|
+
/* @__PURE__ */ a3("span", { children: tpl.name })
|
|
1663
|
+
] }),
|
|
1664
|
+
/* @__PURE__ */ a3(
|
|
1665
|
+
"button",
|
|
1666
|
+
{
|
|
1667
|
+
class: "fnc-ind-btn",
|
|
1668
|
+
"data-tip": t3.deleteTemplate,
|
|
1669
|
+
"aria-label": `${tpl.name} ${t3.deleteTemplate}`,
|
|
1670
|
+
onClick: () => keepTemplates(mine.filter((x2) => x2 !== tpl)),
|
|
1671
|
+
children: /* @__PURE__ */ a3(SmallCloseIcon, {})
|
|
1672
|
+
}
|
|
1673
|
+
)
|
|
1674
|
+
] })),
|
|
1675
|
+
/* @__PURE__ */ a3("div", { class: "fnc-menu-sep" }),
|
|
1676
|
+
naming === null ? /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", onClick: () => setNaming(""), children: t3.saveTemplate }) : /* @__PURE__ */ a3(
|
|
1677
|
+
"input",
|
|
1678
|
+
{
|
|
1679
|
+
class: "fnc-selbar-text fnc-template-name",
|
|
1680
|
+
value: naming,
|
|
1681
|
+
placeholder: t3.templateName,
|
|
1682
|
+
"aria-label": t3.templateName,
|
|
1683
|
+
maxLength: 30,
|
|
1684
|
+
autoFocus: true,
|
|
1685
|
+
onInput: (e3) => setNaming(e3.target.value),
|
|
1686
|
+
onKeyDown: (e3) => {
|
|
1687
|
+
e3.stopPropagation();
|
|
1688
|
+
if (e3.key === "Enter") saveTemplate();
|
|
1689
|
+
if (e3.key === "Escape") setNaming(null);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
)
|
|
1693
|
+
] })
|
|
1694
|
+
] }),
|
|
1588
1695
|
actions.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-sep" }),
|
|
1589
1696
|
actions.map((a4) => /* @__PURE__ */ a3(
|
|
1590
1697
|
"button",
|
|
@@ -4879,6 +4986,13 @@ var CSS = (
|
|
|
4879
4986
|
.fnc-tools-seg[data-count="5"] button, .fnc-tools-seg[data-count="8"] button, .fnc-tools-seg[data-count="13"] button { flex-direction: column; gap: 2px; height: auto; min-height: 40px; padding: 5px 4px; font-size: 12px; white-space: normal; word-break: keep-all; text-align: center; line-height: 1.25; }
|
|
4880
4987
|
.fnc-tools-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0 6px; }
|
|
4881
4988
|
.fnc-tools-seg svg { width: 16px; height: 16px; flex: none; }
|
|
4989
|
+
.fnc-template-menu { min-width: 220px; }
|
|
4990
|
+
.fnc-template-row { display: flex; align-items: center; }
|
|
4991
|
+
.fnc-template-row .fnc-menu-item { flex: 1; min-width: 0; gap: 8px; }
|
|
4992
|
+
.fnc-template-row .fnc-menu-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
4993
|
+
.fnc-template-name { width: calc(100% - 8px); margin: 4px; }
|
|
4994
|
+
.fnc-menu-note { padding: 8px 10px; color: var(--fnc-text-2); font-size: 12px; }
|
|
4995
|
+
.fnc-menu-sep { height: 1px; margin: 4px 6px; background: var(--fnc-border); }
|
|
4882
4996
|
.fnc-tools-layouts { display: flex; flex-direction: column; gap: 2px; padding: 0 2px 4px; }
|
|
4883
4997
|
.fnc-tools-sep { height: 1px; margin: 6px 4px; background: var(--fnc-border); }
|
|
4884
4998
|
.fnc-tools-icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnest/charts-ui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
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.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"preact": "^11.2.0"
|