@gearbox-protocol/ui-kit 4.0.0-next.63 → 4.0.0-next.65

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.
Files changed (45) hide show
  1. package/dist/cjs/components/base/leverage-input/leverage-input.cjs +1 -1
  2. package/dist/cjs/components/base/leverage-preset-chips/leverage-preset-chips.cjs +1 -1
  3. package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
  4. package/dist/cjs/components/graph/graph.cjs +1 -1
  5. package/dist/cjs/components/graph/series-config.cjs +1 -1
  6. package/dist/cjs/components/index.cjs +1 -1
  7. package/dist/cjs/components/trading-view/constants.cjs +1 -0
  8. package/dist/cjs/components/trading-view/index.cjs +1 -1
  9. package/dist/cjs/components/trading-view/price-scale-titles.cjs +1 -0
  10. package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
  11. package/dist/cjs/index.cjs +1 -1
  12. package/dist/cjs/locale/en.json.cjs +1 -1
  13. package/dist/cjs/utils/format-leverage.cjs +1 -1
  14. package/dist/cjs/utils/index.cjs +1 -1
  15. package/dist/cjs/utils/leverage-presets.cjs +1 -1
  16. package/dist/esm/components/base/leverage-input/leverage-input.js +31 -31
  17. package/dist/esm/components/base/leverage-preset-chips/leverage-preset-chips.js +6 -6
  18. package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +30 -30
  19. package/dist/esm/components/graph/graph.js +257 -266
  20. package/dist/esm/components/graph/series-config.js +10 -1
  21. package/dist/esm/components/index.js +70 -68
  22. package/dist/esm/components/trading-view/constants.js +7 -0
  23. package/dist/esm/components/trading-view/index.js +4 -2
  24. package/dist/esm/components/trading-view/price-scale-titles.js +52 -0
  25. package/dist/esm/components/trading-view/trading-view.js +119 -115
  26. package/dist/esm/index.js +230 -227
  27. package/dist/esm/locale/en.json.js +1 -1
  28. package/dist/esm/utils/format-leverage.js +8 -3
  29. package/dist/esm/utils/index.js +18 -17
  30. package/dist/esm/utils/leverage-presets.js +4 -6
  31. package/dist/globals.css +1 -1
  32. package/dist/types/components/base/leverage-input/leverage-input.d.ts +2 -2
  33. package/dist/types/components/graph/graph.d.ts +1 -5
  34. package/dist/types/components/graph/series-config.d.ts +13 -0
  35. package/dist/types/components/trading-view/constants.d.ts +4 -0
  36. package/dist/types/components/trading-view/index.d.ts +1 -0
  37. package/dist/types/components/trading-view/price-scale-titles.d.ts +16 -0
  38. package/dist/types/components/trading-view/trading-view.d.ts +1 -1
  39. package/dist/types/locale/en.json.d.ts +1 -1
  40. package/dist/types/utils/format-leverage.d.ts +9 -1
  41. package/dist/types/utils/leverage-presets.d.ts +3 -1
  42. package/package.json +1 -1
  43. package/dist/cjs/components/base/leverage-preset-chips/format-chip-leverage.cjs +0 -1
  44. package/dist/esm/components/base/leverage-preset-chips/format-chip-leverage.js +0 -6
  45. package/dist/types/components/base/leverage-preset-chips/format-chip-leverage.d.ts +0 -5
