@luxalgo/vela 0.7.6 → 0.7.8

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.
@@ -1,4 +1,4 @@
1
- import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-BKHSQ4YM.js';
1
+ import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-WTWGEB7K.js';
2
2
  import { injectStyles } from './chunk-CAFCLMPF.js';
3
3
  import * as tooltip from '@zag-js/tooltip';
4
4
  import * as dialog from '@zag-js/dialog';
@@ -2177,7 +2177,8 @@ function addRecent(hex6) {
2177
2177
  recents.unshift(hex6);
2178
2178
  if (recents.length > 10) recents.length = 10;
2179
2179
  }
2180
- function buildColorPicker(color, theme, onChange) {
2180
+ function buildColorPicker(color, theme, onChange, options = {}) {
2181
+ const commit = options.commit ?? "live";
2181
2182
  const parsed = splitColor(color);
2182
2183
  let curHex = parsed.hex6;
2183
2184
  let curAlpha = parsed.alpha;
@@ -2260,7 +2261,12 @@ function buildColorPicker(color, theme, onChange) {
2260
2261
  const r = track.getBoundingClientRect();
2261
2262
  curAlpha = Math.max(0, Math.min(1, (clientX - r.left) / r.width));
2262
2263
  paintOpacity();
2263
- emit();
2264
+ if (commit === "live") emit();
2265
+ };
2266
+ const endDrag = () => {
2267
+ if (!dragging) return;
2268
+ dragging = false;
2269
+ if (commit === "release") emit();
2264
2270
  };
2265
2271
  track.addEventListener("pointerdown", (e) => {
2266
2272
  e.stopPropagation();
@@ -2271,7 +2277,8 @@ function buildColorPicker(color, theme, onChange) {
2271
2277
  track.addEventListener("pointermove", (e) => {
2272
2278
  if (dragging) onDrag(e.clientX);
2273
2279
  });
2274
- track.addEventListener("pointerup", () => dragging = false);
2280
+ track.addEventListener("pointerup", endDrag);
2281
+ track.addEventListener("pointercancel", endDrag);
2275
2282
  function emit() {
2276
2283
  onChange(combineColor(curHex, curAlpha));
2277
2284
  }
@@ -2294,7 +2301,7 @@ function buildColorPicker(color, theme, onChange) {
2294
2301
  return root;
2295
2302
  }
2296
2303
  function colorField(theme, getVal, onVal, opts) {
2297
- return new ColorField({ theme, getVal, onVal, shape: opts?.shape, id: opts?.id, popover: opts?.popover }).el;
2304
+ return new ColorField({ theme, getVal, onVal, shape: opts?.shape, id: opts?.id, popover: opts?.popover, commit: opts?.commit }).el;
2298
2305
  }
2299
2306
  var ColorField = class {
2300
2307
  constructor(opts) {
@@ -2303,6 +2310,7 @@ var ColorField = class {
2303
2310
  this.getVal = opts.getVal;
2304
2311
  this.onVal = opts.onVal;
2305
2312
  this.popoverOpts = opts.popover;
2313
+ this.commit = opts.commit;
2306
2314
  const trigger = document.createElement("button");
2307
2315
  trigger.type = "button";
2308
2316
  if (opts.id) trigger.id = opts.id;
@@ -2342,10 +2350,15 @@ var ColorField = class {
2342
2350
  boundary: this.popoverOpts?.boundary,
2343
2351
  zIndex: this.popoverOpts?.zIndex,
2344
2352
  className: "vela-color-field-pop",
2345
- content: buildColorPicker(this.getVal(), this.theme, (val) => {
2346
- this.onVal(val);
2347
- this.paint();
2348
- })
2353
+ content: buildColorPicker(
2354
+ this.getVal(),
2355
+ this.theme,
2356
+ (val) => {
2357
+ this.onVal(val);
2358
+ this.paint();
2359
+ },
2360
+ { commit: this.commit }
2361
+ )
2349
2362
  });
2350
2363
  pop.show();
2351
2364
  }
@@ -2829,7 +2842,8 @@ function buildFieldControl(desc) {
2829
2842
  const el2 = colorField(desc.theme, desc.get, desc.onChange, {
2830
2843
  shape: "circle",
2831
2844
  id: desc.id,
2832
- popover: desc.popover
2845
+ popover: desc.popover,
2846
+ commit: desc.commit
2833
2847
  });
2834
2848
  if (desc.title) el2.title = desc.title;
2835
2849
  return { el: el2 };
@@ -47,6 +47,23 @@ interface StrategyTrade {
47
47
  exit?: StrategyFill;
48
48
  /** Still open at the last computed bar. */
49
49
  open: boolean;
50
+ /**
51
+ * Realized P&L of this round trip in account currency, net of commission. Absent
52
+ * while the trade is open, and for an engine that reports no per-trade ledger.
53
+ */
54
+ pnl?: number;
55
+ /** Commission charged on this trade, in account currency. */
56
+ commission?: number;
57
+ /**
58
+ * Worst / best unrealized excursion of THIS trade from its entry, in account
59
+ * currency (positive magnitudes). Read `maxDrawdown` as the adverse excursion and
60
+ * `maxRunup` as the favorable one — the per-trade counterparts of the account-level
61
+ * {@link StrategyState.maxDrawdown} / {@link StrategyState.maxRunup}. An engine
62
+ * defines the exact convention (intrabar extremes, commission handling); absent when
63
+ * it does not track them.
64
+ */
65
+ maxDrawdown?: number;
66
+ maxRunup?: number;
50
67
  }
51
68
  /** One side of a {@link StrategyTrade}. */
52
69
  interface StrategyFill {
@@ -47,6 +47,23 @@ interface StrategyTrade {
47
47
  exit?: StrategyFill;
48
48
  /** Still open at the last computed bar. */
49
49
  open: boolean;
50
+ /**
51
+ * Realized P&L of this round trip in account currency, net of commission. Absent
52
+ * while the trade is open, and for an engine that reports no per-trade ledger.
53
+ */
54
+ pnl?: number;
55
+ /** Commission charged on this trade, in account currency. */
56
+ commission?: number;
57
+ /**
58
+ * Worst / best unrealized excursion of THIS trade from its entry, in account
59
+ * currency (positive magnitudes). Read `maxDrawdown` as the adverse excursion and
60
+ * `maxRunup` as the favorable one — the per-trade counterparts of the account-level
61
+ * {@link StrategyState.maxDrawdown} / {@link StrategyState.maxRunup}. An engine
62
+ * defines the exact convention (intrabar extremes, commission handling); absent when
63
+ * it does not track them.
64
+ */
65
+ maxDrawdown?: number;
66
+ maxRunup?: number;
50
67
  }
51
68
  /** One side of a {@link StrategyTrade}. */
52
69
  interface StrategyFill {