@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/dist/charts.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./charts-C9B548D2.cjs");exports.CHART_COLORS=e.CHART_COLORS;exports.NiceBarGauge=e.NiceBarGauge;exports.NiceBullet=e.NiceBullet;exports.NiceChart=e.NiceChart;exports.NiceChartAI=e.NiceChartAI;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.NiceRangeSelector=e.NiceRangeSelector;exports.NiceSankey=e.NiceSankey;exports.NiceSparkline=e.NiceSparkline;exports.NiceStockChart=e.NiceStockChart;exports.NiceTreeMap=e.NiceTreeMap;exports.NiceVectorMap=e.NiceVectorMap;
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 2D color-intensity grid with optional cell click. */
551
+ /** Props for the {@link NiceHeatMap} component — a matrix coloured by value. */
522
552
  export declare interface NiceHeatMapProps extends NiceStandardProps {
523
- /** 2D data matrix (rows × cols). */
524
- data?: number[][];
525
- /** Column header labels. */
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 header labels. */
557
+ /** Row labels (along the left). */
528
558
  yLabels?: string[];
529
- /** Color scale as [min color, max color]. */
530
- colors?: [string, string];
531
- /** Called when a cell is clicked. */
532
- onCellClick?: (row: number, col: number, value: number) => void;
533
- /** Cell size in px. */
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
- /** Show numeric values inside cells. */
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: string;
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.ForwardRefExoticComponent<NiceTreeMapProps & default_2.RefAttributes<HTMLDivElement>> & {
946
- displayName: string;
947
- };
992
+ export declare const NiceTreeMap: default_2.FC<NiceTreeMapProps>;
948
993
 
949
- /** A hierarchical node in the {@link NiceTreeMap}. */
950
- declare interface NiceTreeMapNode {
951
- /** Unique key. */
952
- key: string;
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 the {@link NiceTreeMap} component — a squarified treemap visualization. */
1003
+ /** Props for {@link NiceTreeMap}. */
964
1004
  export declare interface NiceTreeMapProps extends NiceStandardProps {
965
- /** Root node. */
966
- data: NiceTreeMapNode;
967
- /** SVG width in px. */
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
- /** SVG height in px. */
1014
+ /** Wysokość */
970
1015
  height?: number;
971
- /** Called when a leaf node is clicked. */
972
- onNodeClick?: (node: NiceTreeMapNode) => void;
973
- /** Color palette. */
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 i } from "./charts/NiceCircularGauge.mjs";
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/NiceTreeMap.mjs";
11
- import { NiceVectorMap as M } from "./charts/NiceVectorMap.mjs";
12
- import { NiceOrganizationChart as R } from "./charts/NiceOrganizationChart.mjs";
13
- import { NiceStockChart as B } from "./charts/NiceStockChart.mjs";
14
- import { NiceSparkline as H } from "./charts/NiceSparkline.mjs";
15
- import { NicePolarChart as T } from "./charts/NicePolarChart.mjs";
16
- import { NiceRangeSelector as v } from "./charts/NiceRangeSelector.mjs";
17
- import { NiceForecastChart as z } from "./charts/NiceForecastChart.mjs";
18
- import { NiceLiveChart as V } from "./charts/NiceLiveChart.mjs";
19
- import { NiceChartAI as b } from "./charts/NiceChartAI.mjs";
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
- j as CHART_COLORS,
21
+ d as CHART_COLORS,
23
22
  f as NiceBarGauge,
24
23
  x as NiceBullet,
25
24
  o as NiceChart,
26
- b as NiceChartAI,
27
- i as NiceCircularGauge,
28
- z as NiceForecastChart,
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
- V as NiceLiveChart,
33
- R as NiceOrganizationChart,
32
+ z as NiceLiveChart,
33
+ O as NiceOrganizationChart,
34
34
  C as NicePieChart,
35
- T as NicePolarChart,
36
- v as NiceRangeSelector,
35
+ M as NicePolarChart,
37
36
  S as NiceSankey,
38
- H as NiceSparkline,
39
- B as NiceStockChart,
40
- G as NiceTreeMap,
41
- M as NiceVectorMap
37
+ F as NiceSparkline,
38
+ A as NiceStockChart,
39
+ G as NiceTreeMap
42
40
  };
@@ -1,7 +1,7 @@
1
- import { jsxs as T, jsx as r, Fragment as V } from "react/jsx-runtime";
2
- import { useNiceTranslation as P, NiceIcon as H } from "@nice2dev/ui-core";
3
- import O, { lazy as A, useRef as z, useState as F, useEffect as y, Suspense as M } from "react";
4
- const u = ({
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
- ), q = (e, t) => {
35
- const { t: a } = P();
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(H, { name: "error", size: 32 }),
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 j extends O.Component {
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(u, {}),
90
+ fallback: a = /* @__PURE__ */ r(y, {}),
91
91
  preloadOnMount: o = !1,
92
- preloadOnHover: p = !1,
92
+ preloadOnHover: u = !1,
93
93
  preloadAfterIdle: n,
94
- minLoadingTime: f = 0,
94
+ minLoadingTime: p = 0,
95
95
  ssrFallback: s,
96
- errorFallback: I = q,
96
+ errorFallback: I = j,
97
97
  displayName: x
98
98
  } = t;
99
- let b = null, m = !1;
100
- const h = async () => {
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 (f > 0) {
106
+ if (p > 0) {
107
107
  const g = Date.now() - v;
108
- g < f && await new Promise((c) => setTimeout(c, f - g));
108
+ g < p && await new Promise((c) => setTimeout(c, p - g));
109
109
  }
110
- return m = !0, k;
111
- }, R = A(h), D = (v) => {
110
+ return f = !0, k;
111
+ }, R = A(m), D = (v) => {
112
112
  const k = z(null);
113
- return y(() => {
114
- o && !m && h();
115
- }, []), y(() => {
116
- if (n && !m) {
117
- const c = "requestIdleCallback" in window ? window.requestIdleCallback(() => h(), {
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(() => h(), n);
119
+ }) : setTimeout(() => m(), n);
120
120
  return () => {
121
121
  "cancelIdleCallback" in window ? window.cancelIdleCallback(c) : clearTimeout(c);
122
122
  };
123
123
  }
124
- }, []), y(() => {
125
- if (!p || m)
124
+ }, []), h(() => {
125
+ if (!u || f)
126
126
  return;
127
127
  const c = k.current;
128
128
  if (!c)
129
129
  return;
130
- const N = () => {
131
- m || h();
130
+ const C = () => {
131
+ f || m();
132
132
  };
133
- return c.addEventListener("mouseenter", N, { once: !0 }), () => c.removeEventListener("mouseenter", N);
134
- }, []), typeof window > "u" && s ? /* @__PURE__ */ r(V, { children: s }) : /* @__PURE__ */ r("div", { ref: k, className: "ntd-lazy-wrapper", children: /* @__PURE__ */ r(j, { fallback: I, children: /* @__PURE__ */ r(M, { fallback: a, children: /* @__PURE__ */ r(R, { ...v }) }) }) });
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
- m || await h();
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, p] = F(!1);
142
- return y(() => {
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
- ([f]) => {
147
- f.isIntersecting && (p(!0), n.disconnect());
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
- y(() => {
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
- y(() => {
175
- const o = document.querySelectorAll("a[href]"), p = (n) => {
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", p);
180
+ n.addEventListener("mouseenter", u);
181
181
  }), () => {
182
182
  o.forEach((n) => {
183
- n.removeEventListener("mouseenter", p);
183
+ n.removeEventListener("mouseenter", u);
184
184
  });
185
185
  };
186
186
  }, [t, e]);
187
187
  }
188
- const C = () => /* @__PURE__ */ r(u, { height: 400 }), L = () => /* @__PURE__ */ r(u, { height: 300 }), S = () => /* @__PURE__ */ r(u, { height: 500 }), E = () => /* @__PURE__ */ r(u, { height: 600 }), i = (e) => e, d = {
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(C, {}),
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(C, {}),
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(u, { height: 600 }),
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(L, {}),
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(L, {}),
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(S, {}),
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(S, {}),
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
- q as DefaultErrorFallback,
343
- u as DefaultLoadingFallback,
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;