@@ -16,7 +16,6 @@ export interface LeverageInputProps {
16
16
  readonly onChange: (value: Leverage) => void;
17
17
  readonly max: Leverage;
18
18
  readonly min?: Leverage;
19
- readonly step?: number;
20
19
  /** Label above the slider; defaults to the "Leverage" locale string. */
21
20
  readonly title?: TitleText;
22
21
  /** Muted note rendered right after the label. */
@@ -37,7 +36,8 @@ export interface LeverageInputProps {
37
36
  type TitleSize = "sm" | "default" | "md" | "lg";
38
37
  /**
39
38
  * Target leverage of a position, bounded by what the strategy allows.
40
- * Title row carries an inline-editable value (`N.NNx`) and an optional reset;
39
+ * Title row carries an inline-editable value (`N.Nx`, hundredths kept where the
40
+ * value has them) and an optional reset;
41
41
  * the slider below can show risk bands via `colorIntervals`.
42
42
  */
43
43
  export declare function LeverageInput({ value, onChange, max, min, title, hint, reset, colorIntervals, colorIntervalLabel, size, }: LeverageInputProps): React.ReactElement;
@@ -123,10 +123,6 @@ export interface GraphProps {
123
123
  dualYAxis?: boolean;
124
124
  /** Preferred default price scale when both left and right are visible. */
125
125
  defaultVisiblePriceScaleId?: SeriesPriceScaleId;
126
- /** Optional label for the left Y axis (dualYAxis mode). */
127
- leftPriceScaleTitle?: string;
128
- /** Optional label for the right Y axis (dualYAxis mode). */
129
- rightPriceScaleTitle?: string;
130
126
  /**
131
127
  * When true (default), shows the current value and date in the top-left corner
132
128
  * in single-series mode. Set to false to hide.
@@ -173,7 +169,7 @@ export interface GraphProps {
173
169
  * with support for area series, custom tooltips, and vertical line annotations
174
170
  * Supports single or multiple series with different colors and legends
175
171
  */
176
- export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, priceLineOptions, zoneOptions, currentValueDecimals, useSharedPriceScale, dualYAxis, defaultVisiblePriceScaleId, leftPriceScaleTitle, rightPriceScaleTitle: _rightPriceScaleTitle, showCurrentValue, graphTitle, yScaleMin, yScaleMinMultiple, visibleTimeFrom, disableZoom, hideDefaultTooltip, }: GraphProps): React.ReactElement;
172
+ export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, priceLineOptions, zoneOptions, currentValueDecimals, useSharedPriceScale, dualYAxis, defaultVisiblePriceScaleId, showCurrentValue, graphTitle, yScaleMin, yScaleMinMultiple, visibleTimeFrom, disableZoom, hideDefaultTooltip, }: GraphProps): React.ReactElement;
177
173
  /**
178
174
  * A legend entry that is not a data series — a vertical marker line, say.
179
175
  * Such a line is drawn by its own layer and never reaches `series`, so
@@ -29,3 +29,16 @@ export interface SeriesConfig {
29
29
  /** Line dash style (line series only). */
30
30
  lineStyle?: LineStyle;
31
31
  }
32
+ /**
33
+ * The left/right split the chart draws in `dualYAxis` mode: an explicit
34
+ * `priceScaleId` wins, otherwise the first series takes the left scale and the
35
+ * rest the right one.
36
+ *
37
+ * Only series carrying points advance that count, because a series with none is
38
+ * never added to the chart — counting it would push every series after it onto
39
+ * the wrong axis.
40
+ */
41
+ export declare function resolvePriceScaleSides(series: ReadonlyArray<SeriesConfig>): Array<{
42
+ series: SeriesConfig;
43
+ side: SeriesPriceScaleId;
44
+ }>;
@@ -0,0 +1,4 @@
1
+ export declare class TradingViewTest {
2
+ static priceScaleTitles: string;
3
+ static priceScaleTitle: (side: "left" | "right") => string;
4
+ }
@@ -1 +1,2 @@
1
+ export * from './constants';
1
2
  export * from './trading-view';
@@ -0,0 +1,16 @@
1
+ import { SeriesConfig } from '../graph/series-config';
2
+ import type * as React from "react";
3
+ export interface PriceScaleTitlesProps {
4
+ /** Pass the list the legend is built from, so the two always agree. */
5
+ readonly series: ReadonlyArray<SeriesConfig>;
6
+ }
7
+ /**
8
+ * Names the series on each Y axis, above the chart frame.
9
+ *
10
+ * Two scales and nothing on the canvas says which line is read against which,
11
+ * and lightweight-charts has no price-scale title of its own. Sitting above the
12
+ * frame rather than over the plot keeps it off the series, and the wording is
13
+ * the legend label, so the two can never disagree about what a series is
14
+ * called.
15
+ */
16
+ export declare function PriceScaleTitles({ series, }: PriceScaleTitlesProps): React.ReactElement;
@@ -189,4 +189,4 @@ export interface TradingViewProps<T extends string = string, TRange extends stri
189
189
  * />
