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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, ReactNode, ForwardedRef } from 'react';
2
+ import { CSSProperties, ReactNode, ForwardedRef, PropsWithChildren } from 'react';
3
3
  import { PivotTableOptions, PivotField, PivotFieldLayout, PivotModel, PivotTable, PivotSelectionState, PivotFilterState, PivotSortRule, PivotCellAddress, PivotAxis, PivotFilterAxis, PivotDimensionFilter, PivotFilterOptionItem, PivotExportOptions, PivotTableStateSnapshot } from '@canvas-components/pivot-table';
4
4
 
5
5
  /** PivotTable 自定义字段面板配置。 */
@@ -80,4 +80,11 @@ declare const ReactPivotTable: <RecordType = Record<string, unknown>>(props: Rea
80
80
  ref?: ForwardedRef<ReactPivotTableRef<RecordType>>;
81
81
  }) => ReturnType<typeof ReactPivotTableInner>;
82
82
 
83
- export { ReactPivotTable, type ReactPivotTableCustomizationOptions, type ReactPivotTableProps, type ReactPivotTableRef };
83
+ /** ReactPivotTable 调试模式上下文属性。 */
84
+ interface ReactPivotTableDebugProviderProps extends PropsWithChildren {
85
+ enabled: boolean;
86
+ }
87
+ /** 为后代 ReactPivotTable 统一切换核心调试模式。 */
88
+ declare function ReactPivotTableDebugProvider(props: ReactPivotTableDebugProviderProps): react.JSX.Element;
89
+
90
+ export { ReactPivotTable, type ReactPivotTableCustomizationOptions, ReactPivotTableDebugProvider, type ReactPivotTableDebugProviderProps, type ReactPivotTableProps, type ReactPivotTableRef };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, ReactNode, ForwardedRef } from 'react';
2
+ import { CSSProperties, ReactNode, ForwardedRef, PropsWithChildren } from 'react';
3
3
  import { PivotTableOptions, PivotField, PivotFieldLayout, PivotModel, PivotTable, PivotSelectionState, PivotFilterState, PivotSortRule, PivotCellAddress, PivotAxis, PivotFilterAxis, PivotDimensionFilter, PivotFilterOptionItem, PivotExportOptions, PivotTableStateSnapshot } from '@canvas-components/pivot-table';
4
4
 
5
5
  /** PivotTable 自定义字段面板配置。 */
@@ -80,4 +80,11 @@ declare const ReactPivotTable: <RecordType = Record<string, unknown>>(props: Rea
80
80
  ref?: ForwardedRef<ReactPivotTableRef<RecordType>>;
81
81
  }) => ReturnType<typeof ReactPivotTableInner>;
82
82
 
83
- export { ReactPivotTable, type ReactPivotTableCustomizationOptions, type ReactPivotTableProps, type ReactPivotTableRef };
83
+ /** ReactPivotTable 调试模式上下文属性。 */
84
+ interface ReactPivotTableDebugProviderProps extends PropsWithChildren {
85
+ enabled: boolean;
86
+ }
87
+ /** 为后代 ReactPivotTable 统一切换核心调试模式。 */
88
+ declare function ReactPivotTableDebugProvider(props: ReactPivotTableDebugProviderProps): react.JSX.Element;
89
+
90
+ export { ReactPivotTable, type ReactPivotTableCustomizationOptions, ReactPivotTableDebugProvider, type ReactPivotTableDebugProviderProps, type ReactPivotTableProps, type ReactPivotTableRef };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { forwardRef, useRef, useState, useMemo, useEffect, useImperativeHandle, Fragment as Fragment$1 } from 'react';
2
- import { createEmptyPivotFieldLayout, createPivotFieldCatalog, resolvePivotDimensionKey, resolvePivotFieldLayoutOptions, PivotTable, loadPivotFieldLayout, getValueByDataIndex, resolvePivotDimensionTitle, findPivotFieldArea, removePivotField, movePivotField, resolvePivotValueFieldTitle, savePivotFieldLayout, createPivotCellKey } from '@canvas-components/pivot-table';
1
+ import { createContext, forwardRef, useMemo, useRef, useState, useEffect, useImperativeHandle, useContext, Fragment as Fragment$1 } from 'react';
2
+ import { createEmptyPivotFieldLayout, createPivotFieldCatalog, resolvePivotDimensionKey, resolvePivotFieldLayoutOptions, PivotTable, loadPivotFieldLayout, DEFAULT_PIVOT_TABLE_DEBUG_OPTIONS, getValueByDataIndex, resolvePivotDimensionTitle, findPivotFieldArea, removePivotField, movePivotField, resolvePivotValueFieldTitle, savePivotFieldLayout, createPivotCellKey } from '@canvas-components/pivot-table';
3
3
  import { ReactResizablePanels, ReactFilterPanel, ReactPopup, ReactCheckbox, ReactInput, ReactSelect, ReactInputNumber } from '@canvas-components/react-components';
