@docubook/ui-react 0.1.0 → 0.1.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.
Files changed (59) hide show
  1. package/dist/breadcrumbs.cjs +3 -3
  2. package/dist/breadcrumbs.js +2 -3
  3. package/dist/{chunk-7HHY2WDF.cjs → chunk-2DFF5NEL.cjs} +3 -1
  4. package/dist/chunk-4QUABBES.js +43 -0
  5. package/dist/{chunk-BCJ3FW3Y.cjs → chunk-5SA5UPFQ.cjs} +3 -3
  6. package/dist/{chunk-IBKH77YN.js → chunk-5UVG5YY5.js} +1 -2
  7. package/dist/{chunk-LUO4YXRQ.js → chunk-7BWAXCW2.js} +1 -2
  8. package/dist/{chunk-FGJ6EYLA.js → chunk-AQP3U2YN.js} +1 -2
  9. package/dist/{chunk-PB4SHWMJ.cjs → chunk-BHHZBMD4.cjs} +9 -9
  10. package/dist/{chunk-LJV3UIMK.cjs → chunk-BXRTL6BJ.cjs} +6 -6
  11. package/dist/{chunk-QZH7EIFW.js → chunk-FQQILPIP.js} +1 -2
  12. package/dist/{chunk-NJKWNMJF.js → chunk-GRADTONK.js} +3 -2
  13. package/dist/{chunk-54N6HTQV.cjs → chunk-HTH2UTCL.cjs} +5 -5
  14. package/dist/{chunk-OB6B2KN5.js → chunk-JHI4G22P.js} +1 -2
  15. package/dist/chunk-K22HSWMW.cjs +43 -0
  16. package/dist/{chunk-VRODU4ZV.cjs → chunk-K6B7XOJ5.cjs} +3 -3
  17. package/dist/{chunk-EJCGJCVK.cjs → chunk-LUVR2YGT.cjs} +10 -10
  18. package/dist/{chunk-42YUT467.cjs → chunk-MWJV72OM.cjs} +6 -6
  19. package/dist/{chunk-I4CZWV3M.js → chunk-ND7BTYGG.js} +1 -2
  20. package/dist/{chunk-Q55KNNKE.js → chunk-OGI5BHGM.js} +1 -2
  21. package/dist/{chunk-ACEM5N2Y.cjs → chunk-OO3HHTPV.cjs} +10 -10
  22. package/dist/{chunk-W5G2ZBYA.js → chunk-OTJGG73E.js} +1 -2
  23. package/dist/{chunk-HTNZRBKW.js → chunk-PFRBA5BH.js} +1 -2
  24. package/dist/{chunk-KHU72DOY.cjs → chunk-RDRDPR67.cjs} +4 -4
  25. package/dist/{chunk-OKMEBWPL.cjs → chunk-SV4L2FGT.cjs} +6 -6
  26. package/dist/{chunk-4DCBYM74.js → chunk-SX6DOGUE.js} +1 -2
  27. package/dist/cn.cjs +2 -2
  28. package/dist/cn.d.cts +2 -1
  29. package/dist/cn.d.ts +2 -1
  30. package/dist/cn.js +1 -2
  31. package/dist/collapse.cjs +3 -3
  32. package/dist/collapse.js +2 -3
  33. package/dist/drawer.cjs +3 -3
  34. package/dist/drawer.js +2 -3
  35. package/dist/dropdown.cjs +3 -3
  36. package/dist/dropdown.js +2 -3
  37. package/dist/index.cjs +13 -25
  38. package/dist/index.d.cts +2 -1
  39. package/dist/index.d.ts +2 -1
  40. package/dist/index.js +13 -26
  41. package/dist/input.cjs +5 -4
  42. package/dist/input.js +2 -2
  43. package/dist/kbd.cjs +5 -4
  44. package/dist/kbd.js +2 -2
  45. package/dist/modal.cjs +3 -3
  46. package/dist/modal.js +2 -3
  47. package/dist/navbar.cjs +3 -3
  48. package/dist/navbar.js +2 -3
  49. package/dist/pagination.cjs +4 -17
  50. package/dist/pagination.d.cts +1 -69
  51. package/dist/pagination.d.ts +1 -69
  52. package/dist/pagination.js +4 -18
  53. package/dist/theme-controller.cjs +3 -3
  54. package/dist/theme-controller.js +2 -3
  55. package/dist/toggle.cjs +3 -3
  56. package/dist/toggle.js +2 -3
  57. package/package.json +6 -2
  58. package/dist/chunk-EN2X23AN.cjs +0 -330
  59. package/dist/chunk-ZMIZV66S.js +0 -331
