@pactor-app/ui 1.22.0 → 1.23.0

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.
@@ -9425,10 +9425,10 @@ function EChartBase({
9425
9425
  dataIndex: params.dataIndex
9426
9426
  });
9427
9427
  });
9428
- const observer = new ResizeObserver(() => chart?.resize());
9429
- observer.observe(host);
9428
+ const observer2 = new ResizeObserver(() => chart?.resize());
9429
+ observer2.observe(host);
9430
9430
  return () => {
9431
- observer.disconnect();
9431
+ observer2.disconnect();
9432
9432
  chart?.dispose();
9433
9433
  chartRef.current = null;
9434
9434
  };
@@ -9889,6 +9889,9 @@ function buildComposedOption(input, theme) {
9889
9889
  };
9890
9890
  }
9891
9891
 
9892
+ // src/components/chart/lib/use-chart-theme.ts
9893
+ import { useSyncExternalStore } from "react";
9894
+
9892
9895
  // src/components/chart/lib/color.ts
9893
9896
  var LPAREN = String.fromCharCode(40);
9894
9897
  var RPAREN = String.fromCharCode(41);
@@ -9985,6 +9988,64 @@ function getChartTheme() {
9985
9988
  return FALLBACK_THEME;
9986
9989
  }
9987
9990
  }
9991
+ function resetChartTheme() {
9992
+ cached = null;
9993
+ }
9994
+ var CHART_SKIN_CHANGE_EVENT = "pactor:skin-change";
9995
+ var listeners = /* @__PURE__ */ new Set();
9996
+ var observer = null;
9997
+ var scheduled = false;
9998
+ function scheduleNotify() {
9999
+ if (scheduled) return;
10000
+ scheduled = true;
10001
+ const enqueue = typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
10002
+ enqueue(() => {
10003
+ scheduled = false;
10004
+ resetChartTheme();
10005
+ for (const listener of [...listeners]) {
10006
+ listener();
10007
+ }
10008
+ });
10009
+ }
10010
+ function handleResourceLoad(event) {
10011
+ const target = event.target;
10012
+ if (target instanceof HTMLLinkElement || target instanceof HTMLStyleElement) {
10013
+ scheduleNotify();
10014
+ }
10015
+ }
10016
+ function subscribeChartTheme(listener) {
10017
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") {
10018
+ return () => {
10019
+ };
10020
+ }
10021
+ listeners.add(listener);
10022
+ if (!observer) {
10023
+ observer = new MutationObserver(scheduleNotify);
10024
+ observer.observe(document.documentElement, { attributes: true });
10025
+ observer.observe(document.head, {
10026
+ attributes: true,
10027
+ childList: true,
10028
+ characterData: true,
10029
+ subtree: true
10030
+ });
10031
+ document.addEventListener("load", handleResourceLoad, true);
10032
+ window.addEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
10033
+ }
10034
+ return () => {
10035
+ listeners.delete(listener);
10036
+ if (listeners.size === 0 && observer) {
10037
+ observer.disconnect();
10038
+ observer = null;
10039
+ document.removeEventListener("load", handleResourceLoad, true);
10040
+ window.removeEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
10041
+ }
10042
+ };
10043
+ }
10044
+
10045
+ // src/components/chart/lib/use-chart-theme.ts
10046
+ function useChartTheme() {
10047
+ return useSyncExternalStore(subscribeChartTheme, getChartTheme, getChartTheme);
10048
+ }
9988
10049
 
9989
10050
  // src/components/chart/AreaChart/index.tsx
9990
10051
  import { jsx as jsx131 } from "react/jsx-runtime";
