next-data-kit 9.2.0 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/client.cjs +2951 -0
  2. package/dist/client.cjs.map +1 -0
  3. package/dist/client.d.cts +60 -0
  4. package/dist/client.d.ts +1 -0
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/client.js +2907 -7
  7. package/dist/client.js.map +1 -1
  8. package/dist/index-CzDzNX62.d.cts +558 -0
  9. package/dist/index-CzDzNX62.d.ts +558 -0
  10. package/dist/index.cjs +99 -105
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +5 -557
  13. package/dist/index.d.ts +5 -557
  14. package/dist/index.js +99 -105
  15. package/dist/index.js.map +1 -1
  16. package/dist/styles.css +1 -1
  17. package/dist/types/index.js +2 -6
  18. package/dist/types/index.js.map +1 -1
  19. package/package.json +1 -1
  20. package/dist/client/components/data-kit-infinity.js +0 -86
  21. package/dist/client/components/data-kit-infinity.js.map +0 -1
  22. package/dist/client/components/data-kit-table.js +0 -190
  23. package/dist/client/components/data-kit-table.js.map +0 -1
  24. package/dist/client/components/data-kit.js +0 -79
  25. package/dist/client/components/data-kit.js.map +0 -1
  26. package/dist/client/components/index.js +0 -4
  27. package/dist/client/components/index.js.map +0 -1
  28. package/dist/client/components/ui/button.js +0 -36
  29. package/dist/client/components/ui/button.js.map +0 -1
  30. package/dist/client/components/ui/checkbox.js +0 -10
  31. package/dist/client/components/ui/checkbox.js.map +0 -1
  32. package/dist/client/components/ui/dropdown-menu.js +0 -52
  33. package/dist/client/components/ui/dropdown-menu.js.map +0 -1
  34. package/dist/client/components/ui/index.js +0 -8
  35. package/dist/client/components/ui/index.js.map +0 -1
  36. package/dist/client/components/ui/pagination.js +0 -31
  37. package/dist/client/components/ui/pagination.js.map +0 -1
  38. package/dist/client/components/ui/popover.js +0 -18
  39. package/dist/client/components/ui/popover.js.map +0 -1
  40. package/dist/client/components/ui/select.js +0 -39
  41. package/dist/client/components/ui/select.js.map +0 -1
  42. package/dist/client/components/ui/table.js +0 -29
  43. package/dist/client/components/ui/table.js.map +0 -1
  44. package/dist/client/context/index.js +0 -28
  45. package/dist/client/context/index.js.map +0 -1
  46. package/dist/client/hooks/index.js +0 -7
  47. package/dist/client/hooks/index.js.map +0 -1
  48. package/dist/client/hooks/useDataKit.js +0 -308
  49. package/dist/client/hooks/useDataKit.js.map +0 -1
  50. package/dist/client/hooks/usePagination.js +0 -51
  51. package/dist/client/hooks/usePagination.js.map +0 -1
  52. package/dist/client/hooks/useSelection.js +0 -93
  53. package/dist/client/hooks/useSelection.js.map +0 -1
  54. package/dist/client/index.js +0 -15
  55. package/dist/client/index.js.map +0 -1
  56. package/dist/client/utils/cn.js +0 -22
  57. package/dist/client/utils/cn.js.map +0 -1
  58. package/dist/client/utils/index.js +0 -133
  59. package/dist/client/utils/index.js.map +0 -1
  60. package/dist/server/utils.js +0 -117
  61. package/dist/server/utils.js.map +0 -1
  62. package/dist/types/client/component.js +0 -7
  63. package/dist/types/client/component.js.map +0 -1
  64. package/dist/types/client/hook.js +0 -7
  65. package/dist/types/client/hook.js.map +0 -1
  66. package/dist/types/client/selectable.js +0 -7
  67. package/dist/types/client/selectable.js.map +0 -1
  68. package/dist/types/next-data-kit.js +0 -7
  69. package/dist/types/next-data-kit.js.map +0 -1
  70. package/dist/types/server/action.js +0 -7
  71. package/dist/types/server/action.js.map +0 -1
  72. package/dist/types/server/database/mongo.js +0 -7
  73. package/dist/types/server/database/mongo.js.map +0 -1
