@canvas-components/react-pivot-table 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,6 +84,24 @@ export function SalesPivotTable(props: { data: SalesRecord[] }) {
84
84
 
85
85
  其余 `dataSource`、`rows`、`columns`、`indicators`、`totals`、`filters`、`sorts` 和虚拟滚动等属性与 `@canvas-components/pivot-table` 保持一致。
86
86
 
87
+ ## 统一切换调试模式
88
+
89
+ `ReactPivotTableDebugProvider` 可为后代中的全部 `ReactPivotTable` 同步开启核心调试模式,并保留每个表格自身的 `debug` 配置:
90
+
91
+ ```tsx
92
+ import {
93
+ ReactPivotTable,
94
+ ReactPivotTableDebugProvider,
95
+ } from "@canvas-components/react-pivot-table";
96
+
97
+ <ReactPivotTableDebugProvider enabled={debuggerEnabled}>
98
+ <ReactPivotTable
99
+ {...props}
100
+ debug={{ showBodyBounds: false, logDrawCalls: true }}
101
+ />
102
+ </ReactPivotTableDebugProvider>;
103
+ ```
104
+
87
105
  ### `ReactPivotTableCustomizationOptions`
88
106
 
89
107
  | 属性 | 类型 | 说明 |
package/dist/index.cjs CHANGED
@@ -1663,8 +1663,31 @@ function PivotChartCanvas(props) {
1663
1663
  }, [props.chartOption]);
1664
1664
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "react-pivot-chart-card__canvas" });
1665
1665
  }
1666
+ var ReactPivotTableDebugContext = react.createContext(false);
1667
+ function ReactPivotTableDebugProvider(props) {
1668
+ return /* @__PURE__ */ jsxRuntime.jsx(ReactPivotTableDebugContext.Provider, { value: props.enabled, children: props.children });
1669
+ }
1670
+ function useReactPivotTableDebugEnabled() {
1671
+ return react.useContext(ReactPivotTableDebugContext);
1672
+ }
1673
+ function resolveReactPivotTableDebugOptions(debug, inheritedEnabled) {
1674
+ if (!inheritedEnabled) return debug;
1675
+ return {
1676
+ ...pivotTable.DEFAULT_PIVOT_TABLE_DEBUG_OPTIONS,
1677
+ ...typeof debug === "object" ? debug : null,
1678
+ enabled: true
1679
+ };
1680
+ }
1666
1681
  function ReactPivotTableInner(props, ref) {
1667
1682
  const { className, style, customization, title, ...tableOptions } = props;
1683
+ const inheritedDebugEnabled = useReactPivotTableDebugEnabled();
1684
+ const resolvedDebug = react.useMemo(
1685
+ () => resolveReactPivotTableDebugOptions(
1686
+ tableOptions.debug,
1687
+ inheritedDebugEnabled
1688
+ ),
1689
+ [inheritedDebugEnabled, tableOptions.debug]
1690
+ );
1668
1691
  const containerRef = react.useRef(null);
1669
1692
  const tableRef = react.useRef(null);
1670
1693
  const customizationOptions = customization && typeof customization === "object" ? customization : void 0;
@@ -1763,6 +1786,7 @@ function ReactPivotTableInner(props, ref) {
1763
1786
  const options = {
1764
1787
  ...tableOptions,
1765
1788
  ...customizedOptions,
1789
+ debug: resolvedDebug,
1766
1790
  rowHeight: densityOverride == null ? tableOptions.rowHeight : resolveDensityRowHeight(densityOverride),
1767
1791
  indicators: customizedOptions?.indicators ?? overriddenIndicators,
1768
1792
  ui: {
@@ -2215,5 +2239,6 @@ function inferFieldAggregator(records, dataIndex) {
2215
2239
  }
2216
2240
 
2217
2241
  exports.ReactPivotTable = ReactPivotTable;
2242
+ exports.ReactPivotTableDebugProvider = ReactPivotTableDebugProvider;
2218
2243
  //# sourceMappingURL=index.cjs.map
2219
2244
  //# sourceMappingURL=index.cjs.map