@docubook/ui-react 0.1.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/README.md +126 -0
- package/dist/breadcrumbs.cjs +13 -0
- package/dist/breadcrumbs.d.cts +19 -0
- package/dist/breadcrumbs.d.ts +19 -0
- package/dist/breadcrumbs.js +14 -0
- package/dist/chunk-42YUT467.cjs +41 -0
- package/dist/chunk-4DCBYM74.js +42 -0
- package/dist/chunk-54N6HTQV.cjs +49 -0
- package/dist/chunk-7HHY2WDF.cjs +43 -0
- package/dist/chunk-ACEM5N2Y.cjs +123 -0
- package/dist/chunk-BCJ3FW3Y.cjs +66 -0
- package/dist/chunk-EJCGJCVK.cjs +89 -0
- package/dist/chunk-EN2X23AN.cjs +330 -0
- package/dist/chunk-FGJ6EYLA.js +90 -0
- package/dist/chunk-HTNZRBKW.js +67 -0
- package/dist/chunk-I4CZWV3M.js +124 -0
- package/dist/chunk-IBKH77YN.js +50 -0
- package/dist/chunk-KHU72DOY.cjs +25 -0
- package/dist/chunk-LJV3UIMK.cjs +53 -0
- package/dist/chunk-LUO4YXRQ.js +38 -0
- package/dist/chunk-NJKWNMJF.js +44 -0
- package/dist/chunk-OB6B2KN5.js +54 -0
- package/dist/chunk-OKMEBWPL.cjs +133 -0
- package/dist/chunk-PB4SHWMJ.cjs +101 -0
- package/dist/chunk-Q55KNNKE.js +26 -0
- package/dist/chunk-QZH7EIFW.js +134 -0
- package/dist/chunk-VRODU4ZV.cjs +37 -0
- package/dist/chunk-W5G2ZBYA.js +102 -0
- package/dist/chunk-ZMIZV66S.js +331 -0
- package/dist/cn.cjs +6 -0
- package/dist/cn.d.cts +4 -0
- package/dist/cn.d.ts +4 -0
- package/dist/cn.js +7 -0
- package/dist/collapse.cjs +12 -0
- package/dist/collapse.d.cts +31 -0
- package/dist/collapse.d.ts +31 -0
- package/dist/collapse.js +13 -0
- package/dist/drawer.cjs +16 -0
- package/dist/drawer.d.cts +44 -0
- package/dist/drawer.d.ts +44 -0
- package/dist/drawer.js +17 -0
- package/dist/dropdown.cjs +12 -0
- package/dist/dropdown.d.cts +20 -0
- package/dist/dropdown.d.ts +20 -0
- package/dist/dropdown.js +13 -0
- package/dist/index.cjs +96 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +97 -0
- package/dist/input.cjs +9 -0
- package/dist/input.d.cts +17 -0
- package/dist/input.d.ts +17 -0
- package/dist/input.js +10 -0
- package/dist/kbd.cjs +9 -0
- package/dist/kbd.d.cts +27 -0
- package/dist/kbd.d.ts +27 -0
- package/dist/kbd.js +10 -0
- package/dist/modal.cjs +10 -0
- package/dist/modal.d.cts +17 -0
- package/dist/modal.d.ts +17 -0
- package/dist/modal.js +11 -0
- package/dist/navbar.cjs +13 -0
- package/dist/navbar.d.cts +36 -0
- package/dist/navbar.d.ts +36 -0
- package/dist/navbar.js +14 -0
- package/dist/pagination.cjs +20 -0
- package/dist/pagination.d.cts +88 -0
- package/dist/pagination.d.ts +88 -0
- package/dist/pagination.js +21 -0
- package/dist/theme-controller.cjs +8 -0
- package/dist/theme-controller.d.cts +21 -0
- package/dist/theme-controller.d.ts +21 -0
- package/dist/theme-controller.js +9 -0
- package/dist/toggle.cjs +10 -0
- package/dist/toggle.d.cts +36 -0
- package/dist/toggle.d.ts +36 -0
- package/dist/toggle.js +11 -0
- package/dist/types-BZI5Cv8-.d.cts +6 -0
- package/dist/types-BZI5Cv8-.d.ts +6 -0
- package/package.json +200 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk7HHY2WDFcjs = require('./chunk-7HHY2WDF.cjs');
|
|
4
|
+
|
|
5
|
+
// src/base/pagination.tsx
|
|
6
|
+
var _react = require('react');
|
|
7
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
8
|
+
function getPaginationRange({
|
|
9
|
+
totalCount,
|
|
10
|
+
pageSize,
|
|
11
|
+
siblingCount = 1,
|
|
12
|
+
currentPage
|
|
13
|
+
}) {
|
|
14
|
+
const totalPages = Math.ceil(totalCount / pageSize);
|
|
15
|
+
if (totalPages <= 1) return [1];
|
|
16
|
+
const totalPageNumbers = siblingCount + 5;
|
|
17
|
+
if (totalPages < totalPageNumbers) return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
18
|
+
const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
|
|
19
|
+
const rightSiblingIndex = Math.min(currentPage + siblingCount, totalPages);
|
|
20
|
+
const showLeftDots = leftSiblingIndex > 2;
|
|
21
|
+
const showRightDots = rightSiblingIndex < totalPages - 1;
|
|
22
|
+
if (!showLeftDots && showRightDots)
|
|
23
|
+
return [...Array.from({ length: 3 }, (_, i) => i + 1), "ellipsis", totalPages - 1, totalPages];
|
|
24
|
+
if (showLeftDots && !showRightDots)
|
|
25
|
+
return [1, 2, "ellipsis", ...Array.from({ length: 3 }, (_, i) => totalPages - 2 + i)];
|
|
26
|
+
if (showLeftDots && showRightDots) {
|
|
27
|
+
const middle = Array.from(
|
|
28
|
+
{ length: rightSiblingIndex - leftSiblingIndex + 1 },
|
|
29
|
+
(_, i) => leftSiblingIndex + i
|
|
30
|
+
);
|
|
31
|
+
return [1, 2, "ellipsis", ...middle, "ellipsis", totalPages - 1, totalPages];
|
|
32
|
+
}
|
|
33
|
+
return [1];
|
|
34
|
+
}
|
|
35
|
+
function variantClass(variant) {
|
|
36
|
+
if (variant === "square") return "[&_.join-item]:btn-square";
|
|
37
|
+
if (variant === "rounded") return "[&_.join-item]:btn-circle";
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
function PaginationItem({
|
|
41
|
+
children,
|
|
42
|
+
active,
|
|
43
|
+
disabled,
|
|
44
|
+
onClick,
|
|
45
|
+
className,
|
|
46
|
+
size = "md",
|
|
47
|
+
"aria-label": ariaLabel
|
|
48
|
+
}) {
|
|
49
|
+
const sizeClass = size === "lg" ? "btn-lg" : size === "sm" ? "btn-sm" : size === "xs" ? "btn-xs" : "";
|
|
50
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
51
|
+
"button",
|
|
52
|
+
{
|
|
53
|
+
type: "button",
|
|
54
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0,
|
|
55
|
+
"join-item btn",
|
|
56
|
+
sizeClass,
|
|
57
|
+
active && "btn-active",
|
|
58
|
+
disabled && "btn-disabled",
|
|
59
|
+
className
|
|
60
|
+
),
|
|
61
|
+
onClick,
|
|
62
|
+
disabled,
|
|
63
|
+
"aria-label": ariaLabel,
|
|
64
|
+
"aria-current": active ? "page" : void 0,
|
|
65
|
+
children
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
function PaginationButtons({
|
|
70
|
+
page,
|
|
71
|
+
totalPages,
|
|
72
|
+
onPageChange,
|
|
73
|
+
className,
|
|
74
|
+
size = "md",
|
|
75
|
+
showFirstLast = false,
|
|
76
|
+
showPrevNext = true,
|
|
77
|
+
prevLabel,
|
|
78
|
+
nextLabel,
|
|
79
|
+
firstLabel,
|
|
80
|
+
lastLabel,
|
|
81
|
+
disabled = false
|
|
82
|
+
}) {
|
|
83
|
+
const sizeClass = size !== "md" ? `btn-${size}` : "";
|
|
84
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
85
|
+
showFirstLast && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
type: "button",
|
|
89
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", sizeClass, className),
|
|
90
|
+
onClick: () => onPageChange(1),
|
|
91
|
+
disabled: disabled || page <= 1,
|
|
92
|
+
"aria-label": firstLabel != null ? firstLabel : "First page",
|
|
93
|
+
children: firstLabel != null ? firstLabel : "\xAB"
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
showPrevNext && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
97
|
+
"button",
|
|
98
|
+
{
|
|
99
|
+
type: "button",
|
|
100
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", sizeClass, className),
|
|
101
|
+
onClick: () => onPageChange(page - 1),
|
|
102
|
+
disabled: disabled || page <= 1,
|
|
103
|
+
"aria-label": prevLabel != null ? prevLabel : "Previous page",
|
|
104
|
+
children: prevLabel != null ? prevLabel : "\u2039"
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "join-item btn btn-disabled no-animation cursor-default", children: [
|
|
108
|
+
page,
|
|
109
|
+
" / ",
|
|
110
|
+
totalPages
|
|
111
|
+
] }),
|
|
112
|
+
showPrevNext && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
type: "button",
|
|
116
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", sizeClass, className),
|
|
117
|
+
onClick: () => onPageChange(page + 1),
|
|
118
|
+
disabled: disabled || page >= totalPages,
|
|
119
|
+
"aria-label": nextLabel != null ? nextLabel : "Next page",
|
|
120
|
+
children: nextLabel != null ? nextLabel : "\u203A"
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
showFirstLast && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", sizeClass, className),
|
|
128
|
+
onClick: () => onPageChange(totalPages),
|
|
129
|
+
disabled: disabled || page >= totalPages,
|
|
130
|
+
"aria-label": lastLabel != null ? lastLabel : "Last page",
|
|
131
|
+
children: lastLabel != null ? lastLabel : "\xBB"
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] });
|
|
135
|
+
}
|
|
136
|
+
function PaginationRange({
|
|
137
|
+
start,
|
|
138
|
+
end,
|
|
139
|
+
total,
|
|
140
|
+
current,
|
|
141
|
+
onPageChange,
|
|
142
|
+
siblingCount = 1,
|
|
143
|
+
className,
|
|
144
|
+
size = "md",
|
|
145
|
+
variant
|
|
146
|
+
}) {
|
|
147
|
+
const range = _react.useMemo.call(void 0,
|
|
148
|
+
() => getPaginationRange({
|
|
149
|
+
totalCount: total,
|
|
150
|
+
pageSize: end - start + 1,
|
|
151
|
+
siblingCount,
|
|
152
|
+
currentPage: current
|
|
153
|
+
}),
|
|
154
|
+
[total, start, end, siblingCount, current]
|
|
155
|
+
);
|
|
156
|
+
const sizeClass = size === "lg" ? "join-lg" : size === "sm" ? "join-sm" : size === "xs" ? "join-xs" : "";
|
|
157
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk7HHY2WDFcjs.cn.call(void 0, "join", sizeClass, variantClass(variant), className), children: range.map(
|
|
158
|
+
(item, i) => item === "ellipsis" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "join-item btn btn-disabled no-animation", children: "..." }, `e-${i}`) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
159
|
+
"button",
|
|
160
|
+
{
|
|
161
|
+
type: "button",
|
|
162
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0,
|
|
163
|
+
"join-item btn",
|
|
164
|
+
item === current && "btn-active",
|
|
165
|
+
size !== "md" && `btn-${size}`
|
|
166
|
+
),
|
|
167
|
+
onClick: () => onPageChange(item),
|
|
168
|
+
"aria-current": item === current ? "page" : void 0,
|
|
169
|
+
children: item
|
|
170
|
+
},
|
|
171
|
+
item
|
|
172
|
+
)
|
|
173
|
+
) });
|
|
174
|
+
}
|
|
175
|
+
function PaginationInfo({
|
|
176
|
+
current,
|
|
177
|
+
total,
|
|
178
|
+
pageSize = 10,
|
|
179
|
+
className,
|
|
180
|
+
label = "Showing",
|
|
181
|
+
showTotal = true
|
|
182
|
+
}) {
|
|
183
|
+
const start = (current - 1) * pageSize + 1;
|
|
184
|
+
const end = Math.min(current * pageSize, total);
|
|
185
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk7HHY2WDFcjs.cn.call(void 0, "text-base-content/70 text-sm", className), children: [
|
|
186
|
+
label,
|
|
187
|
+
" ",
|
|
188
|
+
start,
|
|
189
|
+
"-",
|
|
190
|
+
end,
|
|
191
|
+
showTotal && ` of ${total}`
|
|
192
|
+
] });
|
|
193
|
+
}
|
|
194
|
+
function PaginationFull({
|
|
195
|
+
current,
|
|
196
|
+
total,
|
|
197
|
+
pageSize = 10,
|
|
198
|
+
onPageChange,
|
|
199
|
+
siblingCount = 1,
|
|
200
|
+
className,
|
|
201
|
+
size = "md",
|
|
202
|
+
variant,
|
|
203
|
+
showFirstLast = true,
|
|
204
|
+
showPrevNext = true,
|
|
205
|
+
infoClassName
|
|
206
|
+
}) {
|
|
207
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
208
|
+
const range = _react.useMemo.call(void 0,
|
|
209
|
+
() => getPaginationRange({ totalCount: total, pageSize, siblingCount, currentPage: current }),
|
|
210
|
+
[total, pageSize, siblingCount, current]
|
|
211
|
+
);
|
|
212
|
+
const sizeClass = size === "lg" ? "join-lg" : size === "sm" ? "join-sm" : size === "xs" ? "join-xs" : "";
|
|
213
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk7HHY2WDFcjs.cn.call(void 0, "flex flex-col items-center justify-between gap-4 sm:flex-row", className), children: [
|
|
214
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
215
|
+
PaginationInfo,
|
|
216
|
+
{
|
|
217
|
+
current,
|
|
218
|
+
total,
|
|
219
|
+
pageSize,
|
|
220
|
+
className: infoClassName
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk7HHY2WDFcjs.cn.call(void 0, "join", sizeClass, variantClass(variant)), children: [
|
|
224
|
+
showFirstLast && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
type: "button",
|
|
228
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", size !== "md" && `btn-${size}`),
|
|
229
|
+
onClick: () => onPageChange(1),
|
|
230
|
+
disabled: current <= 1,
|
|
231
|
+
"aria-label": "First page",
|
|
232
|
+
children: "\xAB"
|
|
233
|
+
}
|
|
234
|
+
),
|
|
235
|
+
showPrevNext && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
236
|
+
"button",
|
|
237
|
+
{
|
|
238
|
+
type: "button",
|
|
239
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", size !== "md" && `btn-${size}`),
|
|
240
|
+
onClick: () => onPageChange(current - 1),
|
|
241
|
+
disabled: current <= 1,
|
|
242
|
+
"aria-label": "Previous page",
|
|
243
|
+
children: "\u2039"
|
|
244
|
+
}
|
|
245
|
+
),
|
|
246
|
+
range.map(
|
|
247
|
+
(item, i) => item === "ellipsis" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "join-item btn btn-disabled no-animation", children: "..." }, `e-${i}`) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
248
|
+
"button",
|
|
249
|
+
{
|
|
250
|
+
type: "button",
|
|
251
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0,
|
|
252
|
+
"join-item btn",
|
|
253
|
+
item === current && "btn-active",
|
|
254
|
+
size !== "md" && `btn-${size}`
|
|
255
|
+
),
|
|
256
|
+
onClick: () => onPageChange(item),
|
|
257
|
+
"aria-current": item === current ? "page" : void 0,
|
|
258
|
+
children: item
|
|
259
|
+
},
|
|
260
|
+
item
|
|
261
|
+
)
|
|
262
|
+
),
|
|
263
|
+
showPrevNext && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
264
|
+
"button",
|
|
265
|
+
{
|
|
266
|
+
type: "button",
|
|
267
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", size !== "md" && `btn-${size}`),
|
|
268
|
+
onClick: () => onPageChange(current + 1),
|
|
269
|
+
disabled: current >= totalPages,
|
|
270
|
+
"aria-label": "Next page",
|
|
271
|
+
children: "\u203A"
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
showFirstLast && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
275
|
+
"button",
|
|
276
|
+
{
|
|
277
|
+
type: "button",
|
|
278
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, "join-item btn", size !== "md" && `btn-${size}`),
|
|
279
|
+
onClick: () => onPageChange(totalPages),
|
|
280
|
+
disabled: current >= totalPages,
|
|
281
|
+
"aria-label": "Last page",
|
|
282
|
+
children: "\xBB"
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
] })
|
|
286
|
+
] });
|
|
287
|
+
}
|
|
288
|
+
function PaginationDocs({
|
|
289
|
+
prev,
|
|
290
|
+
next,
|
|
291
|
+
className,
|
|
292
|
+
prevIcon,
|
|
293
|
+
nextIcon,
|
|
294
|
+
linkClassName
|
|
295
|
+
}) {
|
|
296
|
+
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";
|
|
297
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk7HHY2WDFcjs.cn.call(void 0, "grid grow grid-cols-1 gap-4 py-8 sm:grid-cols-2", className), children: [
|
|
298
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: prev && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "a", { href: prev.href, className: _chunk7HHY2WDFcjs.cn.call(void 0, linkBase, "items-start px-4 py-4", linkClassName), children: [
|
|
299
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-muted-foreground flex items-center justify-start text-xs", children: [
|
|
300
|
+
prevIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "mr-1", children: prevIcon }),
|
|
301
|
+
"Previous"
|
|
302
|
+
] }),
|
|
303
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-base-content mt-1 text-sm font-medium", children: prev.title })
|
|
304
|
+
] }) }),
|
|
305
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: next && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
306
|
+
"a",
|
|
307
|
+
{
|
|
308
|
+
href: next.href,
|
|
309
|
+
className: _chunk7HHY2WDFcjs.cn.call(void 0, linkBase, "items-end px-4 py-4 text-right", linkClassName),
|
|
310
|
+
children: [
|
|
311
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-muted-foreground flex items-center justify-end text-xs", children: [
|
|
312
|
+
"Next",
|
|
313
|
+
nextIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "ml-1", children: nextIcon })
|
|
314
|
+
] }),
|
|
315
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-base-content mt-1 text-sm font-medium", children: next.title })
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
) })
|
|
319
|
+
] });
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
exports.getPaginationRange = getPaginationRange; exports.PaginationItem = PaginationItem; exports.PaginationButtons = PaginationButtons; exports.PaginationRange = PaginationRange; exports.PaginationInfo = PaginationInfo; exports.PaginationFull = PaginationFull; exports.PaginationDocs = PaginationDocs;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues,
|
|
6
|
+
cn
|
|
7
|
+
} from "./chunk-NJKWNMJF.js";
|
|
8
|
+
|
|
9
|
+
// src/base/dropdown.tsx
|
|
10
|
+
import { forwardRef, useRef, useEffect } from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var Dropdown = forwardRef(
|
|
13
|
+
(_a, ref) => {
|
|
14
|
+
var _b = _a, { className, align = "start", disabled = false, trigger, children, menuClassName } = _b, props = __objRest(_b, ["className", "align", "disabled", "trigger", "children", "menuClassName"]);
|
|
15
|
+
const detailsRef = useRef(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const handler = (e) => {
|
|
18
|
+
if (detailsRef.current && !detailsRef.current.contains(e.target)) {
|
|
19
|
+
detailsRef.current.open = false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
document.addEventListener("click", handler);
|
|
23
|
+
return () => document.removeEventListener("click", handler);
|
|
24
|
+
}, []);
|
|
25
|
+
return /* @__PURE__ */ jsxs(
|
|
26
|
+
"details",
|
|
27
|
+
__spreadProps(__spreadValues({
|
|
28
|
+
ref: (el) => {
|
|
29
|
+
detailsRef.current = el;
|
|
30
|
+
if (typeof ref === "function") ref(el);
|
|
31
|
+
else if (ref) ref.current = el;
|
|
32
|
+
},
|
|
33
|
+
className: cn("relative", disabled && "pointer-events-none opacity-50", className)
|
|
34
|
+
}, props), {
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ jsx("summary", { className: "cursor-pointer", style: { listStyle: "none" }, children: trigger }),
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
"ul",
|
|
39
|
+
{
|
|
40
|
+
className: cn(
|
|
41
|
+
"bg-base-100 rounded-box border-base-300 absolute z-50 mt-1 min-w-[240px] space-y-1 border p-2 shadow-lg",
|
|
42
|
+
align === "end" ? "right-0" : "left-0",
|
|
43
|
+
menuClassName
|
|
44
|
+
),
|
|
45
|
+
children
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
Dropdown.displayName = "Dropdown";
|
|
54
|
+
var DropdownItem = forwardRef(
|
|
55
|
+
(_a, ref) => {
|
|
56
|
+
var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
|
|
57
|
+
return /* @__PURE__ */ jsx(
|
|
58
|
+
"li",
|
|
59
|
+
__spreadProps(__spreadValues({
|
|
60
|
+
ref,
|
|
61
|
+
className: cn(
|
|
62
|
+
"hover:bg-base-200 text-base-content/80 hover:text-base-content relative flex cursor-pointer items-center gap-2 rounded px-2 py-2 text-sm outline-none transition-colors",
|
|
63
|
+
className
|
|
64
|
+
),
|
|
65
|
+
role: "menuitem"
|
|
66
|
+
}, props), {
|
|
67
|
+
children
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
DropdownItem.displayName = "DropdownItem";
|
|
73
|
+
var DropdownLink = forwardRef((_a, ref) => {
|
|
74
|
+
var _b = _a, { className, children, href } = _b, props = __objRest(_b, ["className", "children", "href"]);
|
|
75
|
+
return /* @__PURE__ */ jsx(
|
|
76
|
+
"li",
|
|
77
|
+
{
|
|
78
|
+
role: "menuitem",
|
|
79
|
+
className: "hover:bg-base-200 text-base-content/80 hover:text-base-content relative flex cursor-pointer items-center gap-2 rounded px-2 py-2 text-sm outline-none transition-colors",
|
|
80
|
+
children: /* @__PURE__ */ jsx("a", __spreadProps(__spreadValues({ ref, href, className: cn("text-inherit no-underline", className) }, props), { children }))
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
DropdownLink.displayName = "DropdownLink";
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
Dropdown,
|
|
88
|
+
DropdownItem,
|
|
89
|
+
DropdownLink
|
|
90
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cn
|
|
4
|
+
} from "./chunk-NJKWNMJF.js";
|
|
5
|
+
|
|
6
|
+
// src/base/theme-controller.tsx
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function applyTheme(theme) {
|
|
10
|
+
if (typeof document !== "undefined") {
|
|
11
|
+
document.documentElement.classList.toggle("dark", theme === "dark");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function useApplyThemeOnMount(theme) {
|
|
15
|
+
const applied = useRef(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!applied.current) {
|
|
18
|
+
applyTheme(theme);
|
|
19
|
+
applied.current = true;
|
|
20
|
+
}
|
|
21
|
+
}, [theme]);
|
|
22
|
+
}
|
|
23
|
+
function ThemeControllerToggle({
|
|
24
|
+
defaultTheme = "light",
|
|
25
|
+
lightTheme = "light",
|
|
26
|
+
darkTheme = "dark",
|
|
27
|
+
onThemeChange,
|
|
28
|
+
className,
|
|
29
|
+
label,
|
|
30
|
+
size = "md",
|
|
31
|
+
children
|
|
32
|
+
}) {
|
|
33
|
+
const [checked, setChecked] = useState(() => {
|
|
34
|
+
if (typeof window === "undefined") return false;
|
|
35
|
+
return (localStorage.getItem("theme") || defaultTheme) === darkTheme;
|
|
36
|
+
});
|
|
37
|
+
useApplyThemeOnMount(checked ? darkTheme : lightTheme);
|
|
38
|
+
const handleChange = (newChecked) => {
|
|
39
|
+
const newTheme = newChecked ? darkTheme : lightTheme;
|
|
40
|
+
setChecked(newChecked);
|
|
41
|
+
applyTheme(newTheme);
|
|
42
|
+
localStorage.setItem("theme", newTheme);
|
|
43
|
+
onThemeChange == null ? void 0 : onThemeChange(newTheme);
|
|
44
|
+
};
|
|
45
|
+
if (children) {
|
|
46
|
+
return /* @__PURE__ */ jsx("div", { className, children: children({ isDark: checked, checked, toggle: handleChange }) });
|
|
47
|
+
}
|
|
48
|
+
const toggleEl = /* @__PURE__ */ jsx(
|
|
49
|
+
"input",
|
|
50
|
+
{
|
|
51
|
+
type: "checkbox",
|
|
52
|
+
className: cn("toggle theme-controller", `toggle-${size}`),
|
|
53
|
+
checked,
|
|
54
|
+
value: darkTheme,
|
|
55
|
+
onChange: (e) => handleChange(e.target.checked)
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
if (!label) return /* @__PURE__ */ jsx("div", { className, children: toggleEl });
|
|
59
|
+
return /* @__PURE__ */ jsxs("label", { className: cn("flex cursor-pointer items-center gap-3", className), children: [
|
|
60
|
+
toggleEl,
|
|
61
|
+
/* @__PURE__ */ jsx("span", { className: "text-base-content", children: label })
|
|
62
|
+
] });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
ThemeControllerToggle
|
|
67
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadValues,
|
|
5
|
+
cn
|
|
6
|
+
} from "./chunk-NJKWNMJF.js";
|
|
7
|
+
|
|
8
|
+
// src/base/toggle.tsx
|
|
9
|
+
import { forwardRef, useState, useEffect } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
var Toggle = forwardRef(function Toggle2(_a, ref) {
|
|
12
|
+
var _b = _a, {
|
|
13
|
+
color = "primary",
|
|
14
|
+
size = "md",
|
|
15
|
+
label,
|
|
16
|
+
description,
|
|
17
|
+
indeterminate = false,
|
|
18
|
+
containerClassName,
|
|
19
|
+
labelClassName,
|
|
20
|
+
descriptionClassName,
|
|
21
|
+
className,
|
|
22
|
+
disabled,
|
|
23
|
+
checked,
|
|
24
|
+
defaultChecked,
|
|
25
|
+
onChange
|
|
26
|
+
} = _b, props = __objRest(_b, [
|
|
27
|
+
"color",
|
|
28
|
+
"size",
|
|
29
|
+
"label",
|
|
30
|
+
"description",
|
|
31
|
+
"indeterminate",
|
|
32
|
+
"containerClassName",
|
|
33
|
+
"labelClassName",
|
|
34
|
+
"descriptionClassName",
|
|
35
|
+
"className",
|
|
36
|
+
"disabled",
|
|
37
|
+
"checked",
|
|
38
|
+
"defaultChecked",
|
|
39
|
+
"onChange"
|
|
40
|
+
]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (indeterminate && ref) {
|
|
43
|
+
const input = ref.current;
|
|
44
|
+
if (input) input.indeterminate = true;
|
|
45
|
+
}
|
|
46
|
+
}, [ref, indeterminate]);
|
|
47
|
+
const toggleEl = /* @__PURE__ */ jsx(
|
|
48
|
+
"input",
|
|
49
|
+
__spreadValues({
|
|
50
|
+
ref,
|
|
51
|
+
type: "checkbox",
|
|
52
|
+
className: cn(`toggle-${color}`, `toggle-${size}`, className),
|
|
53
|
+
disabled,
|
|
54
|
+
checked,
|
|
55
|
+
defaultChecked,
|
|
56
|
+
onChange,
|
|
57
|
+
"data-indeterminate": indeterminate
|
|
58
|
+
}, props)
|
|
59
|
+
);
|
|
60
|
+
if (!label) return toggleEl;
|
|
61
|
+
return /* @__PURE__ */ jsxs(
|
|
62
|
+
"label",
|
|
63
|
+
{
|
|
64
|
+
className: cn(
|
|
65
|
+
"flex items-start gap-3",
|
|
66
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
67
|
+
containerClassName
|
|
68
|
+
),
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center pt-0.5", children: toggleEl }),
|
|
71
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
72
|
+
/* @__PURE__ */ jsx("span", { className: cn("text-base-content cursor-pointer", labelClassName), children: label }),
|
|
73
|
+
description && /* @__PURE__ */ jsx("span", { className: cn("text-base-content/60 text-sm", descriptionClassName), children: description })
|
|
74
|
+
] })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
function ToggleGroup({
|
|
80
|
+
items,
|
|
81
|
+
value,
|
|
82
|
+
defaultValue = [],
|
|
83
|
+
onChange,
|
|
84
|
+
color = "primary",
|
|
85
|
+
size = "md",
|
|
86
|
+
controlled = false,
|
|
87
|
+
className
|
|
88
|
+
}) {
|
|
89
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
90
|
+
const selectedValues = controlled ? value != null ? value : internalValue : internalValue;
|
|
91
|
+
const toggle = (itemValue) => {
|
|
92
|
+
const next = selectedValues.includes(itemValue) ? selectedValues.filter((v) => v !== itemValue) : [...selectedValues, itemValue];
|
|
93
|
+
if (!controlled) setInternalValue(next);
|
|
94
|
+
onChange == null ? void 0 : onChange(next);
|
|
95
|
+
};
|
|
96
|
+
return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-3", className), children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
97
|
+
"label",
|
|
98
|
+
{
|
|
99
|
+
className: cn(
|
|
100
|
+
"flex items-center gap-3",
|
|
101
|
+
item.disabled && "cursor-not-allowed opacity-50"
|
|
102
|
+
),
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
"input",
|
|
106
|
+
{
|
|
107
|
+
type: "checkbox",
|
|
108
|
+
className: cn(`toggle-${color}`, `toggle-${size}`),
|
|
109
|
+
checked: selectedValues.includes(item.value),
|
|
110
|
+
disabled: item.disabled,
|
|
111
|
+
onChange: () => !item.disabled && toggle(item.value)
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsx("span", { className: "text-base-content cursor-pointer", children: item.label })
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
item.value
|
|
118
|
+
)) });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export {
|
|
122
|
+
Toggle,
|
|
123
|
+
ToggleGroup
|
|
124
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues,
|
|
6
|
+
cn
|
|
7
|
+
} from "./chunk-NJKWNMJF.js";
|
|
8
|
+
|
|
9
|
+
// src/base/modal.tsx
|
|
10
|
+
import { forwardRef, useRef, useCallback } from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var Modal = forwardRef(
|
|
13
|
+
(_a, ref) => {
|
|
14
|
+
var _b = _a, { children, className, closeOnBackdrop = true, placement, boxClassName } = _b, props = __objRest(_b, ["children", "className", "closeOnBackdrop", "placement", "boxClassName"]);
|
|
15
|
+
return /* @__PURE__ */ jsxs(
|
|
16
|
+
"dialog",
|
|
17
|
+
__spreadProps(__spreadValues({
|
|
18
|
+
ref,
|
|
19
|
+
className: cn("modal", placement && `modal-${placement}`, className)
|
|
20
|
+
}, props), {
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsx("div", { className: cn("modal-box", boxClassName), children }),
|
|
23
|
+
closeOnBackdrop && /* @__PURE__ */ jsx("form", { method: "dialog", className: "modal-backdrop", children: /* @__PURE__ */ jsx("button", { children: "esc" }) })
|
|
24
|
+
]
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
Modal.displayName = "Modal";
|
|
30
|
+
function useModal() {
|
|
31
|
+
const ref = useRef(null);
|
|
32
|
+
const open = useCallback(() => {
|
|
33
|
+
var _a;
|
|
34
|
+
(_a = ref.current) == null ? void 0 : _a.showModal();
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
var _a2, _b;
|
|
37
|
+
(_b = (_a2 = ref.current) == null ? void 0 : _a2.querySelector("input, [autofocus]")) == null ? void 0 : _b.focus();
|
|
38
|
+
}, 0);
|
|
39
|
+
}, []);
|
|
40
|
+
const close = useCallback(() => {
|
|
41
|
+
var _a;
|
|
42
|
+
return (_a = ref.current) == null ? void 0 : _a.close();
|
|
43
|
+
}, []);
|
|
44
|
+
return { ref, open, close };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
Modal,
|
|
49
|
+
useModal
|
|
50
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk7HHY2WDFcjs = require('./chunk-7HHY2WDF.cjs');
|
|
4
|
+
|
|
5
|
+
// src/base/breadcrumbs.tsx
|
|
6
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
7
|
+
function Breadcrumb({ children, className }) {
|
|
8
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk7HHY2WDFcjs.cn.call(void 0, "breadcrumbs text-sm", className), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { children }) });
|
|
9
|
+
}
|
|
10
|
+
function BreadcrumbItem({ children, className }) {
|
|
11
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { className: _chunk7HHY2WDFcjs.cn.call(void 0, className), children });
|
|
12
|
+
}
|
|
13
|
+
function BreadcrumbPage({ children, className }) {
|
|
14
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _chunk7HHY2WDFcjs.cn.call(void 0, className), children });
|
|
15
|
+
}
|
|
16
|
+
function BreadcrumbList({ children }) {
|
|
17
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
exports.Breadcrumb = Breadcrumb; exports.BreadcrumbItem = BreadcrumbItem; exports.BreadcrumbPage = BreadcrumbPage; exports.BreadcrumbList = BreadcrumbList;
|