@taicode/common-web 4.0.0-beta.5 → 4.0.0-beta.6

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,4 +1,4 @@
1
- interface PaginationProps {
1
+ export interface PaginationProps {
2
2
  /**
3
3
  * 当前页码(从1开始)
4
4
  */
@@ -15,10 +15,6 @@ interface PaginationProps {
15
15
  * 页码改变回调
16
16
  */
17
17
  onPageChange: (page: number) => void;
18
- /**
19
- * 每页数量改变回调(可选)
20
- */
21
- onPageSizeChange?: (pageSize: number) => void;
22
18
  /**
23
19
  * 文案(可选,用于 i18n 覆盖)
24
20
  */
@@ -30,5 +26,4 @@ interface PaginationProps {
30
26
  };
31
27
  }
32
28
  export declare function Pagination(props: PaginationProps): import("react").JSX.Element | null;
33
- export {};
34
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/pagination/index.tsx"],"names":[],"mappings":"AAIA,UAAU,eAAe;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;QACtE,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;KACpD,CAAA;CACF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,sCAmIhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/pagination/index.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;QACtE,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;KACpD,CAAA;CACF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,sCAmIhD"}
@@ -1,4 +1,6 @@
1
1
  import type { ComponentProps, ReactNode } from 'react';
2
+ export { Pagination as DashboardPagination } from '../../components/pagination/index.js';
3
+ export type { PaginationProps as DashboardPaginationProps } from '../../components/pagination/index.js';
2
4
  export interface DashboardLayoutProps {
3
5
  sidebar?: ReactNode;
4
6
  header?: ReactNode;
@@ -36,44 +38,4 @@ export interface DashboardContentProps {
36
38
  }
37
39
  export declare function DashboardMain(props: ComponentProps<'div'>): import("react").JSX.Element;
38
40
  export declare function DashboardContent(props: DashboardContentProps): import("react").JSX.Element;
39
- export interface DashboardBackButtonProps {
40
- label?: string;
41
- context?: string;
42
- onClick: () => void;
43
- }
44
- export declare function DashboardBackButton(props: DashboardBackButtonProps): import("react").JSX.Element;
45
- export interface DashboardRefreshButtonProps {
46
- onClick: () => void;
47
- loading?: boolean;
48
- label?: string;
49
- }
50
- export declare function DashboardRefreshButton(props: DashboardRefreshButtonProps): import("react").JSX.Element;
51
- export interface DashboardResetButtonProps {
52
- onClick: () => void;
53
- label?: string;
54
- }
55
- export declare function DashboardResetButton(props: DashboardResetButtonProps): import("react").JSX.Element;
56
- export interface DashboardFilterActionsProps {
57
- onApply: () => void;
58
- onReset: () => void;
59
- onRefresh?: () => void;
60
- loading?: boolean;
61
- applyLabel?: string;
62
- resetLabel?: string;
63
- refreshLabel?: string;
64
- }
65
- export declare function DashboardFilterActions(props: DashboardFilterActionsProps): import("react").JSX.Element;
66
- export interface DashboardPaginationProps {
67
- currentPage: number;
68
- pageSize: number;
69
- total: number;
70
- onPageChange: (page: number) => void;
71
- labels?: {
72
- showingResults?: (start: number, end: number, total: number) => string;
73
- previous?: string;
74
- next?: string;
75
- pageOf?: (current: number, total: number) => string;
76
- };
77
- }
78
- export declare function DashboardPagination(props: DashboardPaginationProps): import("react").JSX.Element | null;
79
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/layout/dashboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAOrE,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,+BAc1D;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,SAAS,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,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mBAAmB;IAClC,OAAO,EAAE,SAAS,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BAmBxD;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,SAAS,CAAA;IAChB,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,+BAIzD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,+BA8B5D"}
@@ -10,10 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
- import { ArrowLeftIcon, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, RefreshCwIcon, RotateCcwIcon, SearchIcon } from 'lucide-react';
14
- import { Button } from '../../components/button.js';
15
13
  import { SidebarInset, SidebarProvider } from '../../components/sidebar.js';
16
14
  import { mergeClassNames } from '../../utils/merge-class-names/index.js';
15
+ export { Pagination as DashboardPagination } from '../../components/pagination/index.js';
17
16
  export function DashboardLayout(props) {
18
17
  const { sidebar, header, children } = props;
19
18
  return (_jsxs(_Fragment, { children: [sidebar, _jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [header, _jsx("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: _jsx("div", { className: "@container/main flex min-w-0 flex-1 flex-col gap-2", children: children }) })] })] }));
@@ -38,47 +37,3 @@ export function DashboardContent(props) {
38
37
  const { title, description, back, toolbar, filters, children, antiAutoFill = false } = props;
39
38
  return (_jsxs("div", { className: "flex min-w-0 flex-col gap-4 pb-4 md:gap-5", children: [_jsxs("div", { className: "flex flex-col gap-2.5 border-b px-4 py-3 lg:px-6", children: [back, _jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("h1", { className: "truncate text-base font-semibold leading-6 tracking-tight", children: title }), description && (_jsx("p", { className: "mt-0.5 line-clamp-2 text-[13px] leading-5 text-muted-foreground", children: description }))] }), toolbar && _jsx("div", { className: "flex min-h-8 shrink-0 items-center justify-end gap-2", children: toolbar })] }), filters && _jsx("div", { className: "flex flex-col gap-2", children: filters })] }), _jsx(DashboardMain, { className: "space-y-4 md:space-y-5", children: children }), antiAutoFill && (_jsxs(_Fragment, { children: [_jsx("input", { type: "text", name: "fake-username", autoComplete: "off", tabIndex: -1, style: { position: 'absolute', top: -1000, left: -1000 } }), _jsx("input", { type: "password", name: "fake-password", autoComplete: "new-password", tabIndex: -1, style: { position: 'absolute', top: -1000, left: -1000 } })] }))] }));
40
39
  }
41
- export function DashboardBackButton(props) {
42
- const { label = 'Back', context, onClick } = props;
43
- return (_jsxs("div", { className: "flex min-h-9 min-w-0 items-center gap-2", children: [_jsxs(Button, { variant: "ghost", size: "sm", onClick: onClick, className: "-ml-2 shrink-0 gap-1.5 px-2", children: [_jsx(ArrowLeftIcon, { className: "size-4" }), _jsx("span", { children: label })] }), context && _jsx("span", { className: "truncate text-sm text-muted-foreground", children: context })] }));
44
- }
45
- export function DashboardRefreshButton(props) {
46
- const { onClick, loading = false, label = 'Refresh' } = props;
47
- return _jsx(Button, { variant: "outline", size: "icon", className: "size-9", onClick: onClick, disabled: loading, "aria-label": label, title: label, children: _jsx(RefreshCwIcon, { className: loading ? 'size-4 animate-spin' : 'size-4' }) });
48
- }
49
- export function DashboardResetButton(props) {
50
- const { onClick, label = 'Reset' } = props;
51
- return _jsx(Button, { onClick: onClick, variant: "outline", size: "icon", className: "size-9", "aria-label": label, title: label, children: _jsx(RotateCcwIcon, { className: "size-4" }) });
52
- }
53
- export function DashboardFilterActions(props) {
54
- const { onApply, onReset, onRefresh, loading = false, applyLabel = 'Filter', resetLabel = 'Reset', refreshLabel = 'Refresh' } = props;
55
- return _jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [_jsxs(Button, { onClick: onApply, className: "h-9", children: [_jsx(SearchIcon, { className: "size-4" }), applyLabel] }), _jsx(DashboardResetButton, { onClick: onReset, label: resetLabel }), onRefresh && _jsx(DashboardRefreshButton, { onClick: onRefresh, loading: loading, label: refreshLabel })] });
56
- }
57
- export function DashboardPagination(props) {
58
- var _a, _b, _c, _d, _e, _f;
59
- const { currentPage, pageSize, total, onPageChange, labels } = props;
60
- const totalPages = Math.max(1, Math.ceil(total / pageSize));
61
- const pages = [];
62
- if (totalPages <= 7) {
63
- for (let page = 1; page <= totalPages; page++)
64
- pages.push(page);
65
- }
66
- else if (currentPage <= 4) {
67
- pages.push(1, 2, 3, 4, 5, '...', totalPages);
68
- }
69
- else if (currentPage >= totalPages - 3) {
70
- pages.push(1, '...');
71
- for (let page = totalPages - 4; page <= totalPages; page++)
72
- pages.push(page);
73
- }
74
- else {
75
- pages.push(1, '...', currentPage - 1, currentPage, currentPage + 1, '...', totalPages);
76
- }
77
- if (total === 0)
78
- return null;
79
- const start = (currentPage - 1) * pageSize + 1;
80
- const end = Math.min(currentPage * pageSize, total);
81
- const previous = (_a = labels === null || labels === void 0 ? void 0 : labels.previous) !== null && _a !== void 0 ? _a : 'Previous';
82
- const next = (_b = labels === null || labels === void 0 ? void 0 : labels.next) !== null && _b !== void 0 ? _b : 'Next';
83
- return (_jsxs("div", { className: "flex items-center justify-between px-4", children: [_jsx("div", { className: "hidden flex-1 text-sm text-muted-foreground lg:flex", children: (_d = (_c = labels === null || labels === void 0 ? void 0 : labels.showingResults) === null || _c === void 0 ? void 0 : _c.call(labels, start, end, total)) !== null && _d !== void 0 ? _d : `Showing ${start} to ${end} of ${total} results` }), _jsxs("div", { className: "flex w-full items-center justify-between gap-1 lg:hidden", children: [_jsxs(Button, { variant: "outline", size: "sm", className: "shrink-0 px-2", onClick: () => onPageChange(currentPage - 1), disabled: currentPage === 1, children: [_jsx(ChevronLeft, { className: "size-4" }), previous] }), _jsx("div", { className: "min-w-0 truncate px-1 text-center text-xs font-medium", children: (_f = (_e = labels === null || labels === void 0 ? void 0 : labels.pageOf) === null || _e === void 0 ? void 0 : _e.call(labels, currentPage, totalPages)) !== null && _f !== void 0 ? _f : `Page ${currentPage} of ${totalPages}` }), _jsxs(Button, { variant: "outline", size: "sm", className: "shrink-0 px-2", onClick: () => onPageChange(currentPage + 1), disabled: currentPage === totalPages, children: [next, _jsx(ChevronRight, { className: "size-4" })] })] }), _jsxs("div", { className: "hidden w-full items-center gap-2 lg:flex lg:w-fit", children: [_jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(1), disabled: currentPage === 1, children: [_jsx("span", { className: "sr-only", children: "Go to first page" }), _jsx(ChevronsLeft, { className: "size-4" })] }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(currentPage - 1), disabled: currentPage === 1, children: [_jsx("span", { className: "sr-only", children: "Go to previous page" }), _jsx(ChevronLeft, { className: "size-4" })] }), _jsx("div", { className: "flex items-center gap-1", children: pages.map((page, index) => typeof page === 'number' ? _jsx(Button, { variant: page === currentPage ? 'default' : 'outline', className: "size-8 p-0", onClick: () => onPageChange(page), children: page }, `page-${page}`) : _jsx("span", { className: "flex size-8 items-center justify-center text-muted-foreground", children: page }, `ellipsis-${index}`)) }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(currentPage + 1), disabled: currentPage === totalPages, children: [_jsx("span", { className: "sr-only", children: "Go to next page" }), _jsx(ChevronRight, { className: "size-4" })] }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: () => onPageChange(totalPages), disabled: currentPage === totalPages, children: [_jsx("span", { className: "sr-only", children: "Go to last page" }), _jsx(ChevronsRight, { className: "size-4" })] })] })] }));
84
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taicode/common-web",
3
- "version": "4.0.0-beta.5",
3
+ "version": "4.0.0-beta.6",
4
4
  "author": "Alain",
5
5
  "license": "ISC",
6
6
  "description": "",
@@ -54,7 +54,7 @@
54
54
  "mobx": ">=6",
55
55
  "mobx-react-lite": "^4.1.1",
56
56
  "react": ">=18",
57
- "@taicode/common-base": "^4.0.0-beta.5"
57
+ "@taicode/common-base": "^4.0.0-beta.6"
58
58
  },
59
59
  "dependencies": {
60
60
  "@headlessui/react": "^2.2.9",
@@ -107,7 +107,7 @@
107
107
  "vite-plugin-svgr": "^4.5.0",
108
108
  "vite-tsconfig-paths": "^5.1.4",
109
109
  "vitest": "^4.1.9",
110
- "@taicode/common-base": "^4.0.0-beta.5"
110
+ "@taicode/common-base": "^4.0.0-beta.6"
111
111
  },
112
112
  "scripts": {
113
113
  "test": "vitest",