@funnest/charts-ui 0.6.11 → 0.6.13

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
@@ -76,6 +76,8 @@ export declare const STRINGS: {
76
76
  remove: string;
77
77
  color: string;
78
78
  customColor: string;
79
+ partColors: string;
80
+ resetColors: string;
79
81
  lineWidth: string;
80
82
  lineStyle: string;
81
83
  lineSolid: string;
@@ -218,6 +220,8 @@ export declare const STRINGS: {
218
220
  remove: string;
219
221
  color: string;
220
222
  customColor: string;
223
+ partColors: string;
224
+ resetColors: string;
221
225
  lineWidth: string;
222
226
  lineStyle: string;
223
227
  lineSolid: string;
package/dist/icons.d.ts CHANGED
@@ -56,6 +56,8 @@ export declare const CornerIcon: () => import("preact").JSX.Element;
56
56
  /** Sliders: the 도구 menu. */
57
57
  export declare const ToolsIcon: () => import("preact").JSX.Element;
58
58
  export declare const GripIcon: () => import("preact").JSX.Element;
59
+ /** Several colors (a tool's parts): a palette. */
60
+ export declare const PaletteIcon: () => import("preact").JSX.Element;
59
61
  export declare const LockIcon: ({ open }: {
60
62
  open?: boolean;
61
63
  }) => import("preact").JSX.Element;
package/dist/index.js CHANGED
@@ -499,6 +499,8 @@ var STRINGS = {
499
499
  remove: "\uC0AD\uC81C",
500
500
  color: "\uC0C9\uC0C1",
501
501
  customColor: "\uB2E4\uB978 \uC0C9",
502
+ partColors: "\uBD80\uBD84 \uC0C9\uC0C1",
503
+ resetColors: "\uAE30\uBCF8 \uC0C9\uC73C\uB85C",
502
504
  lineWidth: "\uC120 \uAD75\uAE30",
503
505
  lineStyle: "\uC120 \uBAA8\uC591",
504
506
  lineSolid: "\uC2E4\uC120",
@@ -643,6 +645,8 @@ var STRINGS = {
643
645
  remove: "Remove",
644
646
  color: "Color",
645
647
  customColor: "Other color",
648
+ partColors: "Part colors",
649
+ resetColors: "Reset colors",
646
650
  lineWidth: "Line width",
647
651
  lineStyle: "Line style",
648
652
  lineSolid: "Solid",
@@ -823,6 +827,7 @@ var EyeIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
823
827
  /* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.3" })
824
828
  ] });
825
829
  var EyeOffIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M3 3l14 14M8.2 5a8 8 0 0 1 1.8-.5c5 0 8 5.5 8 5.5a14 14 0 0 1-2.2 2.9M5.4 6.4A14 14 0 0 0 2 10s3 5.5 8 5.5a7.7 7.7 0 0 0 3.6-.9" }) });
830
+ var ChevronUpIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M5 12l5-5 5 5" }) });
826
831
  var MagnetIcon = () => /* @__PURE__ */ a3(Icon, { children: [
827
832
  /* @__PURE__ */ a3("path", { d: "M5 4h3v6.5a2 2 0 0 0 4 0V4h3v6.5a5 5 0 0 1-10 0z" }),
828
833
  /* @__PURE__ */ a3("path", { d: "M5 7h3M12 7h3" })
@@ -834,7 +839,6 @@ var StarIcon = ({ filled = false }) => /* @__PURE__ */ a3(Icon, { size: 16, chil
834
839
  fill: filled ? "currentColor" : "none"
835
840
  }
836
841
  ) });
837
- var CollapseLeftIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M11 5l-5 5 5 5M15 5l-5 5 5 5" }) });
838
842
  var SettingsIcon = () => /* @__PURE__ */ a3(Icon, { children: [
839
843
  /* @__PURE__ */ a3("path", { d: "M10 12.6a2.6 2.6 0 1 0 0-5.2 2.6 2.6 0 0 0 0 5.2z" }),
840
844
  /* @__PURE__ */ a3("path", { d: "M16.2 12a1.3 1.3 0 0 0 .26 1.43l.05.05a1.6 1.6 0 1 1-2.26 2.26l-.05-.05a1.3 1.3 0 0 0-1.43-.26 1.3 1.3 0 0 0-.79 1.19v.14a1.6 1.6 0 0 1-3.2 0v-.07a1.3 1.3 0 0 0-.85-1.19 1.3 1.3 0 0 0-1.43.26l-.05.05a1.6 1.6 0 1 1-2.26-2.26l.05-.05A1.3 1.3 0 0 0 4.5 12a1.3 1.3 0 0 0-1.19-.79h-.14a1.6 1.6 0 0 1 0-3.2h.07a1.3 1.3 0 0 0 1.19-.85 1.3 1.3 0 0 0-.26-1.43l-.05-.05a1.6 1.6 0 1 1 2.26-2.26l.05.05a1.3 1.3 0 0 0 1.43.26h.06a1.3 1.3 0 0 0 .79-1.19v-.14a1.6 1.6 0 0 1 3.2 0v.07a1.3 1.3 0 0 0 .79 1.19 1.3 1.3 0 0 0 1.43-.26l.05-.05a1.6 1.6 0 1 1 2.26 2.26l-.05.05a1.3 1.3 0 0 0-.26 1.43v.06a1.3 1.3 0 0 0 1.19.79h.14a1.6 1.6 0 0 1 0 3.2h-.07a1.3 1.3 0 0 0-1.19.79z" })
@@ -882,6 +886,10 @@ var ToolsIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: [
882
886
  /* @__PURE__ */ a3("circle", { cx: "7.5", cy: "14", r: "2" })
883
887
  ] });
884
888
  var GripIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("path", { d: "M7.5 5h.01M7.5 10h.01M7.5 15h.01M12.5 5h.01M12.5 10h.01M12.5 15h.01", "stroke-width": "2.4" }) });
889
+ var PaletteIcon = () => /* @__PURE__ */ a3(Icon, { children: [
890
+ /* @__PURE__ */ a3("path", { d: "M10 3.5a6.5 6.5 0 1 0 0 13c1 0 1.5-.6 1.5-1.3 0-.9-.8-1.2-.8-2 0-.7.6-1.2 1.4-1.2h1.6a2.8 2.8 0 0 0 2.8-2.8C16.5 6 13.6 3.5 10 3.5Z" }),
891
+ /* @__PURE__ */ a3("path", { d: "M6.6 9.2h.01M8.4 6.6h.01M11.6 6.4h.01M13.6 8.6h.01", "stroke-width": "2.2" })
892
+ ] });
885
893
  var LockIcon = ({ open = false }) => /* @__PURE__ */ a3(Icon, { children: [
886
894
  /* @__PURE__ */ a3("rect", { x: "4.5", y: "9", width: "11", height: "8", rx: "1.8" }),
887
895
  /* @__PURE__ */ a3("path", { d: open ? "M7 9V6.5a3 3 0 0 1 5.8-1" : "M7 9V6.5a3 3 0 0 1 6 0V9" })
@@ -964,8 +972,13 @@ function ToolGroup({
964
972
  A2(() => {
965
973
  if (!open) return;
966
974
  const close = (e3) => !ref.current?.contains(e3.target) && onOpen(false);
975
+ const esc = (e3) => e3.key === "Escape" && onOpen(false);
967
976
  document.addEventListener("pointerdown", close, true);
968
- return () => document.removeEventListener("pointerdown", close, true);
977
+ document.addEventListener("keydown", esc);
978
+ return () => {
979
+ document.removeEventListener("pointerdown", close, true);
980
+ document.removeEventListener("keydown", esc);
981
+ };
969
982
  }, [open]);
970
983
  const pick = (def) => {
971
984
  setChosen(def.type);
@@ -1099,7 +1112,14 @@ function SelectionBar({ ctx }) {
1099
1112
  const style = d3.style ?? {};
1100
1113
  const setStyle = (patch) => ctx.chart.updateDrawing(d3.id, { style: { ...style, ...patch } });
1101
1114
  const current = d3.color ?? SWATCHES[0];
1102
- const pickColor = (color) => ctx.chart.updateDrawing(d3.id, { color });
1115
+ const pickColor = (color) => {
1116
+ if (style.colors) {
1117
+ const { colors: _drop, ...rest } = style;
1118
+ ctx.chart.updateDrawing(d3.id, { color, style: rest });
1119
+ } else ctx.chart.updateDrawing(d3.id, { color });
1120
+ };
1121
+ const slots = def?.colors ?? [];
1122
+ const slotColor = (key, fallback) => style.colors?.[key] ?? d3.color ?? fallback;
1103
1123
  const addRecent = (color) => {
1104
1124
  const next = [color, ...recent.filter((c3) => c3 !== color)].slice(0, 3);
1105
1125
  setRecent(next);
@@ -1151,6 +1171,40 @@ function SelectionBar({ ctx }) {
1151
1171
  }
1152
1172
  )
1153
1173
  ] }),
1174
+ slots.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
1175
+ /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.partColors, "aria-label": t3.partColors, "aria-expanded": menu === "colors", onClick: () => setMenu(menu === "colors" ? null : "colors"), children: /* @__PURE__ */ a3(PaletteIcon, {}) }),
1176
+ menu === "colors" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-part-menu", role: "menu", children: [
1177
+ slots.map((slot) => {
1178
+ const c3 = slotColor(slot.key, slot.color);
1179
+ return /* @__PURE__ */ a3("label", { class: "fnc-menu-item fnc-part", children: [
1180
+ /* @__PURE__ */ a3("span", { class: "fnc-swatch", style: { background: c3 } }),
1181
+ /* @__PURE__ */ a3("span", { children: slot.name[s3.locale] }),
1182
+ /* @__PURE__ */ a3(
1183
+ "input",
1184
+ {
1185
+ type: "color",
1186
+ "aria-label": `${slot.name[s3.locale]} ${t3.color}`,
1187
+ value: /^#[0-9a-f]{6}$/i.test(c3) ? c3 : "#3182f6",
1188
+ onInput: (e3) => setStyle({ colors: { ...style.colors, [slot.key]: e3.target.value } })
1189
+ }
1190
+ )
1191
+ ] });
1192
+ }),
1193
+ /* @__PURE__ */ a3(
1194
+ "button",
1195
+ {
1196
+ class: "fnc-menu-item fnc-part-reset",
1197
+ role: "menuitem",
1198
+ onClick: () => {
1199
+ const { colors: _drop, ...rest } = style;
1200
+ ctx.chart.updateDrawing(d3.id, { style: rest });
1201
+ setMenu(null);
1202
+ },
1203
+ children: t3.resetColors
1204
+ }
1205
+ )
1206
+ ] })
1207
+ ] }),
1154
1208
  /* @__PURE__ */ a3("div", { class: "fnc-sep" }),
