@taicode/common-web 3.2.0 → 3.4.0
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/output/components/alert-dialog.js +10 -10
- package/output/components/alert.js +5 -5
- package/output/components/avatar.js +7 -7
- package/output/components/badge.d.ts +7 -6
- package/output/components/badge.d.ts.map +1 -1
- package/output/components/badge.js +21 -13
- package/output/components/button.d.ts +8 -8
- package/output/components/button.d.ts.map +1 -1
- package/output/components/button.js +26 -22
- package/output/components/calendar.d.ts +13 -0
- package/output/components/calendar.d.ts.map +1 -0
- package/output/components/calendar.js +57 -0
- package/output/components/card.d.ts +12 -7
- package/output/components/card.d.ts.map +1 -1
- package/output/components/card.js +26 -21
- package/output/components/chart.d.ts +56 -0
- package/output/components/chart.d.ts.map +1 -0
- package/output/components/chart.js +127 -0
- package/output/components/checkbox.js +2 -2
- package/output/components/command.js +10 -10
- package/output/components/dialog.js +7 -7
- package/output/components/drawer.d.ts +14 -0
- package/output/components/drawer.d.ts.map +1 -0
- package/output/components/drawer.js +56 -0
- package/output/components/dropdown-menu.js +10 -10
- package/output/components/field.js +11 -11
- package/output/components/index.d.ts +6 -0
- package/output/components/index.d.ts.map +1 -1
- package/output/components/index.js +6 -0
- package/output/components/input-group.d.ts +1 -1
- package/output/components/input-group.js +7 -7
- package/output/components/input.d.ts +3 -2
- package/output/components/input.d.ts.map +1 -1
- package/output/components/input.js +7 -7
- package/output/components/item.d.ts +1 -1
- package/output/components/item.js +11 -11
- package/output/components/json-view/index.js +2 -2
- package/output/components/kbd.js +3 -3
- package/output/components/label.js +2 -2
- package/output/components/native-select.js +3 -3
- package/output/components/popover.js +5 -5
- package/output/components/progress.js +2 -2
- package/output/components/radio-group.js +3 -3
- package/output/components/scroll-area.js +3 -3
- package/output/components/select.js +9 -9
- package/output/components/separator.d.ts +4 -5
- package/output/components/separator.d.ts.map +1 -1
- package/output/components/separator.js +8 -7
- package/output/components/sheet.js +7 -7
- package/output/components/sidebar.d.ts +78 -0
- package/output/components/sidebar.d.ts.map +1 -0
- package/output/components/sidebar.js +233 -0
- package/output/components/skeleton.d.ts +2 -2
- package/output/components/skeleton.d.ts.map +1 -1
- package/output/components/skeleton.js +5 -4
- package/output/components/spinner.js +2 -2
- package/output/components/switch.js +2 -2
- package/output/components/table.js +9 -9
- package/output/components/tabs.js +5 -5
- package/output/components/textarea.js +2 -2
- package/output/components/toggle-group.d.ts +12 -0
- package/output/components/toggle-group.d.ts.map +1 -0
- package/output/components/toggle-group.js +38 -0
- package/output/components/toggle.d.ts +10 -0
- package/output/components/toggle.d.ts.map +1 -0
- package/output/components/toggle.js +38 -0
- package/output/components/tooltip.js +2 -2
- package/output/features/confirm-dialog/index.js +2 -2
- package/output/layout/app/index.js +7 -7
- package/output/layout/dashboard/index.js +2 -2
- package/output/layout/empty/index.d.ts +20 -0
- package/output/layout/empty/index.d.ts.map +1 -0
- package/output/layout/empty/index.js +14 -0
- package/output/layout/index.d.ts +4 -0
- package/output/layout/index.d.ts.map +1 -1
- package/output/layout/index.js +4 -0
- package/output/layout/list-actions/index.d.ts +23 -0
- package/output/layout/list-actions/index.d.ts.map +1 -0
- package/output/layout/list-actions/index.js +15 -0
- package/output/layout/page-back-button/index.d.ts +8 -0
- package/output/layout/page-back-button/index.d.ts.map +1 -0
- package/output/layout/page-back-button/index.js +7 -0
- package/output/layout/pagination/index.d.ts +34 -0
- package/output/layout/pagination/index.d.ts.map +1 -0
- package/output/layout/pagination/index.js +75 -0
- package/output/utils/merge-class-names/index.d.ts +3 -0
- package/output/utils/merge-class-names/index.d.ts.map +1 -0
- package/output/utils/{cn → merge-class-names}/index.js +1 -1
- package/output/utils/merge-class-names/index.test.d.ts.map +1 -0
- package/output/utils/merge-class-names/index.test.js +7 -0
- package/package.json +5 -46
- package/output/utils/cn/index.d.ts +0 -3
- package/output/utils/cn/index.d.ts.map +0 -1
- package/output/utils/cn/index.test.d.ts.map +0 -1
- package/output/utils/cn/index.test.js +0 -7
- /package/output/utils/{cn → merge-class-names}/index.test.d.ts +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { mergeClassNames } from '../../utils/merge-class-names/index.js';
|
|
4
4
|
export function AppLayout(props) {
|
|
5
5
|
const { header, footer, mobileNavigation, children, contentClassName } = props;
|
|
6
|
-
return (_jsxs("div", { className: "flex min-h-dvh min-w-0 flex-col bg-background", children: [header, _jsx("main", { className:
|
|
6
|
+
return (_jsxs("div", { className: "flex min-h-dvh min-w-0 flex-col bg-background", children: [header, _jsx("main", { className: mergeClassNames('min-w-0 flex-1', contentClassName), children: children }), footer && _jsx("div", { className: "border-t border-border bg-transparent", children: footer }), mobileNavigation] }));
|
|
7
7
|
}
|
|
8
8
|
export function AppNavigation(props) {
|
|
9
9
|
const { variant = 'standard', brand, navigation, actions, mobileBrand = brand, mobileActions = actions, } = props;
|
|
@@ -16,19 +16,19 @@ export function AppNavigation(props) {
|
|
|
16
16
|
window.addEventListener('scroll', handleScroll, { passive: true });
|
|
17
17
|
return () => window.removeEventListener('scroll', handleScroll);
|
|
18
18
|
}, [variant]);
|
|
19
|
-
return (_jsx("header", { className:
|
|
19
|
+
return (_jsx("header", { className: mergeClassNames('sticky top-0 z-50 transition-all duration-300', variant === 'standard' ? 'border-b border-border/70 bg-background/90 backdrop-blur-xl' : 'py-3 md:py-4'), children: _jsxs("div", { className: mergeClassNames('w-full px-4 sm:px-6 lg:px-8', variant === 'standard' && 'mx-auto max-w-6xl'), children: [_jsxs("nav", { "aria-label": "Global", className: mergeClassNames('hidden items-center justify-between gap-5 transition-all duration-300 lg:flex', variant === 'standard'
|
|
20
20
|
? 'h-16'
|
|
21
|
-
:
|
|
21
|
+
: mergeClassNames('rounded-full border px-6 py-3 shadow-sm backdrop-blur', isScrolled
|
|
22
22
|
? 'border-border/10 bg-background/60 shadow-xl backdrop-blur-2xl'
|
|
23
|
-
: 'border-border/70 bg-background/80')), children: [_jsx("div", { className: "flex h-8 items-center gap-1 lg:flex-1", children: brand }), navigation, _jsx("div", { className: "hidden lg:flex lg:flex-1 lg:items-center lg:justify-end lg:gap-3", children: actions })] }), _jsxs("div", { className:
|
|
23
|
+
: 'border-border/70 bg-background/80')), children: [_jsx("div", { className: "flex h-8 items-center gap-1 lg:flex-1", children: brand }), navigation, _jsx("div", { className: "hidden lg:flex lg:flex-1 lg:items-center lg:justify-end lg:gap-3", children: actions })] }), _jsxs("div", { className: mergeClassNames('flex items-center justify-between gap-4 lg:hidden', variant === 'standard'
|
|
24
24
|
? 'h-14'
|
|
25
25
|
: 'rounded-full border border-border bg-background/80 px-4 py-3 shadow-sm backdrop-blur'), children: [mobileBrand, _jsx("div", { className: "ml-auto flex items-center gap-1", children: mobileActions })] })] }) }));
|
|
26
26
|
}
|
|
27
27
|
export function AppMobileNavigation(props) {
|
|
28
28
|
const { label, children, className } = props;
|
|
29
|
-
return (_jsx("nav", { className: "fixed inset-x-0 bottom-0 z-50 border-t border-border/70 bg-background/90 backdrop-blur-xl lg:hidden", "aria-label": label, children: _jsx("div", { className:
|
|
29
|
+
return (_jsx("nav", { className: "fixed inset-x-0 bottom-0 z-50 border-t border-border/70 bg-background/90 backdrop-blur-xl lg:hidden", "aria-label": label, children: _jsx("div", { className: mergeClassNames('mx-auto grid max-w-lg grid-cols-4 px-2 pb-[max(0.375rem,env(safe-area-inset-bottom))] pt-1.5', className), children: children }) }));
|
|
30
30
|
}
|
|
31
31
|
export function AppContent(props) {
|
|
32
32
|
const { title, description, back, toolbar, children, className } = props;
|
|
33
|
-
return (_jsxs("div", { className:
|
|
33
|
+
return (_jsxs("div", { className: mergeClassNames('mx-auto w-full max-w-6xl min-w-0 px-4 py-6 sm:px-6 md:py-10 lg:px-8', className), children: [(back || title || description || toolbar) && (_jsxs("div", { className: "mb-8 space-y-3 border-b pb-5", children: [back, _jsxs("div", { className: "flex min-w-0 items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [title && _jsx("h1", { className: "text-2xl font-semibold md:text-3xl", children: title }), description && _jsx("p", { className: "mt-1 text-sm text-muted-foreground md:text-base", children: description })] }), toolbar && _jsx("div", { className: "flex min-h-9 shrink-0 items-center gap-2", children: toolbar })] })] })), children] }));
|
|
34
34
|
}
|
|
@@ -12,14 +12,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import { ArrowLeftIcon, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, RefreshCwIcon, RotateCcwIcon, SearchIcon } from 'lucide-react';
|
|
14
14
|
import { Button } from '../../components/button.js';
|
|
15
|
-
import {
|
|
15
|
+
import { mergeClassNames } from '../../utils/merge-class-names/index.js';
|
|
16
16
|
export function DashboardLayout(props) {
|
|
17
17
|
const { sidebar, header, children } = props;
|
|
18
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 }) })] })] }));
|
|
19
19
|
}
|
|
20
20
|
export function DashboardMain(props) {
|
|
21
21
|
const { className } = props, rest = __rest(props, ["className"]);
|
|
22
|
-
return _jsx("div", Object.assign({ className:
|
|
22
|
+
return _jsx("div", Object.assign({ className: mergeClassNames('w-full min-w-0 px-4 lg:px-6', className) }, rest));
|
|
23
23
|
}
|
|
24
24
|
export function DashboardContent(props) {
|
|
25
25
|
const { title, description, back, toolbar, filters, children } = props;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
interface EmptyProps {
|
|
3
|
+
icon?: React.ReactNode;
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
action?: {
|
|
7
|
+
label: string;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface LoadingStateProps {
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
fullscreen?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function LoadingState(props: LoadingStateProps): React.JSX.Element;
|
|
18
|
+
export declare function Empty(props: EmptyProps): React.JSX.Element;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/layout/empty/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE;QACP,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,IAAI,CAAA;QACnB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;KACvB,CAAA;CACF;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBAqBpD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,qBAsBtC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { mergeClassNames } from '../../utils/merge-class-names/index.js';
|
|
3
|
+
import { Button } from '../../components/button.js';
|
|
4
|
+
import { LoaderCircleIcon, PlusIcon } from 'lucide-react';
|
|
5
|
+
export function LoadingState(props) {
|
|
6
|
+
const { title, description, fullscreen = false } = props;
|
|
7
|
+
return (_jsx("div", { className: mergeClassNames(fullscreen
|
|
8
|
+
? 'flex min-h-screen items-center justify-center'
|
|
9
|
+
: 'flex min-h-75 items-center justify-center rounded-lg border border-dashed py-8 md:min-h-100 md:py-12'), role: "status", "aria-live": "polite", "aria-busy": "true", children: _jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [_jsx(LoaderCircleIcon, { className: "size-8 animate-spin text-muted-foreground" }), _jsx("div", { className: "text-sm text-muted-foreground md:text-base", children: title }), description && _jsx("p", { className: "max-w-sm px-4 text-xs text-muted-foreground md:text-sm", children: description })] }) }));
|
|
10
|
+
}
|
|
11
|
+
export function Empty(props) {
|
|
12
|
+
const { icon, title, description, action } = props;
|
|
13
|
+
return (_jsxs("div", { className: "flex min-h-75 flex-col items-center justify-center rounded-lg border border-dashed py-8 md:min-h-100 md:py-12", children: [icon && (_jsx("div", { className: "mb-3 flex size-10 items-center justify-center rounded-full bg-muted md:mb-4 md:size-12", children: _jsx("div", { className: "size-5 text-muted-foreground md:size-6", children: icon }) })), _jsx("h3", { className: "mt-2 text-sm font-semibold md:text-base", children: title }), description && _jsx("p", { className: "mt-1 max-w-sm px-4 text-center text-xs text-muted-foreground md:text-sm", children: description }), action && (_jsx("div", { className: "mt-4 md:mt-6", children: _jsxs(Button, { onClick: action.onClick, size: "sm", children: [action.icon || _jsx(PlusIcon, { className: "size-4" }), action.label] }) }))] }));
|
|
14
|
+
}
|
package/output/layout/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export * from './app/index.js';
|
|
2
2
|
export * from './dashboard/index.js';
|
|
3
|
+
export * from './empty/index.js';
|
|
4
|
+
export * from './list-actions/index.js';
|
|
5
|
+
export * from './page-back-button/index.js';
|
|
6
|
+
export * from './pagination/index.js';
|
|
3
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/layout/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/layout/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA"}
|
package/output/layout/index.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type RefreshButtonProps = {
|
|
2
|
+
onClick: () => void;
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
label?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function RefreshButton(props: RefreshButtonProps): import("react").JSX.Element;
|
|
7
|
+
type ResetButtonProps = {
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function ResetButton(props: ResetButtonProps): import("react").JSX.Element;
|
|
12
|
+
type FilterActionsProps = {
|
|
13
|
+
onApply: () => void;
|
|
14
|
+
onReset: () => void;
|
|
15
|
+
onRefresh?: () => void;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
applyLabel?: string;
|
|
18
|
+
resetLabel?: string;
|
|
19
|
+
refreshLabel?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function FilterActions(props: FilterActionsProps): import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/layout/list-actions/index.tsx"],"names":[],"mappings":"AAIA,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAQtD;AAED,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAQlD;AAED,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAatD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RefreshCwIcon, RotateCcwIcon, SearchIcon } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../components/button.js';
|
|
4
|
+
export function RefreshButton(props) {
|
|
5
|
+
const { onClick, loading = false, label = 'Refresh' } = props;
|
|
6
|
+
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' }) }));
|
|
7
|
+
}
|
|
8
|
+
export function ResetButton(props) {
|
|
9
|
+
const { onClick, label = 'Reset' } = props;
|
|
10
|
+
return (_jsx(Button, { onClick: onClick, variant: "outline", size: "icon", className: "size-9", "aria-label": label, title: label, children: _jsx(RotateCcwIcon, { className: "size-4" }) }));
|
|
11
|
+
}
|
|
12
|
+
export function FilterActions(props) {
|
|
13
|
+
const { onApply, onReset, onRefresh, loading = false, applyLabel = 'Filter', resetLabel = 'Reset', refreshLabel = 'Refresh' } = props;
|
|
14
|
+
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(ResetButton, { onClick: onReset, label: resetLabel }), onRefresh && _jsx(RefreshButton, { onClick: onRefresh, loading: loading, label: refreshLabel })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/layout/page-back-button/index.tsx"],"names":[],"mappings":"AAIA,KAAK,mBAAmB,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BAYxD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowLeftIcon } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../components/button.js';
|
|
4
|
+
export function PageBackButton(props) {
|
|
5
|
+
const { label = 'Back', context, onClick } = props;
|
|
6
|
+
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 })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface PaginationProps {
|
|
2
|
+
/**
|
|
3
|
+
* 当前页码(从1开始)
|
|
4
|
+
*/
|
|
5
|
+
currentPage: number;
|
|
6
|
+
/**
|
|
7
|
+
* 每页数量
|
|
8
|
+
*/
|
|
9
|
+
pageSize: number;
|
|
10
|
+
/**
|
|
11
|
+
* 总数据量
|
|
12
|
+
*/
|
|
13
|
+
total: number;
|
|
14
|
+
/**
|
|
15
|
+
* 页码改变回调
|
|
16
|
+
*/
|
|
17
|
+
onPageChange: (page: number) => void;
|
|
18
|
+
/**
|
|
19
|
+
* 每页数量改变回调(可选)
|
|
20
|
+
*/
|
|
21
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
22
|
+
/**
|
|
23
|
+
* 文案(可选,用于 i18n 覆盖)
|
|
24
|
+
*/
|
|
25
|
+
labels?: {
|
|
26
|
+
showingResults?: (start: number, end: number, total: number) => string;
|
|
27
|
+
previous?: string;
|
|
28
|
+
next?: string;
|
|
29
|
+
pageOf?: (current: number, total: number) => string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare function Pagination(props: PaginationProps): import("react").JSX.Element | null;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/layout/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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../components/button.js';
|
|
4
|
+
export function Pagination(props) {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const { currentPage, pageSize, total, onPageChange, labels } = props;
|
|
7
|
+
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
8
|
+
const getPageNumbers = () => {
|
|
9
|
+
const pages = [];
|
|
10
|
+
const maxVisible = 7;
|
|
11
|
+
if (totalPages <= maxVisible) {
|
|
12
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
13
|
+
pages.push(i);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
if (currentPage <= 4) {
|
|
18
|
+
for (let i = 1; i <= 5; i++) {
|
|
19
|
+
pages.push(i);
|
|
20
|
+
}
|
|
21
|
+
pages.push('...');
|
|
22
|
+
pages.push(totalPages);
|
|
23
|
+
}
|
|
24
|
+
else if (currentPage >= totalPages - 3) {
|
|
25
|
+
pages.push(1);
|
|
26
|
+
pages.push('...');
|
|
27
|
+
for (let i = totalPages - 4; i <= totalPages; i++) {
|
|
28
|
+
pages.push(i);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
pages.push(1);
|
|
33
|
+
pages.push('...');
|
|
34
|
+
for (let i = currentPage - 1; i <= currentPage + 1; i++) {
|
|
35
|
+
pages.push(i);
|
|
36
|
+
}
|
|
37
|
+
pages.push('...');
|
|
38
|
+
pages.push(totalPages);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return pages;
|
|
42
|
+
};
|
|
43
|
+
const pageNumbers = getPageNumbers();
|
|
44
|
+
const handleFirst = () => {
|
|
45
|
+
onPageChange(1);
|
|
46
|
+
};
|
|
47
|
+
const handlePrevious = () => {
|
|
48
|
+
if (currentPage > 1) {
|
|
49
|
+
onPageChange(currentPage - 1);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const handleNext = () => {
|
|
53
|
+
if (currentPage < totalPages) {
|
|
54
|
+
onPageChange(currentPage + 1);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handleLast = () => {
|
|
58
|
+
onPageChange(totalPages);
|
|
59
|
+
};
|
|
60
|
+
const handlePageClick = (page) => {
|
|
61
|
+
if (typeof page === 'number') {
|
|
62
|
+
onPageChange(page);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const startIndex = (currentPage - 1) * pageSize + 1;
|
|
66
|
+
const endIndex = Math.min(currentPage * pageSize, total);
|
|
67
|
+
if (total === 0) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const showingResults = (labels === null || labels === void 0 ? void 0 : labels.showingResults) ? labels.showingResults(startIndex, endIndex, total) : `Showing ${startIndex} to ${endIndex} of ${total} results`;
|
|
71
|
+
const previousLabel = (_a = labels === null || labels === void 0 ? void 0 : labels.previous) !== null && _a !== void 0 ? _a : 'Previous';
|
|
72
|
+
const nextLabel = (_b = labels === null || labels === void 0 ? void 0 : labels.next) !== null && _b !== void 0 ? _b : 'Next';
|
|
73
|
+
const pageOfLabel = (labels === null || labels === void 0 ? void 0 : labels.pageOf) ? labels.pageOf(currentPage, totalPages) : `Page ${currentPage} of ${totalPages}`;
|
|
74
|
+
return (_jsxs("div", { className: "flex items-center justify-between px-4", children: [_jsx("div", { className: "text-muted-foreground hidden flex-1 text-sm lg:flex", children: showingResults }), _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: handlePrevious, disabled: currentPage === 1, children: [_jsx(ChevronLeft, { className: "h-4 w-4" }), previousLabel] }), _jsx("div", { className: "min-w-0 truncate px-1 text-center text-xs font-medium", children: pageOfLabel }), _jsxs(Button, { variant: "outline", size: "sm", className: "shrink-0 px-2", onClick: handleNext, disabled: currentPage === totalPages, children: [nextLabel, _jsx(ChevronRight, { className: "h-4 w-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: handleFirst, disabled: currentPage === 1, children: [_jsx("span", { className: "sr-only", children: "Go to first page" }), _jsx(ChevronsLeft, { className: "h-4 w-4" })] }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: handlePrevious, disabled: currentPage === 1, children: [_jsx("span", { className: "sr-only", children: "Go to previous page" }), _jsx(ChevronLeft, { className: "h-4 w-4" })] }), _jsx("div", { className: "flex items-center gap-1", children: pageNumbers.map((page, index) => typeof page === 'number' ? (_jsx(Button, { variant: page === currentPage ? 'default' : 'outline', className: "size-8 p-0", onClick: () => handlePageClick(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: handleNext, disabled: currentPage === totalPages, children: [_jsx("span", { className: "sr-only", children: "Go to next page" }), _jsx(ChevronRight, { className: "h-4 w-4" })] }), _jsxs(Button, { variant: "outline", className: "size-8 p-0", onClick: handleLast, disabled: currentPage === totalPages, children: [_jsx("span", { className: "sr-only", children: "Go to last page" }), _jsx(ChevronsRight, { className: "h-4 w-4" })] })] })] }));
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/utils/merge-class-names/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,wBAAgB,eAAe,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../source/utils/merge-class-names/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { mergeClassNames } from './index.js';
|
|
3
|
+
describe('mergeClassNames', () => {
|
|
4
|
+
it('merges conditional and conflicting Tailwind classes', () => {
|
|
5
|
+
expect(mergeClassNames('px-2', false && 'text-muted-foreground', 'px-4')).toBe('px-4');
|
|
6
|
+
});
|
|
7
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taicode/common-web",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"author": "Alain",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "",
|
|
@@ -10,54 +10,10 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
"./styles.css": "./styles.css",
|
|
13
|
-
"./
|
|
13
|
+
"./components": {
|
|
14
14
|
"types": "./output/components/index.d.ts",
|
|
15
15
|
"default": "./output/components/index.js"
|
|
16
16
|
},
|
|
17
|
-
"./service": {
|
|
18
|
-
"types": "./output/services/service/index.d.ts",
|
|
19
|
-
"default": "./output/services/service/index.js"
|
|
20
|
-
},
|
|
21
|
-
"./toaster": {
|
|
22
|
-
"types": "./output/components/toaster/index.d.ts",
|
|
23
|
-
"default": "./output/components/toaster/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./loading-button": {
|
|
26
|
-
"types": "./output/components/loading-button/index.d.ts",
|
|
27
|
-
"default": "./output/components/loading-button/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./size-provider": {
|
|
30
|
-
"types": "./output/components/size-provider/index.d.ts",
|
|
31
|
-
"default": "./output/components/size-provider/index.js"
|
|
32
|
-
},
|
|
33
|
-
"./use-loading": {
|
|
34
|
-
"types": "./output/hooks/use-loading/index.d.ts",
|
|
35
|
-
"default": "./output/hooks/use-loading/index.js"
|
|
36
|
-
},
|
|
37
|
-
"./use-observer": {
|
|
38
|
-
"types": "./output/hooks/use-observer/index.d.ts",
|
|
39
|
-
"default": "./output/hooks/use-observer/index.js"
|
|
40
|
-
},
|
|
41
|
-
"./cn": {
|
|
42
|
-
"types": "./output/utils/cn/index.d.ts",
|
|
43
|
-
"default": "./output/utils/cn/index.js"
|
|
44
|
-
},
|
|
45
|
-
"./cache-api": {
|
|
46
|
-
"types": "./output/services/cache-api/index.d.ts",
|
|
47
|
-
"default": "./output/services/cache-api/index.js"
|
|
48
|
-
},
|
|
49
|
-
"./side-cache": {
|
|
50
|
-
"types": "./output/services/side-cache/index.d.ts",
|
|
51
|
-
"default": "./output/services/side-cache/index.js"
|
|
52
|
-
},
|
|
53
|
-
"./signin": {
|
|
54
|
-
"types": "./output/features/signin/index.d.ts",
|
|
55
|
-
"default": "./output/features/signin/index.js"
|
|
56
|
-
},
|
|
57
|
-
"./vite-config": {
|
|
58
|
-
"types": "./output/vite-config/index.d.ts",
|
|
59
|
-
"default": "./output/vite-config/index.js"
|
|
60
|
-
},
|
|
61
17
|
"./features/*": {
|
|
62
18
|
"types": "./output/features/*/index.d.ts",
|
|
63
19
|
"default": "./output/features/*/index.js"
|
|
@@ -121,9 +77,12 @@
|
|
|
121
77
|
"jsoneditor": "^10.4.2",
|
|
122
78
|
"lucide-react": "^0.468.0",
|
|
123
79
|
"radix-ui": "^1.4.3",
|
|
80
|
+
"react-day-picker": "^9.14.0",
|
|
124
81
|
"react-hook-form": "^7.71.2",
|
|
82
|
+
"recharts": "^2.15.4",
|
|
125
83
|
"sonner": "^1.7.4",
|
|
126
84
|
"tailwind-merge": "^3.5.0",
|
|
85
|
+
"vaul": "^1.1.2",
|
|
127
86
|
"web-vitals": "^5.1.0"
|
|
128
87
|
},
|
|
129
88
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/utils/cn/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../source/utils/cn/index.test.ts"],"names":[],"mappings":""}
|
|
File without changes
|