@hkyhy/marsun-components-core 0.1.82 → 0.1.89

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.
@@ -1,66 +1,65 @@
1
- import { jsx as D, jsxs as I } from "react/jsx-runtime";
2
- import x from "classnames";
3
- import { useRef as N } from "react";
4
- import { COLUMN_RESIZE_MIN_WIDTH as X, COLUMN_RESIZE_MAX_WIDTH as y, clampColumnWidth as P } from "./columnConfigUtils.js";
5
- import L from "./style.module.scss.js";
1
+ import { jsx as C, jsxs as H } from "react/jsx-runtime";
2
+ import I from "classnames";
3
+ import { useRef as D } from "react";
4
+ import { COLUMN_RESIZE_MIN_WIDTH as x, COLUMN_RESIZE_MAX_WIDTH as X, clampColumnWidth as P } from "./columnConfigUtils.js";
5
+ import N from "./style.module.scss.js";
6
6
  function T({
7
- width: r,
8
- minWidth: s = X,
9
- maxWidth: M = y,
7
+ width: o,
8
+ minWidth: a = x,
9
+ maxWidth: L = X,
10
10
  onResizeStart: n,
11
11
  onResize: l,
12
- onResizeStop: u,
13
- onReset: c,
12
+ onResizeStop: s,
13
+ onReset: u,
14
14
  children: i,
15
15
  className: f,
16
- style: e,
17
- ...p
16
+ style: r,
17
+ ...d
18
18
  }) {
19
- const a = N(null), m = N(
20
- typeof r == "number" && Number.isFinite(r) ? r : void 0
19
+ const c = D(null), m = D(
20
+ typeof o == "number" && Number.isFinite(o) ? o : void 0
21
21
  );
22
22
  if (!l)
23
- return /* @__PURE__ */ D("th", { ...p, className: f, style: e, ref: a, children: i });
24
- const W = (o) => {
25
- var E;
26
- o.preventDefault(), o.stopPropagation(), n == null || n();
27
- const g = ((E = a.current) == null ? void 0 : E.offsetWidth) || (typeof r == "number" && Number.isFinite(r) && r > 0 ? r : s), H = o.clientX, d = g;
28
- m.current = d;
23
+ return /* @__PURE__ */ C("th", { ...d, className: f, style: r, ref: c, children: i });
24
+ const M = (e) => {
25
+ var y;
26
+ e.preventDefault(), e.stopPropagation(), n == null || n();
27
+ const _ = ((y = c.current) == null ? void 0 : y.offsetWidth) || (typeof o == "number" && Number.isFinite(o) && o > 0 ? o : a), g = e.clientX, p = _;
28
+ m.current = p;
29
29
  const v = (t) => {
30
- const C = P(d + (t.clientX - H), s, M);
31
- m.current = C, l(C);
30
+ const E = P(p + (t.clientX - g), a, L);
31
+ m.current = E, l(E);
32
32
  }, b = () => {
33
33
  document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", b), document.body.style.cursor = "", document.body.style.userSelect = "";
34
34
  const t = m.current;
35
- typeof t == "number" && (u == null || u(t));
35
+ typeof t == "number" && (s == null || s(t));
36
36
  };
37
37
  document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", v), document.addEventListener("mouseup", b);
38
- }, _ = {
39
- ...e,
40
- position: (e == null ? void 0 : e.position) ?? "relative",
41
- overflow: (e == null ? void 0 : e.overflow) ?? "visible"
38
+ }, W = {
39
+ ...r,
40
+ overflow: (r == null ? void 0 : r.overflow) ?? "visible"
42
41
  };
43
- return /* @__PURE__ */ I(
42
+ return /* @__PURE__ */ H(
44
43
  "th",
45
44
  {
46
- ...p,
47
- ref: a,
48
- className: x(f, L.resizableHeaderCell),
49
- style: _,
45
+ ...d,
46
+ ref: c,
47
+ className: I(f, N.resizableHeaderCell),
48
+ style: W,
50
49
  children: [
51
50
  i,
52
- /* @__PURE__ */ D(
51
+ /* @__PURE__ */ C(
53
52
  "span",
54
53
  {
55
54
  role: "separator",
56
55
  "aria-orientation": "vertical",
57
56
  "aria-label": "拖拽调整列宽,双击重置",
58
57
  title: "拖拽调宽 · 双击重置",
59
- className: L.resizeHandle,
60
- onClick: (o) => o.stopPropagation(),
61
- onMouseDown: W,
62
- onDoubleClick: (o) => {
63
- o.preventDefault(), o.stopPropagation(), c == null || c();
58
+ className: N.resizeHandle,
59
+ onClick: (e) => e.stopPropagation(),
60
+ onMouseDown: M,
61
+ onDoubleClick: (e) => {
62
+ e.preventDefault(), e.stopPropagation(), u == null || u();
64
63
  }
65
64
  }
66
65
  )
@@ -1 +1 @@
1
- {"version":3,"file":"ResizableHeaderCell.js","sources":["../../../src/components/Table/ResizableHeaderCell.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport {\n useRef,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type ThHTMLAttributes,\n} from 'react';\nimport {\n clampColumnWidth,\n COLUMN_RESIZE_MAX_WIDTH,\n COLUMN_RESIZE_MIN_WIDTH,\n} from './columnConfigUtils';\nimport styles from './style.module.scss';\n\nexport type ResizableHeaderCellProps = ThHTMLAttributes<HTMLTableCellElement> & {\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n /** 开始拖拽前调用(用于锁死其它列宽) */\n onResizeStart?: () => void;\n onResize?: (width: number) => void;\n onResizeStop?: (width: number) => void;\n /** 双击把手:清除自定义 width */\n onReset?: () => void;\n children?: ReactNode;\n};\n\n/**\n * antd Table header.cell:表头右缘拖拽调宽;无 onResize 时退化为普通 th。\n */\nexport default function ResizableHeaderCell({\n width,\n minWidth = COLUMN_RESIZE_MIN_WIDTH,\n maxWidth = COLUMN_RESIZE_MAX_WIDTH,\n onResizeStart,\n onResize,\n onResizeStop,\n onReset,\n children,\n className,\n style,\n ...rest\n}: ResizableHeaderCellProps) {\n const thRef = useRef<HTMLTableCellElement>(null);\n const lastWidthRef = useRef<number | undefined>(\n typeof width === 'number' && Number.isFinite(width) ? width : undefined,\n );\n\n if (!onResize) {\n return (\n <th {...rest} className={className} style={style} ref={thRef}>\n {children}\n </th>\n );\n }\n\n const startDrag = (e: ReactMouseEvent<HTMLSpanElement>) => {\n e.preventDefault();\n e.stopPropagation();\n // 先锁兄弟列,再量本列(锁宽可能触发重排,故本列尽量用当前 offsetWidth)\n onResizeStart?.();\n const measured =\n thRef.current?.offsetWidth ||\n (typeof width === 'number' && Number.isFinite(width) && width > 0 ? width : minWidth);\n const startX = e.clientX;\n const startW = measured;\n lastWidthRef.current = startW;\n\n const onMove = (ev: MouseEvent) => {\n const next = clampColumnWidth(startW + (ev.clientX - startX), minWidth, maxWidth);\n lastWidthRef.current = next;\n onResize(next);\n };\n const onUp = () => {\n document.removeEventListener('mousemove', onMove);\n document.removeEventListener('mouseup', onUp);\n document.body.style.cursor = '';\n document.body.style.userSelect = '';\n const finalW = lastWidthRef.current;\n if (typeof finalW === 'number') onResizeStop?.(finalW);\n };\n document.body.style.cursor = 'col-resize';\n document.body.style.userSelect = 'none';\n document.addEventListener('mousemove', onMove);\n document.addEventListener('mouseup', onUp);\n };\n\n // 勿覆盖已有 sticky(固定列表头);无 position 时才补 relative 给把手定位\n const mergedStyle = {\n ...style,\n position: style?.position ?? 'relative',\n overflow: style?.overflow ?? 'visible',\n };\n\n return (\n <th\n {...rest}\n ref={thRef}\n className={classNames(className, styles.resizableHeaderCell)}\n style={mergedStyle}\n >\n {children}\n <span\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label=\"拖拽调整列宽,双击重置\"\n title=\"拖拽调宽 · 双击重置\"\n className={styles.resizeHandle}\n onClick={(e) => e.stopPropagation()}\n onMouseDown={startDrag}\n onDoubleClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n onReset?.();\n }}\n />\n </th>\n );\n}\n"],"names":["ResizableHeaderCell","width","minWidth","COLUMN_RESIZE_MIN_WIDTH","maxWidth","COLUMN_RESIZE_MAX_WIDTH","onResizeStart","onResize","onResizeStop","onReset","children","className","style","rest","thRef","useRef","lastWidthRef","jsx","startDrag","e","measured","_a","startX","startW","onMove","ev","next","clampColumnWidth","onUp","finalW","mergedStyle","jsxs","classNames","styles"],"mappings":";;;;;AA8BA,SAAwBA,EAAoB;AAAA,EAC1C,OAAAC;AAAA,EACA,UAAAC,IAAWC;AAAA,EACX,UAAAC,IAAWC;AAAA,EACX,eAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,GAA6B;AAC3B,QAAMC,IAAQC,EAA6B,IAAI,GACzCC,IAAeD;AAAA,IACnB,OAAOd,KAAU,YAAY,OAAO,SAASA,CAAK,IAAIA,IAAQ;AAAA,EAAA;AAGhE,MAAI,CAACM;AACH,WACE,gBAAAU,EAAC,QAAI,GAAGJ,GAAM,WAAAF,GAAsB,OAAAC,GAAc,KAAKE,GACpD,UAAAJ,GACH;AAIJ,QAAMQ,IAAY,CAACC,MAAwC;;AACzD,IAAAA,EAAE,eAAA,GACFA,EAAE,gBAAA,GAEFb,KAAA,QAAAA;AACA,UAAMc,MACJC,IAAAP,EAAM,YAAN,gBAAAO,EAAe,iBACd,OAAOpB,KAAU,YAAY,OAAO,SAASA,CAAK,KAAKA,IAAQ,IAAIA,IAAQC,IACxEoB,IAASH,EAAE,SACXI,IAASH;AACf,IAAAJ,EAAa,UAAUO;AAEvB,UAAMC,IAAS,CAACC,MAAmB;AACjC,YAAMC,IAAOC,EAAiBJ,KAAUE,EAAG,UAAUH,IAASpB,GAAUE,CAAQ;AAChF,MAAAY,EAAa,UAAUU,GACvBnB,EAASmB,CAAI;AAAA,IACf,GACME,IAAO,MAAM;AACjB,eAAS,oBAAoB,aAAaJ,CAAM,GAChD,SAAS,oBAAoB,WAAWI,CAAI,GAC5C,SAAS,KAAK,MAAM,SAAS,IAC7B,SAAS,KAAK,MAAM,aAAa;AACjC,YAAMC,IAASb,EAAa;AAC5B,MAAI,OAAOa,KAAW,aAAUrB,KAAA,QAAAA,EAAeqB;AAAA,IACjD;AACA,aAAS,KAAK,MAAM,SAAS,cAC7B,SAAS,KAAK,MAAM,aAAa,QACjC,SAAS,iBAAiB,aAAaL,CAAM,GAC7C,SAAS,iBAAiB,WAAWI,CAAI;AAAA,EAC3C,GAGME,IAAc;AAAA,IAClB,GAAGlB;AAAA,IACH,WAAUA,KAAA,gBAAAA,EAAO,aAAY;AAAA,IAC7B,WAAUA,KAAA,gBAAAA,EAAO,aAAY;AAAA,EAAA;AAG/B,SACE,gBAAAmB;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAGlB;AAAA,MACJ,KAAKC;AAAA,MACL,WAAWkB,EAAWrB,GAAWsB,EAAO,mBAAmB;AAAA,MAC3D,OAAOH;AAAA,MAEN,UAAA;AAAA,QAAApB;AAAA,QACD,gBAAAO;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,oBAAiB;AAAA,YACjB,cAAW;AAAA,YACX,OAAM;AAAA,YACN,WAAWgB,EAAO;AAAA,YAClB,SAAS,CAACd,MAAMA,EAAE,gBAAA;AAAA,YAClB,aAAaD;AAAA,YACb,eAAe,CAACC,MAAM;AACpB,cAAAA,EAAE,eAAA,GACFA,EAAE,gBAAA,GACFV,KAAA,QAAAA;AAAA,YACF;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"ResizableHeaderCell.js","sources":["../../../src/components/Table/ResizableHeaderCell.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport {\n useRef,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type ThHTMLAttributes,\n} from 'react';\nimport {\n clampColumnWidth,\n COLUMN_RESIZE_MAX_WIDTH,\n COLUMN_RESIZE_MIN_WIDTH,\n} from './columnConfigUtils';\nimport styles from './style.module.scss';\n\nexport type ResizableHeaderCellProps = ThHTMLAttributes<HTMLTableCellElement> & {\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n /** 开始拖拽前调用(用于锁死其它列宽) */\n onResizeStart?: () => void;\n onResize?: (width: number) => void;\n onResizeStop?: (width: number) => void;\n /** 双击把手:清除自定义 width */\n onReset?: () => void;\n children?: ReactNode;\n};\n\n/**\n * antd Table header.cell:表头右缘拖拽调宽;无 onResize 时退化为普通 th。\n */\nexport default function ResizableHeaderCell({\n width,\n minWidth = COLUMN_RESIZE_MIN_WIDTH,\n maxWidth = COLUMN_RESIZE_MAX_WIDTH,\n onResizeStart,\n onResize,\n onResizeStop,\n onReset,\n children,\n className,\n style,\n ...rest\n}: ResizableHeaderCellProps) {\n const thRef = useRef<HTMLTableCellElement>(null);\n const lastWidthRef = useRef<number | undefined>(\n typeof width === 'number' && Number.isFinite(width) ? width : undefined,\n );\n\n if (!onResize) {\n return (\n <th {...rest} className={className} style={style} ref={thRef}>\n {children}\n </th>\n );\n }\n\n const startDrag = (e: ReactMouseEvent<HTMLSpanElement>) => {\n e.preventDefault();\n e.stopPropagation();\n // 先锁兄弟列,再量本列(锁宽可能触发重排,故本列尽量用当前 offsetWidth)\n onResizeStart?.();\n const measured =\n thRef.current?.offsetWidth ||\n (typeof width === 'number' && Number.isFinite(width) && width > 0 ? width : minWidth);\n const startX = e.clientX;\n const startW = measured;\n lastWidthRef.current = startW;\n\n const onMove = (ev: MouseEvent) => {\n const next = clampColumnWidth(startW + (ev.clientX - startX), minWidth, maxWidth);\n lastWidthRef.current = next;\n onResize(next);\n };\n const onUp = () => {\n document.removeEventListener('mousemove', onMove);\n document.removeEventListener('mouseup', onUp);\n document.body.style.cursor = '';\n document.body.style.userSelect = '';\n const finalW = lastWidthRef.current;\n if (typeof finalW === 'number') onResizeStop?.(finalW);\n };\n document.body.style.cursor = 'col-resize';\n document.body.style.userSelect = 'none';\n document.addEventListener('mousemove', onMove);\n document.addEventListener('mouseup', onUp);\n };\n\n // 勿写 inline position:relative——会覆盖 .ant-table-cell-fix 的 sticky,导致固定列分裂。\n // 普通列的定位上下文由 .resizableHeaderCell 的 CSS :not(.ant-table-cell-fix*) 提供;\n // sticky 自身可作为 absolute 把手的 containing block。\n const mergedStyle = {\n ...style,\n overflow: style?.overflow ?? 'visible',\n };\n\n return (\n <th\n {...rest}\n ref={thRef}\n className={classNames(className, styles.resizableHeaderCell)}\n style={mergedStyle}\n >\n {children}\n <span\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label=\"拖拽调整列宽,双击重置\"\n title=\"拖拽调宽 · 双击重置\"\n className={styles.resizeHandle}\n onClick={(e) => e.stopPropagation()}\n onMouseDown={startDrag}\n onDoubleClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n onReset?.();\n }}\n />\n </th>\n );\n}\n"],"names":["ResizableHeaderCell","width","minWidth","COLUMN_RESIZE_MIN_WIDTH","maxWidth","COLUMN_RESIZE_MAX_WIDTH","onResizeStart","onResize","onResizeStop","onReset","children","className","style","rest","thRef","useRef","lastWidthRef","jsx","startDrag","measured","_a","startX","startW","onMove","ev","next","clampColumnWidth","onUp","finalW","mergedStyle","jsxs","classNames","styles"],"mappings":";;;;;AA8BA,SAAwBA,EAAoB;AAAA,EAC1C,OAAAC;AAAA,EACA,UAAAC,IAAWC;AAAA,EACX,UAAAC,IAAWC;AAAA,EACX,eAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,GAA6B;AAC3B,QAAMC,IAAQC,EAA6B,IAAI,GACzCC,IAAeD;AAAA,IACnB,OAAOd,KAAU,YAAY,OAAO,SAASA,CAAK,IAAIA,IAAQ;AAAA,EAAA;AAGhE,MAAI,CAACM;AACH,WACE,gBAAAU,EAAC,QAAI,GAAGJ,GAAM,WAAAF,GAAsB,OAAAC,GAAc,KAAKE,GACpD,UAAAJ,GACH;AAIJ,QAAMQ,IAAY,CAAC,MAAwC;;AACzD,MAAE,eAAA,GACF,EAAE,gBAAA,GAEFZ,KAAA,QAAAA;AACA,UAAMa,MACJC,IAAAN,EAAM,YAAN,gBAAAM,EAAe,iBACd,OAAOnB,KAAU,YAAY,OAAO,SAASA,CAAK,KAAKA,IAAQ,IAAIA,IAAQC,IACxEmB,IAAS,EAAE,SACXC,IAASH;AACf,IAAAH,EAAa,UAAUM;AAEvB,UAAMC,IAAS,CAACC,MAAmB;AACjC,YAAMC,IAAOC,EAAiBJ,KAAUE,EAAG,UAAUH,IAASnB,GAAUE,CAAQ;AAChF,MAAAY,EAAa,UAAUS,GACvBlB,EAASkB,CAAI;AAAA,IACf,GACME,IAAO,MAAM;AACjB,eAAS,oBAAoB,aAAaJ,CAAM,GAChD,SAAS,oBAAoB,WAAWI,CAAI,GAC5C,SAAS,KAAK,MAAM,SAAS,IAC7B,SAAS,KAAK,MAAM,aAAa;AACjC,YAAMC,IAASZ,EAAa;AAC5B,MAAI,OAAOY,KAAW,aAAUpB,KAAA,QAAAA,EAAeoB;AAAA,IACjD;AACA,aAAS,KAAK,MAAM,SAAS,cAC7B,SAAS,KAAK,MAAM,aAAa,QACjC,SAAS,iBAAiB,aAAaL,CAAM,GAC7C,SAAS,iBAAiB,WAAWI,CAAI;AAAA,EAC3C,GAKME,IAAc;AAAA,IAClB,GAAGjB;AAAA,IACH,WAAUA,KAAA,gBAAAA,EAAO,aAAY;AAAA,EAAA;AAG/B,SACE,gBAAAkB;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAGjB;AAAA,MACJ,KAAKC;AAAA,MACL,WAAWiB,EAAWpB,GAAWqB,EAAO,mBAAmB;AAAA,MAC3D,OAAOH;AAAA,MAEN,UAAA;AAAA,QAAAnB;AAAA,QACD,gBAAAO;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,oBAAiB;AAAA,YACjB,cAAW;AAAA,YACX,OAAM;AAAA,YACN,WAAWe,EAAO;AAAA,YAClB,SAAS,CAAC,MAAM,EAAE,gBAAA;AAAA,YAClB,aAAad;AAAA,YACb,eAAe,CAAC,MAAM;AACpB,gBAAE,eAAA,GACF,EAAE,gBAAA,GACFT,KAAA,QAAAA;AAAA,YACF;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -5,93 +5,92 @@ import { forwardRef as Pe, useImperativeHandle as Ie, useMemo as x, useRef as yt
5
5
  import { flushSync as Ee } from "react-dom";
6
6
  import kt from "./columnConfig.module.scss.js";
7
7
  import { ColumnConfigTrigger as Te } from "./ColumnConfigPanel.js";
8
- import { COLUMN_RESIZE_MAX_WIDTH as Ae, COLUMN_RESIZE_MIN_WIDTH as Ne, columnsLeafPathSignature as Fe, applyColumnConfig as je, applyLeafWidthOverrides as Mt, columnsToPanelItems as ke, copyColumnWidths as Me, columnsToConfig as Bt, clampColumnWidth as St, setColumnWidthAtPath as Be, clearColumnWidthAtPath as De, hideColumnAtPath as Ue, configHasLeafWidths as $e, insertBeforeFixedRight as Ge, FLEX_SPACER_COL_KEY as qe, COLUMN_CONFIG_COL_KEY as Xe, isInternalColumnKey as Wt, isFixedColumn as Ze, shortChildId as $t } from "./columnConfigUtils.js";
9
- import Ye from "./ResizableHeaderCell.js";
8
+ import { COLUMN_RESIZE_MAX_WIDTH as Ae, COLUMN_RESIZE_MIN_WIDTH as Ne, columnsLeafPathSignature as Fe, applyColumnConfig as je, applyLeafWidthOverrides as Mt, columnsToPanelItems as ke, copyColumnWidths as Me, columnsToConfig as Bt, clampColumnWidth as St, setColumnWidthAtPath as Be, clearColumnWidthAtPath as De, hideColumnAtPath as Ue, configHasLeafWidths as $e, insertBeforeFixedRight as Ge, FLEX_SPACER_COL_KEY as qe, COLUMN_CONFIG_COL_KEY as Xe, isInternalColumnKey as Wt, shortChildId as $t } from "./columnConfigUtils.js";
9
+ import { isFixedColumn as On } from "./columnConfigUtils.js";
10
+ import Ze from "./ResizableHeaderCell.js";
10
11
  import p from "./style.module.scss.js";
11
- import { emptyTablePrefs as Je } from "./tablePrefsTypes.js";
12
- import { normalizeHiddenRowKeys as Ct, mergeTablePrefs as lt, applyHiddenRows as Qe } from "./tablePrefsUtils.js";
13
- import { parseTablePrefs as Rn, serializeTablePrefs as bn } from "./tablePrefsUtils.js";
14
- import { useTableFetch as Ve } from "./useTableFetch.js";
15
- import { useMarsunFetch as we } from "../../provider/context.js";
12
+ import { emptyTablePrefs as Ye } from "./tablePrefsTypes.js";
13
+ import { normalizeHiddenRowKeys as Ct, mergeTablePrefs as lt, applyHiddenRows as Je } from "./tablePrefsUtils.js";
14
+ import { parseTablePrefs as bn, serializeTablePrefs as Ln } from "./tablePrefsUtils.js";
15
+ import { useTableFetch as Qe } from "./useTableFetch.js";
16
+ import { useMarsunFetch as Ve } from "../../provider/context.js";
16
17
  import Dt from "../Empty/Empty.js";
17
18
  import { Eye as Gt } from "../Icons/Eye.js";
18
- const Ke = { x: "max-content" }, G = 40, tn = 64;
19
- function en(l) {
20
- return `共 ${l} 项`;
19
+ const we = { x: "max-content" }, G = 40, Ke = 64;
20
+ function tn(i) {
21
+ return `共 ${i} 项`;
21
22
  }
22
- function qt(l) {
23
+ function qt(i) {
23
24
  var f;
24
- if (!(l != null && l.length)) return 0;
25
- let a = 0;
26
- for (const o of l) {
27
- const s = o.key != null ? String(o.key) : "";
28
- if (s && Wt(s)) continue;
25
+ if (!(i != null && i.length)) return 0;
26
+ let l = 0;
27
+ for (const o of i) {
28
+ const a = o.key != null ? String(o.key) : "";
29
+ if (a && Wt(a)) continue;
29
30
  if ((f = o.children) != null && f.length) {
30
- a += qt(o.children);
31
+ l += qt(o.children);
31
32
  continue;
32
33
  }
33
34
  const c = o.width;
34
- typeof c == "number" && Number.isFinite(c) && c > 0 ? a += c : a += tn;
35
+ typeof c == "number" && Number.isFinite(c) && c > 0 ? l += c : l += Ke;
35
36
  }
36
- return a;
37
+ return l;
37
38
  }
38
- function Xt(l, a) {
39
- return l.key != null && String(l.key) !== "" ? String(l.key) : l.dataIndex != null ? Array.isArray(l.dataIndex) ? l.dataIndex.join(".") : String(l.dataIndex) : `__col_${a}`;
39
+ function Xt(i, l) {
40
+ return i.key != null && String(i.key) !== "" ? String(i.key) : i.dataIndex != null ? Array.isArray(i.dataIndex) ? i.dataIndex.join(".") : String(i.dataIndex) : `__col_${l}`;
40
41
  }
41
- function nn(l, a, f) {
42
- if (typeof f == "function") return String(f(l, a));
42
+ function en(i, l, f) {
43
+ if (typeof f == "function") return String(f(i, l));
43
44
  if (typeof f == "string" && f) {
44
- const o = l[f];
45
+ const o = i[f];
45
46
  if (o != null && o !== "") return String(o);
46
47
  }
47
- return String(a);
48
+ return String(l);
48
49
  }
49
- function Zt(l, a, f, o = []) {
50
- return l.map((s, c) => {
50
+ function Zt(i, l, f, o = []) {
51
+ return i.map((a, c) => {
51
52
  var R;
52
- const _ = Xt(s, c);
53
- if (Wt(_)) return s;
54
- const d = f ? $t(f, _) : _, O = [...o, d], u = s.onHeaderCell;
55
- if ((R = s.children) != null && R.length)
53
+ const _ = Xt(a, c);
54
+ if (Wt(_)) return a;
55
+ const d = f ? $t(f, _) : _, O = [...o, d], u = a.onHeaderCell;
56
+ if ((R = a.children) != null && R.length)
56
57
  return {
57
- ...s,
58
+ ...a,
58
59
  children: Zt(
59
- s.children,
60
- a,
60
+ a.children,
61
+ l,
61
62
  _,
62
63
  O
63
64
  )
64
65
  };
65
- if (Ze(s))
66
- return s;
67
- const q = O.join("/"), P = a.widthByPath[q] ?? (typeof s.width == "number" && Number.isFinite(s.width) ? s.width : void 0);
66
+ const q = O.join("/"), P = l.widthByPath[q] ?? (typeof a.width == "number" && Number.isFinite(a.width) ? a.width : void 0);
68
67
  return {
69
- ...s,
68
+ ...a,
70
69
  onHeaderCell: (W) => ({
71
70
  ...typeof u == "function" ? u(W) : u || {},
72
71
  "data-marsun-col-path": q,
73
72
  width: P,
74
- minWidth: a.minWidth,
75
- maxWidth: a.maxWidth,
76
- onResizeStart: () => a.onResizeStartPath(O),
77
- onResize: (I) => a.onResizePath(O, I),
78
- onResizeStop: (I) => a.onResizeStopPath(O, I),
79
- onReset: () => a.onResetPath(O)
73
+ minWidth: l.minWidth,
74
+ maxWidth: l.maxWidth,
75
+ onResizeStart: () => l.onResizeStartPath(O),
76
+ onResize: (I) => l.onResizePath(O, I),
77
+ onResizeStop: (I) => l.onResizeStopPath(O, I),
78
+ onReset: () => l.onResetPath(O)
80
79
  })
81
80
  };
82
81
  });
83
82
  }
84
- const rn = 6;
85
- function Yt(l, a, f, o = [], s = 0, c) {
83
+ const nn = 6;
84
+ function Yt(i, l, f, o = [], a = 0, c) {
86
85
  let _ = 0;
87
- return l.map((d, O) => {
86
+ return i.map((d, O) => {
88
87
  var g, N;
89
88
  const u = Xt(d, O);
90
89
  if (Wt(u)) return d;
91
90
  const q = f ? $t(f, u) : u, P = [...o, q], R = d.onHeaderCell;
92
91
  let W = c;
93
- s === 0 && (W = (g = d.children) != null && g.length ? _++ : void 0);
94
- const D = W == null ? void 0 : s === 0 ? p.headerDepth0 : s === 1 ? p.headerDepth1 : p.headerDepth2, I = W == null ? void 0 : p[`headerGroup${W % rn}`], U = /* @__PURE__ */ et("span", { className: p.headerTitleWithEye, children: [
92
+ a === 0 && (W = (g = d.children) != null && g.length ? _++ : void 0);
93
+ const D = W == null ? void 0 : a === 0 ? p.headerDepth0 : a === 1 ? p.headerDepth1 : p.headerDepth2, I = W == null ? void 0 : p[`headerGroup${W % nn}`], U = /* @__PURE__ */ et("span", { className: p.headerTitleWithEye, children: [
95
94
  /* @__PURE__ */ y("span", { className: p.headerTitleText, children: d.title }),
96
95
  /* @__PURE__ */ y(Ut, { title: "隐藏此列", children: /* @__PURE__ */ y(
97
96
  "button",
@@ -100,7 +99,7 @@ function Yt(l, a, f, o = [], s = 0, c) {
100
99
  className: p.headerEyeBtn,
101
100
  "aria-label": "隐藏此列",
102
101
  onClick: (F) => {
103
- F.stopPropagation(), a(P);
102
+ F.stopPropagation(), l(P);
104
103
  },
105
104
  children: /* @__PURE__ */ y(Gt, { size: 12 })
106
105
  }
@@ -118,10 +117,10 @@ function Yt(l, a, f, o = [], s = 0, c) {
118
117
  onHeaderCell: b,
119
118
  children: Yt(
120
119
  d.children,
121
- a,
120
+ l,
122
121
  u,
123
122
  P,
124
- s + 1,
123
+ a + 1,
125
124
  W
126
125
  )
127
126
  } : {
@@ -131,12 +130,12 @@ function Yt(l, a, f, o = [], s = 0, c) {
131
130
  };
132
131
  });
133
132
  }
134
- function sn({
135
- className: l,
136
- style: a,
133
+ function rn({
134
+ className: i,
135
+ style: l,
137
136
  scroll: f,
138
137
  pagination: o,
139
- locale: s,
138
+ locale: a,
140
139
  columns: c,
141
140
  dataSource: _,
142
141
  rowKey: d,
@@ -171,7 +170,7 @@ function sn({
171
170
  ...le
172
171
  }, ae) {
173
172
  var Ft;
174
- const ot = we(), {
173
+ const ot = Ve(), {
175
174
  fetchMode: ct,
176
175
  rows: oe,
177
176
  total: ce,
@@ -181,7 +180,7 @@ function sn({
181
180
  pageSize: he,
182
181
  setPage: fe,
183
182
  reload: zt
184
- } = Ve({
183
+ } = Qe({
185
184
  dataSource: _,
186
185
  fetchData: wt,
187
186
  fetchUrl: Kt,
@@ -199,7 +198,7 @@ function sn({
199
198
  const ut = ct ? oe : _, me = !!O || ct && ue, j = q ?? !!u, v = Jt ?? !!u, E = Qt, T = Vt, Y = x(
200
199
  () => ({ minWidth: E, maxWidth: T }),
201
200
  [E, T]
202
- ), rt = yt(c), dt = yt(null), [i, st] = tt(null), [Ht, pe] = tt(!1), [ht, ft] = tt(!j), [Ot, ye] = tt([]), [k, Q] = tt({}), $ = yt(k);
201
+ ), rt = yt(c), dt = yt(null), [s, st] = tt(null), [Ht, pe] = tt(!1), [ht, ft] = tt(!j), [Ot, ye] = tt([]), [k, Q] = tt({}), $ = yt(k);
203
202
  $.current = k, gt(() => {
204
203
  rt.current = c;
205
204
  }, [c]);
@@ -223,7 +222,7 @@ function sn({
223
222
  t || st((n = r == null ? void 0 : r.columns) != null && n.length ? r : null);
224
223
  } else if (P) {
225
224
  const r = await P(u);
226
- t || st(r != null && r.length ? Je(r) : null);
225
+ t || st(r != null && r.length ? Ye(r) : null);
227
226
  }
228
227
  } catch {
229
228
  t || st(null);
@@ -234,7 +233,7 @@ function sn({
234
233
  t = !0;
235
234
  };
236
235
  }, [j, v, u, D, P]);
237
- const A = (Ft = i == null ? void 0 : i.columns) != null && Ft.length ? i.columns : null, M = x(() => N !== void 0 ? Ct(N, g) : Ct(Ot, g), [N, Ot, g]), J = z(
236
+ const A = (Ft = s == null ? void 0 : s.columns) != null && Ft.length ? s.columns : null, M = x(() => N !== void 0 ? Ct(N, g) : Ct(Ot, g), [N, Ot, g]), J = z(
238
237
  (t) => {
239
238
  const e = Ct(t, g);
240
239
  N === void 0 && ye(e), F == null || F(e);
@@ -274,16 +273,16 @@ function sn({
274
273
  [c]
275
274
  ), Lt = z(
276
275
  async (t) => {
277
- const e = Me(t, i == null ? void 0 : i.columns);
278
- await B(lt(i, { columns: e }));
276
+ const e = Me(t, s == null ? void 0 : s.columns);
277
+ await B(lt(s, { columns: e }));
279
278
  },
280
- [i, B]
279
+ [s, B]
281
280
  ), it = z(() => {
282
281
  var t;
283
- return (t = i == null ? void 0 : i.columns) != null && t.length ? i.columns : Bt(
282
+ return (t = s == null ? void 0 : s.columns) != null && t.length ? s.columns : Bt(
284
283
  rt.current || c
285
284
  );
286
- }, [i, c]), vt = z((t, e) => {
285
+ }, [s, c]), vt = z((t, e) => {
287
286
  const n = t.join("/");
288
287
  Q((r) => {
289
288
  const h = { ...r, [n]: e };
@@ -319,9 +318,9 @@ function sn({
319
318
  let H = it();
320
319
  for (const [m, C] of Object.entries(S))
321
320
  H = Be(H, m.split("/"), C, Y);
322
- await B(lt(i, { columns: H }));
321
+ await B(lt(s, { columns: H }));
323
322
  },
324
- [it, B, i, T, E, Y]
323
+ [it, B, s, T, E, Y]
325
324
  ), It = z(
326
325
  async (t) => {
327
326
  const e = t.join("/");
@@ -331,19 +330,19 @@ function sn({
331
330
  return delete h[e], $.current = h, h;
332
331
  });
333
332
  const n = De(it(), t);
334
- await B(lt(i, { columns: n }));
333
+ await B(lt(s, { columns: n }));
335
334
  },
336
- [it, B, i]
335
+ [it, B, s]
337
336
  ), Et = z(
338
337
  async (t) => {
339
338
  var n;
340
339
  if (!t.length) return;
341
- const e = (n = i == null ? void 0 : i.columns) != null && n.length && i.columns.length ? i.columns : Bt(
340
+ const e = (n = s == null ? void 0 : s.columns) != null && n.length && s.columns.length ? s.columns : Bt(
342
341
  rt.current || c
343
342
  );
344
- await B(lt(i, { columns: Ue(e, t) }));
343
+ await B(lt(s, { columns: Ue(e, t) }));
345
344
  },
346
- [i, c, B]
345
+ [s, c, B]
347
346
  ), Se = z(() => {
348
347
  const t = (X || []).map(String);
349
348
  t.length && J([...M, ...t]);
@@ -439,9 +438,9 @@ function sn({
439
438
  E,
440
439
  T,
441
440
  k
442
- ]), We = x(() => b ? Qe(ut, M, typeof d == "function" || typeof d == "string" ? d : void 0, g) : ut, [b, ut, M, d, g]), xe = o === !1 ? !1 : {
441
+ ]), We = x(() => b ? Je(ut, M, typeof d == "function" || typeof d == "string" ? d : void 0, g) : ut, [b, ut, M, d, g]), xe = o === !1 ? !1 : {
443
442
  showSizeChanger: !0,
444
- showTotal: en,
443
+ showTotal: tn,
445
444
  ...o && typeof o == "object" ? o : {},
446
445
  ...ct ? {
447
446
  current: de,
@@ -452,8 +451,8 @@ function sn({
452
451
  }
453
452
  } : null
454
453
  }, ze = {
455
- ...s,
456
- emptyText: (s == null ? void 0 : s.emptyText) ?? (xt ? /* @__PURE__ */ y(Dt, { iconType: "simple", description: xt.message || "加载失败" }) : /* @__PURE__ */ y(Dt, { iconType: "simple", description: "暂无数据" }))
454
+ ...a,
455
+ emptyText: (a == null ? void 0 : a.emptyText) ?? (xt ? /* @__PURE__ */ y(Dt, { iconType: "simple", description: xt.message || "加载失败" }) : /* @__PURE__ */ y(Dt, { iconType: "simple", description: "暂无数据" }))
457
456
  }, pt = x(() => new Set((g || []).map(String)), [g]), He = b && (X || []).some((t) => {
458
457
  const e = String(t);
459
458
  return e && !pt.has(e);
@@ -478,7 +477,7 @@ function sn({
478
477
  columnWidth: t + 20,
479
478
  renderCell: (e, n, r, h) => {
480
479
  var K;
481
- const H = ((K = L.renderCell) == null ? void 0 : K.call(L, e, n, r, h)) ?? h, m = nn(n, r, d), C = pt.has(m);
480
+ const H = ((K = L.renderCell) == null ? void 0 : K.call(L, e, n, r, h)) ?? h, m = en(n, r, d), C = pt.has(m);
482
481
  return /* @__PURE__ */ et("span", { className: p.rowSelectWithEye, children: [
483
482
  H,
484
483
  /* @__PURE__ */ y(Ut, { title: C ? "主对标不可隐藏" : "隐藏此行", children: /* @__PURE__ */ y(
@@ -503,7 +502,7 @@ function sn({
503
502
  const e = V ? typeof V.columnWidth == "number" ? V.columnWidth : 48 : 0;
504
503
  return t + e;
505
504
  }, [mt, V]), Re = x(() => {
506
- const t = f === void 0 ? { ...Ke } : { ...f };
505
+ const t = f === void 0 ? { ...we } : { ...f };
507
506
  return w > 0 ? { ...t, x: w } : t;
508
507
  }, [f, w]), be = x(() => {
509
508
  const t = Z == null ? void 0 : Z.header, e = t && "cell" in t ? t.cell : void 0;
@@ -511,7 +510,7 @@ function sn({
511
510
  ...Z,
512
511
  header: {
513
512
  ...t,
514
- cell: (r) => !(typeof r.onResize == "function") && e ? /* @__PURE__ */ y(e, { ...r }) : /* @__PURE__ */ y(Ye, { ...r })
513
+ cell: (r) => !(typeof r.onResize == "function") && e ? /* @__PURE__ */ y(e, { ...r }) : /* @__PURE__ */ y(Ze, { ...r })
515
514
  }
516
515
  } : Z;
517
516
  }, [Z, v]);
@@ -520,9 +519,9 @@ function sn({
520
519
  /* @__PURE__ */ y(
521
520
  _e,
522
521
  {
523
- className: at("marsun-table", p["marsun-table"], l),
522
+ className: at("marsun-table", p["marsun-table"], i),
524
523
  style: {
525
- ...a,
524
+ ...l,
526
525
  ...w > 0 ? { "--marsun-table-scroll-x": `${w}px` } : null
527
526
  },
528
527
  scroll: Re,
@@ -539,14 +538,14 @@ function sn({
539
538
  )
540
539
  ] });
541
540
  }
542
- const zn = Pe(sn);
541
+ const xn = Pe(rn);
543
542
  export {
544
543
  Xe as COLUMN_CONFIG_COL_KEY,
545
544
  Ae as COLUMN_RESIZE_MAX_WIDTH,
546
545
  Ne as COLUMN_RESIZE_MIN_WIDTH,
547
546
  qe as FLEX_SPACER_COL_KEY,
548
547
  je as applyColumnConfig,
549
- Qe as applyHiddenRows,
548
+ Je as applyHiddenRows,
550
549
  Mt as applyLeafWidthOverrides,
551
550
  St as clampColumnWidth,
552
551
  De as clearColumnWidthAtPath,
@@ -554,16 +553,16 @@ export {
554
553
  Bt as columnsToConfig,
555
554
  $e as configHasLeafWidths,
556
555
  Me as copyColumnWidths,
557
- zn as default,
558
- Je as emptyTablePrefs,
556
+ xn as default,
557
+ Ye as emptyTablePrefs,
559
558
  Ue as hideColumnAtPath,
560
559
  Ge as insertBeforeFixedRight,
561
- Ze as isFixedColumn,
560
+ On as isFixedColumn,
562
561
  Wt as isInternalColumnKey,
563
562
  lt as mergeTablePrefs,
564
563
  Ct as normalizeHiddenRowKeys,
565
- Rn as parseTablePrefs,
566
- bn as serializeTablePrefs,
564
+ bn as parseTablePrefs,
565
+ Ln as serializeTablePrefs,
567
566
  Be as setColumnWidthAtPath
568
567
  };
569
568
  //# sourceMappingURL=Table.js.map