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

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  `@canvas-components/react-list-table` 是 `@canvas-components/list-table` 的 React 适配层,负责把原生 Canvas 表格接入 React 应用,并提供更接近业务开发习惯的组件化入口。
4
4
 
5
+ 通过顶层 `loading` 属性控制数据加载状态:`<ReactListTable loading={loading} dataSource={rows} columns={columns} />`。加载期间展示加载提示并保留汇总标题;加载完成后,组件自动计算并统一展示完整汇总结果。服务端汇总可通过 `query.summaryValues` 提供,业务侧无需单独管理汇总计算状态。
6
+
5
7
  ## 示例效果
6
8
 
7
9
  ![React List Table 基础示例](./assets/examples/basic.gif)
package/dist/index.cjs CHANGED
@@ -440,7 +440,7 @@ function MenuAction(props) {
440
440
  );
441
441
  }
442
442
  function MenuSubmenu(props) {
443
- const { label, items, footer, children, minWidth = 220 } = props;
443
+ const { label, items, header, footer, children, minWidth = 220 } = props;
444
444
  const menuItems = items.filter((item) => item.onClick || item.disabled);
445
445
  const reserveSelectionIcon = menuItems.some(
446
446
  (item) => typeof item.selected === "boolean"
@@ -448,7 +448,7 @@ function MenuSubmenu(props) {
448
448
  const triggerRef = react.useRef(null);
449
449
  const [open, setOpen] = react.useState(false);
450
450
  const closeTimerRef = react.useRef(null);
451
- if (!menuItems.length && !footer && !children) {
451
+ if (!menuItems.length && !header && !footer && !children) {
452
452
  return null;
453
453
  }
454
454
  const clearCloseTimer = () => {
@@ -530,6 +530,7 @@ function MenuSubmenu(props) {
530
530
  scheduleClose();
531
531
  },
532
532
  children: [
533
+ header,
533
534
  menuItems.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
534
535
  item.separatorBefore ? /* @__PURE__ */ jsxRuntime.jsx(MenuDivider, {}) : null,
535
536
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1165,6 +1166,7 @@ function CustomSelectionRow(props) {
1165
1166
  }
1166
1167
  function SummaryMenu(props) {
1167
1168
  const { request } = props;
1169
+ const [title, setTitle] = react.useState(request.summaryTitle ?? "");
1168
1170
  const [precision, setPrecision] = react.useState(
1169
1171
  request.summaryPrecision ?? null
1170
1172
  );
@@ -1175,11 +1177,13 @@ function SummaryMenu(props) {
1175
1177
  request.summaryPreserveTrailingZeros ?? false
1176
1178
  );
1177
1179
  react.useEffect(() => {
1180
+ setTitle(request.summaryTitle ?? "");
1178
1181
  setPrecision(request.summaryPrecision ?? null);
1179
1182
  setRoundingMode(request.summaryRoundingMode ?? "round");
1180
1183
  setPreserveTrailingZeros(request.summaryPreserveTrailingZeros ?? false);
1181
1184
  }, [
1182
1185
  request.summaryColumnKey,
1186
+ request.summaryTitle,
1183
1187
  request.summaryPrecision,
1184
1188
  request.summaryRoundingMode,
1185
1189
  request.summaryPreserveTrailingZeros
@@ -1202,12 +1206,49 @@ function SummaryMenu(props) {
1202
1206
  {
1203
1207
  label: "\u6C47\u603B\u65B9\u5F0F",
1204
1208
  minWidth: 268,
1205
- items: summaryTypes.map((item) => ({
1206
- key: item.key,
1207
- label: item.label,
1208
- selected: request.summaryType === item.value,
1209
- onClick: () => request.onChangeSummaryType?.(item.value)
1210
- })),
1209
+ header: request.onChangeSummaryTitle ? /* @__PURE__ */ jsxRuntime.jsxs(
1210
+ "div",
1211
+ {
1212
+ style: {
1213
+ display: "grid",
1214
+ gridTemplateColumns: "56px 1fr",
1215
+ gap: 8,
1216
+ alignItems: "center",
1217
+ padding: "2px 10px 10px",
1218
+ marginBottom: 4,
1219
+ borderBottom: "1px solid #e5e7eb"
1220
+ },
1221
+ children: [
1222
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#374151", fontSize: 14 }, children: "\u6807\u9898\uFF1A" }),
1223
+ /* @__PURE__ */ jsxRuntime.jsx(
1224
+ reactComponents.ReactInput,
1225
+ {
1226
+ value: title,
1227
+ placeholder: "\u8BF7\u8F93\u5165\u6807\u9898",
1228
+ onChange: (event) => {
1229
+ const value = event.target.value;
1230
+ setTitle(value);
1231
+ request.onChangeSummaryTitle?.(value);
1232
+ }
1233
+ }
1234
+ )
1235
+ ]
1236
+ }
1237
+ ) : void 0,
1238
+ items: [
1239
+ ...summaryTypes.map((item) => ({
1240
+ key: item.key,
1241
+ label: item.label,
1242
+ selected: request.summaryType === item.value,
1243
+ onClick: () => request.onChangeSummaryType?.(item.value)
1244
+ })),
1245
+ {
1246
+ key: "clear-summary",
1247
+ label: "\u53D6\u6D88\u6C47\u603B",
1248
+ separatorBefore: true,
1249
+ onClick: request.onClearSummary
1250
+ }
1251
+ ],
1211
1252
  footer: request.onChangeSummaryPrecision || request.onChangeSummaryRoundingMode || request.onChangeSummaryPreserveTrailingZeros ? /* @__PURE__ */ jsxRuntime.jsxs(
1212
1253
  "div",
1213
1254
  {
@@ -3831,6 +3872,7 @@ function ReactListTableInner(props, ref) {
3831
3872
  rowKey,
3832
3873
  columns,
3833
3874
  dataSource,
3875
+ loading,
3834
3876
  onRow,
3835
3877
  theme,
3836
3878
  striped,
@@ -3842,6 +3884,7 @@ function ReactListTableInner(props, ref) {
3842
3884
  summaryRowHeight,
3843
3885
  overscanRowCount,
3844
3886
  query,
3887
+ experimental,
3845
3888
  rowSelector,
3846
3889
  rowSelection,
3847
3890
  expandable,
@@ -3901,6 +3944,7 @@ function ReactListTableInner(props, ref) {
3901
3944
  rowKey,
3902
3945
  columns: resolvedColumns,
3903
3946
  dataSource,
3947
+ loading,
3904
3948
  onRow,
3905
3949
  theme,
3906
3950
  striped,
@@ -3912,6 +3956,7 @@ function ReactListTableInner(props, ref) {
3912
3956
  summaryRowHeight: resolvedSummaryRowHeight,
3913
3957
  overscanRowCount,
3914
3958
  query,
3959
+ experimental,
3915
3960
  rowSelector,
3916
3961
  rowSelection,
3917
3962
  expandable,
@@ -3950,6 +3995,7 @@ function ReactListTableInner(props, ref) {
3950
3995
  rowKey,
3951
3996
  resolvedColumns,
3952
3997
  dataSource,
3998
+ loading,
3953
3999
  onRow,
3954
4000
  theme,
3955
4001
  striped,
@@ -3961,6 +4007,7 @@ function ReactListTableInner(props, ref) {
3961
4007
  resolvedSummaryRowHeight,
3962
4008
  overscanRowCount,
3963
4009
  query,
4010
+ experimental,
3964
4011
  rowSelector,
3965
4012
  rowSelection,
3966
4013
  expandable,
@@ -3993,9 +4040,7 @@ function ReactListTableInner(props, ref) {
3993
4040
  closeDangerConfirmRequest
3994
4041
  } = useReactListTableState(options);
3995
4042
  const hasPagination = paginationConfig != null;
3996
- const paginationLayout = resolveReactListTablePaginationLayout(
3997
- resolvedRowHeight
3998
- );
4043
+ const paginationLayout = resolveReactListTablePaginationLayout(resolvedRowHeight);
3999
4044
  react.useImperativeHandle(
4000
4045
  ref,
4001
4046
  () => ({
@@ -4012,7 +4057,8 @@ function ReactListTableInner(props, ref) {
4012
4057
  },
4013
4058
  resetFilter: () => {
4014
4059
  tableRef.current?.resetFilter();
4015
- }
4060
+ },
4061
+ retryQuery: () => tableRef.current?.retryQuery() ?? false
4016
4062
  }),
4017
4063
  []
4018
4064
  );
@@ -4125,7 +4171,7 @@ function ReactListTableInner(props, ref) {
4125
4171
  )
4126
4172
  }
4127
4173
  ),
4128
- loadingRequest ? /* @__PURE__ */ jsxRuntime.jsx(
4174
+ loading || loadingRequest ? /* @__PURE__ */ jsxRuntime.jsx(
4129
4175
  "div",
4130
4176
  {
4131
4177
  style: {
@@ -4140,7 +4186,7 @@ function ReactListTableInner(props, ref) {
4140
4186
  pointerEvents: "auto",
4141
4187
  cursor: "progress"
4142
4188
  },
4143
- children: loadingRequest.text ?? "\u5904\u7406\u4E2D\u2026"
4189
+ children: loading ? "\u6570\u636E\u52A0\u8F7D\u4E2D\u2026" : loadingRequest?.text ?? "\u5904\u7406\u4E2D\u2026"
4144
4190
  }
4145
4191
  ) : null
4146
4192
  ]
@@ -4238,8 +4284,25 @@ function applyManagedColumnOrder(columns, orderedKeys) {
4238
4284
  function resolveColumnKey(column) {
4239
4285
  return String(column.key ?? column.dataIndex);
4240
4286
  }
4241
- var ReactListTable = react.forwardRef(ReactListTableInner);
4287
+ var ReactListTable = react.forwardRef(
4288
+ ReactListTableInner
4289
+ );
4290
+ ReactListTable.EXPAND_COLUMN = listTable.EXPAND_COLUMN;
4291
+ ReactListTable.SELECTION_COLUMN = listTable.SELECTION_COLUMN;
4292
+ ReactListTable.ROW_SELECTION_COLUMN = listTable.ROW_SELECTION_COLUMN;
4242
4293
 
4294
+ Object.defineProperty(exports, "EXPAND_COLUMN", {
4295
+ enumerable: true,
4296
+ get: function () { return listTable.EXPAND_COLUMN; }
4297
+ });
4298
+ Object.defineProperty(exports, "ROW_SELECTION_COLUMN", {
4299
+ enumerable: true,
4300
+ get: function () { return listTable.ROW_SELECTION_COLUMN; }
4301
+ });
4302
+ Object.defineProperty(exports, "SELECTION_COLUMN", {
4303
+ enumerable: true,
4304
+ get: function () { return listTable.SELECTION_COLUMN; }
4305
+ });
4243
4306
  exports.ReactListTable = ReactListTable;
4244
4307
  exports.ReactListTableDebugProvider = ReactListTableDebugProvider;
4245
4308
  //# sourceMappingURL=index.cjs.map