@funnest/charts-ui 0.11.67 → 0.11.69

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/context.d.ts CHANGED
@@ -196,6 +196,8 @@ export interface WidgetContext {
196
196
  showLogo: boolean;
197
197
  /** Ctrl/⌘+K opens symbol search (off when the page uses the shortcut for its own search). */
198
198
  searchHotkey: boolean;
199
+ /** ChartOptions.keyboardShortcuts: false — no key hints (Ctrl+Z…) in the menus either. */
200
+ keyboardShortcuts: boolean;
199
201
  drawingToolbar: boolean;
200
202
  /** Show the Funnest logo badge on the chart. */
201
203
  attribution: boolean;
package/dist/index.js CHANGED
@@ -2176,6 +2176,9 @@ var CSS = (
2176
2176
  }
2177
2177
  .fnc-selbar-action.is-text { width: auto; padding: 0 8px; font-size: 12px; font-weight: 600; }
2178
2178
  .fnc-selbar-action.is-on { color: var(--fnc-accent); }
2179
+ /* \uC0AD\uC81C turns red and \uC54C\uB9BC yellow under the mouse. */
2180
+ .fnc-selbar .fnc-selbar-delete:hover { background: color-mix(in srgb, var(--fnc-danger, #F04452) 14%, transparent); color: var(--fnc-danger, #F04452); }
2181
+ .fnc-selbar .fnc-selbar-action.is-alert:hover { background: color-mix(in srgb, #FFB400 20%, transparent); color: #D99A00; }
2179
2182
  .fnc-selbar-action.is-on svg path:first-child { fill: currentColor; }
2180
2183
  .fnc-axis-plus-menu .fnc-menu-item { color: var(--fnc-text); font-weight: 600; }
2181
2184
  /* A menu row's glyph: one 18px column, so every label starts at the same x. */
@@ -2649,7 +2652,7 @@ var CSS = (
2649
2652
  .fnc-menu-note { padding: 8px 10px; color: var(--fnc-text-2); font-size: 12px; }
2650
2653
  .fnc-menu-sep { height: 1px; margin: 4px 6px; background: var(--fnc-border); }
2651
2654
  /* \u22EF on the drawing bar: \uBCF5\uC81C \xB7 \uBCF5\uC0AC \xB7 \uBD99\uC5EC\uB123\uAE30, then \uC21C\uC11C. */
2652
- .fnc-more-menu { min-width: 180px; }
2655
+ .fnc-more-menu { min-width: 220px; }
2653
2656
  .fnc-more-menu .fnc-menu-item kbd { margin-left: auto; font: inherit; font-size: 12px; color: var(--fnc-text-3); }
2654
2657
  .fnc-more-title { padding: 6px 10px 2px; font-size: 11px; font-weight: 700; color: var(--fnc-text-2); }
2655
2658
  .fnc-tools-layouts { display: flex; flex-direction: column; gap: 2px; padding: 0 2px 4px; }
@@ -3442,7 +3445,7 @@ function createShell(container, options) {
3442
3445
  }
3443
3446
  };
3444
3447
  }
3445
- function bindWidgetKeys(shell, active, searchHotkey, extra) {
3448
+ function bindWidgetKeys(shell, active, searchHotkey, extra, shortcuts = true) {
3446
3449
  const { root } = shell;
3447
3450
  let focused = false;
3448
3451
  const onPointerDown = (e3) => focused = root.contains(e3.target);
@@ -3453,7 +3456,7 @@ function bindWidgetKeys(shell, active, searchHotkey, extra) {
3453
3456
  const target = e3.target;
3454
3457
  const typing = !!target && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName));
3455
3458
  const key = e3.key.toLowerCase();
3456
- if (focused && !typing && !s3.dialog && !s3.searchOpen && (e3.ctrlKey || e3.metaKey) && !e3.altKey && (key === "z" || key === "y")) {
3459
+ if (shortcuts && focused && !typing && !s3.dialog && !s3.searchOpen && (e3.ctrlKey || e3.metaKey) && !e3.altKey && (key === "z" || key === "y")) {
3457
3460
  e3.preventDefault();
3458
3461
  if (key === "y" || e3.shiftKey) pane.chart.redo();
3459
3462
  else pane.chart.undo();
@@ -3473,7 +3476,7 @@ function bindWidgetKeys(shell, active, searchHotkey, extra) {
3473
3476
  shell.toggleFullscreen();
3474
3477
  return;
3475
3478
  }
3476
- if (extra?.(e3)) e3.preventDefault();
3479
+ if (shortcuts && extra?.(e3)) e3.preventDefault();
3477
3480
  };
3478
3481
  const onKeyUp = (e3) => {
3479
3482
  const pane = active();
@@ -3944,10 +3947,6 @@ var LevelsIcon = () => /* @__PURE__ */ a3(Icon, { children: [
3944
3947
  /* @__PURE__ */ a3("circle", { cx: "15", cy: "5", r: "1.4" }),
3945
3948
  /* @__PURE__ */ a3("circle", { cx: "17", cy: "15", r: "1.4" })
3946
3949
  ] });
3947
- var TemplateIcon = () => /* @__PURE__ */ a3(Icon, { children: [
3948
- /* @__PURE__ */ a3("rect", { x: "3", y: "7", width: "10", height: "10", rx: "2" }),
3949
- /* @__PURE__ */ a3("path", { d: "M7 4h8a2 2 0 0 1 2 2v8" })
3950
- ] });
3951
3950
  var SmallPlusIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M5 10h10M10 5v10" }) });
3952
3951
  var SmallCloseIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M6 6l8 8M14 6l-8 8" }) });
3953
3952
  var EyeIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
@@ -4607,6 +4606,12 @@ function SelectionBar({ ctx }) {
4607
4606
  const [menu, setMenu] = d2(null);
4608
4607
  const [sheet, setSheet] = d2(false);
4609
4608
  const [settingsTab, setSettingsTab] = d2("options");
4609
+ const selectedId = d3?.id ?? null;
4610
+ A2(() => {
4611
+ setMenu(null);
4612
+ setSheet(false);
4613
+ setNaming(null);
4614
+ }, [selectedId]);
4610
4615
  const [templates, setTemplates] = d2(() => readJson(TEMPLATES_KEY, {}));
4611
4616
  const [naming, setNaming] = d2(null);
4612
4617
  const bar = T2(null);
@@ -5091,48 +5096,11 @@ function SelectionBar({ ctx }) {
5091
5096
  ] })
5092
5097
  ] })
5093
5098
  ] }),
5094
- phone && /* @__PURE__ */ a3(
5095
- "button",
5096
- {
5097
- class: "fnc-btn",
5098
- "aria-label": t3.style,
5099
- "aria-expanded": sheet,
5100
- onClick: () => {
5101
- setMenu(null);
5102
- setSheet(true);
5103
- },
5104
- children: /* @__PURE__ */ a3(SettingsIcon, {})
5105
- }
5106
- ),
5107
5099
  !phone && /* @__PURE__ */ a3($, { children: [
5108
5100
  slots.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
5109
5101
  /* @__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, {}) }),
5110
5102
  menu === "colors" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-part-menu", role: "menu", children: colorsBody() })
5111
5103
  ] }),
5112
- def && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
5113
- /* @__PURE__ */ a3(
5114
- "button",
5115
- {
5116
- class: style.intervals ? "fnc-btn fnc-btn-on" : "fnc-btn",
5117
- "data-tip": t3.drawingOptions,
5118
- "aria-label": t3.drawingOptions,
5119
- "aria-expanded": menu === "options",
5120
- onClick: () => {
5121
- setSettingsTab(hasOptions ? "options" : "coords");
5122
- setMenu(menu === "options" ? null : "options");
5123
- },
5124
- children: /* @__PURE__ */ a3(SettingsIcon, {})
5125
- }
5126
- ),
5127
- menu === "options" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-options-menu fnc-settings-pop", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
5128
- /* @__PURE__ */ a3("div", { class: "fnc-tabs", role: "tablist", "aria-label": t3.drawingOptions, children: settingsTabs.map(([k2, label]) => /* @__PURE__ */ a3("button", { type: "button", class: "fnc-tab", role: "tab", "aria-selected": settingsTab === k2, onClick: () => setSettingsTab(k2), children: label })) }),
5129
- /* @__PURE__ */ a3("div", { class: "fnc-settings-pop-body", children: [
5130
- settingsTab === "options" && hasOptions && optionsBody(),
5131
- settingsTab === "coords" && coordsBody(),
5132
- settingsTab === "visibility" && visibilityBody()
5133
- ] })
5134
- ] })
5135
- ] }),
5136
5104
  def?.levels && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
