@canvas-components/react-list-table 0.3.74 → 0.3.75

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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createContext, memo, forwardRef, useMemo, useRef, useLayoutEffect, useState, useEffect, useImperativeHandle, useContext, useCallback, useId, Fragment as Fragment$1 } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
- import { getSharedScrollbarSettings, subscribeSharedScrollbarSettings, ReactTooltip, ReactImagePreview, ReactCheckbox, ReactSortableList, ReactInputNumber, ReactSelect, ReactPagination, ReactFilterPanel, ReactPopup, ReactModal, ReactInput, ReactPopconfirm, ReactContentScaleProvider, ReactScrollbarSettingsDialog, ReactScrollbarPositionDialog, setSharedScrollbarSettings, ReactButton, ReactColorPicker, resolveReactScrollbarMode, ReactAutoComplete, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange, ReactCascader, ReactTreeSelect, ReactTableSelect, ReactMathInterval, ReactInputNumberUnit, ReactInputGroup } from '@canvas-components/react-components';
4
- import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, withListTableColumnVisibility, ListTable, getListTableStoredColumnConfig, isListTableColumnHiddenBySource, isListTableColumnHidden, saveListTableStoredColumnConfig, resolveListTableEditorItemWidths } from '@canvas-components/list-table';
3
+ import { getSharedScrollbarSettings, subscribeSharedScrollbarSettings, ReactTooltip, ReactImagePreview, reactMessage, ReactCheckbox, ReactSortableList, ReactInputNumber, ReactSelect, ReactPagination, ReactModal, ReactSwitch, ReactInput, ReactButton, ReactFilterPanel, ReactPopup, ReactPopconfirm, ReactContentScaleProvider, ReactScrollbarSettingsDialog, ReactScrollbarPositionDialog, setSharedScrollbarSettings, ReactColorPicker, resolveReactScrollbarMode, ReactAutoComplete, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange, ReactCascader, ReactTreeSelect, ReactTableSelect, ReactMathInterval, ReactInputNumberUnit, ReactInputGroup } from '@canvas-components/react-components';
4
+ import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, withListTableColumnVisibility, ListTable, formatPaginationText, getListTableStoredColumnConfig, isListTableColumnHiddenBySource, isListTableColumnHidden, withPaginationDefaults, validatePaginationConfig, saveListTableStoredColumnConfig, resolveListTableEditorItemWidths } from '@canvas-components/list-table';
5
5
  export { EXPAND_COLUMN, ROW_SELECTION_COLUMN, SELECTION_COLUMN, getListTableStoredPageSize } from '@canvas-components/list-table';
6
6
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
7
  import { CanvasChart } from '@canvas-components/chart';
@@ -1407,7 +1407,27 @@ function ReactTableContextMenuView(props) {
1407
1407
  onChange: request.onChangeDensity
1408
1408
  }
1409
1409
  ),
1410
+ request.onOpenPaginationConfig ? /* @__PURE__ */ jsx(
1411
+ MenuAction,
1412
+ {
1413
+ label: "\u5206\u9875\u914D\u7F6E",
1414
+ onClick: () => {
1415
+ request.onClose();
1416
+ request.onOpenPaginationConfig?.();
1417
+ }
1418
+ }
1419
+ ) : null,
1410
1420
  /* @__PURE__ */ jsx(ZoomMenu, { value: request.zoom ?? 1, onChange: request.onChangeZoom }),
