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