5137
5105
  /* @__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, {}) }),
5138
5106
  menu === "levels" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-levels-menu", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: levelsBody() })
@@ -5202,30 +5170,13 @@ function SelectionBar({ ctx }) {
5202
5170
  ] })
5203
5171
  }
5204
5172
  )) })
5205
- ] }),
5206
- /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
5207
- /* @__PURE__ */ a3(
5208
- "button",
5209
- {
5210
- class: "fnc-btn",
5211
- "data-tip": t3.templates,
5212
- "aria-label": t3.templates,
5213
- "aria-expanded": menu === "template",
5214
- onClick: () => {
5215
- setNaming(null);
5216
- setMenu(menu === "template" ? null : "template");
5217
- },
5218
- children: /* @__PURE__ */ a3(TemplateIcon, {})
5219
- }
5220
- ),
5221
- menu === "template" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-template-menu", role: "menu", children: templateBody() })
5222
5173
  ] })
5223
5174
  ] }),
5224
5175
  actions.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-sep" }),
5225
5176
  actions.map((a4) => /* @__PURE__ */ a3(
5226
5177
  "button",
5227
5178
  {
5228
- class: `fnc-btn fnc-selbar-action${a4.icon ? "" : " is-text"}${a4.pressed ? " is-on" : ""}`,
5179
+ class: `fnc-btn fnc-selbar-action${a4.icon ? "" : " is-text"}${a4.icon === "alert" ? " is-alert" : ""}${a4.pressed ? " is-on" : ""}`,
5229
5180
  "data-tip": a4.label,
5230
5181
  "aria-label": a4.label,
5231
5182
  "aria-pressed": a4.pressed,
@@ -5240,7 +5191,20 @@ function SelectionBar({ ctx }) {
5240
5191
  !phone && /* @__PURE__ */ a3($, {}),
5241
5192
  /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": locked ? t3.unlock : t3.lock, "aria-label": locked ? t3.unlock : t3.lock, "aria-pressed": locked, onClick: () => setStyle({ locked: !locked }), children: /* @__PURE__ */ a3(LockIcon, { open: !locked }) }),
5242
5193
  /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
5243
- /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.moreActions, "aria-label": t3.moreActions, "aria-expanded": menu === "more", onClick: () => setMenu(menu === "more" ? null : "more"), children: /* @__PURE__ */ a3(MoreIcon, {}) }),
5194
+ /* @__PURE__ */ a3(
5195
+ "button",
5196
+ {
5197
+ class: "fnc-btn",
5198
+ "data-tip": t3.moreActions,
5199
+ "aria-label": t3.moreActions,
5200
+ "aria-expanded": menu === "more",
5201
+ onClick: () => {
5202
+ setNaming(null);
5203
+ setMenu(menu === "more" ? null : "more");
5204
+ },
5205
+ children: /* @__PURE__ */ a3(MoreIcon, {})
5206
+ }
5207
+ ),
5244
5208
  menu === "more" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-more-menu", role: "menu", children: [
5245
5209
  /* @__PURE__ */ a3(
5246
5210
  "button",
@@ -5293,10 +5257,52 @@ function SelectionBar({ ctx }) {
5293
5257
  ),
5294
5258
  /* @__PURE__ */ a3("div", { class: "fnc-menu-sep", role: "separator" }),
5295
5259
  /* @__PURE__ */ a3("div", { class: "fnc-more-title", children: t3.drawingOrder }),
5296
- orderBody()
5260
+ orderBody(),
5261
+ !phone && /* @__PURE__ */ a3($, { children: [
5262
+ /* @__PURE__ */ a3("div", { class: "fnc-menu-sep", role: "separator" }),
5263
+ /* @__PURE__ */ a3("div", { class: "fnc-more-title", children: t3.templates }),
5264
+ templateBody()
5265
+ ] })
5297
5266
  ] })
