@docubook/flame 1.0.0-beta.80 → 1.0.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.
Files changed (35) hide show
  1. package/.docu/components/Anchor.tsx +1 -1
  2. package/.docu/components/Breadcrumb.tsx +6 -1
  3. package/.docu/components/Context.tsx +2 -1
  4. package/.docu/components/Navbar.tsx +2 -2
  5. package/.docu/components/Pagination.tsx +15 -2
  6. package/.docu/components/Search.tsx +4 -10
  7. package/.docu/components/Sidebar.tsx +15 -4
  8. package/.docu/components/Theme.tsx +1 -1
  9. package/.docu/components/registry.ts +21 -87
  10. package/.docu/node/build.ts +6 -2
  11. package/.docu/node/client.ts +1 -8
  12. package/.docu/node/html.ts +12 -0
  13. package/.docu/node/parse-tocs.ts +10 -0
  14. package/.docu/node/search-indexer.ts +16 -2
  15. package/.docu/node/server.ts +1 -13
  16. package/.docu/node/utils.ts +6 -4
  17. package/.docu/pages/docs/[[...slug]].tsx +6 -1
  18. package/.docu/styles/globals.css +8 -0
  19. package/README.md +2 -2
  20. package/package.json +9 -5
  21. package/template/docs/index.mdx +123 -17
  22. package/.docu/components/base/breadcrumbs.tsx +0 -64
  23. package/.docu/components/base/collapse.tsx +0 -186
  24. package/.docu/components/base/drawer.tsx +0 -164
  25. package/.docu/components/base/dropdown.tsx +0 -94
  26. package/.docu/components/base/input.tsx +0 -53
  27. package/.docu/components/base/kbd.tsx +0 -51
  28. package/.docu/components/base/modal.tsx +0 -56
  29. package/.docu/components/base/navbar.tsx +0 -132
  30. package/.docu/components/base/pagination/index.ts +0 -21
  31. package/.docu/components/base/pagination/pagination-docs.tsx +0 -39
  32. package/.docu/components/base/pagination/pagination-numbers.tsx +0 -379
  33. package/.docu/components/base/pagination/types.ts +0 -129
  34. package/.docu/components/base/theme-controller.tsx +0 -358
  35. package/.docu/components/base/toggle.tsx +0 -172