@@ -1,331 +0,0 @@
1
- "use client";
2
- import {
3
- cn
4
- } from "./chunk-NJKWNMJF.js";
5
-
6
- // src/base/pagination.tsx
7
- import { useMemo } from "react";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
- function getPaginationRange({
10
- totalCount,
11
- pageSize,
12
- siblingCount = 1,
13
- currentPage
14
- }) {
15
- const totalPages = Math.ceil(totalCount / pageSize);
16
- if (totalPages <= 1) return [1];
17
- const totalPageNumbers = siblingCount + 5;
18
- if (totalPages < totalPageNumbers) return Array.from({ length: totalPages }, (_, i) => i + 1);
19
- const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
20
- const rightSiblingIndex = Math.min(currentPage + siblingCount, totalPages);
21
- const showLeftDots = leftSiblingIndex > 2;
22
- const showRightDots = rightSiblingIndex < totalPages - 1;
23
- if (!showLeftDots && showRightDots)
24
- return [...Array.from({ length: 3 }, (_, i) => i + 1), "ellipsis", totalPages - 1, totalPages];
25
- if (showLeftDots && !showRightDots)
26
- return [1, 2, "ellipsis", ...Array.from({ length: 3 }, (_, i) => totalPages - 2 + i)];
27
- if (showLeftDots && showRightDots) {
28
- const middle = Array.from(
29
- { length: rightSiblingIndex - leftSiblingIndex + 1 },
30
- (_, i) => leftSiblingIndex + i
31
- );
32
- return [1, 2, "ellipsis", ...middle, "ellipsis", totalPages - 1, totalPages];
33
- }
34
- return [1];
35
- }
36
- function variantClass(variant) {
37
- if (variant === "square") return "[&_.join-item]:btn-square";
38
- if (variant === "rounded") return "[&_.join-item]:btn-circle";
39
- return "";
40
- }
41
- function PaginationItem({
42
- children,
43
- active,
44
- disabled,
45
- onClick,
46
- className,
47
- size = "md",
48
- "aria-label": ariaLabel
49
- }) {
50
- const sizeClass = size === "lg" ? "btn-lg" : size === "sm" ? "btn-sm" : size === "xs" ? "btn-xs" : "";
51
- return /* @__PURE__ */ jsx(
52
- "button",
53
- {
54
- type: "button",
55
- className: cn(
56
- "join-item btn",
57
- sizeClass,
58
- active && "btn-active",
59
- disabled && "btn-disabled",
60
- className
61
- ),
62
- onClick,
63
- disabled,
64
- "aria-label": ariaLabel,
65
- "aria-current": active ? "page" : void 0,
66
- children
67
- }
68
- );
69
- }
70
- function PaginationButtons({
71
- page,
72
- totalPages,
73
- onPageChange,
74
- className,
75
- size = "md",
76
- showFirstLast = false,
77
- showPrevNext = true,
78
- prevLabel,
79
- nextLabel,
80
- firstLabel,
81
- lastLabel,
82
- disabled = false
83
- }) {
84
- const sizeClass = size !== "md" ? `btn-${size}` : "";
85
- return /* @__PURE__ */ jsxs(Fragment, { children: [
86
- showFirstLast && /* @__PURE__ */ jsx(
87
- "button",
88
- {
89
- type: "button",
90
- className: cn("join-item btn", sizeClass, className),
91
- onClick: () => onPageChange(1),
92
- disabled: disabled || page <= 1,
93
- "aria-label": firstLabel != null ? firstLabel : "First page",
94
- children: firstLabel != null ? firstLabel : "\xAB"
95
- }
96
- ),
97
- showPrevNext && /* @__PURE__ */ jsx(
98
- "button",
99
- {
100
- type: "button",
101
- className: cn("join-item btn", sizeClass, className),
102
- onClick: () => onPageChange(page - 1),
103
- disabled: disabled || page <= 1,
104
- "aria-label": prevLabel != null ? prevLabel : "Previous page",
105
- children: prevLabel != null ? prevLabel : "\u2039"
106
- }
107
- ),
108
- /* @__PURE__ */ jsxs("span", { className: "join-item btn btn-disabled no-animation cursor-default", children: [
109
- page,
110
- " / ",
111
- totalPages
112
- ] }),
113
- showPrevNext && /* @__PURE__ */ jsx(
114
- "button",
115
- {
116
- type: "button",
117
- className: cn("join-item btn", sizeClass, className),
118
- onClick: () => onPageChange(page + 1),
119
- disabled: disabled || page >= totalPages,
120
- "aria-label": nextLabel != null ? nextLabel : "Next page",
121
- children: nextLabel != null ? nextLabel : "\u203A"
122
- }
123
- ),
124
- showFirstLast && /* @__PURE__ */ jsx(
125
- "button",
126
- {
127
- type: "button",
128
- className: cn("join-item btn", sizeClass, className),
129
- onClick: () => onPageChange(totalPages),
130
- disabled: disabled || page >= totalPages,
131
- "aria-label": lastLabel != null ? lastLabel : "Last page",
132
- children: lastLabel != null ? lastLabel : "\xBB"
133
- }
134
- )
135
- ] });
136
- }
137
- function PaginationRange({
138
- start,
139
- end,
140
- total,
141
- current,
142
- onPageChange,
143
- siblingCount = 1,
144
- className,
145
- size = "md",
146
- variant
147
- }) {
148
- const range = useMemo(
149
- () => getPaginationRange({
150
- totalCount: total,
151
- pageSize: end - start + 1,
152
- siblingCount,
153
- currentPage: current
154
- }),
155
- [total, start, end, siblingCount, current]
156
- );
157
- const sizeClass = size === "lg" ? "join-lg" : size === "sm" ? "join-sm" : size === "xs" ? "join-xs" : "";
158
- return /* @__PURE__ */ jsx("div", { className: cn("join", sizeClass, variantClass(variant), className), children: range.map(
159
- (item, i) => item === "ellipsis" ? /* @__PURE__ */ jsx("span", { className: "join-item btn btn-disabled no-animation", children: "..." }, `e-${i}`) : /* @__PURE__ */ jsx(
160
- "button",
161
- {
162
- type: "button",
163
- className: cn(
164
- "join-item btn",
165
- item === current && "btn-active",
166
- size !== "md" && `btn-${size}`
167
- ),
168
- onClick: () => onPageChange(item),
169
- "aria-current": item === current ? "page" : void 0,
170
- children: item
171
- },
172
- item
173
- )
174
- ) });
175
- }
176
- function PaginationInfo({
177
- current,
178
- total,
179
- pageSize = 10,
180
- className,
181
- label = "Showing",
182
- showTotal = true
183
- }) {
184
- const start = (current - 1) * pageSize + 1;
185
- const end = Math.min(current * pageSize, total);
186
- return /* @__PURE__ */ jsxs("div", { className: cn("text-base-content/70 text-sm", className), children: [
187
- label,
188
- " ",
189
- start,
190
- "-",
191
- end,
192
- showTotal && ` of ${total}`
193
- ] });
194
- }
195
- function PaginationFull({
196
- current,
197
- total,
198
- pageSize = 10,
199
- onPageChange,
200
- siblingCount = 1,
201
- className,
202
- size = "md",
203
- variant,
204
- showFirstLast = true,
205
- showPrevNext = true,
206
- infoClassName
207
- }) {
208
- const totalPages = Math.ceil(total / pageSize);
209
- const range = useMemo(
210
- () => getPaginationRange({ totalCount: total, pageSize, siblingCount, currentPage: current }),
211
- [total, pageSize, siblingCount, current]
212
- );
213
- const sizeClass = size === "lg" ? "join-lg" : size === "sm" ? "join-sm" : size === "xs" ? "join-xs" : "";
214
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col items-center justify-between gap-4 sm:flex-row", className), children: [
215
- /* @__PURE__ */ jsx(
216
- PaginationInfo,
217
- {
218
- current,
219
- total,
220
- pageSize,
221
- className: infoClassName
222
- }
223
- ),
224
- /* @__PURE__ */ jsxs("div", { className: cn("join", sizeClass, variantClass(variant)), children: [
225
- showFirstLast && /* @__PURE__ */ jsx(
226
- "button",
227
- {
228
- type: "button",
229
- className: cn("join-item btn", size !== "md" && `btn-${size}`),
230
- onClick: () => onPageChange(1),
231
- disabled: current <= 1,
232
- "aria-label": "First page",
233
- children: "\xAB"
234
- }
235
- ),
236
- showPrevNext && /* @__PURE__ */ jsx(
237
- "button",
238
- {
239
- type: "button",
240
- className: cn("join-item btn", size !== "md" && `btn-${size}`),
241
- onClick: () => onPageChange(current - 1),
242
- disabled: current <= 1,
243
- "aria-label": "Previous page",
244
- children: "\u2039"
245
- }
246
- ),
247
- range.map(
248
- (item, i) => item === "ellipsis" ? /* @__PURE__ */ jsx("span", { className: "join-item btn btn-disabled no-animation", children: "..." }, `e-${i}`) : /* @__PURE__ */ jsx(
249
- "button",
250
- {
251
- type: "button",
252
- className: cn(
253
- "join-item btn",
254
- item === current && "btn-active",
255
- size !== "md" && `btn-${size}`
256
- ),
257
- onClick: () => onPageChange(item),
258
- "aria-current": item === current ? "page" : void 0,
259
- children: item
260
- },
261
- item
262
- )
263
- ),
264
- showPrevNext && /* @__PURE__ */ jsx(
265
- "button",
266
- {
267
- type: "button",
268
- className: cn("join-item btn", size !== "md" && `btn-${size}`),
269
- onClick: () => onPageChange(current + 1),
270
- disabled: current >= totalPages,
271
- "aria-label": "Next page",
272
- children: "\u203A"
273
- }
274
- ),
275
- showFirstLast && /* @__PURE__ */ jsx(
276
- "button",
277
- {
278
- type: "button",
279
- className: cn("join-item btn", size !== "md" && `btn-${size}`),
280
- onClick: () => onPageChange(totalPages),
281
- disabled: current >= totalPages,
282
- "aria-label": "Last page",
283
- children: "\xBB"
284
- }
285
- )
286
- ] })
287
- ] });
288
- }
289
- function PaginationDocs({
290
- prev,
291
- next,
292
- className,
293
- prevIcon,
294
- nextIcon,
295
- linkClassName
296
- }) {
297
- const linkBase = "flex flex-col no-underline rounded-lg border border-base-300 bg-base-100 transition-colors hover:bg-base-200 hover:border-base-300";
298
- return /* @__PURE__ */ jsxs("div", { className: cn("grid grow grid-cols-1 gap-4 py-8 sm:grid-cols-2", className), children: [
299
- /* @__PURE__ */ jsx("div", { children: prev && /* @__PURE__ */ jsxs("a", { href: prev.href, className: cn(linkBase, "items-start px-4 py-4", linkClassName), children: [
300
- /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground flex items-center justify-start text-xs", children: [
301
- prevIcon && /* @__PURE__ */ jsx("span", { className: "mr-1", children: prevIcon }),
302
- "Previous"
303
- ] }),
304
- /* @__PURE__ */ jsx("span", { className: "text-base-content mt-1 text-sm font-medium", children: prev.title })
305
- ] }) }),
306
- /* @__PURE__ */ jsx("div", { children: next && /* @__PURE__ */ jsxs(
307
- "a",
308
- {
309
- href: next.href,
310
- className: cn(linkBase, "items-end px-4 py-4 text-right", linkClassName),
311
- children: [
312
- /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground flex items-center justify-end text-xs", children: [
313
- "Next",
314
- nextIcon && /* @__PURE__ */ jsx("span", { className: "ml-1", children: nextIcon })
315
- ] }),
316
- /* @__PURE__ */ jsx("span", { className: "text-base-content mt-1 text-sm font-medium", children: next.title })
317
- ]
318
- }
319
- ) })
320
- ] });
321
- }
322
-
323
- export {
324
- getPaginationRange,
325
- PaginationItem,
326
- PaginationButtons,
327
- PaginationRange,
328
- PaginationInfo,
329
- PaginationFull,
330
- PaginationDocs
331
- };