@funnest/charts-ui 0.6.11 → 0.6.12

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",
@@ -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" }) }) }),
@@ -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.12",
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.12"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"