@krak-stack/registry 0.1.56 → 0.1.57

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.
@@ -4,11 +4,13 @@ import { ListFilterIcon } from "lucide-react";
4
4
  // ../../src/components/ui/data-table.tsx
5
5
  import { useAtom, useAtomSet } from "@effect/atom-react";
6
6
  import { BrowserKeyValueStore } from "@effect/platform-browser";
7
- import { DateTime, Option, Schema } from "effect";
7
+ import { DateTime as DateTime2, Effect as Effect2, Option as Option2, Schema as Schema2, Stream } from "effect";
8
+ import { Csv } from "effect/encoding";
8
9
  import { AsyncResult, Atom } from "effect/reactivity";
9
10
  import {
10
11
  ArrowDown,
11
12
  ArrowUp,
13
+ Check,
12
14
  ChevronDown,
13
15
  ChevronRight as ChevronRight2,
14
16
  ChevronsUpDown,
@@ -18,6 +20,7 @@ import {
18
20
  FileText,
19
21
  GripVertical,
20
22
  LayoutGrid,
23
+ ListFilter,
21
24
  MoreHorizontal,
22
25
  Plus,
23
26
  RefreshCw,
@@ -32,8 +35,9 @@ import {
32
35
  isValidElement,
33
36
  useCallback,
34
37
  useContext,
38
+ useId as useId2,
35
39
  useLayoutEffect,
36
- useMemo,
40
+ useMemo as useMemo2,
37
41
  useRef,
38
42
  useState
39
43
  } from "react";
@@ -315,10 +319,196 @@ function Input({ className, type, ...props }) {
315
319
  });
316
320
  }
317
321
 
322
+ // ../../src/components/ui/field.tsx
323
+ import { useMemo } from "react";
324
+ import { cva as cva3 } from "class-variance-authority";
325
+
326
+ // ../../src/components/ui/label.tsx
327
+ import { jsx as jsx6 } from "react/jsx-runtime";
328
+ "use client";
329
+ function Label({ className, ...props }) {
330
+ return /* @__PURE__ */ jsx6("label", {
331
+ "data-slot": "label",
332
+ className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
333
+ ...props
334
+ });
335
+ }
336
+
337
+ // ../../src/components/ui/separator.tsx
338
+ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
339
+
340
+ // ../../src/components/ui/field.tsx
341
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
342
+ function FieldGroup({ className, ...props }) {
343
+ return /* @__PURE__ */ jsx7("div", {
344
+ "data-slot": "field-group",
345
+ className: cn("group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4", className),
346
+ ...props
347
+ });
348
+ }
349
+ var fieldVariants = cva3("group/field flex w-full gap-3 data-[invalid=true]:text-destructive", {
350
+ variants: {
351
+ orientation: {
352
+ vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
353
+ horizontal: "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
354
+ responsive: "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
355
+ }
356
+ },
357
+ defaultVariants: {
358
+ orientation: "vertical"
359
+ }
360
+ });
361
+ function Field({
362
+ className,
363
+ orientation = "vertical",
364
+ ...props
365
+ }) {
366
+ return /* @__PURE__ */ jsx7("div", {
367
+ role: "group",
368
+ "data-slot": "field",
369
+ "data-orientation": orientation,
370
+ className: cn(fieldVariants({ orientation }), className),
371
+ ...props
372
+ });
373
+ }
374
+ function FieldLabel({
375
+ className,
376
+ ...props
377
+ }) {
378
+ return /* @__PURE__ */ jsx7(Label, {
379
+ "data-slot": "field-label",
380
+ className: cn("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-3 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", className),
381
+ ...props
382
+ });
383
+ }
384
+
385
+ // ../../src/components/ui/select.tsx
386
+ import { Select as SelectPrimitive } from "@base-ui/react/select";
387
+ import { ChevronDownIcon, CheckIcon as CheckIcon3, ChevronUpIcon } from "lucide-react";
388
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
389
+ "use client";
390
+ var Select = SelectPrimitive.Root;
391
+ function SelectGroup({ className, ...props }) {
392
+ return /* @__PURE__ */ jsx8(SelectPrimitive.Group, {
393
+ "data-slot": "select-group",
394
+ className: cn("scroll-my-1 p-1", className),
395
+ ...props
396
+ });
397
+ }
398
+ function SelectValue({ className, ...props }) {
399
+ return /* @__PURE__ */ jsx8(SelectPrimitive.Value, {
400
+ "data-slot": "select-value",
401
+ className: cn("flex flex-1 text-left", className),
402
+ ...props
403
+ });
404
+ }
405
+ function SelectTrigger({
406
+ className,
407
+ size = "default",
408
+ children,
409
+ ...props
410
+ }) {
411
+ return /* @__PURE__ */ jsxs3(SelectPrimitive.Trigger, {
412
+ "data-slot": "select-trigger",
413
+ "data-size": size,
414
+ className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
415
+ ...props,
416
+ children: [
417
+ children,
418
+ /* @__PURE__ */ jsx8(SelectPrimitive.Icon, {
419
+ render: /* @__PURE__ */ jsx8(ChevronDownIcon, {
420
+ className: "text-muted-foreground pointer-events-none size-4"
421
+ })
422
+ })
423
+ ]
424
+ });
425
+ }
426
+ function SelectContent({
427
+ className,
428
+ children,
429
+ side = "bottom",
430
+ sideOffset = 4,
431
+ align = "center",
432
+ alignOffset = 0,
433
+ alignItemWithTrigger = true,
434
+ ...props
435
+ }) {
436
+ return /* @__PURE__ */ jsx8(SelectPrimitive.Portal, {
437
+ children: /* @__PURE__ */ jsx8(SelectPrimitive.Positioner, {
438
+ side,
439
+ sideOffset,
440
+ align,
441
+ alignOffset,
442
+ alignItemWithTrigger,
443
+ className: "isolate z-50",
444
+ children: /* @__PURE__ */ jsxs3(SelectPrimitive.Popup, {
445
+ "data-slot": "select-content",
446
+ "data-align-trigger": alignItemWithTrigger,
447
+ className: cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
448
+ ...props,
449
+ children: [
450
+ /* @__PURE__ */ jsx8(SelectScrollUpButton, {}),
451
+ /* @__PURE__ */ jsx8(SelectPrimitive.List, {
452
+ children
453
+ }),
454
+ /* @__PURE__ */ jsx8(SelectScrollDownButton, {})
455
+ ]
456
+ })
457
+ })
458
+ });
459
+ }
460
+ function SelectItem({
461
+ className,
462
+ children,
463
+ ...props
464
+ }) {
465
+ return /* @__PURE__ */ jsxs3(SelectPrimitive.Item, {
466
+ "data-slot": "select-item",
467
+ className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
468
+ ...props,
469
+ children: [
470
+ /* @__PURE__ */ jsx8(SelectPrimitive.ItemText, {
471
+ className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap",
472
+ children
473
+ }),
474
+ /* @__PURE__ */ jsx8(SelectPrimitive.ItemIndicator, {
475
+ render: /* @__PURE__ */ jsx8("span", {
476
+ className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center"
477
+ }),
478
+ children: /* @__PURE__ */ jsx8(CheckIcon3, {
479
+ className: "pointer-events-none"
480
+ })
481
+ })
482
+ ]
483
+ });
484
+ }
485
+ function SelectScrollUpButton({
486
+ className,
487
+ ...props
488
+ }) {
489
+ return /* @__PURE__ */ jsx8(SelectPrimitive.ScrollUpArrow, {
490
+ "data-slot": "select-scroll-up-button",
491
+ className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
492
+ ...props,
493
+ children: /* @__PURE__ */ jsx8(ChevronUpIcon, {})
494
+ });
495
+ }
496
+ function SelectScrollDownButton({
497
+ className,
498
+ ...props
499
+ }) {
500
+ return /* @__PURE__ */ jsx8(SelectPrimitive.ScrollDownArrow, {
501
+ "data-slot": "select-scroll-down-button",
502
+ className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
503
+ ...props,
504
+ children: /* @__PURE__ */ jsx8(ChevronDownIcon, {})
505
+ });
506
+ }
507
+
318
508
  // ../../src/components/ui/loading.tsx
319
509
  import { Loader2 } from "lucide-react";
320
510
  import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
