imean-service-engine-htmx-plugin 2.11.0 → 2.11.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/index.d.mts +31 -15
- package/dist/index.d.ts +31 -15
- package/dist/index.js +101 -46
- package/dist/index.mjs +101 -46
- package/package.json +15 -14
package/dist/index.d.mts
CHANGED
|
@@ -277,6 +277,11 @@ interface ListParams<F = Record<string, any>> {
|
|
|
277
277
|
page?: number;
|
|
278
278
|
/** 每页数量 */
|
|
279
279
|
pageSize?: number;
|
|
280
|
+
/**
|
|
281
|
+
* Cassandra 风格分页游标
|
|
282
|
+
* 用于请求下一页(由上一次响应返回)
|
|
283
|
+
*/
|
|
284
|
+
pageState?: string;
|
|
280
285
|
/** 排序字段 */
|
|
281
286
|
sortBy?: string;
|
|
282
287
|
/** 排序方向 */
|
|
@@ -290,14 +295,19 @@ interface ListParams<F = Record<string, any>> {
|
|
|
290
295
|
interface ListResult<T> {
|
|
291
296
|
/** 数据列表 */
|
|
292
297
|
items: T[];
|
|
293
|
-
/**
|
|
294
|
-
total
|
|
295
|
-
/**
|
|
296
|
-
page
|
|
298
|
+
/** 总数量(传统分页才有) */
|
|
299
|
+
total?: number;
|
|
300
|
+
/** 当前页码(传统分页才有) */
|
|
301
|
+
page?: number;
|
|
297
302
|
/** 每页数量 */
|
|
298
303
|
pageSize: number;
|
|
299
|
-
/**
|
|
300
|
-
totalPages
|
|
304
|
+
/** 总页数(传统分页才有) */
|
|
305
|
+
totalPages?: number;
|
|
306
|
+
/**
|
|
307
|
+
* Cassandra 风格分页游标
|
|
308
|
+
* 用于请求下一页
|
|
309
|
+
*/
|
|
310
|
+
pageState?: string | null;
|
|
301
311
|
}
|
|
302
312
|
/**
|
|
303
313
|
* 用户信息接口
|
|
@@ -942,10 +952,12 @@ interface TableProps<T = any> {
|
|
|
942
952
|
}>;
|
|
943
953
|
/** 分页信息 */
|
|
944
954
|
pagination?: {
|
|
945
|
-
page
|
|
955
|
+
page?: number;
|
|
946
956
|
pageSize: number;
|
|
947
|
-
total
|
|
948
|
-
totalPages
|
|
957
|
+
total?: number;
|
|
958
|
+
totalPages?: number;
|
|
959
|
+
nextPageState?: string | null;
|
|
960
|
+
itemCount?: number;
|
|
949
961
|
baseUrl: string;
|
|
950
962
|
currentParams?: Record<string, string | number | undefined>;
|
|
951
963
|
};
|
|
@@ -975,14 +987,18 @@ declare function Table<T extends {
|
|
|
975
987
|
* 分页组件
|
|
976
988
|
*/
|
|
977
989
|
interface PaginationProps {
|
|
978
|
-
/**
|
|
979
|
-
page
|
|
990
|
+
/** 当前页码(传统分页) */
|
|
991
|
+
page?: number;
|
|
980
992
|
/** 每页数量 */
|
|
981
993
|
pageSize: number;
|
|
982
|
-
/**
|
|
983
|
-
total
|
|
984
|
-
/**
|
|
985
|
-
totalPages
|
|
994
|
+
/** 总记录数(传统分页) */
|
|
995
|
+
total?: number;
|
|
996
|
+
/** 总页数(传统分页) */
|
|
997
|
+
totalPages?: number;
|
|
998
|
+
/** Cassandra 风格分页游标(用于下一页) */
|
|
999
|
+
nextPageState?: string | null;
|
|
1000
|
+
/** 当前页数据数量(游标分页用于展示) */
|
|
1001
|
+
itemCount?: number;
|
|
986
1002
|
/** 基础 URL */
|
|
987
1003
|
baseUrl: string;
|
|
988
1004
|
/** 当前查询参数(用于保留筛选条件等) */
|
package/dist/index.d.ts
CHANGED
|
@@ -277,6 +277,11 @@ interface ListParams<F = Record<string, any>> {
|
|
|
277
277
|
page?: number;
|
|
278
278
|
/** 每页数量 */
|
|
279
279
|
pageSize?: number;
|
|
280
|
+
/**
|
|
281
|
+
* Cassandra 风格分页游标
|
|
282
|
+
* 用于请求下一页(由上一次响应返回)
|
|
283
|
+
*/
|
|
284
|
+
pageState?: string;
|
|
280
285
|
/** 排序字段 */
|
|
281
286
|
sortBy?: string;
|
|
282
287
|
/** 排序方向 */
|
|
@@ -290,14 +295,19 @@ interface ListParams<F = Record<string, any>> {
|
|
|
290
295
|
interface ListResult<T> {
|
|
291
296
|
/** 数据列表 */
|
|
292
297
|
items: T[];
|
|
293
|
-
/**
|
|
294
|
-
total
|
|
295
|
-
/**
|
|
296
|
-
page
|
|
298
|
+
/** 总数量(传统分页才有) */
|
|
299
|
+
total?: number;
|
|
300
|
+
/** 当前页码(传统分页才有) */
|
|
301
|
+
page?: number;
|
|
297
302
|
/** 每页数量 */
|
|
298
303
|
pageSize: number;
|
|
299
|
-
/**
|
|
300
|
-
totalPages
|
|
304
|
+
/** 总页数(传统分页才有) */
|
|
305
|
+
totalPages?: number;
|
|
306
|
+
/**
|
|
307
|
+
* Cassandra 风格分页游标
|
|
308
|
+
* 用于请求下一页
|
|
309
|
+
*/
|
|
310
|
+
pageState?: string | null;
|
|
301
311
|
}
|
|
302
312
|
/**
|
|
303
313
|
* 用户信息接口
|
|
@@ -942,10 +952,12 @@ interface TableProps<T = any> {
|
|
|
942
952
|
}>;
|
|
943
953
|
/** 分页信息 */
|
|
944
954
|
pagination?: {
|
|
945
|
-
page
|
|
955
|
+
page?: number;
|
|
946
956
|
pageSize: number;
|
|
947
|
-
total
|
|
948
|
-
totalPages
|
|
957
|
+
total?: number;
|
|
958
|
+
totalPages?: number;
|
|
959
|
+
nextPageState?: string | null;
|
|
960
|
+
itemCount?: number;
|
|
949
961
|
baseUrl: string;
|
|
950
962
|
currentParams?: Record<string, string | number | undefined>;
|
|
951
963
|
};
|
|
@@ -975,14 +987,18 @@ declare function Table<T extends {
|
|
|
975
987
|
* 分页组件
|
|
976
988
|
*/
|
|
977
989
|
interface PaginationProps {
|
|
978
|
-
/**
|
|
979
|
-
page
|
|
990
|
+
/** 当前页码(传统分页) */
|
|
991
|
+
page?: number;
|
|
980
992
|
/** 每页数量 */
|
|
981
993
|
pageSize: number;
|
|
982
|
-
/**
|
|
983
|
-
total
|
|
984
|
-
/**
|
|
985
|
-
totalPages
|
|
994
|
+
/** 总记录数(传统分页) */
|
|
995
|
+
total?: number;
|
|
996
|
+
/** 总页数(传统分页) */
|
|
997
|
+
totalPages?: number;
|
|
998
|
+
/** Cassandra 风格分页游标(用于下一页) */
|
|
999
|
+
nextPageState?: string | null;
|
|
1000
|
+
/** 当前页数据数量(游标分页用于展示) */
|
|
1001
|
+
itemCount?: number;
|
|
986
1002
|
/** 基础 URL */
|
|
987
1003
|
baseUrl: string;
|
|
988
1004
|
/** 当前查询参数(用于保留筛选条件等) */
|
package/dist/index.js
CHANGED
|
@@ -2409,15 +2409,18 @@ function Pagination(props) {
|
|
|
2409
2409
|
pageSize,
|
|
2410
2410
|
total,
|
|
2411
2411
|
totalPages,
|
|
2412
|
+
nextPageState,
|
|
2413
|
+
itemCount,
|
|
2412
2414
|
baseUrl,
|
|
2413
2415
|
currentParams = {}
|
|
2414
2416
|
} = props;
|
|
2415
|
-
|
|
2417
|
+
const isCursorPagination = totalPages === void 0 && total === void 0;
|
|
2418
|
+
if (!isCursorPagination && (totalPages ?? 0) <= 1) {
|
|
2416
2419
|
return null;
|
|
2417
2420
|
}
|
|
2418
|
-
const start = (page - 1) * pageSize + 1;
|
|
2419
|
-
const end = Math.min(page * pageSize, total);
|
|
2420
|
-
const
|
|
2421
|
+
const start = page && !isCursorPagination ? (page - 1) * pageSize + 1 : void 0;
|
|
2422
|
+
const end = page && total && !isCursorPagination ? Math.min(page * pageSize, total) : void 0;
|
|
2423
|
+
const buildPageUrl = (targetPage) => {
|
|
2421
2424
|
const url = new URL(baseUrl, "http://localhost");
|
|
2422
2425
|
for (const [key, value] of Object.entries(currentParams)) {
|
|
2423
2426
|
if (value !== void 0 && value !== null && value !== "") {
|
|
@@ -2425,47 +2428,89 @@ function Pagination(props) {
|
|
|
2425
2428
|
}
|
|
2426
2429
|
}
|
|
2427
2430
|
url.searchParams.set("page", String(targetPage));
|
|
2431
|
+
url.searchParams.delete("pageState");
|
|
2428
2432
|
return url.pathname + url.search;
|
|
2429
2433
|
};
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
"
|
|
2450
|
-
"
|
|
2451
|
-
"
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
"
|
|
2462
|
-
"
|
|
2463
|
-
"
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2434
|
+
const buildCursorUrl = (pageState) => {
|
|
2435
|
+
const url = new URL(baseUrl, "http://localhost");
|
|
2436
|
+
for (const [key, value] of Object.entries(currentParams)) {
|
|
2437
|
+
if (value !== void 0 && value !== null && value !== "") {
|
|
2438
|
+
url.searchParams.set(key, String(value));
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
url.searchParams.set("pageState", pageState);
|
|
2442
|
+
url.searchParams.delete("page");
|
|
2443
|
+
return url.pathname + url.search;
|
|
2444
|
+
};
|
|
2445
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2446
|
+
"nav",
|
|
2447
|
+
{
|
|
2448
|
+
className: "px-6 py-4 flex items-center justify-between border-t border-gray-200 bg-gray-50",
|
|
2449
|
+
"data-testid": "pagination",
|
|
2450
|
+
"aria-label": "\u5206\u9875\u5BFC\u822A",
|
|
2451
|
+
children: [
|
|
2452
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-700", "data-testid": "pagination-info", children: isCursorPagination ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2453
|
+
"\u672C\u9875",
|
|
2454
|
+
" ",
|
|
2455
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", "data-testid": "pagination-count", children: itemCount ?? 0 }),
|
|
2456
|
+
" ",
|
|
2457
|
+
"\u6761"
|
|
2458
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2459
|
+
"\u663E\u793A",
|
|
2460
|
+
" ",
|
|
2461
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", "data-testid": "pagination-start", children: start }),
|
|
2462
|
+
" ",
|
|
2463
|
+
"\u5230",
|
|
2464
|
+
" ",
|
|
2465
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", "data-testid": "pagination-end", children: end }),
|
|
2466
|
+
" ",
|
|
2467
|
+
"\u6761\uFF0C\u5171",
|
|
2468
|
+
" ",
|
|
2469
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", "data-testid": "pagination-total", children: total }),
|
|
2470
|
+
" ",
|
|
2471
|
+
"\u6761"
|
|
2472
|
+
] }) }),
|
|
2473
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", "data-testid": "pagination-controls", children: [
|
|
2474
|
+
!isCursorPagination && page && totalPages && page > 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2475
|
+
Button,
|
|
2476
|
+
{
|
|
2477
|
+
variant: "secondary",
|
|
2478
|
+
size: "sm",
|
|
2479
|
+
href: buildPageUrl(page - 1),
|
|
2480
|
+
"hx-get": buildPageUrl(page - 1),
|
|
2481
|
+
"data-testid": "pagination-prev",
|
|
2482
|
+
"aria-label": "\u4E0A\u4E00\u9875",
|
|
2483
|
+
children: "\u4E0A\u4E00\u9875"
|
|
2484
|
+
}
|
|
2485
|
+
),
|
|
2486
|
+
!isCursorPagination && page && totalPages && page < totalPages && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2487
|
+
Button,
|
|
2488
|
+
{
|
|
2489
|
+
variant: "secondary",
|
|
2490
|
+
size: "sm",
|
|
2491
|
+
href: buildPageUrl(page + 1),
|
|
2492
|
+
"hx-get": buildPageUrl(page + 1),
|
|
2493
|
+
"data-testid": "pagination-next",
|
|
2494
|
+
"aria-label": "\u4E0B\u4E00\u9875",
|
|
2495
|
+
children: "\u4E0B\u4E00\u9875"
|
|
2496
|
+
}
|
|
2497
|
+
),
|
|
2498
|
+
isCursorPagination && nextPageState ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2499
|
+
Button,
|
|
2500
|
+
{
|
|
2501
|
+
variant: "secondary",
|
|
2502
|
+
size: "sm",
|
|
2503
|
+
href: buildCursorUrl(nextPageState),
|
|
2504
|
+
"hx-get": buildCursorUrl(nextPageState),
|
|
2505
|
+
"data-testid": "pagination-next",
|
|
2506
|
+
"aria-label": "\u4E0B\u4E00\u9875",
|
|
2507
|
+
children: "\u4E0B\u4E00\u9875"
|
|
2508
|
+
}
|
|
2509
|
+
) : null
|
|
2510
|
+
] })
|
|
2511
|
+
]
|
|
2512
|
+
}
|
|
2513
|
+
);
|
|
2469
2514
|
}
|
|
2470
2515
|
var STYLES = {
|
|
2471
2516
|
header: {
|
|
@@ -2759,6 +2804,7 @@ function ListPage(props) {
|
|
|
2759
2804
|
pageSize: params.pageSize,
|
|
2760
2805
|
sortBy: params.sortBy,
|
|
2761
2806
|
sortOrder: params.sortOrder,
|
|
2807
|
+
pageState: params.pageState,
|
|
2762
2808
|
...params.filters
|
|
2763
2809
|
// 包含所有筛选条件
|
|
2764
2810
|
};
|
|
@@ -2803,14 +2849,16 @@ function ListPage(props) {
|
|
|
2803
2849
|
method: action.method,
|
|
2804
2850
|
target: action.target
|
|
2805
2851
|
})) : void 0,
|
|
2806
|
-
pagination: {
|
|
2852
|
+
pagination: result.totalPages !== void 0 || result.pageState !== void 0 ? {
|
|
2807
2853
|
page: result.page,
|
|
2808
2854
|
pageSize: result.pageSize,
|
|
2809
2855
|
total: result.total,
|
|
2810
2856
|
totalPages: result.totalPages,
|
|
2857
|
+
nextPageState: result.pageState,
|
|
2858
|
+
itemCount: result.items.length,
|
|
2811
2859
|
baseUrl: listPath,
|
|
2812
2860
|
currentParams
|
|
2813
|
-
},
|
|
2861
|
+
} : void 0,
|
|
2814
2862
|
tableActions,
|
|
2815
2863
|
actionStyle: "link"
|
|
2816
2864
|
}
|
|
@@ -2821,7 +2869,13 @@ function ListPage(props) {
|
|
|
2821
2869
|
// src/utils/params.ts
|
|
2822
2870
|
function parseListParams(ctx, filterSchema) {
|
|
2823
2871
|
const url = new URL(ctx.req.url);
|
|
2824
|
-
const systemParams = /* @__PURE__ */ new Set([
|
|
2872
|
+
const systemParams = /* @__PURE__ */ new Set([
|
|
2873
|
+
"page",
|
|
2874
|
+
"pageSize",
|
|
2875
|
+
"sortBy",
|
|
2876
|
+
"sortOrder",
|
|
2877
|
+
"pageState"
|
|
2878
|
+
]);
|
|
2825
2879
|
const filters = {};
|
|
2826
2880
|
for (const [key, value] of url.searchParams.entries()) {
|
|
2827
2881
|
if (!systemParams.has(key)) {
|
|
@@ -2854,6 +2908,7 @@ function parseListParams(ctx, filterSchema) {
|
|
|
2854
2908
|
pageSize: parseInt(url.searchParams.get("pageSize") || "10", 10),
|
|
2855
2909
|
sortBy: url.searchParams.get("sortBy") || void 0,
|
|
2856
2910
|
sortOrder: url.searchParams.get("sortOrder") || void 0,
|
|
2911
|
+
pageState: url.searchParams.get("pageState") || void 0,
|
|
2857
2912
|
filters: processedFilters
|
|
2858
2913
|
};
|
|
2859
2914
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2407,15 +2407,18 @@ function Pagination(props) {
|
|
|
2407
2407
|
pageSize,
|
|
2408
2408
|
total,
|
|
2409
2409
|
totalPages,
|
|
2410
|
+
nextPageState,
|
|
2411
|
+
itemCount,
|
|
2410
2412
|
baseUrl,
|
|
2411
2413
|
currentParams = {}
|
|
2412
2414
|
} = props;
|
|
2413
|
-
|
|
2415
|
+
const isCursorPagination = totalPages === void 0 && total === void 0;
|
|
2416
|
+
if (!isCursorPagination && (totalPages ?? 0) <= 1) {
|
|
2414
2417
|
return null;
|
|
2415
2418
|
}
|
|
2416
|
-
const start = (page - 1) * pageSize + 1;
|
|
2417
|
-
const end = Math.min(page * pageSize, total);
|
|
2418
|
-
const
|
|
2419
|
+
const start = page && !isCursorPagination ? (page - 1) * pageSize + 1 : void 0;
|
|
2420
|
+
const end = page && total && !isCursorPagination ? Math.min(page * pageSize, total) : void 0;
|
|
2421
|
+
const buildPageUrl = (targetPage) => {
|
|
2419
2422
|
const url = new URL(baseUrl, "http://localhost");
|
|
2420
2423
|
for (const [key, value] of Object.entries(currentParams)) {
|
|
2421
2424
|
if (value !== void 0 && value !== null && value !== "") {
|
|
@@ -2423,47 +2426,89 @@ function Pagination(props) {
|
|
|
2423
2426
|
}
|
|
2424
2427
|
}
|
|
2425
2428
|
url.searchParams.set("page", String(targetPage));
|
|
2429
|
+
url.searchParams.delete("pageState");
|
|
2426
2430
|
return url.pathname + url.search;
|
|
2427
2431
|
};
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
"
|
|
2448
|
-
"
|
|
2449
|
-
"
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
"
|
|
2460
|
-
"
|
|
2461
|
-
"
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2432
|
+
const buildCursorUrl = (pageState) => {
|
|
2433
|
+
const url = new URL(baseUrl, "http://localhost");
|
|
2434
|
+
for (const [key, value] of Object.entries(currentParams)) {
|
|
2435
|
+
if (value !== void 0 && value !== null && value !== "") {
|
|
2436
|
+
url.searchParams.set(key, String(value));
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
url.searchParams.set("pageState", pageState);
|
|
2440
|
+
url.searchParams.delete("page");
|
|
2441
|
+
return url.pathname + url.search;
|
|
2442
|
+
};
|
|
2443
|
+
return /* @__PURE__ */ jsxs(
|
|
2444
|
+
"nav",
|
|
2445
|
+
{
|
|
2446
|
+
className: "px-6 py-4 flex items-center justify-between border-t border-gray-200 bg-gray-50",
|
|
2447
|
+
"data-testid": "pagination",
|
|
2448
|
+
"aria-label": "\u5206\u9875\u5BFC\u822A",
|
|
2449
|
+
children: [
|
|
2450
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-gray-700", "data-testid": "pagination-info", children: isCursorPagination ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2451
|
+
"\u672C\u9875",
|
|
2452
|
+
" ",
|
|
2453
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", "data-testid": "pagination-count", children: itemCount ?? 0 }),
|
|
2454
|
+
" ",
|
|
2455
|
+
"\u6761"
|
|
2456
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2457
|
+
"\u663E\u793A",
|
|
2458
|
+
" ",
|
|
2459
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", "data-testid": "pagination-start", children: start }),
|
|
2460
|
+
" ",
|
|
2461
|
+
"\u5230",
|
|
2462
|
+
" ",
|
|
2463
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", "data-testid": "pagination-end", children: end }),
|
|
2464
|
+
" ",
|
|
2465
|
+
"\u6761\uFF0C\u5171",
|
|
2466
|
+
" ",
|
|
2467
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", "data-testid": "pagination-total", children: total }),
|
|
2468
|
+
" ",
|
|
2469
|
+
"\u6761"
|
|
2470
|
+
] }) }),
|
|
2471
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", "data-testid": "pagination-controls", children: [
|
|
2472
|
+
!isCursorPagination && page && totalPages && page > 1 && /* @__PURE__ */ jsx(
|
|
2473
|
+
Button,
|
|
2474
|
+
{
|
|
2475
|
+
variant: "secondary",
|
|
2476
|
+
size: "sm",
|
|
2477
|
+
href: buildPageUrl(page - 1),
|
|
2478
|
+
"hx-get": buildPageUrl(page - 1),
|
|
2479
|
+
"data-testid": "pagination-prev",
|
|
2480
|
+
"aria-label": "\u4E0A\u4E00\u9875",
|
|
2481
|
+
children: "\u4E0A\u4E00\u9875"
|
|
2482
|
+
}
|
|
2483
|
+
),
|
|
2484
|
+
!isCursorPagination && page && totalPages && page < totalPages && /* @__PURE__ */ jsx(
|
|
2485
|
+
Button,
|
|
2486
|
+
{
|
|
2487
|
+
variant: "secondary",
|
|
2488
|
+
size: "sm",
|
|
2489
|
+
href: buildPageUrl(page + 1),
|
|
2490
|
+
"hx-get": buildPageUrl(page + 1),
|
|
2491
|
+
"data-testid": "pagination-next",
|
|
2492
|
+
"aria-label": "\u4E0B\u4E00\u9875",
|
|
2493
|
+
children: "\u4E0B\u4E00\u9875"
|
|
2494
|
+
}
|
|
2495
|
+
),
|
|
2496
|
+
isCursorPagination && nextPageState ? /* @__PURE__ */ jsx(
|
|
2497
|
+
Button,
|
|
2498
|
+
{
|
|
2499
|
+
variant: "secondary",
|
|
2500
|
+
size: "sm",
|
|
2501
|
+
href: buildCursorUrl(nextPageState),
|
|
2502
|
+
"hx-get": buildCursorUrl(nextPageState),
|
|
2503
|
+
"data-testid": "pagination-next",
|
|
2504
|
+
"aria-label": "\u4E0B\u4E00\u9875",
|
|
2505
|
+
children: "\u4E0B\u4E00\u9875"
|
|
2506
|
+
}
|
|
2507
|
+
) : null
|
|
2508
|
+
] })
|
|
2509
|
+
]
|
|
2510
|
+
}
|
|
2511
|
+
);
|
|
2467
2512
|
}
|
|
2468
2513
|
var STYLES = {
|
|
2469
2514
|
header: {
|
|
@@ -2757,6 +2802,7 @@ function ListPage(props) {
|
|
|
2757
2802
|
pageSize: params.pageSize,
|
|
2758
2803
|
sortBy: params.sortBy,
|
|
2759
2804
|
sortOrder: params.sortOrder,
|
|
2805
|
+
pageState: params.pageState,
|
|
2760
2806
|
...params.filters
|
|
2761
2807
|
// 包含所有筛选条件
|
|
2762
2808
|
};
|
|
@@ -2801,14 +2847,16 @@ function ListPage(props) {
|
|
|
2801
2847
|
method: action.method,
|
|
2802
2848
|
target: action.target
|
|
2803
2849
|
})) : void 0,
|
|
2804
|
-
pagination: {
|
|
2850
|
+
pagination: result.totalPages !== void 0 || result.pageState !== void 0 ? {
|
|
2805
2851
|
page: result.page,
|
|
2806
2852
|
pageSize: result.pageSize,
|
|
2807
2853
|
total: result.total,
|
|
2808
2854
|
totalPages: result.totalPages,
|
|
2855
|
+
nextPageState: result.pageState,
|
|
2856
|
+
itemCount: result.items.length,
|
|
2809
2857
|
baseUrl: listPath,
|
|
2810
2858
|
currentParams
|
|
2811
|
-
},
|
|
2859
|
+
} : void 0,
|
|
2812
2860
|
tableActions,
|
|
2813
2861
|
actionStyle: "link"
|
|
2814
2862
|
}
|
|
@@ -2819,7 +2867,13 @@ function ListPage(props) {
|
|
|
2819
2867
|
// src/utils/params.ts
|
|
2820
2868
|
function parseListParams(ctx, filterSchema) {
|
|
2821
2869
|
const url = new URL(ctx.req.url);
|
|
2822
|
-
const systemParams = /* @__PURE__ */ new Set([
|
|
2870
|
+
const systemParams = /* @__PURE__ */ new Set([
|
|
2871
|
+
"page",
|
|
2872
|
+
"pageSize",
|
|
2873
|
+
"sortBy",
|
|
2874
|
+
"sortOrder",
|
|
2875
|
+
"pageState"
|
|
2876
|
+
]);
|
|
2823
2877
|
const filters = {};
|
|
2824
2878
|
for (const [key, value] of url.searchParams.entries()) {
|
|
2825
2879
|
if (!systemParams.has(key)) {
|
|
@@ -2852,6 +2906,7 @@ function parseListParams(ctx, filterSchema) {
|
|
|
2852
2906
|
pageSize: parseInt(url.searchParams.get("pageSize") || "10", 10),
|
|
2853
2907
|
sortBy: url.searchParams.get("sortBy") || void 0,
|
|
2854
2908
|
sortOrder: url.searchParams.get("sortOrder") || void 0,
|
|
2909
|
+
pageState: url.searchParams.get("pageState") || void 0,
|
|
2855
2910
|
filters: processedFilters
|
|
2856
2911
|
};
|
|
2857
2912
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imean-service-engine-htmx-plugin",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.1",
|
|
4
4
|
"description": "HtmxAdminPlugin for IMean Service Engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsup",
|
|
9
|
+
"dev": "tsx watch examples-v2/index.ts",
|
|
10
|
+
"test": "vitest --run",
|
|
11
|
+
"test:ui": "vitest --ui",
|
|
12
|
+
"test:coverage": "vitest --run --coverage",
|
|
13
|
+
"test:unit": "vitest --run --project unit",
|
|
14
|
+
"test:e2e": "playwright test",
|
|
15
|
+
"test:e2e:ui": "playwright test --ui",
|
|
16
|
+
"test:e2e:headed": "playwright test --headed",
|
|
17
|
+
"dev:component": "tsx src/component-system/test.ts",
|
|
18
|
+
"prepublishOnly": "npm run build && npm run test"
|
|
19
|
+
},
|
|
7
20
|
"keywords": [
|
|
8
21
|
"microservice",
|
|
9
22
|
"hono",
|
|
@@ -38,17 +51,5 @@
|
|
|
38
51
|
"tsx": "^4.21.0",
|
|
39
52
|
"typescript": "^5.9.3",
|
|
40
53
|
"vitest": "^4.0.15"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"build": "tsup",
|
|
44
|
-
"dev": "tsx watch examples-v2/index.ts",
|
|
45
|
-
"test": "vitest --run",
|
|
46
|
-
"test:ui": "vitest --ui",
|
|
47
|
-
"test:coverage": "vitest --run --coverage",
|
|
48
|
-
"test:unit": "vitest --run --project unit",
|
|
49
|
-
"test:e2e": "playwright test",
|
|
50
|
-
"test:e2e:ui": "playwright test --ui",
|
|
51
|
-
"test:e2e:headed": "playwright test --headed",
|
|
52
|
-
"dev:component": "tsx src/component-system/test.ts"
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|