1155
1209
  /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
1156
1210
  /* @__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" }) }) }),
@@ -2553,7 +2607,7 @@ function Legend({ ctx }) {
2553
2607
  )
2554
2608
  ] })),
2555
2609
  !collapsed && overlayItems.map((item) => /* @__PURE__ */ a3(IndicatorItem, { ctx, item })),
2556
- overlayItems.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(CollapseLeftIcon, {}) }))
2610
+ overlayItems.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, {}) }))
2557
2611
  ] }),
2558
2612
  paneLegends.map(
2559
2613
  ({ pane, item }) => item && /* @__PURE__ */ a3("div", { class: "fnc-legend fnc-pane-legend", style: { top: `${pane.top + 4}px` }, children: /* @__PURE__ */ a3(IndicatorItem, { ctx, item }) })
@@ -2922,6 +2976,11 @@ var CSS = (
2922
2976
  .fnc-selbar-menu { position: relative; }
2923
2977
  .fnc-selbar-pop { top: calc(100% + 6px); left: 50%; transform: translateX(-50%); min-width: 110px; }
2924
2978
  .fnc-selbar-pop .fnc-menu-item { gap: 10px; }
2979
+ .fnc-part-menu { min-width: 150px; max-height: 320px; overflow-y: auto; }
2980
+ .fnc-part { position: relative; cursor: pointer; }
2981
+ .fnc-part .fnc-swatch { width: 14px; height: 14px; box-shadow: 0 0 0 1px var(--fnc-border); }
2982
+ .fnc-part input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
2983
+ .fnc-part-reset { margin-top: 4px; border-top: 1px solid var(--fnc-border); color: var(--fnc-text-2); }
2925
2984
  .fnc-selbar-text { width: 150px; height: 28px; padding: 0 8px; border: 1px solid var(--fnc-border); border-radius: var(--fnc-radius); background: var(--fnc-surface); color: var(--fnc-text); font: inherit; font-size: 13px; outline: none; }
2926
2985
  .fnc-selbar-text:focus { border-color: var(--fnc-text-2); }
2927
2986
  .fnc-overlay { pointer-events: none; }
@@ -3675,6 +3734,8 @@ var CSS = (
3675
3734
  .fnc-tool-group:hover .fnc-tool-chevron,
3676
3735
  .fnc-tool-more[aria-expanded='true'] .fnc-tool-chevron,
3677
3736
  .fnc-tool-more:focus-visible .fnc-tool-chevron { display: flex; }
3737
+ /* Once the list is open the tab has done its job: it fades out (clicking its spot still closes the list). */
3738
+ .fnc-tool-group[data-open='true'] .fnc-tool-more { opacity: 0; }
3678
3739
  @media (hover: none) {
3679
3740
  .fnc-tool-more { right: -12px; width: 14px; align-items: center; justify-content: center; padding: 0; }
3680
3741
  .fnc-tool-corner { display: none; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.6.11",
3
+ "version": "0.6.13",
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.6.11"
45
+ "@funnest/charts": "0.6.13"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"