190
190
  * ```
191
191
  */
192
- export declare function TradingView<T extends string = string, TRange extends string = string>({ data, yMeasureUnit, height, defaultGraph, onGraphSelected, graphs, isMultipleSelect, range, rangeList, setRange, onGraphExpanded, isGraphExpanded, onUnselectSeries, legendMarkers, graphsWithNoData, loadingGraphs, isLoading: isLoadingProp, noDataMessage, currentValueDecimals, containerClassName, useSharedPriceScale, showCurrentValue, yScaleMin, yScaleMinMultiple, seriesColorPersistenceKey, title, trailing, ...restProps }: TradingViewProps<T, TRange>): React.ReactElement;
192
+ export declare function TradingView<T extends string = string, TRange extends string = string>({ data, yMeasureUnit, height, defaultGraph, onGraphSelected, graphs, isMultipleSelect, range, rangeList, setRange, onGraphExpanded, isGraphExpanded, onUnselectSeries, legendMarkers, graphsWithNoData, loadingGraphs, isLoading: isLoadingProp, noDataMessage, currentValueDecimals, containerClassName, useSharedPriceScale, dualYAxis, showCurrentValue, yScaleMin, yScaleMinMultiple, seriesColorPersistenceKey, title, trailing, ...restProps }: TradingViewProps<T, TRange>): React.ReactElement;
@@ -30,7 +30,7 @@ declare const _default: {
30
30
  "components.apyParts.totalAPY": "Overall APY",
31
31
 
32
32
  "components.yieldBreakdown.titleNetAtLeverage": "Net APY at {leverage}× Leverage",
33
- "components.yieldBreakdown.titleNetAtLeverage7d": "Net APY at {leverage}× Leverage (7d)",
33
+ "components.yieldBreakdown.titleNetAtLeverage7d": "Net APY (7d) at {leverage}× Leverage",
34
34
  "components.yieldBreakdown.titleNet": "Net APY",
35
35
  "components.yieldBreakdown.titleNet7d": "Net APY (7d)",
36
36
  "components.yieldBreakdown.collateralApy": "Collateral APY",
@@ -1,5 +1,13 @@
1
1
  /**
2
- * Display leverage with two decimal places, e.g. `5.79` for `5.7857…`.
2
+ * Display leverage with one decimal place, e.g. `5.8` for `5.7857…`.
3
3
  * The suffix (`x`) / prefix (`×`) stays at the call site.
4
4
  */
5
5
  export declare function formatLeverage(value: number): string;
6
+ /**
7
+ * Leverage keeping the hundredths a value actually carries: `9` → `9.0`,
8
+ * `9.57` → `9.57`. For the slider, whose track ends on an exact `maxLeverage`,
9
+ * and for its edit field, whose text is parsed back into the target: the
10
+ * protocol's own resolution is 0.01, so `formatLeverage` there would silently
11
+ * move the position.
12
+ */
13
+ export declare function formatLeverageExact(value: number): string;
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Leverage chips beside the strategy yield chart: 30% and 70% of the
3
- * (1 → max) span, rounded to 0.5, plus max itself.
3
+ * (1 → max) span, rounded to 0.5, plus max itself. The 0.5 rounding can
4
+ * overshoot a fractional `max` (1.4 would yield a 1.5 chip), so each step is
5
+ * capped — the dialogs seed their initial leverage from this list.
4
6
  */
5
7
  export declare function leveragePresets(max: number): number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.63",
3
+ "version": "4.0.0-next.65",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(e){return e.toFixed(2).replace(/\.?0+$/,"")}exports.formatChipLeverage=r;
@@ -1,6 +0,0 @@
1
- function r(e) {
2
- return e.toFixed(2).replace(/\.?0+$/, "");
3
- }
4
- export {
5
- r as formatChipLeverage
6
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Chip / subtitle leverage without trailing zeros: `5`, `5.5`, `9.54`.
3
- * Its own module: LeveragePresetChips reads it, no consumer does.
4
- */
5
- export declare function formatChipLeverage(leverage: number): string;