@taicode/common-web 3.3.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/badge.d.ts +7 -6
- package/output/components/badge.d.ts.map +1 -1
- package/output/components/badge.js +20 -12
- package/output/components/button.d.ts +8 -8
- package/output/components/button.d.ts.map +1 -1
- package/output/components/button.js +25 -21
- 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 +25 -20
- 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/drawer.d.ts +14 -0
- package/output/components/drawer.d.ts.map +1 -0
- package/output/components/drawer.js +56 -0
- 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.d.ts +3 -2
- package/output/components/input.d.ts.map +1 -1
- package/output/components/input.js +6 -6
- package/output/components/item.d.ts +1 -1
- package/output/components/separator.d.ts +4 -5
- package/output/components/separator.d.ts.map +1 -1
- package/output/components/separator.js +7 -6
- 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 +4 -3
- 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/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/package.json +4 -5
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useContext } from 'react';
|
|
15
|
+
import {} from 'class-variance-authority';
|
|
16
|
+
import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui';
|
|
17
|
+
import { mergeClassNames } from '../utils/merge-class-names/index.js';
|
|
18
|
+
import { toggleVariants } from './toggle.js';
|
|
19
|
+
const ToggleGroupContext = React.createContext({
|
|
20
|
+
size: 'default',
|
|
21
|
+
variant: 'default',
|
|
22
|
+
spacing: 0,
|
|
23
|
+
orientation: 'horizontal',
|
|
24
|
+
});
|
|
25
|
+
function ToggleGroup(params) {
|
|
26
|
+
const { className, variant, size, spacing = 0, orientation = 'horizontal', children } = params, props = __rest(params, ["className", "variant", "size", "spacing", "orientation", "children"]);
|
|
27
|
+
return (_jsx(ToggleGroupPrimitive.Root, Object.assign({ "data-slot": "toggle-group", "data-variant": variant, "data-size": size, "data-spacing": spacing, "data-orientation": orientation, style: { '--gap': spacing }, className: mergeClassNames('rounded-md data-[spacing=0]:data-[variant=outline]:shadow-xs group/toggle-group flex w-fit flex-row items-center gap-(--spacing(var(--gap))) data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch', className) }, props, { children: _jsx(ToggleGroupContext.Provider, { value: { variant, size, spacing, orientation }, children: children }) })));
|
|
28
|
+
}
|
|
29
|
+
function ToggleGroupItem(params) {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
const { className, children, variant = 'default', size = 'default' } = params, props = __rest(params, ["className", "children", "variant", "size"]);
|
|
32
|
+
const context = useContext(ToggleGroupContext);
|
|
33
|
+
return (_jsx(ToggleGroupPrimitive.Item, Object.assign({ "data-slot": "toggle-group-item", "data-variant": (_a = context.variant) !== null && _a !== void 0 ? _a : variant, "data-size": (_b = context.size) !== null && _b !== void 0 ? _b : size, "data-spacing": context.spacing, className: mergeClassNames('data-[state=on]:bg-muted group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t', toggleVariants({
|
|
34
|
+
variant: (_c = context.variant) !== null && _c !== void 0 ? _c : variant,
|
|
35
|
+
size: (_d = context.size) !== null && _d !== void 0 ? _d : size,
|
|
36
|
+
}), className) }, props, { children: children })));
|
|
37
|
+
}
|
|
38
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { Toggle as TogglePrimitive } from 'radix-ui';
|
|
4
|
+
declare const toggleVariants: (props?: ({
|
|
5
|
+
variant?: "default" | "outline" | null | undefined;
|
|
6
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
declare function Toggle(params: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): React.JSX.Element;
|
|
9
|
+
export { Toggle, toggleVariants };
|
|
10
|
+
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../source/components/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAIpD,QAAA,MAAM,cAAc;;;8EAmBnB,CAAA;AAED,iBAAS,MAAM,CACb,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,qBAUhG;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { cva } from 'class-variance-authority';
|
|
15
|
+
import { Toggle as TogglePrimitive } from 'radix-ui';
|
|
16
|
+
import { mergeClassNames } from '../utils/merge-class-names/index.js';
|
|
17
|
+
const toggleVariants = cva("hover:text-foreground aria-pressed:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive gap-1 rounded-md text-sm font-medium transition-[color,box-shadow] [&_svg:not([class*='size-'])]:size-4 group/toggle hover:bg-muted inline-flex items-center justify-center whitespace-nowrap outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
18
|
+
variants: {
|
|
19
|
+
variant: {
|
|
20
|
+
default: 'bg-transparent',
|
|
21
|
+
outline: 'border-input hover:bg-muted border bg-transparent shadow-xs',
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
default: 'h-9 min-w-9 px-2',
|
|
25
|
+
sm: 'h-8 min-w-8 px-1.5',
|
|
26
|
+
lg: 'h-10 min-w-10 px-2.5',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
variant: 'default',
|
|
31
|
+
size: 'default',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
function Toggle(params) {
|
|
35
|
+
const { className, variant = 'default', size = 'default' } = params, props = __rest(params, ["className", "variant", "size"]);
|
|
36
|
+
return (_jsx(TogglePrimitive.Root, Object.assign({ "data-slot": "toggle", className: mergeClassNames(toggleVariants({ variant, size, className })) }, props)));
|
|
37
|
+
}
|
|
38
|
+
export { Toggle, toggleVariants };
|
|
@@ -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
|
+
}
|
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": "",
|
|
@@ -14,10 +14,6 @@
|
|
|
14
14
|
"types": "./output/components/index.d.ts",
|
|
15
15
|
"default": "./output/components/index.js"
|
|
16
16
|
},
|
|
17
|
-
"./vite-config": {
|
|
18
|
-
"types": "./output/vite-config/index.d.ts",
|
|
19
|
-
"default": "./output/vite-config/index.js"
|
|
20
|
-
},
|
|
21
17
|
"./features/*": {
|
|
22
18
|
"types": "./output/features/*/index.d.ts",
|
|
23
19
|
"default": "./output/features/*/index.js"
|
|
@@ -81,9 +77,12 @@
|
|
|
81
77
|
"jsoneditor": "^10.4.2",
|
|
82
78
|
"lucide-react": "^0.468.0",
|
|
83
79
|
"radix-ui": "^1.4.3",
|
|
80
|
+
"react-day-picker": "^9.14.0",
|
|
84
81
|
"react-hook-form": "^7.71.2",
|
|
82
|
+
"recharts": "^2.15.4",
|
|
85
83
|
"sonner": "^1.7.4",
|
|
86
84
|
"tailwind-merge": "^3.5.0",
|
|
85
|
+
"vaul": "^1.1.2",
|
|
87
86
|
"web-vitals": "^5.1.0"
|
|
88
87
|
},
|
|
89
88
|
"devDependencies": {
|