321
- import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
511
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
322
512
  var labels = {
323
513
  en: {
324
514
  loading: "Loading..."
@@ -336,10 +526,10 @@ function Loading({
336
526
  variant = "inline"
337
527
  }) {
338
528
  const locale = useKrakstackLocale(localeOverride);
339
- return /* @__PURE__ */ jsxs2("div", {
529
+ return /* @__PURE__ */ jsxs4("div", {
340
530
  className: cn("text-muted-foreground flex items-center justify-center gap-2 text-sm", variant === "centered" && "min-h-[50svh] w-full", className),
341
531
  children: [
342
- /* @__PURE__ */ jsx6(Loader2, {
532
+ /* @__PURE__ */ jsx9(Loader2, {
343
533
  className: "size-4 animate-spin"
344
534
  }),
345
535
  label ?? loadingLabel(locale, messages)
@@ -350,18 +540,18 @@ function Loading({
350
540
  // ../../src/components/ui/menubar.tsx
351
541
  import { Menu as MenuPrimitive2 } from "@base-ui/react/menu";
352
542
  import { Menubar as MenubarPrimitive } from "@base-ui/react/menubar";
353
- import { CheckIcon as CheckIcon3 } from "lucide-react";
354
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
543
+ import { CheckIcon as CheckIcon4 } from "lucide-react";
544
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
355
545
  "use client";
356
546
  function Menubar({ className, ...props }) {
357
- return /* @__PURE__ */ jsx7(MenubarPrimitive, {
547
+ return /* @__PURE__ */ jsx10(MenubarPrimitive, {
358
548
  "data-slot": "menubar",
359
549
  className: cn("flex h-9 items-center gap-1 rounded-md border p-1 shadow-xs", className),
360
550
  ...props
361
551
  });
362
552
  }
363
553
  function MenubarMenu({ ...props }) {
364
- return /* @__PURE__ */ jsx7(DropdownMenu, {
554
+ return /* @__PURE__ */ jsx10(DropdownMenu, {
365
555
  "data-slot": "menubar-menu",
366
556
  ...props
367
557
  });
@@ -369,7 +559,7 @@ function MenubarMenu({ ...props }) {
369
559
  function MenubarGroup({
370
560
  ...props
371
561
  }) {
372
- return /* @__PURE__ */ jsx7(DropdownMenuGroup, {
562
+ return /* @__PURE__ */ jsx10(DropdownMenuGroup, {
373
563
  "data-slot": "menubar-group",
374
564
  ...props
375
565
  });
@@ -378,7 +568,7 @@ function MenubarTrigger({
378
568
  className,
379
569
  ...props
380
570
  }) {
381
- return /* @__PURE__ */ jsx7(DropdownMenuTrigger, {
571
+ return /* @__PURE__ */ jsx10(DropdownMenuTrigger, {
382
572
  "data-slot": "menubar-trigger",
383
573
  className: cn("flex items-center rounded-sm px-2 py-1 text-sm font-medium outline-hidden select-none hover:bg-muted aria-expanded:bg-muted", className),
384
574
  ...props
@@ -391,7 +581,7 @@ function MenubarContent({
391
581
  sideOffset = 8,
392
582
  ...props
393
583
  }) {
394
- return /* @__PURE__ */ jsx7(DropdownMenuContent, {
584
+ return /* @__PURE__ */ jsx10(DropdownMenuContent, {
395
585
  "data-slot": "menubar-content",
396
586
  align,
397
587
  alignOffset,
@@ -406,7 +596,7 @@ function MenubarItem({
406
596
  variant = "default",
407
597
  ...props
408
598
  }) {
409
- return /* @__PURE__ */ jsx7(DropdownMenuItem, {
599
+ return /* @__PURE__ */ jsx10(DropdownMenuItem, {
410
600
  "data-slot": "menubar-item",
411
601
  "data-inset": inset,
412
602
  "data-variant": variant,
@@ -421,17 +611,17 @@ function MenubarCheckboxItem({
421
611
  inset,
422
612
  ...props
423
613
  }) {
424
- return /* @__PURE__ */ jsxs3(MenuPrimitive2.CheckboxItem, {
614
+ return /* @__PURE__ */ jsxs5(MenuPrimitive2.CheckboxItem, {
425
615
  "data-slot": "menubar-checkbox-item",
426
616
  "data-inset": inset,
427
617
  className: cn("relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", className),
428
618
  checked,
429
619
  ...props,
430
620
  children: [
431
- /* @__PURE__ */ jsx7("span", {
621
+ /* @__PURE__ */ jsx10("span", {
432
622
  className: "pointer-events-none absolute left-2 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4",
433
- children: /* @__PURE__ */ jsx7(MenuPrimitive2.CheckboxItemIndicator, {
434
- children: /* @__PURE__ */ jsx7(CheckIcon3, {})
623
+ children: /* @__PURE__ */ jsx10(MenuPrimitive2.CheckboxItemIndicator, {
624
+ children: /* @__PURE__ */ jsx10(CheckIcon4, {})
435
625
  })
436
626
  }),
437
627
  children
@@ -441,7 +631,7 @@ function MenubarCheckboxItem({
441
631
  function MenubarRadioGroup({
442
632
  ...props
443
633
  }) {
444
- return /* @__PURE__ */ jsx7(DropdownMenuRadioGroup, {
634
+ return /* @__PURE__ */ jsx10(DropdownMenuRadioGroup, {
445
635
  "data-slot": "menubar-radio-group",
446
636
  ...props
447
637
  });
@@ -452,16 +642,16 @@ function MenubarRadioItem({
452
642
  inset,
453
643
  ...props
454
644
  }) {
455
- return /* @__PURE__ */ jsxs3(MenuPrimitive2.RadioItem, {
645
+ return /* @__PURE__ */ jsxs5(MenuPrimitive2.RadioItem, {
456
646
  "data-slot": "menubar-radio-item",
457
647
  "data-inset": inset,
458
648
  className: cn("relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
459
649
  ...props,
460
650
  children: [
461
- /* @__PURE__ */ jsx7("span", {
651
+ /* @__PURE__ */ jsx10("span", {
462
652
  className: "pointer-events-none absolute left-2 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4",
463
- children: /* @__PURE__ */ jsx7(MenuPrimitive2.RadioItemIndicator, {
464
- children: /* @__PURE__ */ jsx7(CheckIcon3, {})
653
+ children: /* @__PURE__ */ jsx10(MenuPrimitive2.RadioItemIndicator, {
654
+ children: /* @__PURE__ */ jsx10(CheckIcon4, {})
465
655
  })
466
656
  }),
467
657
  children
@@ -473,7 +663,7 @@ function MenubarLabel({
473
663
  inset,
474
664
  ...props
475
665
  }) {
476
- return /* @__PURE__ */ jsx7(DropdownMenuLabel, {
666
+ return /* @__PURE__ */ jsx10(DropdownMenuLabel, {
477
667
  "data-slot": "menubar-label",
478
668
  "data-inset": inset,
479
669
  className: cn("px-2 py-1.5 text-sm font-medium data-inset:pl-8", className),
@@ -484,7 +674,7 @@ function MenubarSeparator({
484
674
  className,
485
675
  ...props
486
676
  }) {
487
- return /* @__PURE__ */ jsx7(DropdownMenuSeparator, {
677
+ return /* @__PURE__ */ jsx10(DropdownMenuSeparator, {
488
678
  "data-slot": "menubar-separator",
489
679
  className: cn("-mx-1 my-1 h-px bg-border", className),
490
680
  ...props
@@ -493,7 +683,7 @@ function MenubarSeparator({
493
683
  function MenubarSub({
494
684
  ...props
495
685
  }) {
496
- return /* @__PURE__ */ jsx7(DropdownMenuSub, {
686
+ return /* @__PURE__ */ jsx10(DropdownMenuSub, {
497
687
  "data-slot": "menubar-sub",
498
688
  ...props
499
689
  });
@@ -503,7 +693,7 @@ function MenubarSubTrigger({
503
693
  inset,
504
694
  ...props
505
695
  }) {
506
- return /* @__PURE__ */ jsx7(DropdownMenuSubTrigger, {
696
+ return /* @__PURE__ */ jsx10(DropdownMenuSubTrigger, {
507
697
  "data-slot": "menubar-sub-trigger",
508
698
  "data-inset": inset,
509
699
  className: cn("gap-2 rounded-sm px-2 py-1.5 text-sm focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-open:bg-accent data-open:text-accent-foreground [&_svg:not([class*='size-'])]:size-4", className),
@@ -514,7 +704,7 @@ function MenubarSubContent({
514
704
  className,
515
705
  ...props
516
706
  }) {
517
- return /* @__PURE__ */ jsx7(DropdownMenuSubContent, {
707
+ return /* @__PURE__ */ jsx10(DropdownMenuSubContent, {
518
708
  "data-slot": "menubar-sub-content",
519
709
  className: cn("min-w-32 rounded-md bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
520
710
  ...props
@@ -529,137 +719,8 @@ import {
529
719
  ChevronsRight
530
720
  } from "lucide-react";
531
721
  import { useId } from "react";
532
-
533
- // ../../src/components/ui/label.tsx
534
- import { jsx as jsx8 } from "react/jsx-runtime";
535
- "use client";
536
- function Label({ className, ...props }) {
537
- return /* @__PURE__ */ jsx8("label", {
538
- "data-slot": "label",
539
- className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
540
- ...props
541
- });
542
- }
543
-
544
- // ../../src/components/ui/select.tsx
545
- import { Select as SelectPrimitive } from "@base-ui/react/select";
546
- import { ChevronDownIcon, CheckIcon as CheckIcon4, ChevronUpIcon } from "lucide-react";
547
- import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
548
- "use client";
549
- var Select = SelectPrimitive.Root;
550
- function SelectValue({ className, ...props }) {
551
- return /* @__PURE__ */ jsx9(SelectPrimitive.Value, {
552
- "data-slot": "select-value",
553
- className: cn("flex flex-1 text-left", className),
554
- ...props
555
- });
556
- }
557
- function SelectTrigger({
558
- className,
559
- size = "default",
560
- children,
561
- ...props
562
- }) {
563
- return /* @__PURE__ */ jsxs4(SelectPrimitive.Trigger, {
564
- "data-slot": "select-trigger",
565
- "data-size": size,
566
- className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
567
- ...props,
568
- children: [
569
- children,
570
- /* @__PURE__ */ jsx9(SelectPrimitive.Icon, {
571
- render: /* @__PURE__ */ jsx9(ChevronDownIcon, {
572
- className: "text-muted-foreground pointer-events-none size-4"
573
- })
574
- })
575
- ]
576
- });
577
- }
578
- function SelectContent({
579
- className,
580
- children,
581
- side = "bottom",
582
- sideOffset = 4,
583
- align = "center",
584
- alignOffset = 0,
585
- alignItemWithTrigger = true,
586
- ...props
587
- }) {
588
- return /* @__PURE__ */ jsx9(SelectPrimitive.Portal, {
589
- children: /* @__PURE__ */ jsx9(SelectPrimitive.Positioner, {
590
- side,
591
- sideOffset,
592
- align,
593
- alignOffset,
594
- alignItemWithTrigger,
595
- className: "isolate z-50",
596
- children: /* @__PURE__ */ jsxs4(SelectPrimitive.Popup, {
597
- "data-slot": "select-content",
598
- "data-align-trigger": alignItemWithTrigger,
599
- className: cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
600
- ...props,
601
- children: [
602
- /* @__PURE__ */ jsx9(SelectScrollUpButton, {}),
603
- /* @__PURE__ */ jsx9(SelectPrimitive.List, {
604
- children
605
- }),
606
- /* @__PURE__ */ jsx9(SelectScrollDownButton, {})
607
- ]
608
- })
609
- })
610
- });
611
- }
612
- function SelectItem({
613
- className,
614
- children,
615
- ...props
616
- }) {
617
- return /* @__PURE__ */ jsxs4(SelectPrimitive.Item, {
618
- "data-slot": "select-item",
619
- className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
620
- ...props,
621
- children: [
622
- /* @__PURE__ */ jsx9(SelectPrimitive.ItemText, {
623
- className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap",
624
- children
625
- }),
626
- /* @__PURE__ */ jsx9(SelectPrimitive.ItemIndicator, {
627
- render: /* @__PURE__ */ jsx9("span", {
628
- className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center"
629
- }),
630
- children: /* @__PURE__ */ jsx9(CheckIcon4, {
631
- className: "pointer-events-none"
632
- })
633
- })
634
- ]
635
- });
636
- }
637
- function SelectScrollUpButton({
638
- className,
639
- ...props
640
- }) {
641
- return /* @__PURE__ */ jsx9(SelectPrimitive.ScrollUpArrow, {
642
- "data-slot": "select-scroll-up-button",
643
- className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
644
- ...props,
645
- children: /* @__PURE__ */ jsx9(ChevronUpIcon, {})
646
- });
647
- }
648
- function SelectScrollDownButton({
649
- className,
650
- ...props
651
- }) {
652
- return /* @__PURE__ */ jsx9(SelectPrimitive.ScrollDownArrow, {
653
- "data-slot": "select-scroll-down-button",
654
- className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
655
- ...props,
656
- children: /* @__PURE__ */ jsx9(ChevronDownIcon, {})
657
- });
658
- }
659
-
660
- // ../../src/components/ui/pagination.tsx
661
722
  import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
662
- import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
723
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
663
724
  var messages = {
664
725
  en: {
665
726
  pageSize: "Page size",
@@ -706,32 +767,32 @@ function Pagination({
706
767
  const pageSizeId = useId();
707
768
  const canGoBack = page > 0;
708
769
  const canGoForward = page + 1 < pageCount;
709
- return /* @__PURE__ */ jsxs5("div", {
770
+ return /* @__PURE__ */ jsxs6("div", {
710
771
  className: cn("flex flex-col gap-3 px-2 sm:flex-row sm:items-center sm:justify-between", compact && "gap-2 px-0 sm:flex-col sm:items-stretch"),
711
772
  children: [
712
- showResults ? /* @__PURE__ */ jsxs5("div", {
773
+ showResults ? /* @__PURE__ */ jsxs6("div", {
713
774
  className: "text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",
714
775
  children: [
715
- /* @__PURE__ */ jsx10("span", {
776
+ /* @__PURE__ */ jsx11("span", {
716
777
  children: labels.results(totalRows)
717
778
  }),
718
- selectedRows > 0 ? /* @__PURE__ */ jsx10("span", {
779
+ selectedRows > 0 ? /* @__PURE__ */ jsx11("span", {
719
780
  children: labels.selectedOf(selectedRows, totalRows)
720
781
  }) : null
721
782
  ]
722
783
  }) : null,
723
- /* @__PURE__ */ jsxs5("div", {
784
+ /* @__PURE__ */ jsxs6("div", {
724
785
  className: cn("flex items-center gap-4 sm:justify-end", compact && "flex-wrap justify-between gap-2 sm:justify-between"),
725
786
  children: [
726
- /* @__PURE__ */ jsxs5("div", {
787
+ /* @__PURE__ */ jsxs6("div", {
727
788
  className: "flex items-center gap-2",
728
789
  children: [
729
- /* @__PURE__ */ jsx10(Label, {
790
+ /* @__PURE__ */ jsx11(Label, {
730
791
  htmlFor: pageSizeId,
731
792
  className: cn("hidden text-sm sm:block", compact && "block"),
732
793
  children: labels.pageSize
733
794
  }),
734
- /* @__PURE__ */ jsxs5(Select, {
795
+ /* @__PURE__ */ jsxs6(Select, {
735
796
  items: pageSizes.map((size) => ({
736
797
  label: size.toString(),
737
798
  value: size.toString()
@@ -739,16 +800,16 @@ function Pagination({
739
800
  value: `${pageSize}`,
740
801
  onValueChange: (value) => onPageSizeChange(Number(value)),
741
802
  children: [
742
- /* @__PURE__ */ jsx10(SelectTrigger, {
803
+ /* @__PURE__ */ jsx11(SelectTrigger, {
743
804
  className: "h-8 w-[70px]",
744
805
  id: pageSizeId,
745
- children: /* @__PURE__ */ jsx10(SelectValue, {
806
+ children: /* @__PURE__ */ jsx11(SelectValue, {
746
807
  placeholder: pageSize
747
808
  })
748
809
  }),
749
- /* @__PURE__ */ jsx10(SelectContent, {
810
+ /* @__PURE__ */ jsx11(SelectContent, {
750
811
  side: "top",
751
- children: pageSizes.map((size) => /* @__PURE__ */ jsx10(SelectItem, {
812
+ children: pageSizes.map((size) => /* @__PURE__ */ jsx11(SelectItem, {
752
813
  value: `${size}`,
753
814
  children: size
754
815
  }, size))
@@ -757,66 +818,66 @@ function Pagination({
757
818
  })
758
819
  ]
759
820
  }),
760
- /* @__PURE__ */ jsxs5("div", {
821
+ /* @__PURE__ */ jsxs6("div", {
761
822
  className: "flex items-center gap-2",
762
823
  children: [
763
- /* @__PURE__ */ jsx10("div", {
824
+ /* @__PURE__ */ jsx11("div", {
764
825
  className: "flex items-center justify-center text-sm font-medium sm:block",
765
826
  children: labels.pageOf(page + 1, pageCount)
766
827
  }),
767
- /* @__PURE__ */ jsxs5("div", {
828
+ /* @__PURE__ */ jsxs6("div", {
768
829
  className: "flex items-center gap-1",
769
830
  children: [
770
- /* @__PURE__ */ jsxs5(Button, {
831
+ /* @__PURE__ */ jsxs6(Button, {
771
832
  className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
772
833
  disabled: !canGoBack,
773
834
  onClick: () => onPageChange(0),
774
835
  type: "button",
775
836
  children: [
776
- /* @__PURE__ */ jsx10("span", {
837
+ /* @__PURE__ */ jsx11("span", {
777
838
  className: "sr-only",
778
839
  children: labels.goToFirstPage
779
840
  }),
780
- /* @__PURE__ */ jsx10(ChevronsLeft, {})
841
+ /* @__PURE__ */ jsx11(ChevronsLeft, {})
781
842
  ]
782
843
  }),
783
- /* @__PURE__ */ jsxs5(Button, {
844
+ /* @__PURE__ */ jsxs6(Button, {
784
845
  className: "h-8 w-8 p-0",
785
846
  disabled: !canGoBack,
786
847
  onClick: () => onPageChange(page - 1),
787
848
  type: "button",
788
849
  children: [
789
- /* @__PURE__ */ jsx10("span", {
850
+ /* @__PURE__ */ jsx11("span", {
790
851
  className: "sr-only",
791
852
  children: labels.goToPreviousPage
792
853
  }),
793
- /* @__PURE__ */ jsx10(ChevronLeft, {})
854
+ /* @__PURE__ */ jsx11(ChevronLeft, {})
794
855
  ]
795
856
  }),
796
- /* @__PURE__ */ jsxs5(Button, {
857
+ /* @__PURE__ */ jsxs6(Button, {
797
858
  className: "h-8 w-8 p-0",
798
859
  disabled: !canGoForward,
799
860
  onClick: () => onPageChange(page + 1),
800
861
  type: "button",
801
862
  children: [
802
- /* @__PURE__ */ jsx10("span", {
863
+ /* @__PURE__ */ jsx11("span", {
803
864
  className: "sr-only",
804
865
  children: labels.goToNextPage
805
866
  }),
806
- /* @__PURE__ */ jsx10(ChevronRight, {})
867
+ /* @__PURE__ */ jsx11(ChevronRight, {})
807
868
  ]
808
869
  }),
809
- /* @__PURE__ */ jsxs5(Button, {
870
+ /* @__PURE__ */ jsxs6(Button, {
810
871
  className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
811
872
  disabled: !canGoForward,
812
873
  onClick: () => onPageChange(pageCount - 1),
813
874
  type: "button",
814
875
  children: [
815
- /* @__PURE__ */ jsx10("span", {
876
+ /* @__PURE__ */ jsx11("span", {
816
877
  className: "sr-only",
817
878
  children: labels.goToLastPage
818
879
  }),
819
- /* @__PURE__ */ jsx10(ChevronsRight, {})
880
+ /* @__PURE__ */ jsx11(ChevronsRight, {})
820
881
  ]
821
882
  })
822
883
  ]
@@ -831,24 +892,24 @@ function Pagination({
831
892
 
832
893
  // ../../src/components/ui/scroll-area.tsx
833
894
  import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
834
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
895
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
835
896
  function ScrollArea({
836
897
  className,
837
898
  children,
838
899
  ...props
839
900
  }) {
840
- return /* @__PURE__ */ jsxs6(ScrollAreaPrimitive.Root, {
901
+ return /* @__PURE__ */ jsxs7(ScrollAreaPrimitive.Root, {
841
902
  "data-slot": "scroll-area",
842
903
  className: cn("relative", className),
843
904
  ...props,
844
905
  children: [
845
- /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Viewport, {
906
+ /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Viewport, {
846
907
  "data-slot": "scroll-area-viewport",
847
908
  className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
848
909
  children
849
910
  }),
850
- /* @__PURE__ */ jsx11(ScrollBar, {}),
851
- /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Corner, {})
911
+ /* @__PURE__ */ jsx12(ScrollBar, {}),
912
+ /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Corner, {})
852
913
  ]
853
914
  });
854
915
  }
@@ -857,13 +918,13 @@ function ScrollBar({
857
918
  orientation = "vertical",
858
919
  ...props
859
920
  }) {
860
- return /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Scrollbar, {
921
+ return /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Scrollbar, {
861
922
  "data-slot": "scroll-area-scrollbar",
862
923
  "data-orientation": orientation,
863
924
  orientation,
864
925
  className: cn("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent", className),
865
926
  ...props,
866
- children: /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Thumb, {
927
+ children: /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Thumb, {
867
928
  "data-slot": "scroll-area-thumb",
868
929
  className: "bg-border relative flex-1 rounded-full"
869
930
  })
@@ -871,12 +932,12 @@ function ScrollBar({
871
932
  }
872
933
 
873
934
  // ../../src/components/ui/table.tsx
874
- import { jsx as jsx12 } from "react/jsx-runtime";
935
+ import { jsx as jsx13 } from "react/jsx-runtime";
875
936
  function Table({ className, ...props }) {
876
- return /* @__PURE__ */ jsx12("div", {
937
+ return /* @__PURE__ */ jsx13("div", {
877
938
  "data-slot": "table-container",
878
939
  className: "relative w-full overflow-x-auto",
879
- children: /* @__PURE__ */ jsx12("table", {
940
+ children: /* @__PURE__ */ jsx13("table", {
880
941
  "data-slot": "table",
881
942
  className: cn("w-full caption-bottom text-sm", className),
882
943
  ...props
@@ -884,35 +945,35 @@ function Table({ className, ...props }) {
884
945
  });
885
946
  }
886
947
  function TableHeader({ className, ...props }) {
887
- return /* @__PURE__ */ jsx12("thead", {
948
+ return /* @__PURE__ */ jsx13("thead", {
888
949
  "data-slot": "table-header",
889
950
  className: cn("[&_tr]:border-b", className),
890
951
  ...props
891
952
  });
892
953
  }
893
954
  function TableBody({ className, ...props }) {
894
- return /* @__PURE__ */ jsx12("tbody", {
955
+ return /* @__PURE__ */ jsx13("tbody", {
895
956
  "data-slot": "table-body",
896
957
  className: cn("[&_tr:last-child]:border-0", className),
897
958
  ...props
898
959
  });
899
960
  }
900
961
  function TableRow({ className, ...props }) {
901
- return /* @__PURE__ */ jsx12("tr", {
962
+ return /* @__PURE__ */ jsx13("tr", {
902
963
  "data-slot": "table-row",
903
964
  className: cn("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted", className),
904
965
  ...props
905
966
  });
906
967
  }
907
968
  function TableHead({ className, ...props }) {
908
- return /* @__PURE__ */ jsx12("th", {
969
+ return /* @__PURE__ */ jsx13("th", {
909
970
  "data-slot": "table-head",
910
971
  className: cn("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0", className),
911
972
  ...props
912
973
  });
913
974
  }
914
975
  function TableCell({ className, ...props }) {
915
- return /* @__PURE__ */ jsx12("td", {
976
+ return /* @__PURE__ */ jsx13("td", {
916
977
  "data-slot": "table-cell",
917
978
  className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0", className),
918
979
  ...props
@@ -921,26 +982,26 @@ function TableCell({ className, ...props }) {
921
982
 
922
983
  // ../../src/components/ui/tooltip.tsx
923
984
  import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
924
- import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
985
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
925
986
  "use client";
926
987
  function TooltipProvider({
927
988
  delay = 0,
928
989
  ...props
929
990
  }) {
930
- return /* @__PURE__ */ jsx13(TooltipPrimitive.Provider, {
991
+ return /* @__PURE__ */ jsx14(TooltipPrimitive.Provider, {
931
992
  "data-slot": "tooltip-provider",
932
993
  delay,
933
994
  ...props
934
995
  });
935
996
  }
936
997
  function Tooltip({ ...props }) {
937
- return /* @__PURE__ */ jsx13(TooltipPrimitive.Root, {
998
+ return /* @__PURE__ */ jsx14(TooltipPrimitive.Root, {
938
999
  "data-slot": "tooltip",
939
1000
  ...props
940
1001
  });
941
1002
  }
942
1003
  function TooltipTrigger({ ...props }) {
943
- return /* @__PURE__ */ jsx13(TooltipPrimitive.Trigger, {
1004
+ return /* @__PURE__ */ jsx14(TooltipPrimitive.Trigger, {
944
1005
  "data-slot": "tooltip-trigger",
945
1006
  ...props
946
1007
  });
@@ -954,20 +1015,20 @@ function TooltipContent({
954
1015
  children,
955
1016
  ...props
956
1017
  }) {
957
- return /* @__PURE__ */ jsx13(TooltipPrimitive.Portal, {
958
- children: /* @__PURE__ */ jsx13(TooltipPrimitive.Positioner, {
1018
+ return /* @__PURE__ */ jsx14(TooltipPrimitive.Portal, {
1019
+ children: /* @__PURE__ */ jsx14(TooltipPrimitive.Positioner, {
959
1020
  align,
960
1021
  alignOffset,
961
1022
  side,
962
1023
  sideOffset,
963
1024
  className: "isolate z-50",
964
- children: /* @__PURE__ */ jsxs7(TooltipPrimitive.Popup, {
1025
+ children: /* @__PURE__ */ jsxs8(TooltipPrimitive.Popup, {
965
1026
  "data-slot": "tooltip-content",
966
1027
  className: cn("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
967
1028
  ...props,
968
1029
  children: [
969
1030
  children,
970
- /* @__PURE__ */ jsx13(TooltipPrimitive.Arrow, {
1031
+ /* @__PURE__ */ jsx14(TooltipPrimitive.Arrow, {
971
1032
  className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"
972
1033
  })
973
1034
  ]
@@ -976,14 +1037,181 @@ function TooltipContent({
976
1037
  });
977
1038
  }
978
1039
 
1040
+ // ../../src/lib/query.ts
1041
+ import {
1042
+ DateTime,
1043
+ Effect,
1044
+ Option,
1045
+ Schema,
1046
+ SchemaGetter,
1047
+ SchemaIssue,
1048
+ SchemaTransformation
1049
+ } from "effect";
1050
+ var parseSortParam = (sort) => {
1051
+ const id = sort.startsWith("-") ? sort.slice(1) : sort;
1052
+ if (!id || id.includes(",") || id.includes(":")) {
1053
+ return null;
1054
+ }
1055
+ return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
1056
+ };
1057
+ var SortDirection = Schema.Union([
1058
+ Schema.Literal("asc"),
1059
+ Schema.Literal("desc")
1060
+ ]).pipe(Schema.annotate({
1061
+ identifier: "SortDirection",
1062
+ title: "Sort Direction",
1063
+ description: "Sort direction for list query results.",
1064
+ examples: ["asc", "desc"]
1065
+ }));
1066
+ var SortParam = Schema.Struct({
1067
+ id: Schema.NonEmptyString,
1068
+ direction: SortDirection
1069
+ }).pipe(Schema.annotate({
1070
+ identifier: "SortParam",
1071
+ title: "Sort Parameter",
1072
+ description: "Decoded sort parameter with a field id and direction.",
1073
+ examples: [{ id: "publicName", direction: "asc" }]
1074
+ }));
1075
+ var SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam, SchemaTransformation.transformEffect({
1076
+ decode: (sort) => {
1077
+ const sortParam = parseSortParam(sort);
1078
+ if (!sortParam) {
1079
+ return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field" or "-field"' }, sort));
1080
+ }
1081
+ return Effect.succeed(sortParam);
1082
+ },
1083
+ encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
1084
+ })), Schema.annotate({
1085
+ identifier: "SortParamFromString",
1086
+ title: "Sort Parameter From String",
1087
+ description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
1088
+ examples: [{ id: "publicName", direction: "asc" }]
1089
+ }));
1090
+ var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortParam), SchemaTransformation.transformEffect({
1091
+ decode: (sort) => {
1092
+ if (sort === "")
1093
+ return Effect.succeed([]);
1094
+ const parts = sort.split(",");
1095
+ const sortParams = [];
1096
+ for (const part of parts) {
1097
+ const sortParam = parseSortParam(part);
1098
+ if (!sortParam) {
1099
+ return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field,-otherField"' }, sort));
1100
+ }
1101
+ sortParams.push(sortParam);
1102
+ }
1103
+ return Effect.succeed(sortParams);
1104
+ },
1105
+ encode: (sort) => Effect.succeed(sort.map((part) => Schema.encodeSync(SortParamFromString)(part)).join(","))
1106
+ })), Schema.annotate({
1107
+ identifier: "SortParamsFromString",
1108
+ title: "Sort Parameters From String",
1109
+ description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
1110
+ examples: [
1111
+ [
1112
+ { id: "name", direction: "desc" },
1113
+ { id: "age", direction: "asc" }
1114
+ ]
1115
+ ]
1116
+ }));
1117
+ var SortParamsArray = Schema.Array(SortParam);
1118
+ var SortParams = Schema.declare(Schema.is(SortParamsArray), {
1119
+ identifier: "SortParams",
1120
+ toCodec: () => Schema.link()(SortParamsArray, SchemaTransformation.passthrough()),
1121
+ toCodecStringTree: () => Schema.link()(SortParamsFromString, SchemaTransformation.passthrough())
1122
+ });
1123
+ var TextFilterOperator = Schema.Literals([
1124
+ "contains",
1125
+ "equals",
1126
+ "startsWith",
1127
+ "endsWith"
1128
+ ]).annotate({ identifier: "TextFilterOperator" });
1129
+ var FilterCalendarDate = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
1130
+ var ColumnFilter = Schema.Union([
1131
+ Schema.Struct({
1132
+ id: Schema.NonEmptyString,
1133
+ kind: Schema.Literal("text"),
1134
+ operator: TextFilterOperator,
1135
+ value: Schema.NonEmptyString
1136
+ }),
1137
+ Schema.Struct({
1138
+ id: Schema.NonEmptyString,
1139
+ kind: Schema.Literal("number"),
1140
+ min: Schema.optional(Schema.Finite),
1141
+ max: Schema.optional(Schema.Finite)
1142
+ }).check(Schema.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
1143
+ Schema.Struct({
1144
+ id: Schema.NonEmptyString,
1145
+ kind: Schema.Literal("date"),
1146
+ from: Schema.optional(FilterCalendarDate),
1147
+ to: Schema.optional(FilterCalendarDate)
1148
+ }).check(Schema.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
1149
+ Schema.Struct({
1150
+ id: Schema.NonEmptyString,
1151
+ kind: Schema.Literal("boolean"),
1152
+ value: Schema.Boolean
1153
+ }),
1154
+ Schema.Struct({
1155
+ id: Schema.NonEmptyString,
1156
+ kind: Schema.Literal("values"),
1157
+ values: Schema.NonEmptyArray(Schema.String)
1158
+ })
1159
+ ]).annotate({ identifier: "ColumnFilter" });
1160
+ var ColumnFiltersArray = Schema.Array(ColumnFilter);
1161
+ var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
1162
+ identifier: "ColumnFilters",
1163
+ toCodec: () => Schema.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
1164
+ toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
1165
+ });
1166
+ var Query = Schema.Struct({
1167
+ page: Schema.optional(Schema.Union([Schema.Number, Schema.NumberFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
1168
+ decode: SchemaGetter.withDefault(Effect.succeed(0)),
1169
+ encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
1170
+ })),
1171
+ pageSize: Schema.optional(Schema.Union([Schema.Number, Schema.NumberFromString]).check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })), {
1172
+ decode: SchemaGetter.withDefault(Effect.succeed(20)),
1173
+ encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
1174
+ })),
1175
+ globalFilter: Schema.optional(Schema.String),
1176
+ sort: Schema.optional(SortParams),
1177
+ filters: Schema.optional(ColumnFilters)
1178
+ }).annotate({
1179
+ identifier: "Query",
1180
+ title: "Query",
1181
+ description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
1182
+ examples: [
1183
+ {
1184
+ page: 0,
1185
+ pageSize: 20,
1186
+ globalFilter: "housing",
1187
+ sort: [
1188
+ { id: "publicName", direction: "desc" },
1189
+ { id: "createdAt", direction: "asc" }
1190
+ ]
1191
+ }
1192
+ ]
1193
+ });
1194
+ var QueryStandard = Schema.toStandardSchemaV1(Query);
1195
+ var PaginationMeta = Schema.Struct({
1196
+ page: Schema.Int,
1197
+ pageSize: Schema.Int,
1198
+ total: Schema.Int,
1199
+ pageCount: Schema.Int
1200
+ }).pipe(Schema.annotate({
1201
+ identifier: "PaginationMeta",
1202
+ title: "Pagination Metadata",
1203
+ description: "Pagination metadata returned with a paginated list response.",
1204
+ examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
1205
+ }));
1206
+
979
1207
  // ../../src/components/ui/data-table.tsx
980
1208
  import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
981
- import { jsx as jsx14, jsxs as jsxs8, Fragment } from "react/jsx-runtime";
982
- var DataTablePersistedUiStateSchema = Schema.Struct({
983
- columnVisibility: Schema.Record(Schema.String, Schema.Boolean),
984
- columnSizing: Schema.Record(Schema.String, Schema.Number),
985
- grouping: Schema.optionalKey(Schema.Array(Schema.String)),
986
- view: Schema.Literals(["table", "gallery"])
1209
+ import { jsx as jsx15, jsxs as jsxs9, Fragment } from "react/jsx-runtime";
1210
+ var DataTablePersistedUiStateSchema = Schema2.Struct({
1211
+ columnVisibility: Schema2.Record(Schema2.String, Schema2.Boolean),
1212
+ columnSizing: Schema2.Record(Schema2.String, Schema2.Number),
1213
+ grouping: Schema2.optionalKey(Schema2.Array(Schema2.String)),
1214
+ view: Schema2.Literals(["table", "gallery"])
987
1215
  }).annotate({ identifier: "DataTablePersistedUiState" });
988
1216
  var dataTableStorageRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
989
1217
  var DataTableReferenceCell = ({
@@ -995,29 +1223,29 @@ var DataTableReferenceCell = ({
995
1223
  if (!item)
996
1224
  return emptyLabel;
997
1225
  const initials = item.label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
998
- return /* @__PURE__ */ jsxs8("div", {
1226
+ return /* @__PURE__ */ jsxs9("div", {
999
1227
  className: "flex min-w-0 items-center gap-2",
1000
1228
  children: [
1001
- /* @__PURE__ */ jsx14("div", {
1229
+ /* @__PURE__ */ jsx15("div", {
1002
1230
  className: cn("bg-muted flex size-8 shrink-0 items-center justify-center overflow-hidden text-xs font-medium", imageVariant === "circle" ? "rounded-full" : "rounded-md"),
1003
- children: item.imageSrc && item.imageSrc !== failedImage ? /* @__PURE__ */ jsx14("img", {
1231
+ children: item.imageSrc && item.imageSrc !== failedImage ? /* @__PURE__ */ jsx15("img", {
1004
1232
  src: item.imageSrc,
1005
1233
  alt: item.label,
1006
1234
  className: "size-full object-cover",
1007
1235
  onError: () => setFailedImage(item.imageSrc ?? undefined)
1008
- }) : /* @__PURE__ */ jsx14("span", {
1236
+ }) : /* @__PURE__ */ jsx15("span", {
1009
1237
  "aria-hidden": "true",
1010
1238
  children: initials
1011
1239
  })
1012
1240
  }),
1013
- /* @__PURE__ */ jsxs8("div", {
1241
+ /* @__PURE__ */ jsxs9("div", {
1014
1242
  className: "flex min-w-0 flex-col leading-tight",
1015
1243
  children: [
1016
- /* @__PURE__ */ jsx14("span", {
1244
+ /* @__PURE__ */ jsx15("span", {
1017
1245
  className: "truncate font-medium",
1018
1246
  children: item.label
1019
1247
  }),
1020
- item.description ? /* @__PURE__ */ jsx14("span", {
1248
+ item.description ? /* @__PURE__ */ jsx15("span", {
1021
1249
  className: "text-muted-foreground truncate text-xs",
1022
1250
  children: item.description
1023
1251
  }) : null
@@ -1035,6 +1263,23 @@ var messages2 = {
1035
1263
  empty: "No results.",
1036
1264
  loading: "Loading...",
1037
1265
  filter: "Filter results...",
1266
+ filters: "Filters",
1267
+ filtersClear: "Clear all filters",
1268
+ filterClear: "Clear filter",
1269
+ filterApply: "Apply filter",
1270
+ filterValue: "Value",
1271
+ filterOperator: "Operator",
1272
+ filterContains: "Contains",
1273
+ filterEquals: "Equals",
1274
+ filterStartsWith: "Starts with",
1275
+ filterEndsWith: "Ends with",
1276
+ filterMin: "Minimum",
1277
+ filterMax: "Maximum",
1278
+ filterFrom: "From (UTC)",
1279
+ filterTo: "To (UTC)",
1280
+ filterTrue: "True",
1281
+ filterFalse: "False",
1282
+ filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
1038
1283
  export: "Export",
1039
1284
  exportCsv: "CSV",
1040
1285
  exportJson: "JSON",
@@ -1067,6 +1312,23 @@ var messages2 = {
1067
1312
  empty: "Aucun résultat.",
1068
1313
  loading: "Chargement...",
1069
1314
  filter: "Filtrer les résultats...",
1315
+ filters: "Filtres",
1316
+ filtersClear: "Effacer tous les filtres",
1317
+ filterClear: "Effacer le filtre",
1318
+ filterApply: "Appliquer le filtre",
1319
+ filterValue: "Valeur",
1320
+ filterOperator: "Opérateur",
1321
+ filterContains: "Contient",
1322
+ filterEquals: "Égal à",
1323
+ filterStartsWith: "Commence par",
1324
+ filterEndsWith: "Se termine par",
1325
+ filterMin: "Minimum",
1326
+ filterMax: "Maximum",
1327
+ filterFrom: "Du (UTC)",
1328
+ filterTo: "Au (UTC)",
1329
+ filterTrue: "Vrai",
1330
+ filterFalse: "Faux",
1331
+ filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
1070
1332
  export: "Exporter",
1071
1333
  exportCsv: "CSV",
1072
1334
  exportJson: "JSON",
@@ -1126,7 +1388,7 @@ var transientUiFromState = (state) => ({
1126
1388
  var clampWidth = (column, width) => Math.min(column.maxWidth ?? DEFAULT_MAX_WIDTH, Math.max(column.minWidth ?? DEFAULT_MIN_WIDTH, width));
1127
1389
  var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
1128
1390
  const ids = new Set;
1129
- return columnDefs.map((colDef) => {
1391
+ const columns = columnDefs.map((colDef) => {
1130
1392
  const id = colDef.field ?? colDef.colId;
1131
1393
  if (!id) {
1132
1394
  throw new Error("DataTable columns require a field or colId");
@@ -1141,7 +1403,24 @@ var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
1141
1403
  width: clampWidth(colDef, columnSizing[id] ?? colDef.width ?? DEFAULT_WIDTH)
1142
1404
  };
1143
1405
  });
1406
+ for (const column of columns) {
1407
+ for (const field of column.colDef.fields ?? []) {
1408
+ const id = `${column.id}.${field.id}`;
1409
+ if (!field.id || ids.has(id)) {
1410
+ throw new Error(`DataTable field IDs must be nonempty and unique: ${id}`);
1411
+ }
1412
+ ids.add(id);
1413
+ }
1414
+ }
1415
+ return columns;
1144
1416
  };
1417
+ var getDataTableFieldColumns = (column) => (column.colDef.fields ?? []).map(({ id, export: _export, ...colDef }) => ({
1418
+ id: `${column.id}.${id}`,
1419
+ colDef: { ...colDef, colId: `${column.id}.${id}` },
1420
+ width: column.width
1421
+ }));
1422
+ var getDataTableSortColumns = (columns) => columns.flatMap((column) => column.colDef.sortable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.sortable !== false));
1423
+ var getDataTableExportColumns = (visibleColumns) => visibleColumns.flatMap((column) => column.colDef.fields?.length ? getDataTableFieldColumns(column).filter((_field, index) => column.colDef.fields?.[index]?.export !== false) : [column]);
1145
1424
  var getDataTableWidth = (columns, utilityColumns = 0) => columns.reduce((total, column) => total + column.width, 0) + utilityColumns * 40;
1146
1425
  var buildDataTableRows = (rowData, columns, getRowId) => {
1147
1426
  const ids = new Set;
@@ -1154,7 +1433,7 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
1154
1433
  id,
1155
1434
  data,
1156
1435
  index,
1157
- values: new Map(columns.map((column) => {
1436
+ values: new Map(columns.flatMap((column) => [column, ...getDataTableFieldColumns(column)]).map((column) => {
1158
1437
  const { colDef } = column;
1159
1438
  const value = colDef.valueGetter ? colDef.valueGetter({ data, rowId: id, rowIndex: index, colDef }) : colDef.type === "list" ? colDef.typeOptions.getItems(data).map((item) => item.label).join(", ") : colDef.type === "reference" ? referenceText(colDef.typeOptions.getItem(data)) : colDef.field ? data[colDef.field] : undefined;
1160
1439
  return [column.id, value];
@@ -1162,40 +1441,40 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
1162
1441
  };
1163
1442
  });
1164
1443
  };
1165
- var CalendarDate = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "DataTableCalendarDate" });
1166
- var InstantString = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/), Schema.makeFilter((value) => Schema.is(CalendarDate)(value.slice(0, 10)))).annotate({ identifier: "DataTableInstantString" });
1167
- var DateInput = Schema.Union([
1168
- Schema.Date,
1169
- Schema.Int,
1444
+ var CalendarDate = Schema2.String.check(Schema2.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema2.makeFilter((value) => Option2.exists(DateTime2.make(value), (date) => DateTime2.formatIsoDateUtc(date) === value))).annotate({ identifier: "DataTableCalendarDate" });
1445
+ var InstantString = Schema2.String.check(Schema2.isPattern(/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/), Schema2.makeFilter((value) => Schema2.is(CalendarDate)(value.slice(0, 10)))).annotate({ identifier: "DataTableInstantString" });
1446
+ var DateInput = Schema2.Union([
1447
+ Schema2.Date,
1448
+ Schema2.Int,
1170
1449
  CalendarDate,
1171
1450
  InstantString
1172
1451
  ]).annotate({ identifier: "DataTableDateInput" });
1173
- var decodeDateInput = Schema.decodeUnknownOption(DateInput);
1174
- var resolveDate = (value, type) => Option.getOrUndefined(Option.flatMap(decodeDateInput(value), (input) => {
1175
- const calendarOnly = Schema.is(CalendarDate)(input);
1452
+ var decodeDateInput = Schema2.decodeUnknownOption(DateInput);
1453
+ var resolveDate = (value, type) => Option2.getOrUndefined(Option2.flatMap(decodeDateInput(value), (input) => {
1454
+ const calendarOnly = Schema2.is(CalendarDate)(input);
1176
1455
  if (calendarOnly && type === "dateTime")
1177
- return Option.none();
1178
- return Option.map(DateTime.make(input), (instant) => ({
1456
+ return Option2.none();
1457
+ return Option2.map(DateTime2.make(input), (instant) => ({
1179
1458
  instant,
1180
1459
  calendarOnly
1181
1460
  }));
1182
1461
  }));
1183
- var formatDateValue = (date, column, locale = "en") => DateTime.format(date.instant, {
1462
+ var formatDateValue = (date, column, locale = "en") => DateTime2.format(date.instant, {
1184
1463
  locale: column.typeOptions?.locale ?? locale,
1185
1464
  timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
1186
1465
  dateStyle: column.typeOptions?.dateStyle ?? "medium",
1187
1466
  timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
1188
1467
  hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
1189
1468
  });
1190
- var dateIsoValue = (date) => date.calendarOnly ? DateTime.formatIsoDateUtc(date.instant) : DateTime.formatIso(date.instant);
1191
- var NumberValue = Schema.Finite.annotate({
1469
+ var dateIsoValue = (date) => date.calendarOnly ? DateTime2.formatIsoDateUtc(date.instant) : DateTime2.formatIso(date.instant);
1470
+ var NumberValue = Schema2.Finite.annotate({
1192
1471
  identifier: "DataTableNumberValue"
1193
1472
  });
1194
- var BooleanValue = Schema.Boolean.annotate({
1473
+ var BooleanValue = Schema2.Boolean.annotate({
1195
1474
  identifier: "DataTableBooleanValue"
1196
1475
  });
1197
- var decodeNumberValue = Schema.decodeUnknownOption(NumberValue);
1198
- var decodeBooleanValue = Schema.decodeUnknownOption(BooleanValue);
1476
+ var decodeNumberValue = Schema2.decodeUnknownOption(NumberValue);
1477
+ var decodeBooleanValue = Schema2.decodeUnknownOption(BooleanValue);
1199
1478
  var formatNumberValue = (value, options = {}, defaultLocale = "en") => {
1200
1479
  const {
1201
1480
  locale,
@@ -1211,13 +1490,13 @@ var getDataTableExportValue = (row, column, locale = "en") => {
1211
1490
  const value = row.values.get(column.id);
1212
1491
  const colDef = column.colDef;
1213
1492
  if (colDef.type === "number") {
1214
- const number = Option.getOrUndefined(decodeNumberValue(value));
1493
+ const number = Option2.getOrUndefined(decodeNumberValue(value));
1215
1494
  if (number === undefined)
1216
1495
  return null;
1217
1496
  return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions, locale) : number;
1218
1497
  }
1219
1498
  if (colDef.type === "boolean") {
1220
- const boolean = Option.getOrUndefined(decodeBooleanValue(value));
1499
+ const boolean = Option2.getOrUndefined(decodeBooleanValue(value));
1221
1500
  if (boolean === undefined)
1222
1501
  return null;
1223
1502
  return colDef.typeOptions?.exportFormat === "formatted" ? booleanLabel(boolean, colDef.typeOptions) ?? String(boolean) : boolean;
@@ -1233,7 +1512,7 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
1233
1512
  const query = globalFilter.trim().toLocaleLowerCase();
1234
1513
  if (!query)
1235
1514
  return [...rows];
1236
- const searchable = columns.filter(({ colDef }) => colDef.searchable !== false);
1515
+ const searchable = columns.flatMap((column) => column.colDef.searchable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.searchable !== false));
1237
1516
  return rows.filter((row) => searchable.some((column) => {
1238
1517
  const value = row.values.get(column.id);
1239
1518
  const colDef = column.colDef;
@@ -1242,17 +1521,86 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
1242
1521
  const date = resolveDate(value, colDef.type);
1243
1522
  text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
1244
1523
  } else if (colDef.type === "number") {
1245
- const number = Option.getOrUndefined(decodeNumberValue(value));
1524
+ const number = Option2.getOrUndefined(decodeNumberValue(value));
1246
1525
  text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions, locale)} ${number}`;
1247
1526
  } else if (colDef.type === "boolean") {
1248
- const boolean = Option.getOrUndefined(decodeBooleanValue(value));
1527
+ const boolean = Option2.getOrUndefined(decodeBooleanValue(value));
1249
1528
  text = boolean === undefined ? "" : `${booleanLabel(boolean, colDef.typeOptions) ?? ""} ${boolean}`;
1250
1529
  }
1251
1530
  return text.toLocaleLowerCase().includes(query);
1252
1531
  }));
1253
1532
  };
1533
+ var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
1534
+ var getDataTableFilterKind = ({
1535
+ colDef
1536
+ }) => colDef.filterOptions || colDef.type === "list" ? "values" : colDef.type === "number" ? "number" : colDef.type === "date" || colDef.type === "dateTime" ? "date" : colDef.type === "boolean" ? "boolean" : "text";
1537
+ var getDataTableFilterOptions = (rows, column) => {
1538
+ const { colDef } = column;
1539
+ if (colDef.filterOptions)
1540
+ return colDef.filterOptions;
1541
+ const options = new Map;
1542
+ if (colDef.type === "list") {
1543
+ for (const row of rows) {
1544
+ for (const item of colDef.typeOptions.getItems(row.data)) {
1545
+ const value = item.value ?? item.label;
1546
+ options.set(value, { value, label: item.label });
1547
+ }
1548
+ }
1549
+ }
1550
+ return [...options.values()].sort((left, right) => left.label.localeCompare(right.label));
1551
+ };
1552
+ var filterDataTableColumnRows = (rows, columns, filters) => {
1553
+ const byId = new Map(getDataTableFilterColumns(columns).map((column) => [column.id, column]));
1554
+ return rows.filter((row) => filters.every((filter) => {
1555
+ const column = byId.get(filter.id);
1556
+ if (!column || getDataTableFilterKind(column) !== filter.kind)
1557
+ return true;
1558
+ const value = column.colDef.filterValueGetter ? column.colDef.filterValueGetter({
1559
+ data: row.data,
1560
+ rowId: row.id,
1561
+ rowIndex: row.index,
1562
+ colDef: column.colDef
1563
+ }) : row.values.get(column.id);
1564
+ switch (filter.kind) {
1565
+ case "text": {
1566
+ const text = String(value ?? "").toLocaleLowerCase();
1567
+ const query = filter.value.toLocaleLowerCase();
1568
+ switch (filter.operator) {
1569
+ case "contains":
1570
+ return text.includes(query);
1571
+ case "equals":
1572
+ return text === query;
1573
+ case "startsWith":
1574
+ return text.startsWith(query);
1575
+ case "endsWith":
1576
+ return text.endsWith(query);
1577
+ }
1578
+ }
1579
+ case "number": {
1580
+ const number = Option2.getOrUndefined(decodeNumberValue(value));
1581
+ return number !== undefined && (filter.min === undefined || number >= filter.min) && (filter.max === undefined || number <= filter.max);
1582
+ }
1583
+ case "date": {
1584
+ const date = resolveDate(value, column.colDef.type === "dateTime" ? "dateTime" : "date");
1585
+ if (!date)
1586
+ return false;
1587
+ const day = DateTime2.formatIsoDateUtc(date.instant);
1588
+ return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
1589
+ }
1590
+ case "boolean":
1591
+ return Option2.getOrUndefined(decodeBooleanValue(value)) === filter.value;
1592
+ case "values": {
1593
+ const values = column.colDef.type === "list" ? column.colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [String(value ?? "")];
1594
+ return filter.values.some((selected) => values.includes(selected));
1595
+ }
1596
+ }
1597
+ }));
1598
+ };
1254
1599
  var sortDataTableRows = (rows, columns, sorting) => {
1255
- const byId = new Map(columns.map((column) => [column.id, column]));
1600
+ const byId = new Map([...columns, ...getDataTableSortColumns(columns)].map((column) => [
1601
+ column.id,
1602
+ column
1603
+ ]));
1256
1604
  return rows.map((row, stableIndex) => ({ row, stableIndex })).sort((left, right) => {
1257
1605
  for (const sort of sorting) {
1258
1606
  const column = byId.get(sort.id);
@@ -1262,8 +1610,8 @@ var sortDataTableRows = (rows, columns, sorting) => {
1262
1610
  const rightValue = right.row.values.get(sort.id);
1263
1611
  const colDef = column.colDef;
1264
1612
  if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean")) {
1265
- const leftScalar = colDef.type === "number" ? Option.getOrUndefined(decodeNumberValue(leftValue)) : Option.getOrUndefined(Option.map(decodeBooleanValue(leftValue), Number));
1266
- const rightScalar = colDef.type === "number" ? Option.getOrUndefined(decodeNumberValue(rightValue)) : Option.getOrUndefined(Option.map(decodeBooleanValue(rightValue), Number));
1613
+ const leftScalar = colDef.type === "number" ? Option2.getOrUndefined(decodeNumberValue(leftValue)) : Option2.getOrUndefined(Option2.map(decodeBooleanValue(leftValue), Number));
1614
+ const rightScalar = colDef.type === "number" ? Option2.getOrUndefined(decodeNumberValue(rightValue)) : Option2.getOrUndefined(Option2.map(decodeBooleanValue(rightValue), Number));
1267
1615
  if (leftScalar === undefined || rightScalar === undefined) {
1268
1616
  if (leftScalar === undefined && rightScalar === undefined)
1269
1617
  continue;
@@ -1284,12 +1632,12 @@ var sortDataTableRows = (rows, columns, sorting) => {
1284
1632
  const nullOrder = colDef.typeOptions?.nulls === "first" ? -1 : 1;
1285
1633
  return !leftDate ? nullOrder : -nullOrder;
1286
1634
  }
1287
- const comparison = DateTime.toEpochMillis(leftDate.instant) - DateTime.toEpochMillis(rightDate.instant);
1635
+ const comparison = DateTime2.toEpochMillis(leftDate.instant) - DateTime2.toEpochMillis(rightDate.instant);
1288
1636
  if (comparison !== 0)
1289
1637
  return sort.direction === "desc" ? -comparison : comparison;
1290
1638
  continue;
1291
1639
  }
1292
- const comparison = column.colDef.comparator ? column.colDef.comparator(leftValue, rightValue, left.row.data, right.row.data) : Object.is(leftValue, rightValue) ? 0 : leftValue === null || leftValue === undefined ? 1 : rightValue === null || rightValue === undefined ? -1 : Schema.is(Schema.Number)(leftValue) && Schema.is(Schema.Number)(rightValue) ? leftValue - rightValue : String(leftValue).localeCompare(String(rightValue), undefined, { numeric: true, sensitivity: "base" });
1640
+ const comparison = column.colDef.comparator ? column.colDef.comparator(leftValue, rightValue, left.row.data, right.row.data) : Object.is(leftValue, rightValue) ? 0 : leftValue === null || leftValue === undefined ? 1 : rightValue === null || rightValue === undefined ? -1 : Schema2.is(Schema2.Number)(leftValue) && Schema2.is(Schema2.Number)(rightValue) ? leftValue - rightValue : String(leftValue).localeCompare(String(rightValue), undefined, { numeric: true, sensitivity: "base" });
1293
1641
  if (comparison !== 0)
1294
1642
  return sort.direction === "desc" ? -comparison : comparison;
1295
1643
  }
@@ -1303,7 +1651,7 @@ var paginateDataTableRows = (rows, pagination) => {
1303
1651
  const start = pageIndex * pageSize;
1304
1652
  return rows.slice(start, start + pageSize);
1305
1653
  };
1306
- var sameDataTableState = (left, right) => left.page === right.page && left.pageSize === right.pageSize && left.globalFilter === right.globalFilter && left.sort === right.sort && left.columnVisibility === right.columnVisibility && left.columnSizing === right.columnSizing && left.rowSelection === right.rowSelection && left.grouping === right.grouping && left.collapsedGroups === right.collapsedGroups && left.view === right.view;
1654
+ var sameDataTableState = (left, right) => left.page === right.page && left.pageSize === right.pageSize && left.globalFilter === right.globalFilter && left.filters === right.filters && left.sort === right.sort && left.columnVisibility === right.columnVisibility && left.columnSizing === right.columnSizing && left.rowSelection === right.rowSelection && left.grouping === right.grouping && left.collapsedGroups === right.collapsedGroups && left.view === right.view;
1307
1655
  var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
1308
1656
  const sourceIndex = rows.findIndex((row) => row.id === sourceRowId);
1309
1657
  const targetIndex = rows.findIndex((row) => row.id === targetRowId);
@@ -1371,6 +1719,7 @@ var queryFromState = (state) => ({
1371
1719
  page: state.page,
1372
1720
  pageSize: state.pageSize,
1373
1721
  globalFilter: state.globalFilter,
1722
+ filters: state.filters,
1374
1723
  sort: state.sort
1375
1724
  });
1376
1725
  var uiFromState = (state) => ({
@@ -1382,7 +1731,7 @@ var uiFromState = (state) => ({
1382
1731
  view: state.view
1383
1732
  });
1384
1733
  var sameUiState = (left, right) => left.columnVisibility === right.columnVisibility && left.columnSizing === right.columnSizing && left.rowSelection === right.rowSelection && left.grouping === right.grouping && left.collapsedGroups === right.collapsedGroups && left.view === right.view;
1385
- var sameQueryState = (left, right) => left.page === right.page && left.pageSize === right.pageSize && left.globalFilter === right.globalFilter && left.sort === right.sort;
1734
+ var sameQueryState = (left, right) => left.page === right.page && left.pageSize === right.pageSize && left.globalFilter === right.globalFilter && left.filters === right.filters && left.sort === right.sort;
1386
1735
  var initialPublicState = (props, uiState) => ({
1387
1736
  ...queryFromState(props.state ?? { ...DEFAULT_QUERY, ...props.initialState }),
1388
1737
  ...uiState
@@ -1394,7 +1743,7 @@ var buildDataTableModel = (store) => {
1394
1743
  const rows = buildDataTableRows(store.rowData, columns, rowId);
1395
1744
  const pagination = store.config.features.pagination ?? { mode: "client" };
1396
1745
  const server = pagination !== false && pagination.mode === "server";
1397
- const filteredRows = server ? [...rows] : filterDataTableRows(rows, columns, store.state.globalFilter ?? "", store.config.locale);
1746
+ const filteredRows = server ? [...rows] : filterDataTableColumnRows(filterDataTableRows(rows, columns, store.state.globalFilter ?? "", store.config.locale), columns, store.state.filters ?? []);
1398
1747
  const sortedRows = server ? filteredRows : sortDataTableRows(filteredRows, columns, store.state.sort ?? []);
1399
1748
  const pageRows = pagination === false || server ? sortedRows : paginateDataTableRows(sortedRows, store.state);
1400
1749
  const totalRows = server ? pagination.rowCount : sortedRows.length;
@@ -1466,7 +1815,7 @@ var getActiveGrouping = (store) => {
1466
1815
  };
1467
1816
  var canReorderRows = (store) => {
1468
1817
  const pagination = store.config.features.pagination;
1469
- return !!store.config.features.reordering && !getActiveGrouping(store).length && !store.state.globalFilter && !store.state.sort?.length && !(pagination && pagination.mode === "server");
1818
+ return !!store.config.features.reordering && !getActiveGrouping(store).length && !store.state.globalFilter && !store.state.filters?.length && !store.state.sort?.length && !(pagination && pagination.mode === "server");
1470
1819
  };
1471
1820
  var canMoveRowsToGroups = (store) => getActiveGrouping(store).some((field) => !!field.onMoveToGroup);
1472
1821
  var canDragRows = (store) => getActiveGrouping(store).length ? canMoveRowsToGroups(store) : canReorderRows(store);
@@ -1483,14 +1832,14 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1483
1832
  };
1484
1833
  const CellRenderer = column.colDef.cellRenderer;
1485
1834
  if (CellRenderer)
1486
- return /* @__PURE__ */ jsx14(CellRenderer, {
1835
+ return /* @__PURE__ */ jsx15(CellRenderer, {
1487
1836
  ...params
1488
1837
  });
1489
1838
  const colDef = column.colDef;
1490
1839
  if (colDef.type === "reference") {
1491
1840
  if (colDef.valueFormatter)
1492
1841
  return colDef.valueFormatter(params);
1493
- return /* @__PURE__ */ jsx14(DataTableReferenceCell, {
1842
+ return /* @__PURE__ */ jsx15(DataTableReferenceCell, {
1494
1843
  item: colDef.typeOptions.getItem(row.data),
1495
1844
  emptyLabel: colDef.typeOptions.emptyLabel,
1496
1845
  imageVariant: colDef.typeOptions.imageVariant
@@ -1499,8 +1848,8 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1499
1848
  if (colDef.type === "number") {
1500
1849
  if (colDef.valueFormatter)
1501
1850
  return colDef.valueFormatter(params);
1502
- const number = Option.getOrUndefined(decodeNumberValue(value));
1503
- return /* @__PURE__ */ jsx14("span", {
1851
+ const number = Option2.getOrUndefined(decodeNumberValue(value));
1852
+ return /* @__PURE__ */ jsx15("span", {
1504
1853
  className: "block text-left tabular-nums",
1505
1854
  children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions, locale)
1506
1855
  });
@@ -1508,16 +1857,16 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1508
1857
  if (colDef.type === "boolean") {
1509
1858
  if (colDef.valueFormatter)
1510
1859
  return colDef.valueFormatter(params);
1511
- const boolean = Option.getOrUndefined(decodeBooleanValue(value));
1860
+ const boolean = Option2.getOrUndefined(decodeBooleanValue(value));
1512
1861
  if (boolean === undefined)
1513
1862
  return colDef.typeOptions?.emptyLabel ?? "—";
1514
1863
  const options = colDef.typeOptions;
1515
- return /* @__PURE__ */ jsx14("label", {
1864
+ return /* @__PURE__ */ jsx15("label", {
1516
1865
  "data-slot": "data-table-boolean-cell",
1517
- className: cn("flex min-h-16 w-full items-center justify-start border border-transparent px-2 outline-none focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 focus-within:ring-inset in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0", options?.onChange && !options.disabled?.(row.data) && "cursor-pointer hover:bg-muted/50"),
1866
+ className: cn("focus-within:border-ring focus-within:ring-ring/50 flex min-h-16 w-full items-center justify-start border border-transparent px-2 outline-none focus-within:ring-3 focus-within:ring-inset in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0", options?.onChange && !options.disabled?.(row.data) && "hover:bg-muted/50 cursor-pointer"),
1518
1867
  onClick: (event) => event.stopPropagation(),
1519
1868
  onPointerDown: (event) => event.stopPropagation(),
1520
- children: /* @__PURE__ */ jsx14(Checkbox, {
1869
+ children: /* @__PURE__ */ jsx15(Checkbox, {
1521
1870
  "aria-label": options?.getAriaLabel?.(row.data) ?? columnLabel(column),
1522
1871
  className: "focus-visible:ring-0 focus-visible:outline-none",
1523
1872
  checked: boolean,
@@ -1531,7 +1880,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1531
1880
  if (colDef.valueFormatter)
1532
1881
  return colDef.valueFormatter(params);
1533
1882
  const date = resolveDate(value, colDef.type);
1534
- return date ? /* @__PURE__ */ jsx14("time", {
1883
+ return date ? /* @__PURE__ */ jsx15("time", {
1535
1884
  dateTime: dateIsoValue(date),
1536
1885
  children: formatDateValue(date, colDef, locale)
1537
1886
  }) : colDef.typeOptions?.emptyLabel ?? "—";
@@ -1545,7 +1894,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1545
1894
  disabled: (item) => action.disabled?.({ item, row: row.data }) ?? false
1546
1895
  }));
1547
1896
  if (config.getOptions) {
1548
- return /* @__PURE__ */ jsx14(DataTableListCell, {
1897
+ return /* @__PURE__ */ jsx15(DataTableListCell, {
1549
1898
  ...config,
1550
1899
  itemActions,
1551
1900
  onItemClick: config.onItemClick ? (item) => config.onItemClick?.({ item, row: row.data }) : undefined,
@@ -1558,7 +1907,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1558
1907
  onRemove: config.onRemove ? (value) => config.onRemove?.({ value, row: row.data }) : undefined
1559
1908
  });
1560
1909
  }
1561
- return /* @__PURE__ */ jsx14(DataTableListCell, {
1910
+ return /* @__PURE__ */ jsx15(DataTableListCell, {
1562
1911
  ...config,
1563
1912
  itemActions,
1564
1913
  onItemClick: config.onItemClick ? (item) => config.onItemClick?.({ item, row: row.data }) : undefined,
@@ -1571,25 +1920,19 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1571
1920
  return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : String(value));
1572
1921
  };
1573
1922
  var nodeText = (node) => {
1574
- if (Schema.is(Schema.String)(node) || Schema.is(Schema.Number)(node))
1923
+ if (Schema2.is(Schema2.String)(node) || Schema2.is(Schema2.Number)(node))
1575
1924
  return String(node);
1576
1925
  if (!isValidElement(node))
1577
1926
  return "";
1578
- if (Schema.is(Schema.String)(node.props.title))
1927
+ if (Schema2.is(Schema2.String)(node.props.title))
1579
1928
  return node.props.title;
1580
1929
  return nodeText(node.props.children);
1581
1930
  };
1582
1931
  var columnLabel = (column) => nodeText(column.colDef.headerName) || column.id;
1583
1932
  var withExtension = (fileName, extension) => fileName.includes(".") ? fileName.replace(/\.[^/.]+$/, `.${extension}`) : `${fileName}.${extension}`;
1584
- var escapeCsvValue = (value) => {
1585
- if (value === null || value === undefined)
1586
- return "";
1587
- const text = String(value);
1588
- return /[",\n]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text;
1589
- };
1590
1933
  var downloadCsv = (headers, data, fileName = "data.csv") => {
1591
- const content = [headers, ...data].map((row) => row.map(escapeCsvValue).join(",")).join(`
1592
- `);
1934
+ const content = Effect2.runSync(Stream.fromIterable([headers, ...data]).pipe(Stream.map((row) => row.map((value) => value == null ? "" : String(value))), Stream.pipeThroughChannel(Csv.encodeString({ newline: `
1935
+ ` })), Stream.runCollect, Effect2.map((parts) => parts.join("").slice(0, -1))));
1593
1936
  downloadBlob(content, "text/csv;charset=utf-8", withExtension(fileName, "csv"));
1594
1937
  };
1595
1938
  var downloadJson = (data, fileName = "data.json") => downloadBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", withExtension(fileName, "json"));
@@ -1611,33 +1954,33 @@ var DataTableRowActions = ({
1611
1954
  const visible = actions.filter((action) => !action.visible || action.visible(row));
1612
1955
  if (!visible.length)
1613
1956
  return null;
1614
- return /* @__PURE__ */ jsxs8(DropdownMenu, {
1957
+ return /* @__PURE__ */ jsxs9(DropdownMenu, {
1615
1958
  children: [
1616
- /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
1959
+ /* @__PURE__ */ jsx15(DropdownMenuTrigger, {
1617
1960
  onClick: (event) => event.stopPropagation(),
1618
- render: /* @__PURE__ */ jsxs8(Button, {
1961
+ render: /* @__PURE__ */ jsxs9(Button, {
1619
1962
  className: "size-8 focus-visible:ring-inset [&_svg:not([class*='size-'])]:size-4",
1620
1963
  size: "icon",
1621
1964
  variant: "ghost",
1622
1965
  children: [
1623
- /* @__PURE__ */ jsx14("span", {
1966
+ /* @__PURE__ */ jsx15("span", {
1624
1967
  className: "sr-only",
1625
1968
  children: title
1626
1969
  }),
1627
- /* @__PURE__ */ jsx14(MoreHorizontal, {})
1970
+ /* @__PURE__ */ jsx15(MoreHorizontal, {})
1628
1971
  ]
1629
1972
  })
1630
1973
  }),
1631
- /* @__PURE__ */ jsx14(DropdownMenuContent, {
1974
+ /* @__PURE__ */ jsx15(DropdownMenuContent, {
1632
1975
  align: "end",
1633
1976
  className: "w-max",
1634
- children: /* @__PURE__ */ jsxs8(DropdownMenuGroup, {
1977
+ children: /* @__PURE__ */ jsxs9(DropdownMenuGroup, {
1635
1978
  children: [
1636
- /* @__PURE__ */ jsx14(DropdownMenuLabel, {
1979
+ /* @__PURE__ */ jsx15(DropdownMenuLabel, {
1637
1980
  children: title
1638
1981
  }),
1639
- /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}),
1640
- visible.map((action) => /* @__PURE__ */ jsxs8(DropdownMenuItem, {
1982
+ /* @__PURE__ */ jsx15(DropdownMenuSeparator, {}),
1983
+ visible.map((action) => /* @__PURE__ */ jsxs9(DropdownMenuItem, {
1641
1984
  onClick: (event) => {
1642
1985
  event.stopPropagation();
1643
1986
  action.onClick(row);
@@ -1674,7 +2017,7 @@ var DataTableRowActionMenu = ({
1674
2017
  reorderActions.push({
1675
2018
  id: "data-table-move-up",
1676
2019
  name: store.config.labels.moveUp,
1677
- icon: /* @__PURE__ */ jsx14(ArrowUp, {}),
2020
+ icon: /* @__PURE__ */ jsx15(ArrowUp, {}),
1678
2021
  onClick: () => move(rowIndex - 1)
1679
2022
  });
1680
2023
  }
@@ -1682,12 +2025,12 @@ var DataTableRowActionMenu = ({
1682
2025
  reorderActions.push({
1683
2026
  id: "data-table-move-down",
1684
2027
  name: store.config.labels.moveDown,
1685
- icon: /* @__PURE__ */ jsx14(ArrowDown, {}),
2028
+ icon: /* @__PURE__ */ jsx15(ArrowDown, {}),
1686
2029
  onClick: () => move(rowIndex + 1)
1687
2030
  });
1688
2031
  }
1689
2032
  }
1690
- return /* @__PURE__ */ jsx14(DataTableRowActions, {
2033
+ return /* @__PURE__ */ jsx15(DataTableRowActions, {
1691
2034
  actions: [...reorderActions, ...rowActions ? rowActions.items : []],
1692
2035
  row: row.data,
1693
2036
  title: rowActions?.label ?? store.config.labels.actions
@@ -1706,12 +2049,13 @@ var DataTableToolbar = ({
1706
2049
  const grouping = features.grouping;
1707
2050
  const toolbar = features.toolbar;
1708
2051
  const bulkActions = features.selection && features.selection.bulkActions;
1709
- const hasToolbar = !!toolbar || features.search !== false || features.sorting !== false || features.columnVisibility !== false || !!features.export || !!features.gallery || !!grouping || !!features.refresh || !!bulkActions && selectedRows.length > 0;
2052
+ const hasToolbar = !!toolbar || features.search !== false || features.filtering !== false || features.sorting !== false || features.columnVisibility !== false || !!features.export || !!features.gallery || !!grouping || !!features.refresh || !!bulkActions && selectedRows.length > 0;
1710
2053
  if (!hasToolbar)
1711
2054
  return null;
1712
2055
  const update = (next) => changeState(setStore, next);
1713
2056
  const visibleBulkActions = bulkActions ? bulkActions.items.filter((action) => !action.visible || action.visible(selectedRows)) : [];
1714
- const exportRows = features.export && features.export.scope === "filteredRows" ? model.filteredRows : model.pageRows;
2057
+ const exportRows = features.export && features.export.scope === "currentPage" ? model.pageRows : model.sortedRows;
2058
+ const exportColumns = getDataTableExportColumns(model.visibleColumns);
1715
2059
  const exportFeature = features.export;
1716
2060
  const exportActions = exportFeature ? exportFeature.actions ?? [] : [];
1717
2061
  const builtInExport = exportFeature && exportFeature.builtIn !== false;
@@ -1733,16 +2077,16 @@ var DataTableToolbar = ({
1733
2077
  setExporting(false);
1734
2078
  }
1735
2079
  };
1736
- return /* @__PURE__ */ jsxs8("div", {
2080
+ return /* @__PURE__ */ jsxs9("div", {
1737
2081
  className: "flex flex-col gap-2 pb-4",
1738
2082
  children: [
1739
- features.search !== false ? /* @__PURE__ */ jsxs8("div", {
2083
+ features.search !== false ? /* @__PURE__ */ jsxs9("div", {
1740
2084
  className: "relative min-w-0",
1741
2085
  children: [
1742
- /* @__PURE__ */ jsx14(Search, {
2086
+ /* @__PURE__ */ jsx15(Search, {
1743
2087
  className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
1744
2088
  }),
1745
- /* @__PURE__ */ jsx14(Input, {
2089
+ /* @__PURE__ */ jsx15(Input, {
1746
2090
  className: "px-9",
1747
2091
  onChange: (event) => update((state) => ({
1748
2092
  ...state,
@@ -1752,7 +2096,7 @@ var DataTableToolbar = ({
1752
2096
  placeholder: labels.filter,
1753
2097
  value: store.state.globalFilter ?? ""
1754
2098
  }),
1755
- store.state.globalFilter ? /* @__PURE__ */ jsx14(Button, {
2099
+ store.state.globalFilter ? /* @__PURE__ */ jsx15(Button, {
1756
2100
  "aria-label": labels.filter,
1757
2101
  className: "absolute top-1/2 right-1 size-7 -translate-y-1/2 active:not-aria-[haspopup]:-translate-y-1/2",
1758
2102
  onClick: () => update((state) => ({
@@ -1762,39 +2106,38 @@ var DataTableToolbar = ({
1762
2106
  })),
1763
2107
  size: "icon",
1764
2108
  variant: "ghost",
1765
- children: /* @__PURE__ */ jsx14(X, {})
2109
+ children: /* @__PURE__ */ jsx15(X, {})
1766
2110
  }) : null
1767
2111
  ]
1768
2112
  }) : null,
1769
- /* @__PURE__ */ jsx14("div", {
2113
+ /* @__PURE__ */ jsx15("div", {
1770
2114
  className: "-m-1 flex overflow-x-auto p-1",
1771
- children: /* @__PURE__ */ jsxs8(Menubar, {
2115
+ children: /* @__PURE__ */ jsxs9(Menubar, {
1772
2116
  className: "h-auto w-max min-w-full justify-start bg-transparent shadow-none [&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4",
1773
2117
  children: [
1774
- toolbar && toolbar.items,
1775
- visibleBulkActions.length ? /* @__PURE__ */ jsxs8(MenubarMenu, {
2118
+ visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
1776
2119
  children: [
1777
- /* @__PURE__ */ jsxs8(MenubarTrigger, {
2120
+ /* @__PURE__ */ jsxs9(MenubarTrigger, {
1778
2121
  className: "bg-primary text-primary-foreground hover:bg-primary/90 aria-expanded:bg-primary/90",
1779
2122
  children: [
1780
2123
  labels.selected,
1781
- /* @__PURE__ */ jsx14(Badge, {
2124
+ /* @__PURE__ */ jsx15(Badge, {
1782
2125
  variant: "secondary",
1783
2126
  children: selectedRows.length
1784
2127
  }),
1785
- /* @__PURE__ */ jsx14(ChevronDown, {})
2128
+ /* @__PURE__ */ jsx15(ChevronDown, {})
1786
2129
  ]
1787
2130
  }),
1788
- /* @__PURE__ */ jsx14(MenubarContent, {
2131
+ /* @__PURE__ */ jsx15(MenubarContent, {
1789
2132
  align: "end",
1790
2133
  className: "w-max",
1791
- children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2134
+ children: /* @__PURE__ */ jsxs9(MenubarGroup, {
1792
2135
  children: [
1793
- /* @__PURE__ */ jsx14(MenubarLabel, {
2136
+ /* @__PURE__ */ jsx15(MenubarLabel, {
1794
2137
  children: bulkActions && bulkActions.label ? bulkActions.label : labels.actions
1795
2138
  }),
1796
- /* @__PURE__ */ jsx14(MenubarSeparator, {}),
1797
- visibleBulkActions.map((action) => /* @__PURE__ */ jsxs8(MenubarItem, {
2139
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2140
+ visibleBulkActions.map((action) => /* @__PURE__ */ jsxs9(MenubarItem, {
1798
2141
  onClick: () => action.onClick(selectedRows),
1799
2142
  variant: action.variant ?? "default",
1800
2143
  children: [
@@ -1807,27 +2150,31 @@ var DataTableToolbar = ({
1807
2150
  })
1808
2151
  ]
1809
2152
  }) : null,
1810
- grouping ? /* @__PURE__ */ jsxs8(MenubarMenu, {
2153
+ toolbar && toolbar.items,
2154
+ features.filtering !== false ? /* @__PURE__ */ jsx15(FilterMenu, {
2155
+ tableAtom
2156
+ }) : null,
2157
+ grouping ? /* @__PURE__ */ jsxs9(MenubarMenu, {
1811
2158
  children: [
1812
- /* @__PURE__ */ jsxs8(MenubarTrigger, {
2159
+ /* @__PURE__ */ jsxs9(MenubarTrigger, {
1813
2160
  "aria-label": labels.groupBy,
1814
2161
  children: [
1815
- /* @__PURE__ */ jsx14(Rows3, {}),
1816
- /* @__PURE__ */ jsx14("span", {
2162
+ /* @__PURE__ */ jsx15(Rows3, {}),
2163
+ /* @__PURE__ */ jsx15("span", {
1817
2164
  className: "hidden sm:inline",
1818
2165
  children: labels.groupBy
1819
2166
  })
1820
2167
  ]
1821
2168
  }),
1822
- /* @__PURE__ */ jsx14(MenubarContent, {
2169
+ /* @__PURE__ */ jsx15(MenubarContent, {
1823
2170
  align: "end",
1824
- children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2171
+ children: /* @__PURE__ */ jsxs9(MenubarGroup, {
1825
2172
  children: [
1826
- /* @__PURE__ */ jsx14(MenubarLabel, {
2173
+ /* @__PURE__ */ jsx15(MenubarLabel, {
1827
2174
  children: labels.groupBy
1828
2175
  }),
1829
- /* @__PURE__ */ jsx14(MenubarSeparator, {}),
1830
- grouping.fields.map((field) => /* @__PURE__ */ jsx14(MenubarCheckboxItem, {
2176
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2177
+ grouping.fields.map((field) => /* @__PURE__ */ jsx15(MenubarCheckboxItem, {
1831
2178
  checked: store.state.grouping.includes(field.id),
1832
2179
  onCheckedChange: (checked) => update((state) => ({
1833
2180
  ...state,
@@ -1840,77 +2187,77 @@ var DataTableToolbar = ({
1840
2187
  })
1841
2188
  ]
1842
2189
  }) : null,
1843
- features.sorting !== false ? /* @__PURE__ */ jsx14(SortMenu, {
2190
+ features.sorting !== false ? /* @__PURE__ */ jsx15(SortMenu, {
1844
2191
  tableAtom
1845
2192
  }) : null,
1846
- features.gallery ? /* @__PURE__ */ jsx14(ViewMenu, {
2193
+ features.gallery ? /* @__PURE__ */ jsx15(ViewMenu, {
1847
2194
  tableAtom
1848
2195
  }) : null,
1849
- features.columnVisibility !== false ? /* @__PURE__ */ jsx14(ColumnMenu, {
2196
+ features.columnVisibility !== false ? /* @__PURE__ */ jsx15(ColumnMenu, {
1850
2197
  tableAtom
1851
2198
  }) : null,
1852
- features.refresh ? /* @__PURE__ */ jsx14(MenubarMenu, {
1853
- children: /* @__PURE__ */ jsxs8(MenubarTrigger, {
2199
+ features.refresh ? /* @__PURE__ */ jsx15(MenubarMenu, {
2200
+ children: /* @__PURE__ */ jsxs9(MenubarTrigger, {
1854
2201
  "aria-label": labels.refresh,
1855
2202
  onClick: features.refresh,
1856
2203
  children: [
1857
- /* @__PURE__ */ jsx14(RefreshCw, {}),
1858
- /* @__PURE__ */ jsx14("span", {
2204
+ /* @__PURE__ */ jsx15(RefreshCw, {}),
2205
+ /* @__PURE__ */ jsx15("span", {
1859
2206
  className: "hidden sm:inline",
1860
2207
  children: labels.refresh
1861
2208
  })
1862
2209
  ]
1863
2210
  })
1864
2211
  }) : null,
1865
- features.export ? /* @__PURE__ */ jsxs8(MenubarMenu, {
2212
+ features.export ? /* @__PURE__ */ jsxs9(MenubarMenu, {
1866
2213
  children: [
1867
- /* @__PURE__ */ jsxs8(MenubarTrigger, {
2214
+ /* @__PURE__ */ jsxs9(MenubarTrigger, {
1868
2215
  "aria-label": labels.export,
1869
2216
  "aria-busy": exporting,
1870
2217
  disabled: exporting || !canExport,
1871
2218
  children: [
1872
- exporting ? /* @__PURE__ */ jsx14(RefreshCw, {
2219
+ exporting ? /* @__PURE__ */ jsx15(RefreshCw, {
1873
2220
  className: "animate-spin"
1874
- }) : /* @__PURE__ */ jsx14(Download, {}),
1875
- /* @__PURE__ */ jsx14("span", {
2221
+ }) : /* @__PURE__ */ jsx15(Download, {}),
2222
+ /* @__PURE__ */ jsx15("span", {
1876
2223
  className: "hidden sm:inline",
1877
2224
  children: exporting ? labels.loading : labels.export
1878
2225
  })
1879
2226
  ]
1880
2227
  }),
1881
- /* @__PURE__ */ jsx14(MenubarContent, {
2228
+ /* @__PURE__ */ jsx15(MenubarContent, {
1882
2229
  align: "end",
1883
- children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2230
+ children: /* @__PURE__ */ jsxs9(MenubarGroup, {
1884
2231
  children: [
1885
- /* @__PURE__ */ jsx14(MenubarLabel, {
2232
+ /* @__PURE__ */ jsx15(MenubarLabel, {
1886
2233
  children: labels.export
1887
2234
  }),
1888
- /* @__PURE__ */ jsx14(MenubarSeparator, {}),
1889
- builtInExport ? /* @__PURE__ */ jsxs8(Fragment, {
2235
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2236
+ builtInExport ? /* @__PURE__ */ jsxs9(Fragment, {
1890
2237
  children: [
1891
- /* @__PURE__ */ jsxs8(MenubarItem, {
2238
+ /* @__PURE__ */ jsxs9(MenubarItem, {
1892
2239
  disabled: exporting || !exportRows.length,
1893
- onClick: () => downloadCsv(model.visibleColumns.map(columnLabel), exportRows.map((row) => model.visibleColumns.map((column) => String(getDataTableExportValue(row, column, store.config.locale) ?? ""))), features.export ? features.export.baseName : "table"),
2240
+ onClick: () => downloadCsv(exportColumns.map(columnLabel), exportRows.map((row) => exportColumns.map((column) => String(getDataTableExportValue(row, column, store.config.locale) ?? ""))), features.export ? features.export.baseName : "table"),
1894
2241
  children: [
1895
- /* @__PURE__ */ jsx14(FileText, {}),
2242
+ /* @__PURE__ */ jsx15(FileText, {}),
1896
2243
  labels.exportCsv
1897
2244
  ]
1898
2245
  }),
1899
- /* @__PURE__ */ jsxs8(MenubarItem, {
2246
+ /* @__PURE__ */ jsxs9(MenubarItem, {
1900
2247
  disabled: exporting || !exportRows.length,
1901
- onClick: () => downloadJson(exportRows.map((row) => Object.fromEntries(model.visibleColumns.map((column) => [
2248
+ onClick: () => downloadJson(exportRows.map((row) => Object.fromEntries(exportColumns.map((column) => [
1902
2249
  column.id,
1903
2250
  getDataTableExportValue(row, column, store.config.locale)
1904
2251
  ]))), features.export ? features.export.baseName : "table"),
1905
2252
  children: [
1906
- /* @__PURE__ */ jsx14(FileJson, {}),
2253
+ /* @__PURE__ */ jsx15(FileJson, {}),
1907
2254
  labels.exportJson
1908
2255
  ]
1909
2256
  })
1910
2257
  ]
1911
2258
  }) : null,
1912
- builtInExport && exportActions.length ? /* @__PURE__ */ jsx14(MenubarSeparator, {}) : null,
1913
- exportActions.map((action) => /* @__PURE__ */ jsxs8(MenubarItem, {
2259
+ builtInExport && exportActions.length ? /* @__PURE__ */ jsx15(MenubarSeparator, {}) : null,
2260
+ exportActions.map((action) => /* @__PURE__ */ jsxs9(MenubarItem, {
1914
2261
  disabled: exporting || action.disabled,
1915
2262
  onClick: () => void runExport(action),
1916
2263
  children: [
@@ -1926,7 +2273,7 @@ var DataTableToolbar = ({
1926
2273
  ]
1927
2274
  })
1928
2275
  }),
1929
- exportFeature && exportFailed ? /* @__PURE__ */ jsx14("p", {
2276
+ exportFeature && exportFailed ? /* @__PURE__ */ jsx15("p", {
1930
2277
  role: "alert",
1931
2278
  className: "text-destructive text-sm",
1932
2279
  children: labels.exportFailed ?? dataTableMessages(store.config.locale).exportFailed
@@ -1934,11 +2281,349 @@ var DataTableToolbar = ({
1934
2281
  ]
1935
2282
  });
1936
2283
  };
2284
+ var withColumnFilter = (state, id, filter) => {
2285
+ const filters = (state.filters ?? []).filter((current) => current.id !== id);
2286
+ if (filter)
2287
+ filters.push(filter);
2288
+ return { ...state, page: 0, filters: filters.length ? filters : undefined };
2289
+ };
2290
+ var FilterEditor = ({
2291
+ column,
2292
+ rows,
2293
+ current,
2294
+ labels,
2295
+ onChange
2296
+ }) => {
2297
+ const inputId = useId2();
2298
+ const kind = getDataTableFilterKind(column);
2299
+ const [primary, setPrimary] = useState(current?.kind === "text" ? current.value : current?.kind === "number" ? String(current.min ?? "") : current?.kind === "date" ? current.from ?? "" : "");
2300
+ const [secondary, setSecondary] = useState(current?.kind === "number" ? String(current.max ?? "") : current?.kind === "date" ? current.to ?? "" : "");
2301
+ const [operator, setOperator] = useState(current?.kind === "text" ? current.operator : "contains");
2302
+ const operatorOptions = [
2303
+ { value: "contains", label: labels.filterContains },
2304
+ { value: "equals", label: labels.filterEquals },
2305
+ { value: "startsWith", label: labels.filterStartsWith },
2306
+ { value: "endsWith", label: labels.filterEndsWith }
2307
+ ];
2308
+ const [invalid, setInvalid] = useState(false);
2309
+ const [optionSearch, setOptionSearch] = useState("");
2310
+ const apply = (candidate) => {
2311
+ const decoded = Schema2.decodeUnknownOption(ColumnFilter)(candidate);
2312
+ if (Option2.isNone(decoded)) {
2313
+ setInvalid(true);
2314
+ return;
2315
+ }
2316
+ setInvalid(false);
2317
+ onChange(decoded.value);
2318
+ };
2319
+ if (kind === "boolean") {
2320
+ return /* @__PURE__ */ jsxs9(MenubarGroup, {
2321
+ children: [
2322
+ /* @__PURE__ */ jsxs9(MenubarRadioGroup, {
2323
+ value: current?.kind === "boolean" ? String(current.value) : "",
2324
+ onValueChange: (value) => apply({ id: column.id, kind, value: value === "true" }),
2325
+ children: [
2326
+ /* @__PURE__ */ jsx15(MenubarRadioItem, {
2327
+ value: "true",
2328
+ closeOnClick: false,
2329
+ children: column.colDef.type === "boolean" ? column.colDef.typeOptions?.trueLabel ?? labels.filterTrue : labels.filterTrue
2330
+ }),
2331
+ /* @__PURE__ */ jsx15(MenubarRadioItem, {
2332
+ value: "false",
2333
+ closeOnClick: false,
2334
+ children: column.colDef.type === "boolean" ? column.colDef.typeOptions?.falseLabel ?? labels.filterFalse : labels.filterFalse
2335
+ })
2336
+ ]
2337
+ }),
2338
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2339
+ /* @__PURE__ */ jsx15(MenubarItem, {
2340
+ closeOnClick: false,
2341
+ onClick: () => onChange(undefined),
2342
+ children: labels.filterClear
2343
+ })
2344
+ ]
2345
+ });
2346
+ }
2347
+ if (kind === "values") {
2348
+ const selected = current?.kind === "values" ? current.values : [];
2349
+ const options = getDataTableFilterOptions(rows, column);
2350
+ const filteredOptions = options.filter((option) => option.label.toLocaleLowerCase().includes(optionSearch.trim().toLocaleLowerCase()));
2351
+ return /* @__PURE__ */ jsxs9(MenubarGroup, {
2352
+ children: [
2353
+ options.length > 8 ? /* @__PURE__ */ jsx15("div", {
2354
+ className: "p-1",
2355
+ children: /* @__PURE__ */ jsx15(Input, {
2356
+ "aria-label": labels.filter,
2357
+ placeholder: labels.filter,
2358
+ value: optionSearch,
2359
+ onChange: (event) => setOptionSearch(event.target.value),
2360
+ onKeyDown: (event) => {
2361
+ if (event.key !== "Escape")
2362
+ event.stopPropagation();
2363
+ }
2364
+ })
2365
+ }) : null,
2366
+ filteredOptions.map((option) => /* @__PURE__ */ jsxs9(MenubarCheckboxItem, {
2367
+ checked: selected.includes(option.value),
2368
+ closeOnClick: false,
2369
+ onCheckedChange: (checked) => {
2370
+ const values = checked ? [...selected, option.value] : selected.filter((value) => value !== option.value);
2371
+ if (values.length)
2372
+ apply({ id: column.id, kind, values });
2373
+ else
2374
+ onChange(undefined);
2375
+ },
2376
+ children: [
2377
+ /* @__PURE__ */ jsx15("span", {
2378
+ className: "min-w-0 flex-1 truncate",
2379
+ children: option.label
2380
+ }),
2381
+ option.count !== undefined ? /* @__PURE__ */ jsx15(Badge, {
2382
+ variant: "secondary",
2383
+ className: "ml-auto shrink-0",
2384
+ children: option.count
2385
+ }) : null
2386
+ ]
2387
+ }, option.value)),
2388
+ !filteredOptions.length ? /* @__PURE__ */ jsx15("div", {
2389
+ className: "text-muted-foreground px-2 py-1.5 text-sm",
2390
+ children: labels.empty
2391
+ }) : null,
2392
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2393
+ /* @__PURE__ */ jsx15(MenubarItem, {
2394
+ closeOnClick: false,
2395
+ onClick: () => onChange(undefined),
2396
+ children: labels.filterClear
2397
+ })
2398
+ ]
2399
+ });
2400
+ }
2401
+ return /* @__PURE__ */ jsxs9("form", {
2402
+ className: "flex flex-col gap-3 p-2",
2403
+ onKeyDown: (event) => {
2404
+ if (event.key !== "Escape")
2405
+ event.stopPropagation();
2406
+ },
2407
+ onSubmit: (event) => {
2408
+ event.preventDefault();
2409
+ if (kind === "text")
2410
+ apply({ id: column.id, kind, operator, value: primary.trim() });
2411
+ else if (kind === "date")
2412
+ apply({
2413
+ id: column.id,
2414
+ kind,
2415
+ from: primary || undefined,
2416
+ to: secondary || undefined
2417
+ });
2418
+ else {
2419
+ const min = primary ? Schema2.decodeUnknownOption(Schema2.FiniteFromString)(primary) : Option2.some(undefined);
2420
+ const max = secondary ? Schema2.decodeUnknownOption(Schema2.FiniteFromString)(secondary) : Option2.some(undefined);
2421
+ if (Option2.isNone(min) || Option2.isNone(max)) {
2422
+ setInvalid(true);
2423
+ return;
2424
+ }
2425
+ apply({ id: column.id, kind, min: min.value, max: max.value });
2426
+ }
2427
+ },
2428
+ children: [
2429
+ /* @__PURE__ */ jsxs9(FieldGroup, {
2430
+ children: [
2431
+ kind === "text" ? /* @__PURE__ */ jsxs9(Field, {
2432
+ children: [
2433
+ /* @__PURE__ */ jsx15(FieldLabel, {
2434
+ htmlFor: `${inputId}-operator`,
2435
+ children: labels.filterOperator
2436
+ }),
2437
+ /* @__PURE__ */ jsxs9(Select, {
2438
+ items: operatorOptions,
2439
+ value: operator,
2440
+ onValueChange: (value) => {
2441
+ const decoded = Schema2.decodeUnknownOption(TextFilterOperator)(value);
2442
+ if (Option2.isSome(decoded))
2443
+ setOperator(decoded.value);
2444
+ },
2445
+ children: [
2446
+ /* @__PURE__ */ jsx15(SelectTrigger, {
2447
+ id: `${inputId}-operator`,
2448
+ children: /* @__PURE__ */ jsx15(SelectValue, {})
2449
+ }),
2450
+ /* @__PURE__ */ jsx15(SelectContent, {
2451
+ children: /* @__PURE__ */ jsx15(SelectGroup, {
2452
+ children: operatorOptions.map((option) => /* @__PURE__ */ jsx15(SelectItem, {
2453
+ value: option.value,
2454
+ children: option.label
2455
+ }, option.value))
2456
+ })
2457
+ })
2458
+ ]
2459
+ })
2460
+ ]
2461
+ }) : null,
2462
+ /* @__PURE__ */ jsxs9(Field, {
2463
+ "data-invalid": invalid || undefined,
2464
+ children: [
2465
+ /* @__PURE__ */ jsx15(FieldLabel, {
2466
+ htmlFor: `${inputId}-primary`,
2467
+ children: kind === "text" ? labels.filterValue : kind === "date" ? labels.filterFrom : labels.filterMin
2468
+ }),
2469
+ /* @__PURE__ */ jsx15(Input, {
2470
+ id: `${inputId}-primary`,
2471
+ type: kind === "text" ? "text" : kind === "date" ? "date" : "number",
2472
+ step: kind === "number" ? "any" : undefined,
2473
+ value: primary,
2474
+ "aria-invalid": invalid || undefined,
2475
+ onChange: (event) => {
2476
+ setPrimary(event.target.value);
2477
+ setInvalid(false);
2478
+ }
2479
+ })
2480
+ ]
2481
+ }),
2482
+ kind !== "text" ? /* @__PURE__ */ jsxs9(Field, {
2483
+ "data-invalid": invalid || undefined,
2484
+ children: [
2485
+ /* @__PURE__ */ jsx15(FieldLabel, {
2486
+ htmlFor: `${inputId}-secondary`,
2487
+ children: kind === "date" ? labels.filterTo : labels.filterMax
2488
+ }),
2489
+ /* @__PURE__ */ jsx15(Input, {
2490
+ id: `${inputId}-secondary`,
2491
+ type: kind === "date" ? "date" : "number",
2492
+ step: kind === "number" ? "any" : undefined,
2493
+ value: secondary,
2494
+ "aria-invalid": invalid || undefined,
2495
+ onChange: (event) => {
2496
+ setSecondary(event.target.value);
2497
+ setInvalid(false);
2498
+ }
2499
+ })
2500
+ ]
2501
+ }) : null
2502
+ ]
2503
+ }),
2504
+ invalid ? /* @__PURE__ */ jsx15("p", {
2505
+ role: "alert",
2506
+ className: "text-destructive text-sm",
2507
+ children: labels.filterInvalid
2508
+ }) : null,
2509
+ /* @__PURE__ */ jsxs9("div", {
2510
+ className: "flex gap-2",
2511
+ children: [
2512
+ /* @__PURE__ */ jsx15(Button, {
2513
+ type: "submit",
2514
+ size: "sm",
2515
+ children: labels.filterApply
2516
+ }),
2517
+ /* @__PURE__ */ jsx15(Button, {
2518
+ type: "button",
2519
+ size: "sm",
2520
+ variant: "outline",
2521
+ onClick: () => {
2522
+ setPrimary("");
2523
+ setSecondary("");
2524
+ setInvalid(false);
2525
+ onChange(undefined);
2526
+ },
2527
+ children: labels.filterClear
2528
+ })
2529
+ ]
2530
+ })
2531
+ ]
2532
+ });
2533
+ };
2534
+ var FilterMenu = ({
2535
+ tableAtom
2536
+ }) => {
2537
+ const [store, setStore] = useTableAtom(tableAtom);
2538
+ const model = deriveModel(store);
2539
+ const columns = model.columns.flatMap((parent) => getDataTableFilterColumns([parent]).map((column) => ({
2540
+ column,
2541
+ label: column.id === parent.id ? columnLabel(column) : `${columnLabel(parent)} / ${columnLabel(column)}`
2542
+ })));
2543
+ if (!columns.length)
2544
+ return null;
2545
+ const filters = store.state.filters ?? [];
2546
+ const update = (id, filter) => changeState(setStore, (state) => withColumnFilter(state, id, filter));
2547
+ return /* @__PURE__ */ jsxs9(MenubarMenu, {
2548
+ children: [
2549
+ /* @__PURE__ */ jsxs9(MenubarTrigger, {
2550
+ "aria-label": store.config.labels.filters,
2551
+ children: [
2552
+ /* @__PURE__ */ jsx15(ListFilter, {}),
2553
+ /* @__PURE__ */ jsx15("span", {
2554
+ children: store.config.labels.filters
2555
+ }),
2556
+ filters.length ? /* @__PURE__ */ jsx15(Badge, {
2557
+ variant: "secondary",
2558
+ children: filters.length
2559
+ }) : null
2560
+ ]
2561
+ }),
2562
+ /* @__PURE__ */ jsx15(MenubarContent, {
2563
+ align: "end",
2564
+ className: "w-80 max-w-[calc(100vw-2rem)]",
2565
+ children: /* @__PURE__ */ jsxs9(MenubarGroup, {
2566
+ children: [
2567
+ /* @__PURE__ */ jsx15(MenubarLabel, {
2568
+ children: store.config.labels.filters
2569
+ }),
2570
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2571
+ columns.map(({ column, label }) => /* @__PURE__ */ jsxs9(MenubarSub, {
2572
+ children: [
2573
+ /* @__PURE__ */ jsxs9(MenubarSubTrigger, {
2574
+ children: [
2575
+ /* @__PURE__ */ jsx15("span", {
2576
+ className: "min-w-0 flex-1 truncate",
2577
+ children: label
2578
+ }),
2579
+ filters.some((filter) => filter.id === column.id) ? /* @__PURE__ */ jsx15(Check, {}) : null
2580
+ ]
2581
+ }),
2582
+ /* @__PURE__ */ jsx15(MenubarSubContent, {
2583
+ className: "w-80 max-w-[calc(100vw-2rem)]",
2584
+ children: /* @__PURE__ */ jsx15(FilterEditor, {
2585
+ column,
2586
+ rows: model.rows,
2587
+ current: filters.find((filter) => filter.id === column.id),
2588
+ labels: store.config.labels,
2589
+ onChange: (filter) => update(column.id, filter)
2590
+ })
2591
+ })
2592
+ ]
2593
+ }, column.id)),
2594
+ filters.length ? /* @__PURE__ */ jsxs9(Fragment, {
2595
+ children: [
2596
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2597
+ /* @__PURE__ */ jsxs9(MenubarItem, {
2598
+ onClick: () => changeState(setStore, (state) => ({
2599
+ ...state,
2600
+ page: 0,
2601
+ filters: undefined
2602
+ })),
2603
+ children: [
2604
+ /* @__PURE__ */ jsx15(X, {}),
2605
+ store.config.labels.filtersClear
2606
+ ]
2607
+ })
2608
+ ]
2609
+ }) : null
2610
+ ]
2611
+ })
2612
+ })
2613
+ ]
2614
+ });
2615
+ };
1937
2616
  var SortMenu = ({
1938
2617
  tableAtom
1939
2618
  }) => {
1940
2619
  const [store, setStore] = useTableAtom(tableAtom);
1941
- const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.sortable !== false);
2620
+ const columns = deriveModel(store).columns.flatMap((column) => getDataTableSortColumns([column]).map((field) => field.id === column.id ? field : {
2621
+ ...field,
2622
+ colDef: {
2623
+ ...field.colDef,
2624
+ headerName: `${columnLabel(column)} / ${columnLabel(field)}`
2625
+ }
2626
+ }));
1942
2627
  if (!columns.length)
1943
2628
  return null;
1944
2629
  const current = store.state.sort?.[0];
@@ -1947,69 +2632,77 @@ var SortMenu = ({
1947
2632
  sort: [{ id, direction }],
1948
2633
  page: 0
1949
2634
  }));
1950
- return /* @__PURE__ */ jsxs8(MenubarMenu, {
2635
+ return /* @__PURE__ */ jsxs9(MenubarMenu, {
1951
2636
  children: [
1952
- /* @__PURE__ */ jsxs8(MenubarTrigger, {
2637
+ /* @__PURE__ */ jsxs9(MenubarTrigger, {
1953
2638
  "aria-label": store.config.labels.sortBy,
1954
2639
  children: [
1955
- current ? current.direction === "desc" ? /* @__PURE__ */ jsx14(ArrowDown, {}) : /* @__PURE__ */ jsx14(ArrowUp, {}) : /* @__PURE__ */ jsx14(ChevronsUpDown, {}),
1956
- /* @__PURE__ */ jsx14("span", {
2640
+ current ? current.direction === "desc" ? /* @__PURE__ */ jsx15(ArrowDown, {}) : /* @__PURE__ */ jsx15(ArrowUp, {}) : /* @__PURE__ */ jsx15(ChevronsUpDown, {}),
2641
+ /* @__PURE__ */ jsx15("span", {
1957
2642
  className: "hidden sm:inline",
1958
2643
  children: store.config.labels.sortBy
1959
2644
  })
1960
2645
  ]
1961
2646
  }),
1962
- /* @__PURE__ */ jsx14(MenubarContent, {
2647
+ /* @__PURE__ */ jsx15(MenubarContent, {
1963
2648
  align: "end",
1964
2649
  className: "w-52",
1965
- children: columns.map((column) => {
1966
- const sortState = store.state.sort?.find(({ id }) => id === column.id);
1967
- return /* @__PURE__ */ jsxs8(MenubarSub, {
1968
- children: [
1969
- /* @__PURE__ */ jsxs8(MenubarSubTrigger, {
1970
- children: [
1971
- sortState ? sortState.direction === "desc" ? /* @__PURE__ */ jsx14(ArrowDown, {}) : /* @__PURE__ */ jsx14(ArrowUp, {}) : null,
1972
- columnLabel(column)
1973
- ]
1974
- }),
1975
- /* @__PURE__ */ jsxs8(MenubarSubContent, {
2650
+ children: /* @__PURE__ */ jsxs9(MenubarGroup, {
2651
+ children: [
2652
+ /* @__PURE__ */ jsx15(MenubarLabel, {
2653
+ children: store.config.labels.sortBy
2654
+ }),
2655
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2656
+ columns.map((column) => {
2657
+ const sortState = store.state.sort?.find(({ id }) => id === column.id);
2658
+ return /* @__PURE__ */ jsxs9(MenubarSub, {
1976
2659
  children: [
1977
- /* @__PURE__ */ jsxs8(MenubarItem, {
1978
- onClick: () => sort(column.id, "asc"),
1979
- children: [
1980
- /* @__PURE__ */ jsx14(ArrowUp, {}),
1981
- " ",
1982
- store.config.labels.sortAsc
1983
- ]
1984
- }),
1985
- /* @__PURE__ */ jsxs8(MenubarItem, {
1986
- onClick: () => sort(column.id, "desc"),
2660
+ /* @__PURE__ */ jsxs9(MenubarSubTrigger, {
1987
2661
  children: [
1988
- /* @__PURE__ */ jsx14(ArrowDown, {}),
1989
- " ",
1990
- store.config.labels.sortDesc
2662
+ sortState ? sortState.direction === "desc" ? /* @__PURE__ */ jsx15(ArrowDown, {}) : /* @__PURE__ */ jsx15(ArrowUp, {}) : null,
2663
+ columnLabel(column)
1991
2664
  ]
1992
2665
  }),
1993
- sortState ? /* @__PURE__ */ jsxs8(Fragment, {
2666
+ /* @__PURE__ */ jsxs9(MenubarSubContent, {
1994
2667
  children: [
1995
- /* @__PURE__ */ jsx14(MenubarSeparator, {}),
1996
- /* @__PURE__ */ jsxs8(MenubarItem, {
1997
- onClick: () => changeState(setStore, (state) => ({
1998
- ...state,
1999
- sort: state.sort?.filter(({ id }) => id !== column.id)
2000
- })),
2668
+ /* @__PURE__ */ jsxs9(MenubarItem, {
2669
+ onClick: () => sort(column.id, "asc"),
2001
2670
  children: [
2002
- /* @__PURE__ */ jsx14(X, {}),
2671
+ /* @__PURE__ */ jsx15(ArrowUp, {}),
2003
2672
  " ",
2004
- store.config.labels.sortClear
2673
+ store.config.labels.sortAsc
2005
2674
  ]
2006
- })
2675
+ }),
2676
+ /* @__PURE__ */ jsxs9(MenubarItem, {
2677
+ onClick: () => sort(column.id, "desc"),
2678
+ children: [
2679
+ /* @__PURE__ */ jsx15(ArrowDown, {}),
2680
+ " ",
2681
+ store.config.labels.sortDesc
2682
+ ]
2683
+ }),
2684
+ sortState ? /* @__PURE__ */ jsxs9(Fragment, {
2685
+ children: [
2686
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2687
+ /* @__PURE__ */ jsxs9(MenubarItem, {
2688
+ onClick: () => changeState(setStore, (state) => ({
2689
+ ...state,
2690
+ sort: state.sort?.filter(({ id }) => id !== column.id)
2691
+ })),
2692
+ children: [
2693
+ /* @__PURE__ */ jsx15(X, {}),
2694
+ " ",
2695
+ store.config.labels.sortClear
2696
+ ]
2697
+ })
2698
+ ]
2699
+ }) : null
2007
2700
  ]
2008
- }) : null
2701
+ })
2009
2702
  ]
2010
- })
2011
- ]
2012
- }, column.id);
2703
+ }, column.id);
2704
+ })
2705
+ ]
2013
2706
  })
2014
2707
  })
2015
2708
  ]
@@ -2019,21 +2712,21 @@ var ViewMenu = ({
2019
2712
  tableAtom
2020
2713
  }) => {
2021
2714
  const [store, setStore] = useTableAtom(tableAtom);
2022
- return /* @__PURE__ */ jsxs8(MenubarMenu, {
2715
+ return /* @__PURE__ */ jsxs9(MenubarMenu, {
2023
2716
  children: [
2024
- /* @__PURE__ */ jsxs8(MenubarTrigger, {
2717
+ /* @__PURE__ */ jsxs9(MenubarTrigger, {
2025
2718
  "aria-label": store.config.labels.view,
2026
2719
  children: [
2027
- store.state.view === "gallery" ? /* @__PURE__ */ jsx14(LayoutGrid, {}) : /* @__PURE__ */ jsx14(Rows3, {}),
2028
- /* @__PURE__ */ jsx14("span", {
2720
+ store.state.view === "gallery" ? /* @__PURE__ */ jsx15(LayoutGrid, {}) : /* @__PURE__ */ jsx15(Rows3, {}),
2721
+ /* @__PURE__ */ jsx15("span", {
2029
2722
  className: "hidden sm:inline",
2030
2723
  children: store.config.labels.view
2031
2724
  })
2032
2725
  ]
2033
2726
  }),
2034
- /* @__PURE__ */ jsx14(MenubarContent, {
2727
+ /* @__PURE__ */ jsx15(MenubarContent, {
2035
2728
  align: "end",
2036
- children: /* @__PURE__ */ jsxs8(MenubarRadioGroup, {
2729
+ children: /* @__PURE__ */ jsxs9(MenubarRadioGroup, {
2037
2730
  onValueChange: (view) => {
2038
2731
  if (view === "table" || view === "gallery") {
2039
2732
  changeState(setStore, (state) => ({ ...state, view }));
@@ -2041,18 +2734,18 @@ var ViewMenu = ({
2041
2734
  },
2042
2735
  value: store.state.view,
2043
2736
  children: [
2044
- /* @__PURE__ */ jsxs8(MenubarRadioItem, {
2737
+ /* @__PURE__ */ jsxs9(MenubarRadioItem, {
2045
2738
  value: "table",
2046
2739
  children: [
2047
- /* @__PURE__ */ jsx14(Rows3, {}),
2740
+ /* @__PURE__ */ jsx15(Rows3, {}),
2048
2741
  " ",
2049
2742
  store.config.labels.tableView
2050
2743
  ]
2051
2744
  }),
2052
- /* @__PURE__ */ jsxs8(MenubarRadioItem, {
2745
+ /* @__PURE__ */ jsxs9(MenubarRadioItem, {
2053
2746
  value: "gallery",
2054
2747
  children: [
2055
- /* @__PURE__ */ jsx14(LayoutGrid, {}),
2748
+ /* @__PURE__ */ jsx15(LayoutGrid, {}),
2056
2749
  " ",
2057
2750
  store.config.labels.galleryView
2058
2751
  ]
@@ -2070,27 +2763,27 @@ var ColumnMenu = ({
2070
2763
  const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
2071
2764
  if (!columns.length)
2072
2765
  return null;
2073
- return /* @__PURE__ */ jsxs8(MenubarMenu, {
2766
+ return /* @__PURE__ */ jsxs9(MenubarMenu, {
2074
2767
  children: [
2075
- /* @__PURE__ */ jsxs8(MenubarTrigger, {
2768
+ /* @__PURE__ */ jsxs9(MenubarTrigger, {
2076
2769
  "aria-label": store.config.labels.columns,
2077
2770
  children: [
2078
- /* @__PURE__ */ jsx14(Settings2, {}),
2079
- /* @__PURE__ */ jsx14("span", {
2771
+ /* @__PURE__ */ jsx15(Settings2, {}),
2772
+ /* @__PURE__ */ jsx15("span", {
2080
2773
  className: "hidden sm:inline",
2081
2774
  children: store.config.labels.columns
2082
2775
  })
2083
2776
  ]
2084
2777
  }),
2085
- /* @__PURE__ */ jsx14(MenubarContent, {
2778
+ /* @__PURE__ */ jsx15(MenubarContent, {
2086
2779
  align: "end",
2087
- children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2780
+ children: /* @__PURE__ */ jsxs9(MenubarGroup, {
2088
2781
  children: [
2089
- /* @__PURE__ */ jsx14(MenubarLabel, {
2782
+ /* @__PURE__ */ jsx15(MenubarLabel, {
2090
2783
  children: store.config.labels.columns
2091
2784
  }),
2092
- /* @__PURE__ */ jsx14(MenubarSeparator, {}),
2093
- columns.map((column) => /* @__PURE__ */ jsx14(MenubarCheckboxItem, {
2785
+ /* @__PURE__ */ jsx15(MenubarSeparator, {}),
2786
+ columns.map((column) => /* @__PURE__ */ jsx15(MenubarCheckboxItem, {
2094
2787
  checked: store.state.columnVisibility[column.id] !== false,
2095
2788
  onCheckedChange: (visible) => changeState(setStore, (state) => ({
2096
2789
  ...state,
@@ -2143,7 +2836,7 @@ var ResizeHandle = ({
2143
2836
  const reset = () => {
2144
2837
  resizeRef.current = null;
2145
2838
  };
2146
- return /* @__PURE__ */ jsx14("button", {
2839
+ return /* @__PURE__ */ jsx15("button", {
2147
2840
  "aria-label": store.config.labels.resizeColumn(columnLabel(column)),
2148
2841
  "aria-orientation": "vertical",
2149
2842
  "aria-valuemax": column.colDef.maxWidth ?? DEFAULT_MAX_WIDTH,
@@ -2265,9 +2958,9 @@ var DragHandle = ({
2265
2958
  reordering.onReorder(reorderDataTableRows(model.rows, rowId, target.id));
2266
2959
  }
2267
2960
  };
2268
- return /* @__PURE__ */ jsxs8(Fragment, {
2961
+ return /* @__PURE__ */ jsxs9(Fragment, {
2269
2962
  children: [
2270
- /* @__PURE__ */ jsx14(Button, {
2963
+ /* @__PURE__ */ jsx15(Button, {
2271
2964
  "aria-label": store.config.features.reordering && store.config.features.reordering.handleLabel ? store.config.features.reordering.handleLabel : store.config.labels.reorder,
2272
2965
  className: "size-8 cursor-grab touch-none active:cursor-grabbing",
2273
2966
  onClick: (event) => event.stopPropagation(),
@@ -2285,9 +2978,9 @@ var DragHandle = ({
2285
2978
  onPointerUp: finish,
2286
2979
  size: "icon",
2287
2980
  variant: "ghost",
2288
- children: /* @__PURE__ */ jsx14(GripVertical, {})
2981
+ children: /* @__PURE__ */ jsx15(GripVertical, {})
2289
2982
  }),
2290
- overlay ? createPortal(/* @__PURE__ */ jsx14("div", {
2983
+ overlay ? createPortal(/* @__PURE__ */ jsx15("div", {
2291
2984
  "aria-hidden": "true",
2292
2985
  className: "bg-background pointer-events-none fixed z-[100] rounded-md border px-3 py-2 text-sm shadow-lg",
2293
2986
  style: { left: overlay.x + 12, top: overlay.y + 12 },
@@ -2317,8 +3010,8 @@ var TableDataRow = ({
2317
3010
  const selection = store.config.features.selection;
2318
3011
  const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
2319
3012
  const draggable = canDragRows(store);
2320
- return /* @__PURE__ */ jsxs8(TableRow, {
2321
- className: cn("group/row h-16 data-[drag-source=true]:opacity-40 data-[drop-position=before]:[&>td]:border-t-2 data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-b-2 data-[drop-position=after]:[&>td]:border-primary", store.config.onRowClicked && "cursor-pointer"),
3013
+ return /* @__PURE__ */ jsxs9(TableRow, {
3014
+ className: cn("group/row data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-primary h-16 data-[drag-source=true]:opacity-40 data-[drop-position=after]:[&>td]:border-b-2 data-[drop-position=before]:[&>td]:border-t-2", store.config.onRowClicked && "cursor-pointer"),
2322
3015
  "data-state": store.state.rowSelection[row.id] && "selected",
2323
3016
  "data-table-row": row.id,
2324
3017
  onClick: () => store.config.onRowClicked?.(row.data),
@@ -2330,36 +3023,36 @@ var TableDataRow = ({
2330
3023
  },
2331
3024
  tabIndex: store.config.onRowClicked ? 0 : undefined,
2332
3025
  children: [
2333
- selection ? /* @__PURE__ */ jsx14(TableCell, {
3026
+ selection ? /* @__PURE__ */ jsx15(TableCell, {
2334
3027
  className: "w-10 pr-0",
2335
3028
  onClick: (event) => event.stopPropagation(),
2336
- children: /* @__PURE__ */ jsx14(Checkbox, {
3029
+ children: /* @__PURE__ */ jsx15(Checkbox, {
2337
3030
  "aria-label": store.config.labels.selectRow,
2338
3031
  checked: !!store.state.rowSelection[row.id],
2339
3032
  disabled: !selectable,
2340
3033
  onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked)
2341
3034
  })
2342
3035
  }) : null,
2343
- draggable ? /* @__PURE__ */ jsx14(TableCell, {
3036
+ draggable ? /* @__PURE__ */ jsx15(TableCell, {
2344
3037
  className: "w-10 pr-0",
2345
- children: /* @__PURE__ */ jsx14(DragHandle, {
3038
+ children: /* @__PURE__ */ jsx15(DragHandle, {
2346
3039
  tableAtom
2347
3040
  })
2348
3041
  }) : null,
2349
- model.visibleColumns.map((column) => /* @__PURE__ */ jsx14(TableCell, {
2350
- className: cn("min-w-24 overflow-hidden has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:p-0 has-[[data-slot=data-table-boolean-cell]]:relative has-[[data-slot=data-table-boolean-cell]]:p-0", column.colDef.truncate ? "whitespace-nowrap" : "whitespace-normal"),
3042
+ model.visibleColumns.map((column) => /* @__PURE__ */ jsx15(TableCell, {
3043
+ className: cn("min-w-24 overflow-hidden has-[[data-slot=data-table-boolean-cell]]:relative has-[[data-slot=data-table-boolean-cell]]:p-0 has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:p-0", column.colDef.truncate ? "whitespace-nowrap" : "whitespace-normal"),
2351
3044
  style: { width: column.width },
2352
- children: /* @__PURE__ */ jsx14("div", {
3045
+ children: /* @__PURE__ */ jsx15("div", {
2353
3046
  className: cn("min-w-0", column.colDef.truncate && "truncate"),
2354
3047
  children: renderCell(row, column, store.config.locale, store.config.labels)
2355
3048
  })
2356
3049
  }, column.id)),
2357
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx14(TableCell, {
3050
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableCell, {
2358
3051
  className: "bg-background group-data-[state=selected]/row:bg-muted sticky right-0 z-20 w-10 min-w-10 cursor-default p-0 transition-colors group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--background))]",
2359
3052
  onClick: (event) => event.stopPropagation(),
2360
- children: /* @__PURE__ */ jsx14("div", {
3053
+ children: /* @__PURE__ */ jsx15("div", {
2361
3054
  className: "flex h-16 items-center justify-center",
2362
- children: /* @__PURE__ */ jsx14(DataTableRowActionMenu, {
3055
+ children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
2363
3056
  tableAtom
2364
3057
  })
2365
3058
  })
@@ -2375,26 +3068,26 @@ var GroupActions = ({
2375
3068
  const visible = actions?.filter((action) => !action.visible || action.visible(groupId));
2376
3069
  if (!visible?.length)
2377
3070
  return null;
2378
- return /* @__PURE__ */ jsxs8(DropdownMenu, {
3071
+ return /* @__PURE__ */ jsxs9(DropdownMenu, {
2379
3072
  children: [
2380
- /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
3073
+ /* @__PURE__ */ jsx15(DropdownMenuTrigger, {
2381
3074
  onClick: (event) => event.stopPropagation(),
2382
- render: /* @__PURE__ */ jsxs8(Button, {
3075
+ render: /* @__PURE__ */ jsxs9(Button, {
2383
3076
  size: "icon",
2384
3077
  variant: "ghost",
2385
3078
  children: [
2386
- /* @__PURE__ */ jsx14("span", {
3079
+ /* @__PURE__ */ jsx15("span", {
2387
3080
  className: "sr-only",
2388
3081
  children: title
2389
3082
  }),
2390
- /* @__PURE__ */ jsx14(MoreHorizontal, {})
3083
+ /* @__PURE__ */ jsx15(MoreHorizontal, {})
2391
3084
  ]
2392
3085
  })
2393
3086
  }),
2394
- /* @__PURE__ */ jsx14(DropdownMenuContent, {
3087
+ /* @__PURE__ */ jsx15(DropdownMenuContent, {
2395
3088
  align: "end",
2396
- children: /* @__PURE__ */ jsx14(DropdownMenuGroup, {
2397
- children: visible.map((action) => /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3089
+ children: /* @__PURE__ */ jsx15(DropdownMenuGroup, {
3090
+ children: visible.map((action) => /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2398
3091
  onClick: () => action.onClick(groupId),
2399
3092
  variant: action.variant ?? "default",
2400
3093
  children: [
@@ -2425,40 +3118,40 @@ var GroupedTable = ({
2425
3118
  [section.key]: !collapsed
2426
3119
  }
2427
3120
  }));
2428
- const body = /* @__PURE__ */ jsxs8(TableBody, {
3121
+ const body = /* @__PURE__ */ jsxs9(TableBody, {
2429
3122
  className: "data-[drop-target=true]:outline-primary relative data-[drop-target=true]:z-30 data-[drop-target=true]:outline-2 data-[drop-target=true]:-outline-offset-2 data-[drop-target=true]:[&>tr]:border-transparent data-[drop-target=true]:[&>tr>td:last-child]:z-0",
2430
3123
  "data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
2431
3124
  children: [
2432
- /* @__PURE__ */ jsx14(TableRow, {
3125
+ /* @__PURE__ */ jsx15(TableRow, {
2433
3126
  className: "bg-muted/40 hover:bg-accent! cursor-pointer",
2434
3127
  onClick: toggleCollapsed,
2435
- children: /* @__PURE__ */ jsx14(TableCell, {
3128
+ children: /* @__PURE__ */ jsx15(TableCell, {
2436
3129
  colSpan: model.visibleColumns.length + extra,
2437
- children: /* @__PURE__ */ jsxs8("div", {
3130
+ children: /* @__PURE__ */ jsxs9("div", {
2438
3131
  className: "flex items-center gap-2",
2439
3132
  style: { paddingLeft: section.depth * 20 },
2440
3133
  children: [
2441
- /* @__PURE__ */ jsxs8("button", {
3134
+ /* @__PURE__ */ jsxs9("button", {
2442
3135
  "aria-expanded": !collapsed,
2443
3136
  className: "flex flex-1 cursor-pointer items-center gap-2 text-left font-medium",
2444
3137
  type: "button",
2445
3138
  children: [
2446
- collapsed ? /* @__PURE__ */ jsx14(ChevronRight2, {
3139
+ collapsed ? /* @__PURE__ */ jsx15(ChevronRight2, {
2447
3140
  className: "size-4"
2448
- }) : /* @__PURE__ */ jsx14(ChevronDown, {
3141
+ }) : /* @__PURE__ */ jsx15(ChevronDown, {
2449
3142
  className: "size-4"
2450
3143
  }),
2451
- /* @__PURE__ */ jsx14("span", {
3144
+ /* @__PURE__ */ jsx15("span", {
2452
3145
  className: "flex-1",
2453
3146
  children: section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.data)) ?? section.groupId
2454
3147
  })
2455
3148
  ]
2456
3149
  }),
2457
- /* @__PURE__ */ jsx14(Badge, {
3150
+ /* @__PURE__ */ jsx15(Badge, {
2458
3151
  variant: "secondary",
2459
3152
  children: section.rows.length
2460
3153
  }),
2461
- /* @__PURE__ */ jsx14(GroupActions, {
3154
+ /* @__PURE__ */ jsx15(GroupActions, {
2462
3155
  actions: section.field.actions,
2463
3156
  groupId: section.groupId,
2464
3157
  title: section.field.actionsLabel ?? store.config.labels.actions
@@ -2467,14 +3160,14 @@ var GroupedTable = ({
2467
3160
  })
2468
3161
  })
2469
3162
  }),
2470
- !collapsed && !section.children.length ? section.rows.length ? section.rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
3163
+ !collapsed && !section.children.length ? section.rows.length ? section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
2471
3164
  value: row.id,
2472
- children: /* @__PURE__ */ jsx14(TableDataRow, {
3165
+ children: /* @__PURE__ */ jsx15(TableDataRow, {
2473
3166
  tableAtom
2474
3167
  })
2475
3168
  }, `${section.key}:${row.id}`)) : [
2476
- /* @__PURE__ */ jsx14(TableRow, {
2477
- children: /* @__PURE__ */ jsx14(TableCell, {
3169
+ /* @__PURE__ */ jsx15(TableRow, {
3170
+ children: /* @__PURE__ */ jsx15(TableCell, {
2478
3171
  className: "text-muted-foreground h-16",
2479
3172
  colSpan: model.visibleColumns.length + extra,
2480
3173
  children: section.field.renderEmptyGroup?.(section.groupId) ?? store.config.labels.empty
@@ -2485,7 +3178,7 @@ var GroupedTable = ({
2485
3178
  }, section.key);
2486
3179
  return !collapsed && section.children.length ? [body, renderSections(section.children)] : [body];
2487
3180
  });
2488
- return /* @__PURE__ */ jsx14(Fragment, {
3181
+ return /* @__PURE__ */ jsx15(Fragment, {
2489
3182
  children: renderSections(sections)
2490
3183
  });
2491
3184
  };
@@ -2494,79 +3187,159 @@ var ColumnHeaderMenu = ({
2494
3187
  }) => {
2495
3188
  const [store, setStore] = useTableAtom(tableAtom);
2496
3189
  const columnId = useRequiredId(ColumnIdContext);
2497
- const column = deriveModel(store).columns.find(({ id }) => id === columnId);
3190
+ const model = deriveModel(store);
3191
+ const column = model.columns.find(({ id }) => id === columnId);
2498
3192
  if (!column)
2499
3193
  return null;
2500
- const sortingEnabled = store.config.features.sorting !== false && column.colDef.sortable !== false;
3194
+ const sortColumns = getDataTableSortColumns([column]);
3195
+ const filterColumns = getDataTableFilterColumns([column]);
3196
+ const filteringEnabled = store.config.features.filtering !== false && filterColumns.length > 0;
3197
+ const ownsFilter = (id) => id === column.id || getDataTableFieldColumns(column).some((field) => field.id === id);
3198
+ const activeFilters = (store.state.filters ?? []).filter(({ id }) => ownsFilter(id));
3199
+ const filterEditor = (field) => /* @__PURE__ */ jsx15(FilterEditor, {
3200
+ column: field,
3201
+ rows: model.rows,
3202
+ current: store.state.filters?.find((filter) => filter.id === field.id),
3203
+ labels: store.config.labels,
3204
+ onChange: (filter) => changeState(setStore, (state) => withColumnFilter(state, field.id, filter))
3205
+ });
3206
+ const sortingEnabled = store.config.features.sorting !== false && sortColumns.length > 0;
2501
3207
  const hidingEnabled = store.config.features.columnVisibility !== false && column.colDef.hideable !== false;
2502
- const sort = store.state.sort?.find(({ id }) => id === column.id);
3208
+ const ownsSort = (id) => id === column.id || sortColumns.some((field) => field.id === id);
3209
+ const sort = store.state.sort?.find(({ id }) => ownsSort(id));
2503
3210
  const update = (next) => changeState(setStore, next);
2504
- const setSort = (direction) => update((state) => ({
3211
+ const setSort = (id, direction) => update((state) => ({
2505
3212
  ...state,
2506
- sort: [{ id: column.id, direction }],
3213
+ sort: [{ id, direction }],
2507
3214
  page: 0
2508
3215
  }));
2509
3216
  const label = columnLabel(column);
2510
- if (!sortingEnabled && !hidingEnabled) {
2511
- return /* @__PURE__ */ jsx14("div", {
3217
+ const sortItems = (field) => /* @__PURE__ */ jsxs9(Fragment, {
3218
+ children: [
3219
+ /* @__PURE__ */ jsxs9(DropdownMenuItem, {
3220
+ onClick: () => setSort(field.id, "asc"),
3221
+ children: [
3222
+ /* @__PURE__ */ jsx15(ArrowUp, {}),
3223
+ " ",
3224
+ store.config.labels.sortAsc
3225
+ ]
3226
+ }),
3227
+ /* @__PURE__ */ jsxs9(DropdownMenuItem, {
3228
+ onClick: () => setSort(field.id, "desc"),
3229
+ children: [
3230
+ /* @__PURE__ */ jsx15(ArrowDown, {}),
3231
+ " ",
3232
+ store.config.labels.sortDesc
3233
+ ]
3234
+ })
3235
+ ]
3236
+ });
3237
+ if (!sortingEnabled && !hidingEnabled && !filteringEnabled) {
3238
+ return /* @__PURE__ */ jsx15("div", {
2512
3239
  className: "truncate px-2",
2513
3240
  children: column.colDef.headerName
2514
3241
  });
2515
3242
  }
2516
- return /* @__PURE__ */ jsxs8(DropdownMenu, {
3243
+ return /* @__PURE__ */ jsxs9(DropdownMenu, {
2517
3244
  children: [
2518
- /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
2519
- render: /* @__PURE__ */ jsxs8(Button, {
3245
+ /* @__PURE__ */ jsx15(DropdownMenuTrigger, {
3246
+ render: /* @__PURE__ */ jsxs9(Button, {
2520
3247
  "aria-label": label,
3248
+ "aria-description": activeFilters.length ? `${store.config.labels.filters}: ${activeFilters.length}` : undefined,
2521
3249
  className: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pr-4 focus-visible:ring-inset",
2522
3250
  variant: "ghost",
2523
3251
  children: [
2524
- /* @__PURE__ */ jsx14("span", {
3252
+ /* @__PURE__ */ jsx15("span", {
2525
3253
  className: "truncate",
2526
3254
  children: column.colDef.headerName
2527
3255
  }),
2528
- sort ? sort.direction === "desc" ? /* @__PURE__ */ jsx14(ArrowDown, {}) : /* @__PURE__ */ jsx14(ArrowUp, {}) : null
3256
+ activeFilters.length ? /* @__PURE__ */ jsx15(ListFilter, {}) : null,
3257
+ sort ? sort.direction === "desc" ? /* @__PURE__ */ jsx15(ArrowDown, {}) : /* @__PURE__ */ jsx15(ArrowUp, {}) : null
2529
3258
  ]
2530
3259
  })
2531
3260
  }),
2532
- /* @__PURE__ */ jsx14(DropdownMenuContent, {
3261
+ /* @__PURE__ */ jsx15(DropdownMenuContent, {
2533
3262
  align: "start",
2534
3263
  className: "w-48",
2535
- children: /* @__PURE__ */ jsxs8(DropdownMenuGroup, {
3264
+ children: /* @__PURE__ */ jsxs9(DropdownMenuGroup, {
2536
3265
  children: [
2537
- sortingEnabled ? /* @__PURE__ */ jsxs8(Fragment, {
3266
+ sortingEnabled ? /* @__PURE__ */ jsxs9(Fragment, {
2538
3267
  children: [
2539
- /* @__PURE__ */ jsxs8(DropdownMenuItem, {
2540
- onClick: () => setSort("asc"),
3268
+ column.colDef.fields?.length ? sortColumns.map((field) => /* @__PURE__ */ jsxs9(DropdownMenuSub, {
2541
3269
  children: [
2542
- /* @__PURE__ */ jsx14(ArrowUp, {}),
2543
- " ",
2544
- store.config.labels.sortAsc
2545
- ]
2546
- }),
2547
- /* @__PURE__ */ jsxs8(DropdownMenuItem, {
2548
- onClick: () => setSort("desc"),
2549
- children: [
2550
- /* @__PURE__ */ jsx14(ArrowDown, {}),
2551
- " ",
2552
- store.config.labels.sortDesc
3270
+ /* @__PURE__ */ jsx15(DropdownMenuSubTrigger, {
3271
+ children: columnLabel(field)
3272
+ }),
3273
+ /* @__PURE__ */ jsx15(DropdownMenuSubContent, {
3274
+ children: /* @__PURE__ */ jsx15(DropdownMenuGroup, {
3275
+ children: sortItems(field)
3276
+ })
3277
+ })
2553
3278
  ]
2554
- }),
2555
- sort ? /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3279
+ }, field.id)) : sortItems(column),
3280
+ sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2556
3281
  onClick: () => update((state) => ({
2557
3282
  ...state,
2558
- sort: state.sort?.filter(({ id }) => id !== column.id)
3283
+ sort: state.sort?.filter(({ id }) => !ownsSort(id))
2559
3284
  })),
2560
3285
  children: [
2561
- /* @__PURE__ */ jsx14(X, {}),
3286
+ /* @__PURE__ */ jsx15(X, {}),
2562
3287
  " ",
2563
3288
  store.config.labels.sortClear
2564
3289
  ]
2565
3290
  }) : null
2566
3291
  ]
2567
3292
  }) : null,
2568
- sortingEnabled && hidingEnabled ? /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}) : null,
2569
- hidingEnabled ? /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3293
+ sortingEnabled && filteringEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator, {}) : null,
3294
+ filteringEnabled ? /* @__PURE__ */ jsxs9(Fragment, {
3295
+ children: [
3296
+ /* @__PURE__ */ jsxs9(DropdownMenuSub, {
3297
+ children: [
3298
+ /* @__PURE__ */ jsxs9(DropdownMenuSubTrigger, {
3299
+ children: [
3300
+ /* @__PURE__ */ jsx15(ListFilter, {}),
3301
+ store.config.labels.filters
3302
+ ]
3303
+ }),
3304
+ /* @__PURE__ */ jsx15(DropdownMenuSubContent, {
3305
+ className: "w-80 max-w-[calc(100vw-2rem)]",
3306
+ children: column.colDef.fields?.length ? /* @__PURE__ */ jsx15(DropdownMenuGroup, {
3307
+ children: filterColumns.map((field) => /* @__PURE__ */ jsxs9(DropdownMenuSub, {
3308
+ children: [
3309
+ /* @__PURE__ */ jsxs9(DropdownMenuSubTrigger, {
3310
+ children: [
3311
+ columnLabel(field),
3312
+ activeFilters.some((filter) => filter.id === field.id) ? /* @__PURE__ */ jsx15(Check, {}) : null
3313
+ ]
3314
+ }),
3315
+ /* @__PURE__ */ jsx15(DropdownMenuSubContent, {
3316
+ className: "w-80 max-w-[calc(100vw-2rem)]",
3317
+ children: filterEditor(field)
3318
+ })
3319
+ ]
3320
+ }, field.id))
3321
+ }) : filterEditor(column)
3322
+ })
3323
+ ]
3324
+ }),
3325
+ activeFilters.length ? /* @__PURE__ */ jsxs9(DropdownMenuItem, {
3326
+ onClick: () => update((state) => {
3327
+ const filters = state.filters?.filter(({ id }) => !ownsFilter(id));
3328
+ return {
3329
+ ...state,
3330
+ page: 0,
3331
+ filters: filters?.length ? filters : undefined
3332
+ };
3333
+ }),
3334
+ children: [
3335
+ /* @__PURE__ */ jsx15(X, {}),
3336
+ store.config.labels.filterClear
3337
+ ]
3338
+ }) : null
3339
+ ]
3340
+ }) : null,
3341
+ (sortingEnabled || filteringEnabled) && hidingEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator, {}) : null,
3342
+ hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2570
3343
  onClick: () => update((state) => ({
2571
3344
  ...state,
2572
3345
  columnVisibility: {
@@ -2575,7 +3348,7 @@ var ColumnHeaderMenu = ({
2575
3348
  }
2576
3349
  })),
2577
3350
  children: [
2578
- /* @__PURE__ */ jsx14(EyeOff, {}),
3351
+ /* @__PURE__ */ jsx15(EyeOff, {}),
2579
3352
  " ",
2580
3353
  store.config.labels.hideColumn
2581
3354
  ]
@@ -2597,12 +3370,12 @@ var DataTableHeader = ({
2597
3370
  const selectableRows = getDataTableSelectableRows(model, grouped, selection ? selection.isRowSelectable : undefined);
2598
3371
  const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
2599
3372
  const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
2600
- return /* @__PURE__ */ jsx14(TableHeader, {
2601
- children: /* @__PURE__ */ jsxs8(TableRow, {
3373
+ return /* @__PURE__ */ jsx15(TableHeader, {
3374
+ children: /* @__PURE__ */ jsxs9(TableRow, {
2602
3375
  children: [
2603
- selection ? /* @__PURE__ */ jsx14(TableHead, {
3376
+ selection ? /* @__PURE__ */ jsx15(TableHead, {
2604
3377
  className: "w-10 pr-0",
2605
- children: /* @__PURE__ */ jsx14(Checkbox, {
3378
+ children: /* @__PURE__ */ jsx15(Checkbox, {
2606
3379
  "aria-label": store.config.labels.selectAllRows,
2607
3380
  checked: allSelected,
2608
3381
  indeterminate: someSelected && !allSelected,
@@ -2616,30 +3389,30 @@ var DataTableHeader = ({
2616
3389
  }
2617
3390
  })
2618
3391
  }) : null,
2619
- draggable ? /* @__PURE__ */ jsx14(TableHead, {
3392
+ draggable ? /* @__PURE__ */ jsx15(TableHead, {
2620
3393
  className: "w-10"
2621
3394
  }) : null,
2622
3395
  model.visibleColumns.map((column) => {
2623
3396
  const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
2624
- return /* @__PURE__ */ jsx14(TableHead, {
3397
+ return /* @__PURE__ */ jsx15(TableHead, {
2625
3398
  "aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
2626
3399
  className: "relative h-12 p-0",
2627
3400
  scope: "col",
2628
3401
  style: { width: column.width },
2629
- children: /* @__PURE__ */ jsxs8(ColumnIdContext.Provider, {
3402
+ children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
2630
3403
  value: column.id,
2631
3404
  children: [
2632
- /* @__PURE__ */ jsx14(ColumnHeaderMenu, {
3405
+ /* @__PURE__ */ jsx15(ColumnHeaderMenu, {
2633
3406
  tableAtom
2634
3407
  }),
2635
- /* @__PURE__ */ jsx14(ResizeHandle, {
3408
+ /* @__PURE__ */ jsx15(ResizeHandle, {
2636
3409
  tableAtom
2637
3410
  })
2638
3411
  ]
2639
3412
  })
2640
3413
  }, column.id);
2641
3414
  }),
2642
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx14(TableHead, {
3415
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableHead, {
2643
3416
  className: "w-10"
2644
3417
  }) : null
2645
3418
  ]
@@ -2657,29 +3430,29 @@ var DataTableBody = ({
2657
3430
  const sections = groupDataTableRows(rows, fields);
2658
3431
  const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
2659
3432
  if (sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error) {
2660
- return /* @__PURE__ */ jsx14(GroupedTable, {
3433
+ return /* @__PURE__ */ jsx15(GroupedTable, {
2661
3434
  tableAtom,
2662
3435
  sections
2663
3436
  });
2664
3437
  }
2665
- return /* @__PURE__ */ jsx14(TableBody, {
2666
- children: store.config.status.error || !rows.length && !store.config.status.loading ? /* @__PURE__ */ jsx14(TableRow, {
2667
- children: /* @__PURE__ */ jsx14(TableCell, {
3438
+ return /* @__PURE__ */ jsx15(TableBody, {
3439
+ children: store.config.status.error || !rows.length && !store.config.status.loading ? /* @__PURE__ */ jsx15(TableRow, {
3440
+ children: /* @__PURE__ */ jsx15(TableCell, {
2668
3441
  className: "h-24 text-center",
2669
3442
  colSpan: Math.max(colSpan, 1),
2670
3443
  children: store.config.status.error ?? store.config.status.empty ?? store.config.labels.empty
2671
3444
  })
2672
- }) : store.config.status.loading && !rows.length ? /* @__PURE__ */ jsx14(TableRow, {
2673
- children: /* @__PURE__ */ jsx14(TableCell, {
3445
+ }) : store.config.status.loading && !rows.length ? /* @__PURE__ */ jsx15(TableRow, {
3446
+ children: /* @__PURE__ */ jsx15(TableCell, {
2674
3447
  className: "h-24 text-center",
2675
3448
  colSpan: Math.max(colSpan, 1),
2676
- children: /* @__PURE__ */ jsx14(Loading, {
3449
+ children: /* @__PURE__ */ jsx15(Loading, {
2677
3450
  label: store.config.labels.loading
2678
3451
  })
2679
3452
  })
2680
- }) : rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
3453
+ }) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
2681
3454
  value: row.id,
2682
- children: /* @__PURE__ */ jsx14(TableDataRow, {
3455
+ children: /* @__PURE__ */ jsx15(TableDataRow, {
2683
3456
  tableAtom
2684
3457
  })
2685
3458
  }, row.id))
@@ -2702,8 +3475,8 @@ var GalleryCard = ({
2702
3475
  const selection = store.config.features.selection;
2703
3476
  const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
2704
3477
  const draggable = canDragRows(store);
2705
- return /* @__PURE__ */ jsx14(Card, {
2706
- className: cn("relative gap-3 data-[drag-source=true]:opacity-40 data-[drop-position=before]:border-t-2 data-[drop-position=before]:border-t-primary data-[drop-position=after]:border-b-2 data-[drop-position=after]:border-b-primary", store.config.onRowClicked && "cursor-pointer"),
3478
+ return /* @__PURE__ */ jsx15(Card, {
3479
+ className: cn("data-[drop-position=before]:border-t-primary data-[drop-position=after]:border-b-primary relative gap-3 data-[drag-source=true]:opacity-40 data-[drop-position=after]:border-b-2 data-[drop-position=before]:border-t-2", store.config.onRowClicked && "cursor-pointer"),
2707
3480
  "data-table-row": row.id,
2708
3481
  onClick: () => store.config.onRowClicked?.(row.data),
2709
3482
  onKeyDown: (event) => {
@@ -2713,23 +3486,23 @@ var GalleryCard = ({
2713
3486
  }
2714
3487
  },
2715
3488
  tabIndex: store.config.onRowClicked ? 0 : undefined,
2716
- children: /* @__PURE__ */ jsxs8(CardHeader, {
3489
+ children: /* @__PURE__ */ jsxs9(CardHeader, {
2717
3490
  className: "pr-12",
2718
3491
  children: [
2719
- /* @__PURE__ */ jsxs8("div", {
3492
+ /* @__PURE__ */ jsxs9("div", {
2720
3493
  className: "flex items-center gap-2",
2721
3494
  children: [
2722
- selection ? /* @__PURE__ */ jsx14(Checkbox, {
3495
+ selection ? /* @__PURE__ */ jsx15(Checkbox, {
2723
3496
  "aria-label": store.config.labels.selectRow,
2724
3497
  checked: !!store.state.rowSelection[row.id],
2725
3498
  disabled: !selectable,
2726
3499
  onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
2727
3500
  onClick: (event) => event.stopPropagation()
2728
3501
  }) : null,
2729
- draggable ? /* @__PURE__ */ jsx14(DragHandle, {
3502
+ draggable ? /* @__PURE__ */ jsx15(DragHandle, {
2730
3503
  tableAtom
2731
3504
  }) : null,
2732
- tag ? /* @__PURE__ */ jsxs8(Badge, {
3505
+ tag ? /* @__PURE__ */ jsxs9(Badge, {
2733
3506
  variant: "secondary",
2734
3507
  children: [
2735
3508
  gallery.tagIcon,
@@ -2738,17 +3511,17 @@ var GalleryCard = ({
2738
3511
  }) : null
2739
3512
  ]
2740
3513
  }),
2741
- /* @__PURE__ */ jsx14(CardTitle, {
3514
+ /* @__PURE__ */ jsx15(CardTitle, {
2742
3515
  children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
2743
3516
  }),
2744
- description ? /* @__PURE__ */ jsx14("div", {
3517
+ description ? /* @__PURE__ */ jsx15("div", {
2745
3518
  className: "text-muted-foreground line-clamp-3 text-sm",
2746
3519
  children: renderCell(row, description, store.config.locale, store.config.labels)
2747
3520
  }) : null,
2748
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx14("div", {
3521
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx15("div", {
2749
3522
  className: "absolute top-4 right-4",
2750
3523
  onClick: (event) => event.stopPropagation(),
2751
- children: /* @__PURE__ */ jsx14(DataTableRowActionMenu, {
3524
+ children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
2752
3525
  tableAtom
2753
3526
  })
2754
3527
  }) : null
@@ -2765,31 +3538,31 @@ var DataTableGallery = ({
2765
3538
  const rows = fields.length ? model.sortedRows : model.pageRows;
2766
3539
  const sections = groupDataTableRows(rows, fields);
2767
3540
  if (store.config.status.error) {
2768
- return /* @__PURE__ */ jsx14("div", {
3541
+ return /* @__PURE__ */ jsx15("div", {
2769
3542
  className: "text-destructive rounded-lg border border-dashed p-10 text-center",
2770
3543
  children: store.config.status.error
2771
3544
  });
2772
3545
  }
2773
3546
  if (store.config.status.loading && !rows.length) {
2774
- return /* @__PURE__ */ jsx14("div", {
3547
+ return /* @__PURE__ */ jsx15("div", {
2775
3548
  className: "rounded-lg border border-dashed p-10 text-center",
2776
- children: /* @__PURE__ */ jsx14(Loading, {
3549
+ children: /* @__PURE__ */ jsx15(Loading, {
2777
3550
  label: store.config.labels.loading
2778
3551
  })
2779
3552
  });
2780
3553
  }
2781
3554
  if (!rows.length && !sections.length) {
2782
- return /* @__PURE__ */ jsx14("div", {
3555
+ return /* @__PURE__ */ jsx15("div", {
2783
3556
  className: "text-muted-foreground rounded-lg border border-dashed p-10 text-center",
2784
3557
  children: store.config.status.empty ?? store.config.labels.empty
2785
3558
  });
2786
3559
  }
2787
3560
  if (!fields.length) {
2788
- return /* @__PURE__ */ jsx14("div", {
3561
+ return /* @__PURE__ */ jsx15("div", {
2789
3562
  className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3",
2790
- children: rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
3563
+ children: rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
2791
3564
  value: row.id,
2792
- children: /* @__PURE__ */ jsx14(GalleryCard, {
3565
+ children: /* @__PURE__ */ jsx15(GalleryCard, {
2793
3566
  tableAtom
2794
3567
  })
2795
3568
  }, row.id))
@@ -2805,57 +3578,57 @@ var DataTableGallery = ({
2805
3578
  [section.key]: !collapsed
2806
3579
  }
2807
3580
  }));
2808
- return /* @__PURE__ */ jsxs8("section", {
3581
+ return /* @__PURE__ */ jsxs9("section", {
2809
3582
  className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
2810
3583
  "data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
2811
3584
  children: [
2812
- /* @__PURE__ */ jsxs8("div", {
3585
+ /* @__PURE__ */ jsxs9("div", {
2813
3586
  className: "hover:bg-accent flex cursor-pointer items-center gap-2 rounded-lg border p-3 transition-colors",
2814
3587
  onClick: toggleCollapsed,
2815
3588
  children: [
2816
- /* @__PURE__ */ jsxs8("button", {
3589
+ /* @__PURE__ */ jsxs9("button", {
2817
3590
  "aria-expanded": !collapsed,
2818
3591
  className: "flex flex-1 cursor-pointer items-center gap-2 text-left font-medium",
2819
3592
  type: "button",
2820
3593
  children: [
2821
- collapsed ? /* @__PURE__ */ jsx14(ChevronRight2, {
3594
+ collapsed ? /* @__PURE__ */ jsx15(ChevronRight2, {
2822
3595
  className: "size-4"
2823
- }) : /* @__PURE__ */ jsx14(ChevronDown, {
3596
+ }) : /* @__PURE__ */ jsx15(ChevronDown, {
2824
3597
  className: "size-4"
2825
3598
  }),
2826
- /* @__PURE__ */ jsx14("span", {
3599
+ /* @__PURE__ */ jsx15("span", {
2827
3600
  className: "flex-1",
2828
3601
  children: section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.data)) ?? section.groupId
2829
3602
  }),
2830
- /* @__PURE__ */ jsx14(Badge, {
3603
+ /* @__PURE__ */ jsx15(Badge, {
2831
3604
  variant: "secondary",
2832
3605
  children: section.rows.length
2833
3606
  })
2834
3607
  ]
2835
3608
  }),
2836
- /* @__PURE__ */ jsx14(GroupActions, {
3609
+ /* @__PURE__ */ jsx15(GroupActions, {
2837
3610
  actions: section.field.actions,
2838
3611
  groupId: section.groupId,
2839
3612
  title: section.field.actionsLabel ?? store.config.labels.actions
2840
3613
  })
2841
3614
  ]
2842
3615
  }),
2843
- !collapsed ? section.children.length ? renderSections(section.children) : section.rows.length ? /* @__PURE__ */ jsx14("div", {
3616
+ !collapsed ? section.children.length ? renderSections(section.children) : section.rows.length ? /* @__PURE__ */ jsx15("div", {
2844
3617
  className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3",
2845
- children: section.rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
3618
+ children: section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
2846
3619
  value: row.id,
2847
- children: /* @__PURE__ */ jsx14(GalleryCard, {
3620
+ children: /* @__PURE__ */ jsx15(GalleryCard, {
2848
3621
  tableAtom
2849
3622
  })
2850
3623
  }, `${section.key}:${row.id}`))
2851
- }) : /* @__PURE__ */ jsx14("div", {
3624
+ }) : /* @__PURE__ */ jsx15("div", {
2852
3625
  className: "text-muted-foreground rounded-lg border border-dashed p-8 text-center",
2853
3626
  children: section.field.renderEmptyGroup?.(section.groupId) ?? store.config.labels.empty
2854
3627
  }) : null
2855
3628
  ]
2856
3629
  }, section.key);
2857
3630
  });
2858
- return /* @__PURE__ */ jsx14("div", {
3631
+ return /* @__PURE__ */ jsx15("div", {
2859
3632
  className: "space-y-4",
2860
3633
  children: renderSections(sections)
2861
3634
  });
@@ -2882,9 +3655,9 @@ var DataTablePagination = ({
2882
3655
  return null;
2883
3656
  const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
2884
3657
  const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
2885
- return /* @__PURE__ */ jsx14("div", {
3658
+ return /* @__PURE__ */ jsx15("div", {
2886
3659
  className: "pt-4",
2887
- children: /* @__PURE__ */ jsx14(Pagination, {
3660
+ children: /* @__PURE__ */ jsx15(Pagination, {
2888
3661
  locale: store.config.locale,
2889
3662
  messages: { [store.config.locale]: store.config.labels },
2890
3663
  onPageChange: (page) => setPagination({ page, pageSize: store.state.pageSize }),
@@ -2909,7 +3682,7 @@ var HydratedDataTable = ({
2909
3682
  });
2910
3683
  const [transientUiAtom] = useState(() => Atom.make(transientUiFromState(DEFAULT_UI_STATE)));
2911
3684
  const [transientUiState, setTransientUiState] = useAtom(transientUiAtom);
2912
- const uiState = useMemo(() => ({
3685
+ const uiState = useMemo2(() => ({
2913
3686
  ...persistedUiState,
2914
3687
  ...transientUiState,
2915
3688
  grouping: persistedUiState.grouping ?? initialGrouping
@@ -2978,17 +3751,17 @@ var HydratedDataTable = ({
2978
3751
  setUiState,
2979
3752
  uiState
2980
3753
  ]);
2981
- return /* @__PURE__ */ jsxs8("div", {
3754
+ return /* @__PURE__ */ jsxs9("div", {
2982
3755
  className: "w-full max-w-full min-w-0 rounded-md",
2983
3756
  "data-table-root": "",
2984
3757
  children: [
2985
- /* @__PURE__ */ jsx14(DataTableToolbar, {
3758
+ /* @__PURE__ */ jsx15(DataTableToolbar, {
2986
3759
  tableAtom
2987
3760
  }),
2988
- /* @__PURE__ */ jsx14(DataTableContent, {
3761
+ /* @__PURE__ */ jsx15(DataTableContent, {
2989
3762
  tableAtom
2990
3763
  }),
2991
- /* @__PURE__ */ jsx14(DataTablePagination, {
3764
+ /* @__PURE__ */ jsx15(DataTablePagination, {
2992
3765
  tableAtom
2993
3766
  })
2994
3767
  ]
@@ -3013,7 +3786,7 @@ var DataTable = (props) => {
3013
3786
  });
3014
3787
  });
3015
3788
  const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
3016
- const persistedUiState = useMemo(() => AsyncResult.isSuccess(persistedUiResult) ? {
3789
+ const persistedUiState = useMemo2(() => AsyncResult.isSuccess(persistedUiResult) ? {
3017
3790
  ...persistedUiResult.value,
3018
3791
  columnVisibility: {
3019
3792
  ...initialColumnVisibility,
@@ -3021,13 +3794,13 @@ var DataTable = (props) => {
3021
3794
  }
3022
3795
  } : undefined, [initialColumnVisibility, persistedUiResult]);
3023
3796
  if (!persistedUiState || AsyncResult.isWaiting(persistedUiResult)) {
3024
- return /* @__PURE__ */ jsx14("div", {
3797
+ return /* @__PURE__ */ jsx15("div", {
3025
3798
  "aria-busy": "true",
3026
3799
  className: "invisible w-full max-w-full min-w-0 rounded-md",
3027
3800
  "data-table-root": ""
3028
3801
  });
3029
3802
  }
3030
- return /* @__PURE__ */ jsx14(HydratedDataTable, {
3803
+ return /* @__PURE__ */ jsx15(HydratedDataTable, {
3031
3804
  ...props,
3032
3805
  locale,
3033
3806
  persistedUiState,
@@ -3039,28 +3812,28 @@ var DataTableContent = ({
3039
3812
  }) => {
3040
3813
  const [store] = useTableAtom(tableAtom);
3041
3814
  if (store.config.features.gallery && store.state.view === "gallery") {
3042
- return /* @__PURE__ */ jsx14(DataTableGallery, {
3815
+ return /* @__PURE__ */ jsx15(DataTableGallery, {
3043
3816
  tableAtom
3044
3817
  });
3045
3818
  }
3046
3819
  const model = deriveModel(store);
3047
3820
  const width = getDataTableWidth(model.visibleColumns, (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0));
3048
- return /* @__PURE__ */ jsxs8(ScrollArea, {
3821
+ return /* @__PURE__ */ jsxs9(ScrollArea, {
3049
3822
  className: "max-w-full min-w-0",
3050
3823
  children: [
3051
- /* @__PURE__ */ jsxs8(Table, {
3824
+ /* @__PURE__ */ jsxs9(Table, {
3052
3825
  className: "table-fixed",
3053
3826
  style: { width: `max(100%, ${width}px)` },
3054
3827
  children: [
3055
- /* @__PURE__ */ jsx14(DataTableHeader, {
3828
+ /* @__PURE__ */ jsx15(DataTableHeader, {
3056
3829
  tableAtom
3057
3830
  }),
3058
- /* @__PURE__ */ jsx14(DataTableBody, {
3831
+ /* @__PURE__ */ jsx15(DataTableBody, {
3059
3832
  tableAtom
3060
3833
  })
3061
3834
  ]
3062
3835
  }),
3063
- /* @__PURE__ */ jsx14(ScrollBar, {
3836
+ /* @__PURE__ */ jsx15(ScrollBar, {
3064
3837
  orientation: "horizontal"
3065
3838
  })
3066
3839
  ]
@@ -3070,7 +3843,7 @@ var DataTableListCell = (props) => {
3070
3843
  const locale = useKrakstackLocale3(props.locale);
3071
3844
  const resolvedProps = { ...props, locale };
3072
3845
  if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
3073
- return /* @__PURE__ */ jsx14(EditableDataTableListCell, {
3846
+ return /* @__PURE__ */ jsx15(EditableDataTableListCell, {
3074
3847
  ...resolvedProps
3075
3848
  });
3076
3849
  }
@@ -3078,17 +3851,17 @@ var DataTableListCell = (props) => {
3078
3851
  const labels = dataTableMessages(locale, resolvedProps.messages);
3079
3852
  const hasItems = resolvedProps.items.length > 0;
3080
3853
  if (!itemActions?.length && !hasItems) {
3081
- return /* @__PURE__ */ jsx14(DataTableListSummary, {
3854
+ return /* @__PURE__ */ jsx15(DataTableListSummary, {
3082
3855
  ...summaryProps
3083
3856
  });
3084
3857
  }
3085
3858
  const menuLabel = actionsLabel ?? (itemActions?.length ? labels.actions : labels.listDetails);
3086
- return /* @__PURE__ */ jsx14("div", {
3859
+ return /* @__PURE__ */ jsx15("div", {
3087
3860
  className: "grid min-h-16 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0",
3088
3861
  "data-slot": "data-table-list-cell",
3089
3862
  onClick: (event) => event.stopPropagation(),
3090
3863
  onPointerDown: (event) => event.stopPropagation(),
3091
- children: /* @__PURE__ */ jsx14(DataTableListMenu, {
3864
+ children: /* @__PURE__ */ jsx15(DataTableListMenu, {
3092
3865
  actions: itemActions ?? [],
3093
3866
  display: resolvedProps.display,
3094
3867
  force: hasItems,
@@ -3097,16 +3870,16 @@ var DataTableListCell = (props) => {
3097
3870
  locale,
3098
3871
  messages: resolvedProps.messages,
3099
3872
  onItemClick,
3100
- trigger: /* @__PURE__ */ jsxs8(Button, {
3873
+ trigger: /* @__PURE__ */ jsxs9(Button, {
3101
3874
  "aria-label": menuLabel,
3102
3875
  className: "h-full w-full min-w-0 justify-between rounded-none px-2 focus-visible:ring-inset",
3103
3876
  variant: "ghost",
3104
3877
  children: [
3105
- /* @__PURE__ */ jsx14(DataTableListSummaryContent, {
3878
+ /* @__PURE__ */ jsx15(DataTableListSummaryContent, {
3106
3879
  ...summaryProps,
3107
3880
  showMenu: false
3108
3881
  }),
3109
- /* @__PURE__ */ jsx14(ChevronDown, {})
3882
+ /* @__PURE__ */ jsx15(ChevronDown, {})
3110
3883
  ]
3111
3884
  })
3112
3885
  })
@@ -3142,7 +3915,7 @@ var EditableDataTableListCell = ({
3142
3915
  id: "data-table-list-remove",
3143
3916
  closeOnClick: false,
3144
3917
  name: labels.removeItem,
3145
- icon: /* @__PURE__ */ jsx14(Trash2, {}),
3918
+ icon: /* @__PURE__ */ jsx15(Trash2, {}),
3146
3919
  variant: "destructive",
3147
3920
  onClick: (item) => {
3148
3921
  if (item.value === undefined)
@@ -3153,12 +3926,12 @@ var EditableDataTableListCell = ({
3153
3926
  }
3154
3927
  ] : []
3155
3928
  ];
3156
- return /* @__PURE__ */ jsx14("div", {
3929
+ return /* @__PURE__ */ jsx15("div", {
3157
3930
  "data-slot": "data-table-list-cell",
3158
3931
  className: "grid min-h-16 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0",
3159
3932
  onClick: (event) => event.stopPropagation(),
3160
3933
  onPointerDown: (event) => event.stopPropagation(),
3161
- children: /* @__PURE__ */ jsx14(DataTableListMenu, {
3934
+ children: /* @__PURE__ */ jsx15(DataTableListMenu, {
3162
3935
  actions,
3163
3936
  addEmptyLabel: emptyLabel,
3164
3937
  addLabel: labels.addItem,
@@ -3175,12 +3948,12 @@ var EditableDataTableListCell = ({
3175
3948
  onAdd(item.value);
3176
3949
  setSelected((current) => [...current, item]);
3177
3950
  } : undefined,
3178
- trigger: /* @__PURE__ */ jsxs8(Button, {
3951
+ trigger: /* @__PURE__ */ jsxs9(Button, {
3179
3952
  "aria-label": manageLabel,
3180
3953
  className: "h-full w-full min-w-0 justify-between rounded-none px-2 focus-visible:ring-inset",
3181
3954
  variant: "ghost",
3182
3955
  children: [
3183
- /* @__PURE__ */ jsx14(DataTableListSummaryContent, {
3956
+ /* @__PURE__ */ jsx15(DataTableListSummaryContent, {
3184
3957
  emptyLabel,
3185
3958
  items: selected,
3186
3959
  display,
@@ -3188,7 +3961,7 @@ var EditableDataTableListCell = ({
3188
3961
  visibleCount,
3189
3962
  totalCount: selectedTotal
3190
3963
  }),
3191
- /* @__PURE__ */ jsx14(ChevronDown, {})
3964
+ /* @__PURE__ */ jsx15(ChevronDown, {})
3192
3965
  ]
3193
3966
  })
3194
3967
  })
@@ -3212,7 +3985,7 @@ var DataTableListMenu = ({
3212
3985
  trigger
3213
3986
  }) => {
3214
3987
  const entries = items.map((item) => {
3215
- const normalized = Schema.is(Schema.String)(item) ? { label: item } : item;
3988
+ const normalized = Schema2.is(Schema2.String)(item) ? { label: item } : item;
3216
3989
  const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
3217
3990
  return { item: normalized, visibleActions };
3218
3991
  });
@@ -3221,41 +3994,41 @@ var DataTableListMenu = ({
3221
3994
  return null;
3222
3995
  const labels = dataTableMessages(locale, messages);
3223
3996
  const resolvedLabel = label ?? (hasActions ? labels.actions : labels.listDetails);
3224
- return /* @__PURE__ */ jsxs8(DropdownMenu, {
3997
+ return /* @__PURE__ */ jsxs9(DropdownMenu, {
3225
3998
  children: [
3226
- /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
3999
+ /* @__PURE__ */ jsx15(DropdownMenuTrigger, {
3227
4000
  onClick: (event) => event.stopPropagation(),
3228
4001
  onPointerDown: (event) => event.stopPropagation(),
3229
- render: trigger ?? /* @__PURE__ */ jsx14(Button, {
4002
+ render: trigger ?? /* @__PURE__ */ jsx15(Button, {
3230
4003
  "aria-label": resolvedLabel,
3231
4004
  className: cn("size-8 shrink-0", className),
3232
4005
  size: "icon",
3233
4006
  variant: "ghost",
3234
- children: /* @__PURE__ */ jsx14(MoreHorizontal, {})
4007
+ children: /* @__PURE__ */ jsx15(MoreHorizontal, {})
3235
4008
  })
3236
4009
  }),
3237
- /* @__PURE__ */ jsx14(DropdownMenuContent, {
4010
+ /* @__PURE__ */ jsx15(DropdownMenuContent, {
3238
4011
  align: "end",
3239
4012
  className: "max-h-[min(18rem,var(--available-height))] w-72 max-w-[calc(100vw-2rem)]",
3240
4013
  onClick: (event) => event.stopPropagation(),
3241
4014
  onPointerDown: (event) => event.stopPropagation(),
3242
- children: /* @__PURE__ */ jsxs8(DropdownMenuGroup, {
4015
+ children: /* @__PURE__ */ jsxs9(DropdownMenuGroup, {
3243
4016
  children: [
3244
- /* @__PURE__ */ jsx14(DropdownMenuLabel, {
4017
+ /* @__PURE__ */ jsx15(DropdownMenuLabel, {
3245
4018
  children: resolvedLabel
3246
4019
  }),
3247
- /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}),
3248
- entries.map(({ item, visibleActions }, index) => visibleActions.length ? /* @__PURE__ */ jsxs8(DropdownMenuSub, {
4020
+ /* @__PURE__ */ jsx15(DropdownMenuSeparator, {}),
4021
+ entries.map(({ item, visibleActions }, index) => visibleActions.length ? /* @__PURE__ */ jsxs9(DropdownMenuSub, {
3249
4022
  children: [
3250
- /* @__PURE__ */ jsx14(DropdownMenuSubTrigger, {
3251
- children: /* @__PURE__ */ jsx14(DataTableListEntry, {
4023
+ /* @__PURE__ */ jsx15(DropdownMenuSubTrigger, {
4024
+ children: /* @__PURE__ */ jsx15(DataTableListEntry, {
3252
4025
  item,
3253
4026
  appearance: display === "icon" ? "detail" : "list"
3254
4027
  })
3255
4028
  }),
3256
- /* @__PURE__ */ jsx14(DropdownMenuSubContent, {
4029
+ /* @__PURE__ */ jsx15(DropdownMenuSubContent, {
3257
4030
  className: "w-max",
3258
- children: visibleActions.map((action) => /* @__PURE__ */ jsxs8(DropdownMenuItem, {
4031
+ children: visibleActions.map((action) => /* @__PURE__ */ jsxs9(DropdownMenuItem, {
3259
4032
  closeOnClick: action.closeOnClick,
3260
4033
  disabled: action.disabled?.(item),
3261
4034
  onClick: (event) => {
@@ -3270,21 +4043,21 @@ var DataTableListMenu = ({
3270
4043
  }, action.id ?? action.name))
3271
4044
  })
3272
4045
  ]
3273
- }, item.value ?? `${item.label}-${index}`) : /* @__PURE__ */ jsx14(DropdownMenuItem, {
4046
+ }, item.value ?? `${item.label}-${index}`) : /* @__PURE__ */ jsx15(DropdownMenuItem, {
3274
4047
  closeOnClick: Boolean(onItemClick),
3275
4048
  onClick: (event) => {
3276
4049
  event.stopPropagation();
3277
4050
  onItemClick?.(item);
3278
4051
  },
3279
- children: /* @__PURE__ */ jsx14(DataTableListEntry, {
4052
+ children: /* @__PURE__ */ jsx15(DataTableListEntry, {
3280
4053
  item,
3281
4054
  appearance: display === "icon" ? "detail" : "list"
3282
4055
  })
3283
4056
  }, item.value ?? `${item.label}-${index}`)),
3284
- onAdd && addOptions?.length ? /* @__PURE__ */ jsxs8(Fragment, {
4057
+ onAdd && addOptions?.length ? /* @__PURE__ */ jsxs9(Fragment, {
3285
4058
  children: [
3286
- entries.length ? /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}) : null,
3287
- /* @__PURE__ */ jsx14(DataTableListAddMenu, {
4059
+ entries.length ? /* @__PURE__ */ jsx15(DropdownMenuSeparator, {}) : null,
4060
+ /* @__PURE__ */ jsx15(DataTableListAddMenu, {
3288
4061
  emptyLabel: addEmptyLabel,
3289
4062
  label: addLabel ?? labels.addItem,
3290
4063
  locale,
@@ -3319,28 +4092,28 @@ var DataTableListAddMenu = ({
3319
4092
  const labels = dataTableMessages(locale, messages);
3320
4093
  const normalizedSearch = search.trim().toLocaleLowerCase(locale);
3321
4094
  const filtered = normalizedSearch ? options.filter((item) => item.label.toLocaleLowerCase(locale).includes(normalizedSearch)) : options;
3322
- return /* @__PURE__ */ jsxs8(DropdownMenuSub, {
4095
+ return /* @__PURE__ */ jsxs9(DropdownMenuSub, {
3323
4096
  onOpenChange: (open) => {
3324
4097
  if (!open)
3325
4098
  setSearch("");
3326
4099
  },
3327
4100
  children: [
3328
- /* @__PURE__ */ jsxs8(DropdownMenuSubTrigger, {
4101
+ /* @__PURE__ */ jsxs9(DropdownMenuSubTrigger, {
3329
4102
  children: [
3330
- /* @__PURE__ */ jsx14(Plus, {}),
4103
+ /* @__PURE__ */ jsx15(Plus, {}),
3331
4104
  label
3332
4105
  ]
3333
4106
  }),
3334
- /* @__PURE__ */ jsxs8(DropdownMenuSubContent, {
4107
+ /* @__PURE__ */ jsxs9(DropdownMenuSubContent, {
3335
4108
  className: "w-64",
3336
4109
  children: [
3337
- /* @__PURE__ */ jsxs8("div", {
4110
+ /* @__PURE__ */ jsxs9("div", {
3338
4111
  className: "relative p-1",
3339
4112
  children: [
3340
- /* @__PURE__ */ jsx14(Search, {
4113
+ /* @__PURE__ */ jsx15(Search, {
3341
4114
  className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
3342
4115
  }),
3343
- /* @__PURE__ */ jsx14(Input, {
4116
+ /* @__PURE__ */ jsx15(Input, {
3344
4117
  "aria-label": searchLabel,
3345
4118
  className: "h-8 pl-8",
3346
4119
  onChange: (event) => setSearch(event.target.value),
@@ -3354,15 +4127,15 @@ var DataTableListAddMenu = ({
3354
4127
  })
3355
4128
  ]
3356
4129
  }),
3357
- /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}),
3358
- filtered.length ? filtered.map((item) => /* @__PURE__ */ jsx14(DropdownMenuItem, {
4130
+ /* @__PURE__ */ jsx15(DropdownMenuSeparator, {}),
4131
+ filtered.length ? filtered.map((item) => /* @__PURE__ */ jsx15(DropdownMenuItem, {
3359
4132
  closeOnClick: false,
3360
4133
  onClick: () => onAdd(item),
3361
- children: /* @__PURE__ */ jsx14(DataTableListEntry, {
4134
+ children: /* @__PURE__ */ jsx15(DataTableListEntry, {
3362
4135
  item,
3363
4136
  appearance: display === "icon" ? "detail" : "list"
3364
4137
  })
3365
- }, item.value)) : /* @__PURE__ */ jsx14("div", {
4138
+ }, item.value)) : /* @__PURE__ */ jsx15("div", {
3366
4139
  className: "text-muted-foreground px-2 py-1.5 text-sm",
3367
4140
  children: emptyLabel
3368
4141
  })
@@ -3381,31 +4154,31 @@ var DataTableListSummaryContent = ({
3381
4154
  showMenu,
3382
4155
  visibleCount = 3
3383
4156
  }) => {
3384
- const normalized = items.map((item) => Schema.is(Schema.String)(item) ? { label: item } : item);
4157
+ const normalized = items.map((item) => Schema2.is(Schema2.String)(item) ? { label: item } : item);
3385
4158
  if (!normalized.length)
3386
- return /* @__PURE__ */ jsx14("span", {
4159
+ return /* @__PURE__ */ jsx15("span", {
3387
4160
  className: "text-muted-foreground",
3388
4161
  children: emptyLabel
3389
4162
  });
3390
4163
  const visible = normalized.slice(0, Math.max(0, visibleCount));
3391
4164
  const remaining = Math.max(totalCount - visible.length, 0);
3392
4165
  if (display === "icon") {
3393
- return /* @__PURE__ */ jsx14(TooltipProvider, {
3394
- children: /* @__PURE__ */ jsxs8("span", {
4166
+ return /* @__PURE__ */ jsx15(TooltipProvider, {
4167
+ children: /* @__PURE__ */ jsxs9("span", {
3395
4168
  className: "flex items-center",
3396
4169
  children: [
3397
- visible.map((item, index) => /* @__PURE__ */ jsx14(DataTableListEntry, {
4170
+ visible.map((item, index) => /* @__PURE__ */ jsx15(DataTableListEntry, {
3398
4171
  item,
3399
4172
  appearance: "icon"
3400
4173
  }, item.value ?? `${item.label}-${index}`)),
3401
- remaining ? /* @__PURE__ */ jsxs8("span", {
4174
+ remaining ? /* @__PURE__ */ jsxs9("span", {
3402
4175
  className: "bg-secondary text-secondary-foreground -ml-1 flex size-8 items-center justify-center rounded-full",
3403
4176
  children: [
3404
4177
  "+",
3405
4178
  remaining
3406
4179
  ]
3407
4180
  }) : null,
3408
- remaining && showMenu ? /* @__PURE__ */ jsx14(DataTableListMenu, {
4181
+ remaining && showMenu ? /* @__PURE__ */ jsx15(DataTableListMenu, {
3409
4182
  actions: [],
3410
4183
  display,
3411
4184
  force: true,
@@ -3417,17 +4190,17 @@ var DataTableListSummaryContent = ({
3417
4190
  })
3418
4191
  });
3419
4192
  }
3420
- return /* @__PURE__ */ jsxs8("span", {
4193
+ return /* @__PURE__ */ jsxs9("span", {
3421
4194
  className: "inline-flex min-w-0 items-center gap-2 text-sm",
3422
4195
  children: [
3423
- /* @__PURE__ */ jsxs8("span", {
4196
+ /* @__PURE__ */ jsxs9("span", {
3424
4197
  className: "truncate",
3425
4198
  children: [
3426
4199
  visible.map((item) => item.label).join(", "),
3427
4200
  remaining ? ` +${remaining}` : ""
3428
4201
  ]
3429
4202
  }),
3430
- remaining && showMenu ? /* @__PURE__ */ jsx14(DataTableListMenu, {
4203
+ remaining && showMenu ? /* @__PURE__ */ jsx15(DataTableListMenu, {
3431
4204
  actions: [],
3432
4205
  display,
3433
4206
  force: true,
@@ -3438,7 +4211,7 @@ var DataTableListSummaryContent = ({
3438
4211
  ]
3439
4212
  });
3440
4213
  };
3441
- var DataTableListSummary = (props) => /* @__PURE__ */ jsx14(DataTableListSummaryContent, {
4214
+ var DataTableListSummary = (props) => /* @__PURE__ */ jsx15(DataTableListSummaryContent, {
3442
4215
  ...props,
3443
4216
  showMenu: true
3444
4217
  });
@@ -3446,40 +4219,40 @@ var DataTableListEntry = ({
3446
4219
  item,
3447
4220
  appearance
3448
4221
  }) => {
3449
- const icon = /* @__PURE__ */ jsx14("span", {
4222
+ const icon = /* @__PURE__ */ jsx15("span", {
3450
4223
  "aria-hidden": "true",
3451
4224
  className: "bg-secondary text-secondary-foreground flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full",
3452
- children: item.imageSrc ? /* @__PURE__ */ jsx14("img", {
4225
+ children: item.imageSrc ? /* @__PURE__ */ jsx15("img", {
3453
4226
  alt: "",
3454
4227
  src: item.imageSrc,
3455
4228
  className: "size-full object-cover"
3456
4229
  }) : item.icon ?? item.label.slice(0, 2).toUpperCase()
3457
4230
  });
3458
4231
  if (appearance === "list") {
3459
- return /* @__PURE__ */ jsx14("span", {
4232
+ return /* @__PURE__ */ jsx15("span", {
3460
4233
  className: "min-w-0 flex-1 truncate",
3461
4234
  title: item.label,
3462
4235
  children: item.label
3463
4236
  });
3464
4237
  }
3465
- return appearance === "icon" ? /* @__PURE__ */ jsxs8(Tooltip, {
4238
+ return appearance === "icon" ? /* @__PURE__ */ jsxs9(Tooltip, {
3466
4239
  children: [
3467
- /* @__PURE__ */ jsx14(TooltipTrigger, {
3468
- render: /* @__PURE__ */ jsx14("span", {
4240
+ /* @__PURE__ */ jsx15(TooltipTrigger, {
4241
+ render: /* @__PURE__ */ jsx15("span", {
3469
4242
  className: "-ml-1 inline-flex rounded-full",
3470
4243
  "aria-label": item.label
3471
4244
  }),
3472
4245
  children: icon
3473
4246
  }),
3474
- /* @__PURE__ */ jsx14(TooltipContent, {
4247
+ /* @__PURE__ */ jsx15(TooltipContent, {
3475
4248
  children: item.label
3476
4249
  })
3477
4250
  ]
3478
- }) : /* @__PURE__ */ jsxs8("span", {
4251
+ }) : /* @__PURE__ */ jsxs9("span", {
3479
4252
  className: "flex min-w-0 flex-1 items-center gap-2 text-left",
3480
4253
  children: [
3481
4254
  icon,
3482
- /* @__PURE__ */ jsx14("span", {
4255
+ /* @__PURE__ */ jsx15("span", {
3483
4256
  className: "truncate",
3484
4257
  children: item.label
3485
4258
  })
@@ -3491,17 +4264,17 @@ var DataTableListEntry = ({
3491
4264
  import { useKrakstackLocale as useKrakstackLocale4 } from "@krak-stack/registry/krakstack-provider";
3492
4265
 
3493
4266
  // ../../src/services/events/record.ts
3494
- import { Option as Option2, Schema as Schema2 } from "effect";
3495
- var TextValue = Schema2.Struct({ stringValue: Schema2.String }).annotate({
4267
+ import { Option as Option3, Schema as Schema3 } from "effect";
4268
+ var TextValue = Schema3.Struct({ stringValue: Schema3.String }).annotate({
3496
4269
  identifier: "EventTextValue"
3497
4270
  });
3498
- var TextArrayValue = Schema2.Struct({
3499
- arrayValue: Schema2.Struct({ values: Schema2.Array(TextValue) })
4271
+ var TextArrayValue = Schema3.Struct({
4272
+ arrayValue: Schema3.Struct({ values: Schema3.Array(TextValue) })
3500
4273
  }).annotate({ identifier: "EventTextArrayValue" });
3501
- var eventTextAttribute = (record, key) => Schema2.decodeUnknownOption(TextValue)(record.attributes.find((attribute) => attribute.key === key)?.value).pipe(Option2.map((value) => value.stringValue), Option2.getOrNull);
4274
+ var eventTextAttribute = (record, key) => Schema3.decodeUnknownOption(TextValue)(record.attributes.find((attribute) => attribute.key === key)?.value).pipe(Option3.map((value) => value.stringValue), Option3.getOrNull);
3502
4275
 
3503
4276
  // ../../src/services/events/client/audit-log-table.tsx
3504
- import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
4277
+ import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
3505
4278
  var translations = {
3506
4279
  en: {
3507
4280
  title: "Activity history",
@@ -3617,13 +4390,13 @@ var AuditLogTable = ({
3617
4390
  },
3618
4391
  cellRenderer: ({ data }) => {
3619
4392
  const impersonatorId = eventTextAttribute(data, "app.auth.impersonator.id");
3620
- return /* @__PURE__ */ jsxs9("div", {
4393
+ return /* @__PURE__ */ jsxs10("div", {
3621
4394
  className: "flex min-w-0 flex-col gap-1",
3622
4395
  children: [
3623
- /* @__PURE__ */ jsx15(DataTableReferenceCell, {
4396
+ /* @__PURE__ */ jsx16(DataTableReferenceCell, {
3624
4397
  item: getActor(data)
3625
4398
  }),
3626
- impersonatorId !== null ? /* @__PURE__ */ jsxs9("span", {
4399
+ impersonatorId !== null ? /* @__PURE__ */ jsxs10("span", {
3627
4400
  className: "text-muted-foreground text-xs",
3628
4401
  children: [
3629
4402
  labels.impersonatedBy,
@@ -3645,10 +4418,10 @@ var AuditLogTable = ({
3645
4418
  }
3646
4419
  }
3647
4420
  ];
3648
- return /* @__PURE__ */ jsx15("section", {
4421
+ return /* @__PURE__ */ jsx16("section", {
3649
4422
  "aria-label": labels.title,
3650
4423
  className: "flex flex-col gap-4",
3651
- children: /* @__PURE__ */ jsx15(DataTable, {
4424
+ children: /* @__PURE__ */ jsx16(DataTable, {
3652
4425
  locale,
3653
4426
  status,
3654
4427
  state,
@@ -3658,11 +4431,11 @@ var AuditLogTable = ({
3658
4431
  }) : undefined,
3659
4432
  features: {
3660
4433
  toolbar: state && onStateChange ? {
3661
- items: /* @__PURE__ */ jsxs9(MenubarMenu, {
4434
+ items: /* @__PURE__ */ jsxs10(MenubarMenu, {
3662
4435
  children: [
3663
- /* @__PURE__ */ jsxs9(MenubarTrigger, {
4436
+ /* @__PURE__ */ jsxs10(MenubarTrigger, {
3664
4437
  children: [
3665
- /* @__PURE__ */ jsx15(ListFilterIcon, {
4438
+ /* @__PURE__ */ jsx16(ListFilterIcon, {
3666
4439
  "aria-hidden": "true",
3667
4440
  "data-icon": "inline-start"
3668
4441
  }),
@@ -3670,11 +4443,11 @@ var AuditLogTable = ({
3670
4443
  state.eventName ? `: ${events.find((event) => event.value === state.eventName)?.label ?? state.eventName}` : ""
3671
4444
  ]
3672
4445
  }),
3673
- /* @__PURE__ */ jsx15(MenubarContent, {
4446
+ /* @__PURE__ */ jsx16(MenubarContent, {
3674
4447
  className: "w-80",
3675
- children: /* @__PURE__ */ jsxs9(MenubarGroup, {
4448
+ children: /* @__PURE__ */ jsxs10(MenubarGroup, {
3676
4449
  children: [
3677
- /* @__PURE__ */ jsx15(MenubarItem, {
4450
+ /* @__PURE__ */ jsx16(MenubarItem, {
3678
4451
  onClick: () => onStateChange({
3679
4452
  ...state,
3680
4453
  eventName: undefined,
@@ -3682,7 +4455,7 @@ var AuditLogTable = ({
3682
4455
  }),
3683
4456
  children: labels.allEvents
3684
4457
  }),
3685
- events.map((event) => /* @__PURE__ */ jsx15(MenubarItem, {
4458
+ events.map((event) => /* @__PURE__ */ jsx16(MenubarItem, {
3686
4459
  onClick: () => onStateChange({
3687
4460
  ...state,
3688
4461
  eventName: event.value,