@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260722072521 → 0.8.1-dev.20260722072620

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,183 +0,0 @@
1
- "use client";
2
-
3
- "use client";
4
- import {
5
- OdataBuilder
6
- } from "./chunk-OGGIS4AN.mjs";
7
- import {
8
- Constants,
9
- Hyperlink,
10
- Icon_default
11
- } from "./chunk-FI2KJBK2.mjs";
12
- import "./chunk-IMNQO57B.mjs";
13
-
14
- // src/components/Pagination.tsx
15
- import { useMemo } from "react";
16
- import { jsx, jsxs } from "react/jsx-runtime";
17
- var Pagination = (props) => {
18
- const { dataset, path, query, showPageSizeSelector = false, showJumpToPage = false } = props;
19
- const builder = useMemo(() => {
20
- const b = new OdataBuilder(path);
21
- if (query) b.setQuery(query);
22
- return b;
23
- }, [path, query]);
24
- const activePageNumber = builder.getPageNumber(Constants.pagesize);
25
- const totalItems = dataset?.count || 0;
26
- const itemsPerPage = parseInt(builder.top || Constants.pagesize.toString());
27
- const totalPages = Math.ceil(totalItems / itemsPerPage);
28
- const startItem = totalItems > 0 ? (activePageNumber - 1) * itemsPerPage + 1 : 0;
29
- const endItem = Math.min(activePageNumber * itemsPerPage, totalItems);
30
- const getPaginationRange = () => {
31
- const delta = 1;
32
- const range = [];
33
- if (totalPages <= 7) {
34
- return Array.from({ length: totalPages }, (_, i) => i + 1);
35
- }
36
- range.push(1);
37
- let start = Math.max(2, activePageNumber - delta);
38
- let end = Math.min(totalPages - 1, activePageNumber + delta);
39
- if (activePageNumber - delta <= 2) {
40
- end = Math.min(totalPages - 1, 4);
41
- }
42
- if (activePageNumber + delta >= totalPages - 1) {
43
- start = Math.max(2, totalPages - 4);
44
- }
45
- if (start > 2) {
46
- range.push("...");
47
- }
48
- for (let i = start; i <= end; i++) {
49
- range.push(i);
50
- }
51
- if (end < totalPages - 1) {
52
- range.push("...");
53
- }
54
- if (totalPages > 1) {
55
- range.push(totalPages);
56
- }
57
- return range;
58
- };
59
- const paginationRange = getPaginationRange();
60
- const PageButton = ({ page, children }) => /* @__PURE__ */ jsx(
61
- Hyperlink,
62
- {
63
- linkType: "Link" /* Link */,
64
- className: `
65
- min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center px-2.5 md:px-3
66
- border text-sm font-medium transition-colors duration-150
67
- ${activePageNumber === page ? "bg-primary-base font-semibold" : ""}
68
- `,
69
- href: builder.getNewPageUrl(page),
70
- children
71
- }
72
- );
73
- const NavigationButton = ({ page, disabled, children }) => {
74
- if (disabled) {
75
- return /* @__PURE__ */ jsx("span", { className: "min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center px-2 md:px-3 border bg-neutral-base cursor-not-allowed", children });
76
- }
77
- return /* @__PURE__ */ jsx(
78
- Hyperlink,
79
- {
80
- className: "min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center px-2 md:px-3 border transition-colors duration-150",
81
- href: builder.getNewPageUrl(page),
82
- children
83
- }
84
- );
85
- };
86
- if (totalPages <= 1 && totalItems === 0) return null;
87
- return /* @__PURE__ */ jsxs("div", { className: "py-6 border-t bg-default", children: [
88
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row items-center justify-between gap-4", children: [
89
- /* @__PURE__ */ jsxs("div", { className: "text-sm", children: [
90
- "Showing ",
91
- /* @__PURE__ */ jsxs("span", { className: "font-semibold", children: [
92
- startItem,
93
- "-",
94
- endItem
95
- ] }),
96
- " ",
97
- "out of ",
98
- /* @__PURE__ */ jsx("span", { className: "font-semibold", children: totalItems.toLocaleString() }),
99
- " results"
100
- ] }),
101
- totalPages > 1 && /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
102
- /* @__PURE__ */ jsxs(
103
- NavigationButton,
104
- {
105
- page: activePageNumber - 1,
106
- disabled: activePageNumber === 1,
107
- children: [
108
- /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Icon_default, { name: "chevronLeft", className: "w-4 h-4 mr-1" }) }),
109
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Prev" })
110
- ]
111
- }
112
- ),
113
- paginationRange.map((item, index) => {
114
- if (item === "...") {
115
- return /* @__PURE__ */ jsx(
116
- "span",
117
- {
118
- className: "min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center text-gray-500",
119
- children: "..."
120
- },
121
- `ellipsis-${index}`
122
- );
123
- }
124
- const page = item;
125
- return /* @__PURE__ */ jsx(PageButton, { page, children: page }, page);
126
- }),
127
- /* @__PURE__ */ jsxs(
128
- NavigationButton,
129
- {
130
- page: activePageNumber + 1,
131
- disabled: activePageNumber === totalPages,
132
- children: [
133
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Next" }),
134
- /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Icon_default, { name: "chevronRight", className: "w-4 h-4 ml-1" }) })
135
- ]
136
- }
137
- )
138
- ] }),
139
- showJumpToPage && totalPages > 5 && /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
140
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Go to:" }),
141
- /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx(
142
- "input",
143
- {
144
- type: "number",
145
- min: "1",
146
- max: totalPages,
147
- defaultValue: activePageNumber,
148
- className: "w-20 h-10 px-3 border rounded text-sm focus:outline-none focus:ring-2 focus:border-transparent",
149
- onKeyDown: (e) => {
150
- if (e.key === "Enter") {
151
- const input = e.target;
152
- const page = parseInt(input.value);
153
- if (page >= 1 && page <= totalPages && page !== activePageNumber) {
154
- window.location.href = builder.getNewPageUrl(page);
155
- }
156
- }
157
- }
158
- }
159
- ) })
160
- ] })
161
- ] }),
162
- showPageSizeSelector && /* @__PURE__ */ jsx("div", { className: "mt-4 pt-4 border-t bg-default", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
163
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Show:" }),
164
- /* @__PURE__ */ jsx("div", { className: "flex space-x-1", children: [10, 25, 50, 100].map((size) => /* @__PURE__ */ jsx(
165
- Hyperlink,
166
- {
167
- className: `
168
- px-3 py-1 text-sm rounded border transition-colors duration-150
169
- ${itemsPerPage === size ? "bg-primary-base font-medium" : "bg-neutral-weak"}
170
- `,
171
- href: builder.getNewPageSizeUrl(size),
172
- children: size
173
- },
174
- size
175
- )) }),
176
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: "per page" })
177
- ] }) })
178
- ] });
179
- };
180
- var Pagination_default = Pagination;
181
- export {
182
- Pagination_default as default
183
- };