4
4
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
5
  import { createPortal } from 'react-dom';
@@ -1661,8 +1661,31 @@ function PivotChartCanvas(props) {
1661
1661
  }, [props.chartOption]);
1662
1662
  return /* @__PURE__ */ jsx("div", { ref: containerRef, className: "react-pivot-chart-card__canvas" });
1663
1663
  }
1664
+ var ReactPivotTableDebugContext = createContext(false);
1665
+ function ReactPivotTableDebugProvider(props) {
1666
+ return /* @__PURE__ */ jsx(ReactPivotTableDebugContext.Provider, { value: props.enabled, children: props.children });
1667
+ }
1668
+ function useReactPivotTableDebugEnabled() {
1669
+ return useContext(ReactPivotTableDebugContext);
1670
+ }
1671
+ function resolveReactPivotTableDebugOptions(debug, inheritedEnabled) {
1672
+ if (!inheritedEnabled) return debug;
1673
+ return {
1674
+ ...DEFAULT_PIVOT_TABLE_DEBUG_OPTIONS,
1675
+ ...typeof debug === "object" ? debug : null,
1676
+ enabled: true
1677
+ };
1678
+ }
1664
1679
  function ReactPivotTableInner(props, ref) {
1665
1680
  const { className, style, customization, title, ...tableOptions } = props;
1681
+ const inheritedDebugEnabled = useReactPivotTableDebugEnabled();
1682
+ const resolvedDebug = useMemo(
1683
+ () => resolveReactPivotTableDebugOptions(
1684
+ tableOptions.debug,
1685
+ inheritedDebugEnabled
1686
+ ),
1687
+ [inheritedDebugEnabled, tableOptions.debug]
1688
+ );
1666
1689
  const containerRef = useRef(null);
1667
1690
  const tableRef = useRef(null);
1668
1691
  const customizationOptions = customization && typeof customization === "object" ? customization : void 0;
@@ -1761,6 +1784,7 @@ function ReactPivotTableInner(props, ref) {
1761
1784
  const options = {
1762
1785
  ...tableOptions,
1763
1786
  ...customizedOptions,
1787
+ debug: resolvedDebug,
1764
1788
  rowHeight: densityOverride == null ? tableOptions.rowHeight : resolveDensityRowHeight(densityOverride),
1765
1789
  indicators: customizedOptions?.indicators ?? overriddenIndicators,
1766
1790
  ui: {
@@ -2212,6 +2236,6 @@ function inferFieldAggregator(records, dataIndex) {
2212
2236
  return typeof value === "number" ? "sum" : "count";
2213
2237
  }
2214
2238
 
2215
- export { ReactPivotTable };
2239
+ export { ReactPivotTable, ReactPivotTableDebugProvider };
2216
2240
  //# sourceMappingURL=index.js.map
2217
2241
  //# sourceMappingURL=index.js.map