package/dist/client.js CHANGED
@@ -1,8 +1,2908 @@
1
- /**
2
- * next-data-kit/client
3
- *
4
- * Client-side entry point for next-data-kit.
5
- */
6
- 'use client';
7
- export * from './client/index';
1
+ import * as React2 from 'react';
2
+ import React2__default, { createContext, useRef, useState, useCallback, useEffect, useContext, useMemo } from 'react';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { Filter, Loader2, MoreHorizontal, ArrowUp, ArrowDown, ChevronLeft, ChevronRight, ChevronDownIcon, CheckIcon, ChevronUpIcon } from 'lucide-react';
5
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
6
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
7
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
8
+ import { Slot } from '@radix-ui/react-slot';
9
+ import { cva } from 'class-variance-authority';
10
+ import * as SelectPrimitive from '@radix-ui/react-select';
11
+ import { useInView } from 'react-intersection-observer';
12
+
13
+ // #style-inject:#style-inject
14
+ function styleInject(css, { insertAt } = {}) {
15
+ if (typeof document === "undefined") return;
16
+ const head = document.head || document.getElementsByTagName("head")[0];
17
+ const style = document.createElement("style");
18
+ style.type = "text/css";
19
+ if (insertAt === "top") {
20
+ if (head.firstChild) {
21
+ head.insertBefore(style, head.firstChild);
22
+ } else {
23
+ head.appendChild(style);
24
+ }
25
+ } else {
26
+ head.appendChild(style);
27
+ }
28
+ if (style.styleSheet) {
29
+ style.styleSheet.cssText = css;
30
+ } else {
31
+ style.appendChild(document.createTextNode(css));
32
+ }
33
+ }
34
+
35
+ // dist/styles.css
36
+ styleInject(`/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */
37
+ @layer properties {
38
+ @supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))) {
39
+ *,
40
+ :before,
41
+ :after,
42
+ ::backdrop {
43
+ --tw-space-y-reverse:0;
44
+ --tw-border-style:solid;
45
+ --tw-font-weight:initial;
46
+ --tw-tracking:initial;
47
+ --tw-shadow:0 0 #0000;
48
+ --tw-shadow-color:initial;
49
+ --tw-shadow-alpha:100%;
50
+ --tw-inset-shadow:0 0 #0000;
51
+ --tw-inset-shadow-color:initial;
52
+ --tw-inset-shadow-alpha:100%;
53
+ --tw-ring-color:initial;
54
+ --tw-ring-shadow:0 0 #0000;
55
+ --tw-inset-ring-color:initial;
56
+ --tw-inset-ring-shadow:0 0 #0000;
57
+ --tw-ring-inset:initial;
58
+ --tw-ring-offset-width:0px;
59
+ --tw-ring-offset-color:#fff;
60
+ --tw-ring-offset-shadow:0 0 #0000;
61
+ --tw-translate-x:0;
62
+ --tw-translate-y:0;
63
+ --tw-translate-z:0;
64
+ }
65
+ }
66
+ }
67
+ @layer theme {
68
+ :root,
69
+ :host {
70
+ --ndk-font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
71
+ --ndk-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
72
+ --ndk-color-red-400:oklch(70.4% .191 22.216);
73
+ --ndk-color-red-500:oklch(63.7% .237 25.331);
74
+ --ndk-color-red-600:oklch(57.7% .245 27.325);
75
+ --ndk-color-red-700:oklch(50.5% .213 27.518);
76
+ --ndk-color-gray-50:oklch(98.5% .002 247.839);
77
+ --ndk-color-gray-100:oklch(96.7% .003 264.542);
78
+ --ndk-color-gray-200:oklch(92.8% .006 264.531);
79
+ --ndk-color-gray-400:oklch(70.7% .022 261.325);
80
+ --ndk-color-gray-500:oklch(55.1% .027 264.364);
81
+ --ndk-color-gray-800:oklch(27.8% .033 256.848);
82
+ --ndk-color-gray-900:oklch(21% .034 264.665);
83
+ --ndk-color-gray-950:oklch(13% .028 261.692);
84
+ --ndk-color-black:#000;
85
+ --ndk-color-white:#fff;
86
+ --ndk-spacing:.25rem;
87
+ --ndk-text-xs:.75rem;
88
+ --ndk-text-xs--line-height:calc(1/.75);
89
+ --ndk-text-sm:.875rem;
90
+ --ndk-text-sm--line-height:calc(1.25/.875);
91
+ --ndk-font-weight-medium:500;
92
+ --ndk-tracking-widest:.1em;
93
+ --ndk-radius-sm:.25rem;
94
+ --ndk-radius-md:.375rem;
95
+ --ndk-radius-lg:.5rem;
96
+ --ndk-animate-spin:spin 1s linear infinite;
97
+ --ndk-default-transition-duration:.15s;
98
+ --ndk-default-transition-timing-function:cubic-bezier(.4,0,.2,1);
99
+ --ndk-default-font-family:var(--ndk-font-sans);
100
+ --ndk-default-mono-font-family:var(--ndk-font-mono);
101
+ --ndk-animate-in:animate-in;
102
+ --ndk-animate-out:animate-out;
103
+ }
104
+ }
105
+ @layer base {
106
+ *,
107
+ :after,
108
+ :before,
109
+ ::backdrop {
110
+ box-sizing: border-box;
111
+ border: 0 solid;
112
+ margin: 0;
113
+ padding: 0;
114
+ }
115
+ ::file-selector-button {
116
+ box-sizing: border-box;
117
+ border: 0 solid;
118
+ margin: 0;
119
+ padding: 0;
120
+ }
121
+ html,
122
+ :host {
123
+ -webkit-text-size-adjust: 100%;
124
+ tab-size: 4;
125
+ line-height: 1.5;
126
+ font-family: var(--ndk-default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");
127
+ font-feature-settings: var(--ndk-default-font-feature-settings,normal);
128
+ font-variation-settings: var(--ndk-default-font-variation-settings,normal);
129
+ -webkit-tap-highlight-color: transparent;
130
+ }
131
+ hr {
132
+ height: 0;
133
+ color: inherit;
134
+ border-top-width: 1px;
135
+ }
136
+ abbr:where([title]) {
137
+ -webkit-text-decoration: underline dotted;
138
+ text-decoration: underline dotted;
139
+ }
140
+ h1,
141
+ h2,
142
+ h3,
143
+ h4,
144
+ h5,
145
+ h6 {
146
+ font-size: inherit;
147
+ font-weight: inherit;
148
+ }
149
+ a {
150
+ color: inherit;
151
+ -webkit-text-decoration: inherit;
152
+ -webkit-text-decoration: inherit;
153
+ -webkit-text-decoration: inherit;
154
+ text-decoration: inherit;
155
+ }
156
+ b,
157
+ strong {
158
+ font-weight: bolder;
159
+ }
160
+ code,
161
+ kbd,
162
+ samp,
163
+ pre {
164
+ font-family: var(--ndk-default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);
165
+ font-feature-settings: var(--ndk-default-mono-font-feature-settings,normal);
166
+ font-variation-settings: var(--ndk-default-mono-font-variation-settings,normal);
167
+ font-size: 1em;
168
+ }
169
+ small {
170
+ font-size: 80%;
171
+ }
172
+ sub,
173
+ sup {
174
+ vertical-align: baseline;
175
+ font-size: 75%;
176
+ line-height: 0;
177
+ position: relative;
178
+ }
179
+ sub {
180
+ bottom: -.25em;
181
+ }
182
+ sup {
183
+ top: -.5em;
184
+ }
185
+ table {
186
+ text-indent: 0;
187
+ border-color: inherit;
188
+ border-collapse: collapse;
189
+ }
190
+ :-moz-focusring {
191
+ outline: auto;
192
+ }
193
+ progress {
194
+ vertical-align: baseline;
195
+ }
196
+ summary {
197
+ display: list-item;
198
+ }
199
+ ol,
200
+ ul,
201
+ menu {
202
+ list-style: none;
203
+ }
204
+ img,
205
+ svg,
206
+ video,
207
+ canvas,
208
+ audio,
209
+ iframe,
210
+ embed,
211
+ object {
212
+ vertical-align: middle;
213
+ display: block;
214
+ }
215
+ img,
216
+ video {
217
+ max-width: 100%;
218
+ height: auto;
219
+ }
220
+ button,
221
+ input,
222
+ select,
223
+ optgroup,
224
+ textarea {
225
+ font: inherit;
226
+ font-feature-settings: inherit;
227
+ font-variation-settings: inherit;
228
+ letter-spacing: inherit;
229
+ color: inherit;
230
+ opacity: 1;
231
+ background-color: #0000;
232
+ border-radius: 0;
233
+ }
234
+ ::file-selector-button {
235
+ font: inherit;
236
+ font-feature-settings: inherit;
237
+ font-variation-settings: inherit;
238
+ letter-spacing: inherit;
239
+ color: inherit;
240
+ opacity: 1;
241
+ background-color: #0000;
242
+ border-radius: 0;
243
+ }
244
+ :where(select:is([multiple], [size])) optgroup {
245
+ font-weight: bolder;
246
+ }
247
+ :where(select:is([multiple], [size])) optgroup option {
248
+ padding-inline-start: 20px;
249
+ }
250
+ ::file-selector-button {
251
+ margin-inline-end: 4px;
252
+ }
253
+ ::placeholder {
254
+ opacity: 1;
255
+ }
256
+ @supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px) {
257
+ ::placeholder {
258
+ color: currentColor;
259
+ }
260
+ @supports (color:color-mix(in lab, red, red)) {
261
+ ::placeholder {
262
+ color: color-mix(in oklab, currentcolor 50%, transparent);
263
+ }
264
+ }
265
+ }
266
+ textarea {
267
+ resize: vertical;
268
+ }
269
+ ::-webkit-search-decoration {
270
+ -webkit-appearance: none;
271
+ }
272
+ ::-webkit-date-and-time-value {
273
+ min-height: 1lh;
274
+ text-align: inherit;
275
+ }
276
+ ::-webkit-datetime-edit {
277
+ display: inline-flex;
278
+ }
279
+ ::-webkit-datetime-edit-fields-wrapper {
280
+ padding: 0;
281
+ }
282
+ ::-webkit-datetime-edit {
283
+ padding-block: 0;
284
+ }
285
+ ::-webkit-datetime-edit-year-field {
286
+ padding-block: 0;
287
+ }
288
+ ::-webkit-datetime-edit-month-field {
289
+ padding-block: 0;
290
+ }
291
+ ::-webkit-datetime-edit-day-field {
292
+ padding-block: 0;
293
+ }
294
+ ::-webkit-datetime-edit-hour-field {
295
+ padding-block: 0;
296
+ }
297
+ ::-webkit-datetime-edit-minute-field {
298
+ padding-block: 0;
299
+ }
300
+ ::-webkit-datetime-edit-second-field {
301
+ padding-block: 0;
302
+ }
303
+ ::-webkit-datetime-edit-millisecond-field {
304
+ padding-block: 0;
305
+ }
306
+ ::-webkit-datetime-edit-meridiem-field {
307
+ padding-block: 0;
308
+ }
309
+ ::-webkit-calendar-picker-indicator {
310
+ line-height: 1;
311
+ }
312
+ :-moz-ui-invalid {
313
+ box-shadow: none;
314
+ }
315
+ button,
316
+ input:where([type=button], [type=reset], [type=submit]) {
317
+ appearance: button;
318
+ }
319
+ ::file-selector-button {
320
+ appearance: button;
321
+ }
322
+ ::-webkit-inner-spin-button {
323
+ height: auto;
324
+ }
325
+ ::-webkit-outer-spin-button {
326
+ height: auto;
327
+ }
328
+ [hidden]:where(:not([hidden=until-found])) {
329
+ display: none !important;
330
+ }
331
+ }
332
+ @layer components;
333
+ @layer utilities {
334
+ .ndk\\:pointer-events-none {
335
+ pointer-events: none;
336
+ }
337
+ .ndk\\:sr-only {
338
+ clip-path: inset(50%);
339
+ white-space: nowrap;
340
+ border-width: 0;
341
+ width: 1px;
342
+ height: 1px;
343
+ margin: -1px;
344
+ padding: 0;
345
+ position: absolute;
346
+ overflow: hidden;
347
+ }
348
+ .ndk\\:absolute {
349
+ position: absolute;
350
+ }
351
+ .ndk\\:relative {
352
+ position: relative;
353
+ }
354
+ .ndk\\:right-2 {
355
+ right: calc(var(--ndk-spacing)*2);
356
+ }
357
+ .ndk\\:left-2 {
358
+ left: calc(var(--ndk-spacing)*2);
359
+ }
360
+ .ndk\\:z-50 {
361
+ z-index: 50;
362
+ }
363
+ .ndk\\:-mx-1 {
364
+ margin-inline: calc(var(--ndk-spacing)*-1);
365
+ }
366
+ .ndk\\:mx-0 {
367
+ margin-inline: calc(var(--ndk-spacing)*0);
368
+ }
369
+ .ndk\\:mx-auto {
370
+ margin-inline: auto;
371
+ }
372
+ .ndk\\:my-1 {
373
+ margin-block: calc(var(--ndk-spacing)*1);
374
+ }
375
+ .ndk\\:mt-4 {
376
+ margin-top: calc(var(--ndk-spacing)*4);
377
+ }
378
+ .ndk\\:mr-1\\.5 {
379
+ margin-right: calc(var(--ndk-spacing)*1.5);
380
+ }
381
+ .ndk\\:mr-2 {
382
+ margin-right: calc(var(--ndk-spacing)*2);
383
+ }
384
+ .ndk\\:-ml-4 {
385
+ margin-left: calc(var(--ndk-spacing)*-4);
386
+ }
387
+ .ndk\\:ml-1 {
388
+ margin-left: calc(var(--ndk-spacing)*1);
389
+ }
390
+ .ndk\\:ml-auto {
391
+ margin-left: auto;
392
+ }
393
+ .ndk\\:flex {
394
+ display: flex;
395
+ }
396
+ .ndk\\:grid {
397
+ display: grid;
398
+ }
399
+ .ndk\\:hidden {
400
+ display: none;
401
+ }
402
+ .ndk\\:inline-flex {
403
+ display: inline-flex;
404
+ }
405
+ .ndk\\:size-2 {
406
+ width: calc(var(--ndk-spacing)*2);
407
+ height: calc(var(--ndk-spacing)*2);
408
+ }
409
+ .ndk\\:size-3\\.5 {
410
+ width: calc(var(--ndk-spacing)*3.5);
411
+ height: calc(var(--ndk-spacing)*3.5);
412
+ }
413
+ .ndk\\:size-4 {
414
+ width: calc(var(--ndk-spacing)*4);
415
+ height: calc(var(--ndk-spacing)*4);
416
+ }
417
+ .ndk\\:size-5 {
418
+ width: calc(var(--ndk-spacing)*5);
419
+ height: calc(var(--ndk-spacing)*5);
420
+ }
421
+ .ndk\\:size-6 {
422
+ width: calc(var(--ndk-spacing)*6);
423
+ height: calc(var(--ndk-spacing)*6);
424
+ }
425
+ .ndk\\:size-8 {
426
+ width: calc(var(--ndk-spacing)*8);
427
+ height: calc(var(--ndk-spacing)*8);
428
+ }
429
+ .ndk\\:size-9 {
430
+ width: calc(var(--ndk-spacing)*9);
431
+ height: calc(var(--ndk-spacing)*9);
432
+ }
433
+ .ndk\\:size-10 {
434
+ width: calc(var(--ndk-spacing)*10);
435
+ height: calc(var(--ndk-spacing)*10);
436
+ }
437
+ .ndk\\:h-8 {
438
+ height: calc(var(--ndk-spacing)*8);
439
+ }
440
+ .ndk\\:h-9 {
441
+ height: calc(var(--ndk-spacing)*9);
442
+ }
443
+ .ndk\\:h-10 {
444
+ height: calc(var(--ndk-spacing)*10);
445
+ }
446
+ .ndk\\:h-24 {
447
+ height: calc(var(--ndk-spacing)*24);
448
+ }
449
+ .ndk\\:h-48 {
450
+ height: calc(var(--ndk-spacing)*48);
451
+ }
452
+ .ndk\\:h-\\[var\\(--radix-select-trigger-height\\)\\] {
453
+ height: var(--radix-select-trigger-height);
454
+ }
455
+ .ndk\\:h-auto {
456
+ height: auto;
457
+ }
458
+ .ndk\\:h-full {
459
+ height: 100%;
460
+ }
461
+ .ndk\\:h-px {
462
+ height: 1px;
463
+ }
464
+ .ndk\\:max-h-\\(--radix-dropdown-menu-content-available-height\\) {
465
+ max-height: var(--radix-dropdown-menu-content-available-height);
466
+ }
467
+ .ndk\\:max-h-\\(--radix-select-content-available-height\\) {
468
+ max-height: var(--radix-select-content-available-height);
469
+ }
470
+ .ndk\\:min-h-0 {
471
+ min-height: calc(var(--ndk-spacing)*0);
472
+ }
473
+ .ndk\\:min-h-\\[200px\\] {
474
+ min-height: 200px;
475
+ }
476
+ .ndk\\:w-12 {
477
+ width: calc(var(--ndk-spacing)*12);
478
+ }
479
+ .ndk\\:w-16 {
480
+ width: calc(var(--ndk-spacing)*16);
481
+ }
482
+ .ndk\\:w-72 {
483
+ width: calc(var(--ndk-spacing)*72);
484
+ }
485
+ .ndk\\:w-80 {
486
+ width: calc(var(--ndk-spacing)*80);
487
+ }
488
+ .ndk\\:w-auto {
489
+ width: auto;
490
+ }
491
+ .ndk\\:w-fit {
492
+ width: fit-content;
493
+ }
494
+ .ndk\\:w-full {
495
+ width: 100%;
496
+ }
497
+ .ndk\\:min-w-\\[8rem\\] {
498
+ min-width: 8rem;
499
+ }
500
+ .ndk\\:min-w-\\[var\\(--radix-select-trigger-width\\)\\] {
501
+ min-width: var(--radix-select-trigger-width);
502
+ }
503
+ .ndk\\:flex-1 {
504
+ flex: 1;
505
+ }
506
+ .ndk\\:shrink-0 {
507
+ flex-shrink: 0;
508
+ }
509
+ .ndk\\:caption-bottom {
510
+ caption-side: bottom;
511
+ }
512
+ .ndk\\:origin-\\(--radix-dropdown-menu-content-transform-origin\\) {
513
+ transform-origin: var(--radix-dropdown-menu-content-transform-origin);
514
+ }
515
+ .ndk\\:origin-\\(--radix-popover-content-transform-origin\\) {
516
+ transform-origin: var(--radix-popover-content-transform-origin);
517
+ }
518
+ .ndk\\:origin-\\(--radix-select-content-transform-origin\\) {
519
+ transform-origin: var(--radix-select-content-transform-origin);
520
+ }
521
+ .ndk\\:animate-spin {
522
+ animation: var(--ndk-animate-spin);
523
+ }
524
+ .ndk\\:cursor-default {
525
+ cursor: default;
526
+ }
527
+ .ndk\\:scroll-my-1 {
528
+ scroll-margin-block: calc(var(--ndk-spacing)*1);
529
+ }
530
+ .ndk\\:flex-col {
531
+ flex-direction: column;
532
+ }
533
+ .ndk\\:flex-row {
534
+ flex-direction: row;
535
+ }
536
+ .ndk\\:place-content-center {
537
+ place-content: center;
538
+ }
539
+ .ndk\\:items-center {
540
+ align-items: center;
541
+ }
542
+ .ndk\\:justify-between {
543
+ justify-content: space-between;
544
+ }
545
+ .ndk\\:justify-center {
546
+ justify-content: center;
547
+ }
548
+ .ndk\\:justify-end {
549
+ justify-content: flex-end;
550
+ }
551
+ .ndk\\:gap-1 {
552
+ gap: calc(var(--ndk-spacing)*1);
553
+ }
554
+ .ndk\\:gap-1\\.5 {
555
+ gap: calc(var(--ndk-spacing)*1.5);
556
+ }
557
+ .ndk\\:gap-2 {
558
+ gap: calc(var(--ndk-spacing)*2);
559
+ }
560
+ .ndk\\:gap-3 {
561
+ gap: calc(var(--ndk-spacing)*3);
562
+ }
563
+ .ndk\\:gap-4 {
564
+ gap: calc(var(--ndk-spacing)*4);
565
+ }
566
+ :where(.ndk\\:space-y-3 > :not(:last-child)) {
567
+ --tw-space-y-reverse:0;
568
+ margin-block-start: calc(calc(var(--ndk-spacing)*3)*var(--tw-space-y-reverse));
569
+ margin-block-end: calc(calc(var(--ndk-spacing)*3)*calc(1 - var(--tw-space-y-reverse)));
570
+ }
571
+ .ndk\\:overflow-hidden {
572
+ overflow: hidden;
573
+ }
574
+ .ndk\\:overflow-x-auto {
575
+ overflow-x: auto;
576
+ }
577
+ .ndk\\:overflow-x-hidden {
578
+ overflow-x: hidden;
579
+ }
580
+ .ndk\\:overflow-y-auto {
581
+ overflow-y: auto;
582
+ }
583
+ .ndk\\:rounded-\\[4px\\] {
584
+ border-radius: 4px;
585
+ }
586
+ .ndk\\:rounded-lg {
587
+ border-radius: var(--ndk-radius-lg);
588
+ }
589
+ .ndk\\:rounded-md {
590
+ border-radius: var(--ndk-radius-md);
591
+ }
592
+ .ndk\\:rounded-sm {
593
+ border-radius: var(--ndk-radius-sm);
594
+ }
595
+ .ndk\\:border {
596
+ border-style: var(--tw-border-style);
597
+ border-width: 1px;
598
+ }
599
+ .ndk\\:border-t {
600
+ border-top-style: var(--tw-border-style);
601
+ border-top-width: 1px;
602
+ }
603
+ .ndk\\:border-b {
604
+ border-bottom-style: var(--tw-border-style);
605
+ border-bottom-width: 1px;
606
+ }
607
+ .ndk\\:border-gray-100 {
608
+ border-color: var(--ndk-color-gray-100);
609
+ }
610
+ .ndk\\:border-gray-200 {
611
+ border-color: var(--ndk-color-gray-200);
612
+ }
613
+ .ndk\\:bg-gray-50\\/70 {
614
+ background-color: var(--ndk-color-gray-50);
615
+ }
616
+ @supports (color:color-mix(in lab, red, red)) {
617
+ .ndk\\:bg-gray-50\\/70 {
618
+ background-color: color-mix(in oklab, var(--ndk-color-gray-50)70%, transparent);
619
+ }
620
+ }
621
+ .ndk\\:bg-gray-100 {
622
+ background-color: var(--ndk-color-gray-100);
623
+ }
624
+ .ndk\\:bg-gray-900 {
625
+ background-color: var(--ndk-color-gray-900);
626
+ }
627
+ .ndk\\:bg-red-600 {
628
+ background-color: var(--ndk-color-red-600);
629
+ }
630
+ .ndk\\:bg-transparent {
631
+ background-color: #0000;
632
+ }
633
+ .ndk\\:bg-white {
634
+ background-color: var(--ndk-color-white);
635
+ }
636
+ .ndk\\:fill-current {
637
+ fill: currentColor;
638
+ }
639
+ .ndk\\:p-1 {
640
+ padding: calc(var(--ndk-spacing)*1);
641
+ }
642
+ .ndk\\:p-2 {
643
+ padding: calc(var(--ndk-spacing)*2);
644
+ }
645
+ .ndk\\:p-4 {
646
+ padding: calc(var(--ndk-spacing)*4);
647
+ }
648
+ .ndk\\:px-2 {
649
+ padding-inline: calc(var(--ndk-spacing)*2);
650
+ }
651
+ .ndk\\:px-2\\.5 {
652
+ padding-inline: calc(var(--ndk-spacing)*2.5);
653
+ }
654
+ .ndk\\:px-3 {
655
+ padding-inline: calc(var(--ndk-spacing)*3);
656
+ }
657
+ .ndk\\:px-4 {
658
+ padding-inline: calc(var(--ndk-spacing)*4);
659
+ }
660
+ .ndk\\:px-6 {
661
+ padding-inline: calc(var(--ndk-spacing)*6);
662
+ }
663
+ .ndk\\:py-0 {
664
+ padding-block: calc(var(--ndk-spacing)*0);
665
+ }
666
+ .ndk\\:py-1 {
667
+ padding-block: calc(var(--ndk-spacing)*1);
668
+ }
669
+ .ndk\\:py-1\\.5 {
670
+ padding-block: calc(var(--ndk-spacing)*1.5);
671
+ }
672
+ .ndk\\:py-2 {
673
+ padding-block: calc(var(--ndk-spacing)*2);
674
+ }
675
+ .ndk\\:py-4 {
676
+ padding-block: calc(var(--ndk-spacing)*4);
677
+ }
678
+ .ndk\\:pt-3 {
679
+ padding-top: calc(var(--ndk-spacing)*3);
680
+ }
681
+ .ndk\\:pt-4 {
682
+ padding-top: calc(var(--ndk-spacing)*4);
683
+ }
684
+ .ndk\\:pr-2 {
685
+ padding-right: calc(var(--ndk-spacing)*2);
686
+ }
687
+ .ndk\\:pr-8 {
688
+ padding-right: calc(var(--ndk-spacing)*8);
689
+ }
690
+ .ndk\\:pb-3 {
691
+ padding-bottom: calc(var(--ndk-spacing)*3);
692
+ }
693
+ .ndk\\:pl-2 {
694
+ padding-left: calc(var(--ndk-spacing)*2);
695
+ }
696
+ .ndk\\:pl-8 {
697
+ padding-left: calc(var(--ndk-spacing)*8);
698
+ }
699
+ .ndk\\:text-center {
700
+ text-align: center;
701
+ }
702
+ .ndk\\:text-left {
703
+ text-align: left;
704
+ }
705
+ .ndk\\:align-middle {
706
+ vertical-align: middle;
707
+ }
708
+ .ndk\\:text-sm {
709
+ font-size: var(--ndk-text-sm);
710
+ line-height: var(--tw-leading,var(--ndk-text-sm--line-height));
711
+ }
712
+ .ndk\\:text-xs {
713
+ font-size: var(--ndk-text-xs);
714
+ line-height: var(--tw-leading,var(--ndk-text-xs--line-height));
715
+ }
716
+ .ndk\\:font-medium {
717
+ --tw-font-weight:var(--ndk-font-weight-medium);
718
+ font-weight: var(--ndk-font-weight-medium);
719
+ }
720
+ .ndk\\:tracking-widest {
721
+ --tw-tracking:var(--ndk-tracking-widest);
722
+ letter-spacing: var(--ndk-tracking-widest);
723
+ }
724
+ .ndk\\:whitespace-nowrap {
725
+ white-space: nowrap;
726
+ }
727
+ .ndk\\:text-current {
728
+ color: currentColor;
729
+ }
730
+ .ndk\\:text-gray-500 {
731
+ color: var(--ndk-color-gray-500);
732
+ }
733
+ .ndk\\:text-gray-900 {
734
+ color: var(--ndk-color-gray-900);
735
+ }
736
+ .ndk\\:text-red-500 {
737
+ color: var(--ndk-color-red-500);
738
+ }
739
+ .ndk\\:text-white {
740
+ color: var(--ndk-color-white);
741
+ }
742
+ .ndk\\:underline-offset-4 {
743
+ text-underline-offset: 4px;
744
+ }
745
+ .ndk\\:opacity-50 {
746
+ opacity: .5;
747
+ }
748
+ .ndk\\:shadow-lg {
749
+ --tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);
750
+ box-shadow:
751
+ var(--tw-inset-shadow),
752
+ var(--tw-inset-ring-shadow),
753
+ var(--tw-ring-offset-shadow),
754
+ var(--tw-ring-shadow),
755
+ var(--tw-shadow);
756
+ }
757
+ .ndk\\:shadow-md {
758
+ --tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);
759
+ box-shadow:
760
+ var(--tw-inset-shadow),
761
+ var(--tw-inset-ring-shadow),
762
+ var(--tw-ring-offset-shadow),
763
+ var(--tw-ring-shadow),
764
+ var(--tw-shadow);
765
+ }
766
+ .ndk\\:shadow-xs {
767
+ --tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);
768
+ box-shadow:
769
+ var(--tw-inset-shadow),
770
+ var(--tw-inset-ring-shadow),
771
+ var(--tw-ring-offset-shadow),
772
+ var(--tw-ring-shadow),
773
+ var(--tw-shadow);
774
+ }
775
+ .ndk\\:outline-hidden {
776
+ --tw-outline-style:none;
777
+ outline-style: none;
778
+ }
779
+ @media (forced-colors: active) {
780
+ .ndk\\:outline-hidden {
781
+ outline-offset: 2px;
782
+ outline: 2px solid #0000;
783
+ }
784
+ }
785
+ .ndk\\:transition-\\[color\\,box-shadow\\] {
786
+ transition-property: color, box-shadow;
787
+ transition-timing-function: var(--tw-ease,var(--ndk-default-transition-timing-function));
788
+ transition-duration: var(--tw-duration,var(--ndk-default-transition-duration));
789
+ }
790
+ .ndk\\:transition-all {
791
+ transition-property: all;
792
+ transition-timing-function: var(--tw-ease,var(--ndk-default-transition-timing-function));
793
+ transition-duration: var(--tw-duration,var(--ndk-default-transition-duration));
794
+ }
795
+ .ndk\\:transition-colors {
796
+ transition-property:
797
+ color,
798
+ background-color,
799
+ border-color,
800
+ outline-color,
801
+ text-decoration-color,
802
+ fill,
803
+ stroke,
804
+ --tw-gradient-from,
805
+ --tw-gradient-via,
806
+ --tw-gradient-to;
807
+ transition-timing-function: var(--tw-ease,var(--ndk-default-transition-timing-function));
808
+ transition-duration: var(--tw-duration,var(--ndk-default-transition-duration));
809
+ }
810
+ .ndk\\:transition-shadow {
811
+ transition-property: box-shadow;
812
+ transition-timing-function: var(--tw-ease,var(--ndk-default-transition-timing-function));
813
+ transition-duration: var(--tw-duration,var(--ndk-default-transition-duration));
814
+ }
815
+ .ndk\\:transition-none {
816
+ transition-property: none;
817
+ }
818
+ .ndk\\:outline-none {
819
+ --tw-outline-style:none;
820
+ outline-style: none;
821
+ }
822
+ .ndk\\:select-none {
823
+ -webkit-user-select: none;
824
+ user-select: none;
825
+ }
826
+ @media (hover: hover) {
827
+ .ndk\\:hover\\:bg-gray-50:hover {
828
+ background-color: var(--ndk-color-gray-50);
829
+ }
830
+ .ndk\\:hover\\:bg-gray-100:hover {
831
+ background-color: var(--ndk-color-gray-100);
832
+ }
833
+ .ndk\\:hover\\:bg-gray-200:hover {
834
+ background-color: var(--ndk-color-gray-200);
835
+ }
836
+ .ndk\\:hover\\:bg-gray-800:hover {
837
+ background-color: var(--ndk-color-gray-800);
838
+ }
839
+ .ndk\\:hover\\:bg-red-700:hover {
840
+ background-color: var(--ndk-color-red-700);
841
+ }
842
+ .ndk\\:hover\\:text-gray-900:hover {
843
+ color: var(--ndk-color-gray-900);
844
+ }
845
+ .ndk\\:hover\\:underline:hover {
846
+ text-decoration-line: underline;
847
+ }
848
+ }
849
+ .ndk\\:focus\\:bg-gray-50:focus {
850
+ background-color: var(--ndk-color-gray-50);
851
+ }
852
+ .ndk\\:focus\\:text-gray-900:focus {
853
+ color: var(--ndk-color-gray-900);
854
+ }
855
+ .ndk\\:focus\\:ring-2:focus {
856
+ --tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);
857
+ box-shadow:
858
+ var(--tw-inset-shadow),
859
+ var(--tw-inset-ring-shadow),
860
+ var(--tw-ring-offset-shadow),
861
+ var(--tw-ring-shadow),
862
+ var(--tw-shadow);
863
+ }
864
+ .ndk\\:focus-visible\\:border-gray-900:focus-visible {
865
+ border-color: var(--ndk-color-gray-900);
866
+ }
867
+ .ndk\\:focus-visible\\:ring-\\[3px\\]:focus-visible {
868
+ --tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);
869
+ box-shadow:
870
+ var(--tw-inset-shadow),
871
+ var(--tw-inset-ring-shadow),
872
+ var(--tw-ring-offset-shadow),
873
+ var(--tw-ring-shadow),
874
+ var(--tw-shadow);
875
+ }
876
+ .ndk\\:focus-visible\\:ring-black\\/20:focus-visible {
877
+ --tw-ring-color:var(--ndk-color-black);
878
+ }
879
+ @supports (color:color-mix(in lab, red, red)) {
880
+ .ndk\\:focus-visible\\:ring-black\\/20:focus-visible {
881
+ --tw-ring-color:color-mix(in oklab,var(--ndk-color-black)20%,transparent);
882
+ }
883
+ }
884
+ .ndk\\:disabled\\:pointer-events-none:disabled {
885
+ pointer-events: none;
886
+ }
887
+ .ndk\\:disabled\\:cursor-not-allowed:disabled {
888
+ cursor: not-allowed;
889
+ }
890
+ .ndk\\:disabled\\:opacity-50:disabled {
891
+ opacity: .5;
892
+ }
893
+ .ndk\\:has-\\[\\>svg\\]\\:px-2\\.5:has(> svg) {
894
+ padding-inline: calc(var(--ndk-spacing)*2.5);
895
+ }
896
+ .ndk\\:has-\\[\\>svg\\]\\:px-3:has(> svg) {
897
+ padding-inline: calc(var(--ndk-spacing)*3);
898
+ }
899
+ .ndk\\:has-\\[\\>svg\\]\\:px-4:has(> svg) {
900
+ padding-inline: calc(var(--ndk-spacing)*4);
901
+ }
902
+ .ndk\\:aria-invalid\\:border-red-500[aria-invalid=true] {
903
+ border-color: var(--ndk-color-red-500);
904
+ }
905
+ .ndk\\:aria-invalid\\:ring-red-500\\/20[aria-invalid=true] {
906
+ --tw-ring-color:var(--ndk-color-red-500);
907
+ }
908
+ @supports (color:color-mix(in lab, red, red)) {
909
+ .ndk\\:aria-invalid\\:ring-red-500\\/20[aria-invalid=true] {
910
+ --tw-ring-color:color-mix(in oklab,var(--ndk-color-red-500)20%,transparent);
911
+ }
912
+ }
913
+ .ndk\\:data-\\[disabled\\]\\:pointer-events-none[data-disabled] {
914
+ pointer-events: none;
915
+ }
916
+ .ndk\\:data-\\[disabled\\]\\:opacity-50[data-disabled] {
917
+ opacity: .5;
918
+ }
919
+ .ndk\\:data-\\[inset\\]\\:pl-8[data-inset] {
920
+ padding-left: calc(var(--ndk-spacing)*8);
921
+ }
922
+ .ndk\\:data-\\[placeholder\\]\\:text-gray-500[data-placeholder] {
923
+ color: var(--ndk-color-gray-500);
924
+ }
925
+ .ndk\\:data-\\[side\\=bottom\\]\\:translate-y-1[data-side=bottom] {
926
+ --tw-translate-y:calc(var(--ndk-spacing)*1);
927
+ translate: var(--tw-translate-x)var(--tw-translate-y);
928
+ }
929
+ .ndk\\:data-\\[side\\=left\\]\\:-translate-x-1[data-side=left] {
930
+ --tw-translate-x:calc(var(--ndk-spacing)*-1);
931
+ translate: var(--tw-translate-x)var(--tw-translate-y);
932
+ }
933
+ .ndk\\:data-\\[side\\=right\\]\\:translate-x-1[data-side=right] {
934
+ --tw-translate-x:calc(var(--ndk-spacing)*1);
935
+ translate: var(--tw-translate-x)var(--tw-translate-y);
936
+ }
937
+ .ndk\\:data-\\[side\\=top\\]\\:-translate-y-1[data-side=top] {
938
+ --tw-translate-y:calc(var(--ndk-spacing)*-1);
939
+ translate: var(--tw-translate-x)var(--tw-translate-y);
940
+ }
941
+ .ndk\\:data-\\[size\\=default\\]\\:h-9[data-size=default] {
942
+ height: calc(var(--ndk-spacing)*9);
943
+ }
944
+ .ndk\\:data-\\[size\\=sm\\]\\:h-8[data-size=sm] {
945
+ height: calc(var(--ndk-spacing)*8);
946
+ }
947
+ :is(.ndk\\:\\*\\:data-\\[slot\\=select-value\\]\\:line-clamp-1 > *)[data-slot=select-value] {
948
+ -webkit-line-clamp: 1;
949
+ -webkit-box-orient: vertical;
950
+ display: -webkit-box;
951
+ overflow: hidden;
952
+ }
953
+ :is(.ndk\\:\\*\\:data-\\[slot\\=select-value\\]\\:flex > *)[data-slot=select-value] {
954
+ display: flex;
955
+ }
956
+ :is(.ndk\\:\\*\\:data-\\[slot\\=select-value\\]\\:items-center > *)[data-slot=select-value] {
957
+ align-items: center;
958
+ }
959
+ :is(.ndk\\:\\*\\:data-\\[slot\\=select-value\\]\\:gap-2 > *)[data-slot=select-value] {
960
+ gap: calc(var(--ndk-spacing)*2);
961
+ }
962
+ .ndk\\:data-\\[state\\=checked\\]\\:border-gray-900[data-state=checked] {
963
+ border-color: var(--ndk-color-gray-900);
964
+ }
965
+ .ndk\\:data-\\[state\\=checked\\]\\:bg-gray-900[data-state=checked] {
966
+ background-color: var(--ndk-color-gray-900);
967
+ }
968
+ .ndk\\:data-\\[state\\=checked\\]\\:text-white[data-state=checked] {
969
+ color: var(--ndk-color-white);
970
+ }
971
+ .ndk\\:data-\\[state\\=closed\\]\\:animate-out[data-state=closed] {
972
+ animation: var(--ndk-animate-out);
973
+ }
974
+ .ndk\\:data-\\[state\\=open\\]\\:animate-in[data-state=open] {
975
+ animation: var(--ndk-animate-in);
976
+ }
977
+ .ndk\\:data-\\[state\\=open\\]\\:bg-gray-50[data-state=open] {
978
+ background-color: var(--ndk-color-gray-50);
979
+ }
980
+ .ndk\\:data-\\[state\\=open\\]\\:text-gray-900[data-state=open] {
981
+ color: var(--ndk-color-gray-900);
982
+ }
983
+ .ndk\\:data-\\[state\\=selected\\]\\:bg-gray-50[data-state=selected] {
984
+ background-color: var(--ndk-color-gray-50);
985
+ }
986
+ .ndk\\:data-\\[variant\\=destructive\\]\\:text-red-600[data-variant=destructive] {
987
+ color: var(--ndk-color-red-600);
988
+ }
989
+ .ndk\\:data-\\[variant\\=destructive\\]\\:focus\\:bg-red-500\\/10[data-variant=destructive]:focus {
990
+ background-color: var(--ndk-color-red-500);
991
+ }
992
+ @supports (color:color-mix(in lab, red, red)) {
993
+ .ndk\\:data-\\[variant\\=destructive\\]\\:focus\\:bg-red-500\\/10[data-variant=destructive]:focus {
994
+ background-color: color-mix(in oklab, var(--ndk-color-red-500)10%, transparent);
995
+ }
996
+ }
997
+ .ndk\\:data-\\[variant\\=destructive\\]\\:focus\\:text-red-700[data-variant=destructive]:focus {
998
+ color: var(--ndk-color-red-700);
999
+ }
1000
+ @media (min-width: 40rem) {
1001
+ .ndk\\:sm\\:block {
1002
+ display: block;
1003
+ }
1004
+ .ndk\\:sm\\:hidden {
1005
+ display: none;
1006
+ }
1007
+ .ndk\\:sm\\:pr-2\\.5 {
1008
+ padding-right: calc(var(--ndk-spacing)*2.5);
1009
+ }
1010
+ .ndk\\:sm\\:pl-2\\.5 {
1011
+ padding-left: calc(var(--ndk-spacing)*2.5);
1012
+ }
1013
+ }
1014
+ .ndk\\:dark\\:border-gray-800:where(.dark, .dark *) {
1015
+ border-color: var(--ndk-color-gray-800);
1016
+ }
1017
+ .ndk\\:dark\\:bg-gray-100:where(.dark, .dark *) {
1018
+ background-color: var(--ndk-color-gray-100);
1019
+ }
1020
+ .ndk\\:dark\\:bg-gray-900:where(.dark, .dark *),
1021
+ .ndk\\:dark\\:bg-gray-900\\/40:where(.dark, .dark *) {
1022
+ background-color: var(--ndk-color-gray-900);
1023
+ }
1024
+ @supports (color:color-mix(in lab, red, red)) {
1025
+ .ndk\\:dark\\:bg-gray-900\\/40:where(.dark, .dark *) {
1026
+ background-color: color-mix(in oklab, var(--ndk-color-gray-900)40%, transparent);
1027
+ }
1028
+ }
1029
+ .ndk\\:dark\\:bg-gray-950:where(.dark, .dark *) {
1030
+ background-color: var(--ndk-color-gray-950);
1031
+ }
1032
+ .ndk\\:dark\\:bg-red-600:where(.dark, .dark *) {
1033
+ background-color: var(--ndk-color-red-600);
1034
+ }
1035
+ .ndk\\:dark\\:text-gray-100:where(.dark, .dark *) {
1036
+ color: var(--ndk-color-gray-100);
1037
+ }
1038
+ .ndk\\:dark\\:text-gray-400:where(.dark, .dark *) {
1039
+ color: var(--ndk-color-gray-400);
1040
+ }
1041
+ .ndk\\:dark\\:text-gray-900:where(.dark, .dark *) {
1042
+ color: var(--ndk-color-gray-900);
1043
+ }
1044
+ @media (hover: hover) {
1045
+ .ndk\\:dark\\:hover\\:bg-gray-200:where(.dark, .dark *):hover {
1046
+ background-color: var(--ndk-color-gray-200);
1047
+ }
1048
+ .ndk\\:dark\\:hover\\:bg-gray-800:where(.dark, .dark *):hover {
1049
+ background-color: var(--ndk-color-gray-800);
1050
+ }
1051
+ .ndk\\:dark\\:hover\\:bg-gray-900:where(.dark, .dark *):hover {
1052
+ background-color: var(--ndk-color-gray-900);
1053
+ }
1054
+ .ndk\\:dark\\:hover\\:bg-red-500:where(.dark, .dark *):hover {
1055
+ background-color: var(--ndk-color-red-500);
1056
+ }
1057
+ .ndk\\:dark\\:hover\\:text-gray-100:where(.dark, .dark *):hover {
1058
+ color: var(--ndk-color-gray-100);
1059
+ }
1060
+ }
1061
+ .ndk\\:dark\\:focus\\:bg-gray-900:where(.dark, .dark *):focus {
1062
+ background-color: var(--ndk-color-gray-900);
1063
+ }
1064
+ .ndk\\:dark\\:focus\\:text-gray-100:where(.dark, .dark *):focus {
1065
+ color: var(--ndk-color-gray-100);
1066
+ }
1067
+ .ndk\\:dark\\:focus-visible\\:border-gray-200:where(.dark, .dark *):focus-visible {
1068
+ border-color: var(--ndk-color-gray-200);
1069
+ }
1070
+ .ndk\\:dark\\:focus-visible\\:ring-white\\/20:where(.dark, .dark *):focus-visible {
1071
+ --tw-ring-color:var(--ndk-color-white);
1072
+ }
1073
+ @supports (color:color-mix(in lab, red, red)) {
1074
+ .ndk\\:dark\\:focus-visible\\:ring-white\\/20:where(.dark, .dark *):focus-visible {
1075
+ --tw-ring-color:color-mix(in oklab,var(--ndk-color-white)20%,transparent);
1076
+ }
1077
+ }
1078
+ .ndk\\:dark\\:aria-invalid\\:ring-red-500\\/30:where(.dark, .dark *)[aria-invalid=true] {
1079
+ --tw-ring-color:var(--ndk-color-red-500);
1080
+ }
1081
+ @supports (color:color-mix(in lab, red, red)) {
1082
+ .ndk\\:dark\\:aria-invalid\\:ring-red-500\\/30:where(.dark, .dark *)[aria-invalid=true] {
1083
+ --tw-ring-color:color-mix(in oklab,var(--ndk-color-red-500)30%,transparent);
1084
+ }
1085
+ }
1086
+ .ndk\\:dark\\:data-\\[placeholder\\]\\:text-gray-400:where(.dark, .dark *)[data-placeholder] {
1087
+ color: var(--ndk-color-gray-400);
1088
+ }
1089
+ .ndk\\:dark\\:data-\\[state\\=checked\\]\\:border-gray-100:where(.dark, .dark *)[data-state=checked] {
1090
+ border-color: var(--ndk-color-gray-100);
1091
+ }
1092
+ .ndk\\:dark\\:data-\\[state\\=checked\\]\\:bg-gray-100:where(.dark, .dark *)[data-state=checked] {
1093
+ background-color: var(--ndk-color-gray-100);
1094
+ }
1095
+ .ndk\\:dark\\:data-\\[state\\=checked\\]\\:text-gray-900:where(.dark, .dark *)[data-state=checked] {
1096
+ color: var(--ndk-color-gray-900);
1097
+ }
1098
+ .ndk\\:dark\\:data-\\[state\\=open\\]\\:bg-gray-900:where(.dark, .dark *)[data-state=open] {
1099
+ background-color: var(--ndk-color-gray-900);
1100
+ }
1101
+ .ndk\\:dark\\:data-\\[state\\=open\\]\\:text-gray-100:where(.dark, .dark *)[data-state=open] {
1102
+ color: var(--ndk-color-gray-100);
1103
+ }
1104
+ .ndk\\:dark\\:data-\\[state\\=selected\\]\\:bg-gray-900:where(.dark, .dark *)[data-state=selected] {
1105
+ background-color: var(--ndk-color-gray-900);
1106
+ }
1107
+ .ndk\\:dark\\:data-\\[variant\\=destructive\\]\\:text-red-500:where(.dark, .dark *)[data-variant=destructive] {
1108
+ color: var(--ndk-color-red-500);
1109
+ }
1110
+ .ndk\\:dark\\:data-\\[variant\\=destructive\\]\\:focus\\:bg-red-500\\/15:where(.dark, .dark *)[data-variant=destructive]:focus {
1111
+ background-color: var(--ndk-color-red-500);
1112
+ }
1113
+ @supports (color:color-mix(in lab, red, red)) {
1114
+ .ndk\\:dark\\:data-\\[variant\\=destructive\\]\\:focus\\:bg-red-500\\/15:where(.dark, .dark *)[data-variant=destructive]:focus {
1115
+ background-color: color-mix(in oklab, var(--ndk-color-red-500)15%, transparent);
1116
+ }
1117
+ }
1118
+ .ndk\\:dark\\:data-\\[variant\\=destructive\\]\\:focus\\:text-red-400:where(.dark, .dark *)[data-variant=destructive]:focus {
1119
+ color: var(--ndk-color-red-400);
1120
+ }
1121
+ .ndk\\:\\[\\&_svg\\]\\:pointer-events-none svg {
1122
+ pointer-events: none;
1123
+ }
1124
+ .ndk\\:\\[\\&_svg\\]\\:shrink-0 svg {
1125
+ flex-shrink: 0;
1126
+ }
1127
+ .ndk\\:\\[\\&_svg\\:not\\(\\[class\\*\\=\\'size-\\'\\]\\)\\]\\:size-4 svg:not([class*=size-]) {
1128
+ width: calc(var(--ndk-spacing)*4);
1129
+ height: calc(var(--ndk-spacing)*4);
1130
+ }
1131
+ .ndk\\:\\[\\&_svg\\:not\\(\\[class\\*\\=\\'text-\\'\\]\\)\\]\\:text-gray-500 svg:not([class*=text-]) {
1132
+ color: var(--ndk-color-gray-500);
1133
+ }
1134
+ .ndk\\:dark\\:\\[\\&_svg\\:not\\(\\[class\\*\\=\\'text-\\'\\]\\)\\]\\:text-gray-400:where(.dark, .dark *) svg:not([class*=text-]) {
1135
+ color: var(--ndk-color-gray-400);
1136
+ }
1137
+ .ndk\\:\\[\\&_tr\\]\\:border-b tr {
1138
+ border-bottom-style: var(--tw-border-style);
1139
+ border-bottom-width: 1px;
1140
+ }
1141
+ .ndk\\:\\[\\&_tr\\:last-child\\]\\:border-0 tr:last-child {
1142
+ border-style: var(--tw-border-style);
1143
+ border-width: 0;
1144
+ }
1145
+ .ndk\\:\\[\\&\\:has\\(\\[role\\=checkbox\\]\\)\\]\\:pr-0:has([role=checkbox]) {
1146
+ padding-right: calc(var(--ndk-spacing)*0);
1147
+ }
1148
+ :is(.ndk\\:\\*\\:\\[span\\]\\:last\\:flex > *):is(span):last-child {
1149
+ display: flex;
1150
+ }
1151
+ :is(.ndk\\:\\*\\:\\[span\\]\\:last\\:items-center > *):is(span):last-child {
1152
+ align-items: center;
1153
+ }
1154
+ :is(.ndk\\:\\*\\:\\[span\\]\\:last\\:gap-2 > *):is(span):last-child {
1155
+ gap: calc(var(--ndk-spacing)*2);
1156
+ }
1157
+ :is(.ndk\\:data-\\[variant\\=destructive\\]\\:\\*\\:\\[svg\\]\\:\\!text-red-600[data-variant=destructive] > *):is(svg) {
1158
+ color: var(--ndk-color-red-600) !important;
1159
+ }
1160
+ :is(.ndk\\:dark\\:data-\\[variant\\=destructive\\]\\:\\*\\:\\[svg\\]\\:\\!text-red-500:where(.dark, .dark *)[data-variant=destructive] > *):is(svg) {
1161
+ color: var(--ndk-color-red-500) !important;
1162
+ }
1163
+ .ndk\\:\\[\\&\\>\\[role\\=checkbox\\]\\]\\:translate-y-\\[2px\\] > [role=checkbox] {
1164
+ --tw-translate-y:2px;
1165
+ translate: var(--tw-translate-x)var(--tw-translate-y);
1166
+ }
1167
+ .ndk\\:\\[\\&\\>tr\\]\\:last\\:border-b-0 > tr:last-child {
1168
+ border-bottom-style: var(--tw-border-style);
1169
+ border-bottom-width: 0;
1170
+ }
1171
+ }
1172
+ @keyframes animate-in {
1173
+ 0% {
1174
+ opacity: 0;
1175
+ transform: scale(.95);
1176
+ }
1177
+ to {
1178
+ opacity: 1;
1179
+ transform: scale(1);
1180
+ }
1181
+ }
1182
+ @keyframes animate-out {
1183
+ 0% {
1184
+ opacity: 1;
1185
+ transform: scale(1);
1186
+ }
1187
+ to {
1188
+ opacity: 0;
1189
+ transform: scale(.95);
1190
+ }
1191
+ }
1192
+ @property --tw-space-y-reverse { syntax:"*";inherits:false;initial-value:0 }
1193
+ @property --tw-border-style { syntax:"*";inherits:false;initial-value:solid }
1194
+ @property --tw-font-weight { syntax:"*";inherits:false }
1195
+ @property --tw-tracking { syntax:"*";inherits:false }
1196
+ @property --tw-shadow { syntax:"*";inherits:false;initial-value:0 0 #0000 }
1197
+ @property --tw-shadow-color { syntax:"*";inherits:false }
1198
+ @property --tw-shadow-alpha { syntax:"<percentage>";inherits:false;initial-value:100% }
1199
+ @property --tw-inset-shadow { syntax:"*";inherits:false;initial-value:0 0 #0000 }
1200
+ @property --tw-inset-shadow-color { syntax:"*";inherits:false }
1201
+ @property --tw-inset-shadow-alpha { syntax:"<percentage>";inherits:false;initial-value:100% }
1202
+ @property --tw-ring-color { syntax:"*";inherits:false }
1203
+ @property --tw-ring-shadow { syntax:"*";inherits:false;initial-value:0 0 #0000 }
1204
+ @property --tw-inset-ring-color { syntax:"*";inherits:false }
1205
+ @property --tw-inset-ring-shadow { syntax:"*";inherits:false;initial-value:0 0 #0000 }
1206
+ @property --tw-ring-inset { syntax:"*";inherits:false }
1207
+ @property --tw-ring-offset-width { syntax:"<length>";inherits:false;initial-value:0 }
1208
+ @property --tw-ring-offset-color { syntax:"*";inherits:false;initial-value:#fff }
1209
+ @property --tw-ring-offset-shadow { syntax:"*";inherits:false;initial-value:0 0 #0000 }
1210
+ @property --tw-translate-x { syntax:"*";inherits:false;initial-value:0 }
1211
+ @property --tw-translate-y { syntax:"*";inherits:false;initial-value:0 }
1212
+ @property --tw-translate-z { syntax:"*";inherits:false;initial-value:0 }
1213
+ @keyframes spin {
1214
+ to {
1215
+ transform: rotate(360deg);
1216
+ }
1217
+ }
1218
+ `);
1219
+
1220
+ // src/client/utils/cn.ts
1221
+ var toClassString = (input) => {
1222
+ if (!input) return "";
1223
+ if (typeof input === "string" || typeof input === "number") return String(input);
1224
+ if (Array.isArray(input)) {
1225
+ return input.map(toClassString).filter(Boolean).join(" ");
1226
+ }
1227
+ if (typeof input === "object") {
1228
+ return Object.entries(input).filter(([, value]) => Boolean(value)).map(([key]) => key).join(" ");
1229
+ }
1230
+ return "";
1231
+ };
1232
+ var cn = (...inputs) => inputs.map(toClassString).filter(Boolean).join(" ");
1233
+
1234
+ // src/client/utils/index.ts
1235
+ var getColumnValue = (item, column) => {
1236
+ const { accessor } = column;
1237
+ return typeof accessor === "function" ? accessor(item) : item[accessor];
1238
+ };
1239
+ var getSortValue = (sorts, path) => {
1240
+ const sort = sorts.find((s) => s.path === path);
1241
+ return sort?.value ?? null;
1242
+ };
1243
+ var getNextSortValue = (current) => {
1244
+ if (current === null) return 1;
1245
+ if (current === 1) return -1;
1246
+ return null;
1247
+ };
1248
+ var formatNumber = (num) => num.toLocaleString();
1249
+ var debounce = (fn, delay) => {
1250
+ let timeoutId;
1251
+ return (...args) => {
1252
+ clearTimeout(timeoutId);
1253
+ timeoutId = setTimeout(() => fn(...args), delay);
1254
+ };
1255
+ };
1256
+ var throttle = (fn, limit) => {
1257
+ let inThrottle = false;
1258
+ return (...args) => {
1259
+ if (!inThrottle) {
1260
+ fn(...args);
1261
+ inThrottle = true;
1262
+ setTimeout(() => {
1263
+ inThrottle = false;
1264
+ }, limit);
1265
+ }
1266
+ };
1267
+ };
1268
+ var sortEntriesToKey = (sorts) => sorts.map((s) => `${s.path}:${s.value}`).join(",");
1269
+ var keyToSortEntries = (key) => {
1270
+ if (!key) return [];
1271
+ return key.split(",").map((part) => {
1272
+ const [path, value] = part.split(":");
1273
+ return { path: path ?? "", value: parseInt(value ?? "1", 10) };
1274
+ });
1275
+ };
1276
+ var parseUrlParams = (search) => {
1277
+ const params = new URLSearchParams(search);
1278
+ const state = {};
1279
+ const page = params.get("page");
1280
+ if (page) state.page = parseInt(page, 10);
1281
+ const limit = params.get("limit");
1282
+ if (limit) state.limit = parseInt(limit, 10);
1283
+ const sort = params.get("sort");
1284
+ if (sort) state.sorts = keyToSortEntries(sort);
1285
+ const filter = {};
1286
+ const query = {};
1287
+ params.forEach((value, key) => {
1288
+ if (key.startsWith("f_")) filter[key.slice(2)] = value;
1289
+ else if (key.startsWith("q_")) query[key.slice(2)] = value;
1290
+ });
1291
+ if (Object.keys(filter).length > 0) state.filter = filter;
1292
+ if (Object.keys(query).length > 0) state.query = query;
1293
+ return state;
1294
+ };
1295
+ var stateToUrlParams = (state) => {
1296
+ const params = new URLSearchParams();
1297
+ if (state.page && state.page > 1) params.set("page", state.page.toString());
1298
+ if (state.limit) params.set("limit", state.limit.toString());
1299
+ if (state.sorts && state.sorts.length > 0) params.set("sort", sortEntriesToKey(state.sorts));
1300
+ if (state.filter) {
1301
+ Object.entries(state.filter).forEach(([key, value]) => {
1302
+ if (value !== void 0 && value !== null && value !== "") {
1303
+ params.set(`f_${key}`, String(value));
1304
+ }
1305
+ });
1306
+ }
1307
+ if (state.query) {
1308
+ Object.entries(state.query).forEach(([key, value]) => {
1309
+ if (value !== void 0 && value !== null && value !== "") {
1310
+ params.set(`q_${key}`, String(value));
1311
+ }
1312
+ });
1313
+ }
1314
+ return params;
1315
+ };
1316
+
1317
+ // src/client/hooks/useDataKit.ts
1318
+ var useDataKit = (props) => {
1319
+ const { initial = {}, memory: memoryMode = "memory", filters, action, onSuccess, onError, autoFetch = true, debounce: debounceDelay = 300 } = props;
1320
+ const { page: initialPage = 1, limit: initialLimit = 10, sorts: initialSorts = [], filter: initialFilter = {}, query: initialQuery = {} } = initial;
1321
+ const [page, setPageState] = useState(initialPage);
1322
+ const [limit, setLimitState] = useState(initialLimit);
1323
+ const [sorts, setSortsState] = useState(initialSorts);
1324
+ const [filter, setFilterState] = useState(initialFilter);
1325
+ const [debouncedFilter, setDebouncedFilter] = useState(initialFilter);
1326
+ const [query, setQueryState] = useState(initialQuery);
1327
+ const [isLoading, setIsLoading] = useState(false);
1328
+ const [error, setError] = useState(null);
1329
+ const [items, setItems] = useState([]);
1330
+ const [total, setTotal] = useState(0);
1331
+ const mounted = useRef(true);
1332
+ const fetchIdRef = useRef(0);
1333
+ const debounceTimerRef = useRef(null);
1334
+ const actionRef = useRef(action);
1335
+ const onSuccessRef = useRef(onSuccess);
1336
+ const onErrorRef = useRef(onError);
1337
+ const filtersRef = useRef(filters);
1338
+ actionRef.current = action;
1339
+ onSuccessRef.current = onSuccess;
1340
+ onErrorRef.current = onError;
1341
+ filtersRef.current = filters;
1342
+ const getInput = useCallback(() => {
1343
+ const input = {
1344
+ action: "FETCH",
1345
+ page,
1346
+ limit,
1347
+ sorts,
1348
+ filter: debouncedFilter,
1349
+ query
1350
+ };
1351
+ if (filtersRef.current) {
1352
+ input.filterConfig = filtersRef.current.reduce((acc, f) => {
1353
+ if (f.configuration) acc[f.id] = f.configuration;
1354
+ return acc;
1355
+ }, {});
1356
+ }
1357
+ return input;
1358
+ }, [page, limit, sorts, debouncedFilter, query]);
1359
+ const fetchData = useCallback(async () => {
1360
+ const fetchId = ++fetchIdRef.current;
1361
+ setIsLoading(true);
1362
+ setError(null);
1363
+ try {
1364
+ const input = getInput();
1365
+ const result = await actionRef.current(input);
1366
+ if (fetchId !== fetchIdRef.current || !mounted.current) return;
1367
+ setItems(result.items);
1368
+ setTotal(result.documentTotal);
1369
+ onSuccessRef.current?.(result);
1370
+ } catch (err) {
1371
+ if (fetchId !== fetchIdRef.current || !mounted.current) return;
1372
+ const fetchError = err instanceof Error ? err : new Error(String(err));
1373
+ setError(fetchError);
1374
+ onErrorRef.current?.(fetchError);
1375
+ } finally {
1376
+ if (fetchId === fetchIdRef.current && mounted.current) {
1377
+ setIsLoading(false);
1378
+ }
1379
+ }
1380
+ }, [getInput]);
1381
+ useEffect(() => {
1382
+ if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);
1383
+ debounceTimerRef.current = setTimeout(() => {
1384
+ setDebouncedFilter(filter);
1385
+ }, debounceDelay);
1386
+ return () => {
1387
+ if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);
1388
+ };
1389
+ }, [filter, debounceDelay]);
1390
+ const setPage = useCallback((newPage) => setPageState(newPage), []);
1391
+ const setLimit = useCallback((newLimit) => {
1392
+ setLimitState(newLimit);
1393
+ setPageState(1);
1394
+ }, []);
1395
+ const setSort = useCallback((path, value, append = false) => {
1396
+ setSortsState((prev) => {
1397
+ if (value === null) return prev.filter((s) => s.path !== path);
1398
+ if (!append) return [{ path, value }];
1399
+ const existing = prev.find((s) => s.path === path);
1400
+ if (existing) return prev.map((s) => s.path === path ? { ...s, value } : s);
1401
+ return [...prev, { path, value }];
1402
+ });
1403
+ }, []);
1404
+ const setSorts = useCallback((newSorts) => setSortsState(newSorts), []);
1405
+ const setFilter = useCallback((key, value) => {
1406
+ setFilterState((prev) => ({ ...prev, [key]: value }));
1407
+ setPageState(1);
1408
+ }, []);
1409
+ const setFilters = useCallback((filters2) => {
1410
+ setFilterState((prev) => ({ ...prev, ...filters2 }));
1411
+ setPageState(1);
1412
+ }, []);
1413
+ const clearFilters = useCallback(() => {
1414
+ setFilterState({});
1415
+ setPageState(1);
1416
+ }, []);
1417
+ const setQuery = useCallback((key, value) => {
1418
+ setQueryState((prev) => ({ ...prev, [key]: value }));
1419
+ setPageState(1);
1420
+ }, []);
1421
+ const refresh = useCallback(async () => {
1422
+ await fetchData();
1423
+ }, [fetchData]);
1424
+ const setItemsAction = useCallback((nextItems) => {
1425
+ setItems(nextItems);
1426
+ }, []);
1427
+ const setItemAt = useCallback((index, item) => {
1428
+ setItems((prev) => {
1429
+ if (index < 0 || index >= prev.length) return prev;
1430
+ const next = [...prev];
1431
+ next[index] = item;
1432
+ return next;
1433
+ });
1434
+ }, []);
1435
+ const itemUpdate = useCallback((props2) => {
1436
+ setItems((prev) => {
1437
+ if ("index" in props2) {
1438
+ const { index, data } = props2;
1439
+ if (index < 0 || index >= prev.length) return prev;
1440
+ const next = [...prev];
1441
+ next[index] = { ...next[index], ...data };
1442
+ return next;
1443
+ } else {
1444
+ const { id, data } = props2;
1445
+ const index = prev.findIndex((item) => {
1446
+ const itemWithId = item;
1447
+ return itemWithId.id === id;
1448
+ });
1449
+ if (index === -1) return prev;
1450
+ const next = [...prev];
1451
+ next[index] = { ...next[index], ...data };
1452
+ return next;
1453
+ }
1454
+ });
1455
+ }, []);
1456
+ const deleteItemAt = useCallback((index) => {
1457
+ setItems((prev) => prev.filter((_, i) => i !== index));
1458
+ }, []);
1459
+ const itemDelete = useCallback((props2) => {
1460
+ setItems((prev) => {
1461
+ if ("index" in props2) {
1462
+ const { index } = props2;
1463
+ if (index < 0 || index >= prev.length) return prev;
1464
+ return prev.filter((_, i) => i !== index);
1465
+ } else {
1466
+ const { id } = props2;
1467
+ return prev.filter((item) => {
1468
+ const itemWithId = item;
1469
+ return itemWithId.id !== id;
1470
+ });
1471
+ }
1472
+ });
1473
+ }, []);
1474
+ const itemPush = useCallback((item, position = 1) => {
1475
+ setItems((prev) => position === 0 ? [item, ...prev] : [...prev, item]);
1476
+ }, []);
1477
+ const deleteBulk = useCallback((itemsToDelete) => {
1478
+ if (itemsToDelete.length === 0) return;
1479
+ const toDelete = new Set(itemsToDelete);
1480
+ setItems((prev) => prev.filter((it) => !toDelete.has(it)));
1481
+ }, []);
1482
+ const reset = useCallback(() => {
1483
+ setPageState(initialPage);
1484
+ setLimitState(initialLimit);
1485
+ setSortsState(initialSorts);
1486
+ setFilterState(initialFilter);
1487
+ setDebouncedFilter(initialFilter);
1488
+ setQueryState(initialQuery);
1489
+ }, [initialPage, initialLimit, initialSorts, initialFilter, initialQuery]);
1490
+ useEffect(() => {
1491
+ if (memoryMode !== "search-params" || typeof window === "undefined") return;
1492
+ const urlState = parseUrlParams(window.location.search);
1493
+ if (Object.keys(urlState).length > 0) {
1494
+ if (urlState.page) setPageState(urlState.page);
1495
+ if (urlState.limit) setLimitState(urlState.limit);
1496
+ if (urlState.sorts) setSortsState(urlState.sorts);
1497
+ if (urlState.filter) {
1498
+ setFilterState((prev) => ({ ...prev, ...urlState.filter }));
1499
+ setDebouncedFilter((prev) => ({ ...prev, ...urlState.filter }));
1500
+ }
1501
+ if (urlState.query) setQueryState((prev) => ({ ...prev, ...urlState.query }));
1502
+ }
1503
+ const handlePopState = () => {
1504
+ const newUrlState = parseUrlParams(window.location.search);
1505
+ setPageState(newUrlState.page ?? initialPage);
1506
+ setLimitState(newUrlState.limit ?? initialLimit);
1507
+ setSortsState(newUrlState.sorts ?? initialSorts);
1508
+ setFilterState({ ...initialFilter, ...newUrlState.filter });
1509
+ setDebouncedFilter({ ...initialFilter, ...newUrlState.filter });
1510
+ setQueryState({ ...initialQuery, ...newUrlState.query });
1511
+ };
1512
+ window.addEventListener("popstate", handlePopState);
1513
+ return () => window.removeEventListener("popstate", handlePopState);
1514
+ }, [memoryMode, initialPage, initialLimit, initialSorts, initialFilter, initialQuery]);
1515
+ useEffect(() => {
1516
+ if (memoryMode !== "search-params" || typeof window === "undefined") return;
1517
+ const params = stateToUrlParams({ page, limit, sorts, filter, query });
1518
+ const newSearch = params.toString();
1519
+ const currentSearch = window.location.search.slice(1);
1520
+ if (newSearch !== currentSearch) {
1521
+ const newUrl = newSearch ? `?${newSearch}` : window.location.pathname;
1522
+ window.history.pushState(null, "", newUrl);
1523
+ }
1524
+ }, [page, limit, sorts, filter, query, memoryMode]);
1525
+ useEffect(() => {
1526
+ if (autoFetch) fetchData();
1527
+ }, [page, limit, sorts, debouncedFilter, query, autoFetch, fetchData]);
1528
+ useEffect(() => {
1529
+ mounted.current = true;
1530
+ return () => {
1531
+ mounted.current = false;
1532
+ };
1533
+ }, []);
1534
+ const hasNextPage = page * limit < total;
1535
+ return {
1536
+ page,
1537
+ limit,
1538
+ sorts,
1539
+ filter,
1540
+ filterConfig: filters?.reduce((acc, f) => {
1541
+ if (f.configuration) acc[f.id] = f.configuration;
1542
+ return acc;
1543
+ }, {}),
1544
+ query,
1545
+ items,
1546
+ total,
1547
+ state: { isLoading, error, hasNextPage },
1548
+ actions: {
1549
+ setPage,
1550
+ setLimit,
1551
+ setSort,
1552
+ setSorts,
1553
+ setFilter,
1554
+ setFilters,
1555
+ clearFilters,
1556
+ setQuery,
1557
+ refresh,
1558
+ reset,
1559
+ getInput,
1560
+ setItems: setItemsAction,
1561
+ setItemAt,
1562
+ itemUpdate,
1563
+ deleteItemAt,
1564
+ itemDelete,
1565
+ itemPush,
1566
+ deleteBulk
1567
+ }
1568
+ };
1569
+ };
1570
+ var useSelection = (initialSelected = []) => {
1571
+ const [selectedIds, setSelectedIds] = useState(new Set(initialSelected));
1572
+ const select = useCallback((id) => {
1573
+ setSelectedIds((prev) => new Set(prev).add(id));
1574
+ }, []);
1575
+ const deselect = useCallback((id) => {
1576
+ setSelectedIds((prev) => {
1577
+ const next = new Set(prev);
1578
+ next.delete(id);
1579
+ return next;
1580
+ });
1581
+ }, []);
1582
+ const toggle = useCallback((id) => {
1583
+ setSelectedIds((prev) => {
1584
+ const next = new Set(prev);
1585
+ if (next.has(id)) next.delete(id);
1586
+ else next.add(id);
1587
+ return next;
1588
+ });
1589
+ }, []);
1590
+ const selectAll = useCallback((ids) => {
1591
+ setSelectedIds(new Set(ids));
1592
+ }, []);
1593
+ const deselectAll = useCallback(() => {
1594
+ setSelectedIds(/* @__PURE__ */ new Set());
1595
+ }, []);
1596
+ const toggleAll = useCallback((ids) => {
1597
+ setSelectedIds((prev) => {
1598
+ if (ids.every((id) => prev.has(id))) return /* @__PURE__ */ new Set();
1599
+ return new Set(ids);
1600
+ });
1601
+ }, []);
1602
+ const isSelected = useCallback((id) => selectedIds.has(id), [selectedIds]);
1603
+ const getSelectedArray = useCallback(() => Array.from(selectedIds), [selectedIds]);
1604
+ const isAllSelected = useMemo(() => selectedIds.size > 0, [selectedIds.size]);
1605
+ const isIndeterminate = useMemo(() => false, []);
1606
+ return {
1607
+ selectedIds,
1608
+ isAllSelected,
1609
+ isIndeterminate,
1610
+ select,
1611
+ deselect,
1612
+ toggle,
1613
+ selectAll,
1614
+ deselectAll,
1615
+ toggleAll,
1616
+ isSelected,
1617
+ getSelectedArray
1618
+ };
1619
+ };
1620
+ var useSelectionWithTotal = (totalItems, initialSelected = []) => {
1621
+ const selection = useSelection(initialSelected);
1622
+ const isAllSelected = useMemo(
1623
+ () => totalItems.length > 0 && totalItems.every((id) => selection.selectedIds.has(id)),
1624
+ [totalItems, selection.selectedIds]
1625
+ );
1626
+ const isIndeterminate = useMemo(
1627
+ () => selection.selectedIds.size > 0 && selection.selectedIds.size < totalItems.length,
1628
+ [totalItems.length, selection.selectedIds.size]
1629
+ );
1630
+ const toggleAll = useCallback(() => {
1631
+ if (isAllSelected) selection.deselectAll();
1632
+ else selection.selectAll(totalItems);
1633
+ }, [isAllSelected, selection, totalItems]);
1634
+ return {
1635
+ ...selection,
1636
+ isAllSelected,
1637
+ isIndeterminate,
1638
+ toggleAll
1639
+ };
1640
+ };
1641
+
1642
+ // src/server/utils.ts
1643
+ var calculatePagination = (page, limit, total) => ({
1644
+ currentPage: page,
1645
+ totalPages: Math.ceil(total / limit),
1646
+ totalItems: total,
1647
+ itemsPerPage: limit,
1648
+ hasNextPage: page * limit < total,
1649
+ hasPrevPage: page > 1
1650
+ });
1651
+
1652
+ // src/client/hooks/usePagination.ts
1653
+ var range = (start, end) => Array.from({ length: end - start + 1 }, (_, idx) => idx + start);
1654
+ var usePagination = (props) => {
1655
+ const { page, limit, total, siblingCount = 1 } = props;
1656
+ const paginationInfo = useMemo(() => calculatePagination(page, limit, total), [page, limit, total]);
1657
+ const pages = useMemo(() => {
1658
+ const { totalPages } = paginationInfo;
1659
+ const totalPageNumbers = siblingCount * 2 + 5;
1660
+ if (totalPageNumbers >= totalPages) return range(1, totalPages);
1661
+ const leftSiblingIndex = Math.max(page - siblingCount, 1);
1662
+ const rightSiblingIndex = Math.min(page + siblingCount, totalPages);
1663
+ const shouldShowLeftEllipsis = leftSiblingIndex > 2;
1664
+ const shouldShowRightEllipsis = rightSiblingIndex < totalPages - 1;
1665
+ if (!shouldShowLeftEllipsis && shouldShowRightEllipsis) {
1666
+ const leftRange = range(1, 3 + 2 * siblingCount);
1667
+ return [...leftRange, "ellipsis", totalPages];
1668
+ }
1669
+ if (shouldShowLeftEllipsis && !shouldShowRightEllipsis) {
1670
+ const rightRange = range(totalPages - (3 + 2 * siblingCount) + 1, totalPages);
1671
+ return [1, "ellipsis", ...rightRange];
1672
+ }
1673
+ if (shouldShowLeftEllipsis && shouldShowRightEllipsis) {
1674
+ const middleRange = range(leftSiblingIndex, rightSiblingIndex);
1675
+ return [1, "ellipsis", ...middleRange, "ellipsis", totalPages];
1676
+ }
1677
+ return range(1, totalPages);
1678
+ }, [paginationInfo, page, siblingCount]);
1679
+ return {
1680
+ ...paginationInfo,
1681
+ pages,
1682
+ firstPage: 1,
1683
+ lastPage: paginationInfo.totalPages
1684
+ };
1685
+ };
1686
+ var createDataKitContext = () => {
1687
+ const Context = createContext(null);
1688
+ const DataKitProvider = (props) => {
1689
+ const { value, children } = props;
1690
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
1691
+ };
1692
+ const useDataKitContext = () => {
1693
+ const context = useContext(Context);
1694
+ if (!context) {
1695
+ throw new Error("useDataKitContext must be used within a DataKitProvider");
1696
+ }
1697
+ return context;
1698
+ };
1699
+ return { DataKitProvider, useDataKitContext, Context };
1700
+ };
1701
+ var {
1702
+ DataKitProvider: DefaultDataKitProvider,
1703
+ useDataKitContext: useDefaultDataKitContext,
1704
+ Context: DefaultDataKitContext
1705
+ } = createDataKitContext();
1706
+ function Table({ className, ...props }) {
1707
+ return /* @__PURE__ */ jsx("div", { "data-slot": "table-container", className: "ndk:relative ndk:w-full ndk:overflow-x-auto", children: /* @__PURE__ */ jsx(
1708
+ "table",
1709
+ {
1710
+ "data-slot": "table",
1711
+ className: cn("ndk:w-full ndk:caption-bottom ndk:text-sm", className),
1712
+ ...props
1713
+ }
1714
+ ) });
1715
+ }
1716
+ function TableHeader({ className, ...props }) {
1717
+ return /* @__PURE__ */ jsx(
1718
+ "thead",
1719
+ {
1720
+ "data-slot": "table-header",
1721
+ className: cn("ndk:[&_tr]:border-b", className),
1722
+ ...props
1723
+ }
1724
+ );
1725
+ }
1726
+ function TableBody({ className, ...props }) {
1727
+ return /* @__PURE__ */ jsx(
1728
+ "tbody",
1729
+ {
1730
+ "data-slot": "table-body",
1731
+ className: cn("ndk:[&_tr:last-child]:border-0", className),
1732
+ ...props
1733
+ }
1734
+ );
1735
+ }
1736
+ function TableRow({ className, ...props }) {
1737
+ return /* @__PURE__ */ jsx(
1738
+ "tr",
1739
+ {
1740
+ "data-slot": "table-row",
1741
+ className: cn(
1742
+ "ndk:hover:bg-gray-50 ndk:dark:hover:bg-gray-900 ndk:data-[state=selected]:bg-gray-50 ndk:dark:data-[state=selected]:bg-gray-900 ndk:border-b ndk:border-gray-100 ndk:dark:border-gray-800 ndk:transition-colors",
1743
+ className
1744
+ ),
1745
+ ...props
1746
+ }
1747
+ );
1748
+ }
1749
+ function TableHead({ className, ...props }) {
1750
+ return /* @__PURE__ */ jsx(
1751
+ "th",
1752
+ {
1753
+ "data-slot": "table-head",
1754
+ className: cn(
1755
+ "ndk:text-gray-900 ndk:dark:text-gray-100 ndk:h-10 ndk:px-2 ndk:text-left ndk:align-middle ndk:font-medium ndk:whitespace-nowrap ndk:[&:has([role=checkbox])]:pr-0 ndk:[&>[role=checkbox]]:translate-y-[2px]",
1756
+ className
1757
+ ),
1758
+ ...props
1759
+ }
1760
+ );
1761
+ }
1762
+ function TableCell({ className, ...props }) {
1763
+ return /* @__PURE__ */ jsx(
1764
+ "td",
1765
+ {
1766
+ "data-slot": "table-cell",
1767
+ className: cn(
1768
+ "ndk:p-2 ndk:align-middle ndk:whitespace-nowrap ndk:[&:has([role=checkbox])]:pr-0 ndk:[&>[role=checkbox]]:translate-y-[2px]",
1769
+ className
1770
+ ),
1771
+ ...props
1772
+ }
1773
+ );
1774
+ }
1775
+ function Checkbox({
1776
+ className,
1777
+ ...props
1778
+ }) {
1779
+ return /* @__PURE__ */ jsx(
1780
+ CheckboxPrimitive.Root,
1781
+ {
1782
+ "data-slot": "checkbox",
1783
+ className: cn(
1784
+ "ndk:peer ndk:border-gray-200 ndk:bg-white ndk:text-gray-900 ndk:dark:border-gray-800 ndk:dark:bg-gray-950 ndk:dark:text-gray-100 ndk:data-[state=checked]:bg-gray-900 ndk:data-[state=checked]:text-white ndk:dark:data-[state=checked]:bg-gray-100 ndk:dark:data-[state=checked]:text-gray-900 ndk:data-[state=checked]:border-gray-900 ndk:dark:data-[state=checked]:border-gray-100 ndk:focus-visible:border-gray-900 ndk:dark:focus-visible:border-gray-200 ndk:focus-visible:ring-black/20 ndk:dark:focus-visible:ring-white/20 ndk:aria-invalid:ring-red-500/20 ndk:dark:aria-invalid:ring-red-500/30 ndk:aria-invalid:border-red-500 ndk:size-4 ndk:shrink-0 ndk:rounded-[4px] ndk:border ndk:shadow-xs ndk:transition-shadow ndk:outline-none ndk:focus-visible:ring-[3px] ndk:disabled:cursor-not-allowed ndk:disabled:opacity-50",
1785
+ className
1786
+ ),
1787
+ ...props,
1788
+ children: /* @__PURE__ */ jsx(
1789
+ CheckboxPrimitive.Indicator,
1790
+ {
1791
+ "data-slot": "checkbox-indicator",
1792
+ className: "ndk:grid ndk:place-content-center ndk:text-current ndk:transition-none",
1793
+ children: /* @__PURE__ */ jsx(CheckIcon, { className: "ndk:size-3.5" })
1794
+ }
1795
+ )
1796
+ }
1797
+ );
1798
+ }
1799
+ function Popover(props) {
1800
+ return /* @__PURE__ */ jsx(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
1801
+ }
1802
+ function PopoverTrigger(props) {
1803
+ return /* @__PURE__ */ jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
1804
+ }
1805
+ function PopoverContent({
1806
+ className,
1807
+ align = "center",
1808
+ sideOffset = 4,
1809
+ container,
1810
+ ...props
1811
+ }) {
1812
+ return /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsx(
1813
+ PopoverPrimitive.Content,
1814
+ {
1815
+ "data-slot": "popover-content",
1816
+ align,
1817
+ sideOffset,
1818
+ className: cn(
1819
+ "ndk:bg-white ndk:text-gray-900 ndk:dark:bg-gray-950 ndk:dark:text-gray-100 ndk:data-[state=open]:animate-in ndk:data-[state=closed]:animate-out ndk:data-[state=closed]:fade-out-0 ndk:data-[state=open]:fade-in-0 ndk:data-[state=closed]:zoom-out-95 ndk:data-[state=open]:zoom-in-95 ndk:data-[side=bottom]:slide-in-from-top-2 ndk:data-[side=left]:slide-in-from-right-2 ndk:data-[side=right]:slide-in-from-left-2 ndk:data-[side=top]:slide-in-from-bottom-2 ndk:z-50 ndk:w-72 ndk:origin-(--radix-popover-content-transform-origin) ndk:rounded-md ndk:border ndk:border-gray-200 ndk:dark:border-gray-800 ndk:p-4 ndk:shadow-md ndk:outline-hidden",
1820
+ className
1821
+ ),
1822
+ ...props
1823
+ }
1824
+ ) });
1825
+ }
1826
+ function DropdownMenu({
1827
+ ...props
1828
+ }) {
1829
+ return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
1830
+ }
1831
+ function DropdownMenuTrigger({
1832
+ ...props
1833
+ }) {
1834
+ return /* @__PURE__ */ jsx(
1835
+ DropdownMenuPrimitive.Trigger,
1836
+ {
1837
+ "data-slot": "dropdown-menu-trigger",
1838
+ ...props
1839
+ }
1840
+ );
1841
+ }
1842
+ function DropdownMenuContent({
1843
+ className,
1844
+ sideOffset = 4,
1845
+ container,
1846
+ ...props
1847
+ }) {
1848
+ return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsx(
1849
+ DropdownMenuPrimitive.Content,
1850
+ {
1851
+ "data-slot": "dropdown-menu-content",
1852
+ sideOffset,
1853
+ className: cn(
1854
+ "ndk:bg-white ndk:text-gray-900 ndk:dark:bg-gray-950 ndk:dark:text-gray-100 ndk:data-[state=open]:animate-in ndk:data-[state=closed]:animate-out ndk:data-[state=closed]:fade-out-0 ndk:data-[state=open]:fade-in-0 ndk:data-[state=closed]:zoom-out-95 ndk:data-[state=open]:zoom-in-95 ndk:data-[side=bottom]:slide-in-from-top-2 ndk:data-[side=left]:slide-in-from-right-2 ndk:data-[side=right]:slide-in-from-left-2 ndk:data-[side=top]:slide-in-from-bottom-2 ndk:z-50 ndk:max-h-(--radix-dropdown-menu-content-available-height) ndk:min-w-[8rem] ndk:origin-(--radix-dropdown-menu-content-transform-origin) ndk:overflow-x-hidden ndk:overflow-y-auto ndk:rounded-md ndk:border ndk:border-gray-200 ndk:dark:border-gray-800 ndk:p-1 ndk:shadow-md",
1855
+ className
1856
+ ),
1857
+ ...props
1858
+ }
1859
+ ) });
1860
+ }
1861
+ function DropdownMenuItem({
1862
+ className,
1863
+ inset,
1864
+ variant = "default",
1865
+ ...props
1866
+ }) {
1867
+ return /* @__PURE__ */ jsx(
1868
+ DropdownMenuPrimitive.Item,
1869
+ {
1870
+ "data-slot": "dropdown-menu-item",
1871
+ "data-inset": inset,
1872
+ "data-variant": variant,
1873
+ className: cn(
1874
+ "ndk:focus:bg-gray-50 ndk:dark:focus:bg-gray-900 ndk:focus:text-gray-900 ndk:dark:focus:text-gray-100 ndk:data-[variant=destructive]:text-red-600 ndk:dark:data-[variant=destructive]:text-red-500 ndk:data-[variant=destructive]:focus:bg-red-500/10 ndk:dark:data-[variant=destructive]:focus:bg-red-500/15 ndk:data-[variant=destructive]:focus:text-red-700 ndk:dark:data-[variant=destructive]:focus:text-red-400 ndk:data-[variant=destructive]:*:[svg]:!text-red-600 ndk:dark:data-[variant=destructive]:*:[svg]:!text-red-500 ndk:[&_svg:not([class*='text-'])]:text-gray-500 ndk:dark:[&_svg:not([class*='text-'])]:text-gray-400 ndk:relative ndk:flex ndk:cursor-default ndk:items-center ndk:gap-2 ndk:rounded-sm ndk:px-2 ndk:py-1.5 ndk:text-sm ndk:outline-hidden ndk:select-none ndk:data-[disabled]:pointer-events-none ndk:data-[disabled]:opacity-50 ndk:data-[inset]:pl-8 ndk:[&_svg]:pointer-events-none ndk:[&_svg]:shrink-0 ndk:[&_svg:not([class*='size-'])]:size-4",
1875
+ className
1876
+ ),
1877
+ ...props
1878
+ }
1879
+ );
1880
+ }
1881
+ function DropdownMenuSeparator({
1882
+ className,
1883
+ ...props
1884
+ }) {
1885
+ return /* @__PURE__ */ jsx(
1886
+ DropdownMenuPrimitive.Separator,
1887
+ {
1888
+ "data-slot": "dropdown-menu-separator",
1889
+ className: cn("ndk:bg-gray-100 ndk:dark:bg-gray-900 ndk:-mx-1 ndk:my-1 ndk:h-px", className),
1890
+ ...props
1891
+ }
1892
+ );
1893
+ }
1894
+ var buttonVariants = cva(
1895
+ "ndk:inline-flex ndk:items-center ndk:justify-center ndk:gap-2 ndk:whitespace-nowrap ndk:rounded-md ndk:text-sm ndk:font-medium ndk:transition-all ndk:disabled:pointer-events-none ndk:disabled:opacity-50 ndk:[&_svg]:pointer-events-none ndk:[&_svg:not([class*='size-'])]:size-4 ndk:shrink-0 ndk:[&_svg]:shrink-0 ndk:outline-none ndk:focus-visible:ring-black/20 ndk:dark:focus-visible:ring-white/20 ndk:focus-visible:ring-[3px] ndk:aria-invalid:ring-red-500/20 ndk:dark:aria-invalid:ring-red-500/30 ndk:aria-invalid:border-red-500",
1896
+ {
1897
+ variants: {
1898
+ variant: {
1899
+ default: "ndk:bg-gray-900 ndk:text-white ndk:hover:bg-gray-800 ndk:dark:bg-gray-100 ndk:dark:text-gray-900 ndk:dark:hover:bg-gray-200",
1900
+ destructive: "ndk:bg-red-600 ndk:text-white ndk:hover:bg-red-700 ndk:dark:bg-red-600 ndk:dark:hover:bg-red-500",
1901
+ outline: "ndk:border ndk:border-gray-200 ndk:bg-white ndk:text-gray-900 ndk:shadow-xs ndk:hover:bg-gray-50 ndk:dark:border-gray-800 ndk:dark:bg-gray-950 ndk:dark:text-gray-100 ndk:dark:hover:bg-gray-900",
1902
+ secondary: "ndk:bg-gray-100 ndk:text-gray-900 ndk:hover:bg-gray-200 ndk:dark:bg-gray-900 ndk:dark:text-gray-100 ndk:dark:hover:bg-gray-800",
1903
+ ghost: "ndk:hover:bg-gray-100 ndk:hover:text-gray-900 ndk:dark:hover:bg-gray-900 ndk:dark:hover:text-gray-100",
1904
+ link: "ndk:text-gray-900 ndk:underline-offset-4 ndk:hover:underline ndk:dark:text-gray-100"
1905
+ },
1906
+ size: {
1907
+ default: "ndk:h-9 ndk:px-4 ndk:py-2 ndk:has-[>svg]:px-3",
1908
+ sm: "ndk:h-8 ndk:rounded-md ndk:gap-1.5 ndk:px-3 ndk:has-[>svg]:px-2.5",
1909
+ lg: "ndk:h-10 ndk:rounded-md ndk:px-6 ndk:has-[>svg]:px-4",
1910
+ icon: "ndk:size-9",
1911
+ "icon-sm": "ndk:size-8",
1912
+ "icon-lg": "ndk:size-10"
1913
+ }
1914
+ },
1915
+ defaultVariants: {
1916
+ variant: "default",
1917
+ size: "default"
1918
+ }
1919
+ }
1920
+ );
1921
+ var Button = React2.forwardRef(function Button2({
1922
+ className,
1923
+ variant = "default",
1924
+ size = "default",
1925
+ asChild = false,
1926
+ ...props
1927
+ }, ref) {
1928
+ const Comp = asChild ? Slot : "button";
1929
+ return /* @__PURE__ */ jsx(
1930
+ Comp,
1931
+ {
1932
+ ref,
1933
+ "data-slot": "button",
1934
+ "data-variant": variant,
1935
+ "data-size": size,
1936
+ className: cn(buttonVariants({ variant, size, className })),
1937
+ ...props
1938
+ }
1939
+ );
1940
+ });
1941
+ Button.displayName = "Button";
1942
+ function Pagination({ className, ...props }) {
1943
+ return /* @__PURE__ */ jsx(
1944
+ "nav",
1945
+ {
1946
+ role: "navigation",
1947
+ "aria-label": "pagination",
1948
+ "data-slot": "pagination",
1949
+ className: cn("ndk:flex", className),
1950
+ ...props
1951
+ }
1952
+ );
1953
+ }
1954
+ function PaginationContent({
1955
+ className,
1956
+ ...props
1957
+ }) {
1958
+ return /* @__PURE__ */ jsx(
1959
+ "ul",
1960
+ {
1961
+ "data-slot": "pagination-content",
1962
+ className: cn("ndk:flex ndk:flex-row ndk:items-center ndk:gap-1", className),
1963
+ ...props
1964
+ }
1965
+ );
1966
+ }
1967
+ function PaginationItem({ ...props }) {
1968
+ return /* @__PURE__ */ jsx("li", { "data-slot": "pagination-item", ...props });
1969
+ }
1970
+ function PaginationLink({
1971
+ className,
1972
+ isActive,
1973
+ size = "icon",
1974
+ type = "button",
1975
+ ...props
1976
+ }) {
1977
+ return /* @__PURE__ */ jsx(
1978
+ "button",
1979
+ {
1980
+ "aria-current": isActive ? "page" : void 0,
1981
+ "data-slot": "pagination-link",
1982
+ "data-active": isActive ? "true" : "false",
1983
+ className: cn(
1984
+ buttonVariants({
1985
+ variant: isActive ? "outline" : "ghost",
1986
+ size
1987
+ }),
1988
+ className
1989
+ ),
1990
+ type,
1991
+ ...props
1992
+ }
1993
+ );
1994
+ }
1995
+ function PaginationPrevious({
1996
+ className,
1997
+ ...props
1998
+ }) {
1999
+ return /* @__PURE__ */ jsxs(
2000
+ PaginationLink,
2001
+ {
2002
+ "aria-label": "Go to previous page",
2003
+ size: "default",
2004
+ className: cn("ndk:gap-1 ndk:px-2.5 ndk:sm:pl-2.5", className),
2005
+ ...props,
2006
+ children: [
2007
+ /* @__PURE__ */ jsx(ChevronLeft, { className: "ndk:size-4", "aria-hidden": "true" }),
2008
+ /* @__PURE__ */ jsx("span", { className: "ndk:hidden ndk:sm:block", children: "Previous" })
2009
+ ]
2010
+ }
2011
+ );
2012
+ }
2013
+ function PaginationNext({
2014
+ className,
2015
+ ...props
2016
+ }) {
2017
+ return /* @__PURE__ */ jsxs(
2018
+ PaginationLink,
2019
+ {
2020
+ "aria-label": "Go to next page",
2021
+ size: "default",
2022
+ className: cn("ndk:gap-1 ndk:px-2.5 ndk:sm:pr-2.5", className),
2023
+ ...props,
2024
+ children: [
2025
+ /* @__PURE__ */ jsx("span", { className: "ndk:hidden ndk:sm:block", children: "Next" }),
2026
+ /* @__PURE__ */ jsx(ChevronRight, { className: "ndk:size-4", "aria-hidden": "true" })
2027
+ ]
2028
+ }
2029
+ );
2030
+ }
2031
+ function PaginationEllipsis({
2032
+ className,
2033
+ ...props
2034
+ }) {
2035
+ return /* @__PURE__ */ jsxs(
2036
+ "span",
2037
+ {
2038
+ "aria-hidden": "true",
2039
+ "data-slot": "pagination-ellipsis",
2040
+ className: cn("ndk:flex ndk:size-9 ndk:items-center ndk:justify-center", className),
2041
+ ...props,
2042
+ children: [
2043
+ /* @__PURE__ */ jsx(MoreHorizontal, { className: "ndk:size-4", "aria-hidden": "true" }),
2044
+ /* @__PURE__ */ jsx("span", { className: "ndk:sr-only", children: "More pages" })
2045
+ ]
2046
+ }
2047
+ );
2048
+ }
2049
+ function Select({
2050
+ ...props
2051
+ }) {
2052
+ return /* @__PURE__ */ jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
2053
+ }
2054
+ function SelectValue({
2055
+ ...props
2056
+ }) {
2057
+ return /* @__PURE__ */ jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
2058
+ }
2059
+ function SelectTrigger({
2060
+ className,
2061
+ size = "default",
2062
+ children,
2063
+ ...props
2064
+ }) {
2065
+ return /* @__PURE__ */ jsxs(
2066
+ SelectPrimitive.Trigger,
2067
+ {
2068
+ "data-slot": "select-trigger",
2069
+ "data-size": size,
2070
+ className: cn(
2071
+ "ndk:border-gray-200 ndk:dark:border-gray-800 ndk:data-[placeholder]:text-gray-500 ndk:dark:data-[placeholder]:text-gray-400 ndk:[&_svg:not([class*='text-'])]:text-gray-500 ndk:dark:[&_svg:not([class*='text-'])]:text-gray-400 ndk:focus-visible:border-gray-900 ndk:dark:focus-visible:border-gray-200 ndk:focus-visible:ring-black/20 ndk:dark:focus-visible:ring-white/20 ndk:aria-invalid:ring-red-500/20 ndk:dark:aria-invalid:ring-red-500/30 ndk:aria-invalid:border-red-500 ndk:bg-white ndk:dark:bg-gray-950 ndk:hover:bg-gray-50 ndk:dark:hover:bg-gray-900 ndk:flex ndk:w-fit ndk:items-center ndk:justify-between ndk:gap-2 ndk:rounded-md ndk:border ndk:px-3 ndk:py-2 ndk:text-sm ndk:whitespace-nowrap ndk:shadow-xs ndk:transition-[color,box-shadow] ndk:outline-none ndk:focus-visible:ring-[3px] ndk:disabled:cursor-not-allowed ndk:disabled:opacity-50 ndk:data-[size=default]:h-9 ndk:data-[size=sm]:h-8 ndk:*:data-[slot=select-value]:line-clamp-1 ndk:*:data-[slot=select-value]:flex ndk:*:data-[slot=select-value]:items-center ndk:*:data-[slot=select-value]:gap-2 ndk:[&_svg]:pointer-events-none ndk:[&_svg]:shrink-0 ndk:[&_svg:not([class*='size-'])]:size-4",
2072
+ className
2073
+ ),
2074
+ ...props,
2075
+ children: [
2076
+ children,
2077
+ /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "ndk:size-4 ndk:opacity-50" }) })
2078
+ ]
2079
+ }
2080
+ );
2081
+ }
2082
+ function SelectContent({
2083
+ className,
2084
+ children,
2085
+ position = "item-aligned",
2086
+ align = "center",
2087
+ container,
2088
+ ...props
2089
+ }) {
2090
+ return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsxs(
2091
+ SelectPrimitive.Content,
2092
+ {
2093
+ "data-slot": "select-content",
2094
+ className: cn(
2095
+ "ndk:bg-white ndk:text-gray-900 ndk:dark:bg-gray-950 ndk:dark:text-gray-100 ndk:data-[state=open]:animate-in ndk:data-[state=closed]:animate-out ndk:data-[state=closed]:fade-out-0 ndk:data-[state=open]:fade-in-0 ndk:data-[state=closed]:zoom-out-95 ndk:data-[state=open]:zoom-in-95 ndk:data-[side=bottom]:slide-in-from-top-2 ndk:data-[side=left]:slide-in-from-right-2 ndk:data-[side=right]:slide-in-from-left-2 ndk:data-[side=top]:slide-in-from-bottom-2 ndk:relative ndk:z-50 ndk:max-h-(--radix-select-content-available-height) ndk:min-w-[8rem] ndk:origin-(--radix-select-content-transform-origin) ndk:overflow-x-hidden ndk:overflow-y-auto ndk:rounded-md ndk:border ndk:border-gray-200 ndk:dark:border-gray-800 ndk:shadow-md",
2096
+ position === "popper" && "ndk:data-[side=bottom]:translate-y-1 ndk:data-[side=left]:-translate-x-1 ndk:data-[side=right]:translate-x-1 ndk:data-[side=top]:-translate-y-1",
2097
+ className
2098
+ ),
2099
+ position,
2100
+ align,
2101
+ ...props,
2102
+ children: [
2103
+ /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
2104
+ /* @__PURE__ */ jsx(
2105
+ SelectPrimitive.Viewport,
2106
+ {
2107
+ className: cn(
2108
+ "ndk:p-1",
2109
+ position === "popper" && "ndk:h-[var(--radix-select-trigger-height)] ndk:w-full ndk:min-w-[var(--radix-select-trigger-width)] ndk:scroll-my-1"
2110
+ ),
2111
+ children
2112
+ }
2113
+ ),
2114
+ /* @__PURE__ */ jsx(SelectScrollDownButton, {})
2115
+ ]
2116
+ }
2117
+ ) });
2118
+ }
2119
+ function SelectItem({
2120
+ className,
2121
+ children,
2122
+ ...props
2123
+ }) {
2124
+ return /* @__PURE__ */ jsxs(
2125
+ SelectPrimitive.Item,
2126
+ {
2127
+ "data-slot": "select-item",
2128
+ className: cn(
2129
+ "ndk:focus:bg-gray-50 ndk:dark:focus:bg-gray-900 ndk:focus:text-gray-900 ndk:dark:focus:text-gray-100 ndk:[&_svg:not([class*='text-'])]:text-gray-500 ndk:dark:[&_svg:not([class*='text-'])]:text-gray-400 ndk:relative ndk:flex ndk:w-full ndk:cursor-default ndk:items-center ndk:gap-2 ndk:rounded-sm ndk:py-1.5 ndk:pr-8 ndk:pl-2 ndk:text-sm ndk:outline-hidden ndk:select-none ndk:data-[disabled]:pointer-events-none ndk:data-[disabled]:opacity-50 ndk:[&_svg]:pointer-events-none ndk:[&_svg]:shrink-0 ndk:[&_svg:not([class*='size-'])]:size-4 ndk:*:[span]:last:flex ndk:*:[span]:last:items-center ndk:*:[span]:last:gap-2",
2130
+ className
2131
+ ),
2132
+ ...props,
2133
+ children: [
2134
+ /* @__PURE__ */ jsx(
2135
+ "span",
2136
+ {
2137
+ "data-slot": "select-item-indicator",
2138
+ className: "ndk:absolute ndk:right-2 ndk:flex ndk:size-3.5 ndk:items-center ndk:justify-center",
2139
+ children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "ndk:size-4" }) })
2140
+ }
2141
+ ),
2142
+ /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
2143
+ ]
2144
+ }
2145
+ );
2146
+ }
2147
+ function SelectScrollUpButton({
2148
+ className,
2149
+ ...props
2150
+ }) {
2151
+ return /* @__PURE__ */ jsx(
2152
+ SelectPrimitive.ScrollUpButton,
2153
+ {
2154
+ "data-slot": "select-scroll-up-button",
2155
+ className: cn(
2156
+ "ndk:flex ndk:cursor-default ndk:items-center ndk:justify-center ndk:py-1",
2157
+ className
2158
+ ),
2159
+ ...props,
2160
+ children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "ndk:size-4" })
2161
+ }
2162
+ );
2163
+ }
2164
+ function SelectScrollDownButton({
2165
+ className,
2166
+ ...props
2167
+ }) {
2168
+ return /* @__PURE__ */ jsx(
2169
+ SelectPrimitive.ScrollDownButton,
2170
+ {
2171
+ "data-slot": "select-scroll-down-button",
2172
+ className: cn(
2173
+ "ndk:flex ndk:cursor-default ndk:items-center ndk:justify-center ndk:py-1",
2174
+ className
2175
+ ),
2176
+ ...props,
2177
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "ndk:size-4" })
2178
+ }
2179
+ );
2180
+ }
2181
+ var DataKitRoot = (props) => {
2182
+ const {
2183
+ action,
2184
+ query,
2185
+ table: columns,
2186
+ filters = [],
2187
+ selectable,
2188
+ state: initialState,
2189
+ limit: limitConfig,
2190
+ className,
2191
+ autoFetch = true,
2192
+ debounce: debounce2 = 300,
2193
+ bordered,
2194
+ refetchInterval,
2195
+ memory: memoryMode = "memory",
2196
+ pagination: paginationType = "NUMBER",
2197
+ controller,
2198
+ sorts: defaultSorts = []
2199
+ } = props;
2200
+ const tableRef = useRef(null);
2201
+ const intervalRef = useRef(null);
2202
+ const [isVisible, setIsVisible] = useState(false);
2203
+ const [isFilterOpen, setIsFilterOpen] = useState(false);
2204
+ const [actionLoading, setActionLoading] = useState(null);
2205
+ const [actionsMenuOpen, setActionsMenuOpen] = useState(false);
2206
+ const [rowStates, setRowStates] = useState(/* @__PURE__ */ new Map());
2207
+ const [lastSelectedIndex, setLastSelectedIndex] = useState(null);
2208
+ const overlayContainer = tableRef.current;
2209
+ const getRowState = useCallback((rowId) => {
2210
+ return rowStates.get(rowId) ?? initialState;
2211
+ }, [rowStates, initialState]);
2212
+ const setRowState = useCallback((rowId, updater) => {
2213
+ setRowStates((prev) => {
2214
+ const current = prev.get(rowId) ?? initialState;
2215
+ const newState = typeof updater === "function" ? updater(current) : updater;
2216
+ const newMap = new Map(prev);
2217
+ newMap.set(rowId, newState);
2218
+ return newMap;
2219
+ });
2220
+ }, [initialState]);
2221
+ const dataKit = useDataKit({
2222
+ action,
2223
+ filters,
2224
+ autoFetch,
2225
+ debounce: debounce2,
2226
+ memory: memoryMode,
2227
+ initial: {
2228
+ limit: limitConfig?.default ?? 10,
2229
+ query: query ?? {},
2230
+ sorts: (() => {
2231
+ const columnSorts = columns.reduce((acc, col) => {
2232
+ if (col.sortable && col.sortable.default !== 0) {
2233
+ acc.push({ path: col.sortable.path, value: col.sortable.default });
2234
+ }
2235
+ return acc;
2236
+ }, []);
2237
+ const columnPaths = new Set(columnSorts.map((s) => s.path));
2238
+ const additionalSorts = defaultSorts.filter((s) => !columnPaths.has(s.path));
2239
+ return [...columnSorts, ...additionalSorts];
2240
+ })(),
2241
+ filter: filters.reduce((acc, f) => {
2242
+ if (f.defaultValue !== void 0) acc[f.id] = f.defaultValue;
2243
+ return acc;
2244
+ }, {})
2245
+ }
2246
+ });
2247
+ const pagination = usePagination({ page: dataKit.page, limit: dataKit.limit, total: dataKit.total, siblingCount: 1 });
2248
+ const selection = useSelectionWithTotal(dataKit.items.map((item) => item.id));
2249
+ const selectedCount = selection.selectedIds.size;
2250
+ const colSpan = columns.length + (selectable?.enabled ? 1 : 0);
2251
+ const limitOptions = React2__default.useMemo(() => {
2252
+ const standardOptions = [10, 25, 50, 100];
2253
+ const currentLimit = dataKit.limit;
2254
+ if (!standardOptions.includes(currentLimit)) {
2255
+ return [...standardOptions, currentLimit].sort((a, b) => a - b);
2256
+ }
2257
+ return standardOptions;
2258
+ }, [dataKit.limit]);
2259
+ const handleSort = useCallback((path) => {
2260
+ const currentSort = dataKit.sorts.find((s) => s.path === path);
2261
+ const nextValue = currentSort?.value === 1 ? -1 : currentSort?.value === -1 ? null : 1;
2262
+ dataKit.actions.setSort(path, nextValue);
2263
+ }, [dataKit.sorts, dataKit.actions]);
2264
+ const handleSelectionAction = useCallback(async (actionKey) => {
2265
+ const action2 = selectable?.actions?.[actionKey];
2266
+ if (!action2 || action2.type === "SEPARATOR" || actionLoading) return;
2267
+ setActionLoading(actionKey);
2268
+ setActionsMenuOpen(false);
2269
+ try {
2270
+ const selectedItems = dataKit.items.filter((item) => selection.isSelected(item.id));
2271
+ const result = await action2.function(selectedItems);
2272
+ if (result[0]) {
2273
+ const data = result[1];
2274
+ if (data.deselectAll) selection.deselectAll();
2275
+ await dataKit.actions.refresh();
2276
+ }
2277
+ } catch (error) {
2278
+ console.error("Selection action failed:", error);
2279
+ } finally {
2280
+ setActionLoading(null);
2281
+ }
2282
+ }, [selectable?.actions, actionLoading, dataKit.items, selection, dataKit.actions]);
2283
+ const handleResetFilters = useCallback(() => {
2284
+ filters.forEach((f) => {
2285
+ dataKit.actions.setFilter(f.id, f.defaultValue ?? (f.type === "BOOLEAN" ? false : ""));
2286
+ });
2287
+ }, [filters, dataKit.actions]);
2288
+ const getSortFor = useCallback((path) => dataKit.sorts.find((s) => s.path === path)?.value ?? null, [dataKit.sorts]);
2289
+ const handleRowSelection = useCallback((rowIndex, event) => {
2290
+ if (event.shiftKey && lastSelectedIndex !== null) {
2291
+ const start = Math.min(lastSelectedIndex, rowIndex);
2292
+ const end = Math.max(lastSelectedIndex, rowIndex);
2293
+ for (let i = start; i <= end; i++) {
2294
+ const item = dataKit.items[i];
2295
+ if (item && item.id !== void 0 && !selection.isSelected(item.id)) {
2296
+ selection.select(item.id);
2297
+ }
2298
+ }
2299
+ } else {
2300
+ const item = dataKit.items[rowIndex];
2301
+ if (item && item.id !== void 0) {
2302
+ selection.toggle(item.id);
2303
+ }
2304
+ }
2305
+ setLastSelectedIndex(rowIndex);
2306
+ }, [lastSelectedIndex, dataKit.items, selection]);
2307
+ useEffect(() => {
2308
+ if (controller) {
2309
+ controller.current = {
2310
+ itemPush: dataKit.actions.itemPush,
2311
+ itemUpdate: dataKit.actions.itemUpdate,
2312
+ itemDelete: dataKit.actions.itemDelete,
2313
+ refetchData: dataKit.actions.refresh,
2314
+ deleteBulk: dataKit.actions.deleteBulk,
2315
+ getSelectedItems: () => dataKit.items.filter((item) => selection.isSelected(item.id)),
2316
+ clearSelection: () => selection.deselectAll()
2317
+ };
2318
+ }
2319
+ }, [controller, dataKit.actions, dataKit.items, selection]);
2320
+ useEffect(() => {
2321
+ if (!tableRef.current || !refetchInterval) return;
2322
+ const observer = new IntersectionObserver(
2323
+ (entries) => entries[0] && setIsVisible(entries[0].isIntersecting),
2324
+ { threshold: 0.1 }
2325
+ );
2326
+ const currentRef = tableRef.current;
2327
+ observer.observe(currentRef);
2328
+ return () => {
2329
+ if (currentRef) observer.unobserve(currentRef);
2330
+ };
2331
+ }, [refetchInterval]);
2332
+ useEffect(() => {
2333
+ if (intervalRef.current) {
2334
+ clearInterval(intervalRef.current);
2335
+ intervalRef.current = null;
2336
+ }
2337
+ if (refetchInterval && isVisible) {
2338
+ intervalRef.current = setInterval(dataKit.actions.refresh, refetchInterval);
2339
+ }
2340
+ return () => {
2341
+ if (intervalRef.current) clearInterval(intervalRef.current);
2342
+ };
2343
+ }, [refetchInterval, isVisible, dataKit.actions]);
2344
+ useEffect(() => {
2345
+ selection.deselectAll();
2346
+ }, [dataKit.items.length]);
2347
+ return /* @__PURE__ */ jsxs("div", { ref: tableRef, className: `ndk:space-y-3 ${className ?? ""}`, children: [
2348
+ /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:items-center ndk:justify-between ndk:gap-2", children: /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:items-center ndk:gap-2", children: filters.length > 0 && /* @__PURE__ */ jsxs(Popover, { open: isFilterOpen, onOpenChange: setIsFilterOpen, children: [
2349
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
2350
+ /* @__PURE__ */ jsx(Filter, { className: "ndk:mr-1.5 ndk:size-4" }),
2351
+ "Filters"
2352
+ ] }) }),
2353
+ /* @__PURE__ */ jsxs(PopoverContent, { align: "start", className: "ndk:w-80", container: overlayContainer, children: [
2354
+ /* @__PURE__ */ jsx("div", { className: "ndk:grid ndk:gap-3", children: filters.map((f) => /* @__PURE__ */ jsxs("div", { className: "ndk:grid ndk:gap-1.5", children: [
2355
+ /* @__PURE__ */ jsx("label", { className: "ndk:text-sm ndk:font-medium", children: f.label }),
2356
+ f.type === "TEXT" && /* @__PURE__ */ jsx(
2357
+ "input",
2358
+ {
2359
+ type: "text",
2360
+ className: "ndk:h-9 ndk:w-full ndk:rounded-md ndk:border ndk:bg-transparent ndk:px-3 ndk:text-sm ndk:outline-none ndk:focus:ring-2 ndk:focus:ring-ring",
2361
+ placeholder: f.placeholder,
2362
+ value: dataKit.filter[f.id] ?? "",
2363
+ onChange: (e) => dataKit.actions.setFilter(f.id, e.target.value)
2364
+ }
2365
+ ),
2366
+ f.type === "SELECT" && /* @__PURE__ */ jsxs(
2367
+ Select,
2368
+ {
2369
+ value: String(dataKit.filter[f.id] || "__all__"),
2370
+ onValueChange: (v) => dataKit.actions.setFilter(f.id, v === "__all__" ? "" : v),
2371
+ children: [
2372
+ /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2373
+ /* @__PURE__ */ jsxs(SelectContent, { container: overlayContainer, children: [
2374
+ /* @__PURE__ */ jsx(SelectItem, { value: "__all__", children: "All" }),
2375
+ f.dataset?.map((d) => /* @__PURE__ */ jsx(SelectItem, { value: d.id, children: d.label }, d.id))
2376
+ ] })
2377
+ ]
2378
+ }
2379
+ ),
2380
+ f.type === "BOOLEAN" && /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:items-center ndk:justify-between", children: /* @__PURE__ */ jsx(
2381
+ Checkbox,
2382
+ {
2383
+ checked: Boolean(dataKit.filter[f.id]),
2384
+ onCheckedChange: (c) => dataKit.actions.setFilter(f.id, c)
2385
+ }
2386
+ ) })
2387
+ ] }, f.id)) }),
2388
+ /* @__PURE__ */ jsxs("div", { className: "ndk:mt-4 ndk:flex ndk:justify-between ndk:border-t ndk:pt-3", children: [
2389
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: handleResetFilters, children: "Reset" }),
2390
+ /* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => setIsFilterOpen(false), children: "Done" })
2391
+ ] })
2392
+ ] })
2393
+ ] }) }) }),
2394
+ /* @__PURE__ */ jsx("div", { className: `ndk:overflow-hidden ndk:border ndk:border-gray-200 ndk:dark:border-gray-800 ${bordered === "rounded" ? "ndk:rounded-lg" : bordered ? "" : "ndk:rounded-lg"}`, children: /* @__PURE__ */ jsxs(Table, { children: [
2395
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
2396
+ selectable?.enabled && /* @__PURE__ */ jsx(TableHead, { className: "ndk:w-12", children: /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:gap-2", children: [
2397
+ /* @__PURE__ */ jsx(
2398
+ Checkbox,
2399
+ {
2400
+ checked: selection.isIndeterminate ? "indeterminate" : selection.isAllSelected,
2401
+ onCheckedChange: () => selection.toggleAll()
2402
+ }
2403
+ ),
2404
+ selectable.actions && Object.keys(selectable.actions).length > 0 && /* @__PURE__ */ jsxs(DropdownMenu, { open: actionsMenuOpen, onOpenChange: setActionsMenuOpen, children: [
2405
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
2406
+ Button,
2407
+ {
2408
+ variant: "ghost",
2409
+ size: "icon",
2410
+ className: "ndk:size-6",
2411
+ disabled: selectedCount === 0 || !!actionLoading,
2412
+ children: actionLoading ? /* @__PURE__ */ jsx(Loader2, { className: "ndk:size-4 ndk:animate-spin" }) : /* @__PURE__ */ jsx(MoreHorizontal, { className: "ndk:size-4" })
2413
+ }
2414
+ ) }),
2415
+ /* @__PURE__ */ jsx(DropdownMenuContent, { align: "start", container: overlayContainer, children: Object.entries(selectable.actions).map(
2416
+ ([key, action2]) => action2.type === "SEPARATOR" ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, key) : /* @__PURE__ */ jsx(DropdownMenuItem, { disabled: !!actionLoading, onSelect: () => handleSelectionAction(key), children: actionLoading === key ? "Working\u2026" : /* @__PURE__ */ jsxs(Fragment, { children: [
2417
+ action2.icon,
2418
+ action2.name
2419
+ ] }) }, key)
2420
+ ) })
2421
+ ] })
2422
+ ] }) }),
2423
+ columns.map((col, idx) => /* @__PURE__ */ jsx(React2__default.Fragment, { children: col.sortable ? /* @__PURE__ */ jsx(TableHead, { ...React2__default.isValidElement(col.head) ? col.head.props : {}, children: /* @__PURE__ */ jsxs(
2424
+ Button,
2425
+ {
2426
+ variant: "ghost",
2427
+ size: "sm",
2428
+ className: "ndk:-ml-4 ndk:h-auto ndk:py-0",
2429
+ onClick: () => handleSort(col.sortable.path),
2430
+ children: [
2431
+ React2__default.isValidElement(col.head) ? col.head.props.children : col.head,
2432
+ getSortFor(col.sortable.path) === 1 && /* @__PURE__ */ jsx(ArrowUp, { className: "ndk:ml-1 ndk:size-4" }),
2433
+ getSortFor(col.sortable.path) === -1 && /* @__PURE__ */ jsx(ArrowDown, { className: "ndk:ml-1 ndk:size-4" })
2434
+ ]
2435
+ }
2436
+ ) }) : col.head }, idx))
2437
+ ] }) }),
2438
+ /* @__PURE__ */ jsx(TableBody, { children: dataKit.state.isLoading ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan, className: "ndk:h-24 ndk:text-center", children: /* @__PURE__ */ jsx(Loader2, { className: "ndk:mx-auto ndk:size-5 ndk:animate-spin" }) }) }) : dataKit.state.error ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsxs(TableCell, { colSpan, className: "ndk:h-24 ndk:text-center ndk:text-red-500", children: [
2439
+ "Error: ",
2440
+ dataKit.state.error.message
2441
+ ] }) }) : dataKit.items.length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan, className: "ndk:h-24 ndk:text-center ndk:text-muted-foreground", children: "No results found." }) }) : dataKit.items.map((item, idx) => {
2442
+ const rowId = item.id ?? idx;
2443
+ return /* @__PURE__ */ jsxs(TableRow, { children: [
2444
+ selectable?.enabled && /* @__PURE__ */ jsx(TableCell, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
2445
+ Checkbox,
2446
+ {
2447
+ checked: selection.isSelected(item.id),
2448
+ onCheckedChange: () => {
2449
+ },
2450
+ onClick: (e) => handleRowSelection(idx, e)
2451
+ }
2452
+ ) }),
2453
+ columns.map((col, colIdx) => /* @__PURE__ */ jsx(React2__default.Fragment, { children: col.body({
2454
+ item,
2455
+ index: idx,
2456
+ state: getRowState(rowId),
2457
+ setState: (updater) => setRowState(rowId, updater),
2458
+ setItem: (updatedItem) => dataKit.actions.setItemAt(idx, updatedItem),
2459
+ deleteItem: () => dataKit.actions.deleteItemAt(idx)
2460
+ }) }, colIdx))
2461
+ ] }, rowId);
2462
+ }) })
2463
+ ] }) }),
2464
+ /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:gap-4 ndk:justify-between", children: [
2465
+ /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:gap-3", children: [
2466
+ /* @__PURE__ */ jsxs(Select, { value: String(dataKit.limit), onValueChange: (v) => dataKit.actions.setLimit(Number(v)), disabled: dataKit.state.isLoading, children: [
2467
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "ndk:w-16", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2468
+ /* @__PURE__ */ jsx(SelectContent, { container: overlayContainer, children: limitOptions.map((v) => /* @__PURE__ */ jsx(SelectItem, { value: String(v), children: v }, v)) })
2469
+ ] }),
2470
+ /* @__PURE__ */ jsxs("p", { className: "ndk:text-sm ndk:text-muted-foreground ndk:whitespace-nowrap", children: [
2471
+ "Page ",
2472
+ dataKit.page,
2473
+ " of ",
2474
+ pagination.totalPages
2475
+ ] }),
2476
+ selectable?.enabled && selectedCount > 0 && /* @__PURE__ */ jsxs("p", { className: "ndk:text-sm ndk:text-foreground", children: [
2477
+ selectedCount,
2478
+ " selected"
2479
+ ] })
2480
+ ] }),
2481
+ /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:justify-end", children: paginationType === "SIMPLE" ? /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:gap-1", children: [
2482
+ /* @__PURE__ */ jsx(
2483
+ Button,
2484
+ {
2485
+ variant: "outline",
2486
+ size: "icon",
2487
+ disabled: !pagination.hasPrevPage || dataKit.state.isLoading,
2488
+ onClick: () => dataKit.actions.setPage(dataKit.page - 1),
2489
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "ndk:size-4" })
2490
+ }
2491
+ ),
2492
+ /* @__PURE__ */ jsx(
2493
+ Button,
2494
+ {
2495
+ variant: "outline",
2496
+ size: "icon",
2497
+ disabled: !pagination.hasNextPage || dataKit.state.isLoading,
2498
+ onClick: () => dataKit.actions.setPage(dataKit.page + 1),
2499
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "ndk:size-4" })
2500
+ }
2501
+ )
2502
+ ] }) : /* @__PURE__ */ jsx(Pagination, { className: "ndk:w-auto", children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
2503
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:hidden ndk:sm:block", children: /* @__PURE__ */ jsx(
2504
+ PaginationPrevious,
2505
+ {
2506
+ disabled: !pagination.hasPrevPage || dataKit.state.isLoading,
2507
+ onClick: () => dataKit.actions.setPage(dataKit.page - 1)
2508
+ }
2509
+ ) }),
2510
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:sm:hidden", children: /* @__PURE__ */ jsx(
2511
+ PaginationLink,
2512
+ {
2513
+ disabled: !pagination.hasPrevPage || dataKit.state.isLoading,
2514
+ onClick: () => dataKit.actions.setPage(dataKit.page - 1),
2515
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "ndk:size-4" })
2516
+ }
2517
+ ) }),
2518
+ pagination.pages.map((pageNum, idx) => /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:hidden ndk:sm:block", children: pageNum === "ellipsis" ? /* @__PURE__ */ jsx(PaginationEllipsis, {}) : /* @__PURE__ */ jsx(
2519
+ PaginationLink,
2520
+ {
2521
+ isActive: pageNum === dataKit.page,
2522
+ disabled: dataKit.state.isLoading,
2523
+ onClick: () => dataKit.actions.setPage(pageNum),
2524
+ children: pageNum
2525
+ }
2526
+ ) }, idx)),
2527
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:sm:hidden", children: /* @__PURE__ */ jsx("span", { className: "ndk:flex ndk:size-9 ndk:items-center ndk:justify-center ndk:text-sm", children: dataKit.page }) }),
2528
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:hidden ndk:sm:block", children: /* @__PURE__ */ jsx(
2529
+ PaginationNext,
2530
+ {
2531
+ disabled: !pagination.hasNextPage || dataKit.state.isLoading,
2532
+ onClick: () => dataKit.actions.setPage(dataKit.page + 1)
2533
+ }
2534
+ ) }),
2535
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:sm:hidden", children: /* @__PURE__ */ jsx(
2536
+ PaginationLink,
2537
+ {
2538
+ disabled: !pagination.hasNextPage || dataKit.state.isLoading,
2539
+ onClick: () => dataKit.actions.setPage(dataKit.page + 1),
2540
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "ndk:size-4" })
2541
+ }
2542
+ ) })
2543
+ ] }) }) })
2544
+ ] })
2545
+ ] });
2546
+ };
2547
+ var DataKitTable = Object.assign(DataKitRoot, {
2548
+ Cell: TableCell,
2549
+ Head: TableHead
2550
+ });
2551
+ var DataKitInner = (props, ref) => {
2552
+ const {
2553
+ action,
2554
+ query,
2555
+ filters = [],
2556
+ limit: limitConfig,
2557
+ defaultSort = [],
2558
+ className,
2559
+ autoFetch = true,
2560
+ debounce: debounce2 = 300,
2561
+ refetchInterval,
2562
+ memory: memoryMode = "memory",
2563
+ manual = false,
2564
+ pagination: paginationType = "NUMBER",
2565
+ children
2566
+ } = props;
2567
+ const containerRef = useRef(null);
2568
+ const intervalRef = useRef(null);
2569
+ const [isVisible, setIsVisible] = useState(false);
2570
+ const [isFilterOpen, setIsFilterOpen] = useState(false);
2571
+ const overlayContainer = containerRef.current;
2572
+ const dataKit = useDataKit({
2573
+ action,
2574
+ filters,
2575
+ autoFetch,
2576
+ debounce: debounce2,
2577
+ memory: memoryMode,
2578
+ initial: {
2579
+ limit: limitConfig?.default ?? 10,
2580
+ query: query ?? {},
2581
+ sorts: defaultSort,
2582
+ filter: filters.reduce((acc, f) => {
2583
+ if (f.defaultValue !== void 0) acc[f.id] = f.defaultValue;
2584
+ return acc;
2585
+ }, {})
2586
+ }
2587
+ });
2588
+ const pagination = usePagination({ page: dataKit.page, limit: dataKit.limit, total: dataKit.total, siblingCount: 1 });
2589
+ const limitOptions = React2__default.useMemo(() => {
2590
+ const standardOptions = [10, 25, 50, 100];
2591
+ const currentLimit = dataKit.limit;
2592
+ if (!standardOptions.includes(currentLimit)) {
2593
+ return [...standardOptions, currentLimit].sort((a, b) => a - b);
2594
+ }
2595
+ return standardOptions;
2596
+ }, [dataKit.limit]);
2597
+ React2__default.useImperativeHandle(ref, () => dataKit, [dataKit]);
2598
+ const handleResetFilters = useCallback(() => {
2599
+ filters.forEach((f) => {
2600
+ dataKit.actions.setFilter(f.id, f.defaultValue ?? (f.type === "BOOLEAN" ? false : ""));
2601
+ });
2602
+ }, [filters, dataKit.actions]);
2603
+ useEffect(() => {
2604
+ if (!containerRef.current || !refetchInterval) return;
2605
+ const observer = new IntersectionObserver(
2606
+ (entries) => entries[0] && setIsVisible(entries[0].isIntersecting),
2607
+ { threshold: 0.1 }
2608
+ );
2609
+ const currentRef = containerRef.current;
2610
+ observer.observe(currentRef);
2611
+ return () => {
2612
+ if (currentRef) observer.unobserve(currentRef);
2613
+ };
2614
+ }, [refetchInterval]);
2615
+ useEffect(() => {
2616
+ if (intervalRef.current) {
2617
+ clearInterval(intervalRef.current);
2618
+ intervalRef.current = null;
2619
+ }
2620
+ if (refetchInterval && isVisible) {
2621
+ intervalRef.current = setInterval(dataKit.actions.refresh, refetchInterval);
2622
+ }
2623
+ return () => {
2624
+ if (intervalRef.current) clearInterval(intervalRef.current);
2625
+ };
2626
+ }, [refetchInterval, isVisible, dataKit.actions]);
2627
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `ndk:space-y-3 ${className ?? ""}`, children: [
2628
+ /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:justify-between ndk:gap-2", children: [
2629
+ /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:items-center ndk:gap-2", children: filters.length > 0 && /* @__PURE__ */ jsxs(Popover, { open: isFilterOpen, onOpenChange: setIsFilterOpen, children: [
2630
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
2631
+ /* @__PURE__ */ jsx(Filter, { className: "ndk:mr-1.5 ndk:size-4" }),
2632
+ "Filters"
2633
+ ] }) }),
2634
+ /* @__PURE__ */ jsxs(PopoverContent, { align: "start", className: "ndk:w-80", container: overlayContainer, children: [
2635
+ /* @__PURE__ */ jsx("div", { className: "ndk:grid ndk:gap-3", children: filters.map((f) => /* @__PURE__ */ jsxs("div", { className: "ndk:grid ndk:gap-1.5", children: [
2636
+ /* @__PURE__ */ jsx("label", { className: "ndk:text-sm ndk:font-medium", children: f.label }),
2637
+ f.type === "TEXT" && /* @__PURE__ */ jsx(
2638
+ "input",
2639
+ {
2640
+ type: "text",
2641
+ className: "ndk:h-9 ndk:w-full ndk:rounded-md ndk:border ndk:bg-transparent ndk:px-3 ndk:text-sm ndk:outline-none ndk:focus:ring-2 ndk:focus:ring-ring",
2642
+ placeholder: f.placeholder,
2643
+ value: dataKit.filter[f.id] ?? "",
2644
+ onChange: (e) => dataKit.actions.setFilter(f.id, e.target.value)
2645
+ }
2646
+ ),
2647
+ f.type === "SELECT" && /* @__PURE__ */ jsxs(
2648
+ Select,
2649
+ {
2650
+ value: String(dataKit.filter[f.id] || "__all__"),
2651
+ onValueChange: (v) => dataKit.actions.setFilter(f.id, v === "__all__" ? "" : v),
2652
+ children: [
2653
+ /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2654
+ /* @__PURE__ */ jsxs(SelectContent, { container: overlayContainer, children: [
2655
+ /* @__PURE__ */ jsx(SelectItem, { value: "__all__", children: "All" }),
2656
+ f.dataset?.map((d) => /* @__PURE__ */ jsx(SelectItem, { value: d.id, children: d.label }, d.id))
2657
+ ] })
2658
+ ]
2659
+ }
2660
+ ),
2661
+ f.type === "BOOLEAN" && /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:items-center ndk:justify-between", children: /* @__PURE__ */ jsx(
2662
+ Checkbox,
2663
+ {
2664
+ checked: Boolean(dataKit.filter[f.id]),
2665
+ onCheckedChange: (c) => dataKit.actions.setFilter(f.id, c)
2666
+ }
2667
+ ) })
2668
+ ] }, f.id)) }),
2669
+ /* @__PURE__ */ jsxs("div", { className: "ndk:mt-4 ndk:flex ndk:justify-between ndk:border-t ndk:pt-3", children: [
2670
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: handleResetFilters, children: "Reset" }),
2671
+ /* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => setIsFilterOpen(false), children: "Done" })
2672
+ ] })
2673
+ ] })
2674
+ ] }) }),
2675
+ /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:gap-1", children: [
2676
+ /* @__PURE__ */ jsxs("span", { className: "ndk:mr-2 ndk:text-sm ndk:text-muted-foreground", children: [
2677
+ dataKit.items.length,
2678
+ " of ",
2679
+ dataKit.total
2680
+ ] }),
2681
+ /* @__PURE__ */ jsxs(Select, { value: String(dataKit.limit), onValueChange: (v) => dataKit.actions.setLimit(Number(v)), disabled: dataKit.state.isLoading, children: [
2682
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "ndk:w-16", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2683
+ /* @__PURE__ */ jsx(SelectContent, { container: overlayContainer, children: limitOptions.map((v) => /* @__PURE__ */ jsx(SelectItem, { value: String(v), children: v }, v)) })
2684
+ ] })
2685
+ ] })
2686
+ ] }),
2687
+ manual ? children(dataKit) : /* @__PURE__ */ jsx("div", { className: "ndk:min-h-[200px]", children: dataKit.state.isLoading ? /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:h-48 ndk:items-center ndk:justify-center", children: /* @__PURE__ */ jsx(Loader2, { className: "ndk:size-6 ndk:animate-spin ndk:text-muted-foreground" }) }) : dataKit.items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:h-48 ndk:items-center ndk:justify-center ndk:text-muted-foreground", children: "No results found." }) : children(dataKit) }),
2688
+ /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:justify-between", children: [
2689
+ /* @__PURE__ */ jsxs("p", { className: "ndk:text-sm ndk:text-muted-foreground", children: [
2690
+ "Page ",
2691
+ dataKit.page,
2692
+ " of ",
2693
+ pagination.totalPages
2694
+ ] }),
2695
+ paginationType === "SIMPLE" ? /* @__PURE__ */ jsxs("div", { className: "ndk:flex ndk:items-center ndk:gap-1", children: [
2696
+ /* @__PURE__ */ jsx(
2697
+ Button,
2698
+ {
2699
+ variant: "outline",
2700
+ size: "icon",
2701
+ disabled: !pagination.hasPrevPage || dataKit.state.isLoading,
2702
+ onClick: () => dataKit.actions.setPage(dataKit.page - 1),
2703
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "ndk:size-4" })
2704
+ }
2705
+ ),
2706
+ /* @__PURE__ */ jsx(
2707
+ Button,
2708
+ {
2709
+ variant: "outline",
2710
+ size: "icon",
2711
+ disabled: !pagination.hasNextPage || dataKit.state.isLoading,
2712
+ onClick: () => dataKit.actions.setPage(dataKit.page + 1),
2713
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "ndk:size-4" })
2714
+ }
2715
+ )
2716
+ ] }) : /* @__PURE__ */ jsx(Pagination, { className: "ndk:mx-0 ndk:w-auto", children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
2717
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:hidden ndk:sm:block", children: /* @__PURE__ */ jsx(
2718
+ PaginationPrevious,
2719
+ {
2720
+ disabled: !pagination.hasPrevPage || dataKit.state.isLoading,
2721
+ onClick: () => dataKit.actions.setPage(dataKit.page - 1)
2722
+ }
2723
+ ) }),
2724
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:sm:hidden", children: /* @__PURE__ */ jsx(
2725
+ PaginationLink,
2726
+ {
2727
+ disabled: !pagination.hasPrevPage || dataKit.state.isLoading,
2728
+ onClick: () => dataKit.actions.setPage(dataKit.page - 1),
2729
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "ndk:size-4" })
2730
+ }
2731
+ ) }),
2732
+ pagination.pages.map((pageNum, idx) => /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:hidden ndk:sm:block", children: pageNum === "ellipsis" ? /* @__PURE__ */ jsx(PaginationEllipsis, {}) : /* @__PURE__ */ jsx(
2733
+ PaginationLink,
2734
+ {
2735
+ isActive: pageNum === dataKit.page,
2736
+ disabled: dataKit.state.isLoading,
2737
+ onClick: () => dataKit.actions.setPage(pageNum),
2738
+ children: pageNum
2739
+ }
2740
+ ) }, idx)),
2741
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:sm:hidden", children: /* @__PURE__ */ jsx("span", { className: "ndk:flex ndk:size-9 ndk:items-center ndk:justify-center ndk:text-sm", children: dataKit.page }) }),
2742
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:hidden ndk:sm:block", children: /* @__PURE__ */ jsx(
2743
+ PaginationNext,
2744
+ {
2745
+ disabled: !pagination.hasNextPage || dataKit.state.isLoading,
2746
+ onClick: () => dataKit.actions.setPage(dataKit.page + 1)
2747
+ }
2748
+ ) }),
2749
+ /* @__PURE__ */ jsx(PaginationItem, { className: "ndk:sm:hidden", children: /* @__PURE__ */ jsx(
2750
+ PaginationLink,
2751
+ {
2752
+ disabled: !pagination.hasNextPage || dataKit.state.isLoading,
2753
+ onClick: () => dataKit.actions.setPage(dataKit.page + 1),
2754
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "ndk:size-4" })
2755
+ }
2756
+ ) })
2757
+ ] }) })
2758
+ ] })
2759
+ ] });
2760
+ };
2761
+ var DataKit = React2__default.forwardRef(DataKitInner);
2762
+ var DataKitInfinityInner = (props) => {
2763
+ const {
2764
+ action,
2765
+ query,
2766
+ filters = [],
2767
+ limit: limitConfig,
2768
+ defaultSort = [],
2769
+ className,
2770
+ autoFetch = true,
2771
+ debounce: debounce2 = 300,
2772
+ memory: memoryMode = "memory",
2773
+ manual = false,
2774
+ fullHeight = true,
2775
+ children
2776
+ } = props;
2777
+ const containerRef = useRef(null);
2778
+ const scrollContainerRef = useRef(null);
2779
+ const [allItems, setAllItems] = useState([]);
2780
+ const [isFilterOpen, setIsFilterOpen] = useState(false);
2781
+ const overlayContainer = containerRef.current;
2782
+ const dataKit = useDataKit({
2783
+ action,
2784
+ filters,
2785
+ autoFetch: false,
2786
+ // We'll control fetching manually
2787
+ debounce: debounce2,
2788
+ memory: memoryMode,
2789
+ initial: {
2790
+ limit: limitConfig?.default ?? 10,
2791
+ query: query ?? {},
2792
+ sorts: defaultSort,
2793
+ filter: filters.reduce((acc, f) => {
2794
+ if (f.defaultValue !== void 0) acc[f.id] = f.defaultValue;
2795
+ return acc;
2796
+ }, {})
2797
+ }
2798
+ });
2799
+ const { ref: loadMoreBottomRef, inView: inViewBottom } = useInView({
2800
+ threshold: 0,
2801
+ rootMargin: "100px"
2802
+ });
2803
+ const handleResetFilters = useCallback(() => {
2804
+ filters.forEach((f) => {
2805
+ dataKit.actions.setFilter(f.id, f.defaultValue ?? (f.type === "BOOLEAN" ? false : ""));
2806
+ });
2807
+ }, [filters, dataKit.actions]);
2808
+ const loadMore = useCallback(() => {
2809
+ if (dataKit.state.isLoading || !dataKit.state.hasNextPage) return;
2810
+ dataKit.actions.setPage(dataKit.page + 1);
2811
+ }, [dataKit.state.isLoading, dataKit.state.hasNextPage, dataKit.page, dataKit.actions]);
2812
+ useEffect(() => {
2813
+ if (autoFetch) dataKit.actions.refresh();
2814
+ }, [autoFetch]);
2815
+ useEffect(() => {
2816
+ if (dataKit.items.length > 0) {
2817
+ setAllItems((prev) => {
2818
+ if (dataKit.page === 1) return dataKit.items;
2819
+ return [...prev, ...dataKit.items];
2820
+ });
2821
+ } else if (dataKit.page === 1) {
2822
+ setAllItems([]);
2823
+ }
2824
+ }, [dataKit.items, dataKit.page]);
2825
+ useEffect(() => {
2826
+ if (inViewBottom && !dataKit.state.isLoading && dataKit.state.hasNextPage) {
2827
+ loadMore();
2828
+ }
2829
+ }, [inViewBottom, dataKit.state.isLoading, dataKit.state.hasNextPage]);
2830
+ const enhancedDataKit = {
2831
+ ...dataKit,
2832
+ items: allItems
2833
+ };
2834
+ return /* @__PURE__ */ jsxs(
2835
+ "div",
2836
+ {
2837
+ ref: containerRef,
2838
+ className: `ndk:flex ndk:flex-col ${fullHeight ? "ndk:h-full" : ""}`,
2839
+ children: [
2840
+ filters.length > 0 && /* @__PURE__ */ jsx("div", { className: "ndk:shrink-0 ndk:px-4 ndk:pt-4 ndk:pb-3", children: /* @__PURE__ */ jsxs(Popover, { open: isFilterOpen, onOpenChange: setIsFilterOpen, children: [
2841
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
2842
+ /* @__PURE__ */ jsx(Filter, { className: "ndk:mr-1.5 ndk:size-4" }),
2843
+ "Filters"
2844
+ ] }) }),
2845
+ /* @__PURE__ */ jsxs(PopoverContent, { align: "start", className: "ndk:w-80", container: overlayContainer, children: [
2846
+ /* @__PURE__ */ jsx("div", { className: "ndk:grid ndk:gap-3", children: filters.map((f) => /* @__PURE__ */ jsxs("div", { className: "ndk:grid ndk:gap-1.5", children: [
2847
+ /* @__PURE__ */ jsx("label", { className: "ndk:text-sm ndk:font-medium", children: f.label }),
2848
+ f.type === "TEXT" && /* @__PURE__ */ jsx(
2849
+ "input",
2850
+ {
2851
+ type: "text",
2852
+ className: "ndk:h-9 ndk:w-full ndk:rounded-md ndk:border ndk:bg-transparent ndk:px-3 ndk:text-sm ndk:outline-none ndk:focus:ring-2 ndk:focus:ring-ring",
2853
+ placeholder: f.placeholder,
2854
+ value: dataKit.filter[f.id] ?? "",
2855
+ onChange: (e) => dataKit.actions.setFilter(f.id, e.target.value)
2856
+ }
2857
+ ),
2858
+ f.type === "SELECT" && /* @__PURE__ */ jsxs(
2859
+ Select,
2860
+ {
2861
+ value: String(dataKit.filter[f.id] || "__all__"),
2862
+ onValueChange: (v) => dataKit.actions.setFilter(f.id, v === "__all__" ? "" : v),
2863
+ children: [
2864
+ /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2865
+ /* @__PURE__ */ jsxs(SelectContent, { container: overlayContainer, children: [
2866
+ /* @__PURE__ */ jsx(SelectItem, { value: "__all__", children: "All" }),
2867
+ f.dataset?.map((d) => /* @__PURE__ */ jsx(SelectItem, { value: d.id, children: d.label }, d.id))
2868
+ ] })
2869
+ ]
2870
+ }
2871
+ ),
2872
+ f.type === "BOOLEAN" && /* @__PURE__ */ jsx("div", { className: "ndk:flex ndk:items-center ndk:justify-between", children: /* @__PURE__ */ jsx(
2873
+ Checkbox,
2874
+ {
2875
+ checked: Boolean(dataKit.filter[f.id]),
2876
+ onCheckedChange: (c) => dataKit.actions.setFilter(f.id, c)
2877
+ }
2878
+ ) })
2879
+ ] }, f.id)) }),
2880
+ /* @__PURE__ */ jsxs("div", { className: "ndk:mt-4 ndk:flex ndk:justify-between ndk:border-t ndk:pt-3", children: [
2881
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: handleResetFilters, children: "Reset" }),
2882
+ /* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => setIsFilterOpen(false), children: "Done" })
2883
+ ] })
2884
+ ] })
2885
+ ] }) }),
2886
+ /* @__PURE__ */ jsxs(
2887
+ "div",
2888
+ {
2889
+ ref: scrollContainerRef,
2890
+ className: `ndk:relative ndk:flex-1 ${fullHeight ? "ndk:min-h-0" : ""} ndk:overflow-y-auto ndk:overflow-x-hidden ${className ?? ""}`,
2891
+ children: [
2892
+ children(enhancedDataKit),
2893
+ /* @__PURE__ */ jsx("div", { ref: loadMoreBottomRef, className: manual ? "" : "ndk:flex ndk:items-center ndk:justify-center ndk:py-4", children: !manual && /* @__PURE__ */ jsxs(Fragment, { children: [
2894
+ dataKit.state.isLoading && /* @__PURE__ */ jsx(Loader2, { className: "ndk:size-6 ndk:animate-spin ndk:text-muted-foreground" }),
2895
+ !dataKit.state.isLoading && !dataKit.state.hasNextPage && allItems.length > 0 && /* @__PURE__ */ jsx("p", { className: "ndk:text-sm ndk:text-muted-foreground", children: "You're all set" })
2896
+ ] }) })
2897
+ ]
2898
+ }
2899
+ )
2900
+ ]
2901
+ }
2902
+ );
2903
+ };
2904
+ var DataKitInfinity = DataKitInfinityInner;
2905
+
2906
+ export { DataKit, DefaultDataKitContext as DataKitContext, DataKitInfinity, DefaultDataKitProvider as DataKitProvider, DataKitTable, createDataKitContext, debounce, formatNumber, getColumnValue, getNextSortValue, getSortValue, keyToSortEntries, sortEntriesToKey, throttle, useDataKit, useDefaultDataKitContext as useDataKitContext, usePagination, useSelection, useSelectionWithTotal };
2907
+ //# sourceMappingURL=client.js.map
8
2908
  //# sourceMappingURL=client.js.map