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

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 { ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableScrollToOptions, ListTable, ListTableColumn, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions } from '@canvas-components/list-table';
4
4
 
5
5
  interface ReactListTableScrollConfig {
@@ -88,4 +88,16 @@ declare const ReactListTable: <RecordType = Record<string, unknown>>(props: Reac
88
88
  ref?: ForwardedRef<ReactListTableRef<RecordType>>;
89
89
  }) => ReturnType<typeof ReactListTableInner>;
90
90
 
91
- export { ReactListTable, type ReactListTableColumnType, type ReactListTableColumnsType, type ReactListTableLocale, type ReactListTablePagination, type ReactListTableProps, type ReactListTableQuery, type ReactListTableRef, type ReactListTableRowSelection, type ReactListTableScrollConfig, type ReactListTableTableProps, type ReactListTableToolbarOptions };
91
+ /** ReactListTable 调试模式上下文属性。 */
92
+ interface ReactListTableDebugProviderProps extends PropsWithChildren {
93
+ enabled: boolean;
94
+ }
95
+ /**
96
+ * 为后代 ReactListTable 统一切换核心调试模式。
97
+ *
98
+ * @param props 上下文属性。
99
+ * @returns 调试模式上下文节点。
100
+ */
101
+ declare function ReactListTableDebugProvider(props: ReactListTableDebugProviderProps): react.JSX.Element;
102
+
103
+ export { ReactListTable, type ReactListTableColumnType, type ReactListTableColumnsType, ReactListTableDebugProvider, type ReactListTableDebugProviderProps, type ReactListTableLocale, type ReactListTablePagination, type ReactListTableProps, type ReactListTableQuery, type ReactListTableRef, type ReactListTableRowSelection, type ReactListTableScrollConfig, type ReactListTableTableProps, type ReactListTableToolbarOptions };
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 { ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableScrollToOptions, ListTable, ListTableColumn, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions } from '@canvas-components/list-table';
4
4
 
5
5
  interface ReactListTableScrollConfig {
@@ -88,4 +88,16 @@ declare const ReactListTable: <RecordType = Record<string, unknown>>(props: Reac
88
88
  ref?: ForwardedRef<ReactListTableRef<RecordType>>;
89
89
  }) => ReturnType<typeof ReactListTableInner>;
90
90
 
91
- export { ReactListTable, type ReactListTableColumnType, type ReactListTableColumnsType, type ReactListTableLocale, type ReactListTablePagination, type ReactListTableProps, type ReactListTableQuery, type ReactListTableRef, type ReactListTableRowSelection, type ReactListTableScrollConfig, type ReactListTableTableProps, type ReactListTableToolbarOptions };
91
+ /** ReactListTable 调试模式上下文属性。 */
92
+ interface ReactListTableDebugProviderProps extends PropsWithChildren {
93
+ enabled: boolean;
94
+ }
95
+ /**
96
+ * 为后代 ReactListTable 统一切换核心调试模式。
97
+ *
98
+ * @param props 上下文属性。
99
+ * @returns 调试模式上下文节点。
100
+ */
101
+ declare function ReactListTableDebugProvider(props: ReactListTableDebugProviderProps): react.JSX.Element;
102
+
103
+ export { ReactListTable, type ReactListTableColumnType, type ReactListTableColumnsType, ReactListTableDebugProvider, type ReactListTableDebugProviderProps, type ReactListTableLocale, type ReactListTablePagination, type ReactListTableProps, type ReactListTableQuery, type ReactListTableRef, type ReactListTableRowSelection, type ReactListTableScrollConfig, type ReactListTableTableProps, type ReactListTableToolbarOptions };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { forwardRef, useRef, useState, useMemo, useImperativeHandle, useEffect, useLayoutEffect, Fragment as Fragment$1 } from 'react';
1
+ import { createContext, forwardRef, useMemo, useRef, useState, useImperativeHandle, useContext, useEffect, useLayoutEffect, Fragment as Fragment$1 } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { ReactImagePreview, ReactNumberInput, ReactSelect, ReactPagination, ReactFilterPanel, ReactPopup, ReactModal, ReactInput, ReactPopconfirm, ReactContentScaleProvider, ReactInputNumber, ReactCheckbox, ReactAutoComplete, ReactColorPicker, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange } from '@canvas-components/react-components';
4
4
  import { resetListTableStoredColumnConfig, ListTable } from '@canvas-components/list-table';
@@ -3037,11 +3037,34 @@ function ReactTableFilterPanelView(props) {
3037
3037
  }
3038
3038
  );
3039
3039
  }