1421
+ request.onToggleDebug ? /* @__PURE__ */ jsx(
1422
+ MenuAction,
1423
+ {
1424
+ label: request.debugEnabled ? "\u5173\u95ED\u8C03\u8BD5" : "\u5F00\u542F\u8C03\u8BD5",
1425
+ onClick: () => {
1426
+ request.onClose();
1427
+ request.onToggleDebug?.();
1428
+ }
1429
+ }
1430
+ ) : null,
1411
1431
  request.columnSettingsCacheAvailable === true ? /* @__PURE__ */ jsx(
1412
1432
  MenuSubmenu,
1413
1433
  {
@@ -4442,6 +4462,7 @@ function getEditorInputStyle(request) {
4442
4462
  color: request.theme.cellColor ?? request.theme.textColor,
4443
4463
  textAlign: request.theme.textAlign,
4444
4464
  fontFamily: request.theme.fontFamily,
4465
+ fontWeight: request.theme.fontWeight ?? "normal",
4445
4466
  fontSize,
4446
4467
  // 用像素 token,确保 select/time/color 触发器与内部 Input 同步缩放。
4447
4468
  ["--canvas-react-control-height"]: `${height}px`,
@@ -4471,6 +4492,8 @@ function resolveEditorOverlayStyle(params) {
4471
4492
  minHeight: height,
4472
4493
  zIndex: 1200,
4473
4494
  boxSizing: "border-box",
4495
+ fontFamily: params.fontFamily,
4496
+ fontWeight: params.fontWeight ?? "normal",
4474
4497
  // 覆盖表单组件 token,使输入框高度/字号/内边距跟随表格缩放。
4475
4498
  ["--canvas-react-control-height"]: `${height}px`,
4476
4499
  ["--canvas-react-control-padding-inline"]: `${Math.max(resolvedPaddingInline - 1, 0)}px`,
@@ -4895,6 +4918,7 @@ function CompositeEditor({
4895
4918
  style: {
4896
4919
  fontSize: request.theme.fontSize,
4897
4920
  fontFamily: request.theme.fontFamily,
4921
+ fontWeight: request.theme.fontWeight ?? "normal",
4898
4922
  color: request.theme.textColor,
4899
4923
  ...errorStyle
4900
4924
  },
@@ -5355,6 +5379,8 @@ function ReactTableEditorOverlay(props) {
5355
5379
  rect: request.rect,
5356
5380
  hostRect: request.hostRect,
5357
5381
  fontSize: request.theme.fontSize,
5382
+ fontFamily: request.theme.fontFamily,
5383
+ fontWeight: request.theme.fontWeight,
5358
5384
  paddingInline: request.theme.paddingInline,
5359
5385
  paddingBlock: request.theme.paddingBlock,
5360
5386
  contentZoom: request.theme.contentZoom
@@ -6361,7 +6387,12 @@ function ReactTableFilterPanelView(props) {
6361
6387
  }
6362
6388
 
6363
6389
  // src/components/react-list-table-layout.ts
6364
- function resolveReactListTablePaginationLayout(density) {
6390
+ function resolveReactListTablePaginationLayout(density, size) {
6391
+ if (size && size !== "auto") {
6392
+ return resolveReactListTablePaginationLayout(
6393
+ size === "small" ? 26 : size === "large" ? 48 : 32
6394
+ );
6395
+ }
6365
6396
  if (typeof density === "number" && density <= 26) {
6366
6397
  return { size: "small", height: 32, paddingTop: 8 };
6367
6398
  }
@@ -6386,7 +6417,7 @@ function ReactTablePaginationView(props) {
6386
6417
  if (!config) {
6387
6418
  return null;
6388
6419
  }
6389
- const layout = resolveReactListTablePaginationLayout(density);
6420
+ const layout = resolveReactListTablePaginationLayout(density, config.size);
6390
6421
  return /* @__PURE__ */ jsx(
6391
6422
  "div",
6392
6423
  {
@@ -6405,6 +6436,7 @@ function ReactTablePaginationView(props) {
6405
6436
  {
6406
6437
  styles: config.styles,
6407
6438
  size: layout.size,
6439
+ pageInfoText: config.pageInfoText,
6408
6440
  current: config.current,
6409
6441
  total: config.total,
6410
6442
  pageSize: config.pageSize,
@@ -6429,6 +6461,402 @@ function ReactTablePaginationView(props) {
6429
6461
  }
6430
6462
  );
6431
6463
  }
6464
+ var pageInfoFormats = [
6465
+ { value: "", label: "\u4E0D\u989D\u5916\u663E\u793A" },
6466
+ {
6467
+ value: "\u7B2C {current} \u9875 / \u5171 {totalPages} \u9875",
6468
+ label: "\u7B2C 1 \u9875 / \u5171 10 \u9875"
6469
+ },
6470
+ { value: "{current} / {totalPages}", label: "1 / 10" },
6471
+ { value: "custom", label: "\u81EA\u5B9A\u4E49\u683C\u5F0F" }
6472
+ ];
6473
+ var totalFormats = [
6474
+ { value: "inherit", label: "\u6CBF\u7528\u4F20\u5165\u683C\u5F0F" },
6475
+ { value: "\u5171 {total} \u6761", label: "\u5171 200 \u6761" },
6476
+ {
6477
+ value: "\u7B2C {start}\u2013{end} \u6761\uFF0C\u5171 {total} \u6761",
6478
+ label: "\u7B2C 1\u201320 \u6761\uFF0C\u5171 200 \u6761"
6479
+ },
6480
+ { value: "hide", label: "\u9690\u85CF" },
6481
+ { value: "custom", label: "\u81EA\u5B9A\u4E49\u683C\u5F0F" }
6482
+ ];
6483
+ function createPaginationDraft(snapshot, incoming = false) {
6484
+ const source = incoming ? snapshot.incoming : snapshot.value;
6485
+ const config = withPaginationDefaults(
6486
+ source || (incoming ? {} : snapshot.retained)
6487
+ );
6488
+ const pageTemplate = config.pageInfoFormat ?? "";
6489
+ const totalTemplate = typeof config.totalFormat === "string" ? config.totalFormat : "";
6490
+ return {
6491
+ cacheEnabled: snapshot.cache?.enabled ?? false,
6492
+ cacheScope: snapshot.cache?.scope ?? "all",
6493
+ enabled: !!source,
6494
+ config,
6495
+ current: String(config.current),
6496
+ pageSize: String(config.pageSize),
6497
+ minPageSize: String(config.minPageSize ?? 1),
6498
+ maxPageSize: config.maxPageSize == null ? "" : String(config.maxPageSize),
6499
+ candidates: config.pageSizeOptions.join(", "),
6500
+ pageChoice: pageInfoFormats.some((o) => o.value === pageTemplate) ? pageTemplate : "custom",
6501
+ totalChoice: config.totalFormat === false ? "hide" : config.totalFormat === void 0 ? "inherit" : totalFormats.some((o) => o.value === totalTemplate) ? totalTemplate : "custom",
6502
+ pageTemplate,
6503
+ totalTemplate
6504
+ };
6505
+ }
6506
+ function paginationDraftValue(draft) {
6507
+ if (!draft.enabled) return false;
6508
+ return {
6509
+ ...draft.config,
6510
+ current: Number(draft.current),
6511
+ pageSize: Number(draft.pageSize),
6512
+ minPageSize: Number(draft.minPageSize),
6513
+ maxPageSize: draft.maxPageSize.trim() ? Number(draft.maxPageSize) : void 0,
6514
+ pageSizeOptions: [
6515
+ ...new Set(draft.candidates.split(/[,,]/).map((n) => Number(n.trim())))
6516
+ ].sort((a, b) => a - b),
6517
+ pageInfoFormat: draft.pageChoice === "custom" ? draft.pageTemplate : draft.pageChoice || void 0,
6518
+ totalFormat: draft.totalChoice === "inherit" ? void 0 : draft.totalChoice === "hide" ? false : draft.totalChoice === "custom" ? draft.totalTemplate : draft.totalChoice
6519
+ };
6520
+ }
6521
+
6522
+ // src/features/pagination/pagination-config-dialog.css
6523
+ styleInject(".react-list-table-pagination-config {\n display: grid;\n gap: 18px;\n color: var(--canvas-react-color-text, #253247);\n}\n.react-list-table-pagination-config-enable {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 16px;\n}\n.react-list-table-pagination-config-cache {\n flex-wrap: wrap;\n}\n.react-list-table-pagination-config-cache > label {\n flex-shrink: 0;\n white-space: nowrap;\n}\n.react-list-table-pagination-config-cache-scope {\n flex: 0 1 180px;\n min-width: 120px;\n}\n.react-list-table-pagination-config-help {\n color: var(--canvas-react-color-text-muted, #64748b);\n font-size: 12px;\n margin-top: 6px;\n}\n.react-list-table-pagination-config fieldset {\n border: 0;\n padding: 0;\n margin: 0;\n min-width: 0;\n}\n.react-list-table-pagination-config fieldset:disabled {\n opacity: 0.5;\n}\n.react-list-table-pagination-config h3 {\n font-size: 13px;\n margin: 18px 0 12px;\n}\n.react-list-table-pagination-config h3:first-child {\n margin-top: 0;\n}\n.react-list-table-pagination-config-grid {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 14px 20px;\n margin-top: 12px;\n}\n.react-list-table-pagination-config-field {\n display: grid;\n align-content: start;\n gap: 6px;\n min-width: 0;\n font-size: 13px;\n}\n.react-list-table-pagination-config-check {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n}\n.react-list-table-pagination-config-check input {\n accent-color: var(--canvas-react-color-primary, #2563eb);\n}\n.react-list-table-pagination-config details {\n margin-top: 18px;\n border-top: 1px solid var(--canvas-react-color-border, #e2e8f0);\n padding-top: 14px;\n}\n.react-list-table-pagination-config summary {\n cursor: pointer;\n font-size: 13px;\n font-weight: 600;\n}\n.react-list-table-pagination-config-preview {\n border-top: 1px solid var(--canvas-react-color-border, #e2e8f0);\n padding-top: 10px;\n min-width: 0;\n}\n.react-list-table-pagination-config-pager {\n display: flex;\n justify-content: flex-end;\n margin-top: 12px;\n}\n.react-list-table-pagination-config-pager > div {\n flex-wrap: wrap;\n justify-content: flex-end;\n}\n.react-list-table-pagination-config-off {\n text-align: center;\n padding: 16px 0;\n color: var(--canvas-react-color-text-muted, #64748b);\n}\n.react-list-table-pagination-config-error {\n color: var(--canvas-react-color-danger, #dc2626);\n font-size: 12px;\n}\n.react-list-table-pagination-config-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 12px;\n flex-wrap: wrap;\n width: 100%;\n}\n.react-list-table-pagination-config-footer > div {\n display: flex;\n gap: 10px;\n margin-left: auto;\n}\n@media (max-width: 460px) {\n .react-list-table-pagination-config-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n");
6524
+ function ReactListTablePaginationConfigDialog(props) {
6525
+ const [initial] = useState(() => createPaginationDraft(props.snapshot));
6526
+ const [draft, setDraft] = useState(initial);
6527
+ const [currentEdited, setCurrentEdited] = useState(false);
6528
+ const [errors, setErrors] = useState({});
6529
+ const patch = (next) => setDraft((current2) => ({ ...current2, ...next }));
6530
+ const patchConfig = (next) => setDraft((current2) => ({
6531
+ ...current2,
6532
+ config: { ...current2.config, ...next }
6533
+ }));
6534
+ const value = paginationDraftValue(draft);
6535
+ const scroll = draft.config.mode === "scroll";
6536
+ const pageSize = Math.max(
6537
+ 1,
6538
+ Number.isSafeInteger(Number(draft.pageSize)) ? Number(draft.pageSize) : 10
6539
+ );
6540
+ const totalPages = Math.max(1, Math.ceil(props.snapshot.total / pageSize));
6541
+ const current = Math.min(totalPages, Math.max(1, Number(draft.current) || 1));
6542
+ const field = (label, key, control) => /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-field", children: [
6543
+ /* @__PURE__ */ jsx("span", { children: label }),
6544
+ control,
6545
+ errors[key] ? /* @__PURE__ */ jsx("span", { role: "alert", className: "react-list-table-pagination-config-error", children: errors[key] }) : null
6546
+ ] });
6547
+ const input = (label, key) => field(
6548
+ label,
6549
+ key === "candidates" ? "pageSizeOptions" : key,
6550
+ /* @__PURE__ */ jsx(
6551
+ ReactInput,
6552
+ {
6553
+ "aria-label": label,
6554
+ value: draft[key],
6555
+ inputMode: key === "candidates" ? "text" : "numeric",
6556
+ allowClear: false,
6557
+ placeholder: key === "maxPageSize" ? "\u4E0D\u9650\u5236" : void 0,
6558
+ onChange: (event) => {
6559
+ if (key === "current") setCurrentEdited(true);
6560
+ patch({
6561
+ [key]: event.target.value,
6562
+ ...key === "pageSize" && !currentEdited ? { current: "1" } : {}
6563
+ });
6564
+ }
6565
+ }
6566
+ )
6567
+ );
6568
+ const check = (label, key, disabled = false) => /* @__PURE__ */ jsxs("label", { className: "react-list-table-pagination-config-check", children: [
6569
+ /* @__PURE__ */ jsx(
6570
+ "input",
6571
+ {
6572
+ type: "checkbox",
6573
+ checked: key === "allowPageSizeInput" ? draft.config.allowPageSizeInput ?? !!draft.config.showSizeChanger : !!draft.config[key],
6574
+ disabled,
6575
+ onChange: (event) => patchConfig({ [key]: event.target.checked })
6576
+ }
6577
+ ),
6578
+ label
6579
+ ] });
6580
+ const confirm = () => {
6581
+ if (JSON.stringify(draft) === JSON.stringify(initial)) {
6582
+ props.onClose();
6583
+ return;
6584
+ }
6585
+ const nextErrors = {
6586
+ ...validatePaginationConfig(value, props.snapshot.total)
6587
+ };
6588
+ if (draft.enabled && draft.pageChoice === "custom" && !draft.pageTemplate.trim())
6589
+ nextErrors.pageInfoFormat = "\u8BF7\u8F93\u5165\u9875\u7801\u4FE1\u606F\u683C\u5F0F";
6590
+ setErrors(nextErrors);
6591
+ if (Object.keys(nextErrors).length) return;
6592
+ const result = props.onConfirm(value, {
6593
+ enabled: draft.cacheEnabled,
6594
+ scope: draft.cacheScope
6595
+ });
6596
+ if (result.ok) props.onClose();
6597
+ else setErrors(result.errors);
6598
+ };
6599
+ const totalFormat = value && value.totalFormat;
6600
+ const pageFormat = value && value.pageInfoFormat;
6601
+ return /* @__PURE__ */ jsx(
6602
+ ReactModal,
6603
+ {
6604
+ open: true,
6605
+ title: "\u5206\u9875\u914D\u7F6E",
6606
+ width: 640,
6607
+ fullscreenable: false,
6608
+ onCancel: props.onClose,
6609
+ footer: /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-footer", children: [
6610
+ /* @__PURE__ */ jsx(
6611
+ ReactButton,
6612
+ {
6613
+ type: "text",
6614
+ onClick: () => {
6615
+ setDraft(createPaginationDraft(props.snapshot, true));
6616
+ setCurrentEdited(false);
6617
+ setErrors({});
6618
+ },
6619
+ children: "\u6062\u590D\u4F20\u5165\u914D\u7F6E"
6620
+ }
6621
+ ),
6622
+ /* @__PURE__ */ jsxs("div", { children: [
6623
+ /* @__PURE__ */ jsx(ReactButton, { onClick: props.onClose, children: "\u53D6\u6D88" }),
6624
+ /* @__PURE__ */ jsx(ReactButton, { type: "primary", onClick: confirm, children: "\u786E\u5B9A" })
6625
+ ] })
6626
+ ] }),
6627
+ children: /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config", children: [
6628
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-enable", children: [
6629
+ /* @__PURE__ */ jsxs("div", { children: [
6630
+ /* @__PURE__ */ jsx("strong", { children: "\u542F\u7528\u5206\u9875" }),
6631
+ /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-help", children: "\u5173\u95ED\u540E\u5C55\u793A\u5168\u90E8\u5DF2\u52A0\u8F7D\u6570\u636E\uFF0C\u4E0D\u663E\u793A\u5206\u9875\u63A7\u4EF6" })
6632
+ ] }),
6633
+ /* @__PURE__ */ jsx(
6634
+ ReactSwitch,
6635
+ {
6636
+ "aria-label": "\u542F\u7528\u5206\u9875",
6637
+ checked: draft.enabled,
6638
+ onChange: (enabled) => {
6639
+ setCurrentEdited(false);
6640
+ patch({ enabled, ...enabled ? { current: "1" } : {} });
6641
+ }
6642
+ }
6643
+ )
6644
+ ] }),
6645
+ /* @__PURE__ */ jsxs("fieldset", { disabled: !draft.enabled, children: [
6646
+ /* @__PURE__ */ jsx("h3", { children: scroll ? "\u6EDA\u52A8\u52A0\u8F7D" : "\u57FA\u672C\u8BBE\u7F6E" }),
6647
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
6648
+ scroll ? /* @__PURE__ */ jsxs("div", { children: [
6649
+ "\u5F53\u524D\u5DF2\u52A0\u8F7D ",
6650
+ draft.current,
6651
+ " \u9875"
6652
+ ] }) : input("\u5F53\u524D\u9875", "current"),
6653
+ input(scroll ? "\u6BCF\u6279\u6761\u6570" : "\u6BCF\u9875\u6761\u6570", "pageSize")
6654
+ ] }),
6655
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-help", children: [
6656
+ "\u5171 ",
6657
+ props.snapshot.total,
6658
+ " \u6761\u6570\u636E \xB7 ",
6659
+ totalPages,
6660
+ " \u9875"
6661
+ ] }),
6662
+ !scroll ? /* @__PURE__ */ jsxs(Fragment, { children: [
6663
+ /* @__PURE__ */ jsx("h3", { children: "\u663E\u793A\u8BBE\u7F6E" }),
6664
+ /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-grid", children: field(
6665
+ "\u5206\u9875\u5C3A\u5BF8",
6666
+ "size",
6667
+ /* @__PURE__ */ jsx(
6668
+ ReactSelect,
6669
+ {
6670
+ "aria-label": "\u5206\u9875\u5C3A\u5BF8",
6671
+ value: draft.config.size ?? "auto",
6672
+ options: [
6673
+ { value: "auto", label: "\u8DDF\u968F\u8868\u683C" },
6674
+ { value: "small", label: "\u5C0F" },
6675
+ { value: "middle", label: "\u4E2D" },
6676
+ { value: "large", label: "\u5927" }
6677
+ ],
6678
+ onChange: (size) => patchConfig({
6679
+ size
6680
+ })
6681
+ }
6682
+ )
6683
+ ) }),
6684
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
6685
+ check("\u7B80\u6D01\u6A21\u5F0F", "simple"),
6686
+ check("\u7D27\u51D1\u9875\u7801", "showLessItems", !!draft.config.simple),
6687
+ check("\u663E\u793A\u6BCF\u9875\u6761\u6570\u9009\u62E9\u5668", "showSizeChanger"),
6688
+ check("\u663E\u793A\u5FEB\u901F\u8DF3\u9875", "showQuickJumper")
6689
+ ] }),
6690
+ /* @__PURE__ */ jsx("h3", { children: "\u6587\u6848\u8BBE\u7F6E" }),
6691
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
6692
+ field(
6693
+ "\u9875\u7801\u4FE1\u606F\u683C\u5F0F",
6694
+ "pageInfoFormat",
6695
+ /* @__PURE__ */ jsxs(Fragment, { children: [
6696
+ /* @__PURE__ */ jsx(
6697
+ ReactSelect,
6698
+ {
6699
+ "aria-label": "\u9875\u7801\u4FE1\u606F\u683C\u5F0F",
6700
+ value: draft.pageChoice,
6701
+ options: pageInfoFormats,
6702
+ onChange: (pageChoice) => patch({ pageChoice })
6703
+ }
6704
+ ),
6705
+ draft.pageChoice === "custom" ? /* @__PURE__ */ jsx(
6706
+ ReactInput,
6707
+ {
6708
+ "aria-label": "\u81EA\u5B9A\u4E49\u9875\u7801\u4FE1\u606F\u683C\u5F0F",
6709
+ maxLength: 500,
6710
+ placeholder: "\u7B2C {current} \u9875 / \u5171 {totalPages} \u9875",
6711
+ value: draft.pageTemplate,
6712
+ onChange: (event) => patch({ pageTemplate: event.target.value })
6713
+ }
6714
+ ) : null
6715
+ ] })
6716
+ ),
6717
+ field(
6718
+ "\u603B\u6761\u6570\u683C\u5F0F",
6719
+ "totalFormat",
6720
+ /* @__PURE__ */ jsxs(Fragment, { children: [
6721
+ /* @__PURE__ */ jsx(
6722
+ ReactSelect,
6723
+ {
6724
+ "aria-label": "\u603B\u6761\u6570\u683C\u5F0F",
6725
+ value: draft.totalChoice,
6726
+ options: totalFormats,
6727
+ onChange: (totalChoice) => patch({ totalChoice })
6728
+ }
6729
+ ),
6730
+ draft.totalChoice === "custom" ? /* @__PURE__ */ jsx(
6731
+ ReactInput,
6732
+ {
6733
+ "aria-label": "\u81EA\u5B9A\u4E49\u603B\u6761\u6570\u683C\u5F0F",
6734
+ maxLength: 500,
6735
+ placeholder: "\u7B2C {start}\u2013{end} \u6761\uFF0C\u5171 {total} \u6761",
6736
+ value: draft.totalTemplate,
6737
+ onChange: (event) => patch({ totalTemplate: event.target.value })
6738
+ }
6739
+ ) : null
6740
+ ] })
6741
+ )
6742
+ ] }),
6743
+ draft.pageChoice === "custom" || draft.totalChoice === "custom" ? /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-help", children: [
6744
+ "\u9875\u7801\uFF1A",
6745
+ "{current}\u3001{totalPages}",
6746
+ "\uFF1B\u603B\u6761\u6570\uFF1A",
6747
+ "{total}\u3001{start}\u3001{end}"
6748
+ ] }) : null,
6749
+ /* @__PURE__ */ jsxs("details", { children: [
6750
+ /* @__PURE__ */ jsx("summary", { children: "\u9AD8\u7EA7\u8BBE\u7F6E" }),
6751
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
6752
+ input("\u6BCF\u9875\u6761\u6570\u5019\u9009", "candidates"),
6753
+ input("\u6700\u5C0F\u6BCF\u9875\u6761\u6570", "minPageSize"),
6754
+ input("\u6700\u5927\u6BCF\u9875\u6761\u6570", "maxPageSize")
6755
+ ] }),
6756
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
6757
+ check(
6758
+ "\u5141\u8BB8\u624B\u8F93\u6BCF\u9875\u6761\u6570",
6759
+ "allowPageSizeInput",
6760
+ !draft.config.showSizeChanger
6761
+ ),
6762
+ check("\u7981\u7528\u5206\u9875\u64CD\u4F5C", "disabled")
6763
+ ] })
6764
+ ] })
6765
+ ] }) : null
6766
+ ] }),
6767
+ /* @__PURE__ */ jsxs("div", { children: [
6768
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-enable react-list-table-pagination-config-cache", children: [
6769
+ /* @__PURE__ */ jsxs("label", { className: "react-list-table-pagination-config-check", children: [
6770
+ /* @__PURE__ */ jsx(
6771
+ "input",
6772
+ {
6773
+ type: "checkbox",
6774
+ "aria-label": "\u7F13\u5B58\u5230\u672C\u5730",
6775
+ checked: draft.cacheEnabled,
6776
+ onChange: (event) => patch({ cacheEnabled: event.target.checked })
6777
+ }
6778
+ ),
6779
+ "\u7F13\u5B58\u5230\u672C\u5730"
6780
+ ] }),
6781
+ /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-cache-scope", children: /* @__PURE__ */ jsx(
6782
+ ReactSelect,
6783
+ {
6784
+ "aria-label": "\u7F13\u5B58\u8303\u56F4",
6785
+ disabled: !draft.cacheEnabled,
6786
+ value: draft.cacheScope,
6787
+ options: [
6788
+ {
6789
+ value: "table",
6790
+ label: "\u5F53\u524D\u8868\u683C",
6791
+ disabled: !props.snapshot.cache?.currentTableAvailable
6792
+ },
6793
+ { value: "all", label: "\u6240\u6709\u8868\u683C" }
6794
+ ],
6795
+ onChange: (scope) => patch({ cacheScope: scope })
6796
+ }
6797
+ ) })
6798
+ ] }),
6799
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-help", children: [
6800
+ draft.cacheScope === "all" ? "\u4F5C\u4E3A\u6240\u6709\u8868\u683C\u7684\u5171\u4EAB\u9ED8\u8BA4\u914D\u7F6E\uFF1B\u660E\u786E\u8BBE\u7F6E pagination=false \u7684\u8868\u683C\u4E0D\u4F7F\u7528\u5171\u4EAB\u7F13\u5B58\u3002\u5355\u8868\u7F13\u5B58\u4F18\u5148\u3002" : "\u4EC5\u4FDD\u5B58\u5230\u5F53\u524D\u8868\u683C\uFF1B\u9700\u8981\u7A33\u5B9A\u7684 storageKey\u3002",
6801
+ " ",
6802
+ "\u5F53\u524D\u9875\u4E0D\u7F13\u5B58\u3002"
6803
+ ] }),
6804
+ errors.cache ? /* @__PURE__ */ jsx(
6805
+ "div",
6806
+ {
6807
+ role: "alert",
6808
+ className: "react-list-table-pagination-config-error",
6809
+ children: errors.cache
6810
+ }
6811
+ ) : null
6812
+ ] }),
6813
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-preview", children: [
6814
+ /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-help", children: "\u5206\u9875\u9884\u89C8" }),
6815
+ !draft.enabled ? /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-off", children: "\u5206\u9875\u5DF2\u5173\u95ED" }) : scroll ? /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-off", children: "\u6EDA\u52A8\u5230\u5E95\u90E8\u52A0\u8F7D\u4E0B\u4E00\u6279\uFF0C\u4E0D\u663E\u793A\u5206\u9875\u63A7\u4EF6" }) : /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-pager", children: /* @__PURE__ */ jsx(
6816
+ ReactPagination,
6817
+ {
6818
+ ...draft.config,
6819
+ allowPageSizeInput: draft.config.allowPageSizeInput ?? draft.config.showSizeChanger,
6820
+ size: resolveReactListTablePaginationLayout(
6821
+ void 0,
6822
+ draft.config.size
6823
+ ).size,
6824
+ current,
6825
+ pageSize,
6826
+ total: props.snapshot.total,
6827
+ pageSizeOptions: value ? value.pageSizeOptions : void 0,
6828
+ pageInfoText: pageFormat ? formatPaginationText(pageFormat, { current, totalPages }) : void 0,
6829
+ showTotal: typeof totalFormat === "string" ? (total, [start, end]) => formatPaginationText(totalFormat, {
6830
+ total,
6831
+ start: total ? start : 0,
6832
+ end: total ? end : 0
6833
+ }) : totalFormat === false ? void 0 : props.showTotal,
6834
+ onChange: (page) => {
6835
+ setCurrentEdited(true);
6836
+ patch({ current: String(page) });
6837
+ },
6838
+ onPageSizeChange: (_page, size) => patch({
6839
+ pageSize: String(size),
6840
+ ...!currentEdited ? { current: "1" } : {}
6841
+ })
6842
+ }
6843
+ ) })
6844
+ ] }),
6845
+ errors.table ? /* @__PURE__ */ jsx("div", { role: "alert", children: errors.table }) : null
6846
+ ] })
6847
+ }
6848
+ );
6849
+ }
6850
+ function usePaginationConfigDialog(request, latest, onClose) {
6851
+ const stale = !!request && !!latest && request.revision !== latest.revision;
6852
+ useEffect(() => {
6853
+ if (stale) {
6854
+ onClose();
6855
+ reactMessage.info("\u5206\u9875\u72B6\u6001\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u914D\u7F6E");
6856
+ }
6857
+ }, [stale, onClose]);
6858
+ return request && !stale ? request : null;
6859
+ }
6432
6860
  function ReactTableDangerConfirmView(props) {
6433
6861
  const { request, onClose } = props;
6434
6862
  const confirmingRef = useRef(false);
@@ -6844,6 +7272,14 @@ function flattenColumns(columns, parentKey = "root", level = 0, parentHidden = f
6844
7272
  function useReactListTableState(options) {
6845
7273
  const containerRef = useRef(null);
6846
7274
  const tableRef = useRef(null);
7275
+ const [paginationSnapshot, setPaginationSnapshot] = useState(null);
7276
+ const [paginationConfigRequest, setPaginationConfigRequest] = useState(null);
7277
+ const hadPaginationConfigRequest = useRef(false);
7278
+ useEffect(() => {
7279
+ if (hadPaginationConfigRequest.current && !paginationConfigRequest)
7280
+ containerRef.current?.querySelector("canvas")?.focus();
7281
+ hadPaginationConfigRequest.current = !!paginationConfigRequest;
7282
+ }, [paginationConfigRequest]);
6847
7283
  const [editorRequest, setEditorRequest] = useState(null);
6848
7284
  const [paginationConfig, setPaginationConfig] = useState(null);
6849
7285
  const [tooltipRequest, setTooltipRequest] = useState(null);
@@ -6858,6 +7294,15 @@ function useReactListTableState(options) {
6858
7294
  const uiOptions = useMemo(
6859
7295
  () => ({
6860
7296
  ...options.ui,
7297
+ onOpenPaginationConfig: () => {
7298
+ const snapshot = tableRef.current?.getPaginationConfig();
7299
+ if (snapshot) setPaginationConfigRequest(snapshot);
7300
+ options.ui?.onOpenPaginationConfig?.();
7301
+ },
7302
+ onPaginationConfigRender: (snapshot) => {
7303
+ setPaginationSnapshot(snapshot);
7304
+ options.ui?.onPaginationConfigRender?.(snapshot);
7305
+ },
6861
7306
  onExportNameRequest: (request) => {
6862
7307
  setExportNameRequest(request);
6863
7308
  options.ui?.onExportNameRequest?.(request);
@@ -6924,6 +7369,8 @@ function useReactListTableState(options) {
6924
7369
  appliedOptionsRef.current = null;
6925
7370
  setEditorRequest(null);
6926
7371
  setPaginationConfig(null);
7372
+ setPaginationSnapshot(null);
7373
+ setPaginationConfigRequest(null);
6927
7374
  setTooltipRequest(null);
6928
7375
  setLoadingRequest(null);
6929
7376
  setFilterPanelRequest(null);
@@ -6948,6 +7395,9 @@ function useReactListTableState(options) {
6948
7395
  return {
6949
7396
  containerRef,
6950
7397
  tableRef,
7398
+ paginationSnapshot,
7399
+ paginationConfigRequest,
7400
+ closePaginationConfigRequest: () => setPaginationConfigRequest(null),
6951
7401
  editorRequest,
6952
7402
  paginationConfig,
6953
7403
  tooltipRequest,
@@ -7029,7 +7479,7 @@ function useStableTableProps(props) {
7029
7479
  }
7030
7480
  return handler;
7031
7481
  };
7032
- for (const key of ["onChange"]) {
7482
+ for (const key of ["onChange", "onPaginationConfigChange"]) {
7033
7483
  if (typeof props[key] === "function") next[key] = event(void 0, key);
7034
7484
  }
7035
7485
  for (const key of CONFIG_KEYS) {
@@ -7292,6 +7742,7 @@ function ReactListTableInner(props, ref) {
7292
7742
  rowSelection,
7293
7743
  expandable,
7294
7744
  pagination,
7745
+ onPaginationConfigChange,
7295
7746
  scrollbar,
7296
7747
  stickToBottom,
7297
7748
  carouselScroll,
@@ -7323,6 +7774,7 @@ function ReactListTableInner(props, ref) {
7323
7774
  }, [storageKey]);
7324
7775
  const shellRef = useRef(null);
7325
7776
  const [isFullscreen, setIsFullscreen] = useState(false);
7777
+ const [paginationHeight, setPaginationHeight] = useState(0);
7326
7778
  const [scrollbarOverride, setScrollbarOverride] = useStorageKeyState(
7327
7779
  storageKey,
7328
7780
  () => null
@@ -7379,11 +7831,13 @@ function ReactListTableInner(props, ref) {
7379
7831
  const queryRef = useRef(query);
7380
7832
  queryRef.current = retainEqualQueryOption(queryRef.current, query);
7381
7833
  const stableQuery = queryRef.current;
7834
+ const autoContentHeight = height == null && style?.height == null && scroll?.y == null ? (resolvedHeaderRowHeight ?? 40) + dataSource.length * (typeof resolvedRowHeight === "number" ? resolvedRowHeight : 40) + paginationHeight : void 0;
7835
+ const resolvedTableHeight = autoContentHeight ?? height;
7382
7836
  const options = useMemo(() => {
7383
7837
  const nextOptions = buildListTableOptions({
7384
7838
  exportOptions,
7385
7839
  width,
7386
- height,
7840
+ height: resolvedTableHeight,
7387
7841
  emptyText,
7388
7842
  scroll,
7389
7843
  locale,
@@ -7412,6 +7866,7 @@ function ReactListTableInner(props, ref) {
7412
7866
  rowSelection,
7413
7867
  expandable,
7414
7868
  pagination,
7869
+ onPaginationConfigChange,
7415
7870
  scrollbar: effectiveScrollbar,
7416
7871
  stickToBottom,
7417
7872
  carouselScroll,
@@ -7479,7 +7934,7 @@ function ReactListTableInner(props, ref) {
7479
7934
  }, [
7480
7935
  exportOptions,
7481
7936
  width,
7482
- height,
7937
+ resolvedTableHeight,
7483
7938
  emptyText,
7484
7939
  scroll,
7485
7940
  locale,
@@ -7508,6 +7963,7 @@ function ReactListTableInner(props, ref) {
7508
7963
  rowSelection,
7509
7964
  expandable,
7510
7965
  pagination,
7966
+ onPaginationConfigChange,
7511
7967
  effectiveScrollbar,
7512
7968
  stickToBottom,
7513
7969
  carouselScroll,
@@ -7527,6 +7983,9 @@ function ReactListTableInner(props, ref) {
7527
7983
  const {
7528
7984
  containerRef,
7529
7985
  tableRef,
7986
+ paginationSnapshot,
7987
+ paginationConfigRequest,
7988
+ closePaginationConfigRequest,
7530
7989
  editorRequest,
7531
7990
  paginationConfig,
7532
7991
  tooltipRequest,
@@ -7543,7 +8002,18 @@ function ReactListTableInner(props, ref) {
7543
8002
  } = useReactListTableState(options);
7544
8003
  const hasPagination = paginationConfig != null;
7545
8004
  const [cacheConfigOpen, setCacheConfigOpen] = useState(false);
7546
- const paginationLayout = resolveReactListTablePaginationLayout(resolvedRowHeight);
8005
+ const paginationLayout = resolveReactListTablePaginationLayout(
8006
+ resolvedRowHeight,
8007
+ paginationConfig?.size
8008
+ );
8009
+ useLayoutEffect(() => {
8010
+ setPaginationHeight(hasPagination ? paginationLayout.height : 0);
8011
+ }, [hasPagination, paginationLayout.height]);
8012
+ const paginationDialogSnapshot = usePaginationConfigDialog(
8013
+ paginationConfigRequest,
8014
+ paginationSnapshot,
8015
+ closePaginationConfigRequest
8016
+ );
7547
8017
  const portalContainer = resolveFullscreenPortalContainer(shellRef.current);
7548
8018
  const PrintHost = printIntegration?.Host;
7549
8019
  const contextMenuRequest = headerContextMenuRequest ? {
@@ -7576,6 +8046,11 @@ function ReactListTableInner(props, ref) {
7576
8046
  useImperativeHandle(
7577
8047
  ref,
7578
8048
  () => ({
8049
+ getPaginationConfig: () => tableRef.current?.getPaginationConfig() ?? null,
8050
+ setPaginationConfig: (value, cache) => tableRef.current?.setPaginationConfig(value, cache) ?? {
8051
+ ok: false,
8052
+ errors: { table: "\u8868\u683C\u5C1A\u672A\u6302\u8F7D" }
8053
+ },
7579
8054
  getDataSource: () => tableRef.current?.getDataSource() ?? [],
7580
8055
  getFilteredData: () => tableRef.current?.getFilteredData() ?? [],
7581
8056
  validate: () => tableRef.current?.validate() ?? Promise.resolve([]),
@@ -7591,6 +8066,19 @@ function ReactListTableInner(props, ref) {
7591
8066
  scrollTo: (options2) => {
7592
8067
  tableRef.current?.scrollTo(options2);
7593
8068
  },
8069
+ freezeRow: (targets) => {
8070
+ tableRef.current?.freezeRow(targets);
8071
+ },
8072
+ freezeRows: (targets) => {
8073
+ tableRef.current?.freezeRows(targets);
8074
+ },
8075
+ unfreezeRow: (targets) => {
8076
+ tableRef.current?.unfreezeRow(targets);
8077
+ },
8078
+ unfreezeRows: (targets) => {
8079
+ tableRef.current?.unfreezeRows(targets);
8080
+ },
8081
+ getFrozenRows: () => tableRef.current?.getFrozenRows() ?? [],
7594
8082
  getDebugSnapshot: () => tableRef.current?.getDebugSnapshot() ?? null,
7595
8083
  resetSorter: () => {
7596
8084
  tableRef.current?.resetSorter();
@@ -7755,6 +8243,18 @@ function ReactListTableInner(props, ref) {
7755
8243
  ]
7756
8244
  }
7757
8245
  ),
8246
+ paginationDialogSnapshot ? /* @__PURE__ */ jsx(
8247
+ ReactListTablePaginationConfigDialog,
8248
+ {
8249
+ snapshot: paginationDialogSnapshot,
8250
+ showTotal: pagination ? pagination.showTotal : void 0,
8251
+ onConfirm: (value, cache) => tableRef.current?.setPaginationConfig(value, cache) ?? {
8252
+ ok: false,
8253
+ errors: { table: "\u8868\u683C\u5C1A\u672A\u6302\u8F7D" }
8254
+ },
8255
+ onClose: closePaginationConfigRequest
8256
+ }
8257
+ ) : null,
7758
8258
  tooltipRequest ? createPortal(
7759
8259
  /* @__PURE__ */ jsx(ReactTooltip, { request: tooltipRequest }),
7760
8260
  portalContainer