@bioturing/components 0.36.2 → 0.37.1
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/components/button/component.d.ts +1 -1
- package/dist/components/button/component.d.ts.map +1 -1
- package/dist/components/button/component.js +42 -35
- package/dist/components/button/component.js.map +1 -1
- package/dist/components/button/style.css +1 -1
- package/dist/components/data-table/component.d.ts.map +1 -1
- package/dist/components/data-table/component.js +76 -71
- package/dist/components/data-table/component.js.map +1 -1
- package/dist/components/data-table/components/TablePagination.d.ts +1 -1
- package/dist/components/data-table/components/TablePagination.d.ts.map +1 -1
- package/dist/components/data-table/components/TablePagination.js +26 -23
- package/dist/components/data-table/components/TablePagination.js.map +1 -1
- package/dist/components/data-table/hooks.d.ts.map +1 -1
- package/dist/components/data-table/hooks.js +82 -82
- package/dist/components/data-table/hooks.js.map +1 -1
- package/dist/components/data-table/style.css +1 -1
- package/dist/components/empty/component.d.ts +0 -2
- package/dist/components/empty/component.d.ts.map +1 -1
- package/dist/components/empty/component.js +14 -35
- package/dist/components/empty/component.js.map +1 -1
- package/dist/components/empty/style.css +1 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +105 -102
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/truncate/component.d.ts +7 -0
- package/dist/components/truncate/component.d.ts.map +1 -1
- package/dist/components/truncate/component.js +57 -48
- package/dist/components/truncate/component.js.map +1 -1
- package/dist/components/truncate/helpers.d.ts +8 -2
- package/dist/components/truncate/helpers.d.ts.map +1 -1
- package/dist/components/truncate/helpers.js +82 -54
- package/dist/components/truncate/helpers.js.map +1 -1
- package/dist/index.js +126 -127
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export interface ButtonProps extends AntdButtonProps {
|
|
|
6
6
|
*/
|
|
7
7
|
negativeMargin?: boolean;
|
|
8
8
|
}
|
|
9
|
-
declare const ButtonInner: ({ negativeMargin, type, size, variant, icon, ...rest }: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const ButtonInner: ({ negativeMargin, type, size, variant, icon, loading, classNames, ...rest }: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare const Button: (props: ButtonProps & {
|
|
11
11
|
ref?: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>;
|
|
12
12
|
}) => ReturnType<typeof ButtonInner>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/button/component.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,IAAI,eAAe,EACpC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/button/component.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,IAAI,eAAe,EACpC,MAAM,gBAAgB,CAAC;AAOxB,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,QAAA,MAAM,WAAW,GACf,6EASG,WAAW,EACd,KAAK,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,4CA2CtD,CAAC;AAEF,eAAO,MAAM,MAAM,EAA8B,CAC/C,KAAK,EAAE,WAAW,GAAG;IACnB,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;CACjE,KACE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -1,46 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
import { forwardRef as
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import f from "antd/es/button";
|
|
4
|
+
import { forwardRef as d } from "react";
|
|
5
|
+
import { CircleNotchIcon as b } from "@bioturing/assets";
|
|
5
6
|
import './style.css';/* empty css */
|
|
6
|
-
import { useCls as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { useCls as g } from "../utils/antdUtils.js";
|
|
8
|
+
import { cn as w } from "../utils/cn.js";
|
|
9
|
+
const N = ({
|
|
10
|
+
negativeMargin: m = !0,
|
|
11
|
+
type: t,
|
|
12
|
+
size: e,
|
|
13
|
+
variant: n,
|
|
14
|
+
icon: i,
|
|
15
|
+
loading: c,
|
|
16
|
+
classNames: p,
|
|
17
|
+
...a
|
|
18
|
+
}, l) => {
|
|
19
|
+
const u = m && (n === "text" || n === "link" || t == "text" || t === "link"), o = g(), s = /* @__PURE__ */ r(
|
|
20
|
+
f,
|
|
21
|
+
{
|
|
22
|
+
ref: l,
|
|
23
|
+
type: t,
|
|
24
|
+
size: e,
|
|
25
|
+
variant: n,
|
|
26
|
+
icon: i,
|
|
27
|
+
loading: c && {
|
|
28
|
+
icon: /* @__PURE__ */ r(b, {})
|
|
29
|
+
},
|
|
30
|
+
className: w(i && o("btn-with-icon")),
|
|
31
|
+
classNames: {
|
|
32
|
+
icon: c ? o("btn-loading-icon") : void 0,
|
|
33
|
+
...p
|
|
34
|
+
},
|
|
35
|
+
...a
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return u ? /* @__PURE__ */ r(
|
|
10
39
|
"span",
|
|
11
40
|
{
|
|
12
|
-
className:
|
|
41
|
+
className: o(
|
|
13
42
|
"btn-wrapper",
|
|
14
43
|
"btn-negative-margin-wrapper",
|
|
15
|
-
"btn-wrapper-" +
|
|
44
|
+
"btn-wrapper-" + e
|
|
16
45
|
),
|
|
17
|
-
children:
|
|
18
|
-
a,
|
|
19
|
-
{
|
|
20
|
-
ref: p,
|
|
21
|
-
type: t,
|
|
22
|
-
size: o,
|
|
23
|
-
variant: n,
|
|
24
|
-
icon: r,
|
|
25
|
-
className: r ? e("btn-with-icon") : "",
|
|
26
|
-
...m
|
|
27
|
-
}
|
|
28
|
-
)
|
|
46
|
+
children: s
|
|
29
47
|
}
|
|
30
|
-
) :
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
ref: p,
|
|
34
|
-
type: t,
|
|
35
|
-
size: o,
|
|
36
|
-
variant: n,
|
|
37
|
-
icon: r,
|
|
38
|
-
className: r ? e("btn-with-icon") : "",
|
|
39
|
-
...m
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}, d = l(w);
|
|
48
|
+
) : s;
|
|
49
|
+
}, v = d(N);
|
|
43
50
|
export {
|
|
44
|
-
|
|
51
|
+
v as Button
|
|
45
52
|
};
|
|
46
53
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/button/component.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n default as AntdButton,\n type ButtonProps as AntdButtonProps,\n} from \"antd/es/button\";\nimport { forwardRef } from \"react\";\n\n// Import component-specific styles\nimport { useCls } from \"../utils\";\nimport \"./style.css\";\n\nexport interface ButtonProps extends AntdButtonProps {\n /**\n * If true, negative margin will be applied to the text and link buttons to make it align with content\n * @default true\n */\n negativeMargin?: boolean;\n}\n\nconst ButtonInner = (\n {
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/button/component.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n default as AntdButton,\n type ButtonProps as AntdButtonProps,\n} from \"antd/es/button\";\nimport { forwardRef } from \"react\";\n\n// Import component-specific styles\nimport { useCls } from \"../utils\";\nimport { cn } from \"../utils\";\nimport { CircleNotchIcon } from \"@bioturing/assets\";\nimport \"./style.css\";\n\nexport interface ButtonProps extends AntdButtonProps {\n /**\n * If true, negative margin will be applied to the text and link buttons to make it align with content\n * @default true\n */\n negativeMargin?: boolean;\n}\n\nconst ButtonInner = (\n {\n negativeMargin = true,\n type,\n size,\n variant,\n icon,\n loading,\n classNames,\n ...rest\n }: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) => {\n const useNegativeMargin =\n negativeMargin &&\n (variant === \"text\" ||\n variant === \"link\" ||\n type == \"text\" ||\n type === \"link\");\n const cls = useCls();\n // const iconNode = loading ? <Spin /> : icon;\n const renderedButton = (\n <AntdButton\n ref={ref}\n type={type}\n size={size}\n variant={variant}\n icon={icon}\n loading={\n loading && {\n icon: <CircleNotchIcon />,\n }\n }\n className={cn(icon && cls(\"btn-with-icon\"))}\n classNames={{\n icon: loading ? cls(\"btn-loading-icon\") : undefined,\n ...classNames,\n }}\n {...rest}\n />\n );\n return useNegativeMargin ? (\n <span\n className={cls(\n \"btn-wrapper\",\n \"btn-negative-margin-wrapper\",\n \"btn-wrapper-\" + size\n )}\n >\n {renderedButton}\n </span>\n ) : (\n renderedButton\n );\n};\n\nexport const Button = forwardRef(ButtonInner) as (\n props: ButtonProps & {\n ref?: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>;\n }\n) => ReturnType<typeof ButtonInner>;\n"],"names":["ButtonInner","negativeMargin","type","size","variant","icon","loading","classNames","rest","ref","useNegativeMargin","cls","useCls","renderedButton","jsx","AntdButton","CircleNotchIcon","cn","Button","forwardRef"],"mappings":";;;;;;;;AAsBA,MAAMA,IAAc,CAClB;AAAA,EACE,gBAAAC,IAAiB;AAAA,EACjB,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,GACAC,MACG;AACH,QAAMC,IACJT,MACCG,MAAY,UACXA,MAAY,UACZF,KAAQ,UACRA,MAAS,SACPS,IAAMC,EAAA,GAENC,IACJ,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,MAAAP;AAAA,MACA,MAAAC;AAAA,MACA,SAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SACEC,KAAW;AAAA,QACT,wBAAOU,GAAA,CAAA,CAAgB;AAAA,MAAA;AAAA,MAG3B,WAAWC,EAAGZ,KAAQM,EAAI,eAAe,CAAC;AAAA,MAC1C,YAAY;AAAA,QACV,MAAML,IAAUK,EAAI,kBAAkB,IAAI;AAAA,QAC1C,GAAGJ;AAAA,MAAA;AAAA,MAEJ,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGR,SAAOE,IACL,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWH;AAAA,QACT;AAAA,QACA;AAAA,QACA,iBAAiBR;AAAA,MAAA;AAAA,MAGlB,UAAAU;AAAA,IAAA;AAAA,EAAA,IAGHA;AAEJ,GAEaK,IAASC,EAAWnB,CAAW;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{span.ds-btn-icon{display:flex;align-items:center}.ds-btn-negative-margin-wrapper{display:inline-flex;flex-shrink:0}.ds-btn-negative-margin-wrapper,.ds-btn-negative-margin-wrapper.ds-btn-wrapper-lg{margin-inline:-1rem}.ds-btn-negative-margin-wrapper.ds-btn-wrapper-sm{margin-inline:-.5rem}.ds-btn-loading:not(.ds-btn-with-icon) .ds-btn-loading-icon{position:absolute}.ds-btn-loading:not(.ds-btn-with-icon)>*:not(.ds-btn-loading-icon){opacity:0}}
|
|
1
|
+
@layer components{span.ds-btn-icon{display:flex;align-items:center}.ds-btn-negative-margin-wrapper{display:inline-flex;flex-shrink:0}.ds-btn-negative-margin-wrapper,.ds-btn-negative-margin-wrapper.ds-btn-wrapper-lg{margin-inline:-1rem}.ds-btn-negative-margin-wrapper.ds-btn-wrapper-sm{margin-inline:-.5rem}.ds-btn-loading-icon svg{animation:spin 1s linear infinite}.ds-btn-loading:not(.ds-btn-with-icon) .ds-btn-loading-icon{position:absolute}.ds-btn-loading:not(.ds-btn-with-icon)>*:not(.ds-btn-loading-icon){opacity:0}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/data-table/component.tsx"],"names":[],"mappings":"AACA,OAAc,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/data-table/component.tsx"],"names":[],"mappings":"AACA,OAAc,EAKZ,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAGjE,OAAO,aAAa,CAAC;AAWrB,QAAA,MAAM,cAAc,GAClB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEhE,OAAO,cAAc,CAAC,UAAU,CAAC,EACjC,KAAK,GAAG,CAAC,YAAY,CAAC,4CA+IvB,CAAC;AAQF,eAAO,MAAM,SAAS,GALpB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,mCAE/B,cAAc,CAAC,UAAU,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAA;CAAE,KAC5D,UAAU,CAAC,OAAO,cAAc,CAEK,CAAC"}
|
|
@@ -1,112 +1,117 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Spin as
|
|
5
|
-
import { useDataTable as
|
|
6
|
-
import { convertSelectionToAntFormat as
|
|
2
|
+
import { jsx as t, jsxs as p } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as y, useRef as h, useState as H, useEffect as N } from "react";
|
|
4
|
+
import { Spin as W } from "../spin/component.js";
|
|
5
|
+
import { useDataTable as P } from "./hooks.js";
|
|
6
|
+
import { convertSelectionToAntFormat as k } from "./utils.js";
|
|
7
7
|
import './style.css';/* empty css */
|
|
8
|
-
import { TableHeader as
|
|
9
|
-
import { TableBody as
|
|
10
|
-
import { TablePagination as
|
|
11
|
-
import { useCls as
|
|
12
|
-
import { clsx as
|
|
13
|
-
const
|
|
8
|
+
import { TableHeader as I } from "./components/TableHeader.js";
|
|
9
|
+
import { TableBody as j } from "./components/TableBody.js";
|
|
10
|
+
import { TablePagination as A } from "./components/TablePagination.js";
|
|
11
|
+
import { useCls as E, useAntdCssVarClassname as F } from "../utils/antdUtils.js";
|
|
12
|
+
import { clsx as u } from "../utils/cn.js";
|
|
13
|
+
const $ = (s, G) => {
|
|
14
14
|
const {
|
|
15
15
|
dataSource: i = [],
|
|
16
|
-
className:
|
|
17
|
-
size:
|
|
18
|
-
variant:
|
|
19
|
-
emptyDescription:
|
|
20
|
-
rowKey:
|
|
21
|
-
} =
|
|
16
|
+
className: b,
|
|
17
|
+
size: g = "large",
|
|
18
|
+
variant: S = "default",
|
|
19
|
+
emptyDescription: w,
|
|
20
|
+
rowKey: c
|
|
21
|
+
} = s, e = E(), v = h(null), {
|
|
22
22
|
table: a,
|
|
23
|
-
isLoading:
|
|
24
|
-
spinProps:
|
|
25
|
-
hasRowSelection:
|
|
26
|
-
hasPagination:
|
|
27
|
-
paginationConfig:
|
|
28
|
-
rowSelectionConfig:
|
|
29
|
-
} =
|
|
30
|
-
if (
|
|
31
|
-
const { selectedRows:
|
|
23
|
+
isLoading: C,
|
|
24
|
+
spinProps: R,
|
|
25
|
+
hasRowSelection: m,
|
|
26
|
+
hasPagination: d,
|
|
27
|
+
paginationConfig: z,
|
|
28
|
+
rowSelectionConfig: n
|
|
29
|
+
} = P(s), T = (l) => {
|
|
30
|
+
if (m && (l.toggleSelected(), n?.onSelect)) {
|
|
31
|
+
const { selectedRows: r } = k(
|
|
32
32
|
a.getState().rowSelection,
|
|
33
33
|
i,
|
|
34
|
-
|
|
34
|
+
c
|
|
35
35
|
);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
!
|
|
39
|
-
|
|
36
|
+
n.onSelect(
|
|
37
|
+
l.original,
|
|
38
|
+
!l.getIsSelected(),
|
|
39
|
+
r,
|
|
40
40
|
new Event("click")
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
}, D = F(), o = h(null), [f, x] = H({
|
|
44
|
+
vertical: !1,
|
|
45
|
+
horizontal: !1
|
|
46
|
+
});
|
|
47
|
+
return N(() => {
|
|
48
|
+
o.current && x({
|
|
49
|
+
vertical: o.current.scrollHeight > o.current.clientHeight,
|
|
50
|
+
horizontal: o.current.scrollWidth > o.current.clientWidth
|
|
51
|
+
});
|
|
52
|
+
}, [i.length]), /* @__PURE__ */ t(
|
|
45
53
|
"div",
|
|
46
54
|
{
|
|
47
|
-
ref:
|
|
48
|
-
className:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
55
|
+
ref: v,
|
|
56
|
+
className: u(
|
|
57
|
+
e("table-wrapper", "data-table"),
|
|
58
|
+
e(`table-${g}`),
|
|
59
|
+
S === "zebra" ? e("table-zebra") : "",
|
|
60
|
+
d ? e("table-has-pagination") : "",
|
|
61
|
+
f.vertical ? e("table-scroll-vertical") : "",
|
|
62
|
+
f.horizontal ? e("table-scroll-horizontal") : "",
|
|
63
|
+
D,
|
|
64
|
+
b
|
|
54
65
|
),
|
|
55
|
-
children: /* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
let
|
|
59
|
-
if (
|
|
60
|
-
|
|
66
|
+
children: /* @__PURE__ */ p(W, { spinning: C, ...R, children: [
|
|
67
|
+
/* @__PURE__ */ t("div", { className: u(e("table")), children: /* @__PURE__ */ t("div", { className: e("table-container"), ref: o, children: /* @__PURE__ */ t("div", { className: e("table-content"), children: /* @__PURE__ */ p("table", { children: [
|
|
68
|
+
/* @__PURE__ */ t("colgroup", { children: a.getHeaderGroups()[0]?.headers.map((l) => {
|
|
69
|
+
let r;
|
|
70
|
+
if (l.id === "select")
|
|
71
|
+
r = n?.columnWidth || 32;
|
|
61
72
|
else
|
|
62
73
|
try {
|
|
63
|
-
|
|
74
|
+
r = `${l.getSize()}px`;
|
|
64
75
|
} catch {
|
|
65
|
-
|
|
76
|
+
r = l.column.columnDef.meta?.width;
|
|
66
77
|
}
|
|
67
|
-
return /* @__PURE__ */
|
|
68
|
-
"col",
|
|
69
|
-
{
|
|
70
|
-
style: { width: l }
|
|
71
|
-
},
|
|
72
|
-
t.id
|
|
73
|
-
);
|
|
78
|
+
return /* @__PURE__ */ t("col", { style: { width: r } }, l.id);
|
|
74
79
|
}) }),
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
|
|
80
|
+
/* @__PURE__ */ t(
|
|
81
|
+
I,
|
|
77
82
|
{
|
|
78
83
|
table: a,
|
|
79
|
-
rowSelectionConfig:
|
|
84
|
+
rowSelectionConfig: n,
|
|
80
85
|
dataSource: i,
|
|
81
|
-
rowKey:
|
|
86
|
+
rowKey: c
|
|
82
87
|
}
|
|
83
88
|
),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
|
|
89
|
+
/* @__PURE__ */ t(
|
|
90
|
+
j,
|
|
86
91
|
{
|
|
87
92
|
table: a,
|
|
88
93
|
dataSource: i,
|
|
89
|
-
emptyDescription:
|
|
90
|
-
hasRowSelection:
|
|
91
|
-
onRowClick:
|
|
92
|
-
rowSelectionConfig:
|
|
93
|
-
rowKey:
|
|
94
|
+
emptyDescription: w,
|
|
95
|
+
hasRowSelection: m,
|
|
96
|
+
onRowClick: T,
|
|
97
|
+
rowSelectionConfig: n,
|
|
98
|
+
rowKey: c
|
|
94
99
|
}
|
|
95
100
|
)
|
|
96
101
|
] }) }) }) }),
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
d && /* @__PURE__ */ t(
|
|
103
|
+
A,
|
|
99
104
|
{
|
|
100
105
|
table: a,
|
|
101
|
-
paginationConfig:
|
|
106
|
+
paginationConfig: z,
|
|
102
107
|
totalCount: a.getPreFilteredRowModel().rows.length
|
|
103
108
|
}
|
|
104
109
|
)
|
|
105
110
|
] })
|
|
106
111
|
}
|
|
107
112
|
);
|
|
108
|
-
},
|
|
113
|
+
}, B = y($), _ = B;
|
|
109
114
|
export {
|
|
110
|
-
|
|
115
|
+
_ as DataTable
|
|
111
116
|
};
|
|
112
117
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/data-table/component.tsx"],"sourcesContent":["\"use client\";\nimport React, {
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/data-table/component.tsx"],"sourcesContent":["\"use client\";\nimport React, {\n forwardRef,\n useEffect,\n useRef,\n useState,\n type Ref,\n} from \"react\";\nimport { type Row } from \"@tanstack/react-table\";\nimport { clsx, useAntdCssVarClassname, useCls } from \"../utils\";\nimport { Spin } from \"../spin/component\";\nimport { TableHeader, TableBody, TablePagination } from \"./components\";\nimport { useDataTable } from \"./hooks\";\nimport { convertSelectionToAntFormat } from \"./utils\";\nimport { type DataTableProps, type DataTableRef } from \"./types\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useToken } from \"../hooks\";\n\n// Extended meta type for column definitions\ninterface ExtendedColumnMeta {\n align?: \"left\" | \"center\" | \"right\";\n width?: string | number;\n fixed?: \"left\" | \"right\" | boolean;\n ellipsis?: boolean;\n}\n\nconst InnerDataTable = <\n RecordType extends Record<string, any> = Record<string, unknown>\n>(\n props: DataTableProps<RecordType>,\n ref: Ref<DataTableRef>\n) => {\n const {\n dataSource = [],\n className,\n size = \"large\",\n variant = \"default\",\n emptyDescription,\n rowKey,\n } = props;\n\n const cls = useCls();\n const tableWrapperRef = useRef<HTMLDivElement>(null);\n\n // Use the custom hook for table logic\n const {\n table,\n isLoading,\n spinProps,\n hasRowSelection,\n hasPagination,\n paginationConfig,\n rowSelectionConfig,\n } = useDataTable(props);\n\n // Handle row click for selection\n const handleRowClick = (row: Row<RecordType>) => {\n if (hasRowSelection) {\n row.toggleSelected();\n if (rowSelectionConfig?.onSelect) {\n const { selectedRowKeys, selectedRows } = convertSelectionToAntFormat(\n table.getState().rowSelection,\n dataSource,\n rowKey\n );\n rowSelectionConfig.onSelect(\n row.original,\n !row.getIsSelected(),\n selectedRows,\n new Event(\"click\")\n );\n }\n }\n };\n\n // cls(\"table-scroll-horizontal\"))\n\n const antdClass = useAntdCssVarClassname();\n\n const tableContainerRef = useRef<HTMLDivElement>(null);\n\n const [hasScroll, setHasScroll] = useState({\n vertical: false,\n horizontal: false,\n });\n\n useEffect(() => {\n if (tableContainerRef.current) {\n setHasScroll({\n vertical:\n tableContainerRef.current.scrollHeight >\n tableContainerRef.current.clientHeight,\n horizontal:\n tableContainerRef.current.scrollWidth >\n tableContainerRef.current.clientWidth,\n });\n }\n }, [dataSource.length]);\n\n return (\n <div\n ref={tableWrapperRef}\n className={clsx(\n cls(\"table-wrapper\", \"data-table\"),\n cls(`table-${size}`),\n variant === \"zebra\" ? cls(\"table-zebra\") : \"\",\n hasPagination ? cls(\"table-has-pagination\") : \"\",\n hasScroll.vertical ? cls(\"table-scroll-vertical\") : \"\",\n hasScroll.horizontal ? cls(\"table-scroll-horizontal\") : \"\",\n antdClass,\n className\n )}\n >\n <Spin spinning={isLoading} {...spinProps}>\n <div className={clsx(cls(\"table\"))}>\n <div className={cls(\"table-container\")} ref={tableContainerRef}>\n <div className={cls(\"table-content\")}>\n <table>\n <colgroup>\n {table.getHeaderGroups()[0]?.headers.map((header) => {\n let columnWidth: string | number | undefined;\n\n if (header.id === \"select\") {\n columnWidth = rowSelectionConfig?.columnWidth || 32;\n } else {\n // Try to get the current size from TanStack, fallback to meta width\n try {\n columnWidth = `${header.getSize()}px`;\n } catch (error) {\n // Fallback to static width from column meta\n columnWidth = (\n header.column.columnDef.meta as ExtendedColumnMeta\n )?.width;\n }\n }\n\n return (\n <col key={header.id} style={{ width: columnWidth }} />\n );\n })}\n </colgroup>\n\n <TableHeader\n table={table}\n rowSelectionConfig={rowSelectionConfig}\n dataSource={dataSource}\n rowKey={rowKey}\n />\n\n <TableBody\n table={table}\n dataSource={dataSource}\n emptyDescription={emptyDescription}\n hasRowSelection={hasRowSelection}\n onRowClick={handleRowClick}\n rowSelectionConfig={rowSelectionConfig}\n rowKey={rowKey}\n />\n </table>\n </div>\n </div>\n </div>\n\n {hasPagination && (\n <TablePagination\n table={table}\n paginationConfig={paginationConfig}\n totalCount={table.getPreFilteredRowModel().rows.length}\n />\n )}\n </Spin>\n </div>\n );\n};\n\nconst InternalDataTable = forwardRef(InnerDataTable) as <\n RecordType extends Record<string, any> = Record<string, unknown>\n>(\n props: DataTableProps<RecordType> & { ref?: Ref<DataTableRef> }\n) => ReturnType<typeof InnerDataTable>;\n\nexport const DataTable = InternalDataTable;\n"],"names":["InnerDataTable","props","ref","dataSource","className","size","variant","emptyDescription","rowKey","cls","useCls","tableWrapperRef","useRef","table","isLoading","spinProps","hasRowSelection","hasPagination","paginationConfig","rowSelectionConfig","useDataTable","handleRowClick","row","selectedRows","convertSelectionToAntFormat","antdClass","useAntdCssVarClassname","tableContainerRef","hasScroll","setHasScroll","useState","useEffect","jsx","clsx","jsxs","Spin","header","columnWidth","TableHeader","TableBody","TablePagination","InternalDataTable","forwardRef","DataTable"],"mappings":";;;;;;;;;;;;AA4BA,MAAMA,IAAiB,CAGrBC,GACAC,MACG;AACH,QAAM;AAAA,IACJ,YAAAC,IAAa,CAAA;AAAA,IACb,WAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SAAAC,IAAU;AAAA,IACV,kBAAAC;AAAA,IACA,QAAAC;AAAA,EAAA,IACEP,GAEEQ,IAAMC,EAAA,GACNC,IAAkBC,EAAuB,IAAI,GAG7C;AAAA,IACJ,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAC;AAAA,EAAA,IACEC,EAAanB,CAAK,GAGhBoB,IAAiB,CAACC,MAAyB;AAC/C,QAAIN,M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@ interface TablePaginationProps<RecordType extends Record<string, any> = Record<s
|
|
|
5
5
|
paginationConfig?: DataTablePaginationConfig;
|
|
6
6
|
totalCount: number;
|
|
7
7
|
}
|
|
8
|
-
export declare const TablePagination: <RecordType extends Record<string, any> = Record<string, any>>({ table, paginationConfig, totalCount }: TablePaginationProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const TablePagination: <RecordType extends Record<string, any> = Record<string, any>>({ table, paginationConfig, totalCount, }: TablePaginationProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=TablePagination.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePagination.d.ts","sourceRoot":"","sources":["../../../../src/components/data-table/components/TablePagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,UAAU,oBAAoB,
|
|
1
|
+
{"version":3,"file":"TablePagination.d.ts","sourceRoot":"","sources":["../../../../src/components/data-table/components/TablePagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,UAAU,oBAAoB,CAC5B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAE5D,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACzB,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAC7C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,GAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,0CAIC,oBAAoB,CAAC,UAAU,CAAC,4CAoClC,CAAC"}
|
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { Pagination as h } from "antd";
|
|
3
|
-
import { useCls as
|
|
4
|
-
import { clsx as
|
|
3
|
+
import { useCls as g } from "../../utils/antdUtils.js";
|
|
4
|
+
import { clsx as m } from "../../utils/cn.js";
|
|
5
5
|
const x = ({
|
|
6
6
|
table: t,
|
|
7
7
|
paginationConfig: o,
|
|
8
8
|
totalCount: n
|
|
9
9
|
}) => {
|
|
10
|
-
const s =
|
|
11
|
-
if (!o) return null;
|
|
10
|
+
const s = g();
|
|
11
|
+
if (!o || !t.getState().pagination) return null;
|
|
12
12
|
const c = t.getState().pagination.pageIndex + 1, a = t.getState().pagination.pageSize;
|
|
13
|
-
return /* @__PURE__ */ i(
|
|
14
|
-
|
|
15
|
-
s("table-pagination-right")
|
|
16
|
-
), children: /* @__PURE__ */ i(
|
|
17
|
-
h,
|
|
13
|
+
return /* @__PURE__ */ i(
|
|
14
|
+
"div",
|
|
18
15
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
className: m(s("table-pagination"), s("table-pagination-right")),
|
|
17
|
+
children: /* @__PURE__ */ i(
|
|
18
|
+
h,
|
|
19
|
+
{
|
|
20
|
+
...o,
|
|
21
|
+
current: c,
|
|
22
|
+
pageSize: a,
|
|
23
|
+
total: n,
|
|
24
|
+
showSizeChanger: o.showSizeChanger !== !1,
|
|
25
|
+
showQuickJumper: o.showQuickJumper || !1,
|
|
26
|
+
showTotal: o.showTotal || ((r, e) => `${e[0]}-${e[1]} of ${r} items`),
|
|
27
|
+
onChange: (r, e) => {
|
|
28
|
+
t.setPageIndex(r - 1), e && e !== a && t.setPageSize(e);
|
|
29
|
+
},
|
|
30
|
+
onShowSizeChange: (r, e) => {
|
|
31
|
+
t.setPageSize(e), t.setPageIndex(0);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
)
|
|
32
35
|
}
|
|
33
|
-
)
|
|
36
|
+
);
|
|
34
37
|
};
|
|
35
38
|
export {
|
|
36
39
|
x as TablePagination
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePagination.js","sources":["../../../../src/components/data-table/components/TablePagination.tsx"],"sourcesContent":["import React from \"react\";\nimport { Pagination } from \"antd\";\nimport { type Table } from \"@tanstack/react-table\";\nimport { clsx, useCls } from \"../../utils\";\nimport { type DataTablePaginationConfig } from \"../types\";\n\ninterface TablePaginationProps
|
|
1
|
+
{"version":3,"file":"TablePagination.js","sources":["../../../../src/components/data-table/components/TablePagination.tsx"],"sourcesContent":["import React from \"react\";\nimport { Pagination } from \"antd\";\nimport { type Table } from \"@tanstack/react-table\";\nimport { clsx, useCls } from \"../../utils\";\nimport { type DataTablePaginationConfig } from \"../types\";\n\ninterface TablePaginationProps<\n RecordType extends Record<string, any> = Record<string, any>\n> {\n table: Table<RecordType>;\n paginationConfig?: DataTablePaginationConfig;\n totalCount: number;\n}\n\nexport const TablePagination = <\n RecordType extends Record<string, any> = Record<string, any>\n>({\n table,\n paginationConfig,\n totalCount,\n}: TablePaginationProps<RecordType>) => {\n const cls = useCls();\n\n if (!paginationConfig || !table.getState().pagination) return null;\n\n const currentPage = table.getState().pagination.pageIndex + 1;\n const pageSize = table.getState().pagination.pageSize;\n\n return (\n <div\n className={clsx(cls(\"table-pagination\"), cls(\"table-pagination-right\"))}\n >\n <Pagination\n {...paginationConfig}\n current={currentPage}\n pageSize={pageSize}\n total={totalCount}\n showSizeChanger={paginationConfig.showSizeChanger !== false}\n showQuickJumper={paginationConfig.showQuickJumper || false}\n showTotal={\n paginationConfig.showTotal ||\n ((total, range) => `${range[0]}-${range[1]} of ${total} items`)\n }\n onChange={(page, newPageSize) => {\n table.setPageIndex(page - 1);\n if (newPageSize && newPageSize !== pageSize) {\n table.setPageSize(newPageSize);\n }\n }}\n onShowSizeChange={(current, size) => {\n table.setPageSize(size);\n table.setPageIndex(0); // Reset to first page when changing page size\n }}\n />\n </div>\n );\n};\n"],"names":["TablePagination","table","paginationConfig","totalCount","cls","useCls","currentPage","pageSize","jsx","clsx","Pagination","total","range","page","newPageSize","current","size"],"mappings":";;;;AAcO,MAAMA,IAAkB,CAE7B;AAAA,EACA,OAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AACF,MAAwC;AACtC,QAAMC,IAAMC,EAAA;AAEZ,MAAI,CAACH,KAAoB,CAACD,EAAM,SAAA,EAAW,WAAY,QAAO;AAE9D,QAAMK,IAAcL,EAAM,SAAA,EAAW,WAAW,YAAY,GACtDM,IAAWN,EAAM,SAAA,EAAW,WAAW;AAE7C,SACE,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAKL,EAAI,kBAAkB,GAAGA,EAAI,wBAAwB,CAAC;AAAA,MAEtE,UAAA,gBAAAI;AAAA,QAACE;AAAA,QAAA;AAAA,UACE,GAAGR;AAAA,UACJ,SAASI;AAAA,UACT,UAAAC;AAAA,UACA,OAAOJ;AAAA,UACP,iBAAiBD,EAAiB,oBAAoB;AAAA,UACtD,iBAAiBA,EAAiB,mBAAmB;AAAA,UACrD,WACEA,EAAiB,cAChB,CAACS,GAAOC,MAAU,GAAGA,EAAM,CAAC,CAAC,IAAIA,EAAM,CAAC,CAAC,OAAOD,CAAK;AAAA,UAExD,UAAU,CAACE,GAAMC,MAAgB;AAC/B,YAAAb,EAAM,aAAaY,IAAO,CAAC,GACvBC,KAAeA,MAAgBP,KACjCN,EAAM,YAAYa,CAAW;AAAA,UAEjC;AAAA,UACA,kBAAkB,CAACC,GAASC,MAAS;AACnC,YAAAf,EAAM,YAAYe,CAAI,GACtBf,EAAM,aAAa,CAAC;AAAA,UACtB;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/components/data-table/hooks.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,SAAS,CAAC;AAOnE;;GAEG;AACH,wBAAgB,YAAY,CAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC;;;;;;;;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/components/data-table/hooks.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,SAAS,CAAC;AAOnE;;GAEG;AACH,wBAAgB,YAAY,CAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC;;;;;;;;EA+LlC"}
|