@canvas-components/react-list-table 0.3.10 → 0.3.11

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
@@ -289,6 +289,25 @@ export function DemoTable() {
289
289
  | `getFullscreenNode` | `() => HTMLElement \| null` | 自定义全屏节点 |
290
290
  | `extra` | `ReactNode` | 工具栏右侧额外内容 |
291
291
 
292
+ ## 统一切换调试模式
293
+
294
+ `ReactListTableDebugProvider` 可为后代中的全部 `ReactListTable` 同步开启核心调试模式,并默认显示表头、表体、固定列分割线、命中区域和表头操作区。表格自身通过 `debug` 传入的其他选项仍会保留,也可以显式关闭某个可视化项:
295
+
296
+ ```tsx
297
+ import {
298
+ ReactListTable,
299
+ ReactListTableDebugProvider,
300
+ } from "@canvas-components/react-list-table";
301
+
302
+ <ReactListTableDebugProvider enabled={statsEnabled}>
303
+ <ReactListTable
304
+ columns={columns}
305
+ dataSource={dataSource}
306
+ debug={{ showBodyBounds: true }}
307
+ />
308
+ </ReactListTableDebugProvider>;
309
+ ```
310
+
292
311
  ## 方法说明
293
312
 
294
313
  ### `ReactListTableRef`
package/dist/index.cjs CHANGED
@@ -3039,11 +3039,34 @@ function ReactTableFilterPanelView(props) {
3039
3039
  }
3040
3040
  );
3041
3041
  }
