tw-react-components 0.0.148 → 0.0.150

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/index.cjs.js DELETED
@@ -1,2273 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var clsx = require('clsx');
6
- var tailwindMerge = require('tailwind-merge');
7
- var dayjs = require('dayjs');
8
- var advancedFormat = require('dayjs/plugin/advancedFormat');
9
- var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
10
- var lucideReact = require('lucide-react');
11
- var localeData = require('dayjs/plugin/localeData');
12
- var TooltipPrimitive = require('@radix-ui/react-tooltip');
13
- var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
14
- var reactHookForm = require('react-hook-form');
15
- var DialogPrimitive = require('@radix-ui/react-dialog');
16
- var classVarianceAuthority = require('class-variance-authority');
17
- var core = require('@dnd-kit/core');
18
- var modifiers = require('@dnd-kit/modifiers');
19
- var sortable = require('@dnd-kit/sortable');
20
- var utilities = require('@dnd-kit/utilities');
21
- var reactRouterDom = require('react-router-dom');
22
- var reactSlot = require('@radix-ui/react-slot');
23
- var SeparatorPrimitive = require('@radix-ui/react-separator');
24
- var PopoverPrimitive = require('@radix-ui/react-popover');
25
- var SwitchPrimitives = require('@radix-ui/react-switch');
26
- var TabsPrimitive = require('@radix-ui/react-tabs');
27
-
28
- function _interopNamespaceDefault(e) {
29
- var n = Object.create(null);
30
- if (e) {
31
- Object.keys(e).forEach(function (k) {
32
- if (k !== 'default') {
33
- var d = Object.getOwnPropertyDescriptor(e, k);
34
- Object.defineProperty(n, k, d.get ? d : {
35
- enumerable: true,
36
- get: function () { return e[k]; }
37
- });
38
- }
39
- });
40
- }
41
- n.default = e;
42
- return Object.freeze(n);
43
- }
44
-
45
- var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CollapsiblePrimitive);
46
- var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TooltipPrimitive);
47
- var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DropdownMenuPrimitive);
48
- var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
49
- var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SeparatorPrimitive);
50
- var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
51
- var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespaceDefault(SwitchPrimitives);
52
- var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TabsPrimitive);
53
-
54
- /******************************************************************************
55
- Copyright (c) Microsoft Corporation.
56
-
57
- Permission to use, copy, modify, and/or distribute this software for any
58
- purpose with or without fee is hereby granted.
59
-
60
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
61
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
62
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
63
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
64
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
65
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
66
- PERFORMANCE OF THIS SOFTWARE.
67
- ***************************************************************************** */
68
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
69
-
70
-
71
- function __rest(s, e) {
72
- var t = {};
73
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
74
- t[p] = s[p];
75
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
76
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
77
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
78
- t[p[i]] = s[p[i]];
79
- }
80
- return t;
81
- }
82
-
83
- function __awaiter(thisArg, _arguments, P, generator) {
84
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
85
- return new (P || (P = Promise))(function (resolve, reject) {
86
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
87
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
88
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
89
- step((generator = generator.apply(thisArg, _arguments || [])).next());
90
- });
91
- }
92
-
93
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
94
- var e = new Error(message);
95
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
96
- };
97
-
98
- function cn(...inputs) {
99
- return tailwindMerge.twMerge(clsx.clsx(inputs));
100
- }
101
-
102
- function compareDates(date1, date2, startOf) {
103
- if (startOf) {
104
- date1 = dayjs(date1).startOf(startOf).toDate();
105
- date2 = dayjs(date2).startOf(startOf).toDate();
106
- }
107
- return date1.getTime() - date2.getTime();
108
- }
109
-
110
- function generalComparator(a, b) {
111
- if (Array.isArray(a) && Array.isArray(b)) {
112
- return a.length - b.length;
113
- }
114
- if (typeof a === 'number' && typeof b === 'number') {
115
- return a - b;
116
- }
117
- if (typeof a === 'string' && typeof b === 'string') {
118
- return a.localeCompare(b);
119
- }
120
- return 0;
121
- }
122
-
123
- dayjs.extend(advancedFormat);
124
- function getDisplayDate(date, format, locale) {
125
- return (locale ? dayjs(date).locale(locale) : dayjs(date)).format(format);
126
- }
127
-
128
- function getValueFromCookie(key, _default) {
129
- var _a, _b;
130
- const transformers = {
131
- string: String,
132
- boolean: (value) => value === 'true',
133
- };
134
- return typeof window !== 'undefined'
135
- ? transformers[typeof _default]((_b = (_a = document.cookie
136
- .split('; ')
137
- .find((row) => row.startsWith(key))) === null || _a === void 0 ? void 0 : _a.split('=')[1]) !== null && _b !== void 0 ? _b : _default)
138
- : _default;
139
- }
140
-
141
- function isEmpty(s) {
142
- if (Array.isArray(s))
143
- return s.length === 0;
144
- return [null, undefined, ''].includes(s);
145
- }
146
-
147
- function mergeRefs(refs) {
148
- return (value) => {
149
- refs.forEach((ref) => {
150
- if (typeof ref === 'function') {
151
- ref(value);
152
- }
153
- else if (ref != null) {
154
- ref.current = value;
155
- }
156
- });
157
- };
158
- }
159
-
160
- function resolveTargetObject(payload, fieldChain, defaultValue) {
161
- if (!fieldChain.length) {
162
- return payload === null ? payload : payload || defaultValue;
163
- }
164
- if (typeof payload !== 'object' || !payload) {
165
- if (defaultValue)
166
- return defaultValue;
167
- throw new Error(`Could not resolve field ${fieldChain[0]} because payload is not an object!`);
168
- }
169
- const [key, ...rest] = fieldChain;
170
- if (Array.isArray(payload)) {
171
- if (Number.isNaN(+key)) {
172
- throw new Error('The payload is an array, thus the key should be a number!');
173
- }
174
- const index = +key;
175
- if (index < 0 || index >= payload.length) {
176
- throw new Error('Index out of payload boundaries!');
177
- }
178
- return resolveTargetObject(payload[index], rest, defaultValue);
179
- }
180
- return resolveTargetObject(payload[key], rest, defaultValue);
181
- }
182
-
183
- const variantClassNames = {
184
- filled: {
185
- slate: {
186
- base: 'bg-slate-100 dark:bg-slate-800',
187
- hover: 'hover:bg-slate-200 dark:hover:bg-slate-700',
188
- focus: 'focus:bg-slate-200 dark:focus:bg-slate-700',
189
- active: 'active:bg-slate-300 dark:active:bg-slate-800/50',
190
- },
191
- gray: {
192
- base: 'text-white bg-gray-500 dark:bg-gray-600',
193
- hover: 'hover:bg-gray-400 dark:hover:bg-gray-500',
194
- focus: 'focus:bg-gray-400 dark:focus:bg-gray-500',
195
- active: 'active:bg-gray-600 dark:active:bg-gray-700',
196
- },
197
- zinc: {
198
- base: 'text-white bg-zinc-500 dark:bg-zinc-600',
199
- hover: 'hover:bg-zinc-400 dark:hover:bg-zinc-500',
200
- focus: 'focus:bg-zinc-400 dark:focus:bg-zinc-500',
201
- active: 'active:bg-zinc-600 dark:active:bg-zinc-700',
202
- },
203
- neutral: {
204
- base: 'text-white bg-neutral-500 dark:bg-neutral-600',
205
- hover: 'hover:bg-neutral-400 dark:hover:bg-neutral-500',
206
- focus: 'focus:bg-neutral-400 dark:focus:bg-neutral-500',
207
- active: 'active:bg-neutral-600 dark:active:bg-neutral-700',
208
- },
209
- stone: {
210
- base: 'text-white bg-stone-500 dark:bg-stone-600',
211
- hover: 'hover:bg-stone-400 dark:hover:bg-stone-500',
212
- focus: 'focus:bg-stone-400 dark:focus:bg-stone-500',
213
- active: 'active:bg-stone-600 dark:active:bg-stone-700',
214
- },
215
- red: {
216
- base: 'text-white bg-red-500 dark:bg-red-600',
217
- hover: 'hover:bg-red-400 dark:hover:bg-red-500',
218
- focus: 'focus:bg-red-400 dark:focus:bg-red-500',
219
- active: 'active:bg-red-600 dark:active:bg-red-700',
220
- },
221
- orange: {
222
- base: 'text-white bg-orange-500 dark:bg-orange-600',
223
- hover: 'hover:bg-orange-400 dark:hover:bg-orange-500',
224
- focus: 'focus:bg-orange-400 dark:focus:bg-orange-500',
225
- active: 'active:bg-orange-600 dark:active:bg-orange-700',
226
- },
227
- amber: {
228
- base: 'text-white bg-amber-500 dark:bg-amber-600',
229
- hover: 'hover:bg-amber-400 dark:hover:bg-amber-500',
230
- focus: 'focus:bg-amber-400 dark:focus:bg-amber-500',
231
- active: 'active:bg-amber-600 dark:active:bg-amber-700',
232
- },
233
- yellow: {
234
- base: 'text-white bg-yellow-500 dark:bg-yellow-600',
235
- hover: 'hover:bg-yellow-400 dark:hover:bg-yellow-500',
236
- focus: 'focus:bg-yellow-400 dark:focus:bg-yellow-500',
237
- active: 'active:bg-yellow-600 dark:active:bg-yellow-700',
238
- },
239
- lime: {
240
- base: 'text-white bg-lime-500 dark:bg-lime-600',
241
- hover: 'hover:bg-lime-400 dark:hover:bg-lime-500',
242
- focus: 'focus:bg-lime-400 dark:focus:bg-lime-500',
243
- active: 'active:bg-lime-600 dark:active:bg-lime-700',
244
- },
245
- green: {
246
- base: 'text-white bg-green-500 dark:bg-green-600',
247
- hover: 'hover:bg-green-400 dark:hover:bg-green-500',
248
- focus: 'focus:bg-green-400 dark:focus:bg-green-500',
249
- active: 'active:bg-green-600 dark:active:bg-green-700',
250
- },
251
- emerald: {
252
- base: 'text-white bg-emerald-500 dark:bg-emerald-600',
253
- hover: 'hover:bg-emerald-400 dark:hover:bg-emerald-500',
254
- focus: 'focus:bg-emerald-400 dark:focus:bg-emerald-500',
255
- active: 'active:bg-emerald-600 dark:active:bg-emerald-700',
256
- },
257
- teal: {
258
- base: 'text-white bg-teal-500 dark:bg-teal-600',
259
- hover: 'hover:bg-teal-400 dark:hover:bg-teal-500',
260
- focus: 'focus:bg-teal-400 dark:focus:bg-teal-500',
261
- active: 'active:bg-teal-600 dark:active:bg-teal-700',
262
- },
263
- cyan: {
264
- base: 'text-white bg-cyan-500 dark:bg-cyan-600',
265
- hover: 'hover:bg-cyan-400 dark:hover:bg-cyan-500',
266
- focus: 'focus:bg-cyan-400 dark:focus:bg-cyan-500',
267
- active: 'active:bg-cyan-600 dark:active:bg-cyan-700',
268
- },
269
- sky: {
270
- base: 'text-white bg-sky-500 dark:bg-sky-600',
271
- hover: 'hover:bg-sky-400 dark:hover:bg-sky-500',
272
- focus: 'focus:bg-sky-400 dark:focus:bg-sky-500',
273
- active: 'active:bg-sky-600 dark:active:bg-sky-700',
274
- },
275
- blue: {
276
- base: 'text-white bg-blue-500 dark:bg-blue-600',
277
- hover: 'hover:bg-blue-400 dark:hover:bg-blue-500',
278
- focus: 'focus:bg-blue-400 dark:focus:bg-blue-500',
279
- active: 'active:bg-blue-600 dark:active:bg-blue-700',
280
- },
281
- indigo: {
282
- base: 'text-white bg-indigo-500 dark:bg-indigo-600',
283
- hover: 'hover:bg-indigo-400 dark:hover:bg-indigo-500',
284
- focus: 'focus:bg-indigo-400 dark:focus:bg-indigo-500',
285
- active: 'active:bg-indigo-600 dark:active:bg-indigo-700',
286
- },
287
- violet: {
288
- base: 'text-white bg-violet-500 dark:bg-violet-600',
289
- hover: 'hover:bg-violet-400 dark:hover:bg-violet-500',
290
- focus: 'focus:bg-violet-400 dark:focus:bg-violet-500',
291
- active: 'active:bg-violet-600 dark:active:bg-violet-700',
292
- },
293
- fuchsia: {
294
- base: 'text-white bg-fuchsia-500 dark:bg-fuchsia-600',
295
- hover: 'hover:bg-fuchsia-400 dark:hover:bg-fuchsia-500',
296
- focus: 'focus:bg-fuchsia-400 dark:focus:bg-fuchsia-500',
297
- active: 'active:bg-fuchsia-600 dark:active:bg-fuchsia-700',
298
- },
299
- purple: {
300
- base: 'text-white bg-purple-500 dark:bg-purple-600',
301
- hover: 'hover:bg-purple-400 dark:hover:bg-purple-500',
302
- focus: 'focus:bg-purple-400 dark:focus:bg-purple-500',
303
- active: 'active:bg-purple-600 dark:active:bg-purple-700',
304
- },
305
- pink: {
306
- base: 'text-white bg-pink-500 dark:bg-pink-600',
307
- hover: 'hover:bg-pink-400 dark:hover:bg-pink-500',
308
- focus: 'focus:bg-pink-400 dark:focus:bg-pink-500',
309
- active: 'active:bg-pink-600 dark:active:bg-pink-700',
310
- },
311
- rose: {
312
- base: 'text-white bg-rose-500 dark:bg-rose-600',
313
- hover: 'hover:bg-rose-400 dark:hover:bg-rose-500',
314
- focus: 'focus:bg-rose-400 dark:focus:bg-rose-500',
315
- active: 'active:bg-rose-600 dark:active:bg-rose-700',
316
- },
317
- },
318
- outlined: {
319
- slate: {
320
- base: 'border-2 dark:border-slate-600',
321
- hover: 'hover:bg-slate-200 dark:hover:bg-slate-600',
322
- focus: 'focus:bg-slate-200 dark:focus:bg-slate-600',
323
- active: 'active:bg-slate-300 active:border-slate-300 dark:active:bg-slate-700 dark:active:border-slate-700',
324
- },
325
- gray: {
326
- base: 'border-2 border-gray-500 text-gray-600 dark:border-gray-600 dark:text-gray-500',
327
- hover: 'hover:text-white hover:bg-gray-500 dark:hover:text-white dark:hover:bg-gray-600',
328
- focus: 'focus:text-white focus:bg-gray-500 dark:focus:text-white dark:focus:bg-gray-600',
329
- active: 'active:bg-gray-600 active:border-gray-600 dark:active:bg-gray-700 dark:active:border-gray-700',
330
- },
331
- zinc: {
332
- base: 'border-2 border-zinc-500 text-zinc-600 dark:border-zinc-600 dark:text-zinc-500',
333
- hover: 'hover:text-white hover:bg-zinc-500 dark:hover:text-white dark:hover:bg-zinc-600',
334
- focus: 'focus:text-white focus:bg-zinc-500 dark:focus:text-white dark:focus:bg-zinc-600',
335
- active: 'active:bg-zinc-600 active:border-zinc-600 dark:active:bg-zinc-700 dark:active:border-zinc-700',
336
- },
337
- neutral: {
338
- base: 'border-2 border-neutral-500 text-neutral-600 dark:border-neutral-600 dark:text-neutral-500',
339
- hover: 'hover:text-white hover:bg-neutral-500 dark:hover:text-white dark:hover:bg-neutral-600',
340
- focus: 'focus:text-white focus:bg-neutral-500 dark:focus:text-white dark:focus:bg-neutral-600',
341
- active: 'active:bg-neutral-600 active:border-neutral-600 dark:active:bg-neutral-700 dark:active:border-neutral-700',
342
- },
343
- stone: {
344
- base: 'border-2 border-stone-500 text-stone-600 dark:border-stone-600 dark:text-stone-500',
345
- hover: 'hover:text-white hover:bg-stone-500 dark:hover:text-white dark:hover:bg-stone-600',
346
- focus: 'focus:text-white focus:bg-stone-500 dark:focus:text-white dark:focus:bg-stone-600',
347
- active: 'active:bg-stone-600 active:border-stone-600 dark:active:bg-stone-700 dark:active:border-stone-700',
348
- },
349
- red: {
350
- base: 'border-2 border-red-500 text-red-600 dark:border-red-600 dark:text-red-500',
351
- hover: 'hover:text-white hover:bg-red-500 dark:hover:text-white dark:hover:bg-red-600',
352
- focus: 'focus:text-white focus:bg-red-500 dark:focus:text-white dark:focus:bg-red-600',
353
- active: 'active:bg-red-600 active:border-red-600 dark:active:bg-red-700 dark:active:border-red-700',
354
- },
355
- orange: {
356
- base: 'border-2 border-orange-500 text-orange-600 dark:border-orange-600 dark:text-orange-500',
357
- hover: 'hover:text-white hover:bg-orange-500 dark:hover:text-white dark:hover:bg-orange-600',
358
- focus: 'focus:text-white focus:bg-orange-500 dark:focus:text-white dark:focus:bg-orange-600',
359
- active: 'active:bg-orange-600 active:border-orange-600 dark:active:bg-orange-700 dark:active:border-orange-700',
360
- },
361
- amber: {
362
- base: 'border-2 border-amber-500 text-amber-600 dark:border-amber-600 dark:text-amber-500',
363
- hover: 'hover:text-white hover:bg-amber-500 dark:hover:text-white dark:hover:bg-amber-600',
364
- focus: 'focus:text-white focus:bg-amber-500 dark:focus:text-white dark:focus:bg-amber-600',
365
- active: 'active:bg-amber-600 active:border-amber-600 dark:active:bg-amber-700 dark:active:border-amber-700',
366
- },
367
- yellow: {
368
- base: 'border-2 border-yellow-500 text-yellow-600 dark:border-yellow-600 dark:text-yellow-500',
369
- hover: 'hover:text-white hover:bg-yellow-500 dark:hover:text-white dark:hover:bg-yellow-600',
370
- focus: 'focus:text-white focus:bg-yellow-500 dark:focus:text-white dark:focus:bg-yellow-600',
371
- active: 'active:bg-yellow-600 active:border-yellow-600 dark:active:bg-yellow-700 dark:active:border-yellow-700',
372
- },
373
- lime: {
374
- base: 'border-2 border-lime-500 text-lime-600 dark:border-lime-600 dark:text-lime-500',
375
- hover: 'hover:text-white hover:bg-lime-500 dark:hover:text-white dark:hover:bg-lime-600',
376
- focus: 'focus:text-white focus:bg-lime-500 dark:focus:text-white dark:focus:bg-lime-600',
377
- active: 'active:bg-lime-600 active:border-lime-600 dark:active:bg-lime-700 dark:active:border-lime-700',
378
- },
379
- green: {
380
- base: 'border-2 border-green-500 text-green-600 dark:border-green-600 dark:text-green-500',
381
- hover: 'hover:text-white hover:bg-green-500 dark:hover:text-white dark:hover:bg-green-600',
382
- focus: 'focus:text-white focus:bg-green-500 dark:focus:text-white dark:focus:bg-green-600',
383
- active: 'active:bg-green-600 active:border-green-600 dark:active:bg-green-700 dark:active:border-green-700',
384
- },
385
- emerald: {
386
- base: 'border-2 border-emerald-500 text-emerald-600 dark:border-emerald-600 dark:text-emerald-500',
387
- hover: 'hover:text-white hover:bg-emerald-500 dark:hover:text-white dark:hover:bg-emerald-600',
388
- focus: 'focus:text-white focus:bg-emerald-500 dark:focus:text-white dark:focus:bg-emerald-600',
389
- active: 'active:bg-emerald-600 active:border-emerald-600 dark:active:bg-emerald-700 dark:active:border-emerald-700',
390
- },
391
- teal: {
392
- base: 'border-2 border-teal-500 text-teal-600 dark:border-teal-600 dark:text-teal-500',
393
- hover: 'hover:text-white hover:bg-teal-500 dark:hover:text-white dark:hover:bg-teal-600',
394
- focus: 'focus:text-white focus:bg-teal-500 dark:focus:text-white dark:focus:bg-teal-600',
395
- active: 'active:bg-teal-600 active:border-teal-600 dark:active:bg-teal-700 dark:active:border-teal-700',
396
- },
397
- cyan: {
398
- base: 'border-2 border-cyan-500 text-cyan-600 dark:border-cyan-600 dark:text-cyan-500',
399
- hover: 'hover:text-white hover:bg-cyan-500 dark:hover:text-white dark:hover:bg-cyan-600',
400
- focus: 'focus:text-white focus:bg-cyan-500 dark:focus:text-white dark:focus:bg-cyan-600',
401
- active: 'active:bg-cyan-600 active:border-cyan-600 dark:active:bg-cyan-700 dark:active:border-cyan-700',
402
- },
403
- sky: {
404
- base: 'border-2 border-sky-500 text-sky-600 dark:border-sky-600 dark:text-sky-500',
405
- hover: 'hover:text-white hover:bg-sky-500 dark:hover:text-white dark:hover:bg-sky-600',
406
- focus: 'focus:text-white focus:bg-sky-500 dark:focus:text-white dark:focus:bg-sky-600',
407
- active: 'active:bg-sky-600 active:border-sky-600 dark:active:bg-sky-700 dark:active:border-sky-700',
408
- },
409
- blue: {
410
- base: 'border-2 border-blue-500 text-blue-600 dark:border-blue-600 dark:text-blue-500',
411
- hover: 'hover:text-white hover:bg-blue-500 dark:hover:text-white dark:hover:bg-blue-600',
412
- focus: 'focus:text-white focus:bg-blue-500 dark:focus:text-white dark:focus:bg-blue-600',
413
- active: 'active:bg-blue-600 active:border-blue-600 dark:active:bg-blue-700 dark:active:border-blue-700',
414
- },
415
- indigo: {
416
- base: 'border-2 border-indigo-500 text-indigo-600 dark:border-indigo-600 dark:text-indigo-500',
417
- hover: 'hover:text-white hover:bg-indigo-500 dark:hover:text-white dark:hover:bg-indigo-600',
418
- focus: 'focus:text-white focus:bg-indigo-500 dark:focus:text-white dark:focus:bg-indigo-600',
419
- active: 'active:bg-indigo-600 active:border-indigo-600 dark:active:bg-indigo-700 dark:active:border-indigo-700',
420
- },
421
- violet: {
422
- base: 'border-2 border-violet-500 text-violet-600 dark:border-violet-600 dark:text-violet-500',
423
- hover: 'hover:text-white hover:bg-violet-500 dark:hover:text-white dark:hover:bg-violet-600',
424
- focus: 'focus:text-white focus:bg-violet-500 dark:focus:text-white dark:focus:bg-violet-600',
425
- active: 'active:bg-violet-600 active:border-violet-600 dark:active:bg-violet-700 dark:active:border-violet-700',
426
- },
427
- fuchsia: {
428
- base: 'border-2 border-fuchsia-500 text-fuchsia-600 dark:border-fuchsia-600 dark:text-fuchsia-500',
429
- hover: 'hover:text-white hover:bg-fuchsia-500 dark:hover:text-white dark:hover:bg-fuchsia-600',
430
- focus: 'focus:text-white focus:bg-fuchsia-500 dark:focus:text-white dark:focus:bg-fuchsia-600',
431
- active: 'active:bg-fuchsia-600 active:border-fuchsia-600 dark:active:bg-fuchsia-700 dark:active:border-fuchsia-700',
432
- },
433
- purple: {
434
- base: 'border-2 border-purple-500 text-purple-600 dark:border-purple-600 dark:text-purple-500',
435
- hover: 'hover:text-white hover:bg-purple-500 dark:hover:text-white dark:hover:bg-purple-600',
436
- focus: 'focus:text-white focus:bg-purple-500 dark:focus:text-white dark:focus:bg-purple-600',
437
- active: 'active:bg-purple-600 active:border-purple-600 dark:active:bg-purple-700 dark:active:border-purple-700',
438
- },
439
- pink: {
440
- base: 'border-2 border-pink-500 text-pink-600 dark:border-pink-600 dark:text-pink-500',
441
- hover: 'hover:text-white hover:bg-pink-500 dark:hover:text-white dark:hover:bg-pink-600',
442
- focus: 'focus:text-white focus:bg-pink-500 dark:focus:text-white dark:focus:bg-pink-600',
443
- active: 'active:bg-pink-600 active:border-pink-600 dark:active:bg-pink-700 dark:active:border-pink-700',
444
- },
445
- rose: {
446
- base: 'border-2 border-rose-500 text-rose-600 dark:border-rose-600 dark:text-rose-500',
447
- hover: 'hover:text-white hover:bg-rose-500 dark:hover:text-white dark:hover:bg-rose-600',
448
- focus: 'focus:text-white focus:bg-rose-500 dark:focus:text-white dark:focus:bg-rose-600',
449
- active: 'active:bg-rose-600 active:border-rose-600 dark:active:bg-rose-700 dark:active:border-rose-700',
450
- },
451
- },
452
- text: {
453
- slate: {
454
- base: 'bg-transparent',
455
- hover: 'hover:bg-slate-200 dark:hover:bg-slate-700',
456
- focus: 'focus:bg-slate-200 dark:focus:bg-slate-700',
457
- active: 'active:bg-slate-300 dark:active:bg-slate-800',
458
- },
459
- gray: {
460
- base: 'bg-transparent',
461
- hover: 'hover:text-white hover:bg-gray-500 dark:hover:bg-gray-600',
462
- focus: 'focus:text-white focus:bg-gray-500 dark:focus:bg-gray-600',
463
- active: 'active:bg-gray-600 dark:active:bg-gray-700',
464
- },
465
- zinc: {
466
- base: 'bg-transparent',
467
- hover: 'hover:text-white hover:bg-zinc-500 dark:hover:bg-zinc-600',
468
- focus: 'focus:text-white focus:bg-zinc-500 dark:focus:bg-zinc-600',
469
- active: 'active:bg-zinc-600 dark:active:bg-zinc-700',
470
- },
471
- neutral: {
472
- base: 'bg-transparent',
473
- hover: 'hover:text-white hover:bg-neutral-500 dark:hover:bg-neutral-600',
474
- focus: 'focus:text-white focus:bg-neutral-500 dark:focus:bg-neutral-600',
475
- active: 'active:bg-neutral-600 dark:active:bg-neutral-700',
476
- },
477
- stone: {
478
- base: 'bg-transparent',
479
- hover: 'hover:text-white hover:bg-stone-500 dark:hover:bg-stone-600',
480
- focus: 'focus:text-white focus:bg-stone-500 dark:focus:bg-stone-600',
481
- active: 'active:bg-stone-600 dark:active:bg-stone-700',
482
- },
483
- red: {
484
- base: 'bg-transparent',
485
- hover: 'hover:text-white hover:bg-red-500 dark:hover:bg-red-600',
486
- focus: 'focus:text-white focus:bg-red-500 dark:focus:bg-red-600',
487
- active: 'active:bg-red-600 dark:active:bg-red-700',
488
- },
489
- orange: {
490
- base: 'bg-transparent',
491
- hover: 'hover:text-white hover:bg-orange-500 dark:hover:bg-orange-600',
492
- focus: 'focus:text-white focus:bg-orange-500 dark:focus:bg-orange-600',
493
- active: 'active:bg-orange-600 dark:active:bg-orange-700',
494
- },
495
- amber: {
496
- base: 'bg-transparent',
497
- hover: 'hover:text-white hover:bg-amber-500 dark:hover:bg-amber-600',
498
- focus: 'focus:text-white focus:bg-amber-500 dark:focus:bg-amber-600',
499
- active: 'active:bg-amber-600 dark:active:bg-amber-700',
500
- },
501
- yellow: {
502
- base: 'bg-transparent',
503
- hover: 'hover:text-white hover:bg-yellow-500 dark:hover:bg-yellow-600',
504
- focus: 'focus:text-white focus:bg-yellow-500 dark:focus:bg-yellow-600',
505
- active: 'active:bg-yellow-600 dark:active:bg-yellow-700',
506
- },
507
- lime: {
508
- base: 'bg-transparent',
509
- hover: 'hover:text-white hover:bg-lime-500 dark:hover:bg-lime-600',
510
- focus: 'focus:text-white focus:bg-lime-500 dark:focus:bg-lime-600',
511
- active: 'active:bg-lime-600 dark:active:bg-lime-700',
512
- },
513
- green: {
514
- base: 'bg-transparent',
515
- hover: 'hover:text-white hover:bg-green-500 dark:hover:bg-green-600',
516
- focus: 'focus:text-white focus:bg-green-500 dark:focus:bg-green-600',
517
- active: 'active:bg-green-600 dark:active:bg-green-700',
518
- },
519
- emerald: {
520
- base: 'bg-transparent',
521
- hover: 'hover:text-white hover:bg-emerald-500 dark:hover:bg-emerald-600',
522
- focus: 'focus:text-white focus:bg-emerald-500 dark:focus:bg-emerald-600',
523
- active: 'active:bg-emerald-600 dark:active:bg-emerald-700',
524
- },
525
- teal: {
526
- base: 'bg-transparent',
527
- hover: 'hover:text-white hover:bg-teal-500 dark:hover:bg-teal-600',
528
- focus: 'focus:text-white focus:bg-teal-500 dark:focus:bg-teal-600',
529
- active: 'active:bg-teal-600 dark:active:bg-teal-700',
530
- },
531
- cyan: {
532
- base: 'bg-transparent',
533
- hover: 'hover:text-white hover:bg-cyan-500 dark:hover:bg-cyan-600',
534
- focus: 'focus:text-white focus:bg-cyan-500 dark:focus:bg-cyan-600',
535
- active: 'active:bg-cyan-600 dark:active:bg-cyan-700',
536
- },
537
- sky: {
538
- base: 'bg-transparent',
539
- hover: 'hover:text-white hover:bg-sky-500 dark:hover:bg-sky-600',
540
- focus: 'focus:text-white focus:bg-sky-500 dark:focus:bg-sky-600',
541
- active: 'active:bg-sky-600 dark:active:bg-sky-700',
542
- },
543
- blue: {
544
- base: 'bg-transparent',
545
- hover: 'hover:text-white hover:bg-blue-500 dark:hover:bg-blue-600',
546
- focus: 'focus:text-white focus:bg-blue-500 dark:focus:bg-blue-600',
547
- active: 'active:bg-blue-600 dark:active:bg-blue-700',
548
- },
549
- indigo: {
550
- base: 'bg-transparent',
551
- hover: 'hover:text-white hover:bg-indigo-500 dark:hover:bg-indigo-600',
552
- focus: 'focus:text-white focus:bg-indigo-500 dark:focus:bg-indigo-600',
553
- active: 'active:bg-indigo-600 dark:active:bg-indigo-700',
554
- },
555
- violet: {
556
- base: 'bg-transparent',
557
- hover: 'hover:text-white hover:bg-violet-500 dark:hover:bg-violet-600',
558
- focus: 'focus:text-white focus:bg-violet-500 dark:focus:bg-violet-600',
559
- active: 'active:bg-violet-600 dark:active:bg-violet-700',
560
- },
561
- fuchsia: {
562
- base: 'bg-transparent',
563
- hover: 'hover:text-white hover:bg-fuchsia-500 dark:hover:bg-fuchsia-600',
564
- focus: 'focus:text-white focus:bg-fuchsia-500 dark:focus:bg-fuchsia-600',
565
- active: 'active:bg-fuchsia-600 dark:active:bg-fuchsia-700',
566
- },
567
- purple: {
568
- base: 'bg-transparent',
569
- hover: 'hover:text-white hover:bg-purple-500 dark:hover:bg-purple-600',
570
- focus: 'focus:text-white focus:bg-purple-500 dark:focus:bg-purple-600',
571
- active: 'active:bg-purple-600 dark:active:bg-purple-700',
572
- },
573
- pink: {
574
- base: 'bg-transparent',
575
- hover: 'hover:text-white hover:bg-pink-500 dark:hover:bg-pink-600',
576
- focus: 'focus:text-white focus:bg-pink-500 dark:focus:bg-pink-600',
577
- active: 'active:bg-pink-600 dark:active:bg-pink-700',
578
- },
579
- rose: {
580
- base: 'bg-transparent',
581
- hover: 'hover:text-white hover:bg-rose-500 dark:hover:bg-rose-600',
582
- focus: 'focus:text-white focus:bg-rose-500 dark:focus:bg-rose-600',
583
- active: 'active:bg-rose-600 dark:active:bg-rose-700',
584
- },
585
- },
586
- };
587
- const sizeClassNames = {
588
- small: {
589
- base: 'gap-1.5 text-sm h-7',
590
- withChildren: 'px-2',
591
- icon: {
592
- base: 'h-4 w-4',
593
- withChildren: 'h-3 w-3',
594
- },
595
- },
596
- medium: {
597
- base: 'gap-2 text-base h-10',
598
- withChildren: 'px-2.5',
599
- icon: {
600
- base: 'h-5 w-5',
601
- withChildren: 'h-4 w-4',
602
- },
603
- },
604
- };
605
- const Button = react.forwardRef((_a, ref) => {
606
- var { children, className, size = 'medium', color = 'slate', variant = 'filled', rounded, prefixIcon: PrefixIcon, suffixIcon: SuffixIcon, unstyled } = _a, props = __rest(_a, ["children", "className", "size", "color", "variant", "rounded", "prefixIcon", "suffixIcon", "unstyled"]);
607
- return (jsxRuntime.jsxs("button", Object.assign({ className: cn('relative flex aspect-square items-center font-medium duration-200', sizeClassNames[size].base, variantClassNames[variant][color].base, rounded ? 'rounded-full' : 'rounded-md', props.disabled
608
- ? 'cursor-not-allowed opacity-50'
609
- : !unstyled
610
- ? `${variantClassNames[variant][color].hover} ${variantClassNames[variant][color].focus} ${variantClassNames[variant][color].active}`
611
- : 'cursor-default', children ? `${sizeClassNames[size].withChildren} aspect-[initial]` : 'justify-center', className), type: "button" }, props, { ref: ref, children: [PrefixIcon && (jsxRuntime.jsx(PrefixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base })), children, SuffixIcon && (jsxRuntime.jsx(SuffixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base }))] })));
612
- });
613
-
614
- const Badge = react.forwardRef((_a, ref) => {
615
- var { size = 'small' } = _a, props = __rest(_a, ["size"]);
616
- return jsxRuntime.jsx(Button, Object.assign({ size: size }, props, { ref: ref }));
617
- });
618
-
619
- const Block = react.forwardRef((_a, ref) => {
620
- var { children, className, centered, container, fullWidth, fullHeight } = _a, props = __rest(_a, ["children", "className", "centered", "container", "fullWidth", "fullHeight"]);
621
- return (jsxRuntime.jsx("div", Object.assign({ className: cn(centered && 'mx-auto', container && 'container', fullWidth && 'w-full', fullHeight && 'h-full', className) }, props, { ref: ref, children: children })));
622
- });
623
-
624
- const Card = react.forwardRef((_a, ref) => {
625
- var { children, className } = _a, blockProps = __rest(_a, ["children", "className"]);
626
- return (jsxRuntime.jsx(Block, Object.assign({ className: cn('rounded-lg border p-3 dark:border-slate-700 dark:bg-slate-900', className) }, blockProps, { ref: ref, children: children })));
627
- });
628
-
629
- const $Collapsible = CollapsiblePrimitive__namespace.Root;
630
- const CollapsibleTrigger = CollapsiblePrimitive__namespace.CollapsibleTrigger;
631
- const CollapsibleContent = CollapsiblePrimitive__namespace.CollapsibleContent;
632
- const Collapsible = Object.assign($Collapsible, {
633
- Trigger: CollapsibleTrigger,
634
- Content: CollapsibleContent,
635
- });
636
-
637
- const directionClasses = {
638
- row: {
639
- normal: 'flex-row',
640
- reverse: 'flex-row-reverse',
641
- },
642
- column: {
643
- normal: 'flex-col',
644
- reverse: 'flex-col-reverse',
645
- },
646
- };
647
- const alignClasses = {
648
- start: 'items-start',
649
- center: 'items-center',
650
- end: 'items-end',
651
- };
652
- const justifyClasses = {
653
- start: 'justify-start',
654
- center: 'justify-center',
655
- between: 'justify-between',
656
- end: 'justify-end',
657
- };
658
- const Flex = react.forwardRef((_a, ref) => {
659
- var { children, className, reverse, wrap, direction = 'row', align = 'start', justify = 'start' } = _a, blockProps = __rest(_a, ["children", "className", "reverse", "wrap", "direction", "align", "justify"]);
660
- return (jsxRuntime.jsx(Block, Object.assign({ className: cn('flex gap-3', wrap && 'flex-wrap', directionClasses[direction][reverse ? 'reverse' : 'normal'], alignClasses[align], justifyClasses[justify], className) }, blockProps, { ref: ref, children: children })));
661
- });
662
-
663
- dayjs.extend(localeData);
664
- function useDays(locale = 'en') {
665
- return react.useMemo(() => {
666
- dayjs.extend(localeData).locale(locale);
667
- const names = dayjs.weekdays();
668
- const shortNames = dayjs.weekdaysShort();
669
- return names.map((name, index) => ({ name, shortName: shortNames[index], index }));
670
- }, [locale]);
671
- }
672
-
673
- const MOBILE_BREAKPOINT = 768;
674
- function useIsMobile() {
675
- const [isMobile, setIsMobile] = react.useState(undefined);
676
- react.useEffect(() => {
677
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
678
- const onChange = () => {
679
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
680
- };
681
- mql.addEventListener('change', onChange);
682
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
683
- return () => mql.removeEventListener('change', onChange);
684
- }, []);
685
- return !!isMobile;
686
- }
687
-
688
- function useLongPress(callback, ms = 100) {
689
- const [startLongPress, setStartLongPress] = react.useState(false);
690
- react.useEffect(() => {
691
- let timerId;
692
- if (startLongPress) {
693
- timerId = setTimeout(callback, ms);
694
- }
695
- else if (timerId) {
696
- clearTimeout(timerId);
697
- }
698
- return () => {
699
- timerId && clearTimeout(timerId);
700
- };
701
- }, [callback, ms, startLongPress]);
702
- return {
703
- onMouseDown: () => setStartLongPress(true),
704
- onMouseUp: () => setStartLongPress(false),
705
- onMouseLeave: () => setStartLongPress(false),
706
- onTouchStart: () => setStartLongPress(true),
707
- onTouchEnd: () => setStartLongPress(false),
708
- };
709
- }
710
-
711
- dayjs.extend(localeData);
712
- function useMonths(locale = 'en') {
713
- return react.useMemo(() => {
714
- dayjs.extend(localeData).locale(locale);
715
- const names = dayjs.months();
716
- const shortNames = dayjs.monthsShort();
717
- return names.map((name, index) => ({ name, shortName: shortNames[index], index }));
718
- }, [locale]);
719
- }
720
-
721
- function useOnSwipe(element, onSwipe, minSwipeDistance = 50) {
722
- react.useEffect(() => {
723
- if (!element.current)
724
- return;
725
- const elem = element.current;
726
- let touchStartX = 0, touchEndX = 0, touchStartY = 0, touchEndY = 0;
727
- const onTouchStart = (event) => {
728
- touchStartX = event.targetTouches[0].clientX;
729
- touchStartY = event.targetTouches[0].clientY;
730
- };
731
- const onTouchMove = (event) => {
732
- touchEndX = event.targetTouches[0].clientX;
733
- touchEndY = event.targetTouches[0].clientY;
734
- };
735
- const onTouchEnd = (event) => {
736
- const distanceX = touchEndX - touchStartX;
737
- const distanceY = touchEndY - touchStartY;
738
- if (Math.abs(distanceX) > minSwipeDistance && Math.abs(distanceY) > minSwipeDistance)
739
- return;
740
- if (Math.abs(distanceX) > minSwipeDistance) {
741
- if (onSwipe(distanceX > 0 ? 'right' : 'left') !== false) {
742
- event.stopPropagation();
743
- }
744
- }
745
- if (Math.abs(distanceY) > minSwipeDistance) {
746
- if (onSwipe(distanceY > 0 ? 'bottom' : 'up') !== false) {
747
- event.stopPropagation();
748
- }
749
- }
750
- };
751
- elem.addEventListener('touchstart', onTouchStart);
752
- elem.addEventListener('touchmove', onTouchMove);
753
- elem.addEventListener('touchend', onTouchEnd);
754
- return () => {
755
- elem.removeEventListener('touchstart', onTouchStart);
756
- elem.removeEventListener('touchmove', onTouchMove);
757
- elem.removeEventListener('touchend', onTouchEnd);
758
- };
759
- }, [element, minSwipeDistance, onSwipe]);
760
- }
761
-
762
- function useOutsideClick(ref, callback) {
763
- react.useEffect(() => {
764
- const handleClickOutside = (event) => {
765
- if ((ref === null || ref === void 0 ? void 0 : ref.current) && !ref.current.contains(event.target)) {
766
- callback();
767
- }
768
- };
769
- // Bind the event listener
770
- document.addEventListener('mousedown', handleClickOutside);
771
- return () => {
772
- // Unbind the event listener on clean up
773
- document.removeEventListener('mousedown', handleClickOutside);
774
- };
775
- }, [ref, callback]);
776
- }
777
-
778
- function usePagination(currentIndex, totalPages) {
779
- return react.useMemo(() => {
780
- const result = [];
781
- result.push(currentIndex);
782
- if (totalPages > 7 && currentIndex > 4) {
783
- for (let index = currentIndex - 1; index >= Math.min(totalPages - 4, currentIndex - 1); index--) {
784
- result.push(index);
785
- }
786
- result.push('...');
787
- result.push(1);
788
- }
789
- else {
790
- for (let index = currentIndex - 1; index > 0; index--) {
791
- result.push(index);
792
- }
793
- }
794
- result.reverse();
795
- if (totalPages > 7 && totalPages - currentIndex >= 4) {
796
- for (let index = currentIndex + 1; index <= Math.max(5, currentIndex + 1); index++) {
797
- result.push(index);
798
- }
799
- result.push('...');
800
- result.push(totalPages);
801
- }
802
- else {
803
- for (let index = currentIndex + 1; index <= totalPages; index++) {
804
- result.push(index);
805
- }
806
- }
807
- return result;
808
- }, [currentIndex, totalPages]);
809
- }
810
-
811
- const Tooltip = ({ children, className, content, asChild, placement }) => (jsxRuntime.jsx(TooltipPrimitive__namespace.Provider, { delayDuration: 200, children: jsxRuntime.jsxs(TooltipPrimitive__namespace.Root, { children: [jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { asChild: asChild, children: children }), jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: jsxRuntime.jsx(TooltipPrimitive__namespace.Content, { className: cn('animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-[101] overflow-hidden rounded-md border bg-white px-3 py-1.5 text-sm shadow-md dark:border-slate-700 dark:bg-slate-800 dark:text-white', className), side: placement, sideOffset: 5, children: content }) })] }) }));
812
-
813
- const Label = ({ children, className, description, required, hasErrors, htmlFor, }) => {
814
- return !children ? null : (jsxRuntime.jsxs("label", { className: cn('flex items-center gap-1 font-medium', {
815
- 'text-slate-700 dark:text-slate-100': !hasErrors,
816
- 'text-red-600 dark:text-red-500': hasErrors,
817
- }, className), htmlFor: htmlFor, children: [children, description && (jsxRuntime.jsx(Tooltip, { content: jsxRuntime.jsx("div", { className: "max-w-xs", children: description }), placement: "top", asChild: true, children: jsxRuntime.jsx(lucideReact.HelpCircle, { className: "h-4 w-4" }) })), required && jsxRuntime.jsx("span", { className: "text-red-600", children: "*" })] }));
818
- };
819
-
820
- const inputClasses = {
821
- base: {
822
- input: 'dark:bg-transparent peer w-full border focus:ring-0 rounded-md overflow-hidden text-ellipsis',
823
- disabled: 'opacity-60',
824
- },
825
- withoutErrors: {
826
- input: 'border-slate-300 dark:border-slate-700 focus:border-blue-500 dark:focus:border-blue-600 dark:placeholder-slate-400',
827
- extension: 'bg-white dark:bg-transparent border-slate-300 text-slate-600 peer-focus:border-blue-500 dark:peer-focus:border-blue-600 dark:border-slate-700 dark:text-white',
828
- },
829
- withErrors: {
830
- input: 'text-red-600 border-red-500 placeholder-red-500 focus:border-red-500 dark:border-red-600 dark:peer-focus:border-red-600 dark:placeholder-red-600',
831
- extension: 'text-red-600 border-red-500 peer-focus:border-red-500 dark:border-red-600 dark:peer-focus:border-red-600 dark:text-red-500',
832
- },
833
- };
834
- const sizeClasses = {
835
- small: {
836
- label: 'text-sm',
837
- input: 'text-sm py-1 px-2 h-7',
838
- checkbox: {
839
- input: 'w-4 h-4',
840
- wrapper: 'h-6 gap-1',
841
- },
842
- suffix: {
843
- wrapper: 'h-7',
844
- icon: 'h-4 w-4 mx-1.5',
845
- },
846
- clearButton: {
847
- base: 'h-5 w-5',
848
- withSuffixIcon: 'right-8',
849
- },
850
- },
851
- medium: {
852
- label: 'text-base',
853
- input: 'text-base py-2 px-3 h-10',
854
- checkbox: {
855
- input: 'w-5 h-5',
856
- wrapper: 'h-8 gap-2',
857
- },
858
- suffix: {
859
- wrapper: 'h-10',
860
- icon: 'w-5 h-5 mx-2',
861
- },
862
- clearButton: {
863
- base: 'h-6 w-6',
864
- withSuffixIcon: 'right-12',
865
- },
866
- },
867
- };
868
- const BasicInput = react.forwardRef(function BasicInput(_a, ref) {
869
- var { className, inputClassName, extensionClassName, type = 'text', label, description, size = 'medium', hasErrors, clearable, suffixIcon: SuffixIcon, onClear, onSuffixIconClick } = _a, props = __rest(_a, ["className", "inputClassName", "extensionClassName", "type", "label", "description", "size", "hasErrors", "clearable", "suffixIcon", "onClear", "onSuffixIconClick"]);
870
- const id = react.useId();
871
- const memoLabel = react.useMemo(() => label && (jsxRuntime.jsx(Label, { className: sizeClasses[size].label, htmlFor: id, description: description, required: props.required, hasErrors: hasErrors, children: label })), [description, hasErrors, id, label, props.required, size]);
872
- const handleClear = (event) => {
873
- var _a;
874
- event.stopPropagation();
875
- onClear === null || onClear === void 0 ? void 0 : onClear();
876
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, { target: { value: '', checked: false } });
877
- };
878
- return (jsxRuntime.jsxs("div", { className: cn('w-full dark:text-white', className), children: [type !== 'checkbox' && memoLabel, jsxRuntime.jsxs("div", { className: cn('group relative flex', {
879
- 'mt-1': label && type !== 'checkbox',
880
- [`items-center ${sizeClasses[size].checkbox.wrapper}`]: type === 'checkbox',
881
- }), title: type !== 'textarea' && typeof props.value === 'string' ? props.value : undefined, children: [type === 'textarea' ? (jsxRuntime.jsx("textarea", Object.assign({ id: id, className: cn(inputClasses.base.input, sizeClasses[size].input.replace(/ h-\d/g, ''), {
882
- [inputClasses.base.disabled]: props.disabled,
883
- [inputClasses.withoutErrors.input]: !hasErrors,
884
- [inputClasses.withErrors.input]: hasErrors,
885
- 'rounded-r-none border-r-0': SuffixIcon,
886
- }, inputClassName) }, props, { value: props.value, ref: ref }))) : type === 'checkbox' ? (jsxRuntime.jsx("input", Object.assign({ id: id, className: cn('rounded border-slate-300 text-blue-600', sizeClasses[size].checkbox.input, {
887
- [inputClasses.base.disabled]: props.disabled,
888
- 'bg-red-100': hasErrors,
889
- }, inputClassName), type: type, checked: Boolean(props.value) }, props, { ref: ref }))) : (jsxRuntime.jsx("input", Object.assign({ id: id, className: cn(inputClasses.base.input, sizeClasses[size].input, {
890
- [inputClasses.base.disabled]: props.disabled,
891
- [inputClasses.withoutErrors.input]: !hasErrors,
892
- [inputClasses.withErrors.input]: hasErrors,
893
- 'rounded-r-none border-r-0': SuffixIcon,
894
- }, inputClassName), type: type !== null && type !== void 0 ? type : 'text' }, props, { value: props.value, ref: ref }))), type === 'checkbox' && memoLabel, clearable && (onClear || !!props.value) && !props.disabled && (jsxRuntime.jsx(lucideReact.XIcon, { className: cn('absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer rounded-full bg-white p-0.5 opacity-0 duration-200 hover:bg-slate-200 group-hover:opacity-100 dark:bg-slate-700 dark:hover:bg-slate-800', sizeClasses[size].clearButton.base, {
895
- [sizeClasses[size].clearButton.withSuffixIcon]: SuffixIcon,
896
- }), onClick: handleClear, onPointerDown: (event) => event.stopPropagation() })), type !== 'checkbox' && SuffixIcon && (jsxRuntime.jsx(BasicInputExtension, { className: extensionClassName, hasErrors: hasErrors, size: size, disabled: props.disabled, onClick: onSuffixIconClick, children: jsxRuntime.jsx(SuffixIcon, { className: sizeClasses[size].suffix.icon }) }))] })] }));
897
- });
898
- const BasicInputExtension = ({ children, className, size, hasErrors, disabled, onClick }) => (jsxRuntime.jsx("div", { className: cn('flex aspect-square items-center justify-center rounded-r-md border border-l-0', sizeClasses[size].suffix.wrapper, {
899
- [inputClasses.base.disabled]: disabled,
900
- [inputClasses.withoutErrors.extension]: !hasErrors,
901
- [inputClasses.withErrors.extension]: hasErrors,
902
- 'cursor-pointer': onClick,
903
- }, className), onClick: !disabled ? onClick : undefined, onPointerDown: (event) => event.stopPropagation(), children: children }));
904
-
905
- const CheckboxInput = react.forwardRef((props, ref) => (jsxRuntime.jsx(BasicInput, Object.assign({ type: "checkbox" }, props, { ref: ref }))));
906
-
907
- const EmailInput = react.forwardRef((props, ref) => (jsxRuntime.jsx(BasicInput, Object.assign({ type: "email" }, props, { suffixIcon: lucideReact.AtSignIcon, ref: ref }))));
908
-
909
- const NumberInput = react.forwardRef((_a, ref) => {
910
- var { unit } = _a, props = __rest(_a, ["unit"]);
911
- return (jsxRuntime.jsx(BasicInput, Object.assign({ type: "number" }, props, { suffixIcon: unit
912
- ? ({ className }) => (jsxRuntime.jsx("div", { className: cn(className, 'flex w-min items-center'), onClick: props.onSuffixIconClick, children: unit }))
913
- : props.suffixIcon, ref: ref })));
914
- });
915
-
916
- const PasswordInput = react.forwardRef((props, ref) => {
917
- const [type, setType] = react.useState('password');
918
- const toggleType = () => setType((type) => (type === 'text' ? 'password' : 'text'));
919
- return (jsxRuntime.jsx(BasicInput, Object.assign({ type: type }, props, { suffixIcon: type === 'password' ? lucideReact.EyeIcon : lucideReact.EyeOffIcon, onSuffixIconClick: toggleType, ref: ref })));
920
- });
921
-
922
- const TextareaInput = react.forwardRef((props, ref) => (jsxRuntime.jsx(BasicInput, Object.assign({ type: "textarea" }, props, { ref: ref }))));
923
-
924
- const TextInput = react.forwardRef((props, ref) => (jsxRuntime.jsx(BasicInput, Object.assign({ type: "text" }, props, { ref: ref }))));
925
-
926
- const DaysView = ({ date, value, month, year, minDate, maxDate, locale, setNewDate, }) => {
927
- const days = useDays(locale);
928
- const monthDays = react.useMemo(() => {
929
- const daysInMonth = new Date(year, month + 1, 0).getDate();
930
- const daysInMonthArr = [];
931
- for (let i = 1; i <= daysInMonth; i++) {
932
- daysInMonthArr.push(i);
933
- }
934
- return daysInMonthArr;
935
- }, [month, year]);
936
- const prefixDays = react.useMemo(() => {
937
- const firstDay = new Date(year, month);
938
- const dayOfWeek = firstDay.getDay();
939
- firstDay.setDate(firstDay.getDate() - 1);
940
- const lastDay = firstDay.getDate();
941
- const prefixDays = [];
942
- for (let i = 1; i <= dayOfWeek; i++) {
943
- prefixDays.push(lastDay - dayOfWeek + i);
944
- }
945
- return prefixDays;
946
- }, [month, year]);
947
- const suffixDays = react.useMemo(() => {
948
- const lastDay = new Date(year, month + 1);
949
- lastDay.setDate(lastDay.getDate() - 1);
950
- const dayOfWeek = lastDay.getDay();
951
- const suffixDays = [];
952
- for (let i = dayOfWeek; i < 6; i++) {
953
- suffixDays.push(i - dayOfWeek + 1);
954
- }
955
- return suffixDays;
956
- }, [month, year]);
957
- const setDayNumber = react.useCallback((newDay, newMonth = month, newYear = year) => () => {
958
- const newDate = new Date(newYear, newMonth, newDay, date.getHours(), date.getMinutes());
959
- if (minDate) {
960
- const _minDate = new Date(minDate);
961
- if (_minDate.getFullYear() === newYear &&
962
- _minDate.getMonth() === newMonth &&
963
- _minDate.getDate() === newDay) {
964
- newDate.setHours(Math.max(newDate.getHours(), _minDate.getHours()));
965
- if (newDate.getHours() === _minDate.getHours()) {
966
- newDate.setMinutes(Math.max(newDate.getMinutes(), _minDate.getMinutes()));
967
- }
968
- }
969
- }
970
- if (maxDate) {
971
- const _maxDate = new Date(maxDate);
972
- if (_maxDate.getFullYear() === newYear &&
973
- _maxDate.getMonth() === newMonth &&
974
- _maxDate.getDate() === newDay) {
975
- newDate.setHours(Math.min(newDate.getHours(), _maxDate.getHours()));
976
- if (newDate.getHours() === _maxDate.getHours()) {
977
- newDate.setMinutes(Math.min(newDate.getMinutes(), _maxDate.getMinutes()));
978
- }
979
- }
980
- }
981
- setNewDate(newDate);
982
- }, [date, maxDate, minDate, month, setNewDate, year]);
983
- return (jsxRuntime.jsxs("div", { className: "gap-1 px-3 py-2", children: [jsxRuntime.jsx("div", { className: "grid grid-cols-7", children: days.map((day, index) => (jsxRuntime.jsx("span", { className: "flex h-8 w-8 items-center justify-center text-xs uppercase text-slate-500 dark:text-slate-400", children: day.shortName }, index))) }), jsxRuntime.jsxs("div", { className: "grid grid-cols-7 gap-1", children: [prefixDays.map((dayNumber, index) => (jsxRuntime.jsx(Day, { value: value, day: dayNumber, month: (month - 1 + 12) % 12, year: month % 12 ? year : year - 1, minDate: minDate, maxDate: maxDate, setDayNumber: setDayNumber }, `${dayNumber}-${index}`))), monthDays.map((dayNumber, index) => (jsxRuntime.jsx(Day, { value: value, day: dayNumber, month: month, year: year, minDate: minDate, maxDate: maxDate, primary: true, setDayNumber: setDayNumber }, `${dayNumber}-${index}`))), suffixDays.map((dayNumber, index) => (jsxRuntime.jsx(Day, { value: value, day: dayNumber, month: (month + 1) % 12, year: (month + 1) % 12 ? year : year + 1, minDate: minDate, maxDate: maxDate, setDayNumber: setDayNumber }, `${dayNumber}-${index}`)))] })] }));
984
- };
985
- const Day = ({ value, day, month, year, minDate, maxDate, primary, setDayNumber, }) => {
986
- const dayDate = react.useMemo(() => new Date(year, month, day), [day, month, year]);
987
- const isSelectable = react.useMemo(() => (!minDate || compareDates(dayDate, new Date(minDate), 'day') >= 0) &&
988
- (!maxDate || compareDates(dayDate, new Date(maxDate), 'day') <= 0), [minDate, dayDate, maxDate]);
989
- const isSelected = react.useMemo(() => !!value && !compareDates(dayDate, new Date(value), 'day'), [dayDate, value]);
990
- const isEqualToday = react.useMemo(() => !compareDates(dayDate, new Date(), 'day'), [dayDate]);
991
- return (jsxRuntime.jsx("div", { className: cn('mx-auto flex h-8 w-8 items-center justify-center rounded-lg text-sm', {
992
- 'border-2 border-blue-500': isEqualToday,
993
- 'bg-blue-500 text-white': isSelected,
994
- 'cursor-pointer': isSelectable,
995
- 'hover:bg-blue-100 dark:hover:bg-blue-800': isSelectable && !isSelected,
996
- 'text-slate-400 dark:text-slate-500': !isSelectable || !primary,
997
- }), onClick: isSelectable ? setDayNumber(day, month, year) : undefined, children: day }));
998
- };
999
-
1000
- const MonthsView = ({ date, value, year, minDate, maxDate, locale, selectMonth, }) => {
1001
- const months = useMonths(locale);
1002
- return (jsxRuntime.jsx("div", { className: "grid grid-cols-4 gap-1 px-3 py-2", children: months.map((month, index) => (jsxRuntime.jsx(Month, { date: date, value: value, shortName: month.shortName, month: index, year: year, minDate: minDate, maxDate: maxDate, selectMonth: selectMonth }, index))) }));
1003
- };
1004
- const Month = ({ date, value, shortName, month, year, minDate, maxDate, selectMonth, }) => {
1005
- const dayDate = react.useMemo(() => new Date(year, month, date.getDate(), date.getHours(), date.getMinutes()), [date, month, year]);
1006
- const isSelectable = react.useMemo(() => (!minDate || compareDates(dayDate, new Date(minDate), 'month') >= 0) &&
1007
- (!maxDate || compareDates(dayDate, new Date(maxDate), 'month') <= 0), [dayDate, minDate, maxDate]);
1008
- const isSelected = react.useMemo(() => !!value && !compareDates(dayDate, new Date(value), 'month'), [dayDate, value]);
1009
- const isEqualThisMonth = react.useMemo(() => !compareDates(dayDate, new Date(), 'month'), [dayDate]);
1010
- return (jsxRuntime.jsx("div", { className: cn('mx-auto flex w-14 items-center justify-center rounded border py-3 text-sm', {
1011
- 'border-blue-500': isEqualThisMonth,
1012
- 'border-transparent': !isEqualThisMonth,
1013
- 'bg-blue-500 text-white': isSelected,
1014
- 'cursor-pointer': isSelectable,
1015
- 'hover:bg-blue-100 dark:hover:bg-blue-900': isSelectable && !isSelected,
1016
- 'text-slate-400 dark:text-slate-500': !isSelectable,
1017
- }), onClick: isSelectable ? selectMonth(month) : undefined, children: shortName }));
1018
- };
1019
-
1020
- const YearsView = ({ date, value, years, minDate, maxDate, selectYear, }) => (jsxRuntime.jsx("div", { className: "grid grid-cols-4 gap-1 px-3 py-2", children: years.map((year, index) => (jsxRuntime.jsx(Year, { date: date, value: value, year: year, minDate: minDate, maxDate: maxDate, selectYear: selectYear }, index))) }));
1021
- const Year = ({ date, value, year, minDate, maxDate, selectYear }) => {
1022
- const dayDate = react.useMemo(() => new Date(year, date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()), [date, year]);
1023
- const isSelectable = react.useMemo(() => (!minDate || compareDates(dayDate, new Date(minDate), 'year') >= 0) &&
1024
- (!maxDate || compareDates(dayDate, new Date(maxDate), 'year') <= 0), [dayDate, minDate, maxDate]);
1025
- const isSelected = react.useMemo(() => !!value && !compareDates(dayDate, new Date(value), 'year'), [dayDate, value]);
1026
- const isEqualThisYear = react.useMemo(() => !compareDates(dayDate, new Date(), 'year'), [dayDate]);
1027
- return (jsxRuntime.jsx("div", { className: cn('mx-auto flex w-14 items-center justify-center rounded border py-3 text-sm', {
1028
- 'border-blue-500': isEqualThisYear,
1029
- 'border-transparent': !isEqualThisYear,
1030
- 'bg-blue-500 text-white': isSelected,
1031
- 'cursor-pointer': isSelectable,
1032
- 'hover:bg-blue-100 dark:hover:bg-blue-900': isSelectable && !isSelected,
1033
- 'text-slate-400 dark:text-slate-500': !isSelectable,
1034
- }), onClick: isSelectable ? selectYear(year) : undefined, children: year }));
1035
- };
1036
-
1037
- const DateSelector = ({ date, value, minDate, maxDate, locale, calendarView, setCalendarView, setNewDate, }) => {
1038
- const months = useMonths(locale);
1039
- const [month, setMonth] = react.useState(date.getMonth());
1040
- const [year, setYear] = react.useState(date.getFullYear());
1041
- const [yearOffset, setYearOffset] = react.useState(0);
1042
- react.useEffect(() => {
1043
- setMonth(date.getMonth());
1044
- setYear(date.getFullYear());
1045
- }, [date]);
1046
- const yearsRange = react.useMemo(() => {
1047
- const yearsRangeArr = [];
1048
- for (let i = year + yearOffset - 6; i < year + yearOffset + 6; i++) {
1049
- yearsRangeArr.push(i);
1050
- }
1051
- return yearsRangeArr;
1052
- }, [year, yearOffset]);
1053
- const editCalendarViewPage = (type) => () => {
1054
- let newYear = year;
1055
- let newMonth = month;
1056
- if (calendarView === 'days') {
1057
- if (type === 'add') {
1058
- newMonth = (month + 1) % 12;
1059
- newYear = newMonth ? year : year + 1;
1060
- }
1061
- else {
1062
- newMonth = (month - 1 + 12) % 12;
1063
- newYear = month % 12 ? year : year - 1;
1064
- }
1065
- }
1066
- else if (calendarView === 'months') {
1067
- newYear = year + (type === 'add' ? 1 : -1);
1068
- }
1069
- else {
1070
- setYearOffset((yearOffset) => yearOffset + (type === 'add' ? 12 : -12));
1071
- }
1072
- setYear(newYear);
1073
- setMonth(newMonth);
1074
- };
1075
- const nextCalendarView = () => {
1076
- setMonth(date.getMonth());
1077
- setYear(date.getFullYear());
1078
- if (calendarView === 'days') {
1079
- setCalendarView('months');
1080
- }
1081
- else if (calendarView === 'months') {
1082
- setCalendarView('years');
1083
- }
1084
- else {
1085
- setCalendarView('days');
1086
- }
1087
- };
1088
- const selectMonth = (month) => () => {
1089
- setMonth(month);
1090
- setCalendarView('days');
1091
- };
1092
- const selectYear = (year) => () => {
1093
- setYear(year);
1094
- setCalendarView('months');
1095
- };
1096
- return (jsxRuntime.jsxs("div", { className: "select-none", children: [jsxRuntime.jsxs("div", { className: "flex justify-between px-3 pt-2", children: [jsxRuntime.jsx("div", { className: "flex cursor-pointer items-center justify-center rounded-lg px-1 transition duration-100 ease-in-out hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-slate-700", onClick: editCalendarViewPage('subtract'), children: jsxRuntime.jsx(lucideReact.ChevronLeftIcon, { className: "h-5 w-5 text-slate-400" }) }), jsxRuntime.jsxs("div", { className: "flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition duration-100 ease-in-out hover:bg-slate-100 dark:hover:bg-slate-700", onClick: nextCalendarView, children: [calendarView === 'days' && jsxRuntime.jsx("span", { className: "capitalize", children: months[month].name }), calendarView !== 'years' ? (jsxRuntime.jsx("span", { className: "text-slate-500 dark:text-slate-300", children: year })) : (jsxRuntime.jsxs("span", { className: "text-slate-500 dark:text-slate-300", children: [yearsRange[0], " - ", yearsRange[11]] }))] }), jsxRuntime.jsx("div", { className: "flex cursor-pointer items-center justify-center rounded-lg px-1 transition duration-100 ease-in-out hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-slate-700", onClick: editCalendarViewPage('add'), children: jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: "h-5 w-5 text-slate-400" }) })] }), calendarView === 'days' ? (jsxRuntime.jsx(DaysView, { date: date, value: value, month: month, year: year, minDate: minDate, maxDate: maxDate, locale: locale, setNewDate: setNewDate })) : calendarView === 'months' ? (jsxRuntime.jsx(MonthsView, { date: date, value: value, year: year, minDate: minDate, maxDate: maxDate, locale: locale, selectMonth: selectMonth })) : (jsxRuntime.jsx(YearsView, { date: date, value: value, years: yearsRange, minDate: minDate, maxDate: maxDate, selectYear: selectYear }))] }));
1097
- };
1098
-
1099
- const TimeSelector = ({ date, step = 1, minDate, maxDate, setNewDate, }) => {
1100
- const editDateField = (field, diff) => () => {
1101
- const newDate = dayjs(date).add(diff, field).toDate();
1102
- if (minDate && compareDates(newDate, new Date(minDate), 'minute') < 0)
1103
- return;
1104
- if (maxDate && compareDates(newDate, new Date(maxDate), 'minute') > 0)
1105
- return;
1106
- setNewDate(newDate);
1107
- };
1108
- const increaseHours = useLongPress(editDateField('hours', 1));
1109
- const decreaseHours = useLongPress(editDateField('hours', -1));
1110
- const increaseMinutes = useLongPress(editDateField('minutes', step));
1111
- const decreaseMinutes = useLongPress(editDateField('minutes', -step));
1112
- const onWheel = (field) => (event) => editDateField(field, (event.deltaY < 0 ? 1 : -1) * (field === 'hours' ? 1 : step))();
1113
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("label", { className: "text-sm text-slate-700 dark:text-slate-300", children: "Time" }), jsxRuntime.jsxs("div", { className: "flex flex-grow justify-center gap-2", children: [jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center", children: [jsxRuntime.jsx(lucideReact.ChevronUpIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('hours', 1) }, increaseHours)), jsxRuntime.jsx(lucideReact.ChevronDownIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('hours', -1) }, decreaseHours))] }), jsxRuntime.jsxs("div", { className: "flex items-center rounded-lg border border-slate-100 bg-slate-100 text-right dark:border-slate-700 dark:bg-slate-800", children: [jsxRuntime.jsx("span", { className: "flex px-2", onWheel: onWheel('hours'), children: date.getHours().toString().padStart(2, '0') }), jsxRuntime.jsx("span", { children: ":" }), jsxRuntime.jsx("span", { className: "flex px-2", onWheel: onWheel('minutes'), children: date.getMinutes().toString().padStart(2, '0') })] }), jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center", children: [jsxRuntime.jsx(lucideReact.ChevronUpIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('minutes', step) }, increaseMinutes)), jsxRuntime.jsx(lucideReact.ChevronDownIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('minutes', -step) }, decreaseMinutes))] })] })] }));
1114
- };
1115
-
1116
- const DateTimeInput = react.forwardRef((_a, ref) => {
1117
- var { className, value, clearable, type = 'datetime-local', step = 1, minDate, maxDate, hasErrors, onChange, onBlur, displayFormat = 'dddd, MMMM Do YYYY, HH:mm:ss', displayLocale = 'en' } = _a, props = __rest(_a, ["className", "value", "clearable", "type", "step", "minDate", "maxDate", "hasErrors", "onChange", "onBlur", "displayFormat", "displayLocale"]);
1118
- const [isOpen, setIsOpen] = react.useState();
1119
- const [calendarView, setCalendarView] = react.useState('days');
1120
- const date = react.useMemo(() => {
1121
- const result = value
1122
- ? new Date(value)
1123
- : new Date(Math.min(Math.max(new Date(minDate !== null && minDate !== void 0 ? minDate : Date.now()).getTime(), Date.now()), new Date(maxDate !== null && maxDate !== void 0 ? maxDate : Date.now()).getTime()));
1124
- result.setMinutes(result.getMinutes() - ((result.getMinutes() + step) % step));
1125
- return result;
1126
- }, [step, maxDate, minDate, value]);
1127
- const displayDate = react.useMemo(() => value && getDisplayDate(date, displayFormat, displayLocale), [date, value, displayFormat, displayLocale]);
1128
- const calendarRef = react.useRef(null);
1129
- useOutsideClick(calendarRef, () => setIsOpen(false));
1130
- react.useEffect(() => {
1131
- if (!isOpen) {
1132
- setCalendarView('days');
1133
- }
1134
- }, [isOpen]);
1135
- const setNewDate = (newDate) => {
1136
- if (type === 'date') {
1137
- newDate = dayjs(newDate).startOf('day').toDate();
1138
- }
1139
- onChange === null || onChange === void 0 ? void 0 : onChange(newDate);
1140
- if (type === 'date') {
1141
- setIsOpen(false);
1142
- }
1143
- };
1144
- const clearDate = () => {
1145
- onChange === null || onChange === void 0 ? void 0 : onChange(null);
1146
- };
1147
- const handleOnClick = () => {
1148
- var _a;
1149
- if (props.readOnly)
1150
- return;
1151
- setIsOpen((open) => !open);
1152
- (_a = calendarRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1153
- };
1154
- const handleOnBlur = (event) => {
1155
- if (props.readOnly)
1156
- return;
1157
- setIsOpen(false);
1158
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
1159
- };
1160
- const handleOnKeyUp = (event) => {
1161
- switch (event.key) {
1162
- case ' ':
1163
- setIsOpen(!isOpen);
1164
- break;
1165
- case 'Escape':
1166
- setIsOpen(false);
1167
- }
1168
- };
1169
- return (jsxRuntime.jsxs("div", { className: cn('relative w-full', className), ref: ref, children: [jsxRuntime.jsx(BasicInput, Object.assign({}, props, { type: "text", readOnly: true, value: displayDate !== null && displayDate !== void 0 ? displayDate : '', hasErrors: hasErrors, onClick: handleOnClick, onKeyUp: handleOnKeyUp, clearable: clearable && !!displayDate, onClear: clearDate, suffixIcon: (type === null || type === void 0 ? void 0 : type.includes('date')) ? lucideReact.CalendarIcon : lucideReact.ClockIcon, onSuffixIconClick: handleOnClick })), isOpen && (jsxRuntime.jsxs("div", { className: "absolute z-20 mt-2 flex origin-top-left flex-col rounded-md border bg-white shadow duration-200 dark:border-slate-700 dark:bg-slate-900 dark:text-white", tabIndex: 0, onBlur: handleOnBlur, ref: calendarRef, children: [(type === null || type === void 0 ? void 0 : type.includes('date')) && (jsxRuntime.jsx(DateSelector, { date: date, value: value, minDate: minDate, maxDate: maxDate, locale: displayLocale, calendarView: calendarView, setCalendarView: setCalendarView, setNewDate: setNewDate })), calendarView === 'days' && (jsxRuntime.jsxs("div", { className: "flex select-none items-center justify-end gap-2 px-3 py-2", children: [(type === null || type === void 0 ? void 0 : type.includes('time')) && (jsxRuntime.jsx(TimeSelector, { date: date, step: step, minDate: minDate, maxDate: maxDate, setNewDate: setNewDate })), jsxRuntime.jsx("div", { className: "cursor-pointer rounded-lg border border-transparent p-1 text-sm font-bold uppercase text-blue-600 transition duration-100 ease-in-out hover:bg-slate-100 dark:text-blue-500 dark:hover:bg-slate-700", onClick: () => setIsOpen(false), children: "OK" })] }))] }))] }));
1170
- });
1171
-
1172
- const ListContent = react.forwardRef((_a, ref) => {
1173
- var { className } = _a, props = __rest(_a, ["className"]);
1174
- return (jsxRuntime.jsx(Block, Object.assign({ className: cn('z-50 min-w-[8rem] overflow-hidden rounded-md border border-slate-100 bg-white p-1 text-slate-700 shadow-md dark:border-slate-700 dark:bg-slate-900 dark:text-white', className), ref: ref }, props)));
1175
- });
1176
- const labelSizeClasses = {
1177
- small: 'p-1 text-sm',
1178
- medium: 'px-2 py-1.5',
1179
- };
1180
- const ListItem = react.forwardRef((_a, ref) => {
1181
- var { className, size = 'medium', inset } = _a, props = __rest(_a, ["className", "size", "inset"]);
1182
- return (jsxRuntime.jsx(Flex, Object.assign({ className: cn(labelSizeClasses[size], 'relative cursor-default select-none gap-2 rounded-md outline-none focus:bg-slate-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-700', inset && 'pl-8', className), align: "center", ref: ref }, props)));
1183
- });
1184
- const ListLabel = react.forwardRef((_a, ref) => {
1185
- var { className, size = 'medium', inset } = _a, props = __rest(_a, ["className", "size", "inset"]);
1186
- return (jsxRuntime.jsx(Block, Object.assign({ className: cn(labelSizeClasses[size], 'font-semibold text-slate-900 dark:text-slate-300', inset && 'pl-8', className), ref: ref }, props)));
1187
- });
1188
- const ListIndicator = react.forwardRef((_a, ref) => {
1189
- var { className, icon: Icon, iconClassName } = _a, props = __rest(_a, ["className", "icon", "iconClassName"]);
1190
- return (jsxRuntime.jsx(Flex, Object.assign({ className: cn('absolute left-2 h-3.5 w-3.5', className), align: "center", justify: "center", ref: ref }, props, { children: jsxRuntime.jsx(Icon, { className: iconClassName }) })));
1191
- });
1192
- const ListIcon = react.forwardRef(({ className, icon: Icon }, ref) => jsxRuntime.jsx(Icon, { className: cn('h-4 w-4', className), ref: ref }));
1193
- const ListSeparator = react.forwardRef((_a, ref) => {
1194
- var { className } = _a, props = __rest(_a, ["className"]);
1195
- return (jsxRuntime.jsx(Block, Object.assign({ className: cn('-mx-1 my-1 h-px bg-slate-100 dark:bg-slate-700', className), ref: ref }, props)));
1196
- });
1197
- const List = Object.assign(ListContent, {
1198
- Item: ListItem,
1199
- Label: ListLabel,
1200
- Indicator: ListIndicator,
1201
- Icon: ListIcon,
1202
- Separator: ListSeparator,
1203
- });
1204
-
1205
- const DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
1206
- const DropdownMenuGroup = DropdownMenuPrimitive__namespace.Group;
1207
- const DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
1208
- const DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
1209
- const DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
1210
- const DropdownMenuSubTrigger = react.forwardRef((_a, ref) => {
1211
- var { className, inset, children } = _a, props = __rest(_a, ["className", "inset", "children"]);
1212
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.SubTrigger, Object.assign({ ref: ref }, props, { asChild: true, children: jsxRuntime.jsxs(List.Item, { className: className, inset: inset, children: [children, jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: "ml-auto h-4 w-4" })] }) })));
1213
- });
1214
- DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
1215
- const DropdownMenuSubContent = react.forwardRef((_a, ref) => {
1216
- var { className, children } = _a, props = __rest(_a, ["className", "children"]);
1217
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: jsxRuntime.jsx(DropdownMenuPrimitive__namespace.SubContent, Object.assign({ ref: ref }, props, { asChild: true, children: jsxRuntime.jsx(List, { className: className, children: children }) })) }));
1218
- });
1219
- DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
1220
- const DropdownMenuContent = react.forwardRef((_a, ref) => {
1221
- var { className, children, sideOffset = 4 } = _a, props = __rest(_a, ["className", "children", "sideOffset"]);
1222
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Content, Object.assign({ ref: ref, sideOffset: sideOffset }, props, { asChild: true, children: jsxRuntime.jsx(List, { className: className, children: children }) })) }));
1223
- });
1224
- DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
1225
- const DropdownMenuItem = react.forwardRef((_a, ref) => {
1226
- var { className, inset, children } = _a, props = __rest(_a, ["className", "inset", "children"]);
1227
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Item, Object.assign({ ref: ref }, props, { asChild: true, children: jsxRuntime.jsx(List.Item, { inset: inset, className: className, children: children }) })));
1228
- });
1229
- DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
1230
- const DropdownMenuCheckboxItem = react.forwardRef((_a, ref) => {
1231
- var { className, children } = _a, props = __rest(_a, ["className", "children"]);
1232
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.CheckboxItem, Object.assign({ ref: ref }, props, { asChild: true, children: jsxRuntime.jsxs(List.Item, { inset: true, className: className, children: [jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { asChild: true, children: jsxRuntime.jsx(List.Indicator, { icon: lucideReact.CheckIcon, iconClassName: "h-4 w-4" }) }), children] }) })));
1233
- });
1234
- DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
1235
- const DropdownMenuRadioItem = react.forwardRef((_a, ref) => {
1236
- var { className, children } = _a, props = __rest(_a, ["className", "children"]);
1237
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.RadioItem, Object.assign({ ref: ref }, props, { asChild: true, children: jsxRuntime.jsxs(List.Item, { inset: true, className: className, children: [jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { asChild: true, children: jsxRuntime.jsx(List.Indicator, { icon: lucideReact.CircleIcon, iconClassName: "h-2 w-2 fill-current" }) }), children] }) })));
1238
- });
1239
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
1240
- const DropdownMenuLabel = react.forwardRef((_a, ref) => {
1241
- var { className, inset, children } = _a, props = __rest(_a, ["className", "inset", "children"]);
1242
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Label, Object.assign({ ref: ref }, props, { asChild: true, children: jsxRuntime.jsx(List.Label, { className: className, inset: inset, children: children }) })));
1243
- });
1244
- DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
1245
- const DropdownMenuSeparator = react.forwardRef((_a, ref) => {
1246
- var { className } = _a, props = __rest(_a, ["className"]);
1247
- return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Separator, Object.assign({ ref: ref }, props, { asChild: true, children: jsxRuntime.jsx(List.Separator, { className: className }) })));
1248
- });
1249
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive__namespace.Separator.displayName;
1250
- const DropdownMenuShortcut = (_a) => {
1251
- var { className } = _a, props = __rest(_a, ["className"]);
1252
- return (jsxRuntime.jsx("span", Object.assign({ className: cn('ml-auto text-xs tracking-widest text-slate-500', className) }, props)));
1253
- };
1254
- DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
1255
- const DropdownMenu = Object.assign(DropdownMenuPrimitive__namespace.Root, {
1256
- Trigger: DropdownMenuTrigger,
1257
- Content: DropdownMenuContent,
1258
- Item: DropdownMenuItem,
1259
- CheckboxItem: DropdownMenuCheckboxItem,
1260
- RadioItem: DropdownMenuRadioItem,
1261
- Label: DropdownMenuLabel,
1262
- Separator: DropdownMenuSeparator,
1263
- Icon: List.Icon,
1264
- Shortcut: DropdownMenuShortcut,
1265
- Group: DropdownMenuGroup,
1266
- Portal: DropdownMenuPortal,
1267
- Sub: DropdownMenuSub,
1268
- SubContent: DropdownMenuSubContent,
1269
- SubTrigger: DropdownMenuSubTrigger,
1270
- RadioGroup: DropdownMenuRadioGroup,
1271
- });
1272
-
1273
- const SelectInput = react.forwardRef((_a, ref) => {
1274
- var { className, items, renderItem = (item) => item.label, value, multiple, clearable, allowAddition, onNewItemAdded, search, searchPredicate = (item, searchValue) => item.label.toLowerCase().includes(searchValue.toLowerCase()), selectPredicate = (a, b) => a === b, onChange, readOnly, parentRef } = _a, props = __rest(_a, ["className", "items", "renderItem", "value", "multiple", "clearable", "allowAddition", "onNewItemAdded", "search", "searchPredicate", "selectPredicate", "onChange", "readOnly", "parentRef"]);
1275
- const [open, setOpen] = react.useState(false);
1276
- const [searchValue, setSearchValue] = react.useState('');
1277
- const pureItems = react.useMemo(() => items.flatMap((item) => (item.group ? item.items : [item])), [items]);
1278
- const selectedItems = react.useMemo(() => isNotNullOrUndefined(value)
1279
- ? !multiple
1280
- ? pureItems.find((item) => selectPredicate(item.value, value))
1281
- ? [pureItems.find((item) => selectPredicate(item.value, value))]
1282
- : []
1283
- : Array.isArray(value)
1284
- ? value
1285
- .map((v) => pureItems.find((item) => selectPredicate(item.value, v)))
1286
- .filter(Boolean)
1287
- : []
1288
- : [], [multiple, pureItems, selectPredicate, value]);
1289
- const filteredItems = react.useMemo(() => !search || !searchValue
1290
- ? items
1291
- : items.flatMap((item) => item.group
1292
- ? item.items.some((subItem) => subItem.label.toLowerCase().includes(searchValue.toLowerCase()))
1293
- ? [
1294
- Object.assign(Object.assign({}, item), { items: item.items.filter((subItem) => subItem.label.toLowerCase().includes(searchValue.toLowerCase())) }),
1295
- ]
1296
- : []
1297
- : item.label.toLowerCase().includes(searchValue.toLowerCase())
1298
- ? [item]
1299
- : []), [items, search, searchValue]);
1300
- const text = react.useMemo(() => selectedItems.length
1301
- ? !multiple
1302
- ? selectedItems[0].label
1303
- : selectedItems.map((item) => item.label).join(', ')
1304
- : undefined, [multiple, selectedItems]);
1305
- const selectedMap = react.useMemo(() => selectedItems.reduce((prev, curr) => (Object.assign(Object.assign({}, prev), { [curr.id]: curr.value })), {}), [selectedItems]);
1306
- const handleOnSelect = react.useCallback((id) => {
1307
- var _a, _b, _c;
1308
- !multiple && setOpen(false);
1309
- if (!multiple) {
1310
- if (clearable && ((_a = selectedItems[0]) === null || _a === void 0 ? void 0 : _a.id) === id) {
1311
- onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
1312
- }
1313
- else {
1314
- onChange === null || onChange === void 0 ? void 0 : onChange((_b = pureItems.find((item) => item.id === id)) === null || _b === void 0 ? void 0 : _b.value);
1315
- }
1316
- }
1317
- else if (multiple) {
1318
- if (isNotNullOrUndefined(selectedMap[id])) {
1319
- onChange === null || onChange === void 0 ? void 0 : onChange(selectedItems.filter((item) => item.id !== id).map((item) => item.value));
1320
- }
1321
- else {
1322
- onChange === null || onChange === void 0 ? void 0 : onChange([
1323
- ...selectedItems.map((item) => item.value),
1324
- (_c = pureItems.find((item) => item.id === id)) === null || _c === void 0 ? void 0 : _c.value,
1325
- ].filter(Boolean));
1326
- }
1327
- }
1328
- }, [clearable, multiple, onChange, pureItems, selectedItems, selectedMap]);
1329
- const handleOnSearchValueChange = (event) => setSearchValue(event.target.value);
1330
- const clearSearchValue = () => setSearchValue('');
1331
- const handleOnClear = () => {
1332
- if (readOnly)
1333
- return;
1334
- onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
1335
- };
1336
- const handleOnAddItemClicked = () => {
1337
- onNewItemAdded === null || onNewItemAdded === void 0 ? void 0 : onNewItemAdded(searchValue);
1338
- setSearchValue('');
1339
- };
1340
- const GroupComponent = multiple ? DropdownMenu.Group : DropdownMenu.RadioGroup;
1341
- const ItemComponent = multiple ? DropdownMenu.CheckboxItem : DropdownMenu.RadioItem;
1342
- const RenderOption = react.useCallback((option) => {
1343
- return (jsxRuntime.jsx(ItemComponent, { className: cn('w-full cursor-pointer hover:bg-slate-200 dark:hover:bg-slate-700', {
1344
- 'bg-slate-200 dark:bg-slate-700': isNotNullOrUndefined(selectedMap[option.id]),
1345
- }), value: String(option.id), checked: isNotNullOrUndefined(selectedMap[option.id]), onSelect: (event) => {
1346
- multiple && event.preventDefault();
1347
- handleOnSelect(option.id);
1348
- }, children: jsxRuntime.jsx("span", { children: renderItem(option, isNotNullOrUndefined(selectedMap[option.id])) }) }));
1349
- }, [ItemComponent, handleOnSelect, multiple, renderItem, selectedMap]);
1350
- return (jsxRuntime.jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [jsxRuntime.jsx(DropdownMenu.Trigger, { className: cn('w-full', className), children: jsxRuntime.jsx(TextInput, Object.assign({ className: "[&>div>*]:cursor-pointer", inputClassName: "text-left" }, props, { value: text !== null && text !== void 0 ? text : '', clearable: clearable && !!selectedItems.length, onClear: handleOnClear, suffixIcon: lucideReact.ChevronDownIcon, onSuffixIconClick: () => setOpen((open) => !open), ref: ref, readOnly: true })) }), jsxRuntime.jsxs(DropdownMenu.Content, { className: "flex max-h-80 w-[calc(var(--radix-popper-anchor-width))] flex-col overflow-hidden", children: [search && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TextInput, { value: searchValue, placeholder: "Search...", size: props.size, onChange: handleOnSearchValueChange, clearable: !!searchValue.length, onClear: clearSearchValue }), jsxRuntime.jsx(DropdownMenu.Separator, { className: "w-full" })] })), filteredItems.length === 0 &&
1351
- (allowAddition && searchValue ? (jsxRuntime.jsxs("button", { className: "rounded bg-slate-100 py-1.5 text-center hover:bg-slate-200 dark:bg-slate-900/30 dark:hover:bg-slate-700/30", onClick: handleOnAddItemClicked, children: ["Add '", searchValue, "'"] })) : (jsxRuntime.jsx("div", { className: "py-1.5 text-center text-slate-500", children: "No items." }))), jsxRuntime.jsx(GroupComponent, { className: "flex flex-col gap-1 overflow-auto", value: !multiple && selectedItems.length ? String(selectedItems[0].id) : undefined, children: filteredItems.map((item, index) => item.group ? (jsxRuntime.jsxs(Flex, { className: "gap-1", direction: "column", fullWidth: true, children: [jsxRuntime.jsx(DropdownMenu.Label, { className: "sticky top-0 z-[51] w-full rounded-md border bg-white py-1 dark:bg-slate-900", children: item.label }), item.items.map((subItem) => (jsxRuntime.jsx(RenderOption, Object.assign({}, subItem), subItem.id))), index < filteredItems.length - 1 && (jsxRuntime.jsx("div", { className: "mb-1 h-px w-full bg-slate-200 dark:bg-slate-700" }))] }, item.id)) : (jsxRuntime.jsx(RenderOption, Object.assign({}, item), item.id))) })] })] }));
1352
- });
1353
- function isNotNullOrUndefined(value) {
1354
- return value !== null && value !== undefined;
1355
- }
1356
-
1357
- const FileInput = react.forwardRef((_a, ref) => {
1358
- var { className, value, onChange, onFileChange, accept } = _a, props = __rest(_a, ["className", "value", "onChange", "onFileChange", "accept"]);
1359
- const fileInputRef = react.useRef(null);
1360
- const handleFileChange = (_a) => __awaiter(void 0, [_a], void 0, function* ({ target: { files } }) {
1361
- console.log(files);
1362
- if (files && files.length > 0) {
1363
- const file = files[0];
1364
- console.log(file, file.name, onChange, onFileChange);
1365
- onChange === null || onChange === void 0 ? void 0 : onChange(file.name);
1366
- onFileChange === null || onFileChange === void 0 ? void 0 : onFileChange(file);
1367
- }
1368
- });
1369
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TextInput, Object.assign({ className: cn('[&>div>*]:cursor-pointer', className), inputClassName: "text-left" }, props, { value: value !== null && value !== void 0 ? value : '', onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, suffixIcon: lucideReact.CloudUploadIcon, onSuffixIconClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, ref: ref, readOnly: true })), jsxRuntime.jsx("input", { ref: (ref) => (fileInputRef.current = ref), type: "file", hidden: true, accept: accept, onChange: handleFileChange })] }));
1370
- });
1371
-
1372
- const FormGroup = ({ className, label, children }) => (jsxRuntime.jsxs(Flex, { className: cn('relative !gap-4 rounded-lg border p-4 dark:border-slate-700', className), direction: "column", fullWidth: true, children: [jsxRuntime.jsx("div", { className: "absolute right-0 top-0 rounded-bl-lg rounded-tr-lg bg-slate-500 px-2 py-1 font-medium text-white dark:bg-slate-900 dark:text-white", children: label }), children] }));
1373
-
1374
- function withForm(Component) {
1375
- return react.forwardRef((props, ref) => {
1376
- const _a = props, { name, pattern, validate } = _a, restProps = __rest(_a, ["name", "pattern", "validate"]);
1377
- const { control, formState } = reactHookForm.useFormContext();
1378
- return (jsxRuntime.jsx(reactHookForm.Controller, { name: name, control: control, rules: {
1379
- required: restProps.required,
1380
- min: restProps.min,
1381
- max: restProps.max,
1382
- minLength: restProps.minLength,
1383
- maxLength: restProps.maxLength,
1384
- pattern,
1385
- validate,
1386
- }, render: ({ field, fieldState }) => {
1387
- var _a, _b;
1388
- return (jsxRuntime.jsx(Component, Object.assign({}, restProps, field, { value: (_a = field.value) !== null && _a !== void 0 ? _a : '', disabled: ((_b = field.disabled) !== null && _b !== void 0 ? _b : restProps.disabled) ||
1389
- formState.isSubmitting, hasErrors: fieldState.error, ref: mergeRefs([ref, field.ref]) })));
1390
- } }));
1391
- });
1392
- }
1393
- const FormInputs = {
1394
- Text: withForm(TextInput),
1395
- Email: withForm(EmailInput),
1396
- Password: withForm(PasswordInput),
1397
- Textarea: withForm(TextareaInput),
1398
- Number: withForm(NumberInput),
1399
- Checkbox: withForm(CheckboxInput),
1400
- DateTime: withForm(DateTimeInput),
1401
- Select: withForm(SelectInput),
1402
- File: withForm(FileInput),
1403
- };
1404
-
1405
- const HintRoot = react.forwardRef(({ children }, ref) => (jsxRuntime.jsx(Block, { className: "relative", ref: ref, children: children })));
1406
- HintRoot.displayName = 'HintRoot';
1407
- const dotSizeClassNames = {
1408
- small: {
1409
- base: 'h-2 w-2',
1410
- top: '-top-0.5',
1411
- right: '-right-0.5',
1412
- bottom: '-bottom-0.5',
1413
- left: '-left-0.5',
1414
- },
1415
- medium: {
1416
- base: 'h-3 w-3',
1417
- top: '-top-1',
1418
- right: '-right-1',
1419
- bottom: '-bottom-1',
1420
- left: '-left-1',
1421
- },
1422
- };
1423
- const colorClassNames = {
1424
- slate: 'bg-slate-500 dark:bg-slate-600',
1425
- gray: 'bg-gray-500 dark:bg-gray-600',
1426
- zinc: 'bg-zinc-500 dark:bg-zinc-600',
1427
- neutral: 'bg-neutral-500 dark:bg-neutral-600',
1428
- stone: 'bg-stone-500 dark:bg-stone-600',
1429
- red: 'bg-red-500 dark:bg-red-600',
1430
- orange: 'bg-orange-500 dark:bg-orange-600',
1431
- amber: 'bg-amber-500 dark:bg-amber-600',
1432
- yellow: 'bg-yellow-500 dark:bg-yellow-600',
1433
- lime: 'bg-lime-500 dark:bg-lime-600',
1434
- green: 'bg-green-500 dark:bg-green-600',
1435
- emerald: 'bg-emerald-500 dark:bg-emerald-600',
1436
- teal: 'bg-teal-500 dark:bg-teal-600',
1437
- cyan: 'bg-cyan-500 dark:bg-cyan-600',
1438
- sky: 'bg-sky-500 dark:bg-sky-600',
1439
- blue: 'bg-blue-500 dark:bg-blue-600',
1440
- indigo: 'bg-indigo-500 dark:bg-indigo-600',
1441
- violet: 'bg-violet-500 dark:bg-violet-600',
1442
- fuchsia: 'bg-fuchsia-500 dark:bg-fuchsia-600',
1443
- purple: 'bg-purple-500 dark:bg-purple-600',
1444
- pink: 'bg-pink-500 dark:bg-pink-600',
1445
- rose: 'bg-rose-500 dark:bg-rose-600',
1446
- };
1447
- const HintDot = react.forwardRef(({ size = 'medium', placement = 'top-right', color = 'green', ping }, ref) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Block, { className: cn('absolute rounded-full', colorClassNames[color], dotSizeClassNames[size].base, {
1448
- [`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].left}`]: placement === 'top-left',
1449
- [`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].right}`]: placement === 'top-right',
1450
- [`${dotSizeClassNames[size].bottom} ${dotSizeClassNames[size].right}`]: placement === 'bottom-right',
1451
- [`${dotSizeClassNames[size].bottom} ${dotSizeClassNames[size].left}`]: placement === 'bottom-left',
1452
- }), ref: ref }), ping && (jsxRuntime.jsx(Block, { className: cn('absolute animate-ping rounded-full', colorClassNames[color], dotSizeClassNames[size].base, {
1453
- [`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].left}`]: placement === 'top-left',
1454
- [`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].right}`]: placement === 'top-right',
1455
- [`${dotSizeClassNames[size].bottom} ${dotSizeClassNames[size].right}`]: placement === 'bottom-right',
1456
- [`${dotSizeClassNames[size].bottom} ${dotSizeClassNames[size].left}`]: placement === 'bottom-left',
1457
- }) }))] })));
1458
- HintDot.displayName = 'HintDot';
1459
- const badgeSizeClassNames = {
1460
- top: 'top-0 -translate-y-1/2',
1461
- right: 'right-2 translate-x-full',
1462
- bottom: 'bottom-0 translate-y-1/2',
1463
- left: 'left-2 -translate-x-full',
1464
- };
1465
- const HintBadge = react.forwardRef((_a, ref) => {
1466
- var { className, size = 'small', placement = 'top-right' } = _a, props = __rest(_a, ["className", "size", "placement"]);
1467
- return (jsxRuntime.jsx(Badge, Object.assign({ className: cn('absolute px-1', size === 'small' ? 'h-5' : 'h-6', {
1468
- [`${badgeSizeClassNames.top} ${badgeSizeClassNames.left}`]: placement === 'top-left',
1469
- [`${badgeSizeClassNames.top} ${badgeSizeClassNames.right}`]: placement === 'top-right',
1470
- [`${badgeSizeClassNames.bottom} ${badgeSizeClassNames.right}`]: placement === 'bottom-right',
1471
- [`${badgeSizeClassNames.bottom} ${badgeSizeClassNames.left}`]: placement === 'bottom-left',
1472
- }, className), size: size }, props, { ref: ref })));
1473
- });
1474
- HintBadge.displayName = 'HintBadge';
1475
- const Hint = Object.assign(HintRoot, { Dot: HintDot, Badge: HintBadge });
1476
-
1477
- const Pagination = ({ disabled, pageSize = 10, currentPage, totalItems, setCurrentPage, }) => {
1478
- const totalPages = react.useMemo(() => Math.ceil(totalItems / pageSize), [pageSize, totalItems]);
1479
- const pagination = usePagination(currentPage + 1, totalPages);
1480
- react.useEffect(() => {
1481
- setCurrentPage((page) => Math.min(page, Math.max(0, totalPages - 1)));
1482
- }, [setCurrentPage, totalPages]);
1483
- return (jsxRuntime.jsx(Flex, { justify: "end", children: jsxRuntime.jsxs(Flex, { className: "h-10 gap-0 divide-x rounded-md border border-slate-300 bg-white dark:divide-slate-700 dark:border-slate-700 dark:bg-slate-800", children: [jsxRuntime.jsx(PaginationItem, { title: "First page", onClick: () => setCurrentPage(0), disabled: !currentPage || disabled, children: jsxRuntime.jsx(lucideReact.ChevronsLeftIcon, { className: "h-5 w-5" }) }), jsxRuntime.jsx(PaginationItem, { title: "Previous page", onClick: () => currentPage && setCurrentPage(currentPage - 1), disabled: !currentPage || disabled, children: jsxRuntime.jsx(lucideReact.ChevronLeftIcon, { className: "h-5 w-5" }) }), pagination.map((page, index) => (jsxRuntime.jsx(PaginationItem, { active: page !== '...' && page - 1 === currentPage, title: page !== '...' ? `Page ${page}` : undefined, onClick: page !== '...' ? () => setCurrentPage(page - 1) : undefined, disabled: page === '...' || disabled, children: page }, index))), jsxRuntime.jsx(PaginationItem, { title: "Next page", onClick: () => currentPage + 1 < totalPages && setCurrentPage(currentPage + 1), disabled: currentPage + 1 === totalPages || disabled, children: jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: "h-5 w-5" }) }), jsxRuntime.jsx(PaginationItem, { title: "Last page", onClick: () => setCurrentPage(Math.floor(totalItems && !(totalItems % pageSize)
1484
- ? (totalItems - 1) / pageSize
1485
- : totalItems / pageSize)), disabled: currentPage + 1 === totalPages || disabled, children: jsxRuntime.jsx(lucideReact.ChevronsRightIcon, { className: "h-5 w-5" }) })] }) }));
1486
- };
1487
- const PaginationItem = (_a) => {
1488
- var { children, active, disabled } = _a, props = __rest(_a, ["children", "active", "disabled"]);
1489
- return (jsxRuntime.jsx(Flex, Object.assign({ className: cn('w-10 first:rounded-l-md last:rounded-r-md', {
1490
- 'text-slate-400 dark:text-slate-500': disabled,
1491
- 'bg-slate-100 dark:bg-slate-900': active,
1492
- 'cursor-pointer hover:bg-slate-200 dark:hover:bg-slate-900': !disabled && props.onClick,
1493
- }), align: "center", justify: "center", fullHeight: true }, props, { children: children })));
1494
- };
1495
-
1496
- const Spinner = ({ className, fullScreen }) => (jsxRuntime.jsx("div", { className: cn('flex w-full items-center justify-center bg-white dark:bg-slate-900', {
1497
- 'h-screen': fullScreen,
1498
- 'h-full': !fullScreen,
1499
- }, className), children: jsxRuntime.jsxs("svg", { className: "h-8 w-8 animate-spin text-black dark:text-white", fill: "none", viewBox: "0 0 24 24", children: [jsxRuntime.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), jsxRuntime.jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }) }));
1500
-
1501
- const $Table = (_a) => {
1502
- var { children, className } = _a, props = __rest(_a, ["children", "className"]);
1503
- return (jsxRuntime.jsx(Flex, { className: cn('overflow-auto rounded-lg', className), fullWidth: true, children: jsxRuntime.jsx("table", Object.assign({ className: "min-w-full divide-y divide-slate-200 dark:divide-slate-800 dark:text-white" }, props, { children: children })) }));
1504
- };
1505
- const TableHead = (_a) => {
1506
- var { children, className } = _a, props = __rest(_a, ["children", "className"]);
1507
- return (jsxRuntime.jsx("thead", Object.assign({ className: cn('border-b bg-slate-100 text-slate-800 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300', className) }, props, { children: children })));
1508
- };
1509
- const TableHeadCell = (_a) => {
1510
- var { children, className } = _a, props = __rest(_a, ["children", "className"]);
1511
- return (jsxRuntime.jsx("th", Object.assign({ className: cn('px-4 py-2 font-medium', className) }, props, { children: children })));
1512
- };
1513
- const TableBody = (_a) => {
1514
- var { children, className } = _a, props = __rest(_a, ["children", "className"]);
1515
- return (jsxRuntime.jsx("tbody", Object.assign({ className: cn('divide-y divide-slate-200 bg-slate-50/80 dark:divide-slate-700 dark:bg-slate-900', className) }, props, { children: children })));
1516
- };
1517
- const TableRow = (_a) => {
1518
- var { children } = _a, props = __rest(_a, ["children"]);
1519
- return (jsxRuntime.jsx("tr", Object.assign({}, props, { children: children })));
1520
- };
1521
- const TableCell = (_a) => {
1522
- var { children, className } = _a, props = __rest(_a, ["children", "className"]);
1523
- return (jsxRuntime.jsx("td", Object.assign({ className: cn('px-4 py-2', className) }, props, { children: children })));
1524
- };
1525
- const TableFooter = (_a) => {
1526
- var { children, className } = _a, props = __rest(_a, ["children", "className"]);
1527
- return (jsxRuntime.jsx("tfoot", Object.assign({ className: cn('bg-slate-100 text-slate-800 dark:bg-slate-800 dark:text-slate-300', className) }, props, { children: children })));
1528
- };
1529
- const Table = Object.assign($Table, {
1530
- Head: TableHead,
1531
- HeadCell: TableHeadCell,
1532
- Body: TableBody,
1533
- Row: TableRow,
1534
- Cell: TableCell,
1535
- Footer: TableFooter,
1536
- });
1537
-
1538
- const possiblePageSize = [5, 10, 25, 50, 100, 500, 1000];
1539
- function defaultRender(item, field) {
1540
- return resolveTargetObject(item, field.split('.'), '-');
1541
- }
1542
- function DataTable({ className, columns, rows, sorting, pagination, actions = [], isLoading, rowExtraContent, noDataMessage, onRowClick, rowClassName, }) {
1543
- var _a;
1544
- const footerRef = react.useRef(null);
1545
- const [expandedRows, setExpandedRows] = react.useState({});
1546
- const allRowsExpanded = react.useMemo(() => rowExtraContent ? rows.every((row) => expandedRows[rowExtraContent.idGetter(row)]) : false, [expandedRows, rowExtraContent, rows]);
1547
- const _columns = react.useMemo(() => (Array.isArray(columns) ? columns : Object.values(columns)).filter((column) => !column.hide), [columns]);
1548
- const columnsLength = react.useMemo(() => (rowExtraContent ? 1 : 0) + _columns.length + Math.min(1, actions.length), [_columns.length, actions.length, rowExtraContent]);
1549
- const handleSorting = (field, comparator) => () => {
1550
- if (!sorting)
1551
- return;
1552
- if (!sorting.sorting) {
1553
- sorting.onSortingChange({
1554
- field,
1555
- direction: 'asc',
1556
- comparator: comparator !== null && comparator !== void 0 ? comparator : generalComparator,
1557
- });
1558
- }
1559
- else {
1560
- const newDirection = sorting.sorting.field === field && sorting.sorting.direction === 'asc' ? 'desc' : 'asc';
1561
- sorting.onSortingChange({
1562
- field,
1563
- direction: newDirection,
1564
- comparator: comparator !== null && comparator !== void 0 ? comparator : generalComparator,
1565
- });
1566
- }
1567
- };
1568
- const handleActionClicked = (action, item, rowIndex) => (event) => {
1569
- event.stopPropagation();
1570
- action.onClick(item, rowIndex);
1571
- };
1572
- const handleRowClicked = (item, rowIndex) => (event) => {
1573
- event.stopPropagation();
1574
- if (onRowClick) {
1575
- return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(item, rowIndex);
1576
- }
1577
- if (rowExtraContent) {
1578
- handleExpandRow(rowExtraContent.idGetter(item))(event);
1579
- }
1580
- };
1581
- const handleExpandAll = (event) => {
1582
- event.stopPropagation();
1583
- if (!rowExtraContent)
1584
- return;
1585
- setExpandedRows((prev) => (Object.assign(Object.assign({}, prev), rows.reduce((acc, row) => (Object.assign(Object.assign({}, acc), { [rowExtraContent.idGetter(row)]: !allRowsExpanded })), {}))));
1586
- };
1587
- const handleExpandRow = (id) => (event) => {
1588
- event.stopPropagation();
1589
- setExpandedRows((prev) => (rowExtraContent === null || rowExtraContent === void 0 ? void 0 : rowExtraContent.singleExpansion) ? { [id]: !prev[id] } : Object.assign(Object.assign({}, prev), { [id]: !prev[id] }));
1590
- };
1591
- return (jsxRuntime.jsxs(Table, { className: cn('border dark:border-slate-700', className), children: [jsxRuntime.jsx(Table.Head, { className: "sticky top-0 z-10", children: jsxRuntime.jsxs(Table.Row, { children: [rowExtraContent && (jsxRuntime.jsx(Table.HeadCell, { align: "center", children: !rowExtraContent.singleExpansion && (jsxRuntime.jsx(ExpandButton, { folded: !allRowsExpanded, foldComponent: lucideReact.ChevronsDownUpIcon, unfoldComponent: lucideReact.ChevronsUpDownIcon, onClick: handleExpandAll })) })), _columns.map((column, columnIndex) => {
1592
- var _a, _b, _c;
1593
- return (jsxRuntime.jsxs(Table.HeadCell, { className: cn('group relative', {
1594
- 'cursor-pointer': !isLoading && sorting && !column.noSorting,
1595
- }), align: (_a = column.align) !== null && _a !== void 0 ? _a : 'left', onClick: !isLoading && sorting && !column.noSorting
1596
- ? handleSorting(column.field, column.comparator)
1597
- : undefined, children: [column.header, sorting &&
1598
- !column.noSorting &&
1599
- (((_b = sorting.sorting) === null || _b === void 0 ? void 0 : _b.field) !== column.field ? (jsxRuntime.jsx(lucideReact.ArrowUpDownIcon, { className: "absolute top-1/2 float-right ml-1 hidden h-4 w-4 -translate-y-1/2 group-hover:inline-block" })) : ((_c = sorting.sorting) === null || _c === void 0 ? void 0 : _c.direction) === 'asc' ? (jsxRuntime.jsx(lucideReact.SortAscIcon, { className: "absolute top-1/2 float-right ml-1 inline-block h-4 w-4 -translate-y-1/2" })) : (jsxRuntime.jsx(lucideReact.SortDescIcon, { className: "absolute top-1/2 float-right ml-1 inline-block h-4 w-4 -translate-y-1/2" })))] }, columnIndex));
1600
- }), actions.filter((action) => !action.hide).length > 0 && (jsxRuntime.jsx(Table.HeadCell, { align: "center", children: "Actions" }))] }) }), jsxRuntime.jsxs(Table.Body, { className: "relative", children: [isLoading && (jsxRuntime.jsx(Table.Row, { children: jsxRuntime.jsx(Table.Cell, { className: cn('z-10 h-full w-full p-0', {
1601
- absolute: rows.length,
1602
- }), colSpan: columnsLength, children: jsxRuntime.jsx(Spinner, { className: "bg-white/50 py-4 dark:bg-slate-700/50" }) }) })), !isLoading && !rows.length && (jsxRuntime.jsx(Table.Row, { children: jsxRuntime.jsx(Table.Cell, { colSpan: columnsLength, children: jsxRuntime.jsx(Flex, { className: "text-slate-500", justify: "center", children: noDataMessage !== null && noDataMessage !== void 0 ? noDataMessage : 'No data' }) }) })), rows.map((item, rowIndex) => [
1603
- jsxRuntime.jsxs(Table.Row, { className: cn({
1604
- 'cursor-pointer hover:bg-slate-100 dark:hover:bg-slate-800': onRowClick || rowExtraContent,
1605
- }, rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(item, rowIndex)), onClick: handleRowClicked(item, rowIndex), children: [rowExtraContent && (jsxRuntime.jsx(Table.Cell, { className: "w-min", align: "center", children: jsxRuntime.jsx(ExpandButton, { folded: !expandedRows[rowExtraContent.idGetter(item)], foldComponent: lucideReact.MinusIcon, unfoldComponent: lucideReact.PlusIcon, onClick: handleExpandRow(rowExtraContent.idGetter(item)) }) })), _columns.map((column, columnIndex) => {
1606
- var _a, _b, _c;
1607
- return (jsxRuntime.jsx(Table.Cell, { className: column.className, align: (_a = column.align) !== null && _a !== void 0 ? _a : 'left', children: (_c = (_b = column.render) === null || _b === void 0 ? void 0 : _b.call(column, item, rowIndex)) !== null && _c !== void 0 ? _c : defaultRender(item, column.field) }, columnIndex));
1608
- }), actions.filter((action) => !action.hide).length > 0 && (jsxRuntime.jsx(Table.Cell, { className: "py-3", children: jsxRuntime.jsx(Flex, { align: "center", justify: "center", children: actions
1609
- .filter((action) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); })
1610
- .map((action, actionIndex) => {
1611
- var _a;
1612
- const notification = (_a = action.hasNotification) === null || _a === void 0 ? void 0 : _a.call(action, item, rowIndex);
1613
- return (jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx(Button, { size: "small", prefixIcon: action.icon, color: action.color, onClick: handleActionClicked(action, item, rowIndex), children: action.label }), notification &&
1614
- (notification === true ? (jsxRuntime.jsx(Hint.Dot, {})) : notification.type === 'dot' ? (jsxRuntime.jsx(Hint.Dot, Object.assign({}, notification.props))) : (jsxRuntime.jsx(Hint.Badge, Object.assign({}, notification.props))))] }, actionIndex));
1615
- }) }) }))] }, rowIndex),
1616
- rowExtraContent && expandedRows[rowExtraContent.idGetter(item)] && (jsxRuntime.jsx(Table.Row, { children: jsxRuntime.jsx(Table.Cell, { className: "p-0", colSpan: columnsLength, children: jsxRuntime.jsx(rowExtraContent.component, { item: item, rowIndex: rowIndex }) }) }, `${rowIndex}-expanded`)),
1617
- ])] }), pagination && (jsxRuntime.jsx(Table.Footer, { className: "sticky -bottom-px", children: jsxRuntime.jsx(Table.Row, { className: "border-t dark:border-slate-700", children: jsxRuntime.jsx(Table.Cell, { colSpan: columnsLength, children: jsxRuntime.jsxs(Flex, { justify: "end", ref: footerRef, children: [jsxRuntime.jsx(Pagination, Object.assign({ disabled: isLoading }, pagination)), pagination.onPageSizeChange && (jsxRuntime.jsx(SelectInput, { className: "w-32", value: (_a = pagination.pageSize) !== null && _a !== void 0 ? _a : 10, items: possiblePageSize.map((pageSize) => ({
1618
- id: pageSize,
1619
- label: String(pageSize),
1620
- value: pageSize,
1621
- })), onChange: (newPageSize) => { var _a; return newPageSize && ((_a = pagination.onPageSizeChange) === null || _a === void 0 ? void 0 : _a.call(pagination, newPageSize)); }, disabled: isLoading, parentRef: footerRef }))] }) }) }) }))] }));
1622
- }
1623
- const ExpandButton = ({ folded, foldComponent, unfoldComponent, onClick, }) => {
1624
- const Icon = folded ? unfoldComponent : foldComponent;
1625
- return (jsxRuntime.jsx(Icon, { className: "h-6 w-6 cursor-pointer rounded p-1 hover:bg-slate-300 hover:dark:bg-slate-600", onClick: onClick }));
1626
- };
1627
-
1628
- const $Dialog = (props) => (jsxRuntime.jsx(DialogPrimitive__namespace.Root, Object.assign({}, props)));
1629
- $Dialog.displayName = DialogPrimitive__namespace.Root.displayName;
1630
- const DialogTrigger = DialogPrimitive__namespace.Trigger;
1631
- const DialogPortal = DialogPrimitive__namespace.Portal;
1632
- const DialogClose = DialogPrimitive__namespace.Close;
1633
- const DialogOverlay = react.forwardRef((_a, ref) => {
1634
- var { className } = _a, props = __rest(_a, ["className"]);
1635
- return (jsxRuntime.jsx(DialogPrimitive__namespace.Overlay, Object.assign({ ref: ref, className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className) }, props)));
1636
- });
1637
- DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
1638
- const DialogContent = react.forwardRef((_a, ref) => {
1639
- var { className, fullScreen, children } = _a, props = __rest(_a, ["className", "fullScreen", "children"]);
1640
- return (jsxRuntime.jsxs(DialogPortal, { children: [jsxRuntime.jsx(DialogOverlay, {}), jsxRuntime.jsxs(DialogPrimitive__namespace.Content, Object.assign({ ref: ref, className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', 'fixed left-[50%] top-[50%] z-50 flex max-h-[95dvh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-lg border p-4 shadow-lg duration-200', className, fullScreen && 'h-full max-h-none w-full max-w-none rounded-none'), "aria-describedby": "dialog-content" }, props, { children: [children, jsxRuntime.jsx(DialogPrimitive__namespace.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, children: jsxRuntime.jsx(Button, { prefixIcon: lucideReact.XIcon, size: "small", variant: "text" }) }), jsxRuntime.jsx(DialogPrimitive__namespace.Description, { className: "hidden" })] }))] }));
1641
- });
1642
- DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
1643
- const DialogHeader = (_a) => {
1644
- var { className } = _a, props = __rest(_a, ["className"]);
1645
- return (jsxRuntime.jsx("div", Object.assign({ className: cn('flex flex-col space-y-1.5 text-left', className) }, props)));
1646
- };
1647
- DialogHeader.displayName = 'DialogHeader';
1648
- const DialogFooter = (_a) => {
1649
- var { className } = _a, props = __rest(_a, ["className"]);
1650
- return (jsxRuntime.jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className) }, props)));
1651
- };
1652
- DialogFooter.displayName = 'DialogFooter';
1653
- const DialogTitle = react.forwardRef((_a, ref) => {
1654
- var { className } = _a, props = __rest(_a, ["className"]);
1655
- return (jsxRuntime.jsx(DialogPrimitive__namespace.Title, Object.assign({ ref: ref, className: cn('text-foreground text-lg font-semibold', className) }, props)));
1656
- });
1657
- DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
1658
- const DialogDescription = react.forwardRef((_a, ref) => {
1659
- var { className } = _a, props = __rest(_a, ["className"]);
1660
- return (jsxRuntime.jsx(DialogPrimitive__namespace.Description, Object.assign({ ref: ref, className: cn('text-muted-foreground text-sm', className) }, props)));
1661
- });
1662
- DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
1663
- const Dialog = Object.assign($Dialog, {
1664
- Portal: DialogPortal,
1665
- Overlay: DialogOverlay,
1666
- Close: DialogClose,
1667
- Trigger: DialogTrigger,
1668
- Content: DialogContent,
1669
- Header: DialogHeader,
1670
- Footer: DialogFooter,
1671
- Title: DialogTitle,
1672
- Description: DialogDescription,
1673
- });
1674
-
1675
- const ConfirmDialog = ({ open, title, children, yesLabel, noLabel, onConfirm, onClose, }) => (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxRuntime.jsxs(Dialog.Content, { children: [jsxRuntime.jsx(Dialog.Header, { children: jsxRuntime.jsx(Dialog.Title, { children: title }) }), children, jsxRuntime.jsxs(Dialog.Footer, { children: [jsxRuntime.jsx(Dialog.Close, { asChild: true, children: jsxRuntime.jsx(Button, { color: "red", children: noLabel !== null && noLabel !== void 0 ? noLabel : 'No' }) }), jsxRuntime.jsx(Dialog.Close, { asChild: true, children: jsxRuntime.jsx(Button, { color: "green", onClick: onConfirm, children: yesLabel !== null && yesLabel !== void 0 ? yesLabel : 'Yes' }) })] })] }) }));
1676
-
1677
- const $Sheet = (props) => (jsxRuntime.jsx(DialogPrimitive__namespace.Root, Object.assign({}, props)));
1678
- $Sheet.displayName = DialogPrimitive__namespace.Root.displayName;
1679
- const SheetTrigger = DialogPrimitive__namespace.Trigger;
1680
- const SheetClose = DialogPrimitive__namespace.Close;
1681
- const SheetPortal = DialogPrimitive__namespace.Portal;
1682
- const SheetOverlay = react.forwardRef((_a, ref) => {
1683
- var { className } = _a, props = __rest(_a, ["className"]);
1684
- return (jsxRuntime.jsx(DialogPrimitive__namespace.Overlay, Object.assign({ className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className) }, props, { ref: ref })));
1685
- });
1686
- SheetOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
1687
- const sheetVariants = classVarianceAuthority.cva('fixed flex flex-col z-50 gap-4 bg-background p-4 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500', {
1688
- variants: {
1689
- side: {
1690
- top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
1691
- bottom: 'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
1692
- left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
1693
- right: 'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
1694
- },
1695
- },
1696
- defaultVariants: {
1697
- side: 'right',
1698
- },
1699
- });
1700
- const SheetContent = react.forwardRef((_a, ref) => {
1701
- var { side = 'right', className, children } = _a, props = __rest(_a, ["side", "className", "children"]);
1702
- return (jsxRuntime.jsxs(SheetPortal, { children: [jsxRuntime.jsx(SheetOverlay, {}), jsxRuntime.jsxs(DialogPrimitive__namespace.Content, Object.assign({ ref: ref, className: cn(sheetVariants({ side }), className) }, props, { children: [children, jsxRuntime.jsx(DialogPrimitive__namespace.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, children: jsxRuntime.jsx(Button, { prefixIcon: lucideReact.XIcon, size: "small", variant: "text" }) }), jsxRuntime.jsx(DialogPrimitive__namespace.Description, { className: "hidden" })] }))] }));
1703
- });
1704
- SheetContent.displayName = DialogPrimitive__namespace.Content.displayName;
1705
- const SheetHeader = (_a) => {
1706
- var { className } = _a, props = __rest(_a, ["className"]);
1707
- return (jsxRuntime.jsx("div", Object.assign({ className: cn('flex flex-col space-y-2 text-center sm:text-left', className) }, props)));
1708
- };
1709
- SheetHeader.displayName = 'SheetHeader';
1710
- const SheetFooter = (_a) => {
1711
- var { className } = _a, props = __rest(_a, ["className"]);
1712
- return (jsxRuntime.jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className) }, props)));
1713
- };
1714
- SheetFooter.displayName = 'SheetFooter';
1715
- const SheetTitle = react.forwardRef((_a, ref) => {
1716
- var { className } = _a, props = __rest(_a, ["className"]);
1717
- return (jsxRuntime.jsx(DialogPrimitive__namespace.Title, Object.assign({ ref: ref, className: cn('text-foreground text-lg font-semibold', className) }, props)));
1718
- });
1719
- SheetTitle.displayName = DialogPrimitive__namespace.Title.displayName;
1720
- const SheetDescription = react.forwardRef((_a, ref) => {
1721
- var { className } = _a, props = __rest(_a, ["className"]);
1722
- return (jsxRuntime.jsx(DialogPrimitive__namespace.Description, Object.assign({ ref: ref, className: cn('text-muted-foreground text-sm', className) }, props)));
1723
- });
1724
- SheetDescription.displayName = DialogPrimitive__namespace.Description.displayName;
1725
- const Sheet = Object.assign($Sheet, {
1726
- Portal: SheetPortal,
1727
- Overlay: SheetOverlay,
1728
- Trigger: SheetTrigger,
1729
- Close: SheetClose,
1730
- Content: SheetContent,
1731
- Header: SheetHeader,
1732
- Footer: SheetFooter,
1733
- Title: SheetTitle,
1734
- Description: SheetDescription,
1735
- });
1736
-
1737
- const FormDialog = ({ className, formClassName, open, title, form, children, submitLabel = 'Submit', cancelLabel = 'Cancel', extraAction, as: As = Sheet, onSubmit, onInvalid, onClose, }) => {
1738
- const id = react.useId();
1739
- const handleSubmit = (data, event) => __awaiter(void 0, void 0, void 0, function* () {
1740
- try {
1741
- yield onSubmit(data, event);
1742
- }
1743
- catch (_a) {
1744
- // do nothering
1745
- }
1746
- });
1747
- return (jsxRuntime.jsx(As, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxRuntime.jsxs(As.Content, { className: className, children: [jsxRuntime.jsx(As.Header, { children: jsxRuntime.jsx(As.Title, { children: title }) }), jsxRuntime.jsx(reactHookForm.FormProvider, Object.assign({}, form, { children: jsxRuntime.jsx("form", { id: `form-${id}`, className: cn('flex h-full w-full flex-col gap-3 overflow-auto', formClassName), onSubmit: form.handleSubmit(handleSubmit, onInvalid), children: children }) })), jsxRuntime.jsxs(As.Footer, { className: "w-full sm:justify-between", children: [extraAction, jsxRuntime.jsxs(As.Footer, { className: "ml-auto", children: [jsxRuntime.jsx(As.Close, { asChild: true, children: jsxRuntime.jsx(Button, { color: "red", children: cancelLabel }) }), jsxRuntime.jsx(Button, { color: "green", type: "submit", form: `form-${id}`, disabled: form.formState.isSubmitting, children: submitLabel })] })] })] }) }));
1748
- };
1749
-
1750
- function ListSorter({ className, items, idResolver, renderer, onChange, }) {
1751
- const adaptedItems = react.useMemo(() => items.map((value, index) => ({ id: idResolver(value, index), value })), [idResolver, items]);
1752
- const sensors = core.useSensors(core.useSensor(core.PointerSensor), core.useSensor(core.KeyboardSensor, { coordinateGetter: sortable.sortableKeyboardCoordinates }));
1753
- const onDragEnd = ({ active, over }) => {
1754
- if (!over || active.id === over.id)
1755
- return;
1756
- const sortedItems = structuredClone(adaptedItems);
1757
- const oldIndex = sortedItems.findIndex((item) => item.id === active.id);
1758
- const newIndex = sortedItems.findIndex((item) => item.id === over.id);
1759
- const [removed] = sortedItems.splice(oldIndex, 1);
1760
- sortedItems.splice(newIndex, 0, removed);
1761
- for (const [index, { value }] of Object.entries(sortedItems)) {
1762
- if (typeof value === 'object') {
1763
- value.rank = +index;
1764
- }
1765
- }
1766
- onChange(sortedItems.map(({ value }) => value));
1767
- };
1768
- return (jsxRuntime.jsx(core.DndContext, { sensors: sensors, modifiers: [modifiers.restrictToFirstScrollableAncestor], collisionDetection: core.closestCenter, onDragEnd: onDragEnd, children: jsxRuntime.jsx(sortable.SortableContext, { items: adaptedItems, strategy: sortable.verticalListSortingStrategy, children: jsxRuntime.jsx("div", { className: className, children: adaptedItems.map((item, index) => (jsxRuntime.jsx(SortableItem, { item: item, index: index, renderer: renderer }, item.id))) }) }) }));
1769
- }
1770
- function SortableItem({ item, index, renderer, }) {
1771
- const { attributes, listeners, setNodeRef, transform, transition } = sortable.useSortable({ id: item.id });
1772
- const style = { transform: utilities.CSS.Transform.toString(transform), transition };
1773
- return (jsxRuntime.jsx("div", Object.assign({ ref: setNodeRef, style: style }, attributes, { children: renderer(item.value, index, listeners) })));
1774
- }
1775
-
1776
- function ListSorterDialog({ className, open, title, items, idResolver, renderer, cancelLabel, submitLabel, onSubmit, onClose, }) {
1777
- const [sortedItems, setSortedItems] = react.useState(structuredClone(items));
1778
- react.useEffect(() => {
1779
- return () => {
1780
- setSortedItems(structuredClone(items));
1781
- };
1782
- }, [items]);
1783
- const preFinish = () => onSubmit(sortedItems);
1784
- const customRenderer = (item, index, listeners) => (jsxRuntime.jsxs(Flex, { align: "center", className: "gap-4 p-4 focus:outline-none dark:bg-slate-900 hover:dark:bg-slate-800", children: [jsxRuntime.jsx(Flex, Object.assign({ align: "center", justify: "center", className: "cursor-move rounded-lg p-2 hover:bg-slate-200 dark:hover:bg-slate-700" }, listeners, { children: jsxRuntime.jsx(lucideReact.ArrowUpDownIcon, { className: "h-5 w-5" }) })), renderer(item, index, listeners)] }));
1785
- return (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxRuntime.jsxs(Dialog.Content, { className: className, onPointerDownOutside: (event) => event.preventDefault(), children: [jsxRuntime.jsx(Dialog.Header, { children: jsxRuntime.jsx(Dialog.Title, { children: title }) }), jsxRuntime.jsx(ListSorter, { className: "divide-y overflow-auto rounded-lg border dark:divide-slate-700 dark:border-slate-700 dark:text-white", items: sortedItems, idResolver: idResolver, renderer: customRenderer, onChange: setSortedItems }), jsxRuntime.jsxs(Dialog.Footer, { children: [jsxRuntime.jsx(Dialog.Close, { asChild: true, children: jsxRuntime.jsx(Button, { color: "red", children: cancelLabel !== null && cancelLabel !== void 0 ? cancelLabel : 'Cancel' }) }), jsxRuntime.jsx(Button, { color: "green", onClick: preFinish, children: submitLabel !== null && submitLabel !== void 0 ? submitLabel : 'Submit' })] })] }) }));
1786
- }
1787
-
1788
- const PdfViewerDialog = ({ open, title, url, data, onClose }) => {
1789
- return !(url || data) ? null : (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxRuntime.jsxs(Dialog.Content, { className: "h-[95dvh] max-w-[95dvw]", children: [jsxRuntime.jsx(Dialog.Header, { children: jsxRuntime.jsx(Dialog.Title, { children: title }) }), (url || data) && (jsxRuntime.jsx("embed", { className: "rounded-lg", src: url !== null && url !== void 0 ? url : `data:application/pdf;base64,${data}`, type: "application/pdf", width: "100%", height: "100%" }))] }) }));
1790
- };
1791
-
1792
- const Separator = react.forwardRef((_a, ref) => {
1793
- var { className, orientation = 'horizontal', decorative = true } = _a, props = __rest(_a, ["className", "orientation", "decorative"]);
1794
- return (jsxRuntime.jsx(SeparatorPrimitive__namespace.Root, Object.assign({ ref: ref, decorative: decorative, orientation: orientation, className: cn('bg-border shrink-0', orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', className) }, props)));
1795
- });
1796
- Separator.displayName = SeparatorPrimitive__namespace.Root.displayName;
1797
-
1798
- const Skeleton = (_a) => {
1799
- var { className } = _a, props = __rest(_a, ["className"]);
1800
- return (jsxRuntime.jsx("div", Object.assign({ className: cn('bg-muted animate-pulse rounded-md', className) }, props)));
1801
- };
1802
- Skeleton.displayName = 'Skeleton';
1803
-
1804
- const SIDEBAR_COOKIE_NAME = 'sidebar:state';
1805
- const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
1806
- const SIDEBAR_WIDTH = '16rem';
1807
- const SIDEBAR_WIDTH_MOBILE = '18rem';
1808
- const SIDEBAR_WIDTH_ICON = '3rem';
1809
- const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
1810
- const SidebarContext = react.createContext(null);
1811
- function useSidebar() {
1812
- const context = react.useContext(SidebarContext);
1813
- if (!context) {
1814
- throw new Error('useSidebar must be used within a SidebarProvider.');
1815
- }
1816
- return context;
1817
- }
1818
- const SidebarContextProvider = react.forwardRef((_a, ref) => {
1819
- var { defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children } = _a, props = __rest(_a, ["defaultOpen", "open", "onOpenChange", "className", "style", "children"]);
1820
- const isMobile = useIsMobile();
1821
- const [openMobile, setOpenMobile] = react.useState(false);
1822
- const screenRef = react.useRef(document.documentElement);
1823
- // This is the internal state of the sidebar.
1824
- // We use openProp and setOpenProp for control from outside the component.
1825
- const [_open, _setOpen] = react.useState(getValueFromCookie(SIDEBAR_COOKIE_NAME, defaultOpen));
1826
- const open = openProp !== null && openProp !== void 0 ? openProp : _open;
1827
- const setOpen = react.useCallback((value) => {
1828
- if (setOpenProp) {
1829
- return setOpenProp === null || setOpenProp === void 0 ? void 0 : setOpenProp(typeof value === 'function' ? value(open) : value);
1830
- }
1831
- const newValue = typeof value === 'function' ? value(open) : value;
1832
- _setOpen(newValue);
1833
- // This sets the cookie to keep the sidebar state.
1834
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${newValue}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
1835
- }, [setOpenProp, open]);
1836
- // Helper to toggle the sidebar.
1837
- const toggleSidebar = react.useCallback(() => {
1838
- return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
1839
- }, [isMobile, setOpen, setOpenMobile]);
1840
- // Add swipe gesture support for opening and closing the sidebar.
1841
- useOnSwipe(screenRef, (direction) => direction === 'right' ? setOpen(true) : direction === 'left' && setOpen(false));
1842
- // Adds a keyboard shortcut to toggle the sidebar.
1843
- react.useEffect(() => {
1844
- const handleKeyDown = (event) => {
1845
- if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
1846
- event.preventDefault();
1847
- toggleSidebar();
1848
- }
1849
- };
1850
- window.addEventListener('keydown', handleKeyDown);
1851
- return () => window.removeEventListener('keydown', handleKeyDown);
1852
- }, [toggleSidebar]);
1853
- // We add a state so that we can do data-state="expanded" or "collapsed".
1854
- // This makes it easier to style the sidebar with Tailwind classes.
1855
- const state = open ? 'expanded' : 'collapsed';
1856
- const contextValue = react.useMemo(() => ({
1857
- state,
1858
- open,
1859
- setOpen,
1860
- isMobile,
1861
- openMobile,
1862
- setOpenMobile,
1863
- toggleSidebar,
1864
- }), [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]);
1865
- return (jsxRuntime.jsx(SidebarContext.Provider, { value: contextValue, children: jsxRuntime.jsx("div", Object.assign({ style: Object.assign({ '--sidebar-width': SIDEBAR_WIDTH, '--sidebar-width-icon': SIDEBAR_WIDTH_ICON }, style), className: cn('group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full', className), ref: ref }, props, { children: children })) }));
1866
- });
1867
- SidebarContextProvider.displayName = 'SidebarContextProvider';
1868
- const $Sidebar = react.forwardRef((_a, ref) => {
1869
- var { side = 'left', variant = 'sidebar', collapsible = 'offcanvas', className, children } = _a, props = __rest(_a, ["side", "variant", "collapsible", "className", "children"]);
1870
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
1871
- if (collapsible === 'none') {
1872
- return (jsxRuntime.jsx("div", Object.assign({ className: cn('bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col', className), ref: ref }, props, { children: children })));
1873
- }
1874
- if (isMobile) {
1875
- return (jsxRuntime.jsx(Sheet, Object.assign({ open: openMobile, onOpenChange: setOpenMobile }, props, { children: jsxRuntime.jsx(Sheet.Content, { "data-sidebar": "sidebar", "data-mobile": "true", className: "bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden", style: {
1876
- '--sidebar-width': SIDEBAR_WIDTH_MOBILE,
1877
- }, side: side, children: jsxRuntime.jsx("div", { className: "flex h-full w-full flex-col", children: children }) }) })));
1878
- }
1879
- return (jsxRuntime.jsxs("div", { ref: ref, className: "text-sidebar-foreground group peer hidden md:block", "data-state": state, "data-collapsible": state === 'collapsed' ? collapsible : '', "data-variant": variant, "data-side": side, children: [jsxRuntime.jsx("div", { className: cn('relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear', 'group-data-[collapsible=offcanvas]:w-0', 'group-data-[side=right]:rotate-180', variant === 'floating' || variant === 'inset'
1880
- ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]'
1881
- : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon]') }), jsxRuntime.jsx("div", Object.assign({ className: cn('fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex', side === 'left'
1882
- ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
1883
- : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
1884
- // Adjust the padding for floating and inset variants.
1885
- variant === 'floating' || variant === 'inset'
1886
- ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]'
1887
- : 'border-sidebar-border group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l', className) }, props, { children: jsxRuntime.jsx("div", { "data-sidebar": "sidebar", className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow", children: children }) }))] }));
1888
- });
1889
- $Sidebar.displayName = 'Sidebar';
1890
- const SidebarTrigger = react.forwardRef((_a, ref) => {
1891
- var { className, onClick } = _a, props = __rest(_a, ["className", "onClick"]);
1892
- const { toggleSidebar } = useSidebar();
1893
- return (jsxRuntime.jsx(Button, Object.assign({ ref: ref, "data-sidebar": "trigger", variant: "text", suffixIcon: lucideReact.PanelLeft, className: className, onClick: (event) => {
1894
- onClick === null || onClick === void 0 ? void 0 : onClick(event);
1895
- toggleSidebar();
1896
- } }, props)));
1897
- });
1898
- SidebarTrigger.displayName = 'SidebarTrigger';
1899
- const SidebarRail = react.forwardRef((_a, ref) => {
1900
- var { className } = _a, props = __rest(_a, ["className"]);
1901
- const { toggleSidebar } = useSidebar();
1902
- return (jsxRuntime.jsx("button", Object.assign({ ref: ref, "data-sidebar": "rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn('hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex', '[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize', '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize', 'group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full', '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2', '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2', className) }, props)));
1903
- });
1904
- SidebarRail.displayName = 'SidebarRail';
1905
- const SidebarInset = react.forwardRef((_a, ref) => {
1906
- var { className } = _a, props = __rest(_a, ["className"]);
1907
- return (jsxRuntime.jsx("main", Object.assign({ ref: ref, className: cn('bg-background relative flex min-h-svh flex-1 flex-col', 'peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow', className) }, props)));
1908
- });
1909
- SidebarInset.displayName = 'SidebarInset';
1910
- const SidebarInput = react.forwardRef((_a, ref) => {
1911
- var { className } = _a, props = __rest(_a, ["className"]);
1912
- return (jsxRuntime.jsx(BasicInput, Object.assign({ ref: ref, "data-sidebar": "input", className: cn('focus-visible:ring-sidebar-ring focus-visible:ring-2', className) }, props)));
1913
- });
1914
- SidebarInput.displayName = 'SidebarInput';
1915
- const SidebarHeader = react.forwardRef((_a, ref) => {
1916
- var { className } = _a, props = __rest(_a, ["className"]);
1917
- return (jsxRuntime.jsx("div", Object.assign({ ref: ref, "data-sidebar": "header", className: cn('flex flex-col gap-2 p-2', className) }, props)));
1918
- });
1919
- SidebarHeader.displayName = 'SidebarHeader';
1920
- const SidebarFooter = react.forwardRef((_a, ref) => {
1921
- var { className } = _a, props = __rest(_a, ["className"]);
1922
- return (jsxRuntime.jsx("div", Object.assign({ ref: ref, "data-sidebar": "footer", className: cn('flex flex-col gap-2 p-2', className) }, props)));
1923
- });
1924
- SidebarFooter.displayName = 'SidebarFooter';
1925
- const SidebarSeparator = react.forwardRef((_a, ref) => {
1926
- var { className } = _a, props = __rest(_a, ["className"]);
1927
- return (jsxRuntime.jsx(Separator, Object.assign({ ref: ref, "data-sidebar": "separator", className: cn('bg-sidebar-border mx-2 w-auto', className) }, props)));
1928
- });
1929
- SidebarSeparator.displayName = 'SidebarSeparator';
1930
- const SidebarContent = react.forwardRef((_a, ref) => {
1931
- var { className } = _a, props = __rest(_a, ["className"]);
1932
- return (jsxRuntime.jsx("div", Object.assign({ ref: ref, "data-sidebar": "content", className: cn('flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden', className) }, props)));
1933
- });
1934
- SidebarContent.displayName = 'SidebarContent';
1935
- const SidebarGroup = react.forwardRef((_a, ref) => {
1936
- var { className } = _a, props = __rest(_a, ["className"]);
1937
- return (jsxRuntime.jsx("div", Object.assign({ ref: ref, "data-sidebar": "group", className: cn('relative flex w-full min-w-0 flex-col p-2', className) }, props)));
1938
- });
1939
- SidebarGroup.displayName = 'SidebarGroup';
1940
- const SidebarGroupLabel = react.forwardRef((_a, ref) => {
1941
- var { className, asChild = false } = _a, props = __rest(_a, ["className", "asChild"]);
1942
- const Comp = asChild ? reactSlot.Slot : 'div';
1943
- return (jsxRuntime.jsx(Comp, Object.assign({ ref: ref, "data-sidebar": "group-label", className: cn('text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-none transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0', 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0', className) }, props)));
1944
- });
1945
- SidebarGroupLabel.displayName = 'SidebarGroupLabel';
1946
- const SidebarGroupAction = react.forwardRef((_a, ref) => {
1947
- var { className, asChild = false } = _a, props = __rest(_a, ["className", "asChild"]);
1948
- const Comp = asChild ? reactSlot.Slot : 'button';
1949
- return (jsxRuntime.jsx(Comp, Object.assign({ ref: ref, "data-sidebar": "group-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
1950
- // Increases the hit area of the button on mobile.
1951
- 'after:absolute after:-inset-2 after:md:hidden', 'group-data-[collapsible=icon]:hidden', className) }, props)));
1952
- });
1953
- SidebarGroupAction.displayName = 'SidebarGroupAction';
1954
- const SidebarGroupContent = react.forwardRef((_a, ref) => {
1955
- var { className } = _a, props = __rest(_a, ["className"]);
1956
- return (jsxRuntime.jsx("div", Object.assign({ ref: ref, "data-sidebar": "group-content", className: cn('w-full text-sm', className) }, props)));
1957
- });
1958
- SidebarGroupContent.displayName = 'SidebarGroupContent';
1959
- const SidebarMenu = react.forwardRef((_a, ref) => {
1960
- var { className } = _a, props = __rest(_a, ["className"]);
1961
- return (jsxRuntime.jsx("ul", Object.assign({ ref: ref, "data-sidebar": "menu", className: cn('flex w-full min-w-0 flex-col gap-1', className) }, props)));
1962
- });
1963
- SidebarMenu.displayName = 'SidebarMenu';
1964
- const SidebarMenuItem = react.forwardRef((_a, ref) => {
1965
- var { className } = _a, props = __rest(_a, ["className"]);
1966
- return (jsxRuntime.jsx("li", Object.assign({ ref: ref, "data-sidebar": "menu-item", className: cn('group/menu-item relative', className) }, props)));
1967
- });
1968
- SidebarMenuItem.displayName = 'SidebarMenuItem';
1969
- const sidebarMenuButtonVariants = classVarianceAuthority.cva('peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', {
1970
- variants: {
1971
- variant: {
1972
- default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
1973
- outline: 'bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]',
1974
- },
1975
- size: {
1976
- default: 'h-8 text-sm',
1977
- sm: 'h-7 text-xs',
1978
- lg: 'h-12 text-sm group-data-[collapsible=icon]:!p-0',
1979
- },
1980
- },
1981
- defaultVariants: {
1982
- variant: 'default',
1983
- size: 'default',
1984
- },
1985
- });
1986
- const SidebarMenuButton = react.forwardRef((_a, ref) => {
1987
- var { asChild = false, isActive = false, variant = 'default', size = 'default', tooltip, className } = _a, props = __rest(_a, ["asChild", "isActive", "variant", "size", "tooltip", "className"]);
1988
- const Comp = asChild ? reactSlot.Slot : 'button';
1989
- const { isMobile, state } = useSidebar();
1990
- const button = (jsxRuntime.jsx(Comp, Object.assign({ ref: ref, "data-sidebar": "menu-button", "data-size": size, "data-active": isActive, className: cn(sidebarMenuButtonVariants({ variant, size }), className) }, props)));
1991
- if (!tooltip || state !== 'collapsed' || isMobile) {
1992
- return button;
1993
- }
1994
- if (typeof tooltip === 'string') {
1995
- tooltip = {
1996
- content: tooltip,
1997
- };
1998
- }
1999
- return (jsxRuntime.jsx(Tooltip, Object.assign({ asChild: true, placement: "right" }, tooltip, { children: button })));
2000
- });
2001
- SidebarMenuButton.displayName = 'SidebarMenuButton';
2002
- const SidebarMenuAction = react.forwardRef((_a, ref) => {
2003
- var { className, asChild = false, showOnHover = false } = _a, props = __rest(_a, ["className", "asChild", "showOnHover"]);
2004
- const Comp = asChild ? reactSlot.Slot : 'button';
2005
- return (jsxRuntime.jsx(Comp, Object.assign({ ref: ref, "data-sidebar": "menu-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
2006
- // Increases the hit area of the button on mobile.
2007
- 'after:absolute after:-inset-2 after:md:hidden', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', showOnHover &&
2008
- 'peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0', className) }, props)));
2009
- });
2010
- SidebarMenuAction.displayName = 'SidebarMenuAction';
2011
- const SidebarMenuBadge = react.forwardRef((_a, ref) => {
2012
- var { className } = _a, props = __rest(_a, ["className"]);
2013
- return (jsxRuntime.jsx("div", Object.assign({ ref: ref, "data-sidebar": "menu-badge", className: cn('text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums', 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', className) }, props)));
2014
- });
2015
- SidebarMenuBadge.displayName = 'SidebarMenuBadge';
2016
- const SidebarMenuSkeleton = react.forwardRef((_a, ref) => {
2017
- var { className, showIcon = false } = _a, props = __rest(_a, ["className", "showIcon"]);
2018
- // Random width between 50 to 90%.
2019
- const width = react.useMemo(() => {
2020
- return `${Math.floor(Math.random() * 40) + 50}%`;
2021
- }, []);
2022
- return (jsxRuntime.jsxs("div", Object.assign({ ref: ref, "data-sidebar": "menu-skeleton", className: cn('flex h-8 items-center gap-2 rounded-md px-2', className) }, props, { children: [showIcon && jsxRuntime.jsx(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" }), jsxRuntime.jsx(Skeleton, { className: "h-4 max-w-[--skeleton-width] flex-1", "data-sidebar": "menu-skeleton-text", style: {
2023
- '--skeleton-width': width,
2024
- } })] })));
2025
- });
2026
- SidebarMenuSkeleton.displayName = 'SidebarMenuSkeleton';
2027
- const SidebarMenuSub = react.forwardRef((_a, ref) => {
2028
- var { className } = _a, props = __rest(_a, ["className"]);
2029
- return (jsxRuntime.jsx("ul", Object.assign({ ref: ref, "data-sidebar": "menu-sub", className: cn('border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5', 'group-data-[collapsible=icon]:hidden', className) }, props)));
2030
- });
2031
- SidebarMenuSub.displayName = 'SidebarMenuSub';
2032
- const SidebarMenuSubItem = react.forwardRef((_a, ref) => {
2033
- var props = __rest(_a, []);
2034
- return (jsxRuntime.jsx("li", Object.assign({ ref: ref }, props)));
2035
- });
2036
- SidebarMenuSubItem.displayName = 'SidebarMenuSubItem';
2037
- const SidebarMenuSubButton = react.forwardRef((_a, ref) => {
2038
- var { asChild = false, size = 'md', isActive, className } = _a, props = __rest(_a, ["asChild", "size", "isActive", "className"]);
2039
- const Comp = asChild ? reactSlot.Slot : 'a';
2040
- return (jsxRuntime.jsx(Comp, Object.assign({ ref: ref, "data-sidebar": "menu-sub-button", "data-size": size, "data-active": isActive, className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', 'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground', size === 'sm' && 'text-xs', size === 'md' && 'text-sm', 'group-data-[collapsible=icon]:hidden', className) }, props)));
2041
- });
2042
- SidebarMenuSubButton.displayName = 'SidebarMenuSubButton';
2043
- const Sidebar = Object.assign($Sidebar, {
2044
- Content: SidebarContent,
2045
- Footer: SidebarFooter,
2046
- Group: SidebarGroup,
2047
- GroupAction: SidebarGroupAction,
2048
- GroupContent: SidebarGroupContent,
2049
- GroupLabel: SidebarGroupLabel,
2050
- Header: SidebarHeader,
2051
- Input: SidebarInput,
2052
- Inset: SidebarInset,
2053
- Menu: SidebarMenu,
2054
- MenuAction: SidebarMenuAction,
2055
- MenuBadge: SidebarMenuBadge,
2056
- MenuButton: SidebarMenuButton,
2057
- MenuItem: SidebarMenuItem,
2058
- MenuSkeleton: SidebarMenuSkeleton,
2059
- MenuSub: SidebarMenuSub,
2060
- MenuSubButton: SidebarMenuSubButton,
2061
- MenuSubItem: SidebarMenuSubItem,
2062
- Rail: SidebarRail,
2063
- Separator: SidebarSeparator,
2064
- Trigger: SidebarTrigger,
2065
- });
2066
-
2067
- const Navbar = ({ className, sidebarTriggerClassName, leftSlot, rightSlot, }) => (jsxRuntime.jsx(Block, { className: cn('border-b p-3 dark:border-slate-700', className), fullWidth: true, children: jsxRuntime.jsxs(Flex, { align: "center", justify: "between", children: [jsxRuntime.jsxs(Flex, { align: "center", children: [jsxRuntime.jsx(Sidebar.Trigger, { className: sidebarTriggerClassName }), leftSlot] }), rightSlot] }) }));
2068
-
2069
- const Layout = (_a) => {
2070
- var { children, className } = _a, _b = _a.sidebarProps, { basePath, header, items, extraContent, footer } = _b, sidebarProps = __rest(_b, ["basePath", "header", "items", "extraContent", "footer"]), { navbarProps } = _a;
2071
- return (jsxRuntime.jsxs(Flex, { className: "h-screen w-screen gap-0 text-black dark:bg-slate-900 dark:text-white", children: [jsxRuntime.jsxs(Sidebar, Object.assign({ collapsible: "icon" }, sidebarProps, { children: [header && (jsxRuntime.jsx(Sidebar.Header, { children: jsxRuntime.jsx(Sidebar.Menu, { children: jsxRuntime.jsx(Sidebar.MenuItem, { children: header }) }) })), jsxRuntime.jsxs(Sidebar.Content, { className: "gap-0", children: [items
2072
- .filter((item) => !item.hidden)
2073
- .map((item, index) => item.type === 'item' ? (jsxRuntime.jsx(Sidebar.Group, { children: jsxRuntime.jsx(Sidebar.Menu, { children: jsxRuntime.jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, item)) }) }, index)) : (jsxRuntime.jsxs(Sidebar.Group, { children: [item.title && jsxRuntime.jsx(Sidebar.GroupLabel, { children: item.title }), jsxRuntime.jsx(Sidebar.GroupContent, { children: jsxRuntime.jsx(Sidebar.Menu, { children: item.items
2074
- .filter((subItem) => !subItem.hidden)
2075
- .map((subItem, index) => (jsxRuntime.jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, subItem), index))) }) })] }, index))), extraContent] }), footer && (jsxRuntime.jsx(Sidebar.Footer, { children: jsxRuntime.jsx(Sidebar.Menu, { children: jsxRuntime.jsx(Sidebar.MenuItem, { children: footer }) }) })), jsxRuntime.jsx(Sidebar.Rail, {})] })), jsxRuntime.jsxs(Flex, { className: "gap-0 overflow-hidden", direction: "column", fullHeight: true, fullWidth: true, children: [navbarProps && jsxRuntime.jsx(Navbar, Object.assign({}, navbarProps)), jsxRuntime.jsx(Flex, { className: cn('overflow-hidden p-3', className), direction: "column", fullWidth: true, fullHeight: true, children: children })] })] }));
2076
- };
2077
- const RenderSideBarItem = ({ basePath = '/', pathname, title, Icon, items, }) => {
2078
- const location = reactRouterDom.useLocation();
2079
- const { open } = useSidebar();
2080
- const currentPath = react.useMemo(() => location.pathname.replace(basePath, '').replace(/^\/*/, ''), [basePath, location.pathname]);
2081
- if (!(items === null || items === void 0 ? void 0 : items.filter((subItem) => !subItem.hidden).length)) {
2082
- return (jsxRuntime.jsx(Sidebar.MenuItem, { children: jsxRuntime.jsx(Sidebar.MenuButton, { asChild: true, isActive: isLinkStartsWithPathname(currentPath, pathname), children: jsxRuntime.jsxs(reactRouterDom.Link, { to: pathname, className: "font-medium", children: [Icon && jsxRuntime.jsx(Icon, {}), title] }) }) }));
2083
- }
2084
- const isOpen = open &&
2085
- (isLinkStartsWithPathname(currentPath, pathname) ||
2086
- items.some((subItem) => isLinkStartsWithPathname(currentPath, `${pathname}/${subItem.pathname}`)));
2087
- return (jsxRuntime.jsx(Collapsible, { asChild: true, open: isOpen, className: "group/collapsible", children: jsxRuntime.jsxs(Sidebar.MenuItem, { children: [jsxRuntime.jsx(Collapsible.Trigger, { asChild: true, children: jsxRuntime.jsx(Sidebar.MenuButton, { asChild: true, tooltip: title, isActive: open
2088
- ? currentPath === pathname &&
2089
- !items.some((subItem) => isLinkStartsWithPathname(currentPath, `${pathname}/${subItem.pathname}`))
2090
- : isLinkStartsWithPathname(currentPath, pathname), children: jsxRuntime.jsxs(reactRouterDom.Link, { to: pathname, className: "font-medium", children: [Icon && jsxRuntime.jsx(Icon, {}), title, jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })] }) }) }), items && (jsxRuntime.jsx(Collapsible.Content, { children: jsxRuntime.jsx(Sidebar.MenuSub, { children: items
2091
- .filter((subItem) => !subItem.hidden)
2092
- .map((subItem, index) => (jsxRuntime.jsx(Sidebar.MenuSubItem, { children: jsxRuntime.jsx(Sidebar.MenuSubButton, { asChild: true, isActive: isLinkStartsWithPathname(currentPath, `${pathname}/${subItem.pathname}`), children: jsxRuntime.jsx(reactRouterDom.Link, { to: `${pathname}/${subItem.pathname}`, children: subItem.title }) }) }, index))) }) }))] }) }));
2093
- };
2094
- function isLinkStartsWithPathname(link, pathname) {
2095
- return pathname === '' ? link === pathname : link.startsWith(pathname);
2096
- }
2097
-
2098
- const $Popover = PopoverPrimitive__namespace.Root;
2099
- const PopoverTrigger = PopoverPrimitive__namespace.Trigger;
2100
- const PopoverContent = react.forwardRef((_a, ref) => {
2101
- var { className, align = 'center', sideOffset = 4, container } = _a, props = __rest(_a, ["className", "align", "sideOffset", "container"]);
2102
- return (jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { container: container, children: jsxRuntime.jsx(PopoverPrimitive__namespace.Content, Object.assign({ ref: ref, align: align, sideOffset: sideOffset, className: cn('z-50 rounded-md border bg-white p-1 shadow-md outline-none dark:border-slate-700 dark:bg-slate-900 dark:text-white', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', className) }, props)) }));
2103
- });
2104
- PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
2105
- const Popover = Object.assign($Popover, {
2106
- Trigger: PopoverTrigger,
2107
- Content: PopoverContent,
2108
- });
2109
-
2110
- const Switch = react.forwardRef((_a, ref) => {
2111
- var { className } = _a, _b = _a.thumbProps, _c = _b === void 0 ? {} : _b, { className: thumbClassName } = _c, thumbProps = __rest(_c, ["className"]), props = __rest(_a, ["className", "thumbProps"]);
2112
- return (jsxRuntime.jsx(SwitchPrimitives__namespace.Root, Object.assign({ className: cn('peer inline-flex h-[calc(1.5rem+6px)] w-[calc(3rem+6px)] shrink-0 cursor-pointer items-center rounded-full border-[3px] border-transparent', 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-600 focus-visible:ring-offset-2', 'focus-visible:ring-offset-white disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-slate-300', 'dark:focus-visible:ring-slate-200 dark:focus-visible:ring-offset-slate-800 dark:data-[state=checked]:bg-blue-700 dark:data-[state=unchecked]:bg-slate-700', className) }, props, { ref: ref, children: jsxRuntime.jsx(SwitchPrimitives__namespace.Thumb, Object.assign({ className: cn('pointer-events-none block h-6 w-6 rounded-full bg-white shadow-lg ring-0 transition-transform', 'data-[state=checked]:translate-x-6 data-[state=unchecked]:translate-x-0 dark:bg-slate-900', thumbClassName) }, thumbProps)) })));
2113
- });
2114
- Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
2115
-
2116
- const $Tabs = react.forwardRef((_a, ref) => {
2117
- var { className } = _a, props = __rest(_a, ["className"]);
2118
- return (jsxRuntime.jsx(TabsPrimitive__namespace.Root, Object.assign({ ref: ref, className: cn('flex flex-col gap-2', className) }, props)));
2119
- });
2120
- $Tabs.displayName = TabsPrimitive__namespace.Root.displayName;
2121
- const TabsList = react.forwardRef((_a, ref) => {
2122
- var { className } = _a, props = __rest(_a, ["className"]);
2123
- return (jsxRuntime.jsx(TabsPrimitive__namespace.List, Object.assign({ ref: ref, className: cn('inline-flex w-full items-center justify-center gap-1 rounded-lg border bg-slate-100 p-1 text-slate-400 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-500', className) }, props)));
2124
- });
2125
- TabsList.displayName = TabsPrimitive__namespace.List.displayName;
2126
- const TabsTrigger = react.forwardRef((_a, ref) => {
2127
- var { className } = _a, props = __rest(_a, ["className"]);
2128
- return (jsxRuntime.jsx(TabsPrimitive__namespace.Trigger, Object.assign({ ref: ref, className: cn('inline-flex w-full items-center justify-center whitespace-nowrap rounded-md px-2 py-1.5 font-medium transition-all hover:bg-slate-200 disabled:pointer-events-none disabled:opacity-50 dark:hover:bg-slate-800', 'data-[state=active]:bg-white data-[state=active]:text-black data-[state=active]:shadow dark:data-[state=active]:bg-slate-700 dark:data-[state=active]:text-white', className) }, props)));
2129
- });
2130
- TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
2131
- const TabsContent = TabsPrimitive__namespace.Content;
2132
- const Tabs = Object.assign($Tabs, {
2133
- List: TabsList,
2134
- Trigger: TabsTrigger,
2135
- Content: TabsContent,
2136
- });
2137
-
2138
- const LayoutContext = react.createContext(undefined);
2139
- const THEME_MEDIA_QUERY = '(prefers-color-scheme: dark)';
2140
- const THEME_COOKIE_NAME = 'theme:state';
2141
- const THEME_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
2142
- const SHOW_IDS_COOKIE_NAME = 'show-ids:state';
2143
- const SHOW_IDS_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
2144
- const LayoutContextProvider = ({ children }) => {
2145
- const [theme, _setTheme] = react.useState(getValueFromCookie(THEME_COOKIE_NAME, 'system'));
2146
- const [showIds, _setShowIds] = react.useState(getValueFromCookie(SHOW_IDS_COOKIE_NAME, false));
2147
- const [resolvedTheme, setResolvedTheme] = react.useState(() => theme === 'system' ? getSystemTheme() : theme);
2148
- react.useEffect(() => {
2149
- if (resolvedTheme === 'dark') {
2150
- document.documentElement.classList.add('dark');
2151
- }
2152
- else {
2153
- document.documentElement.classList.remove('dark');
2154
- }
2155
- }, [resolvedTheme]);
2156
- react.useEffect(() => {
2157
- if (theme !== 'system') {
2158
- setResolvedTheme(theme);
2159
- return;
2160
- }
2161
- setResolvedTheme(getSystemTheme());
2162
- const handleMediaQuery = (e) => setResolvedTheme(getSystemTheme(e));
2163
- const mediaQuery = window.matchMedia(THEME_MEDIA_QUERY);
2164
- mediaQuery.addEventListener('change', handleMediaQuery);
2165
- return () => mediaQuery.removeEventListener('change', handleMediaQuery);
2166
- }, [theme]);
2167
- const setTheme = (theme) => {
2168
- _setTheme(theme);
2169
- // This sets the cookie to keep the theme state.
2170
- document.cookie = `${THEME_COOKIE_NAME}=${theme}; path=/; max-age=${THEME_COOKIE_MAX_AGE}`;
2171
- };
2172
- const toggleShowIds = () => _setShowIds((showIds) => {
2173
- const newValue = !showIds;
2174
- // This sets the cookie to keep the showIds state.
2175
- document.cookie = `${SHOW_IDS_COOKIE_NAME}=${newValue}; path=/; max-age=${SHOW_IDS_COOKIE_MAX_AGE}`;
2176
- return newValue;
2177
- });
2178
- return (jsxRuntime.jsx(LayoutContext.Provider, { value: { theme, resolvedTheme, setTheme, showIds, toggleShowIds }, children: children }));
2179
- };
2180
- function useLayoutContext() {
2181
- const context = react.useContext(LayoutContext);
2182
- if (!context) {
2183
- throw new Error('Please use LayoutContextProvider!');
2184
- }
2185
- return context;
2186
- }
2187
- function getSystemTheme(e) {
2188
- if (!e)
2189
- e = window.matchMedia(THEME_MEDIA_QUERY);
2190
- return e.matches ? 'dark' : 'light';
2191
- }
2192
-
2193
- const ThemeSelector = ({ className }) => {
2194
- const { resolvedTheme, setTheme } = useLayoutContext();
2195
- return (jsxRuntime.jsxs(DropdownMenu, { children: [jsxRuntime.jsx(DropdownMenu.Trigger, { asChild: true, children: jsxRuntime.jsx(Button, { prefixIcon: resolvedTheme === 'dark' ? lucideReact.MoonIcon : lucideReact.SunIcon, className: className, variant: "text" }) }), jsxRuntime.jsxs(DropdownMenu.Content, { children: [jsxRuntime.jsxs(DropdownMenu.Item, { onClick: () => setTheme('light'), children: [jsxRuntime.jsx(DropdownMenu.Icon, { icon: lucideReact.SunIcon }), "Light"] }), jsxRuntime.jsxs(DropdownMenu.Item, { onClick: () => setTheme('dark'), children: [jsxRuntime.jsx(DropdownMenu.Icon, { icon: lucideReact.MoonIcon }), "Dark"] }), jsxRuntime.jsxs(DropdownMenu.Item, { onClick: () => setTheme('system'), children: [jsxRuntime.jsx(DropdownMenu.Icon, { icon: lucideReact.MonitorIcon }), "System"] })] })] }));
2196
- };
2197
-
2198
- exports.Badge = Badge;
2199
- exports.BasicInput = BasicInput;
2200
- exports.BasicInputExtension = BasicInputExtension;
2201
- exports.Block = Block;
2202
- exports.Button = Button;
2203
- exports.Card = Card;
2204
- exports.CheckboxInput = CheckboxInput;
2205
- exports.Collapsible = Collapsible;
2206
- exports.ConfirmDialog = ConfirmDialog;
2207
- exports.DataTable = DataTable;
2208
- exports.DateTimeInput = DateTimeInput;
2209
- exports.Dialog = Dialog;
2210
- exports.DropdownMenu = DropdownMenu;
2211
- exports.EmailInput = EmailInput;
2212
- exports.FileInput = FileInput;
2213
- exports.Flex = Flex;
2214
- exports.FormDialog = FormDialog;
2215
- exports.FormGroup = FormGroup;
2216
- exports.FormInputs = FormInputs;
2217
- exports.Hint = Hint;
2218
- exports.Label = Label;
2219
- exports.Layout = Layout;
2220
- exports.LayoutContext = LayoutContext;
2221
- exports.LayoutContextProvider = LayoutContextProvider;
2222
- exports.List = List;
2223
- exports.ListSorter = ListSorter;
2224
- exports.ListSorterDialog = ListSorterDialog;
2225
- exports.Navbar = Navbar;
2226
- exports.NumberInput = NumberInput;
2227
- exports.Pagination = Pagination;
2228
- exports.PasswordInput = PasswordInput;
2229
- exports.PdfViewerDialog = PdfViewerDialog;
2230
- exports.Popover = Popover;
2231
- exports.SHOW_IDS_COOKIE_MAX_AGE = SHOW_IDS_COOKIE_MAX_AGE;
2232
- exports.SHOW_IDS_COOKIE_NAME = SHOW_IDS_COOKIE_NAME;
2233
- exports.SIDEBAR_COOKIE_MAX_AGE = SIDEBAR_COOKIE_MAX_AGE;
2234
- exports.SIDEBAR_COOKIE_NAME = SIDEBAR_COOKIE_NAME;
2235
- exports.SIDEBAR_KEYBOARD_SHORTCUT = SIDEBAR_KEYBOARD_SHORTCUT;
2236
- exports.SIDEBAR_WIDTH = SIDEBAR_WIDTH;
2237
- exports.SIDEBAR_WIDTH_ICON = SIDEBAR_WIDTH_ICON;
2238
- exports.SIDEBAR_WIDTH_MOBILE = SIDEBAR_WIDTH_MOBILE;
2239
- exports.SelectInput = SelectInput;
2240
- exports.Separator = Separator;
2241
- exports.Sheet = Sheet;
2242
- exports.Sidebar = Sidebar;
2243
- exports.SidebarContext = SidebarContext;
2244
- exports.SidebarContextProvider = SidebarContextProvider;
2245
- exports.Skeleton = Skeleton;
2246
- exports.Spinner = Spinner;
2247
- exports.Switch = Switch;
2248
- exports.THEME_COOKIE_MAX_AGE = THEME_COOKIE_MAX_AGE;
2249
- exports.THEME_COOKIE_NAME = THEME_COOKIE_NAME;
2250
- exports.THEME_MEDIA_QUERY = THEME_MEDIA_QUERY;
2251
- exports.Table = Table;
2252
- exports.Tabs = Tabs;
2253
- exports.TextInput = TextInput;
2254
- exports.TextareaInput = TextareaInput;
2255
- exports.ThemeSelector = ThemeSelector;
2256
- exports.Tooltip = Tooltip;
2257
- exports.cn = cn;
2258
- exports.compareDates = compareDates;
2259
- exports.generalComparator = generalComparator;
2260
- exports.getDisplayDate = getDisplayDate;
2261
- exports.getValueFromCookie = getValueFromCookie;
2262
- exports.isEmpty = isEmpty;
2263
- exports.mergeRefs = mergeRefs;
2264
- exports.resolveTargetObject = resolveTargetObject;
2265
- exports.useDays = useDays;
2266
- exports.useIsMobile = useIsMobile;
2267
- exports.useLayoutContext = useLayoutContext;
2268
- exports.useLongPress = useLongPress;
2269
- exports.useMonths = useMonths;
2270
- exports.useOnSwipe = useOnSwipe;
2271
- exports.useOutsideClick = useOutsideClick;
2272
- exports.usePagination = usePagination;
2273
- exports.useSidebar = useSidebar;