lightweight-charts-react-components 1.1.0 → 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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**!
3
- * lightweight-charts-react-components v1.1.0
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.
@@ -146,6 +146,9 @@ export declare const CandlestickSeries: ForwardRefExoticComponent<SeriesProps<"C
146
146
  */
147
147
  export declare const Chart: ForwardRefExoticComponent<ChartProps & RefAttributes<HTMLDivElement>>;
148
148
 
149
+ /**
150
+ * Chart API reference type that can be used to access the chart plugin API.
151
+ */
149
152
  export declare type ChartApiRef = {
150
153
  _chart: IChartApi | null;
151
154
  api: () => IChartApi | null;
@@ -153,6 +156,9 @@ export declare type ChartApiRef = {
153
156
  clear: () => void;
154
157
  };
155
158
 
159
+ /**
160
+ * Chart component props.
161
+ */
156
162
  export declare type ChartProps = {
157
163
  children?: ReactNode;
158
164
  containerProps?: JSX.IntrinsicElements["div"];
@@ -185,6 +191,9 @@ export declare type ChartProps = {
185
191
  */
186
192
  export declare const CustomSeries: ForwardRefExoticComponent<SeriesProps<"Custom"> & RefAttributes<SeriesApiRef<"Custom">>>;
187
193
 
194
+ /**
195
+ * Unique properties for the custom series component.
196
+ */
188
197
  declare type CustomSeriesUniqueProps = {
189
198
  plugin?: ICustomSeriesPaneView;
190
199
  };
@@ -216,10 +225,16 @@ declare type GenericSeriesPrimitiveComponent = (<T extends SeriesType>(props: Se
216
225
  */
217
226
  export declare const HistogramSeries: ForwardRefExoticComponent<SeriesProps<"Histogram"> & RefAttributes<SeriesApiRef<"Histogram">>>;
218
227
 
228
+ /**
229
+ * Unique properties for the image watermark component.
230
+ */
219
231
  export declare type ImageWatermarkProps = {
220
232
  src: string;
221
233
  } & DeepPartial<ImageWatermarkOptions>;
222
234
 
235
+ /**
236
+ * Pane context that provides access to the pane API and readiness state.
237
+ */
223
238
  export declare interface IPaneContext {
224
239
  paneApiRef?: PaneApiRef;
225
240
  isReady: boolean;
@@ -266,6 +281,9 @@ export declare const LineSeries: ForwardRefExoticComponent<SeriesProps<"Line"> &
266
281
  */
267
282
  export declare const Markers: ForwardRefExoticComponent<MarkersProps & RefAttributes<MarkersApiRef>>;
268
283
 
284
+ /**
285
+ * Markers API reference type that can be used to access the series markers plugin API.
286
+ */
269
287
  export declare type MarkersApiRef = {
270
288
  _markers: ISeriesMarkersPluginApi<Time> | null;
271
289
  api: () => ISeriesMarkersPluginApi<Time> | null;
@@ -273,6 +291,9 @@ export declare type MarkersApiRef = {
273
291
  clear: () => void;
274
292
  };
275
293
 
294
+ /**
295
+ * Markers component properties that can be used to create a series markers component.
296
+ */
276
297
  export declare type MarkersProps = {
277
298
  markers: SeriesMarker<Time>[];
278
299
  reactive?: boolean;
@@ -295,6 +316,9 @@ export declare type MarkersProps = {
295
316
  */
296
317
  export declare const Pane: ForwardRefExoticComponent<PaneProps & RefAttributes<PaneApiRef>>;
297
318
 
319
+ /**
320
+ * Pane API reference type that can be used to access the pane plugin API.
321
+ */
298
322
  export declare type PaneApiRef = {
299
323
  _pane: IPaneApi<Time> | null;
300
324
  api: () => IPaneApi<Time> | null;
@@ -302,6 +326,9 @@ export declare type PaneApiRef = {
302
326
  clear: () => void;
303
327
  };
304
328
 
329
+ /**
330
+ * Pane component props.
331
+ */
305
332
  export declare type PaneProps = {
306
333
  children?: ReactNode;
307
334
  stretchFactor?: number;
@@ -322,6 +349,9 @@ export declare type PaneProps = {
322
349
  */
323
350
  export declare const PriceLine: ForwardRefExoticComponent<PriceLineProps & RefAttributes<PriceLineApiRef>>;
324
351
 
352
+ /**
353
+ * PriceLine API reference type that can be used to access the price line plugin API.
354
+ */
325
355
  export declare type PriceLineApiRef = {
326
356
  _priceLine: IPriceLine | null;
327
357
  api: () => IPriceLine | null;
@@ -329,6 +359,9 @@ export declare type PriceLineApiRef = {
329
359
  clear: () => void;
330
360
  };
331
361
 
362
+ /**
363
+ * PriceLine component props.
364
+ */
332
365
  export declare type PriceLineProps = {
333
366
  price: number;
334
367
  options?: Omit<Partial<PriceLineOptions>, "price">;
@@ -349,6 +382,9 @@ export declare type PriceLineProps = {
349
382
  */
350
383
  export declare const PriceScale: ForwardRefExoticComponent<PriceScaleProps & RefAttributes<PriceScaleApiRef>>;
351
384
 
385
+ /**
386
+ * Price scale API reference type that can be used to access the price scale plugin API.
387
+ */
352
388
  export declare type PriceScaleApiRef = {
353
389
  _priceScale: IPriceScaleApi | null;
354
390
  api: () => IPriceScaleApi | null;
@@ -359,16 +395,25 @@ export declare type PriceScaleApiRef = {
359
395
 
360
396
  declare type PriceScaleOptions = DeepPartial<PriceScaleOptions_2>;
361
397
 
398
+ /**
399
+ * PriceScale component props.
400
+ */
362
401
  export declare type PriceScaleProps = {
363
402
  options?: PriceScaleOptions;
364
403
  id: string;
365
404
  };
366
405
 
406
+ /**
407
+ * Render function type for series primitives.
408
+ */
367
409
  export declare type RenderPrimitive<T extends SeriesType = SeriesType> = ({ chart, series, }: {
368
410
  chart: IChartApi;
369
411
  series: ISeriesApi<T>;
370
412
  }) => ISeriesPrimitive;
371
413
 
414
+ /**
415
+ * Series API reference type that can be used to access the series plugin API.
416
+ */
372
417
  export declare type SeriesApiRef<T extends SeriesType> = {
373
418
  _series: ISeriesApi<T> | null;
374
419
  api: () => ISeriesApi<T> | null;
@@ -376,6 +421,9 @@ export declare type SeriesApiRef<T extends SeriesType> = {
376
421
  clear: () => void;
377
422
  };
378
423
 
424
+ /**
425
+ * Series options that can be used to customize the appearance and behavior of a series.
426
+ */
379
427
  export declare type SeriesOptions<T extends SeriesType> = SeriesPartialOptionsMap[T];
380
428
 
381
429
  declare type SeriesParameters<T extends SeriesType> = {
@@ -400,6 +448,9 @@ declare type SeriesParameters<T extends SeriesType> = {
400
448
  */
401
449
  export declare const SeriesPrimitive: GenericSeriesPrimitiveComponent;
402
450
 
451
+ /**
452
+ * Series primitive API reference type that can be used to access the series primitive plugin API.
453
+ */
403
454
  export declare type SeriesPrimitiveApiRef = {
404
455
  _primitive: ISeriesPrimitive | null;
405
456
  api(): ISeriesPrimitive | null;
@@ -407,6 +458,9 @@ export declare type SeriesPrimitiveApiRef = {
407
458
  clear(): void;
408
459
  };
409
460
 
461
+ /**
462
+ * Series primitive properties that can be used to create a series primitive.
463
+ */
410
464
  export declare type SeriesPrimitiveProps<T extends SeriesType = SeriesType> = SeriesPrimitivePropsWithRender<T> | SeriesPrimitivePropsWithPlugin;
411
465
 
412
466
  declare type SeriesPrimitivePropsWithPlugin = {
@@ -421,13 +475,22 @@ declare type SeriesPrimitivePropsWithRender<T extends SeriesType> = {
421
475
 
422
476
  declare const SeriesPrimitiveRenderFunction: <T extends SeriesType>(props: SeriesPrimitiveProps<T>, ref: ForwardedRef<SeriesPrimitiveApiRef>) => JSX.Element | null;
423
477
 
478
+ /**
479
+ * Series component properties that can be used to create a series of a specific type.
480
+ */
424
481
  export declare type SeriesProps<T extends SeriesType> = Omit<SeriesTemplateProps<T>, "type">;
425
482
 
483
+ /**
484
+ * Properties of a series template component that can be used to create a series of a specific type.
485
+ */
426
486
  declare type SeriesTemplateProps<T extends SeriesType> = {
427
487
  type: T;
428
488
  children?: ReactNode;
429
489
  } & SeriesParameters<T>;
430
490
 
491
+ /**
492
+ * Unique properties for the text watermark component.
493
+ */
431
494
  export declare type TextWatermarkProps = DeepPartial<TextWatermarkOptions>;
432
495
 
433
496
  /**
@@ -445,6 +508,9 @@ export declare type TextWatermarkProps = DeepPartial<TextWatermarkOptions>;
445
508
  */
446
509
  export declare const TimeScale: ForwardRefExoticComponent<TimeScaleProps & RefAttributes<TimeScaleApiRef>>;
447
510
 
511
+ /**
512
+ * Time scale API reference type that can be used to access the time scale plugin API.
513
+ */
448
514
  export declare type TimeScaleApiRef = {
449
515
  _timeScale: ITimeScaleApi<Time> | null;
450
516
  api: () => ITimeScaleApi<Time> | null;
@@ -465,12 +531,18 @@ export declare type TimeScaleApiRef = {
465
531
  */
466
532
  export declare const TimeScaleFitContentTrigger: ({ deps, }: TimeScaleFitContentTriggerProps) => JSX.Element | null;
467
533
 
534
+ /**
535
+ * TimeScaleFitContentTriggerProps component props.
536
+ */
468
537
  export declare type TimeScaleFitContentTriggerProps = {
469
538
  deps: DependencyList;
470
539
  };
471
540
 
472
541
  declare type TimeScaleOptions = DeepPartial<TimeScaleOptions_2>;
473
542
 
543
+ /**
544
+ * TimeScale component props.
545
+ */
474
546
  export declare type TimeScaleProps = {
475
547
  onVisibleTimeRangeChange?: TimeRangeChangeEventHandler<Time>;
476
548
  onVisibleLogicalRangeChange?: LogicalRangeChangeEventHandler;
@@ -481,6 +553,9 @@ export declare type TimeScaleProps = {
481
553
  children?: ReactNode;
482
554
  };
483
555
 
556
+ /**
557
+ * Watermark API reference type that can be used to access the watermark plugin API.
558
+ */
484
559
  export declare type WatermarkApiRef<T extends WatermarkType> = T extends "text" ? WatermarkTextApiRefBase : WatermarkImageApiRefBase;
485
560
 
486
561
  /**
@@ -537,6 +612,11 @@ declare type WatermarkTextApiRefBase = {
537
612
  clear: () => void;
538
613
  };
539
614
 
615
+ /**
616
+ * Watermark types supported by the library.
617
+ * - `text`: A text watermark.
618
+ * - `image`: An image watermark.
619
+ */
540
620
  export declare type WatermarkType = "text" | "image";
541
621
 
542
622
  export { }
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**!
3
- * lightweight-charts-react-components v1.1.0
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.1.0";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