5298
5267
  ] }),
5299
- /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.remove, "aria-label": t3.remove, onClick: () => ctx.chart.removeDrawing(d3.id), children: /* @__PURE__ */ a3(TrashIcon, {}) }),
5268
+ phone && /* @__PURE__ */ a3(
5269
+ "button",
5270
+ {
5271
+ class: "fnc-btn",
5272
+ "aria-label": t3.style,
5273
+ "aria-expanded": sheet,
5274
+ onClick: () => {
5275
+ setMenu(null);
5276
+ setSheet(true);
5277
+ },
5278
+ children: /* @__PURE__ */ a3(SettingsIcon, {})
5279
+ }
5280
+ ),
5281
+ !phone && def && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
5282
+ /* @__PURE__ */ a3(
5283
+ "button",
5284
+ {
5285
+ class: style.intervals ? "fnc-btn fnc-btn-on" : "fnc-btn",
5286
+ "data-tip": t3.drawingOptions,
5287
+ "aria-label": t3.drawingOptions,
5288
+ "aria-expanded": menu === "options",
5289
+ onClick: () => {
5290
+ setSettingsTab(hasOptions ? "options" : "coords");
5291
+ setMenu(menu === "options" ? null : "options");
5292
+ },
5293
+ children: /* @__PURE__ */ a3(SettingsIcon, {})
5294
+ }
5295
+ ),
5296
+ menu === "options" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-options-menu fnc-settings-pop", role: "menu", onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
5297
+ /* @__PURE__ */ a3("div", { class: "fnc-tabs", role: "tablist", "aria-label": t3.drawingOptions, children: settingsTabs.map(([k2, label]) => /* @__PURE__ */ a3("button", { type: "button", class: "fnc-tab", role: "tab", "aria-selected": settingsTab === k2, onClick: () => setSettingsTab(k2), children: label })) }),
5298
+ /* @__PURE__ */ a3("div", { class: "fnc-settings-pop-body", children: [
5299
+ settingsTab === "options" && hasOptions && optionsBody(),
5300
+ settingsTab === "coords" && coordsBody(),
5301
+ settingsTab === "visibility" && visibilityBody()
5302
+ ] })
5303
+ ] })
5304
+ ] }),
5305
+ /* @__PURE__ */ a3("button", { class: "fnc-btn fnc-selbar-delete", "data-tip": t3.remove, "aria-label": t3.remove, onClick: () => ctx.chart.removeDrawing(d3.id), children: /* @__PURE__ */ a3(TrashIcon, {}) }),
5300
5306
  phone && sheet && /* @__PURE__ */ a3(StyleSheet, { ctx, title: t3.style, resetLabel: t3.resetDefaults, onReset: resetLook, onClose: () => setSheet(false), children: [
5301
5307
  !def?.plain && /* @__PURE__ */ a3("section", { class: "fnc-ss-section", children: [
5302
5308
  /* @__PURE__ */ a3("div", { class: "fnc-ss-row", children: [
@@ -8236,8 +8242,8 @@ function ContextMenu({ ctx }) {
8236
8242
  const mod = mac ? "\u2318" : "Ctrl+";
8237
8243
  const extra = ctx.contextMenuItems?.({ ...target, chart: ctx.chart }) ?? [];
8238
8244
  const items = [
8239
- { label: t3.undo, icon: "undo", shortcut: `${mod}Z`, disabled: !s3.canUndo, onSelect: () => ctx.chart.undo() },
8240
- { label: t3.redo, icon: "redo", shortcut: `${mod}${mac ? "\u21E7" : "Shift+"}Z`, disabled: !s3.canRedo, onSelect: () => ctx.chart.redo() },
8245
+ { label: t3.undo, icon: "undo", ...ctx.keyboardShortcuts ? { shortcut: `${mod}Z` } : {}, disabled: !s3.canUndo, onSelect: () => ctx.chart.undo() },
8246
+ { label: t3.redo, icon: "redo", ...ctx.keyboardShortcuts ? { shortcut: `${mod}${mac ? "\u21E7" : "Shift+"}Z` } : {}, disabled: !s3.canRedo, onSelect: () => ctx.chart.redo() },
8241
8247
  "separator",
8242
8248
  ...extra.length ? [...extra, "separator"] : []
8243
8249
  ];
@@ -9135,6 +9141,7 @@ function createPane(shell, config) {
9135
9141
  displayTimezone: config.displayTimezone,
9136
9142
  showLogo: config.symbolLogo,
9137
9143
  searchHotkey: config.searchHotkey,
9144
+ keyboardShortcuts: config.chartOptions.keyboardShortcuts !== false,
9138
9145
  drawingToolbar: config.drawingToolbar,
9139
9146
  attribution: config.attribution,
9140
9147
  contextMenuItems: config.contextMenuItems,
@@ -9287,7 +9294,7 @@ function createTradingChart(container, options) {
9287
9294
  });
9288
9295
  shell.main.insertBefore(pane.stage, shell.rangeHost);
9289
9296
  shell.setPanes(() => [pane]);
9290
- const unbindKeys = bindWidgetKeys(shell, () => pane, searchHotkey);
9297
+ const unbindKeys = bindWidgetKeys(shell, () => pane, searchHotkey, void 0, chartOptions.keyboardShortcuts !== false);
9291
9298
  Q(/* @__PURE__ */ a3(Toolbar, { ctx: pane.ctx }), shell.toolbarHost);
9292
9299
  Q(/* @__PURE__ */ a3(RangeBar, { ctx: pane.ctx }), shell.rangeHost);
9293
9300
  if (shell.drawbarHost) Q(/* @__PURE__ */ a3(DrawingToolbar, { ctx: pane.ctx }), shell.drawbarHost);
@@ -9721,7 +9728,8 @@ function createMultiChart(container, options) {
9721
9728
  if (!digit) return false;
9722
9729
  activate(Number(digit) - 1);
9723
9730
  return true;
9724
- }
9731
+ },
9732
+ chartOptions.keyboardShortcuts !== false
9725
9733
  );
9726
9734
  const save = () => {
9727
9735
  const s3 = store.get();
package/dist/shell.d.ts CHANGED
@@ -129,4 +129,6 @@ export declare function bindWidgetKeys(shell: Shell, active: () => {
129
129
  undo(): void;
130
130
  redo(): void;
131
131
  };
132
- } | null, searchHotkey: boolean, extra?: (e: KeyboardEvent) => boolean): () => void;
132
+ } | null, searchHotkey: boolean, extra?: (e: KeyboardEvent) => boolean,
133
+ /** ChartOptions.keyboardShortcuts: false leaves Ctrl+Z / Ctrl+Y and `extra` to the app (Esc still closes). */
134
+ shortcuts?: boolean): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.11.67",
3
+ "version": "0.11.69",
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.11.67"
45
+ "@funnest/charts": "0.11.69"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"