@@ -10003,7 +10064,7 @@ function AreaChart({
10003
10064
  }) {
10004
10065
  const option = buildAreaOption(
10005
10066
  { data, xKey, yKeys, stacked, fillOpacity, colors, title },
10006
- getChartTheme()
10067
+ useChartTheme()
10007
10068
  );
10008
10069
  return /* @__PURE__ */ jsx131(
10009
10070
  EChartBase,
@@ -10034,7 +10095,7 @@ function BarChart2({
10034
10095
  }) {
10035
10096
  const option = buildBarOption(
10036
10097
  { data, yKey, yKeys: xKeys, stacked, colors, title },
10037
- getChartTheme()
10098
+ useChartTheme()
10038
10099
  );
10039
10100
  return /* @__PURE__ */ jsx132(
10040
10101
  EChartBase,
@@ -10066,7 +10127,7 @@ function BubbleChart({
10066
10127
  }) {
10067
10128
  const option = buildBubbleOption(
10068
10129
  { data, xKey, yKey, sizeKey, seriesKey, colors, title },
10069
- getChartTheme()
10130
+ useChartTheme()
10070
10131
  );
10071
10132
  return /* @__PURE__ */ jsx133(
10072
10133
  EChartBase,
@@ -10097,7 +10158,7 @@ function ColumnChart({
10097
10158
  }) {
10098
10159
  const option = buildColumnOption(
10099
10160
  { data, xKey, yKeys, stacked, colors, title },
10100
- getChartTheme()
10161
+ useChartTheme()
10101
10162
  );
10102
10163
  return /* @__PURE__ */ jsx134(
10103
10164
  EChartBase,
@@ -10127,7 +10188,7 @@ function ComposedChart({
10127
10188
  }) {
10128
10189
  const option = buildComposedOption(
10129
10190
  { data, xKey, series, colors, title },
10130
- getChartTheme()
10191
+ useChartTheme()
10131
10192
  );
10132
10193
  return /* @__PURE__ */ jsx135(
10133
10194
  EChartBase,
@@ -10173,7 +10234,7 @@ function DonutChart({
10173
10234
  colors,
10174
10235
  title
10175
10236
  },
10176
- getChartTheme()
10237
+ useChartTheme()
10177
10238
  );
10178
10239
  return /* @__PURE__ */ jsx136(
10179
10240
  EChartBase,
@@ -10204,7 +10265,7 @@ function FunnelChart2({
10204
10265
  }) {
10205
10266
  const option = buildFunnelOption(
10206
10267
  { data, nameKey, valueKey, sort, colors, title },
10207
- getChartTheme()
10268
+ useChartTheme()
10208
10269
  );
10209
10270
  return /* @__PURE__ */ jsx137(
10210
10271
  EChartBase,
@@ -10235,7 +10296,7 @@ function GaugeChart2({
10235
10296
  }) {
10236
10297
  const option = buildGaugeOption(
10237
10298
  { value, min, max, thresholds, unit, title },
10238
- getChartTheme()
10299
+ useChartTheme()
10239
10300
  );
10240
10301
  return /* @__PURE__ */ jsx138(
10241
10302
  EChartBase,
@@ -10265,7 +10326,7 @@ function Heatmap({
10265
10326
  }) {
10266
10327
  const option = buildHeatmapOption(
10267
10328
  { data, xKey, yKey, valueKey, title },
10268
- getChartTheme()
10329
+ useChartTheme()
10269
10330
  );
10270
10331
  return /* @__PURE__ */ jsx139(
10271
10332
  EChartBase,
@@ -10298,7 +10359,7 @@ function LineChart2({
10298
10359
  }) {
10299
10360
  const option = buildLineOption(
10300
10361
  { data, xKey, yKeys, smooth, showArea, stacked, colors, title },
10301
- getChartTheme()
10362
+ useChartTheme()
10302
10363
  );
10303
10364
  return /* @__PURE__ */ jsx140(
10304
10365
  EChartBase,
@@ -10337,6 +10398,7 @@ function MapChart2({
10337
10398
  className,
10338
10399
  style
10339
10400
  }) {
10401
+ const theme = useChartTheme();
10340
10402
  const [loadState, setLoadState] = useState46(
10341
10403
  () => geoJson || !geoJsonUrl || hasRegisteredMap(mapName) ? "idle" : "loading"
10342
10404
  );
@@ -10403,7 +10465,7 @@ function MapChart2({
10403
10465
  }
10404
10466
  );
10405
10467
  }
10406
- const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, getChartTheme());
10468
+ const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, theme);
10407
10469
  return /* @__PURE__ */ jsx141(
10408
10470
  EChartBase,
10409
10471
  {
@@ -10490,7 +10552,7 @@ function PieChart2({
10490
10552
  }) {
10491
10553
  const option = buildPieOption(
10492
10554
  { data, nameKey, valueKey, showLabel, colors, title },
10493
- getChartTheme()
10555
+ useChartTheme()
10494
10556
  );
10495
10557
  return /* @__PURE__ */ jsx143(
10496
10558
  EChartBase,
@@ -10520,7 +10582,7 @@ function RadarChart2({
10520
10582
  }) {
10521
10583
  const option = buildRadarOption(
10522
10584
  { data, indicatorKey, yKeys, colors, title },
10523
- getChartTheme()
10585
+ useChartTheme()
10524
10586
  );
10525
10587
  return /* @__PURE__ */ jsx144(
10526
10588
  EChartBase,
@@ -10546,7 +10608,7 @@ function SankeyChart2({
10546
10608
  className,
10547
10609
  style
10548
10610
  }) {
10549
- const option = buildSankeyOption({ nodes, links, title }, getChartTheme());
10611
+ const option = buildSankeyOption({ nodes, links, title }, useChartTheme());
10550
10612
  return /* @__PURE__ */ jsx145(
10551
10613
  EChartBase,
10552
10614
  {
@@ -10576,7 +10638,7 @@ function ScatterChart2({
10576
10638
  }) {
10577
10639
  const option = buildScatterOption(
10578
10640
  { data, xKey, yKey, seriesKey, colors, title },
10579
- getChartTheme()
10641
+ useChartTheme()
10580
10642
  );
10581
10643
  return /* @__PURE__ */ jsx146(
10582
10644
  EChartBase,
@@ -10606,7 +10668,7 @@ function TreeChart2({
10606
10668
  }) {
10607
10669
  const option = buildTreeOption(
10608
10670
  { data, title, orient, edgeShape, initialTreeDepth },
10609
- getChartTheme()
10671
+ useChartTheme()
10610
10672
  );
10611
10673
  return /* @__PURE__ */ jsx147(
10612
10674
  EChartBase,
@@ -13660,10 +13660,10 @@ function EChartBase({
13660
13660
  dataIndex: params.dataIndex
13661
13661
  });
13662
13662
  });
13663
- const observer = new ResizeObserver(() => chart?.resize());
13664
- observer.observe(host);
13663
+ const observer2 = new ResizeObserver(() => chart?.resize());
13664
+ observer2.observe(host);
13665
13665
  return () => {
13666
- observer.disconnect();
13666
+ observer2.disconnect();
13667
13667
  chart?.dispose();
13668
13668
  chartRef.current = null;
13669
13669
  };
@@ -14124,6 +14124,9 @@ function buildComposedOption(input, theme) {
14124
14124
  };
14125
14125
  }
14126
14126
 
14127
+ // src/components/chart/lib/use-chart-theme.ts
14128
+ var import_react69 = require("react");
14129
+
14127
14130
  // src/components/chart/lib/color.ts
14128
14131
  var LPAREN = String.fromCharCode(40);
14129
14132
  var RPAREN = String.fromCharCode(41);
@@ -14220,6 +14223,64 @@ function getChartTheme() {
14220
14223
  return FALLBACK_THEME;
14221
14224
  }
14222
14225
  }
14226
+ function resetChartTheme() {
14227
+ cached = null;
14228
+ }
14229
+ var CHART_SKIN_CHANGE_EVENT = "pactor:skin-change";
14230
+ var listeners = /* @__PURE__ */ new Set();
14231
+ var observer = null;
14232
+ var scheduled = false;
14233
+ function scheduleNotify() {
14234
+ if (scheduled) return;
14235
+ scheduled = true;
14236
+ const enqueue = typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
14237
+ enqueue(() => {
14238
+ scheduled = false;
14239
+ resetChartTheme();
14240
+ for (const listener of [...listeners]) {
14241
+ listener();
14242
+ }
14243
+ });
14244
+ }
14245
+ function handleResourceLoad(event) {
14246
+ const target = event.target;
14247
+ if (target instanceof HTMLLinkElement || target instanceof HTMLStyleElement) {
14248
+ scheduleNotify();
14249
+ }
14250
+ }
14251
+ function subscribeChartTheme(listener) {
14252
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") {
14253
+ return () => {
14254
+ };
14255
+ }
14256
+ listeners.add(listener);
14257
+ if (!observer) {
14258
+ observer = new MutationObserver(scheduleNotify);
14259
+ observer.observe(document.documentElement, { attributes: true });
14260
+ observer.observe(document.head, {
14261
+ attributes: true,
14262
+ childList: true,
14263
+ characterData: true,
14264
+ subtree: true
14265
+ });
14266
+ document.addEventListener("load", handleResourceLoad, true);
14267
+ window.addEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
14268
+ }
14269
+ return () => {
14270
+ listeners.delete(listener);
14271
+ if (listeners.size === 0 && observer) {
14272
+ observer.disconnect();
14273
+ observer = null;
14274
+ document.removeEventListener("load", handleResourceLoad, true);
14275
+ window.removeEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
14276
+ }
14277
+ };
14278
+ }
14279
+
14280
+ // src/components/chart/lib/use-chart-theme.ts
14281
+ function useChartTheme() {
14282
+ return (0, import_react69.useSyncExternalStore)(subscribeChartTheme, getChartTheme, getChartTheme);
14283
+ }
14223
14284
 
14224
14285
  // src/components/chart/AreaChart/index.tsx
14225
14286
  var import_jsx_runtime189 = require("react/jsx-runtime");
@@ -14238,7 +14299,7 @@ function AreaChart({
14238
14299
  }) {
14239
14300
  const option = buildAreaOption(
14240
14301
  { data, xKey, yKeys, stacked, fillOpacity, colors, title },
14241
- getChartTheme()
14302
+ useChartTheme()
14242
14303
  );
14243
14304
  return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
14244
14305
  EChartBase,
@@ -14269,7 +14330,7 @@ function BarChart2({
14269
14330
  }) {
14270
14331
  const option = buildBarOption(
14271
14332
  { data, yKey, yKeys: xKeys, stacked, colors, title },
14272
- getChartTheme()
14333
+ useChartTheme()
14273
14334
  );
14274
14335
  return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
14275
14336
  EChartBase,
@@ -14301,7 +14362,7 @@ function BubbleChart({
14301
14362
  }) {
14302
14363
  const option = buildBubbleOption(
14303
14364
  { data, xKey, yKey, sizeKey, seriesKey, colors, title },
14304
- getChartTheme()
14365
+ useChartTheme()
14305
14366
  );
14306
14367
  return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
14307
14368
  EChartBase,
@@ -14332,7 +14393,7 @@ function ColumnChart({
14332
14393
  }) {
14333
14394
  const option = buildColumnOption(
14334
14395
  { data, xKey, yKeys, stacked, colors, title },
14335
- getChartTheme()
14396
+ useChartTheme()
14336
14397
  );
14337
14398
  return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(
14338
14399
  EChartBase,
@@ -14362,7 +14423,7 @@ function ComposedChart({
14362
14423
  }) {
14363
14424
  const option = buildComposedOption(
14364
14425
  { data, xKey, series, colors, title },
14365
- getChartTheme()
14426
+ useChartTheme()
14366
14427
  );
14367
14428
  return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
14368
14429
  EChartBase,
@@ -14408,7 +14469,7 @@ function DonutChart({
14408
14469
  colors,
14409
14470
  title
14410
14471
  },
14411
- getChartTheme()
14472
+ useChartTheme()
14412
14473
  );
14413
14474
  return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
14414
14475
  EChartBase,
@@ -14439,7 +14500,7 @@ function FunnelChart2({
14439
14500
  }) {
14440
14501
  const option = buildFunnelOption(
14441
14502
  { data, nameKey, valueKey, sort, colors, title },
14442
- getChartTheme()
14503
+ useChartTheme()
14443
14504
  );
14444
14505
  return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
14445
14506
  EChartBase,
@@ -14470,7 +14531,7 @@ function GaugeChart2({
14470
14531
  }) {
14471
14532
  const option = buildGaugeOption(
14472
14533
  { value, min, max, thresholds, unit, title },
14473
- getChartTheme()
14534
+ useChartTheme()
14474
14535
  );
14475
14536
  return /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
14476
14537
  EChartBase,
@@ -14500,7 +14561,7 @@ function Heatmap({
14500
14561
  }) {
14501
14562
  const option = buildHeatmapOption(
14502
14563
  { data, xKey, yKey, valueKey, title },
14503
- getChartTheme()
14564
+ useChartTheme()
14504
14565
  );
14505
14566
  return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
14506
14567
  EChartBase,
@@ -14533,7 +14594,7 @@ function LineChart2({
14533
14594
  }) {
14534
14595
  const option = buildLineOption(
14535
14596
  { data, xKey, yKeys, smooth, showArea, stacked, colors, title },
14536
- getChartTheme()
14597
+ useChartTheme()
14537
14598
  );
14538
14599
  return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
14539
14600
  EChartBase,
@@ -14549,7 +14610,7 @@ function LineChart2({
14549
14610
  }
14550
14611
 
14551
14612
  // src/components/chart/MapChart/index.tsx
14552
- var import_react69 = require("react");
14613
+ var import_react70 = require("react");
14553
14614
  var import_jsx_runtime199 = require("react/jsx-runtime");
14554
14615
  var fetchedMaps = /* @__PURE__ */ new Set();
14555
14616
  function hasRegisteredMap(mapName) {
@@ -14572,7 +14633,8 @@ function MapChart2({
14572
14633
  className,
14573
14634
  style
14574
14635
  }) {
14575
- const [loadState, setLoadState] = (0, import_react69.useState)(
14636
+ const theme = useChartTheme();
14637
+ const [loadState, setLoadState] = (0, import_react70.useState)(
14576
14638
  () => geoJson || !geoJsonUrl || hasRegisteredMap(mapName) ? "idle" : "loading"
14577
14639
  );
14578
14640
  if (geoJson) {
@@ -14581,7 +14643,7 @@ function MapChart2({
14581
14643
  } catch {
14582
14644
  }
14583
14645
  }
14584
- (0, import_react69.useEffect)(() => {
14646
+ (0, import_react70.useEffect)(() => {
14585
14647
  if (geoJson || !geoJsonUrl || hasRegisteredMap(mapName) || fetchedMaps.has(mapName)) {
14586
14648
  setLoadState("idle");
14587
14649
  return;
@@ -14638,7 +14700,7 @@ function MapChart2({
14638
14700
  }
14639
14701
  );
14640
14702
  }
14641
- const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, getChartTheme());
14703
+ const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, theme);
14642
14704
  return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
14643
14705
  EChartBase,
14644
14706
  {
@@ -14725,7 +14787,7 @@ function PieChart2({
14725
14787
  }) {
14726
14788
  const option = buildPieOption(
14727
14789
  { data, nameKey, valueKey, showLabel, colors, title },
14728
- getChartTheme()
14790
+ useChartTheme()
14729
14791
  );
14730
14792
  return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
14731
14793
  EChartBase,
@@ -14755,7 +14817,7 @@ function RadarChart2({
14755
14817
  }) {
14756
14818
  const option = buildRadarOption(
14757
14819
  { data, indicatorKey, yKeys, colors, title },
14758
- getChartTheme()
14820
+ useChartTheme()
14759
14821
  );
14760
14822
  return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
14761
14823
  EChartBase,
@@ -14781,7 +14843,7 @@ function SankeyChart2({
14781
14843
  className,
14782
14844
  style
14783
14845
  }) {
14784
- const option = buildSankeyOption({ nodes, links, title }, getChartTheme());
14846
+ const option = buildSankeyOption({ nodes, links, title }, useChartTheme());
14785
14847
  return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
14786
14848
  EChartBase,
14787
14849
  {
@@ -14811,7 +14873,7 @@ function ScatterChart2({
14811
14873
  }) {
14812
14874
  const option = buildScatterOption(
14813
14875
  { data, xKey, yKey, seriesKey, colors, title },
14814
- getChartTheme()
14876
+ useChartTheme()
14815
14877
  );
14816
14878
  return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(
14817
14879
  EChartBase,
@@ -14841,7 +14903,7 @@ function TreeChart2({
14841
14903
  }) {
14842
14904
  const option = buildTreeOption(
14843
14905
  { data, title, orient, edgeShape, initialTreeDepth },
14844
- getChartTheme()
14906
+ useChartTheme()
14845
14907
  );
14846
14908
  return /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(
14847
14909
  EChartBase,
@@ -151,7 +151,7 @@ import {
151
151
  inferKind,
152
152
  registerBuiltinComponents,
153
153
  useFormContext
154
- } from "../chunk-EDUMGNT6.js";
154
+ } from "../chunk-VTCNWVKQ.js";
155
155
  import {
156
156
  ICONS,
157
157
  Icon,
package/dist/index.cjs CHANGED
@@ -13699,10 +13699,10 @@ function EChartBase({
13699
13699
  dataIndex: params.dataIndex
13700
13700
  });
13701
13701
  });
13702
- const observer = new ResizeObserver(() => chart?.resize());
13703
- observer.observe(host);
13702
+ const observer2 = new ResizeObserver(() => chart?.resize());
13703
+ observer2.observe(host);
13704
13704
  return () => {
13705
- observer.disconnect();
13705
+ observer2.disconnect();
13706
13706
  chart?.dispose();
13707
13707
  chartRef.current = null;
13708
13708
  };
@@ -14163,6 +14163,9 @@ function buildComposedOption(input, theme) {
14163
14163
  };
14164
14164
  }
14165
14165
 
14166
+ // src/components/chart/lib/use-chart-theme.ts
14167
+ var import_react69 = require("react");
14168
+
14166
14169
  // src/components/chart/lib/color.ts
14167
14170
  var LPAREN = String.fromCharCode(40);
14168
14171
  var RPAREN = String.fromCharCode(41);
@@ -14259,6 +14262,64 @@ function getChartTheme() {
14259
14262
  return FALLBACK_THEME;
14260
14263
  }
14261
14264
  }
14265
+ function resetChartTheme() {
14266
+ cached = null;
14267
+ }
14268
+ var CHART_SKIN_CHANGE_EVENT = "pactor:skin-change";
14269
+ var listeners = /* @__PURE__ */ new Set();
14270
+ var observer = null;
14271
+ var scheduled = false;
14272
+ function scheduleNotify() {
14273
+ if (scheduled) return;
14274
+ scheduled = true;
14275
+ const enqueue = typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
14276
+ enqueue(() => {
14277
+ scheduled = false;
14278
+ resetChartTheme();
14279
+ for (const listener of [...listeners]) {
14280
+ listener();
14281
+ }
14282
+ });
14283
+ }
14284
+ function handleResourceLoad(event) {
14285
+ const target = event.target;
14286
+ if (target instanceof HTMLLinkElement || target instanceof HTMLStyleElement) {
14287
+ scheduleNotify();
14288
+ }
14289
+ }
14290
+ function subscribeChartTheme(listener) {
14291
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") {
14292
+ return () => {
14293
+ };
14294
+ }
14295
+ listeners.add(listener);
14296
+ if (!observer) {
14297
+ observer = new MutationObserver(scheduleNotify);
14298
+ observer.observe(document.documentElement, { attributes: true });
14299
+ observer.observe(document.head, {
14300
+ attributes: true,
14301
+ childList: true,
14302
+ characterData: true,
14303
+ subtree: true
14304
+ });
14305
+ document.addEventListener("load", handleResourceLoad, true);
14306
+ window.addEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
14307
+ }
14308
+ return () => {
14309
+ listeners.delete(listener);
14310
+ if (listeners.size === 0 && observer) {
14311
+ observer.disconnect();
14312
+ observer = null;
14313
+ document.removeEventListener("load", handleResourceLoad, true);
14314
+ window.removeEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
14315
+ }
14316
+ };
14317
+ }
14318
+
14319
+ // src/components/chart/lib/use-chart-theme.ts
14320
+ function useChartTheme() {
14321
+ return (0, import_react69.useSyncExternalStore)(subscribeChartTheme, getChartTheme, getChartTheme);
14322
+ }
14262
14323
 
14263
14324
  // src/components/chart/AreaChart/index.tsx
14264
14325
  var import_jsx_runtime189 = require("react/jsx-runtime");
@@ -14277,7 +14338,7 @@ function AreaChart({
14277
14338
  }) {
14278
14339
  const option = buildAreaOption(
14279
14340
  { data, xKey, yKeys, stacked, fillOpacity, colors, title },
14280
- getChartTheme()
14341
+ useChartTheme()
14281
14342
  );
14282
14343
  return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
14283
14344
  EChartBase,
@@ -14308,7 +14369,7 @@ function BarChart2({
14308
14369
  }) {
14309
14370
  const option = buildBarOption(
14310
14371
  { data, yKey, yKeys: xKeys, stacked, colors, title },
14311
- getChartTheme()
14372
+ useChartTheme()
14312
14373
  );
14313
14374
  return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
14314
14375
  EChartBase,
@@ -14340,7 +14401,7 @@ function BubbleChart({
14340
14401
  }) {
14341
14402
  const option = buildBubbleOption(
14342
14403
  { data, xKey, yKey, sizeKey, seriesKey, colors, title },
14343
- getChartTheme()
14404
+ useChartTheme()
14344
14405
  );
14345
14406
  return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
14346
14407
  EChartBase,
@@ -14371,7 +14432,7 @@ function ColumnChart({
14371
14432
  }) {
14372
14433
  const option = buildColumnOption(
14373
14434
  { data, xKey, yKeys, stacked, colors, title },
14374
- getChartTheme()
14435
+ useChartTheme()
14375
14436
  );
14376
14437
  return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(
14377
14438
  EChartBase,
@@ -14401,7 +14462,7 @@ function ComposedChart({
14401
14462
  }) {
14402
14463
  const option = buildComposedOption(
14403
14464
  { data, xKey, series, colors, title },
14404
- getChartTheme()
14465
+ useChartTheme()
14405
14466
  );
14406
14467
  return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
14407
14468
  EChartBase,
@@ -14447,7 +14508,7 @@ function DonutChart({
14447
14508
  colors,
14448
14509
  title
14449
14510
  },
14450
- getChartTheme()
14511
+ useChartTheme()
14451
14512
  );
14452
14513
  return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
14453
14514
  EChartBase,
@@ -14478,7 +14539,7 @@ function FunnelChart2({
14478
14539
  }) {
14479
14540
  const option = buildFunnelOption(
14480
14541
  { data, nameKey, valueKey, sort, colors, title },
14481
- getChartTheme()
14542
+ useChartTheme()
14482
14543
  );
14483
14544
  return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
14484
14545
  EChartBase,
@@ -14509,7 +14570,7 @@ function GaugeChart2({
14509
14570
  }) {
14510
14571
  const option = buildGaugeOption(
14511
14572
  { value, min, max, thresholds, unit, title },
14512
- getChartTheme()
14573
+ useChartTheme()
14513
14574
  );
14514
14575
  return /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
14515
14576
  EChartBase,
@@ -14539,7 +14600,7 @@ function Heatmap({
14539
14600
  }) {
14540
14601
  const option = buildHeatmapOption(
14541
14602
  { data, xKey, yKey, valueKey, title },
14542
- getChartTheme()
14603
+ useChartTheme()
14543
14604
  );
14544
14605
  return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
14545
14606
  EChartBase,
@@ -14572,7 +14633,7 @@ function LineChart2({
14572
14633
  }) {
14573
14634
  const option = buildLineOption(
14574
14635
  { data, xKey, yKeys, smooth, showArea, stacked, colors, title },
14575
- getChartTheme()
14636
+ useChartTheme()
14576
14637
  );
14577
14638
  return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
14578
14639
  EChartBase,
@@ -14588,7 +14649,7 @@ function LineChart2({
14588
14649
  }
14589
14650
 
14590
14651
  // src/components/chart/MapChart/index.tsx
14591
- var import_react69 = require("react");
14652
+ var import_react70 = require("react");
14592
14653
  var import_jsx_runtime199 = require("react/jsx-runtime");
14593
14654
  var fetchedMaps = /* @__PURE__ */ new Set();
14594
14655
  function hasRegisteredMap(mapName) {
@@ -14611,7 +14672,8 @@ function MapChart2({
14611
14672
  className,
14612
14673
  style
14613
14674
  }) {
14614
- const [loadState, setLoadState] = (0, import_react69.useState)(
14675
+ const theme = useChartTheme();
14676
+ const [loadState, setLoadState] = (0, import_react70.useState)(
14615
14677
  () => geoJson || !geoJsonUrl || hasRegisteredMap(mapName) ? "idle" : "loading"
14616
14678
  );
14617
14679
  if (geoJson) {
@@ -14620,7 +14682,7 @@ function MapChart2({
14620
14682
  } catch {
14621
14683
  }
14622
14684
  }
14623
- (0, import_react69.useEffect)(() => {
14685
+ (0, import_react70.useEffect)(() => {
14624
14686
  if (geoJson || !geoJsonUrl || hasRegisteredMap(mapName) || fetchedMaps.has(mapName)) {
14625
14687
  setLoadState("idle");
14626
14688
  return;
@@ -14677,7 +14739,7 @@ function MapChart2({
14677
14739
  }
14678
14740
  );
14679
14741
  }
14680
- const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, getChartTheme());
14742
+ const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, theme);
14681
14743
  return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
14682
14744
  EChartBase,
14683
14745
  {
@@ -14764,7 +14826,7 @@ function PieChart2({
14764
14826
  }) {
14765
14827
  const option = buildPieOption(
14766
14828
  { data, nameKey, valueKey, showLabel, colors, title },
14767
- getChartTheme()
14829
+ useChartTheme()
14768
14830
  );
14769
14831
  return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
14770
14832
  EChartBase,
@@ -14794,7 +14856,7 @@ function RadarChart2({
14794
14856
  }) {
14795
14857
  const option = buildRadarOption(
14796
14858
  { data, indicatorKey, yKeys, colors, title },
14797
- getChartTheme()
14859
+ useChartTheme()
14798
14860
  );
14799
14861
  return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
14800
14862
  EChartBase,
@@ -14820,7 +14882,7 @@ function SankeyChart2({
14820
14882
  className,
14821
14883
  style
14822
14884
  }) {
14823
- const option = buildSankeyOption({ nodes, links, title }, getChartTheme());
14885
+ const option = buildSankeyOption({ nodes, links, title }, useChartTheme());
14824
14886
  return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
14825
14887
  EChartBase,
14826
14888
  {
@@ -14850,7 +14912,7 @@ function ScatterChart2({
14850
14912
  }) {
14851
14913
  const option = buildScatterOption(
14852
14914
  { data, xKey, yKey, seriesKey, colors, title },
14853
- getChartTheme()
14915
+ useChartTheme()
14854
14916
  );
14855
14917
  return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(
14856
14918
  EChartBase,
@@ -14880,7 +14942,7 @@ function TreeChart2({
14880
14942
  }) {
14881
14943
  const option = buildTreeOption(
14882
14944
  { data, title, orient, edgeShape, initialTreeDepth },
14883
- getChartTheme()
14945
+ useChartTheme()
14884
14946
  );
14885
14947
  return /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(
14886
14948
  EChartBase,
@@ -15117,10 +15179,10 @@ function collectDefaultOpenKeys(registry, activeMenuId) {
15117
15179
  var import_permission = require("@pactor-app/permission");
15118
15180
  var import_router = require("@pactor-app/router");
15119
15181
  var import_runtime27 = require("@pactor-app/runtime");
15120
- var import_react71 = require("react");
15182
+ var import_react72 = require("react");
15121
15183
 
15122
15184
  // src/layout/admin/use-media-query.ts
15123
- var import_react70 = require("react");
15185
+ var import_react71 = require("react");
15124
15186
  var BREAKPOINT_PX = {
15125
15187
  xs: 480,
15126
15188
  sm: 576,
@@ -15130,10 +15192,10 @@ var BREAKPOINT_PX = {
15130
15192
  xxl: 1600
15131
15193
  };
15132
15194
  function useMediaQuery(query) {
15133
- const [matches, setMatches] = (0, import_react70.useState)(
15195
+ const [matches, setMatches] = (0, import_react71.useState)(
15134
15196
  () => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : false
15135
15197
  );
15136
- (0, import_react70.useEffect)(() => {
15198
+ (0, import_react71.useEffect)(() => {
15137
15199
  if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
15138
15200
  return;
15139
15201
  }
@@ -15176,8 +15238,8 @@ function CollapsedGroupFlyout({
15176
15238
  activeMenuId,
15177
15239
  defaultOpenKeys
15178
15240
  }) {
15179
- const [open, setOpen] = (0, import_react71.useState)(false);
15180
- const closeTimer = (0, import_react71.useRef)(void 0);
15241
+ const [open, setOpen] = (0, import_react72.useState)(false);
15242
+ const closeTimer = (0, import_react72.useRef)(void 0);
15181
15243
  const openNow = () => {
15182
15244
  window.clearTimeout(closeTimer.current);
15183
15245
  setOpen(true);
@@ -15186,7 +15248,7 @@ function CollapsedGroupFlyout({
15186
15248
  window.clearTimeout(closeTimer.current);
15187
15249
  closeTimer.current = window.setTimeout(() => setOpen(false), 200);
15188
15250
  };
15189
- (0, import_react71.useEffect)(() => () => window.clearTimeout(closeTimer.current), []);
15251
+ (0, import_react72.useEffect)(() => () => window.clearTimeout(closeTimer.current), []);
15190
15252
  return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(Popover, { open, onOpenChange: setOpen, children: [
15191
15253
  /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(
15192
15254
  PopoverTrigger,
@@ -15370,16 +15432,16 @@ function AdminLayout({
15370
15432
  const showTabs = config.tabs ?? false;
15371
15433
  const showBreadcrumb = config.breadcrumb ?? false;
15372
15434
  const showFooter = config.footer ?? false;
15373
- const [collapsed, setCollapsed] = (0, import_react71.useState)(config.collapsed ?? false);
15435
+ const [collapsed, setCollapsed] = (0, import_react72.useState)(config.collapsed ?? false);
15374
15436
  const broken = useBreakpointBelow(config.breakpoint);
15375
15437
  const effectiveCollapsed = collapsed || broken;
15376
- const [bridgeRoute, setBridgeRoute] = (0, import_react71.useState)(
15438
+ const [bridgeRoute, setBridgeRoute] = (0, import_react72.useState)(
15377
15439
  () => (0, import_router.resolveRoute)(registry, bridge.getLocation())
15378
15440
  );
15379
- const [tabs, setTabs] = (0, import_react71.useState)([]);
15380
- const tabsRef = (0, import_react71.useRef)(tabs);
15441
+ const [tabs, setTabs] = (0, import_react72.useState)([]);
15442
+ const tabsRef = (0, import_react72.useRef)(tabs);
15381
15443
  tabsRef.current = tabs;
15382
- (0, import_react71.useEffect)(() => {
15444
+ (0, import_react72.useEffect)(() => {
15383
15445
  const handleLocation = (location) => {
15384
15446
  const next = (0, import_router.resolveRoute)(registry, location);
15385
15447
  setBridgeRoute(next);
@@ -15400,16 +15462,16 @@ function AdminLayout({
15400
15462
  }, [registry, bridge]);
15401
15463
  const route = routeProp ?? bridgeRoute;
15402
15464
  const activeMenuId = route?.activeMenu;
15403
- const visibleMenus = (0, import_react71.useMemo)(
15465
+ const visibleMenus = (0, import_react72.useMemo)(
15404
15466
  () => buildVisibleMenuTree(registry, permissionChecker),
15405
15467
  [registry, permissionChecker]
15406
15468
  );
15407
- const defaultOpenKeysRef = (0, import_react71.useRef)(null);
15469
+ const defaultOpenKeysRef = (0, import_react72.useRef)(null);
15408
15470
  if (defaultOpenKeysRef.current === null) {
15409
15471
  defaultOpenKeysRef.current = collectDefaultOpenKeys(registry, activeMenuId);
15410
15472
  }
15411
15473
  const defaultOpenKeys = defaultOpenKeysRef.current;
15412
- const activeTopId = (0, import_react71.useMemo)(() => {
15474
+ const activeTopId = (0, import_react72.useMemo)(() => {
15413
15475
  if (activeMenuId !== void 0) {
15414
15476
  const chain = findMenuChain(registry, activeMenuId);
15415
15477
  if (chain.length > 0) {
@@ -15418,11 +15480,11 @@ function AdminLayout({
15418
15480
  }
15419
15481
  return void 0;
15420
15482
  }, [registry, activeMenuId]);
15421
- const [selectedTopId, setSelectedTopId] = (0, import_react71.useState)();
15483
+ const [selectedTopId, setSelectedTopId] = (0, import_react72.useState)();
15422
15484
  const secondaryTopId = selectedTopId ?? activeTopId ?? visibleMenus.find((m) => m.type === "group")?.id ?? visibleMenus[0]?.id;
15423
15485
  const secondaryTop = visibleMenus.find((m) => m.id === secondaryTopId);
15424
15486
  const hasSecondary = (secondaryTop?.children?.length ?? 0) > 0;
15425
- const breadcrumbItems = (0, import_react71.useMemo)(() => {
15487
+ const breadcrumbItems = (0, import_react72.useMemo)(() => {
15426
15488
  if (!showBreadcrumb || activeMenuId === void 0) {
15427
15489
  return [];
15428
15490
  }
@@ -15675,7 +15737,7 @@ function BlankLayout({ children }) {
15675
15737
 
15676
15738
  // src/layout/chat/ChatLayout.tsx
15677
15739
  var import_permission2 = require("@pactor-app/permission");
15678
- var import_react72 = require("react");
15740
+ var import_react73 = require("react");
15679
15741
  var import_jsx_runtime208 = require("react/jsx-runtime");
15680
15742
  function ChatLayout({
15681
15743
  brand,
@@ -15691,7 +15753,7 @@ function ChatLayout({
15691
15753
  sidebarFooter,
15692
15754
  children
15693
15755
  }) {
15694
- const registryMenus = (0, import_react72.useMemo)(() => {
15756
+ const registryMenus = (0, import_react73.useMemo)(() => {
15695
15757
  if (menu !== void 0 || registry === void 0) {
15696
15758
  return [];
15697
15759
  }
@@ -15700,10 +15762,10 @@ function ChatLayout({
15700
15762
  return visible.flatMap((item) => menuItemToMenuData(item));
15701
15763
  }, [menu, registry, permissionChecker]);
15702
15764
  const menuItems = menu ?? registryMenus;
15703
- const [bridgePath, setBridgePath] = (0, import_react72.useState)(
15765
+ const [bridgePath, setBridgePath] = (0, import_react73.useState)(
15704
15766
  () => bridge?.getLocation().pathname ?? "/"
15705
15767
  );
15706
- (0, import_react72.useEffect)(() => {
15768
+ (0, import_react73.useEffect)(() => {
15707
15769
  if (bridge === void 0) {
15708
15770
  return;
15709
15771
  }
@@ -15711,7 +15773,7 @@ function ChatLayout({
15711
15773
  setBridgePath(location.pathname);
15712
15774
  });
15713
15775
  }, [bridge]);
15714
- const activeKey = (0, import_react72.useMemo)(() => {
15776
+ const activeKey = (0, import_react73.useMemo)(() => {
15715
15777
  if (activeMenuKey !== void 0) {
15716
15778
  return activeMenuKey;
15717
15779
  }
@@ -16086,7 +16148,7 @@ function isRecord(value) {
16086
16148
 
16087
16149
  // src/interaction/provider.tsx
16088
16150
  var import_runtime29 = require("@pactor-app/runtime");
16089
- var import_react73 = require("react");
16151
+ var import_react74 = require("react");
16090
16152
  var import_react_dom2 = require("react-dom");
16091
16153
  var import_jsx_runtime211 = require("react/jsx-runtime");
16092
16154
  var TOAST_DURATION = 3e3;
@@ -16100,11 +16162,11 @@ function InteractionProvider({
16100
16162
  bridge,
16101
16163
  children
16102
16164
  }) {
16103
- const [confirmState, setConfirmState] = (0, import_react73.useState)(null);
16104
- const [confirmOpen, setConfirmOpen] = (0, import_react73.useState)(false);
16105
- const [toasts, setToasts] = (0, import_react73.useState)([]);
16165
+ const [confirmState, setConfirmState] = (0, import_react74.useState)(null);
16166
+ const [confirmOpen, setConfirmOpen] = (0, import_react74.useState)(false);
16167
+ const [toasts, setToasts] = (0, import_react74.useState)([]);
16106
16168
  const { t } = (0, import_runtime29.useI18n)();
16107
- const { modal, message } = (0, import_react73.useMemo)(() => {
16169
+ const { modal, message } = (0, import_react74.useMemo)(() => {
16108
16170
  const pushToast = (type, content) => {
16109
16171
  const id = Date.now() + Math.random();
16110
16172
  setToasts((prev) => [...prev, { id, type, content }]);
@@ -16126,7 +16188,7 @@ function InteractionProvider({
16126
16188
  };
16127
16189
  return { modal: modalImpl, message: messageImpl };
16128
16190
  }, []);
16129
- (0, import_react73.useEffect)(() => {
16191
+ (0, import_react74.useEffect)(() => {
16130
16192
  bridge.modal = modal;
16131
16193
  bridge.message = message;
16132
16194
  return () => {
@@ -16209,7 +16271,7 @@ function InteractionProvider({
16209
16271
  // src/interaction/host.tsx
16210
16272
  var import_lucide_react38 = require("lucide-react");
16211
16273
  var import_runtime30 = require("@pactor-app/runtime");
16212
- var import_react74 = require("react");
16274
+ var import_react75 = require("react");
16213
16275
  var import_jsx_runtime212 = require("react/jsx-runtime");
16214
16276
  function toCssWidth(width) {
16215
16277
  if (width === void 0) {
@@ -16219,11 +16281,11 @@ function toCssWidth(width) {
16219
16281
  }
16220
16282
  function OverlayHost({ manager, resolvePage }) {
16221
16283
  const renderer = (0, import_runtime30.useRenderer)();
16222
- const stack = (0, import_react74.useSyncExternalStore)(
16284
+ const stack = (0, import_react75.useSyncExternalStore)(
16223
16285
  (onChange) => manager.subscribe(onChange),
16224
16286
  () => manager.stack()
16225
16287
  );
16226
- (0, import_react74.useSyncExternalStore)(
16288
+ (0, import_react75.useSyncExternalStore)(
16227
16289
  (onChange) => {
16228
16290
  const offState = renderer.context.state.subscribe(onChange);
16229
16291
  const offData = renderer.context.data.subscribe(onChange);
@@ -16370,9 +16432,9 @@ function PageOverlayBody({
16370
16432
  renderer,
16371
16433
  resolvePage
16372
16434
  }) {
16373
- const [child, setChild] = (0, import_react74.useState)(null);
16374
- const [error, setError] = (0, import_react74.useState)(null);
16375
- (0, import_react74.useEffect)(() => {
16435
+ const [child, setChild] = (0, import_react75.useState)(null);
16436
+ const [error, setError] = (0, import_react75.useState)(null);
16437
+ (0, import_react75.useEffect)(() => {
16376
16438
  if (!resolvePage) {
16377
16439
  setError(
16378
16440
  new Error(
package/dist/index.js CHANGED
@@ -151,7 +151,7 @@ import {
151
151
  inferKind,
152
152
  registerBuiltinComponents,
153
153
  useFormContext
154
- } from "./chunk-EDUMGNT6.js";
154
+ } from "./chunk-VTCNWVKQ.js";
155
155
  import {
156
156
  InteractionProvider,
157
157
  OVERLAY_CANCEL_PAYLOAD,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pactor-app/ui",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "Pactor UI kit (shadcn): the single built-in UI kit — vendored shadcn/ui components (Base UI primitives + cva + tailwind-merge + lucide-react), props contracts, interaction core (OverlayManager / UiBridge) and layouts, with build-time Tailwind v4 prebuilt styles.css (zero consumer-side Tailwind config)",
5
5
  "keywords": [
6
6
  "pactor",
@@ -107,11 +107,11 @@
107
107
  "react-resizable-panels": "^4.12.3",
108
108
  "tailwind-merge": "^3.6.0",
109
109
  "vaul": "^1.1.2",
110
- "@pactor-app/core": "1.22.0",
111
- "@pactor-app/markdown": "1.22.0",
112
- "@pactor-app/router": "1.22.0",
113
- "@pactor-app/permission": "1.22.0",
114
- "@pactor-app/runtime": "1.22.0"
110
+ "@pactor-app/core": "1.23.0",
111
+ "@pactor-app/markdown": "1.23.0",
112
+ "@pactor-app/permission": "1.23.0",
113
+ "@pactor-app/runtime": "1.23.0",
114
+ "@pactor-app/router": "1.23.0"
115
115
  },
116
116
  "peerDependencies": {
117
117
  "react": ">=18",