lightweight-charts-react-components 1.0.1 → 1.1.1

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/README.md CHANGED
@@ -151,7 +151,7 @@ const data = [
151
151
  { time: "2023-01-03", value: 102 },
152
152
  ];
153
153
 
154
- const Example = () => {
154
+ const App = () => {
155
155
  return (
156
156
  <Chart>
157
157
  <LineSeries data={data} />
@@ -159,7 +159,7 @@ const Example = () => {
159
159
  );
160
160
  };
161
161
 
162
- export { Example };
162
+ export { App };
163
163
  ```
164
164
 
165
165
  The following is an advanced example that demonstrates how to use custom scales, panes and multiple series in a single chart:
@@ -169,7 +169,7 @@ import React from "react";
169
169
  import {
170
170
  Chart,
171
171
  LineSeries,
172
- BarSeries,
172
+ HistogramSeries,
173
173
  PriceScale,
174
174
  TimeScale,
175
175
  TimeScaleFitContentTrigger,
@@ -182,9 +182,9 @@ const data = [
182
182
  { time: "2023-01-03", value: 102 },
183
183
  ];
184
184
  const volumeData = [
185
- { time: "2023-01-01", value: 1000 },
186
- { time: "2023-01-02", value: 1100 },
187
- { time: "2023-01-03", value: 1200 },
185
+ { time: "2023-01-01", value: 1000, color: "rgba(0, 150, 136, 0.5)" },
186
+ { time: "2023-01-02", value: 1100, color: "rgba(0, 150, 136, 0.5)" },
187
+ { time: "2023-01-03", value: 1200, color: "rgba(0, 150, 136, 0.5)" },
188
188
  ];
189
189
 
190
190
  const chartOptions = {
@@ -195,7 +195,7 @@ const priceScaleOptions = {
195
195
  // Price scale options can be customized here
196
196
  };
197
197
 
198
- const AdvancedExample = () => {
198
+ const App = () => {
199
199
  return (
200
200
  <Chart options={chartOptions}>
201
201
  <Pane stretchFactor={2}>
@@ -203,7 +203,7 @@ const AdvancedExample = () => {
203
203
  <PriceScale id="left" options={priceScaleOptions} />
204
204
  </Pane>
205
205
  <Pane>
206
- <BarSeries data={volumeData} />
206
+ <HistogramSeries data={volumeData} />
207
207
  </Pane>
208
208
  <TimeScale>
209
209
  <TimeScaleFitContentTrigger deps={[]} />
@@ -212,7 +212,7 @@ const AdvancedExample = () => {
212
212
  );
213
213
  };
214
214
 
215
- export { AdvancedExample };
215
+ export { App };
216
216
  ```
217
217
 
218
218
  ## Examples
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**!
3
- * lightweight-charts-react-components v1.0.1
3
+ * lightweight-charts-react-components v1.1.1
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE.md file in the root directory of this source tree.
@@ -43,16 +43,112 @@ import { Time } from 'lightweight-charts';
43
43
  import type { TimeRangeChangeEventHandler } from 'lightweight-charts';
44
44
  import type { TimeScaleOptions as TimeScaleOptions_2 } from 'lightweight-charts';
45
45
 
46
+ /**
47
+ * AreaSeries component that can be used to create an area series in a chart.
48
+ *
49
+ * @param props - The properties for the area series.
50
+ * @param ref - The ref to access the area series API.
51
+ * @returns A React component that renders the area series.
52
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
53
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#area | TradingView documentation for area series}
54
+ * @example
55
+ * ```tsx
56
+ * <AreaSeries
57
+ * data={[
58
+ * { time: '2021-01-01', value: 100 },
59
+ * { time: '2021-01-02', value: 200 }
60
+ * ]}
61
+ * options={{}}
62
+ * />
63
+ * ```
64
+ */
46
65
  export declare const AreaSeries: ForwardRefExoticComponent<SeriesProps<"Area"> & RefAttributes<SeriesApiRef<"Area">>>;
47
66
 
67
+ /**
68
+ * BarSeries component that can be used to create a bar series in a chart.
69
+ *
70
+ * @param props - The properties for the bar series.
71
+ * @param ref - The ref to access the bar series API.
72
+ * @returns A React component that renders the bar series.
73
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
74
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#bar | TradingView documentation for bar series}
75
+ * @example
76
+ * ```tsx
77
+ * <BarSeries
78
+ * data={[
79
+ * { time: '2021-01-01', open: 100, high: 110, low: 90, close: 105 },
80
+ * { time: '2021-01-02', open: 105, high: 115, low: 95, close: 110 }
81
+ * ]}
82
+ * options={{}}
83
+ * />
84
+ * ```
85
+ */
48
86
  export declare const BarSeries: ForwardRefExoticComponent<SeriesProps<"Bar"> & RefAttributes<SeriesApiRef<"Bar">>>;
49
87
 
88
+ /**
89
+ * BaselineSeries component that can be used to create a baseline series in a chart.
90
+ *
91
+ * @param props - The properties for the baseline series.
92
+ * @param ref - The ref to access the baseline series API.
93
+ * @returns A React component that renders the baseline series.
94
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
95
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#baseline | TradingView documentation for baseline series}
96
+ * @example
97
+ * ```tsx
98
+ * <BaselineSeries
99
+ * data={[
100
+ * { time: '2021-01-01', value: 100 },
101
+ * { time: '2021-01-02', value: 200 }
102
+ * ]}
103
+ * options={{}}
104
+ * />
105
+ * ```
106
+ */
50
107
  export declare const BaselineSeries: ForwardRefExoticComponent<SeriesProps<"Baseline"> & RefAttributes<SeriesApiRef<"Baseline">>>;
51
108
 
109
+ /**
110
+ * CandlestickSeries component that can be used to create a candlestick series in a chart.
111
+ *
112
+ * @param props - The properties for the candlestick series.
113
+ * @param ref - The ref to access the candlestick series API.
114
+ * @returns A React component that renders the candlestick series.
115
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
116
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#candlestick | TradingView documentation for candlestick series}
117
+ * @example
118
+ * ```tsx
119
+ * <CandlestickSeries
120
+ * data={[
121
+ * { time: '2021-01-01', open: 100, high: 110, low: 90, close: 105 },
122
+ * { time: '2021-01-02', open: 105, high: 115, low: 95, close: 110 }
123
+ * ]}
124
+ * options={{}}
125
+ * />
126
+ * ```
127
+ */
52
128
  export declare const CandlestickSeries: ForwardRefExoticComponent<SeriesProps<"Candlestick"> & RefAttributes<SeriesApiRef<"Candlestick">>>;
53
129
 
130
+ /**
131
+ * Chart component that can be used to create a chart.
132
+ *
133
+ * @param props - The properties for the chart.
134
+ * @param ref - The ref to access the chart API.
135
+ * @returns A React component that renders the chart.
136
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/chart | Chart documentation}
137
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/chart-types | TradingView documentation for charts}
138
+ * @example
139
+ * ```tsx
140
+ * <Chart>
141
+ * <Pane stretchFactor={2}>
142
+ * ...
143
+ * </Pane>
144
+ * </Chart>
145
+ * ```
146
+ */
54
147
  export declare const Chart: ForwardRefExoticComponent<ChartProps & RefAttributes<HTMLDivElement>>;
55
148
 
149
+ /**
150
+ * Chart API reference type that can be used to access the chart plugin API.
151
+ */
56
152
  export declare type ChartApiRef = {
57
153
  _chart: IChartApi | null;
58
154
  api: () => IChartApi | null;
@@ -60,6 +156,9 @@ export declare type ChartApiRef = {
60
156
  clear: () => void;
61
157
  };
62
158
 
159
+ /**
160
+ * Chart component props.
161
+ */
63
162
  export declare type ChartProps = {
64
163
  children?: ReactNode;
65
164
  containerProps?: JSX.IntrinsicElements["div"];
@@ -70,8 +169,31 @@ export declare type ChartProps = {
70
169
  onDblClick?: MouseEventHandler<Time>;
71
170
  };
72
171
 
172
+ /**
173
+ * CustomSeries component that can be used to create a custom series in a chart.
174
+ *
175
+ * @param props - The properties for the custom series.
176
+ * @param ref - The ref to access the custom series API.
177
+ * @returns A React component that renders the custom series.
178
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
179
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#custom-series-plugins | TradingView documentation for custom series}
180
+ * @example
181
+ * ```tsx
182
+ * <CustomSeries
183
+ * data={[
184
+ * { time: '2021-01-01', value: 100 },
185
+ * { time: '2021-01-02', value: 200 }
186
+ * ]}
187
+ * options={{}}
188
+ * plugin={{}}
189
+ * />
190
+ * ```
191
+ */
73
192
  export declare const CustomSeries: ForwardRefExoticComponent<SeriesProps<"Custom"> & RefAttributes<SeriesApiRef<"Custom">>>;
74
193
 
194
+ /**
195
+ * Unique properties for the custom series component.
196
+ */
75
197
  declare type CustomSeriesUniqueProps = {
76
198
  plugin?: ICustomSeriesPaneView;
77
199
  };
@@ -82,21 +204,86 @@ declare type GenericSeriesPrimitiveComponent = (<T extends SeriesType>(props: Se
82
204
  displayName: string;
83
205
  };
84
206
 
207
+ /**
208
+ * HistogramSeries component that can be used to create a histogram series in a chart.
209
+ *
210
+ * @param props - The properties for the histogram series.
211
+ * @param ref - The ref to access the histogram series API.
212
+ * @returns A React component that renders the histogram series.
213
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
214
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#histogram | TradingView documentation for histogram series}
215
+ * @example
216
+ * ```tsx
217
+ * <HistogramSeries
218
+ * data={[
219
+ * { time: '2021-01-01', value: 100 },
220
+ * { time: '2021-01-02', value: 200 }
221
+ * ]}
222
+ * options={{}}
223
+ * />
224
+ * ```
225
+ */
85
226
  export declare const HistogramSeries: ForwardRefExoticComponent<SeriesProps<"Histogram"> & RefAttributes<SeriesApiRef<"Histogram">>>;
86
227
 
228
+ /**
229
+ * Unique properties for the image watermark component.
230
+ */
87
231
  export declare type ImageWatermarkProps = {
88
232
  src: string;
89
233
  } & DeepPartial<ImageWatermarkOptions>;
90
234
 
235
+ /**
236
+ * Pane context that provides access to the pane API and readiness state.
237
+ */
91
238
  export declare interface IPaneContext {
92
239
  paneApiRef?: PaneApiRef;
93
240
  isReady: boolean;
94
241
  }
95
242
 
243
+ /**
244
+ * LineSeries component that can be used to create a line series in a chart.
245
+ *
246
+ * @param props - The properties for the line series.
247
+ * @param ref - The ref to access the line series API.
248
+ * @returns A React component that renders the line series.
249
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
250
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#line | TradingView documentation for line series}
251
+ * @example
252
+ * ```tsx
253
+ * <LineSeries
254
+ * data={[
255
+ * { time: '2021-01-01', value: 100 },
256
+ * { time: '2021-01-02', value: 200 }
257
+ * ]}
258
+ * options={{}}
259
+ * />
260
+ * ```
261
+ */
96
262
  export declare const LineSeries: ForwardRefExoticComponent<SeriesProps<"Line"> & RefAttributes<SeriesApiRef<"Line">>>;
97
263
 
264
+ /**
265
+ * Markers component that can be used to add markers to a chart pane.
266
+ *
267
+ * @param props - The properties for the markers.
268
+ * @param ref - The ref to access the markers API.
269
+ * @returns A React component that renders the markers.
270
+ * @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/series-markers | Markers documentation}
271
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/markers | TradingView documentation for markers}
272
+ * @example
273
+ * ```tsx
274
+ * <Markers
275
+ * markers={[
276
+ * { time: 1622548800, position: "aboveBar", color: "red", shape: "arrowUp" },
277
+ * { time: 1622548800, position: "belowBar", color: "green", shape: "arrowDown" },
278
+ * ]}
279
+ * />
280
+ * ```
281
+ */
98
282
  export declare const Markers: ForwardRefExoticComponent<MarkersProps & RefAttributes<MarkersApiRef>>;
99
283
 
284
+ /**
285
+ * Markers API reference type that can be used to access the series markers plugin API.
286
+ */
100
287
  export declare type MarkersApiRef = {
101
288
  _markers: ISeriesMarkersPluginApi<Time> | null;
102
289
  api: () => ISeriesMarkersPluginApi<Time> | null;
@@ -104,13 +291,34 @@ export declare type MarkersApiRef = {
104
291
  clear: () => void;
105
292
  };
106
293
 
294
+ /**
295
+ * Markers component properties that can be used to create a series markers component.
296
+ */
107
297
  export declare type MarkersProps = {
108
298
  markers: SeriesMarker<Time>[];
109
299
  reactive?: boolean;
110
300
  };
111
301
 
302
+ /**
303
+ * Pane component that can be used to create a pane in a chart.
304
+ *
305
+ * @param props - The properties for the pane.
306
+ * @param ref - The ref to access the pane API.
307
+ * @returns A React component that renders the pane.
308
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/panes | Panes documentation}
309
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/panes | TradingView documentation for panes}
310
+ * @example
311
+ * ```tsx
312
+ * <Pane stretchFactor={2}>
313
+ * ...
314
+ * </Pane>
315
+ * ```
316
+ */
112
317
  export declare const Pane: ForwardRefExoticComponent<PaneProps & RefAttributes<PaneApiRef>>;
113
318
 
319
+ /**
320
+ * Pane API reference type that can be used to access the pane plugin API.
321
+ */
114
322
  export declare type PaneApiRef = {
115
323
  _pane: IPaneApi<Time> | null;
116
324
  api: () => IPaneApi<Time> | null;
@@ -118,13 +326,32 @@ export declare type PaneApiRef = {
118
326
  clear: () => void;
119
327
  };
120
328
 
329
+ /**
330
+ * Pane component props.
331
+ */
121
332
  export declare type PaneProps = {
122
333
  children?: ReactNode;
123
334
  stretchFactor?: number;
124
335
  };
125
336
 
337
+ /**
338
+ * PriceLine component that can be used to add a price line to a chart pane.
339
+ *
340
+ * @param props - The properties for the price line.
341
+ * @param ref - The ref to access the price line API.
342
+ * @returns A React component that renders the price line.
343
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/price-lines | Price Lines documentation}
344
+ * @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/price-line | TradingView documentation for price lines}
345
+ * @example
346
+ * ```tsx
347
+ * <PriceLine price={100} options={{}} />
348
+ * ```
349
+ */
126
350
  export declare const PriceLine: ForwardRefExoticComponent<PriceLineProps & RefAttributes<PriceLineApiRef>>;
127
351
 
352
+ /**
353
+ * PriceLine API reference type that can be used to access the price line plugin API.
354
+ */
128
355
  export declare type PriceLineApiRef = {
129
356
  _priceLine: IPriceLine | null;
130
357
  api: () => IPriceLine | null;
@@ -132,13 +359,32 @@ export declare type PriceLineApiRef = {
132
359
  clear: () => void;
133
360
  };
134
361
 
362
+ /**
363
+ * PriceLine component props.
364
+ */
135
365
  export declare type PriceLineProps = {
136
366
  price: number;
137
367
  options?: Omit<Partial<PriceLineOptions>, "price">;
138
368
  };
139
369
 
370
+ /**
371
+ * PriceScale component that can be used to create/customize price scale in a chart.
372
+ *
373
+ * @param props - The properties for the price scale.
374
+ * @param ref - The ref to access the price scale API.
375
+ * @returns A React component that renders the price scale.
376
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/price-scale | Price Scale documentation}
377
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/price-scale | TradingView documentation for price scale}
378
+ * @example
379
+ * ```tsx
380
+ * <PriceScale id="right" options={{}} />
381
+ * ```
382
+ */
140
383
  export declare const PriceScale: ForwardRefExoticComponent<PriceScaleProps & RefAttributes<PriceScaleApiRef>>;
141
384
 
385
+ /**
386
+ * Price scale API reference type that can be used to access the price scale plugin API.
387
+ */
142
388
  export declare type PriceScaleApiRef = {
143
389
  _priceScale: IPriceScaleApi | null;
144
390
  api: () => IPriceScaleApi | null;
@@ -149,16 +395,25 @@ export declare type PriceScaleApiRef = {
149
395
 
150
396
  declare type PriceScaleOptions = DeepPartial<PriceScaleOptions_2>;
151
397
 
398
+ /**
399
+ * PriceScale component props.
400
+ */
152
401
  export declare type PriceScaleProps = {
153
402
  options?: PriceScaleOptions;
154
403
  id: string;
155
404
  };
156
405
 
406
+ /**
407
+ * Render function type for series primitives.
408
+ */
157
409
  export declare type RenderPrimitive<T extends SeriesType = SeriesType> = ({ chart, series, }: {
158
410
  chart: IChartApi;
159
411
  series: ISeriesApi<T>;
160
412
  }) => ISeriesPrimitive;
161
413
 
414
+ /**
415
+ * Series API reference type that can be used to access the series plugin API.
416
+ */
162
417
  export declare type SeriesApiRef<T extends SeriesType> = {
163
418
  _series: ISeriesApi<T> | null;
164
419
  api: () => ISeriesApi<T> | null;
@@ -166,6 +421,9 @@ export declare type SeriesApiRef<T extends SeriesType> = {
166
421
  clear: () => void;
167
422
  };
168
423
 
424
+ /**
425
+ * Series options that can be used to customize the appearance and behavior of a series.
426
+ */
169
427
  export declare type SeriesOptions<T extends SeriesType> = SeriesPartialOptionsMap[T];
170
428
 
171
429
  declare type SeriesParameters<T extends SeriesType> = {
@@ -174,8 +432,25 @@ declare type SeriesParameters<T extends SeriesType> = {
174
432
  options?: SeriesOptions<T>;
175
433
  } & (T extends "Custom" ? CustomSeriesUniqueProps : {});
176
434
 
435
+ /**
436
+ * SeriesPrimitive component that can be used to create a primitive on series.
437
+ *
438
+ * @param props - The properties for the series primitive.
439
+ * @param ref - The ref to access the series primitive API.
440
+ * @returns A React component that renders the series primitive.
441
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series-primitives | Series primitives documentation}
442
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives | TradingView documentation for series primitive}
443
+ * @example
444
+ * ```tsx
445
+ * <SeriesPrimitive render={{}} />
446
+ * <SeriesPrimitive plugin={{}} />
447
+ * ```
448
+ */
177
449
  export declare const SeriesPrimitive: GenericSeriesPrimitiveComponent;
178
450
 
451
+ /**
452
+ * Series primitive API reference type that can be used to access the series primitive plugin API.
453
+ */
179
454
  export declare type SeriesPrimitiveApiRef = {
180
455
  _primitive: ISeriesPrimitive | null;
181
456
  api(): ISeriesPrimitive | null;
@@ -183,6 +458,9 @@ export declare type SeriesPrimitiveApiRef = {
183
458
  clear(): void;
184
459
  };
185
460
 
461
+ /**
462
+ * Series primitive properties that can be used to create a series primitive.
463
+ */
186
464
  export declare type SeriesPrimitiveProps<T extends SeriesType = SeriesType> = SeriesPrimitivePropsWithRender<T> | SeriesPrimitivePropsWithPlugin;
187
465
 
188
466
  declare type SeriesPrimitivePropsWithPlugin = {
@@ -197,17 +475,42 @@ declare type SeriesPrimitivePropsWithRender<T extends SeriesType> = {
197
475
 
198
476
  declare const SeriesPrimitiveRenderFunction: <T extends SeriesType>(props: SeriesPrimitiveProps<T>, ref: ForwardedRef<SeriesPrimitiveApiRef>) => JSX.Element | null;
199
477
 
478
+ /**
479
+ * Series component properties that can be used to create a series of a specific type.
480
+ */
200
481
  export declare type SeriesProps<T extends SeriesType> = Omit<SeriesTemplateProps<T>, "type">;
201
482
 
483
+ /**
484
+ * Properties of a series template component that can be used to create a series of a specific type.
485
+ */
202
486
  declare type SeriesTemplateProps<T extends SeriesType> = {
203
487
  type: T;
204
488
  children?: ReactNode;
205
489
  } & SeriesParameters<T>;
206
490
 
491
+ /**
492
+ * Unique properties for the text watermark component.
493
+ */
207
494
  export declare type TextWatermarkProps = DeepPartial<TextWatermarkOptions>;
208
495
 
496
+ /**
497
+ * TimeScale component that can be used to create/customize time scale in a chart.
498
+ *
499
+ * @param props - The properties for the time scale.
500
+ * @param ref - The ref to access the time scale API.
501
+ * @returns A React component that renders the time scale.
502
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/time-scale | Time Scale documentation}
503
+ * @see {@link https://tradingview.github.io/lightweight-charts/docs/time-scale | TradingView documentation for time scale}
504
+ * @example
505
+ * ```tsx
506
+ * <TimeScale visibleRange={{ from: 0, to: 100 }} onVisibleRangeChanged={() => {}} />
507
+ * ```
508
+ */
209
509
  export declare const TimeScale: ForwardRefExoticComponent<TimeScaleProps & RefAttributes<TimeScaleApiRef>>;
210
510
 
511
+ /**
512
+ * Time scale API reference type that can be used to access the time scale plugin API.
513
+ */
211
514
  export declare type TimeScaleApiRef = {
212
515
  _timeScale: ITimeScaleApi<Time> | null;
213
516
  api: () => ITimeScaleApi<Time> | null;
@@ -215,14 +518,31 @@ export declare type TimeScaleApiRef = {
215
518
  clear: () => void;
216
519
  };
217
520
 
521
+ /**
522
+ * TimeScaleFitContentTrigger component that triggers a fit content operation on the time scale.
523
+ *
524
+ * @param props - The properties for the time scale fit content trigger.
525
+ * @returns A React component that triggers a fit content operation on the time scale.
526
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/time-scale-fit-content-trigger | Time Scale Fit Content Trigger documentation}
527
+ * @example
528
+ * ```tsx
529
+ * <TimeScaleFitContentTrigger deps={[...]} />
530
+ * ```
531
+ */
218
532
  export declare const TimeScaleFitContentTrigger: ({ deps, }: TimeScaleFitContentTriggerProps) => JSX.Element | null;
219
533
 
534
+ /**
535
+ * TimeScaleFitContentTriggerProps component props.
536
+ */
220
537
  export declare type TimeScaleFitContentTriggerProps = {
221
538
  deps: DependencyList;
222
539
  };
223
540
 
224
541
  declare type TimeScaleOptions = DeepPartial<TimeScaleOptions_2>;
225
542
 
543
+ /**
544
+ * TimeScale component props.
545
+ */
226
546
  export declare type TimeScaleProps = {
227
547
  onVisibleTimeRangeChange?: TimeRangeChangeEventHandler<Time>;
228
548
  onVisibleLogicalRangeChange?: LogicalRangeChangeEventHandler;
@@ -233,8 +553,28 @@ export declare type TimeScaleProps = {
233
553
  children?: ReactNode;
234
554
  };
235
555
 
556
+ /**
557
+ * Watermark API reference type that can be used to access the watermark plugin API.
558
+ */
236
559
  export declare type WatermarkApiRef<T extends WatermarkType> = T extends "text" ? WatermarkTextApiRefBase : WatermarkImageApiRefBase;
237
560
 
561
+ /**
562
+ * Watermark component that can be used to add an image watermark to a chart pane.
563
+ *
564
+ * @param props - The properties for the image watermark.
565
+ * @param ref - The ref to access the watermark API.
566
+ * @returns A React component that renders the image watermark.
567
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/watermarks | Watermarks documentation}
568
+ * @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/watermark | TradingView documentation for watermarks}
569
+ * @example
570
+ * ```tsx
571
+ * <WatermarkImage
572
+ * src="data:image/svg+xml;base64,..."
573
+ * alpha={0.5}
574
+ * padding={20}
575
+ * />
576
+ * ```
577
+ */
238
578
  export declare const WatermarkImage: ForwardRefExoticComponent<ImageWatermarkProps & RefAttributes<WatermarkApiRef<"image">>>;
239
579
 
240
580
  declare type WatermarkImageApiRefBase = {
@@ -244,6 +584,25 @@ declare type WatermarkImageApiRefBase = {
244
584
  clear: () => void;
245
585
  };
246
586
 
587
+ /**
588
+ * Watermark component that can be used to add a text or image watermark to a chart pane.
589
+ *
590
+ * @param props - The properties for the watermark.
591
+ * @param ref - The ref to access the watermark API.
592
+ * @returns A React component that renders the watermark.
593
+ * @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/watermarks | Watermarks documentation}
594
+ * @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/watermark | TradingView documentation for watermarks}
595
+ * @example
596
+ * ```tsx
597
+ * <WatermarkText
598
+ * lines={[
599
+ * { text: "Your chart name", color: "blue", fontSize: 24 },
600
+ * { text: "Some other text", color: "pink", fontSize: 16 },
601
+ * ]}
602
+ * horzAlign="center"
603
+ * />
604
+ * ```
605
+ */
247
606
  export declare const WatermarkText: ForwardRefExoticComponent<TextWatermarkProps & RefAttributes<WatermarkApiRef<"text">>>;
248
607
 
249
608
  declare type WatermarkTextApiRefBase = {
@@ -253,6 +612,11 @@ declare type WatermarkTextApiRefBase = {
253
612
  clear: () => void;
254
613
  };
255
614
 
615
+ /**
616
+ * Watermark types supported by the library.
617
+ * - `text`: A text watermark.
618
+ * - `image`: An image watermark.
619
+ */
256
620
  export declare type WatermarkType = "text" | "image";
257
621
 
258
622
  export { }
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**!
3
- * lightweight-charts-react-components v1.0.1
3
+ * lightweight-charts-react-components v1.1.1
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE.md file in the root directory of this source tree.
@@ -8,7 +8,7 @@
8
8
  * @license MIT
9
9
  */
10
10
 
11
- import*as e from"react";import*as t from"lightweight-charts";let i=(0,e.createContext)(null);i.displayName="ChartContext";let r={addDefaultPane:!1},a=({container:i,onClick:a,onCrosshairMove:l,onInit:n,options:s={},onDblClick:u})=>{let[c,f]=(0,e.useState)(!1),o=(0,e.useRef)({_chart:null,api(){return this._chart},init(){if(null===this._chart){let e=(0,t.createChart)(i,{...r,...s});this._chart=e,n&&n(this._chart)}return c||f(!0),this._chart},clear(){null!==this._chart&&(f(!1),this._chart.remove(),this._chart=null)}});return(0,e.useLayoutEffect)(()=>(o.current.init(),()=>{o.current.clear()}),[]),(0,e.useLayoutEffect)(()=>{if(i){if(a){var e;null===(e=o.current.api())||void 0===e||e.subscribeClick(a)}return()=>{if(a){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeClick(a)}}}},[a]),(0,e.useLayoutEffect)(()=>{if(i){if(l){var e;null===(e=o.current.api())||void 0===e||e.subscribeCrosshairMove(l)}return()=>{if(l){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeCrosshairMove(l)}}}},[l]),(0,e.useLayoutEffect)(()=>{if(i){if(u){var e;null===(e=o.current.api())||void 0===e||e.subscribeDblClick(u)}return()=>{if(u){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeDblClick(u)}}}},[u]),(0,e.useLayoutEffect)(()=>{var e;i&&(null===(e=o.current.api())||void 0===e||e.applyOptions({...r,...s}))},[s]),{chartApiRef:o,isReady:c}},l=({children:t,container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u})=>{let{chartApiRef:{current:c},isReady:f}=a({container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u});return e.default.createElement(i.Provider,{value:{chartApiRef:c,isReady:f}},t)},n=(0,e.forwardRef)(({children:t,containerProps:i,...r},a)=>{let[n,s]=(0,e.useState)(),u=(0,e.useCallback)(e=>{s(e),a&&("function"==typeof a?u(e):a.current=e)},[a]);return e.default.createElement("div",{ref:u,...i},!!n&&e.default.createElement(l,{container:n,...r},t))});n.displayName="ChartWrapper";let s=(0,e.createContext)(null);s.displayName="TimeScaleContext";let u="1.0.1";function c(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class f extends Error{constructor(e,{isOperational:t=!0,cause:i,docsPath:r}={}){super(e),c(this,"isOperational",void 0),c(this,"cause",void 0),this.name=this.constructor.name??"InternalError",this.isOperational=t,this.cause=i,this.message=`${e??"An error occurred"}`,r&&(this.message=`${this.message}
11
+ import*as e from"react";import*as t from"lightweight-charts";let i=(0,e.createContext)(null);i.displayName="ChartContext";let r={addDefaultPane:!1},a=({container:i,onClick:a,onCrosshairMove:l,onInit:n,options:s={},onDblClick:u})=>{let[c,f]=(0,e.useState)(!1),o=(0,e.useRef)({_chart:null,api(){return this._chart},init(){if(null===this._chart){let e=(0,t.createChart)(i,{...r,...s});this._chart=e,n&&n(this._chart)}return c||f(!0),this._chart},clear(){null!==this._chart&&(f(!1),this._chart.remove(),this._chart=null)}});return(0,e.useLayoutEffect)(()=>(o.current.init(),()=>{o.current.clear()}),[]),(0,e.useLayoutEffect)(()=>{if(i){if(a){var e;null===(e=o.current.api())||void 0===e||e.subscribeClick(a)}return()=>{if(a){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeClick(a)}}}},[a]),(0,e.useLayoutEffect)(()=>{if(i){if(l){var e;null===(e=o.current.api())||void 0===e||e.subscribeCrosshairMove(l)}return()=>{if(l){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeCrosshairMove(l)}}}},[l]),(0,e.useLayoutEffect)(()=>{if(i){if(u){var e;null===(e=o.current.api())||void 0===e||e.subscribeDblClick(u)}return()=>{if(u){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeDblClick(u)}}}},[u]),(0,e.useLayoutEffect)(()=>{var e;i&&(null===(e=o.current.api())||void 0===e||e.applyOptions({...r,...s}))},[s]),{chartApiRef:o,isReady:c}},l=({children:t,container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u})=>{let{chartApiRef:{current:c},isReady:f}=a({container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u});return e.default.createElement(i.Provider,{value:{chartApiRef:c,isReady:f}},t)},n=(0,e.forwardRef)(({children:t,containerProps:i,...r},a)=>{let[n,s]=(0,e.useState)(),u=(0,e.useCallback)(e=>{s(e),a&&("function"==typeof a?u(e):a.current=e)},[a]);return e.default.createElement("div",{ref:u,...i},!!n&&e.default.createElement(l,{container:n,...r},t))});n.displayName="ChartWrapper";let s=(0,e.createContext)(null);s.displayName="TimeScaleContext";let u="1.1.1";function c(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class f extends Error{constructor(e,{isOperational:t=!0,cause:i,docsPath:r}={}){super(e),c(this,"isOperational",void 0),c(this,"cause",void 0),this.name=this.constructor.name??"InternalError",this.isOperational=t,this.cause=i,this.message=`${e??"An error occurred"}`,r&&(this.message=`${this.message}
12
12
 
13
13
  Docs: see ${"https://ukorvl.github.io/lightweight-charts-react-components/docs/"+r}`),u&&(this.message=`${this.message}
14
14