3040
+
3041
+ // src/components/react-list-table-layout.ts
3042
+ function resolveReactListTablePaginationLayout(density) {
3043
+ if (typeof density === "number" && density <= 26) {
3044
+ return { size: "small", height: 32, paddingTop: 8 };
3045
+ }
3046
+ if (typeof density === "number" && density >= 48) {
3047
+ return { size: "large", height: 52, paddingTop: 12 };
3048
+ }
3049
+ return { size: "middle", height: 44, paddingTop: 12 };
3050
+ }
3051
+ function resolveReactListTableHostStyle(hasPagination, paginationHeight = resolveReactListTablePaginationLayout().height) {
3052
+ return {
3053
+ position: "relative",
3054
+ flex: 1,
3055
+ minWidth: 0,
3056
+ width: "100%",
3057
+ minHeight: 0,
3058
+ boxSizing: "border-box",
3059
+ paddingBottom: hasPagination ? paginationHeight : void 0
3060
+ };
3061
+ }
3040
3062
  function ReactTablePaginationView(props) {
3041
- const { config } = props;
3063
+ const { config, density } = props;
3042
3064
  if (!config) {
3043
3065
  return null;
3044
3066
  }
3067
+ const layout = resolveReactListTablePaginationLayout(density);
3045
3068
  return /* @__PURE__ */ jsx(
3046
3069
  "div",
3047
3070
  {
@@ -3051,11 +3074,14 @@ function ReactTablePaginationView(props) {
3051
3074
  bottom: 0,
3052
3075
  display: "flex",
3053
3076
  justifyContent: "flex-end",
3054
- paddingTop: 12
3077
+ paddingTop: layout.paddingTop,
3078
+ height: layout.height,
3079
+ boxSizing: "border-box"
3055
3080
  },
3056
3081
  children: /* @__PURE__ */ jsx(
3057
3082
  ReactPagination,
3058
3083
  {
3084
+ size: layout.size,
3059
3085
  current: config.current,
3060
3086
  total: config.total,
3061
3087
  pageSize: config.pageSize,
@@ -3767,6 +3793,29 @@ function buildListTableOptions(props) {
3767
3793
  } : query
3768
3794
  };
3769
3795
  }
3796
+ var ReactListTableDebugContext = createContext(false);
3797
+ var INHERITED_DEBUG_DEFAULTS = {
3798
+ enabled: true,
3799
+ showHeaderBounds: true,
3800
+ showBodyBounds: true,
3801
+ showFixedSplitLines: true,
3802
+ showHitTarget: true,
3803
+ showHeaderActionOverlay: true
3804
+ };
3805
+ function ReactListTableDebugProvider(props) {
3806
+ return /* @__PURE__ */ jsx(ReactListTableDebugContext.Provider, { value: props.enabled, children: props.children });
3807
+ }
3808
+ function useReactListTableDebugEnabled() {
3809
+ return useContext(ReactListTableDebugContext);
3810
+ }
3811
+ function resolveReactListTableDebugOptions(debug, inheritedEnabled) {
3812
+ if (!inheritedEnabled) return debug;
3813
+ return {
3814
+ ...INHERITED_DEBUG_DEFAULTS,
3815
+ ...debug,
3816
+ enabled: true
3817
+ };
3818
+ }
3770
3819
  function ReactListTableInner(props, ref) {
3771
3820
  const {
3772
3821
  className,
@@ -3807,6 +3856,11 @@ function ReactListTableInner(props, ref) {
3807
3856
  title,
3808
3857
  toolbar
3809
3858
  } = props;
3859
+ const inheritedDebugEnabled = useReactListTableDebugEnabled();
3860
+ const resolvedDebug = useMemo(
3861
+ () => resolveReactListTableDebugOptions(debug, inheritedDebugEnabled),
3862
+ [debug, inheritedDebugEnabled]
3863
+ );
3810
3864
  const shellRef = useRef(null);
3811
3865
  const [isFullscreen, setIsFullscreen] = useState(false);
3812
3866
  const [densityOverride, setDensityOverride] = useState(null);
@@ -3868,7 +3922,7 @@ function ReactListTableInner(props, ref) {
3868
3922
  draggable,
3869
3923
  tableId,
3870
3924
  rowDrag,
3871
- debug
3925
+ debug: resolvedDebug
3872
3926
  });
3873
3927
  const fullscreenSize = resolveFullscreenTableSize(
3874
3928
  nextOptions.width,
@@ -3917,7 +3971,7 @@ function ReactListTableInner(props, ref) {
3917
3971
  draggable,
3918
3972
  tableId,
3919
3973
  rowDrag,
3920
- debug,
3974
+ resolvedDebug,
3921
3975
  isFullscreen,
3922
3976
  columnConfigRevision
3923
3977
  ]);
@@ -3937,6 +3991,9 @@ function ReactListTableInner(props, ref) {
3937
3991
  closeDangerConfirmRequest
3938
3992
  } = useReactListTableState(options);
3939
3993
  const hasPagination = paginationConfig != null;
3994
+ const paginationLayout = resolveReactListTablePaginationLayout(
3995
+ resolvedRowHeight
3996
+ );
3940
3997
  useImperativeHandle(
3941
3998
  ref,
3942
3999
  () => ({
@@ -3971,7 +4028,6 @@ function ReactListTableInner(props, ref) {
3971
4028
  position: "relative",
3972
4029
  display: "flex",
3973
4030
  flexDirection: "column",
3974
- paddingBottom: hasPagination ? 44 : void 0,
3975
4031
  ...style
3976
4032
  },
3977
4033
  children: [
@@ -4054,8 +4110,17 @@ function ReactListTableInner(props, ref) {
4054
4110
  {
4055
4111
  ref: containerRef,
4056
4112
  className: "react-list-table-host",
4057
- style: { flex: 1, minWidth: 0, width: "100%", minHeight: 0 },
4058
- children: /* @__PURE__ */ jsx(ReactTablePaginationView, { config: paginationConfig })
4113
+ style: resolveReactListTableHostStyle(
4114
+ hasPagination,
4115
+ paginationLayout.height
4116
+ ),
4117
+ children: /* @__PURE__ */ jsx(
4118
+ ReactTablePaginationView,
4119
+ {
4120
+ config: paginationConfig,
4121
+ density: resolvedRowHeight
4122
+ }
4123
+ )
4059
4124
  }
4060
4125
  ),
4061
4126
  loadingRequest ? /* @__PURE__ */ jsx(
@@ -4173,6 +4238,6 @@ function resolveColumnKey(column) {
4173
4238
  }
4174
4239
  var ReactListTable = forwardRef(ReactListTableInner);
4175
4240
 
4176
- export { ReactListTable };
4241
+ export { ReactListTable, ReactListTableDebugProvider };
4177
4242
  //# sourceMappingURL=index.js.map
4178
4243
  //# sourceMappingURL=index.js.map