@@ -1,379 +0,0 @@
1
- "use client";
2
-
3
- import { cn } from "../../../node/utils";
4
- import { ChevronLeft, ChevronRight } from "lucide-react";
5
- import { useMemo } from "react";
6
- import {
7
- getPaginationRange,
8
- type PaginationRootProps,
9
- type PaginationItemProps,
10
- type PaginationButtonsProps,
11
- type PaginationRangeProps,
12
- type PaginationInfoProps,
13
- type PaginationFullProps,
14
- } from "./types";
15
-
16
- export function Pagination({
17
- children,
18
- className,
19
- size = "md",
20
- variant = "default",
21
- }: PaginationRootProps) {
22
- const sizeClass = {
23
- lg: "join-lg",
24
- md: "",
25
- sm: "join-sm",
26
- xs: "join-xs",
27
- }[size];
28
-
29
- const variantClass =
30
- variant === "square"
31
- ? "[&_.join-item]:btn-square"
32
- : variant === "rounded"
33
- ? "[&_.join-item]:btn-circle"
34
- : "";
35
-
36
- return <div className={cn("join", sizeClass, variantClass, className)}>{children}</div>;
37
- }
38
-
39
- export function PaginationItem({
40
- children,
41
- active = false,
42
- disabled = false,
43
- onClick,
44
- className,
45
- size = "md",
46
- "aria-label": ariaLabel,
47
- }: PaginationItemProps) {
48
- const sizeClasses = {
49
- lg: "btn-lg",
50
- md: "",
51
- sm: "btn-sm",
52
- xs: "btn-xs",
53
- }[size];
54
-
55
- return (
56
- <button
57
- type="button"
58
- className={cn(
59
- "join-item btn",
60
- sizeClasses,
61
- active && "btn-active",
62
- disabled && "btn-disabled",
63
- className
64
- )}
65
- onClick={onClick}
66
- disabled={disabled}
67
- aria-label={ariaLabel}
68
- aria-current={active ? "page" : undefined}
69
- >
70
- {children}
71
- </button>
72
- );
73
- }
74
-
75
- export function PaginationButtons({
76
- page,
77
- totalPages,
78
- onPageChange,
79
- className,
80
- size = "md",
81
- showFirstLast = false,
82
- showPrevNext = true,
83
- prevLabel,
84
- nextLabel,
85
- firstLabel,
86
- lastLabel,
87
- disabled = false,
88
- }: PaginationButtonsProps) {
89
- const handlePrev = () => {
90
- if (page > 1) onPageChange(page - 1);
91
- };
92
-
93
- const handleNext = () => {
94
- if (page < totalPages) onPageChange(page + 1);
95
- };
96
-
97
- const handleFirst = () => {
98
- onPageChange(1);
99
- };
100
-
101
- const handleLast = () => {
102
- onPageChange(totalPages);
103
- };
104
-
105
- return (
106
- <>
107
- {showFirstLast && (
108
- <button
109
- type="button"
110
- className={cn("join-item btn", size !== "md" && `btn-${size}`, className)}
111
- onClick={handleFirst}
112
- disabled={disabled || page <= 1}
113
- aria-label={firstLabel ?? "First page"}
114
- >
115
- {firstLabel ?? <ChevronLeft className="h-4 w-4" />}
116
- </button>
117
- )}
118
-
119
- {showPrevNext && (
120
- <button
121
- type="button"
122
- className={cn("join-item btn", size !== "md" && `btn-${size}`, className)}
123
- onClick={handlePrev}
124
- disabled={disabled || page <= 1}
125
- aria-label={prevLabel ?? "Previous page"}
126
- >
127
- {prevLabel ?? <ChevronLeft className="h-4 w-4" />}
128
- </button>
129
- )}
130
-
131
- <span className="join-item btn btn-disabled no-animation cursor-default">
132
- {page} / {totalPages}
133
- </span>
134
-
135
- {showPrevNext && (
136
- <button
137
- type="button"
138
- className={cn("join-item btn", size !== "md" && `btn-${size}`, className)}
139
- onClick={handleNext}
140
- disabled={disabled || page >= totalPages}
141
- aria-label={nextLabel ?? "Next page"}
142
- >
143
- {nextLabel ?? <ChevronRight className="h-4 w-4" />}
144
- </button>
145
- )}
146
-
147
- {showFirstLast && (
148
- <button
149
- type="button"
150
- className={cn("join-item btn", size !== "md" && `btn-${size}`, className)}
151
- onClick={handleLast}
152
- disabled={disabled || page >= totalPages}
153
- aria-label={lastLabel ?? "Last page"}
154
- >
155
- {lastLabel ?? <ChevronRight className="h-4 w-4" />}
156
- </button>
157
- )}
158
- </>
159
- );
160
- }
161
-
162
- export function PaginationRange({
163
- start,
164
- end,
165
- total,
166
- current,
167
- onPageChange,
168
- siblingCount = 1,
169
- className,
170
- size = "md",
171
- variant = "default",
172
- }: PaginationRangeProps) {
173
- const range = useMemo(
174
- () =>
175
- getPaginationRange({
176
- totalCount: total,
177
- pageSize: end - start + 1,
178
- siblingCount,
179
- currentPage: current,
180
- }),
181
- [total, start, end, siblingCount, current]
182
- );
183
-
184
- const sizeClasses = {
185
- lg: "join-lg",
186
- md: "",
187
- sm: "join-sm",
188
- xs: "join-xs",
189
- }[size];
190
-
191
- const variantClass =
192
- variant === "square"
193
- ? "[&_.join-item]:btn-square"
194
- : variant === "rounded"
195
- ? "[&_.join-item]:btn-circle"
196
- : "";
197
-
198
- return (
199
- <div className={cn("join", sizeClasses, variantClass, className)}>
200
- {range.map((item, index) => {
201
- if (item === "ellipsis") {
202
- return (
203
- <span key={`ellipsis-${index}`} className="join-item btn btn-disabled no-animation">
204
- ...
205
- </span>
206
- );
207
- }
208
-
209
- const isActive = item === current;
210
-
211
- return (
212
- <button
213
- key={item}
214
- type="button"
215
- className={cn(
216
- "join-item btn",
217
- isActive && "btn-active",
218
- size !== "md" && `btn-${size}`
219
- )}
220
- onClick={() => onPageChange(item)}
221
- aria-label={`Page ${item}`}
222
- aria-current={isActive ? "page" : undefined}
223
- >
224
- {item}
225
- </button>
226
- );
227
- })}
228
- </div>
229
- );
230
- }
231
-
232
- export function PaginationInfo({
233
- current,
234
- total,
235
- pageSize = 10,
236
- className,
237
- label = "Showing",
238
- showTotal = true,
239
- }: PaginationInfoProps) {
240
- const start = (current - 1) * pageSize + 1;
241
- const end = Math.min(current * pageSize, total);
242
-
243
- return (
244
- <div className={cn("text-base-content/70 text-sm", className)}>
245
- {label} {start}-{end} {showTotal && `of ${total}`}
246
- </div>
247
- );
248
- }
249
-
250
- export function PaginationFull({
251
- current,
252
- total,
253
- pageSize = 10,
254
- onPageChange,
255
- siblingCount = 1,
256
- className,
257
- size = "md",
258
- variant = "default",
259
- showFirstLast = true,
260
- showPrevNext = true,
261
- infoClassName,
262
- }: PaginationFullProps) {
263
- const totalPages = Math.ceil(total / pageSize);
264
-
265
- const range = useMemo(
266
- () =>
267
- getPaginationRange({
268
- totalCount: total,
269
- pageSize,
270
- siblingCount,
271
- currentPage: current,
272
- }),
273
- [total, pageSize, siblingCount, current]
274
- );
275
-
276
- const sizeClasses = {
277
- lg: "join-lg",
278
- md: "",
279
- sm: "join-sm",
280
- xs: "join-xs",
281
- }[size];
282
-
283
- const variantClass =
284
- variant === "square"
285
- ? "[&_.join-item]:btn-square"
286
- : variant === "rounded"
287
- ? "[&_.join-item]:btn-circle"
288
- : "";
289
-
290
- return (
291
- <div className={cn("flex flex-col items-center justify-between gap-4 sm:flex-row", className)}>
292
- <PaginationInfo
293
- current={current}
294
- total={total}
295
- pageSize={pageSize}
296
- className={infoClassName}
297
- />
298
-
299
- <div className={cn("join", sizeClasses, variantClass)}>
300
- {showFirstLast && (
301
- <button
302
- type="button"
303
- className={cn("join-item btn", size !== "md" && `btn-${size}`)}
304
- onClick={() => onPageChange(1)}
305
- disabled={current <= 1}
306
- aria-label="First page"
307
- >
308
- <ChevronLeft className="h-4 w-4" />
309
- </button>
310
- )}
311
-
312
- {showPrevNext && (
313
- <button
314
- type="button"
315
- className={cn("join-item btn", size !== "md" && `btn-${size}`)}
316
- onClick={() => onPageChange(current - 1)}
317
- disabled={current <= 1}
318
- aria-label="Previous page"
319
- >
320
- <ChevronLeft className="h-4 w-4" />
321
- </button>
322
- )}
323
-
324
- {range.map((item, index) => {
325
- if (item === "ellipsis") {
326
- return (
327
- <span key={`ellipsis-${index}`} className="join-item btn btn-disabled no-animation">
328
- ...
329
- </span>
330
- );
331
- }
332
-
333
- const isActive = item === current;
334
-
335
- return (
336
- <button
337
- key={item}
338
- type="button"
339
- className={cn(
340
- "join-item btn",
341
- isActive && "btn-active",
342
- size !== "md" && `btn-${size}`
343
- )}
344
- onClick={() => onPageChange(item)}
345
- aria-label={`Page ${item}`}
346
- aria-current={isActive ? "page" : undefined}
347
- >
348
- {item}
349
- </button>
350
- );
351
- })}
352
-
353
- {showPrevNext && (
354
- <button
355
- type="button"
356
- className={cn("join-item btn", size !== "md" && `btn-${size}`)}
357
- onClick={() => onPageChange(current + 1)}
358
- disabled={current >= totalPages}
359
- aria-label="Next page"
360
- >
361
- <ChevronRight className="h-4 w-4" />
362
- </button>
363
- )}
364
-
365
- {showFirstLast && (
366
- <button
367
- type="button"
368
- className={cn("join-item btn", size !== "md" && `btn-${size}`)}
369
- onClick={() => onPageChange(totalPages)}
370
- disabled={current >= totalPages}
371
- aria-label="Last page"
372
- >
373
- <ChevronRight className="h-4 w-4" />
374
- </button>
375
- )}
376
- </div>
377
- </div>
378
- );
379
- }
@@ -1,129 +0,0 @@
1
- import type { ReactNode } from "react";
2
-
3
- export type PaginationSize = "lg" | "md" | "sm" | "xs";
4
- export type PaginationVariant = "default" | "square" | "rounded";
5
-
6
- export interface PaginationRootProps {
7
- children?: ReactNode;
8
- className?: string;
9
- size?: PaginationSize;
10
- variant?: PaginationVariant;
11
- }
12
-
13
- export interface PaginationItemProps {
14
- children: ReactNode;
15
- active?: boolean;
16
- disabled?: boolean;
17
- onClick?: () => void;
18
- className?: string;
19
- size?: PaginationSize;
20
- variant?: PaginationVariant;
21
- "aria-label"?: string;
22
- }
23
-
24
- export interface PaginationRangeProps {
25
- start: number;
26
- end: number;
27
- total: number;
28
- current: number;
29
- onPageChange: (page: number) => void;
30
- siblingCount?: number;
31
- className?: string;
32
- size?: PaginationSize;
33
- variant?: PaginationVariant;
34
- }
35
-
36
- export interface PaginationButtonsProps {
37
- page: number;
38
- totalPages: number;
39
- onPageChange: (page: number) => void;
40
- className?: string;
41
- size?: PaginationSize;
42
- showFirstLast?: boolean;
43
- showPrevNext?: boolean;
44
- prevLabel?: string;
45
- nextLabel?: string;
46
- firstLabel?: string;
47
- lastLabel?: string;
48
- disabled?: boolean;
49
- }
50
-
51
- export interface PaginationInfoProps {
52
- current: number;
53
- total: number;
54
- pageSize?: number;
55
- className?: string;
56
- label?: string;
57
- showTotal?: boolean;
58
- }
59
-
60
- export interface PaginationFullProps {
61
- current: number;
62
- total: number;
63
- pageSize?: number;
64
- onPageChange: (page: number) => void;
65
- siblingCount?: number;
66
- className?: string;
67
- size?: PaginationSize;
68
- variant?: PaginationVariant;
69
- showFirstLast?: boolean;
70
- showPrevNext?: boolean;
71
- infoClassName?: string;
72
- }
73
-
74
- export interface PaginationDocsProps {
75
- prev?: { href: string; title: string };
76
- next?: { href: string; title: string };
77
- className?: string;
78
- }
79
-
80
- export function getPaginationRange({
81
- totalCount,
82
- pageSize,
83
- siblingCount = 1,
84
- currentPage,
85
- }: {
86
- totalCount: number;
87
- pageSize: number;
88
- siblingCount?: number;
89
- currentPage: number;
90
- }): (number | "ellipsis")[] {
91
- const totalPages = Math.ceil(totalCount / pageSize);
92
- const DOTS = "ellipsis" as const;
93
-
94
- if (totalPages === 1) {
95
- return [1];
96
- }
97
-
98
- const totalPageNumbers = siblingCount + 5;
99
-
100
- if (totalPages < totalPageNumbers) {
101
- return Array.from({ length: totalPages }, (_, i) => i + 1);
102
- }
103
-
104
- const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
105
- const rightSiblingIndex = Math.min(currentPage + siblingCount, totalPages);
106
-
107
- const showLeftDots = leftSiblingIndex > 2;
108
- const showRightDots = rightSiblingIndex < totalPages - 1;
109
-
110
- if (!showLeftDots && showRightDots) {
111
- const leftRange = Array.from({ length: 3 }, (_, i) => i + 1);
112
- return [...leftRange, DOTS, totalPages - 1, totalPages];
113
- }
114
-
115
- if (showLeftDots && !showRightDots) {
116
- const rightRange = Array.from({ length: 3 }, (_, i) => totalPages - 2 + i);
117
- return [1, 2, DOTS, ...rightRange];
118
- }
119
-
120
- if (showLeftDots && showRightDots) {
121
- const middleRange = Array.from(
122
- { length: rightSiblingIndex - leftSiblingIndex + 1 },
123
- (_, i) => leftSiblingIndex + i
124
- );
125
- return [1, 2, DOTS, ...middleRange, DOTS, totalPages - 1, totalPages];
126
- }
127
-
128
- return [1];
129
- }