@nice2dev/ui 1.4.23 → 1.4.24
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/CHANGELOG.md +57 -0
- package/dist/{NicePivotGrid-B5Fgi5E_.cjs → NicePivotGrid-D53CQ2cY.cjs} +1 -1
- package/dist/charts/NiceAdvancedCharts.mjs +586 -773
- package/dist/charts/NiceChartRangeSelector.mjs +159 -0
- package/dist/charts/NiceHeatMap.mjs +140 -70
- package/dist/charts/NiceOrganizationChart.mjs +183 -90
- package/dist/charts/NiceSankey.mjs +166 -93
- package/dist/charts/NiceStockChart.mjs +258 -157
- package/dist/charts-CSgOgfES.cjs +867 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +126 -102
- package/dist/charts.mjs +22 -24
- package/dist/core/lazy.mjs +50 -63
- package/dist/core-lazy-sO0xvg64.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/demo/docs/docPreviews.mjs +450 -466
- package/dist/demo/docs/docRegistry.mjs +5 -35
- package/dist/index.cjs +60 -67
- package/dist/index.d.ts +121 -172
- package/dist/index.mjs +831 -836
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +41 -23
- package/dist/lazy.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/tools/NiceShowcase.mjs +1 -2
- package/package.json +4 -4
- package/dist/charts/NiceRangeSelector.mjs +0 -135
- package/dist/charts/NiceTreeMap.mjs +0 -100
- package/dist/charts/NiceVectorMap.mjs +0 -59
- package/dist/charts-C9B548D2.cjs +0 -924
- package/dist/core-lazy-B54FdghB.cjs +0 -1
package/dist/charts.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./charts-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./charts-CSgOgfES.cjs");exports.CHART_COLORS=e.CHART_COLORS;exports.NiceBarGauge=e.NiceBarGauge;exports.NiceBullet=e.NiceBullet;exports.NiceChart=e.NiceChart;exports.NiceChartAI=e.NiceChartAI;exports.NiceChartRangeSelector=e.NiceChartRangeSelector;exports.NiceCircularGauge=e.NiceCircularGauge;exports.NiceForecastChart=e.NiceForecastChart;exports.NiceFunnel=e.NiceFunnel;exports.NiceHeatMap=e.NiceHeatMap;exports.NiceLinearGauge=e.NiceLinearGauge;exports.NiceLiveChart=e.NiceLiveChart;exports.NiceOrganizationChart=e.NiceOrganizationChart;exports.NicePieChart=e.NicePieChart;exports.NicePolarChart=e.NicePolarChart;exports.NiceSankey=e.NiceSankey;exports.NiceSparkline=e.NiceSparkline;exports.NiceStockChart=e.NiceStockChart;exports.NiceTreeMap=e.NiceTreeMap;
|
package/dist/charts.d.ts
CHANGED
|
@@ -368,6 +368,36 @@ export declare interface NiceChartProps extends NiceStandardProps {
|
|
|
368
368
|
exportable?: boolean;
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
export declare const NiceChartRangeSelector: default_2.FC<NiceChartRangeSelectorProps>;
|
|
372
|
+
|
|
373
|
+
/** Props for the {@link NiceChartRangeSelector} component — a chart's range window with handles over an optional sparkline. */
|
|
374
|
+
export declare interface NiceChartRangeSelectorProps extends NiceStandardProps {
|
|
375
|
+
/** Sparkline data rendered behind the window. */
|
|
376
|
+
data?: number[];
|
|
377
|
+
/** Minimum selectable value. */
|
|
378
|
+
min: number;
|
|
379
|
+
/** Maximum selectable value. */
|
|
380
|
+
max: number;
|
|
381
|
+
/** Current start of the selected range. */
|
|
382
|
+
start: number;
|
|
383
|
+
/** Current end of the selected range. */
|
|
384
|
+
end: number;
|
|
385
|
+
/** Called when the range changes. */
|
|
386
|
+
onChange: (start: number, end: number) => void;
|
|
387
|
+
/** Width in px (the starting width when `responsive`). */
|
|
388
|
+
width?: number;
|
|
389
|
+
/** Height in px. */
|
|
390
|
+
height?: number;
|
|
391
|
+
/** Step increment. */
|
|
392
|
+
step?: number;
|
|
393
|
+
/** Custom value formatter. */
|
|
394
|
+
formatValue?: (v: number) => string;
|
|
395
|
+
/** Sparkline fill color. */
|
|
396
|
+
chartColor?: string;
|
|
397
|
+
/** Follow the container's width. Default `true`. */
|
|
398
|
+
responsive?: boolean;
|
|
399
|
+
}
|
|
400
|
+
|
|
371
401
|
/** A single data series in a {@link NiceChart}. */
|
|
372
402
|
declare interface NiceChartSeries {
|
|
373
403
|
name: string;
|
|
@@ -518,22 +548,47 @@ export declare const NiceHeatMap: default_2.ForwardRefExoticComponent<NiceHeatMa
|
|
|
518
548
|
displayName: string;
|
|
519
549
|
};
|
|
520
550
|
|
|
521
|
-
/** Props for the {@link NiceHeatMap} component — a
|
|
551
|
+
/** Props for the {@link NiceHeatMap} component — a matrix coloured by value. */
|
|
522
552
|
export declare interface NiceHeatMapProps extends NiceStandardProps {
|
|
523
|
-
/**
|
|
524
|
-
data?: number
|
|
525
|
-
/** Column
|
|
553
|
+
/** Matrix of values, rows × columns; `null` is an empty cell. */
|
|
554
|
+
data?: Array<Array<number | null>>;
|
|
555
|
+
/** Column labels (along the top). */
|
|
526
556
|
xLabels?: string[];
|
|
527
|
-
/** Row
|
|
557
|
+
/** Row labels (along the left). */
|
|
528
558
|
yLabels?: string[];
|
|
529
|
-
/**
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
559
|
+
/**
|
|
560
|
+
* Colour stops from low to high: two for a sequential scale, three (low, middle, high) for a
|
|
561
|
+
* diverging one. Theme colours by default.
|
|
562
|
+
*/
|
|
563
|
+
colors?: [string, string] | [string, string, string];
|
|
564
|
+
/** Fires when a cell is clicked. */
|
|
565
|
+
onCellClick?: (row: number, col: number, value: number | null) => void;
|
|
566
|
+
/** Smallest cell size in px (cells grow to fill the width when `responsive`). Default 32. */
|
|
534
567
|
cellSize?: number;
|
|
535
|
-
/**
|
|
568
|
+
/** Write the values in the cells. Default `false` — the colours carry them. 1.4.24. */
|
|
536
569
|
showValues?: boolean;
|
|
570
|
+
/** Colour scale legend under the matrix. Default `true`. 1.4.24. */
|
|
571
|
+
showLegend?: boolean;
|
|
572
|
+
/** Tooltip with the row, the column and the value. Default `true`. 1.4.24. */
|
|
573
|
+
showTooltip?: boolean;
|
|
574
|
+
/** Cells fill the container's width. Default `true`. 1.4.24. */
|
|
575
|
+
responsive?: boolean;
|
|
576
|
+
/** Low end of the scale (default: the smallest value). 1.4.24. */
|
|
577
|
+
min?: number;
|
|
578
|
+
/** High end of the scale (default: the largest value). 1.4.24. */
|
|
579
|
+
max?: number;
|
|
580
|
+
/** Gap between cells in px. Default 2. 1.4.24. */
|
|
581
|
+
cellGap?: number;
|
|
582
|
+
/** Corner radius of the cells in px. Default 3. 1.4.24. */
|
|
583
|
+
cellRadius?: number;
|
|
584
|
+
/** Colour of empty (`null`) cells. 1.4.24. */
|
|
585
|
+
emptyColor?: string;
|
|
586
|
+
/** Format a value for the cells, the tooltip and the legend. 1.4.24. */
|
|
587
|
+
formatValue?: (v: number) => string;
|
|
588
|
+
/** Title of the column axis. 1.4.24. */
|
|
589
|
+
xAxisLabel?: string;
|
|
590
|
+
/** Title of the row axis. 1.4.24. */
|
|
591
|
+
yAxisLabel?: string;
|
|
537
592
|
}
|
|
538
593
|
|
|
539
594
|
export declare const NiceLinearGauge: default_2.FC<NiceLinearGaugeProps>;
|
|
@@ -686,18 +741,6 @@ declare interface NiceLiveChartSeriesConfig {
|
|
|
686
741
|
initialData?: number[];
|
|
687
742
|
}
|
|
688
743
|
|
|
689
|
-
/** A geographic region rendered by the {@link NiceVectorMap}. */
|
|
690
|
-
declare interface NiceMapRegion {
|
|
691
|
-
/** Unique region identifier (e.g. ISO code). */
|
|
692
|
-
id: string;
|
|
693
|
-
/** Display name. */
|
|
694
|
-
name: string;
|
|
695
|
-
/** SVG path data. */
|
|
696
|
-
path: string;
|
|
697
|
-
/** Data value (drives color intensity). */
|
|
698
|
-
value?: number;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
744
|
export declare const NiceOrganizationChart: default_2.ForwardRefExoticComponent<NiceOrganizationChartProps & default_2.RefAttributes<HTMLDivElement>> & {
|
|
702
745
|
displayName: string;
|
|
703
746
|
};
|
|
@@ -727,6 +770,18 @@ export declare interface NiceOrganizationChartProps extends NiceStandardProps {
|
|
|
727
770
|
exportable?: boolean | Array<'svg' | 'png'>;
|
|
728
771
|
/** An export, instead of downloading it (`svg`: the document text, `png`: the image). */
|
|
729
772
|
onExport?: (format: 'svg' | 'png', data: string | Blob) => void;
|
|
773
|
+
/** Drag the chart with the pointer (the hand). Default `true`. 1.4.24. */
|
|
774
|
+
pannable?: boolean;
|
|
775
|
+
/** Zoom with the wheel — `'ctrl'` (default) only with Ctrl / ⌘ held, `true` always. 1.4.24. */
|
|
776
|
+
wheelZoom?: boolean | 'ctrl';
|
|
777
|
+
/** A search box in the toolbar: matches are highlighted, expanded and brought into view. 1.4.24. */
|
|
778
|
+
searchable?: boolean;
|
|
779
|
+
/** Start with branches below this depth collapsed (0 = only the root open). 1.4.24. */
|
|
780
|
+
collapsedDepth?: number;
|
|
781
|
+
/** Keys drawn highlighted. 1.4.24. */
|
|
782
|
+
highlightKeys?: string[];
|
|
783
|
+
/** Fires when a node is clicked (with or without `selectable`). 1.4.24. */
|
|
784
|
+
onNodeClick?: (node: NiceOrgNode) => void;
|
|
730
785
|
}
|
|
731
786
|
|
|
732
787
|
/** A node in the {@link NiceOrganizationChart} hierarchy. */
|
|
@@ -813,34 +868,6 @@ declare interface NicePolarChartSeries {
|
|
|
813
868
|
fill?: boolean;
|
|
814
869
|
}
|
|
815
870
|
|
|
816
|
-
export declare const NiceRangeSelector: default_2.FC<NiceRangeSelectorProps>;
|
|
817
|
-
|
|
818
|
-
/** Props for the {@link NiceRangeSelector} component — a dual-handle range slider with optional sparkline background. */
|
|
819
|
-
export declare interface NiceRangeSelectorProps extends NiceStandardProps {
|
|
820
|
-
/** Sparkline data rendered behind the handles. */
|
|
821
|
-
data?: number[];
|
|
822
|
-
/** Minimum selectable value. */
|
|
823
|
-
min: number;
|
|
824
|
-
/** Maximum selectable value. */
|
|
825
|
-
max: number;
|
|
826
|
-
/** Current start of the selected range. */
|
|
827
|
-
start: number;
|
|
828
|
-
/** Current end of the selected range. */
|
|
829
|
-
end: number;
|
|
830
|
-
/** Called when the range changes. */
|
|
831
|
-
onChange: (start: number, end: number) => void;
|
|
832
|
-
/** SVG width in px. */
|
|
833
|
-
width?: number;
|
|
834
|
-
/** SVG height in px. */
|
|
835
|
-
height?: number;
|
|
836
|
-
/** Step increment. */
|
|
837
|
-
step?: number;
|
|
838
|
-
/** Custom value formatter. */
|
|
839
|
-
formatValue?: (v: number) => string;
|
|
840
|
-
/** Sparkline fill color. */
|
|
841
|
-
chartColor?: string;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
871
|
export declare const NiceSankey: default_2.FC<NiceSankeyProps>;
|
|
845
872
|
|
|
846
873
|
/** A flow link between two {@link NiceSankeyNode} entries. */
|
|
@@ -851,14 +878,18 @@ declare interface NiceSankeyLink {
|
|
|
851
878
|
target: string;
|
|
852
879
|
/** Flow magnitude. */
|
|
853
880
|
value: number;
|
|
881
|
+
/** Link colour (default: a gradient from the source's colour to the target's). */
|
|
882
|
+
color?: string;
|
|
854
883
|
}
|
|
855
884
|
|
|
856
885
|
/** A node in the {@link NiceSankey} diagram. */
|
|
857
886
|
declare interface NiceSankeyNode {
|
|
858
887
|
/** Unique identifier. */
|
|
859
888
|
id: string;
|
|
860
|
-
/** Node label. */
|
|
861
|
-
label
|
|
889
|
+
/** Node label (default: `name`, then the id). */
|
|
890
|
+
label?: string;
|
|
891
|
+
/** Alias of `label`, as in the former NiceSankeyChart. */
|
|
892
|
+
name?: string;
|
|
862
893
|
/** Node color. */
|
|
863
894
|
color?: string;
|
|
864
895
|
}
|
|
@@ -879,6 +910,16 @@ export declare interface NiceSankeyProps extends NiceStandardProps {
|
|
|
879
910
|
nodePadding?: number;
|
|
880
911
|
/** Chart title. */
|
|
881
912
|
title?: string;
|
|
913
|
+
/** Add each node's total to its label. 1.4.24. */
|
|
914
|
+
showValues?: boolean;
|
|
915
|
+
/** Native tooltips on nodes and links. Default `true`. 1.4.24. */
|
|
916
|
+
showTooltip?: boolean;
|
|
917
|
+
/** Links drawn as a gradient from the source's colour to the target's. Default `true`. 1.4.24. */
|
|
918
|
+
gradientLinks?: boolean;
|
|
919
|
+
/** Fires when a node is clicked. 1.4.24. */
|
|
920
|
+
onNodeClick?: (node: NiceSankeyNode) => void;
|
|
921
|
+
/** Fires when a link is clicked. 1.4.24. */
|
|
922
|
+
onLinkClick?: (link: NiceSankeyLink) => void;
|
|
882
923
|
}
|
|
883
924
|
|
|
884
925
|
export declare const NiceSparkline: default_2.FC<NiceSparklineProps>;
|
|
@@ -921,6 +962,12 @@ export declare interface NiceStockChartProps extends NiceStandardProps {
|
|
|
921
962
|
bullColor?: string;
|
|
922
963
|
/** Color for bearish candles. */
|
|
923
964
|
bearColor?: string;
|
|
965
|
+
/** Crosshair with the day's open / high / low / close / volume. Default `true`. 1.4.24. */
|
|
966
|
+
showCrosshair?: boolean;
|
|
967
|
+
/** Follow the container's width (`width` is the starting size). Default `true`. 1.4.24. */
|
|
968
|
+
responsive?: boolean;
|
|
969
|
+
/** Format a price for the axis and the tooltip. Default: two decimals. 1.4.24. */
|
|
970
|
+
formatPrice?: (v: number) => string;
|
|
924
971
|
}
|
|
925
972
|
|
|
926
973
|
/** Chart type for the {@link NiceStockChart}. */
|
|
@@ -942,65 +989,42 @@ declare interface NiceStockDataPoint {
|
|
|
942
989
|
volume?: number;
|
|
943
990
|
}
|
|
944
991
|
|
|
945
|
-
export declare const NiceTreeMap: default_2.
|
|
946
|
-
displayName: string;
|
|
947
|
-
};
|
|
992
|
+
export declare const NiceTreeMap: default_2.FC<NiceTreeMapProps>;
|
|
948
993
|
|
|
949
|
-
/** A
|
|
950
|
-
declare interface NiceTreeMapNode {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
/** Node label. */
|
|
954
|
-
label: string;
|
|
955
|
-
/** Numeric weight (determines area). */
|
|
994
|
+
/** A node of a {@link NiceTreeMap}. */
|
|
995
|
+
export declare interface NiceTreeMapNode {
|
|
996
|
+
id: string;
|
|
997
|
+
name: string;
|
|
956
998
|
value: number;
|
|
957
|
-
/** Node color. */
|
|
958
999
|
color?: string;
|
|
959
|
-
/** Child nodes. */
|
|
960
1000
|
children?: NiceTreeMapNode[];
|
|
961
1001
|
}
|
|
962
1002
|
|
|
963
|
-
/** Props for
|
|
1003
|
+
/** Props for {@link NiceTreeMap}. */
|
|
964
1004
|
export declare interface NiceTreeMapProps extends NiceStandardProps {
|
|
965
|
-
/**
|
|
966
|
-
data: NiceTreeMapNode
|
|
967
|
-
|
|
1005
|
+
/** Dane hierarchiczne. Można też podać płaską listę — zostanie opakowana w wirtualny korzeń. */
|
|
1006
|
+
data: NiceTreeMapNode | Array<{
|
|
1007
|
+
label?: string;
|
|
1008
|
+
name?: string;
|
|
1009
|
+
value: number;
|
|
1010
|
+
color?: string;
|
|
1011
|
+
}>;
|
|
1012
|
+
/** Szerokość */
|
|
968
1013
|
width?: number;
|
|
969
|
-
/**
|
|
1014
|
+
/** Wysokość */
|
|
970
1015
|
height?: number;
|
|
971
|
-
/**
|
|
972
|
-
|
|
973
|
-
/**
|
|
1016
|
+
/** Pokaż etykiety */
|
|
1017
|
+
showLabels?: boolean;
|
|
1018
|
+
/** Pokaż wartości */
|
|
1019
|
+
showValues?: boolean;
|
|
1020
|
+
/** Callback po kliknięciu */
|
|
1021
|
+
onNodeClick?: (node: NiceTreeMapNode, path: string[]) => void;
|
|
1022
|
+
/** Umożliw drill-down */
|
|
1023
|
+
drilldownEnabled?: boolean;
|
|
1024
|
+
/** Kolory */
|
|
974
1025
|
colors?: string[];
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
export declare const NiceVectorMap: default_2.FC<NiceVectorMapProps>;
|
|
978
|
-
|
|
979
|
-
/** Props for the {@link NiceVectorMap} component — an SVG choropleth map with region selection and tooltips. */
|
|
980
|
-
export declare interface NiceVectorMapProps extends NiceStandardProps {
|
|
981
|
-
/** Region definitions. */
|
|
982
|
-
regions?: NiceMapRegion[];
|
|
983
|
-
/** SVG width in px. */
|
|
984
|
-
width?: number;
|
|
985
|
-
/** SVG height in px. */
|
|
986
|
-
height?: number;
|
|
987
|
-
/** SVG viewBox (overrides width/height). */
|
|
988
|
-
viewBox?: string;
|
|
989
|
-
/**
|
|
990
|
-
* Color scale as [min color, max color] — `#rrggbb` hex, interpolated numerically per
|
|
991
|
-
* region (a `var()` token cannot be interpolated).
|
|
992
|
-
*/
|
|
993
|
-
colorRange?: [string, string];
|
|
994
|
-
/** Maximum data value (for color interpolation). */
|
|
995
|
-
maxValue?: number;
|
|
996
|
-
/** Called when a region is clicked. */
|
|
997
|
-
onRegionClick?: (region: NiceMapRegion) => void;
|
|
998
|
-
/** Currently selected region id. */
|
|
999
|
-
selectedRegionId?: string;
|
|
1000
|
-
/** Map title. */
|
|
1001
|
-
title?: string;
|
|
1002
|
-
/** Show tooltip on hover. */
|
|
1003
|
-
showTooltip?: boolean;
|
|
1026
|
+
/** Padding między kafelkami */
|
|
1027
|
+
tilePadding?: number;
|
|
1004
1028
|
}
|
|
1005
1029
|
|
|
1006
1030
|
/**
|
package/dist/charts.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NiceChart as o } from "./charts/NiceChart.mjs";
|
|
2
|
-
import { NiceCircularGauge as
|
|
2
|
+
import { NiceCircularGauge as a } from "./charts/NiceCircularGauge.mjs";
|
|
3
3
|
import { NiceLinearGauge as c } from "./charts/NiceLinearGauge.mjs";
|
|
4
4
|
import { NiceBarGauge as f } from "./charts/NiceBarGauge.mjs";
|
|
5
5
|
import { NiceBullet as x } from "./charts/NiceBullet.mjs";
|
|
@@ -7,36 +7,34 @@ import { NicePieChart as C } from "./charts/NicePieChart.mjs";
|
|
|
7
7
|
import { NiceFunnel as n } from "./charts/NiceFunnel.mjs";
|
|
8
8
|
import { NiceHeatMap as u } from "./charts/NiceHeatMap.mjs";
|
|
9
9
|
import { NiceSankey as S } from "./charts/NiceSankey.mjs";
|
|
10
|
-
import { NiceTreeMap as G } from "./charts/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { CHART_COLORS as j } from "./charts/colors.mjs";
|
|
10
|
+
import { NiceTreeMap as G } from "./charts/NiceAdvancedCharts.mjs";
|
|
11
|
+
import { NiceOrganizationChart as O } from "./charts/NiceOrganizationChart.mjs";
|
|
12
|
+
import { NiceStockChart as A } from "./charts/NiceStockChart.mjs";
|
|
13
|
+
import { NiceSparkline as F } from "./charts/NiceSparkline.mjs";
|
|
14
|
+
import { NicePolarChart as M } from "./charts/NicePolarChart.mjs";
|
|
15
|
+
import { NiceChartRangeSelector as T } from "./charts/NiceChartRangeSelector.mjs";
|
|
16
|
+
import { NiceForecastChart as v } from "./charts/NiceForecastChart.mjs";
|
|
17
|
+
import { NiceLiveChart as z } from "./charts/NiceLiveChart.mjs";
|
|
18
|
+
import { NiceChartAI as _ } from "./charts/NiceChartAI.mjs";
|
|
19
|
+
import { CHART_COLORS as d } from "./charts/colors.mjs";
|
|
21
20
|
export {
|
|
22
|
-
|
|
21
|
+
d as CHART_COLORS,
|
|
23
22
|
f as NiceBarGauge,
|
|
24
23
|
x as NiceBullet,
|
|
25
24
|
o as NiceChart,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
_ as NiceChartAI,
|
|
26
|
+
T as NiceChartRangeSelector,
|
|
27
|
+
a as NiceCircularGauge,
|
|
28
|
+
v as NiceForecastChart,
|
|
29
29
|
n as NiceFunnel,
|
|
30
30
|
u as NiceHeatMap,
|
|
31
31
|
c as NiceLinearGauge,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
z as NiceLiveChart,
|
|
33
|
+
O as NiceOrganizationChart,
|
|
34
34
|
C as NicePieChart,
|
|
35
|
-
|
|
36
|
-
v as NiceRangeSelector,
|
|
35
|
+
M as NicePolarChart,
|
|
37
36
|
S as NiceSankey,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
G as NiceTreeMap
|
|
41
|
-
M as NiceVectorMap
|
|
37
|
+
F as NiceSparkline,
|
|
38
|
+
A as NiceStockChart,
|
|
39
|
+
G as NiceTreeMap
|
|
42
40
|
};
|
package/dist/core/lazy.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as T, jsx as r, Fragment as
|
|
2
|
-
import { useNiceTranslation as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { jsxs as T, jsx as r, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as H, NiceIcon as O } from "@nice2dev/ui-core";
|
|
3
|
+
import V, { lazy as A, useRef as z, useState as F, useEffect as h, Suspense as q } from "react";
|
|
4
|
+
const y = ({
|
|
5
5
|
height: e = 200
|
|
6
6
|
}) => /* @__PURE__ */ r(
|
|
7
7
|
"div",
|
|
@@ -31,8 +31,8 @@ const u = ({
|
|
|
31
31
|
}
|
|
32
32
|
)
|
|
33
33
|
}
|
|
34
|
-
),
|
|
35
|
-
const { t: a } =
|
|
34
|
+
), j = (e, t) => {
|
|
35
|
+
const { t: a } = H();
|
|
36
36
|
return /* @__PURE__ */ T(
|
|
37
37
|
"div",
|
|
38
38
|
{
|
|
@@ -48,7 +48,7 @@ const u = ({
|
|
|
48
48
|
color: "var(--ntd-color-error, #dc2626)"
|
|
49
49
|
},
|
|
50
50
|
children: [
|
|
51
|
-
/* @__PURE__ */ r(
|
|
51
|
+
/* @__PURE__ */ r(O, { name: "error", size: 32 }),
|
|
52
52
|
/* @__PURE__ */ r("p", { style: { margin: "12px 0 8px", fontWeight: 500 }, children: a("lazy.failedToLoadComponent", "Failed to load component") }),
|
|
53
53
|
/* @__PURE__ */ r("p", { style: { margin: 0, fontSize: "0.875em", opacity: 0.8 }, children: e.message }),
|
|
54
54
|
/* @__PURE__ */ r(
|
|
@@ -72,7 +72,7 @@ const u = ({
|
|
|
72
72
|
}
|
|
73
73
|
);
|
|
74
74
|
};
|
|
75
|
-
class
|
|
75
|
+
class M extends V.Component {
|
|
76
76
|
constructor() {
|
|
77
77
|
super(...arguments), this.state = { error: null }, this.handleRetry = () => {
|
|
78
78
|
this.setState({ error: null });
|
|
@@ -87,64 +87,64 @@ class j extends O.Component {
|
|
|
87
87
|
}
|
|
88
88
|
function l(e, t = {}) {
|
|
89
89
|
const {
|
|
90
|
-
fallback: a = /* @__PURE__ */ r(
|
|
90
|
+
fallback: a = /* @__PURE__ */ r(y, {}),
|
|
91
91
|
preloadOnMount: o = !1,
|
|
92
|
-
preloadOnHover:
|
|
92
|
+
preloadOnHover: u = !1,
|
|
93
93
|
preloadAfterIdle: n,
|
|
94
|
-
minLoadingTime:
|
|
94
|
+
minLoadingTime: p = 0,
|
|
95
95
|
ssrFallback: s,
|
|
96
|
-
errorFallback: I =
|
|
96
|
+
errorFallback: I = j,
|
|
97
97
|
displayName: x
|
|
98
98
|
} = t;
|
|
99
|
-
let b = null,
|
|
100
|
-
const
|
|
99
|
+
let b = null, f = !1;
|
|
100
|
+
const m = async () => {
|
|
101
101
|
if (b)
|
|
102
102
|
return b;
|
|
103
103
|
const v = Date.now();
|
|
104
104
|
b = e();
|
|
105
105
|
const k = await b;
|
|
106
|
-
if (
|
|
106
|
+
if (p > 0) {
|
|
107
107
|
const g = Date.now() - v;
|
|
108
|
-
g <
|
|
108
|
+
g < p && await new Promise((c) => setTimeout(c, p - g));
|
|
109
109
|
}
|
|
110
|
-
return
|
|
111
|
-
}, R = A(
|
|
110
|
+
return f = !0, k;
|
|
111
|
+
}, R = A(m), D = (v) => {
|
|
112
112
|
const k = z(null);
|
|
113
|
-
return
|
|
114
|
-
o && !
|
|
115
|
-
}, []),
|
|
116
|
-
if (n && !
|
|
117
|
-
const c = "requestIdleCallback" in window ? window.requestIdleCallback(() =>
|
|
113
|
+
return h(() => {
|
|
114
|
+
o && !f && m();
|
|
115
|
+
}, []), h(() => {
|
|
116
|
+
if (n && !f) {
|
|
117
|
+
const c = "requestIdleCallback" in window ? window.requestIdleCallback(() => m(), {
|
|
118
118
|
timeout: n
|
|
119
|
-
}) : setTimeout(() =>
|
|
119
|
+
}) : setTimeout(() => m(), n);
|
|
120
120
|
return () => {
|
|
121
121
|
"cancelIdleCallback" in window ? window.cancelIdleCallback(c) : clearTimeout(c);
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
}, []),
|
|
125
|
-
if (!
|
|
124
|
+
}, []), h(() => {
|
|
125
|
+
if (!u || f)
|
|
126
126
|
return;
|
|
127
127
|
const c = k.current;
|
|
128
128
|
if (!c)
|
|
129
129
|
return;
|
|
130
|
-
const
|
|
131
|
-
|
|
130
|
+
const C = () => {
|
|
131
|
+
f || m();
|
|
132
132
|
};
|
|
133
|
-
return c.addEventListener("mouseenter",
|
|
134
|
-
}, []), typeof window > "u" && s ? /* @__PURE__ */ r(
|
|
133
|
+
return c.addEventListener("mouseenter", C, { once: !0 }), () => c.removeEventListener("mouseenter", C);
|
|
134
|
+
}, []), typeof window > "u" && s ? /* @__PURE__ */ r(P, { children: s }) : /* @__PURE__ */ r("div", { ref: k, className: "ntd-lazy-wrapper", children: /* @__PURE__ */ r(M, { fallback: I, children: /* @__PURE__ */ r(q, { fallback: a, children: /* @__PURE__ */ r(R, { ...v }) }) }) });
|
|
135
135
|
}, G = async () => {
|
|
136
|
-
|
|
136
|
+
f || await m();
|
|
137
137
|
}, w = D;
|
|
138
138
|
return w.preload = G, w.displayName = x || "LazyComponent", w;
|
|
139
139
|
}
|
|
140
140
|
function K(e = 0.1, t = "100px") {
|
|
141
|
-
const a = z(null), [o,
|
|
142
|
-
return
|
|
141
|
+
const a = z(null), [o, u] = F(!1);
|
|
142
|
+
return h(() => {
|
|
143
143
|
if (!a.current || o)
|
|
144
144
|
return;
|
|
145
145
|
const n = new IntersectionObserver(
|
|
146
|
-
([
|
|
147
|
-
|
|
146
|
+
([p]) => {
|
|
147
|
+
p.isIntersecting && (u(!0), n.disconnect());
|
|
148
148
|
},
|
|
149
149
|
{ threshold: e, rootMargin: t }
|
|
150
150
|
);
|
|
@@ -152,7 +152,7 @@ function K(e = 0.1, t = "100px") {
|
|
|
152
152
|
}, [e, t, o]), [a, o];
|
|
153
153
|
}
|
|
154
154
|
function Q(e, t = 2e3) {
|
|
155
|
-
|
|
155
|
+
h(() => {
|
|
156
156
|
if ("requestIdleCallback" in window) {
|
|
157
157
|
const a = window.requestIdleCallback(
|
|
158
158
|
() => {
|
|
@@ -171,21 +171,21 @@ function Q(e, t = 2e3) {
|
|
|
171
171
|
}
|
|
172
172
|
function U(e, t) {
|
|
173
173
|
const a = z(/* @__PURE__ */ new Set());
|
|
174
|
-
|
|
175
|
-
const o = document.querySelectorAll("a[href]"),
|
|
174
|
+
h(() => {
|
|
175
|
+
const o = document.querySelectorAll("a[href]"), u = (n) => {
|
|
176
176
|
const s = n.currentTarget.getAttribute("href");
|
|
177
177
|
s && e[s] && !a.current.has(s) && (e[s](), a.current.add(s));
|
|
178
178
|
};
|
|
179
179
|
return o.forEach((n) => {
|
|
180
|
-
n.addEventListener("mouseenter",
|
|
180
|
+
n.addEventListener("mouseenter", u);
|
|
181
181
|
}), () => {
|
|
182
182
|
o.forEach((n) => {
|
|
183
|
-
n.removeEventListener("mouseenter",
|
|
183
|
+
n.removeEventListener("mouseenter", u);
|
|
184
184
|
});
|
|
185
185
|
};
|
|
186
186
|
}, [t, e]);
|
|
187
187
|
}
|
|
188
|
-
const
|
|
188
|
+
const N = () => /* @__PURE__ */ r(y, { height: 400 }), S = () => /* @__PURE__ */ r(y, { height: 300 }), L = () => /* @__PURE__ */ r(y, { height: 500 }), E = () => /* @__PURE__ */ r(y, { height: 600 }), i = (e) => e, d = {
|
|
189
189
|
/**
|
|
190
190
|
* Lazy-loaded NiceCodeEditor (Monaco ~2MB)
|
|
191
191
|
*
|
|
@@ -205,7 +205,7 @@ const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */
|
|
|
205
205
|
() => import("../editors/rich/NiceCodeEditor.mjs").then((e) => ({ default: e.NiceCodeEditor }))
|
|
206
206
|
),
|
|
207
207
|
{
|
|
208
|
-
fallback: /* @__PURE__ */ r(
|
|
208
|
+
fallback: /* @__PURE__ */ r(N, {}),
|
|
209
209
|
preloadOnHover: !0,
|
|
210
210
|
displayName: "LazyCodeEditor"
|
|
211
211
|
}
|
|
@@ -218,7 +218,7 @@ const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */
|
|
|
218
218
|
() => import("../editors/rich/NiceHtmlEditor.mjs").then((e) => ({ default: e.NiceHtmlEditor }))
|
|
219
219
|
),
|
|
220
220
|
{
|
|
221
|
-
fallback: /* @__PURE__ */ r(
|
|
221
|
+
fallback: /* @__PURE__ */ r(N, {}),
|
|
222
222
|
preloadOnHover: !0,
|
|
223
223
|
displayName: "LazyHtmlEditor"
|
|
224
224
|
}
|
|
@@ -231,7 +231,7 @@ const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */
|
|
|
231
231
|
() => import("../tools/NiceDocumentViewer.mjs").then((e) => ({ default: e.NiceDocumentViewer }))
|
|
232
232
|
),
|
|
233
233
|
{
|
|
234
|
-
fallback: /* @__PURE__ */ r(
|
|
234
|
+
fallback: /* @__PURE__ */ r(y, { height: 600 }),
|
|
235
235
|
displayName: "LazyDocumentViewer"
|
|
236
236
|
}
|
|
237
237
|
),
|
|
@@ -243,23 +243,11 @@ const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */
|
|
|
243
243
|
() => import("../charts/NiceChart.mjs").then((e) => ({ default: e.NiceChart }))
|
|
244
244
|
),
|
|
245
245
|
{
|
|
246
|
-
fallback: /* @__PURE__ */ r(
|
|
246
|
+
fallback: /* @__PURE__ */ r(S, {}),
|
|
247
247
|
preloadAfterIdle: 3e3,
|
|
248
248
|
displayName: "LazyChart"
|
|
249
249
|
}
|
|
250
250
|
),
|
|
251
|
-
/**
|
|
252
|
-
* Lazy-loaded NiceVectorMap
|
|
253
|
-
*/
|
|
254
|
-
VectorMap: /* @__PURE__ */ l(
|
|
255
|
-
/* @__PURE__ */ i(
|
|
256
|
-
() => import("../charts/NiceVectorMap.mjs").then((e) => ({ default: e.NiceVectorMap }))
|
|
257
|
-
),
|
|
258
|
-
{
|
|
259
|
-
fallback: /* @__PURE__ */ r(u, { height: 400 }),
|
|
260
|
-
displayName: "LazyVectorMap"
|
|
261
|
-
}
|
|
262
|
-
),
|
|
263
251
|
/**
|
|
264
252
|
* Lazy-loaded NiceSankey
|
|
265
253
|
*/
|
|
@@ -268,7 +256,7 @@ const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */
|
|
|
268
256
|
() => import("../charts/NiceSankey.mjs").then((e) => ({ default: e.NiceSankey }))
|
|
269
257
|
),
|
|
270
258
|
{
|
|
271
|
-
fallback: /* @__PURE__ */ r(
|
|
259
|
+
fallback: /* @__PURE__ */ r(S, {}),
|
|
272
260
|
displayName: "LazySankey"
|
|
273
261
|
}
|
|
274
262
|
),
|
|
@@ -304,7 +292,7 @@ const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */
|
|
|
304
292
|
() => import("../data/NicePivotGrid.mjs").then((e) => ({ default: e.NicePivotGrid }))
|
|
305
293
|
),
|
|
306
294
|
{
|
|
307
|
-
fallback: /* @__PURE__ */ r(
|
|
295
|
+
fallback: /* @__PURE__ */ r(L, {}),
|
|
308
296
|
displayName: "LazyPivotGrid"
|
|
309
297
|
}
|
|
310
298
|
),
|
|
@@ -316,7 +304,7 @@ const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */
|
|
|
316
304
|
() => import("../data/NiceDataGrid.mjs").then((e) => ({ default: e.NiceDataGrid }))
|
|
317
305
|
),
|
|
318
306
|
{
|
|
319
|
-
fallback: /* @__PURE__ */ r(
|
|
307
|
+
fallback: /* @__PURE__ */ r(L, {}),
|
|
320
308
|
preloadAfterIdle: 2e3,
|
|
321
309
|
displayName: "LazyDataGrid"
|
|
322
310
|
}
|
|
@@ -328,7 +316,6 @@ async function X() {
|
|
|
328
316
|
d.HtmlEditor.preload(),
|
|
329
317
|
d.DocumentViewer.preload(),
|
|
330
318
|
d.Chart.preload(),
|
|
331
|
-
d.VectorMap.preload(),
|
|
332
319
|
d.Sankey.preload(),
|
|
333
320
|
d.Scheduler.preload(),
|
|
334
321
|
d.Gantt.preload(),
|
|
@@ -339,8 +326,8 @@ async function Y(e) {
|
|
|
339
326
|
await Promise.all(e.map((t) => d[t].preload()));
|
|
340
327
|
}
|
|
341
328
|
export {
|
|
342
|
-
|
|
343
|
-
|
|
329
|
+
j as DefaultErrorFallback,
|
|
330
|
+
y as DefaultLoadingFallback,
|
|
344
331
|
d as LazyComponents,
|
|
345
332
|
l as createLazyComponent,
|
|
346
333
|
X as preloadAllHeavyComponents,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),N=require("@nice2dev/ui-core"),o=require("react"),f=({height:e=200})=>r.jsx("div",{className:"ntd-lazy-loading",style:{display:"flex",alignItems:"center",justifyContent:"center",height:e,background:"var(--ntd-color-surface, #f5f5f5)",borderRadius:"var(--ntd-radius, 8px)",animation:"ntd-pulse 1.5s ease-in-out infinite"},children:r.jsx("div",{className:"ntd-lazy-loading-spinner",style:{width:24,height:24,border:"2px solid var(--ntd-color-border, #ddd)",borderTopColor:"var(--ntd-color-primary, #6366f1)",borderRadius:"50%",animation:"ntd-spin 0.8s linear infinite"}})}),L=(e,t)=>{const{t:n}=N.useNiceTranslation();return r.jsxs("div",{className:"ntd-lazy-error",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,background:"var(--ntd-color-error-bg, #fee2e2)",borderRadius:"var(--ntd-radius, 8px)",color:"var(--ntd-color-error, #dc2626)"},children:[r.jsx(N.NiceIcon,{name:"error",size:32}),r.jsx("p",{style:{margin:"12px 0 8px",fontWeight:500},children:n("lazy.failedToLoadComponent","Failed to load component")}),r.jsx("p",{style:{margin:0,fontSize:"0.875em",opacity:.8},children:e.message}),r.jsx("button",{onClick:t,style:{marginTop:16,padding:"8px 16px",border:"none",borderRadius:"var(--ntd-radius, 8px)",background:"var(--ntd-color-error, #dc2626)",color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:"0.875em"},children:n("lazy.retry","Retry")})]})};class D extends o.Component{constructor(){super(...arguments),this.state={error:null},this.handleRetry=()=>{this.setState({error:null})}}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback(this.state.error,this.handleRetry):this.props.children}}function i(e,t={}){const{fallback:n=r.jsx(f,{}),preloadOnMount:l=!1,preloadOnHover:p=!1,preloadAfterIdle:a,minLoadingTime:m=0,ssrFallback:c,errorFallback:S=L,displayName:P}=t;let b=null,h=!1;const y=async()=>{if(b)return b;const x=Date.now();b=e();const v=await b;if(m>0){const w=Date.now()-x;w<m&&await new Promise(u=>setTimeout(u,m-w))}return h=!0,v},I=o.lazy(y),R=x=>{const v=o.useRef(null);return o.useEffect(()=>{l&&!h&&y()},[]),o.useEffect(()=>{if(a&&!h){const u="requestIdleCallback"in window?window.requestIdleCallback(()=>y(),{timeout:a}):setTimeout(()=>y(),a);return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(u):clearTimeout(u)}}},[]),o.useEffect(()=>{if(!p||h)return;const u=v.current;if(!u)return;const C=()=>{h||y()};return u.addEventListener("mouseenter",C,{once:!0}),()=>u.removeEventListener("mouseenter",C)},[]),typeof window>"u"&&c?r.jsx(r.Fragment,{children:c}):r.jsx("div",{ref:v,className:"ntd-lazy-wrapper",children:r.jsx(D,{fallback:S,children:r.jsx(o.Suspense,{fallback:n,children:r.jsx(I,{...x})})})})},q=async()=>{h||await y()},k=R;return k.preload=q,k.displayName=P||"LazyComponent",k}function G(e=.1,t="100px"){const n=o.useRef(null),[l,p]=o.useState(!1);return o.useEffect(()=>{if(!n.current||l)return;const a=new IntersectionObserver(([m])=>{m.isIntersecting&&(p(!0),a.disconnect())},{threshold:e,rootMargin:t});return a.observe(n.current),()=>a.disconnect()},[e,t,l]),[n,l]}function T(e,t=2e3){o.useEffect(()=>{if("requestIdleCallback"in window){const n=window.requestIdleCallback(()=>{e.forEach(l=>l())},{timeout:t});return()=>window.cancelIdleCallback(n)}else{const n=setTimeout(()=>{e.forEach(l=>l())},t);return()=>clearTimeout(n)}},[])}function H(e,t){const n=o.useRef(new Set);o.useEffect(()=>{const l=document.querySelectorAll("a[href]"),p=a=>{const c=a.currentTarget.getAttribute("href");c&&e[c]&&!n.current.has(c)&&(e[c](),n.current.add(c))};return l.forEach(a=>{a.addEventListener("mouseenter",p)}),()=>{l.forEach(a=>{a.removeEventListener("mouseenter",p)})}},[t,e])}const z=()=>r.jsx(f,{height:400}),g=()=>r.jsx(f,{height:300}),j=()=>r.jsx(f,{height:500}),E=()=>r.jsx(f,{height:600}),d=e=>e,s={CodeEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceCodeEditor-CBgbzwjx.cjs")).then(e=>({default:e.NiceCodeEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyCodeEditor"}),HtmlEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceHtmlEditor-BEWNA_UI.cjs")).then(e=>({default:e.NiceHtmlEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyHtmlEditor"}),DocumentViewer:i(d(()=>Promise.resolve().then(()=>require("./NiceDocumentViewer-CDXAmPp7.cjs")).then(e=>({default:e.NiceDocumentViewer}))),{fallback:r.jsx(f,{height:600}),displayName:"LazyDocumentViewer"}),Chart:i(d(()=>Promise.resolve().then(()=>require("./charts-CSgOgfES.cjs")).then(e=>e.NiceChart$1).then(e=>({default:e.NiceChart}))),{fallback:r.jsx(g,{}),preloadAfterIdle:3e3,displayName:"LazyChart"}),Sankey:i(d(()=>Promise.resolve().then(()=>require("./charts-CSgOgfES.cjs")).then(e=>e.NiceSankey$1).then(e=>({default:e.NiceSankey}))),{fallback:r.jsx(g,{}),displayName:"LazySankey"}),Scheduler:i(d(()=>Promise.resolve().then(()=>require("./NiceScheduler-Dff8fuq_.cjs")).then(e=>e.NiceScheduler$1).then(e=>({default:e.NiceScheduler}))),{fallback:r.jsx(E,{}),displayName:"LazyScheduler"}),Gantt:i(d(()=>Promise.resolve().then(()=>require("./NiceGantt-Drl4gvw9.cjs")).then(e=>({default:e.NiceGantt}))),{fallback:r.jsx(E,{}),displayName:"LazyGantt"}),PivotGrid:i(d(()=>Promise.resolve().then(()=>require("./NicePivotGrid-D53CQ2cY.cjs")).then(e=>e.NicePivotGrid$1).then(e=>({default:e.NicePivotGrid}))),{fallback:r.jsx(j,{}),displayName:"LazyPivotGrid"}),DataGrid:i(d(()=>Promise.resolve().then(()=>require("./NiceDataGrid-Cszjz8NV.cjs")).then(e=>e.NiceDataGrid$1).then(e=>({default:e.NiceDataGrid}))),{fallback:r.jsx(j,{}),preloadAfterIdle:2e3,displayName:"LazyDataGrid"})};async function O(){await Promise.all([s.CodeEditor.preload(),s.HtmlEditor.preload(),s.DocumentViewer.preload(),s.Chart.preload(),s.Sankey.preload(),s.Scheduler.preload(),s.Gantt.preload(),s.PivotGrid.preload()])}async function F(e){await Promise.all(e.map(t=>s[t].preload()))}exports.DefaultErrorFallback=L;exports.DefaultLoadingFallback=f;exports.LazyComponents=s;exports.createLazyComponent=i;exports.preloadAllHeavyComponents=O;exports.preloadComponents=F;exports.useLazyOnVisible=G;exports.usePreloadOnIdle=T;exports.usePreloadOnRouteHint=H;
|