3042
+
3043
+ // src/components/react-list-table-layout.ts
3044
+ function resolveReactListTablePaginationLayout(density) {
3045
+ if (typeof density === "number" && density <= 26) {
3046
+ return { size: "small", height: 32, paddingTop: 8 };
3047
+ }
3048
+ if (typeof density === "number" && density >= 48) {
3049
+ return { size: "large", height: 52, paddingTop: 12 };
3050
+ }
3051
+ return { size: "middle", height: 44, paddingTop: 12 };
3052
+ }
3053
+ function resolveReactListTableHostStyle(hasPagination, paginationHeight = resolveReactListTablePaginationLayout().height) {
3054
+ return {
3055
+ position: "relative",
3056
+ flex: 1,
3057
+ minWidth: 0,
3058
+ width: "100%",
3059
+ minHeight: 0,
3060
+ boxSizing: "border-box",
3061
+ paddingBottom: hasPagination ? paginationHeight : void 0
3062
+ };
3063
+ }
3042
3064
  function ReactTablePaginationView(props) {
3043
- const { config } = props;
3065
+ const { config, density } = props;
3044
3066
  if (!config) {
3045
3067
  return null;
3046
3068
  }
3069
+ const layout = resolveReactListTablePaginationLayout(density);
3047
3070
  return /* @__PURE__ */ jsxRuntime.jsx(
3048
3071
  "div",
3049
3072
  {
@@ -3053,11 +3076,14 @@ function ReactTablePaginationView(props) {
3053
3076
  bottom: 0,
3054
3077
  display: "flex",
3055
3078
  justifyContent: "flex-end",
3056
- paddingTop: 12
3079
+ paddingTop: layout.paddingTop,
3080
+ height: layout.height,
3081
+ boxSizing: "border-box"
3057
3082
  },
3058
3083
  children: /* @__PURE__ */ jsxRuntime.jsx(
3059
3084
  reactComponents.ReactPagination,
3060
3085
  {
3086
+ size: layout.size,
3061
3087
  current: config.current,
3062
3088
  total: config.total,
3063
3089
  pageSize: config.pageSize,
@@ -3769,6 +3795,29 @@ function buildListTableOptions(props) {
3769
3795
  } : query
3770
3796
  };
3771
3797
  }
3798
+ var ReactListTableDebugContext = react.createContext(false);
3799
+ var INHERITED_DEBUG_DEFAULTS = {
3800
+ enabled: true,
3801
+ showHeaderBounds: true,
3802
+ showBodyBounds: true,
3803
+ showFixedSplitLines: true,
3804
+ showHitTarget: true,
3805
+ showHeaderActionOverlay: true
3806
+ };
3807
+ function ReactListTableDebugProvider(props) {
3808
+ return /* @__PURE__ */ jsxRuntime.jsx(ReactListTableDebugContext.Provider, { value: props.enabled, children: props.children });
3809
+ }
3810
+ function useReactListTableDebugEnabled() {
3811
+ return react.useContext(ReactListTableDebugContext);
3812
+ }
3813
+ function resolveReactListTableDebugOptions(debug, inheritedEnabled) {
3814
+ if (!inheritedEnabled) return debug;
3815
+ return {
3816
+ ...INHERITED_DEBUG_DEFAULTS,
3817
+ ...debug,
3818
+ enabled: true
3819
+ };
3820
+ }
3772
3821
  function ReactListTableInner(props, ref) {
3773
3822
  const {
3774
3823
  className,
@@ -3809,6 +3858,11 @@ function ReactListTableInner(props, ref) {
3809
3858
  title,
3810
3859
  toolbar
3811
3860
  } = props;
3861
+ const inheritedDebugEnabled = useReactListTableDebugEnabled();
3862
+ const resolvedDebug = react.useMemo(
3863
+ () => resolveReactListTableDebugOptions(debug, inheritedDebugEnabled),
3864
+ [debug, inheritedDebugEnabled]
3865
+ );
3812
3866
  const shellRef = react.useRef(null);
3813
3867
  const [isFullscreen, setIsFullscreen] = react.useState(false);
3814
3868
  const [densityOverride, setDensityOverride] = react.useState(null);
@@ -3870,7 +3924,7 @@ function ReactListTableInner(props, ref) {
3870
3924
  draggable,
3871
3925
  tableId,
3872
3926
  rowDrag,
3873
- debug
3927
+ debug: resolvedDebug
3874
3928
  });
3875
3929
  const fullscreenSize = resolveFullscreenTableSize(
3876
3930
  nextOptions.width,
@@ -3919,7 +3973,7 @@ function ReactListTableInner(props, ref) {
3919
3973
  draggable,
3920
3974
  tableId,
3921
3975
  rowDrag,
3922
- debug,
3976
+ resolvedDebug,
3923
3977
  isFullscreen,
3924
3978
  columnConfigRevision
3925
3979
  ]);
@@ -3939,6 +3993,9 @@ function ReactListTableInner(props, ref) {
3939
3993
  closeDangerConfirmRequest
3940
3994
  } = useReactListTableState(options);
3941
3995
  const hasPagination = paginationConfig != null;
3996
+ const paginationLayout = resolveReactListTablePaginationLayout(
3997
+ resolvedRowHeight
3998
+ );
3942
3999
  react.useImperativeHandle(
3943
4000
  ref,
3944
4001
  () => ({
@@ -3973,7 +4030,6 @@ function ReactListTableInner(props, ref) {
3973
4030
  position: "relative",
3974
4031
  display: "flex",
3975
4032
  flexDirection: "column",
3976
- paddingBottom: hasPagination ? 44 : void 0,
3977
4033
  ...style
3978
4034
  },
3979
4035
  children: [
@@ -4056,8 +4112,17 @@ function ReactListTableInner(props, ref) {
4056
4112
  {
4057
4113
  ref: containerRef,
4058
4114
  className: "react-list-table-host",
4059
- style: { flex: 1, minWidth: 0, width: "100%", minHeight: 0 },
4060
- children: /* @__PURE__ */ jsxRuntime.jsx(ReactTablePaginationView, { config: paginationConfig })
4115
+ style: resolveReactListTableHostStyle(
4116
+ hasPagination,
4117
+ paginationLayout.height
4118
+ ),
4119
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4120
+ ReactTablePaginationView,
4121
+ {
4122
+ config: paginationConfig,
4123
+ density: resolvedRowHeight
4124
+ }
4125
+ )
4061
4126
  }
4062
4127
  ),
4063
4128
  loadingRequest ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -4176,5 +4241,6 @@ function resolveColumnKey(column) {
4176
4241
  var ReactListTable = react.forwardRef(ReactListTableInner);
4177
4242
 
4178
4243
  exports.ReactListTable = ReactListTable;
4244
+ exports.ReactListTableDebugProvider = ReactListTableDebugProvider;
4179
4245
  //# sourceMappingURL=index.cjs.map
4180
4246
  //# sourceMappingURL=index.cjs.map