@aircall/ds 0.17.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,15 +3,16 @@ import { createContext, useCallback, useContext, useSyncExternalStore } from "re
3
3
  import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
4
4
  import { clsx } from "clsx";
5
5
  import { extendTailwindMerge } from "tailwind-merge";
6
- import { ArrowDownToLine, ArrowLeft, ArrowRight, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsUpDownIcon, CircleAlert, CircleAlertIcon, CircleCheck, FLAGS, FlagUs, Info, Loader2Icon, Minus, MinusIcon, MoreHorizontalIcon, PanelLeftIcon, Plus, Search, Smile, TriangleAlertIcon, XIcon } from "@aircall/react-icons";
6
+ import { ArrowDownToLine, ArrowLeft, ArrowRight, Backward10, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsUpDownIcon, CircleAlert, CircleAlertIcon, CircleCheck, FLAGS, FastForward, FlagUs, Forward10, Info, Loader2Icon, Minus, MinusIcon, MoreHorizontalIcon, PanelLeftIcon, Pause, Play, Plus, Rewind, RotateCcw, Search, Smile, TriangleAlertIcon, XIcon } from "@aircall/react-icons";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { Button as Button$1 } from "@base-ui/react/button";
9
9
  import { cva } from "class-variance-authority";
10
10
  import i18next from "i18next";
11
- import { AlertDialog as AlertDialog$1 } from "@base-ui/react/alert-dialog";
12
- import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
13
11
  import { mergeProps } from "@base-ui/react/merge-props";
12
+ import { Slider as Slider$1 } from "@base-ui/react/slider";
14
13
  import { useRender } from "@base-ui/react/use-render";
14
+ import { AlertDialog as AlertDialog$1 } from "@base-ui/react/alert-dialog";
15
+ import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
15
16
  import { Separator as Separator$1 } from "@base-ui/react/separator";
16
17
  import { DayPicker, getDefaultClassNames } from "react-day-picker";
17
18
  import useEmblaCarousel from "embla-carousel-react";
@@ -22,6 +23,7 @@ import { Combobox as Combobox$1 } from "@base-ui/react";
22
23
  import { Command as Command$1 } from "cmdk";
23
24
  import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
24
25
  import { flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
26
+ import { useVirtualizer } from "@tanstack/react-virtual";
25
27
  import { checkboxesFeature, hotkeysCoreFeature, selectionFeature, syncDataLoaderFeature } from "@headless-tree/core";
26
28
  import { useTree } from "@headless-tree/react";
27
29
  import { useControllableState } from "@aircall/hooks";
@@ -38,7 +40,6 @@ import { OTPInput, OTPInputContext } from "input-otp";
38
40
  import { Progress as Progress$1 } from "@base-ui/react/progress";
39
41
  import { Select as Select$1 } from "@base-ui/react/select";
40
42
  import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
41
- import { Slider as Slider$1 } from "@base-ui/react/slider";
42
43
  import { Toaster as Toaster$1, toast } from "sonner";
43
44
  import { Switch as Switch$1 } from "@base-ui/react/switch";
44
45
  import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
@@ -236,7 +237,8 @@ const de = {
236
237
  "actionBar.clearSelection": "Auswahl aufheben",
237
238
  "actionBar.itemsSelected": "{{count}} Elemente ausgewählt.",
238
239
  "fieldLabel.required": "(erforderlich)",
239
- "fieldLabel.optional": "(optional)"
240
+ "fieldLabel.optional": "(optional)",
241
+ "fieldLabel.moreInfo": "Weitere Informationen"
240
242
  };
241
243
  var de_default = de;
242
244
 
@@ -263,7 +265,8 @@ const en = {
263
265
  "actionBar.clearSelection": "Clear selection",
264
266
  "actionBar.itemsSelected": "{{count}} items selected.",
265
267
  "fieldLabel.required": "(required)",
266
- "fieldLabel.optional": "(optional)"
268
+ "fieldLabel.optional": "(optional)",
269
+ "fieldLabel.moreInfo": "More information"
267
270
  };
268
271
  var en_default = en;
269
272
 
@@ -290,7 +293,8 @@ const es = {
290
293
  "actionBar.clearSelection": "Borrar selección",
291
294
  "actionBar.itemsSelected": "{{count}} elementos seleccionados.",
292
295
  "fieldLabel.required": "(obligatorio)",
293
- "fieldLabel.optional": "(opcional)"
296
+ "fieldLabel.optional": "(opcional)",
297
+ "fieldLabel.moreInfo": "Más información"
294
298
  };
295
299
  var es_default = es;
296
300
 
@@ -317,7 +321,8 @@ const fr = {
317
321
  "actionBar.clearSelection": "Effacer la sélection",
318
322
  "actionBar.itemsSelected": "{{count}} éléments sélectionnés.",
319
323
  "fieldLabel.required": "(obligatoire)",
320
- "fieldLabel.optional": "(facultatif)"
324
+ "fieldLabel.optional": "(facultatif)",
325
+ "fieldLabel.moreInfo": "Plus d'informations"
321
326
  };
322
327
  var fr_default = fr;
323
328
 
@@ -344,7 +349,8 @@ const it = {
344
349
  "actionBar.clearSelection": "Cancella selezione",
345
350
  "actionBar.itemsSelected": "{{count}} elementi selezionati.",
346
351
  "fieldLabel.required": "(obbligatorio)",
347
- "fieldLabel.optional": "(facoltativo)"
352
+ "fieldLabel.optional": "(facoltativo)",
353
+ "fieldLabel.moreInfo": "Maggiori informazioni"
348
354
  };
349
355
  var it_default = it;
350
356
 
@@ -471,6 +477,585 @@ const ActionBar = React.forwardRef((componentProps, forwardRef) => {
471
477
  });
472
478
  ActionBar.displayName = "ActionBar";
473
479
 
480
+ //#endregion
481
+ //#region src/components/spinner.tsx
482
+ const spinnerVariants = cva("animate-spin text-current", {
483
+ variants: { size: {
484
+ default: "size-4",
485
+ sm: "size-3",
486
+ lg: "size-5",
487
+ xl: "size-6"
488
+ } },
489
+ defaultVariants: { size: "default" }
490
+ });
491
+ const Spinner = React.forwardRef((componentProps, forwardRef) => {
492
+ const { className, size, ...props } = componentProps;
493
+ const t = useDsTranslation("ds");
494
+ return /* @__PURE__ */ jsx(Loader2Icon, {
495
+ ref: forwardRef,
496
+ "data-slot": "spinner",
497
+ role: "status",
498
+ "aria-label": t("spinner.loading"),
499
+ className: cn(spinnerVariants({ size }), className),
500
+ ...props
501
+ });
502
+ });
503
+ Spinner.displayName = "Spinner";
504
+
505
+ //#endregion
506
+ //#region src/components/audio-player.tsx
507
+ const AudioPlayerContext = React.createContext(null);
508
+ const AudioPlayerTimeContext = React.createContext(null);
509
+ const AudioPlayerRowContext = React.createContext({ variant: "default" });
510
+ const AudioPlayerManagerContext = React.createContext(null);
511
+ /**
512
+ * Returns the playback context from the nearest `<Audio>` ancestor. Throws if
513
+ * called outside an `<Audio>` tree.
514
+ *
515
+ * **State**
516
+ * - `activeItem` — the item currently loaded (`{ src }` or `null`)
517
+ * - `isPlaying` — `true` while audio is playing
518
+ * - `isBuffering` — `true` while waiting for data (spinner state)
519
+ * - `isEnded` — `true` when playback has reached the end
520
+ * - `duration` — total length in seconds, `null` until metadata loads
521
+ * - `playbackRate` — current speed multiplier (default `1`)
522
+ * - `error` — `MediaError | null`; watch in a child `useEffect` to handle expired URLs etc.
523
+ * - `audioRef` — ref to the hidden `<audio>` element (escape hatch for `setSinkId` etc.)
524
+ *
525
+ * **Controls**
526
+ * - `play(item?)` — start playback; pass `{ src }` to swap the track first
527
+ * - `pause()` — pause playback
528
+ * - `toggle(item?)` — play if paused, pause if playing
529
+ * - `seek(seconds)` — jump to a position
530
+ * - `setPlaybackRate(rate)` — change speed
531
+ * - `setActiveItem(item)` — pre-load a track without auto-playing
532
+ * - `isItemActive(src)` — predicate: is this src the currently loaded one?
533
+ *
534
+ * @example
535
+ * ```tsx
536
+ * const { isPlaying, toggle, seek, duration, error } = useAudioPlayer();
537
+ * ```
538
+ */
539
+ function useAudioPlayer() {
540
+ const ctx = React.useContext(AudioPlayerContext);
541
+ if (!ctx) throw new Error("AudioPlayer sub-components must be rendered inside <AudioPlayerProvider>.");
542
+ return ctx;
543
+ }
544
+ /**
545
+ * Returns the current playback position in seconds, updated every animation frame
546
+ * via `requestAnimationFrame`. Published on a separate context from `useAudioPlayer`
547
+ * so that high-frequency time updates do not re-render every component that only
548
+ * needs playback state (isPlaying, duration, etc.). Throws outside `<Audio>`.
549
+ *
550
+ * @example
551
+ * ```tsx
552
+ * const currentTime = useAudioPlayerTime(); // e.g. 1.23 (seconds)
553
+ * ```
554
+ */
555
+ function useAudioPlayerTime() {
556
+ const time = React.useContext(AudioPlayerTimeContext);
557
+ if (time === null) throw new Error("useAudioPlayerTime must be called inside <AudioPlayerProvider>.");
558
+ return time;
559
+ }
560
+ function useAnimationFrameLoop(callback) {
561
+ const callbackRef = React.useRef(callback);
562
+ React.useEffect(() => {
563
+ callbackRef.current = callback;
564
+ }, [callback]);
565
+ React.useEffect(() => {
566
+ let raf = 0;
567
+ const tick = () => {
568
+ callbackRef.current();
569
+ raf = requestAnimationFrame(tick);
570
+ };
571
+ raf = requestAnimationFrame(tick);
572
+ return () => cancelAnimationFrame(raf);
573
+ }, []);
574
+ }
575
+ function Audio({ src, defaultPlaybackRate = 1, preload = "metadata", crossOrigin, children, ...divProps }) {
576
+ const audioRef = React.useRef(null);
577
+ const playPromiseRef = React.useRef(null);
578
+ const managerCtx = React.useContext(AudioPlayerManagerContext);
579
+ const managerRef = React.useRef(managerCtx);
580
+ React.useEffect(() => {
581
+ managerRef.current = managerCtx;
582
+ }, [managerCtx]);
583
+ React.useEffect(() => {
584
+ const audio = audioRef.current;
585
+ return () => {
586
+ if (audio) managerRef.current?.unregister(audio);
587
+ };
588
+ }, []);
589
+ const [activeItem, setActiveItemState] = React.useState(null);
590
+ const [isPlaying, setIsPlaying] = React.useState(false);
591
+ const [isBuffering, setIsBuffering] = React.useState(false);
592
+ const [isEnded, setIsEnded] = React.useState(false);
593
+ const [duration, setDuration] = React.useState(null);
594
+ const [playbackRate, setPlaybackRateState] = React.useState(defaultPlaybackRate);
595
+ const [error, setError] = React.useState(null);
596
+ const [time, setTime] = React.useState(0);
597
+ React.useEffect(() => {
598
+ if (audioRef.current) audioRef.current.playbackRate = playbackRate;
599
+ }, [playbackRate, activeItem?.src]);
600
+ React.useEffect(() => {
601
+ setIsPlaying(false);
602
+ setIsEnded(false);
603
+ setDuration(null);
604
+ setError(null);
605
+ setTime(0);
606
+ }, [activeItem?.src]);
607
+ useAnimationFrameLoop(() => {
608
+ const audio = audioRef.current;
609
+ if (!audio) return;
610
+ setTime((prev) => {
611
+ const next = audio.currentTime;
612
+ return Math.abs(prev - next) < .02 ? prev : next;
613
+ });
614
+ const d = audio.duration;
615
+ setDuration(Number.isFinite(d) ? d : null);
616
+ setIsPlaying(!audio.paused);
617
+ setIsEnded(audio.ended);
618
+ setIsBuffering(audio.readyState < 3 && audio.networkState === 2);
619
+ });
620
+ const swapSrc = React.useCallback((item) => {
621
+ const audio = audioRef.current;
622
+ if (!audio) return;
623
+ const currentRate = audio.playbackRate;
624
+ audio.pause();
625
+ audio.currentTime = 0;
626
+ if (item === null) audio.removeAttribute("src");
627
+ else audio.src = item.src;
628
+ audio.load();
629
+ audio.playbackRate = currentRate;
630
+ setActiveItemState(item);
631
+ }, []);
632
+ const setActiveItem = React.useCallback(async (item) => {
633
+ if (item?.src === activeItem?.src) return;
634
+ if (playPromiseRef.current) try {
635
+ await playPromiseRef.current;
636
+ } catch {}
637
+ swapSrc(item);
638
+ }, [activeItem, swapSrc]);
639
+ const setActiveItemRef = React.useRef(setActiveItem);
640
+ React.useEffect(() => {
641
+ setActiveItemRef.current = setActiveItem;
642
+ });
643
+ React.useEffect(() => {
644
+ setActiveItemRef.current(src ? { src } : null);
645
+ }, [src]);
646
+ const play = React.useCallback(async (item) => {
647
+ const audio = audioRef.current;
648
+ if (!audio) return;
649
+ if (playPromiseRef.current) try {
650
+ await playPromiseRef.current;
651
+ } catch {}
652
+ if (item === void 0 || item !== null && item?.src === activeItem?.src) {
653
+ managerRef.current?.register(audio);
654
+ const p$1 = audio.play();
655
+ playPromiseRef.current = p$1;
656
+ return p$1;
657
+ }
658
+ swapSrc(item);
659
+ if (item == null) return;
660
+ managerRef.current?.register(audio);
661
+ const p = audio.play();
662
+ playPromiseRef.current = p;
663
+ return p;
664
+ }, [activeItem, swapSrc]);
665
+ const pause = React.useCallback(async () => {
666
+ const audio = audioRef.current;
667
+ if (!audio) return;
668
+ if (playPromiseRef.current) try {
669
+ await playPromiseRef.current;
670
+ } catch {}
671
+ audio.pause();
672
+ playPromiseRef.current = null;
673
+ }, []);
674
+ const toggle = React.useCallback(async (item) => {
675
+ if (item && item.src !== activeItem?.src) return play(item);
676
+ if (audioRef.current?.paused) return play();
677
+ return pause();
678
+ }, [
679
+ activeItem,
680
+ play,
681
+ pause
682
+ ]);
683
+ const seek = React.useCallback((seconds) => {
684
+ if (audioRef.current && Number.isFinite(seconds)) audioRef.current.currentTime = Math.max(0, seconds);
685
+ }, []);
686
+ const setPlaybackRate = React.useCallback((rate) => {
687
+ setPlaybackRateState(rate);
688
+ }, []);
689
+ const isItemActive = React.useCallback((src$1) => src$1 != null && activeItem?.src === src$1, [activeItem]);
690
+ const ctx = React.useMemo(() => ({
691
+ audioRef,
692
+ activeItem,
693
+ isItemActive,
694
+ setActiveItem,
695
+ isPlaying,
696
+ isBuffering,
697
+ isEnded,
698
+ duration,
699
+ playbackRate,
700
+ error,
701
+ play,
702
+ pause,
703
+ toggle,
704
+ seek,
705
+ setPlaybackRate
706
+ }), [
707
+ activeItem,
708
+ isItemActive,
709
+ setActiveItem,
710
+ isPlaying,
711
+ isBuffering,
712
+ isEnded,
713
+ duration,
714
+ playbackRate,
715
+ error,
716
+ play,
717
+ pause,
718
+ toggle,
719
+ seek,
720
+ setPlaybackRate
721
+ ]);
722
+ return /* @__PURE__ */ jsx(AudioPlayerContext.Provider, {
723
+ value: ctx,
724
+ children: /* @__PURE__ */ jsxs(AudioPlayerTimeContext.Provider, {
725
+ value: time,
726
+ children: [/* @__PURE__ */ jsx("audio", {
727
+ ref: audioRef,
728
+ preload,
729
+ crossOrigin,
730
+ className: "hidden",
731
+ onError: (event) => {
732
+ const mediaError = event.currentTarget.error;
733
+ if (mediaError) setError(mediaError);
734
+ }
735
+ }), /* @__PURE__ */ jsx("div", {
736
+ ...divProps,
737
+ children
738
+ })]
739
+ })
740
+ });
741
+ }
742
+ function formatTime(seconds) {
743
+ if (seconds == null || !Number.isFinite(seconds)) return "--:--";
744
+ const total = Math.max(0, Math.floor(seconds));
745
+ const h = Math.floor(total / 3600);
746
+ const m = Math.floor(total % 3600 / 60);
747
+ const s = total % 60;
748
+ const pad = (n) => n.toString().padStart(2, "0");
749
+ if (h > 0) return `${h}:${pad(m)}:${pad(s)}`;
750
+ return `${m}:${pad(s)}`;
751
+ }
752
+ function AudioPlayerRow({ variant = "default", className, children, ...props }) {
753
+ return /* @__PURE__ */ jsx(AudioPlayerRowContext.Provider, {
754
+ value: { variant },
755
+ children: /* @__PURE__ */ jsx("div", {
756
+ "data-slot": "audio-player-row",
757
+ className: cn("flex items-center gap-2 [&>[data-slot=audio-player-bar]]:flex-1", className),
758
+ ...props,
759
+ children
760
+ })
761
+ });
762
+ }
763
+ function AudioPlayerButton({ variant, render, onClick, ...props }) {
764
+ const rowCtx = React.useContext(AudioPlayerRowContext);
765
+ const resolvedVariant = variant ?? rowCtx.variant;
766
+ const { isPlaying, isEnded, isBuffering, activeItem, seek, play, toggle } = useAudioPlayer();
767
+ const isTargetActive = activeItem != null;
768
+ const showPause = isPlaying && isTargetActive;
769
+ const showReplay = isEnded && isTargetActive;
770
+ const showSpinner = isBuffering && isTargetActive && isPlaying;
771
+ const accessibleLabel = showSpinner ? "Loading" : showPause ? "Pause" : showReplay ? "Replay" : "Play";
772
+ const Icon = showSpinner ? Spinner : showPause ? Pause : showReplay ? RotateCcw : Play;
773
+ function handleClick(event) {
774
+ onClick?.(event);
775
+ if (event.defaultPrevented) return;
776
+ if (showReplay) {
777
+ seek(0);
778
+ play();
779
+ return;
780
+ }
781
+ toggle();
782
+ }
783
+ const buttonSize = resolvedVariant === "default" ? "icon" : "icon-sm";
784
+ return useRender({
785
+ defaultTagName: "button",
786
+ props: mergeProps({
787
+ type: "button",
788
+ "data-slot": "audio-player-button",
789
+ "data-state": showPause ? "playing" : showReplay ? "ended" : "idle",
790
+ "aria-label": accessibleLabel,
791
+ onClick: handleClick
792
+ }, props),
793
+ render: render ?? /* @__PURE__ */ jsx(Button, {
794
+ variant: resolvedVariant,
795
+ size: buttonSize,
796
+ children: /* @__PURE__ */ jsx(Icon, {})
797
+ })
798
+ });
799
+ }
800
+ function AudioPlayerBar({ className, step = .25, playheadHeight, ...props }) {
801
+ const { duration, seek, isPlaying, pause, play } = useAudioPlayer();
802
+ const currentTime = useAudioPlayerTime();
803
+ const wasPlayingRef = React.useRef(false);
804
+ const [dragValue, setDragValue] = React.useState(null);
805
+ const knownDuration = duration != null && Number.isFinite(duration) && duration > 0 ? duration : null;
806
+ const max = knownDuration ?? 1;
807
+ const value = dragValue ?? (knownDuration ? Math.min(currentTime, knownDuration) : 0);
808
+ return /* @__PURE__ */ jsx(Slider$1.Root, {
809
+ "data-slot": "audio-player-bar",
810
+ value: [value],
811
+ min: 0,
812
+ max,
813
+ step,
814
+ thumbAlignment: "center",
815
+ onValueChange: (vals) => {
816
+ if (!knownDuration) return;
817
+ const next = Array.isArray(vals) ? vals[0] : vals;
818
+ if (typeof next !== "number" || !Number.isFinite(next)) return;
819
+ if (dragValue === null) {
820
+ wasPlayingRef.current = isPlaying;
821
+ if (isPlaying) pause();
822
+ }
823
+ setDragValue(next);
824
+ seek(next);
825
+ },
826
+ onValueCommitted: () => {
827
+ if (dragValue === null) return;
828
+ setDragValue(null);
829
+ if (wasPlayingRef.current) play();
830
+ wasPlayingRef.current = false;
831
+ },
832
+ className: cn("group/audio-player-bar data-[orientation=horizontal]:w-full", !knownDuration && "pointer-events-none opacity-50", className),
833
+ ...props,
834
+ children: /* @__PURE__ */ jsxs(Slider$1.Control, {
835
+ className: "relative flex w-full touch-none items-center select-none",
836
+ style: { height: playheadHeight ?? 16 },
837
+ children: [
838
+ /* @__PURE__ */ jsx(Slider$1.Track, {
839
+ "data-slot": "audio-player-bar-track",
840
+ className: "relative h-1 w-full grow overflow-hidden rounded-full bg-muted select-none",
841
+ children: /* @__PURE__ */ jsx(Slider$1.Indicator, {
842
+ "data-slot": "audio-player-bar-range",
843
+ className: "h-full bg-primary select-none"
844
+ })
845
+ }),
846
+ playheadHeight && /* @__PURE__ */ jsx("div", {
847
+ "aria-hidden": true,
848
+ className: "absolute top-1/2 w-0.5 rounded-none bg-primary pointer-events-none",
849
+ style: {
850
+ left: `${value / max * 100}%`,
851
+ height: playheadHeight,
852
+ translate: "-50% 0"
853
+ }
854
+ }),
855
+ /* @__PURE__ */ jsx(Slider$1.Thumb, {
856
+ "data-slot": "audio-player-bar-thumb",
857
+ className: cn("block shrink-0 rounded-full shadow-sm select-none", playheadHeight ? [
858
+ "bg-primary size-3 hover:size-4 focus-visible:size-4",
859
+ "relative z-10 transition-[width,height]",
860
+ "focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none"
861
+ ] : [
862
+ "size-4 border border-ring bg-white",
863
+ "transition-opacity",
864
+ "opacity-0 group-hover/audio-player-bar:opacity-100",
865
+ "focus-visible:opacity-100 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none"
866
+ ])
867
+ })
868
+ ]
869
+ })
870
+ });
871
+ }
872
+ /**
873
+ * Dumb span that always renders the current playback position as a formatted
874
+ * time string (e.g. `1:23`). Reads from the nearest `AudioPlayerProvider`.
875
+ *
876
+ * @example
877
+ * ```tsx
878
+ * <AudioPlayerCurrentTime />
879
+ * ```
880
+ */
881
+ function AudioPlayerCurrentTime({ className, ...props }) {
882
+ const elapsed = useAudioPlayerTime();
883
+ return /* @__PURE__ */ jsx("span", {
884
+ "data-slot": "audio-player-current-time",
885
+ className: cn("text-xs font-medium text-muted-foreground tabular-nums select-none", className),
886
+ ...props,
887
+ children: formatTime(elapsed)
888
+ });
889
+ }
890
+ /**
891
+ * Time display for `AudioPlayerRow`. Two layouts controlled by `mode`:
892
+ * - `compact` (default) — duration before first play, elapsed once started (even while paused)
893
+ * - `full` — current position + `/` + total duration, always visible
894
+ *
895
+ * Use `AudioPlayerCurrentTime` or `AudioPlayerDuration` directly when you need
896
+ * more layout control.
897
+ *
898
+ * @example
899
+ * ```tsx
900
+ * <AudioPlayerTime mode="full" />
901
+ * ```
902
+ */
903
+ function AudioPlayerTime({ mode = "compact", className, ...props }) {
904
+ const { isPlaying, duration } = useAudioPlayer();
905
+ const elapsed = useAudioPlayerTime();
906
+ if (mode === "full") return /* @__PURE__ */ jsxs("span", {
907
+ "data-slot": "audio-player-time",
908
+ className: cn("inline-flex items-center gap-1", className),
909
+ ...props,
910
+ children: [
911
+ /* @__PURE__ */ jsx(AudioPlayerCurrentTime, {}),
912
+ /* @__PURE__ */ jsx("span", {
913
+ className: "text-xs text-muted-foreground",
914
+ children: "/"
915
+ }),
916
+ /* @__PURE__ */ jsx(AudioPlayerDuration, {})
917
+ ]
918
+ });
919
+ return /* @__PURE__ */ jsx("span", {
920
+ "data-slot": "audio-player-time",
921
+ className: cn("text-xs font-medium text-muted-foreground tabular-nums select-none", className),
922
+ ...props,
923
+ children: !isPlaying && elapsed === 0 ? formatTime(duration) : formatTime(elapsed)
924
+ });
925
+ }
926
+ /**
927
+ * Dumb span that always renders the total audio duration as a formatted time
928
+ * string (e.g. `3:45`). Reads from the nearest `AudioPlayerProvider`.
929
+ *
930
+ * @example
931
+ * ```tsx
932
+ * <AudioPlayerDuration />
933
+ * ```
934
+ */
935
+ function AudioPlayerDuration({ className, ...props }) {
936
+ const { duration } = useAudioPlayer();
937
+ return /* @__PURE__ */ jsx("span", {
938
+ "data-slot": "audio-player-duration",
939
+ className: cn("text-xs font-medium text-muted-foreground tabular-nums select-none", className),
940
+ ...props,
941
+ children: formatTime(duration)
942
+ });
943
+ }
944
+ /**
945
+ * Cycling playback-speed button. Displays the current rate (e.g. `1.0x`) and
946
+ * advances to the next value in the `speeds` array on each click. Renders a ghost
947
+ * DS `<Button>` by default; substitute via `render` (Base UI `useRender` pattern).
948
+ *
949
+ * Size is controlled by `variant`, which is inherited from a parent
950
+ * `<AudioPlayerRow>` when not explicitly set — the visual style stays ghost in both
951
+ * cases; `variant` only affects hit-area height for row alignment.
952
+ *
953
+ * @example
954
+ * ```tsx
955
+ * <AudioPlayerSpeed />
956
+ * <AudioPlayerSpeed speeds={[1, 1.25, 1.5, 2]} />
957
+ * ```
958
+ */
959
+ const DEFAULT_SPEEDS = [
960
+ 1,
961
+ 1.5,
962
+ 2,
963
+ .5
964
+ ];
965
+ function AudioPlayerSpeed({ speeds = DEFAULT_SPEEDS, variant, render, onClick, className, ...props }) {
966
+ const rowCtx = React.useContext(AudioPlayerRowContext);
967
+ const resolvedVariant = variant ?? rowCtx.variant;
968
+ const { playbackRate, setPlaybackRate } = useAudioPlayer();
969
+ function handleClick(event) {
970
+ onClick?.(event);
971
+ if (event.defaultPrevented) return;
972
+ setPlaybackRate(speeds[(speeds.indexOf(playbackRate) + 1) % speeds.length] ?? speeds[0]);
973
+ }
974
+ const label = `${Number.isInteger(playbackRate) ? playbackRate.toFixed(1) : playbackRate}x`;
975
+ const buttonSize = resolvedVariant === "default" ? "default" : "sm";
976
+ return useRender({
977
+ defaultTagName: "button",
978
+ props: mergeProps({
979
+ type: "button",
980
+ "data-slot": "audio-player-speed",
981
+ "aria-label": `Playback speed: ${label}`,
982
+ onClick: handleClick,
983
+ className: cn("min-w-10 tabular-nums", className)
984
+ }, props),
985
+ render: render ?? /* @__PURE__ */ jsx(Button, {
986
+ variant: "ghost",
987
+ size: buttonSize,
988
+ children: label
989
+ })
990
+ });
991
+ }
992
+ function pickSkipIcon(offset) {
993
+ if (offset === -10) return Backward10;
994
+ if (offset === 10) return Forward10;
995
+ return offset < 0 ? Rewind : FastForward;
996
+ }
997
+ function AudioPlayerSkip({ offset, render, onClick, ...props }) {
998
+ const { seek, audioRef } = useAudioPlayer();
999
+ const Icon = pickSkipIcon(offset);
1000
+ const label = `Skip ${offset < 0 ? "back" : "forward"} ${Math.abs(offset)} seconds`;
1001
+ function handleClick(event) {
1002
+ onClick?.(event);
1003
+ if (event.defaultPrevented) return;
1004
+ seek((audioRef.current?.currentTime ?? 0) + offset);
1005
+ }
1006
+ return useRender({
1007
+ defaultTagName: "button",
1008
+ props: mergeProps({
1009
+ type: "button",
1010
+ "data-slot": "audio-player-skip",
1011
+ "aria-label": label,
1012
+ onClick: handleClick
1013
+ }, props),
1014
+ render: render ?? /* @__PURE__ */ jsx(Button, {
1015
+ variant: "ghost",
1016
+ size: "icon",
1017
+ children: /* @__PURE__ */ jsx(Icon, {})
1018
+ })
1019
+ });
1020
+ }
1021
+ /**
1022
+ * Optional coordination wrapper. Place it above multiple `<Audio>` instances to
1023
+ * ensure only one plays at a time — starting playback on any child automatically
1024
+ * pauses whichever other was playing. Unregisters cleanly when a child unmounts.
1025
+ *
1026
+ * Works transparently: `<Audio>` instances without a parent `AudioPlayerManager`
1027
+ * are unaffected. Only add it when you need the pause-others behaviour.
1028
+ *
1029
+ * @example
1030
+ * ```tsx
1031
+ * <AudioPlayerManager>
1032
+ * <Audio src={url1}>…</Audio>
1033
+ * <Audio src={url2}>…</Audio>
1034
+ * </AudioPlayerManager>
1035
+ * ```
1036
+ */
1037
+ function AudioPlayerManager({ children }) {
1038
+ const currentAudio = React.useRef(null);
1039
+ const register = React.useCallback((audio) => {
1040
+ if (currentAudio.current && currentAudio.current !== audio) currentAudio.current.pause();
1041
+ currentAudio.current = audio;
1042
+ }, []);
1043
+ const unregister = React.useCallback((audio) => {
1044
+ if (currentAudio.current === audio) {
1045
+ currentAudio.current.pause();
1046
+ currentAudio.current = null;
1047
+ }
1048
+ }, []);
1049
+ const ctx = React.useMemo(() => ({
1050
+ register,
1051
+ unregister
1052
+ }), [register, unregister]);
1053
+ return /* @__PURE__ */ jsx(AudioPlayerManagerContext.Provider, {
1054
+ value: ctx,
1055
+ children
1056
+ });
1057
+ }
1058
+
474
1059
  //#endregion
475
1060
  //#region src/components/alert-dialog.tsx
476
1061
  function AlertDialog(componentProps) {
@@ -644,6 +1229,202 @@ const AlertAction = React.forwardRef((componentProps, forwardRef) => {
644
1229
  });
645
1230
  AlertAction.displayName = "AlertAction";
646
1231
 
1232
+ //#endregion
1233
+ //#region src/components/attachment.tsx
1234
+ const attachmentVariants = cva("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed", { variants: {
1235
+ size: {
1236
+ default: "gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2",
1237
+ sm: "gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",
1238
+ xs: "gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"
1239
+ },
1240
+ orientation: {
1241
+ horizontal: "min-w-40 items-center",
1242
+ vertical: "w-24 flex-col has-data-[slot=attachment-content]:w-30"
1243
+ }
1244
+ } });
1245
+ /**
1246
+ * Card displaying a single file or image attachment with its metadata,
1247
+ * upload state, and actions. Renders a `<div>`; compose it from
1248
+ * `AttachmentMedia`, `AttachmentContent`, `AttachmentActions`, and
1249
+ * `AttachmentTrigger`. Wrap several in an `AttachmentGroup`.
1250
+ *
1251
+ * @example
1252
+ * ```tsx
1253
+ * <Attachment state="done">
1254
+ * <AttachmentMedia>
1255
+ * <FileText />
1256
+ * </AttachmentMedia>
1257
+ * <AttachmentContent>
1258
+ * <AttachmentTitle>sales-dashboard.pdf</AttachmentTitle>
1259
+ * <AttachmentDescription>PDF · 2.4 MB</AttachmentDescription>
1260
+ * </AttachmentContent>
1261
+ * <AttachmentActions>
1262
+ * <AttachmentAction aria-label="Remove attachment">
1263
+ * <X />
1264
+ * </AttachmentAction>
1265
+ * </AttachmentActions>
1266
+ * </Attachment>
1267
+ * ```
1268
+ */
1269
+ const Attachment = React.forwardRef((componentProps, forwardRef) => {
1270
+ const { className, state = "done", size = "default", orientation = "horizontal", ...props } = componentProps;
1271
+ return /* @__PURE__ */ jsx("div", {
1272
+ ref: forwardRef,
1273
+ "data-slot": "attachment",
1274
+ "data-state": state,
1275
+ "data-size": size,
1276
+ "data-orientation": orientation,
1277
+ className: cn(attachmentVariants({
1278
+ size,
1279
+ orientation
1280
+ }), className),
1281
+ ...props
1282
+ });
1283
+ });
1284
+ Attachment.displayName = "Attachment";
1285
+ const attachmentMediaVariants = cva("relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5", {
1286
+ variants: { variant: {
1287
+ icon: "",
1288
+ image: "opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"
1289
+ } },
1290
+ defaultVariants: { variant: "icon" }
1291
+ });
1292
+ /**
1293
+ * Leading media slot of an `Attachment` — holds an icon (`variant="icon"`)
1294
+ * or an image thumbnail (`variant="image"`). Renders a `<div>`.
1295
+ */
1296
+ const AttachmentMedia = React.forwardRef((componentProps, forwardRef) => {
1297
+ const { className, variant = "icon", ...props } = componentProps;
1298
+ return /* @__PURE__ */ jsx("div", {
1299
+ ref: forwardRef,
1300
+ "data-slot": "attachment-media",
1301
+ "data-variant": variant,
1302
+ className: cn(attachmentMediaVariants({ variant }), className),
1303
+ ...props
1304
+ });
1305
+ });
1306
+ AttachmentMedia.displayName = "AttachmentMedia";
1307
+ /**
1308
+ * Text column of an `Attachment` — wraps `AttachmentTitle` and
1309
+ * `AttachmentDescription`. Renders a `<div>`.
1310
+ */
1311
+ const AttachmentContent = React.forwardRef((componentProps, forwardRef) => {
1312
+ const { className, ...props } = componentProps;
1313
+ return /* @__PURE__ */ jsx("div", {
1314
+ ref: forwardRef,
1315
+ "data-slot": "attachment-content",
1316
+ className: cn("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1", className),
1317
+ ...props
1318
+ });
1319
+ });
1320
+ AttachmentContent.displayName = "AttachmentContent";
1321
+ /**
1322
+ * Attachment name. Renders a truncating `<span>`; shimmers while the parent
1323
+ * `Attachment` is in the `uploading` or `processing` state.
1324
+ */
1325
+ const AttachmentTitle = React.forwardRef((componentProps, forwardRef) => {
1326
+ const { className, ...props } = componentProps;
1327
+ return /* @__PURE__ */ jsx("span", {
1328
+ ref: forwardRef,
1329
+ "data-slot": "attachment-title",
1330
+ className: cn("block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer", className),
1331
+ ...props
1332
+ });
1333
+ });
1334
+ AttachmentTitle.displayName = "AttachmentTitle";
1335
+ /**
1336
+ * Secondary metadata line (type, size, status) of an `Attachment`. Renders a
1337
+ * truncating `<span>`; turns destructive while the parent is in the `error` state.
1338
+ */
1339
+ const AttachmentDescription = React.forwardRef((componentProps, forwardRef) => {
1340
+ const { className, ...props } = componentProps;
1341
+ return /* @__PURE__ */ jsx("span", {
1342
+ ref: forwardRef,
1343
+ "data-slot": "attachment-description",
1344
+ className: cn("mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80", "max-w-full", className),
1345
+ ...props
1346
+ });
1347
+ });
1348
+ AttachmentDescription.displayName = "AttachmentDescription";
1349
+ /**
1350
+ * Trailing actions container of an `Attachment`. Renders a `<div>`; in
1351
+ * `orientation="vertical"` it floats to the top-right corner of the card.
1352
+ */
1353
+ const AttachmentActions = React.forwardRef((componentProps, forwardRef) => {
1354
+ const { className, ...props } = componentProps;
1355
+ return /* @__PURE__ */ jsx("div", {
1356
+ ref: forwardRef,
1357
+ "data-slot": "attachment-actions",
1358
+ className: cn("relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1", className),
1359
+ ...props
1360
+ });
1361
+ });
1362
+ AttachmentActions.displayName = "AttachmentActions";
1363
+ /**
1364
+ * A single action button (e.g. remove, download) inside `AttachmentActions`.
1365
+ * Wraps the DS `Button`, defaulting to `variant="ghost"` and `size="icon-sm"`.
1366
+ * Always provide an `aria-label` since it renders an icon-only button.
1367
+ */
1368
+ const AttachmentAction = React.forwardRef((componentProps, forwardRef) => {
1369
+ const { className, variant, size = "icon-sm", ...props } = componentProps;
1370
+ return /* @__PURE__ */ jsx(Button, {
1371
+ ref: forwardRef,
1372
+ "data-slot": "attachment-action",
1373
+ variant: variant ?? "ghost",
1374
+ size,
1375
+ className: cn(className),
1376
+ ...props
1377
+ });
1378
+ });
1379
+ AttachmentAction.displayName = "AttachmentAction";
1380
+ /**
1381
+ * Full-card overlay button that makes the whole `Attachment` clickable
1382
+ * (e.g. to open a preview or link) without swallowing `AttachmentAction`
1383
+ * clicks. Renders a `<button>` by default; pass `render` to substitute an
1384
+ * element such as an anchor.
1385
+ *
1386
+ * @example
1387
+ * ```tsx
1388
+ * <AttachmentTrigger render={<a href="/files/report.pdf" />} />
1389
+ * ```
1390
+ */
1391
+ const AttachmentTrigger = React.forwardRef((componentProps, forwardRef) => {
1392
+ const { className, render, type, ...props } = componentProps;
1393
+ return useRender({
1394
+ defaultTagName: "button",
1395
+ props: mergeProps({
1396
+ ref: forwardRef,
1397
+ type: render ? type : type ?? "button",
1398
+ className: cn("absolute inset-0 z-10 outline-none", className)
1399
+ }, props),
1400
+ render,
1401
+ state: { slot: "attachment-trigger" }
1402
+ });
1403
+ });
1404
+ AttachmentTrigger.displayName = "AttachmentTrigger";
1405
+ /**
1406
+ * Horizontally scrollable, snapping row of `Attachment` cards with a masked
1407
+ * edge fade and hidden scrollbar. Renders a `<div>`.
1408
+ *
1409
+ * @example
1410
+ * ```tsx
1411
+ * <AttachmentGroup>
1412
+ * <Attachment>…</Attachment>
1413
+ * <Attachment>…</Attachment>
1414
+ * </AttachmentGroup>
1415
+ * ```
1416
+ */
1417
+ const AttachmentGroup = React.forwardRef((componentProps, forwardRef) => {
1418
+ const { className, ...props } = componentProps;
1419
+ return /* @__PURE__ */ jsx("div", {
1420
+ ref: forwardRef,
1421
+ "data-slot": "attachment-group",
1422
+ className: cn("flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start", className),
1423
+ ...props
1424
+ });
1425
+ });
1426
+ AttachmentGroup.displayName = "AttachmentGroup";
1427
+
647
1428
  //#endregion
648
1429
  //#region src/components/avatar.tsx
649
1430
  const Avatar = React.forwardRef((componentProps, forwardRef) => {
@@ -2419,36 +3200,12 @@ const Skeleton = React.forwardRef((componentProps, forwardRef) => {
2419
3200
  });
2420
3201
  Skeleton.displayName = "Skeleton";
2421
3202
 
2422
- //#endregion
2423
- //#region src/components/spinner.tsx
2424
- const spinnerVariants = cva("animate-spin text-current", {
2425
- variants: { size: {
2426
- default: "size-4",
2427
- sm: "size-3",
2428
- lg: "size-5",
2429
- xl: "size-6"
2430
- } },
2431
- defaultVariants: { size: "default" }
2432
- });
2433
- const Spinner = React.forwardRef((componentProps, forwardRef) => {
2434
- const { className, size, ...props } = componentProps;
2435
- const t = useDsTranslation("ds");
2436
- return /* @__PURE__ */ jsx(Loader2Icon, {
2437
- ref: forwardRef,
2438
- "data-slot": "spinner",
2439
- role: "status",
2440
- "aria-label": t("spinner.loading"),
2441
- className: cn(spinnerVariants({ size }), className),
2442
- ...props
2443
- });
2444
- });
2445
- Spinner.displayName = "Spinner";
2446
-
2447
3203
  //#endregion
2448
3204
  //#region src/components/table.tsx
2449
3205
  const Table = React.forwardRef((componentProps, forwardRef) => {
2450
- const { className, containerClassName, containerStyle, ...props } = componentProps;
3206
+ const { className, containerClassName, containerStyle, containerRef, ...props } = componentProps;
2451
3207
  return /* @__PURE__ */ jsx("div", {
3208
+ ref: containerRef,
2452
3209
  "data-slot": "table-container",
2453
3210
  style: containerStyle,
2454
3211
  className: cn("relative w-full overflow-x-auto rounded-lg border border-border", containerClassName),
@@ -2566,7 +3323,20 @@ function DataTable(componentProps) {
2566
3323
  if (row.getCanSelect()) row.toggleSelected();
2567
3324
  } else if (onRowClick) onRowClick(row.original);
2568
3325
  };
2569
- const colWidth = (size) => enableColumnResizing ? { width: size } : void 0;
3326
+ const virtualizeRows = (componentProps.virtualizeRows ?? false) && fillHeight;
3327
+ const pinWidths = enableColumnResizing || virtualizeRows;
3328
+ const colWidth = (size) => pinWidths ? { width: size } : void 0;
3329
+ const containerRef = React.useRef(null);
3330
+ const rowVirtualizer = useVirtualizer({
3331
+ count: virtualizeRows ? rows.length : 0,
3332
+ getScrollElement: () => virtualizeRows ? containerRef.current : null,
3333
+ estimateSize: () => 48,
3334
+ measureElement: typeof window !== "undefined" && navigator.userAgent.indexOf("Firefox") === -1 ? (el) => el?.getBoundingClientRect().height : void 0,
3335
+ overscan: 5
3336
+ });
3337
+ const virtualItems = virtualizeRows ? rowVirtualizer.getVirtualItems() : null;
3338
+ const paddingTop = virtualItems && virtualItems.length > 0 ? virtualItems[0].start : 0;
3339
+ const paddingBottom = virtualItems && virtualItems.length > 0 ? rowVirtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end : 0;
2570
3340
  const showActionBar = !!actionBar && hasSelection;
2571
3341
  const reservedBottom = showActionBar ? ActionBarHeight + 16 : void 0;
2572
3342
  const sentinelRef = useFetchMoreSentinel(onFetchMore, fillHeight, data.length);
@@ -2575,13 +3345,14 @@ function DataTable(componentProps) {
2575
3345
  "aria-busy": isInitialLoading || isRefreshing || void 0,
2576
3346
  children: [
2577
3347
  /* @__PURE__ */ jsxs(Table, {
2578
- className: cn(enableColumnResizing && "table-fixed", fillHeight && "[&_[data-slot=table-head]]:sticky [&_[data-slot=table-head]]:top-0 [&_[data-slot=table-head]]:z-10 [&_[data-slot=table-head]]:bg-background", fillHeight && showEmptyState && "h-full"),
3348
+ containerRef,
3349
+ className: cn((enableColumnResizing || virtualizeRows) && "table-fixed", fillHeight && "[&_[data-slot=table-head]]:sticky [&_[data-slot=table-head]]:top-0 [&_[data-slot=table-head]]:z-10 [&_[data-slot=table-head]]:bg-background", fillHeight && showEmptyState && "h-full"),
2579
3350
  containerClassName: fillHeight ? "min-h-0 flex-1 overflow-y-auto" : void 0,
2580
3351
  containerStyle: reservedBottom ? {
2581
3352
  paddingBottom: reservedBottom,
2582
3353
  scrollPaddingBottom: reservedBottom
2583
3354
  } : void 0,
2584
- style: enableColumnResizing ? { width: `max(100%, ${table.getTotalSize()}px)` } : void 0,
3355
+ style: pinWidths ? { width: `max(100%, ${table.getTotalSize()}px)` } : void 0,
2585
3356
  children: [
2586
3357
  /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, {
2587
3358
  className: enableColumnResizing ? "group/header-row" : void 0,
@@ -2595,7 +3366,36 @@ function DataTable(componentProps) {
2595
3366
  columns: finalColumns,
2596
3367
  count: skeletonCount
2597
3368
  }) : rows.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
2598
- rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
3369
+ virtualItems ? /* @__PURE__ */ jsxs(Fragment, { children: [
3370
+ paddingTop > 0 && /* @__PURE__ */ jsx("tr", {
3371
+ "aria-hidden": true,
3372
+ children: /* @__PURE__ */ jsx("td", {
3373
+ colSpan: finalColumns.length,
3374
+ style: { height: paddingTop }
3375
+ })
3376
+ }),
3377
+ virtualItems.map((vi) => {
3378
+ const row = rows[vi.index];
3379
+ return /* @__PURE__ */ jsx(TableRow, {
3380
+ ref: (node) => rowVirtualizer.measureElement(node),
3381
+ "data-index": vi.index,
3382
+ "data-state": row.getIsSelected() ? "selected" : void 0,
3383
+ onClick: rowClickable ? () => handleRowActivate(row) : void 0,
3384
+ className: rowClickable ? "cursor-pointer" : void 0,
3385
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, {
3386
+ style: colWidth(cell.column.getSize()),
3387
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
3388
+ }, cell.id))
3389
+ }, row.id);
3390
+ }),
3391
+ paddingBottom > 0 && /* @__PURE__ */ jsx("tr", {
3392
+ "aria-hidden": true,
3393
+ children: /* @__PURE__ */ jsx("td", {
3394
+ colSpan: finalColumns.length,
3395
+ style: { height: paddingBottom }
3396
+ })
3397
+ })
3398
+ ] }) : rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
2599
3399
  "data-state": row.getIsSelected() ? "selected" : void 0,
2600
3400
  onClick: rowClickable ? () => handleRowActivate(row) : void 0,
2601
3401
  className: rowClickable ? "cursor-pointer" : void 0,
@@ -4181,7 +4981,7 @@ const FieldContent = React.forwardRef((componentProps, forwardRef) => {
4181
4981
  return /* @__PURE__ */ jsx("div", {
4182
4982
  ref: forwardRef,
4183
4983
  "data-slot": "field-content",
4184
- className: cn("group/field-content flex flex-1 flex-col gap-2 leading-normal", className),
4984
+ className: cn("group/field-content flex flex-1 flex-col gap-0.5 leading-normal", className),
4185
4985
  ...props
4186
4986
  });
4187
4987
  });
@@ -4221,6 +5021,72 @@ const FieldLabel = React.forwardRef((componentProps, forwardRef) => {
4221
5021
  });
4222
5022
  });
4223
5023
  FieldLabel.displayName = "FieldLabel";
5024
+ /**
5025
+ * Row layout container that groups a `FieldLabel` with optional label add-ons on one line.
5026
+ * Renders a `<div data-slot="field-label-row">` with `flex w-full items-center gap-1`.
5027
+ * Any child carrying `data-slot="field-label-aside"` (e.g. `FieldLabelAside`) is pushed to the
5028
+ * right edge via `ml-auto`.
5029
+ *
5030
+ * @example
5031
+ * ```tsx
5032
+ * <FieldLabelRow>
5033
+ * <FieldLabel htmlFor="taxid">Tax ID Number</FieldLabel>
5034
+ * <FieldLabelAside render={<a href="/help/tax-id" />}>Where do I find this?</FieldLabelAside>
5035
+ * </FieldLabelRow>
5036
+ * ```
5037
+ */
5038
+ const FieldLabelRow = React.forwardRef((componentProps, forwardRef) => {
5039
+ const { className, ...props } = componentProps;
5040
+ return /* @__PURE__ */ jsx("div", {
5041
+ ref: forwardRef,
5042
+ "data-slot": "field-label-row",
5043
+ className: cn("flex w-full items-center gap-1 [&>[data-slot=field-label-aside]]:ml-auto", className),
5044
+ ...props
5045
+ });
5046
+ });
5047
+ FieldLabelRow.displayName = "FieldLabelRow";
5048
+ /**
5049
+ * An info `(i)` icon shown beside a `FieldLabel` (inside a `FieldLabelRow`, never inside the
5050
+ * `<label>` itself). Click/tap opens a Popover with purely additive context — use only when ~90% of
5051
+ * users can complete the field without reading it. `children` is the popover content.
5052
+ */
5053
+ const FieldLabelInfo = React.forwardRef((componentProps, forwardRef) => {
5054
+ const { className, children, "aria-label": ariaLabel, ...props } = componentProps;
5055
+ const t = useDsTranslation("ds");
5056
+ return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
5057
+ ref: forwardRef,
5058
+ "data-slot": "field-label-info",
5059
+ "aria-label": ariaLabel ?? t("fieldLabel.moreInfo"),
5060
+ className: cn("inline-flex items-center text-muted-foreground hover:text-foreground", className),
5061
+ ...props,
5062
+ children: /* @__PURE__ */ jsx(Info, { className: "size-4" })
5063
+ }), /* @__PURE__ */ jsx(PopoverContent, { children })] });
5064
+ });
5065
+ FieldLabelInfo.displayName = "FieldLabelInfo";
5066
+ /**
5067
+ * Wrapper for content shown at the **right end** of a `FieldLabelRow` — a "look-it-up" link
5068
+ * ("Where do I find this?"), a popover trigger, or plain helper text. It enforces only placement
5069
+ * (`data-slot="field-label-aside"`, right-aligned by `FieldLabelRow`) and the label-row typography
5070
+ * (`text-sm leading-normal font-normal`); it imposes **no** link styling. Put whatever you want
5071
+ * inside — an `Anchor`, a `PopoverTrigger`, text — and it carries its own appearance.
5072
+ *
5073
+ * @example
5074
+ * ```tsx
5075
+ * <FieldLabelAside>
5076
+ * <Anchor href="/help/tax-id">Where do I find this?</Anchor>
5077
+ * </FieldLabelAside>
5078
+ * ```
5079
+ */
5080
+ const FieldLabelAside = React.forwardRef((componentProps, forwardRef) => {
5081
+ const { className, ...props } = componentProps;
5082
+ return /* @__PURE__ */ jsx("span", {
5083
+ ref: forwardRef,
5084
+ "data-slot": "field-label-aside",
5085
+ className: cn("text-sm leading-normal font-normal", className),
5086
+ ...props
5087
+ });
5088
+ });
5089
+ FieldLabelAside.displayName = "FieldLabelAside";
4224
5090
  const FieldTitle = React.forwardRef((componentProps, forwardRef) => {
4225
5091
  const { className, ...props } = componentProps;
4226
5092
  return /* @__PURE__ */ jsx("div", {
@@ -4232,11 +5098,12 @@ const FieldTitle = React.forwardRef((componentProps, forwardRef) => {
4232
5098
  });
4233
5099
  FieldTitle.displayName = "FieldTitle";
4234
5100
  const FieldDescription = React.forwardRef((componentProps, forwardRef) => {
4235
- const { className, ...props } = componentProps;
5101
+ const { className, variant = "contextual", ...props } = componentProps;
4236
5102
  return /* @__PURE__ */ jsx("p", {
4237
5103
  ref: forwardRef,
4238
5104
  "data-slot": "field-description",
4239
- className: cn("text-left text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance [[data-variant=legend]+&]:-mt-1.5", "last:mt-0 nth-last-2:-mt-1", "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
5105
+ "data-variant": variant,
5106
+ className: cn("text-left text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance [[data-variant=legend]+&]:-mt-1.5", "last:mt-0 nth-last-2:-mt-1", "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", variant === "contextual" && "group-data-[invalid=true]/field:hidden", className),
4240
5107
  ...props
4241
5108
  });
4242
5109
  });
@@ -4558,7 +5425,7 @@ const NumericInputControl = React.forwardRef((componentProps, forwardRef) => {
4558
5425
  return /* @__PURE__ */ jsx(NumberField.Input, {
4559
5426
  ref: forwardRef,
4560
5427
  "data-slot": "input-group-control",
4561
- className: cn("text-foreground placeholder:text-muted-foreground flex-1 rounded-none border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none disabled:opacity-100 md:text-sm", className),
5428
+ className: cn("text-foreground placeholder:text-muted-foreground min-w-0 flex-1 rounded-none border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none disabled:opacity-100 md:text-sm", className),
4562
5429
  ...props
4563
5430
  });
4564
5431
  });
@@ -6268,4 +7135,4 @@ function useAudioGauge(options = {}) {
6268
7135
  }
6269
7136
 
6270
7137
  //#endregion
6271
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataTable, DataTree, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Filter, FilterClearAllButton, FilterGroup, Gauge, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, List, ListCol, ListRow, NotificationQueueProvider, NotificationSlot, NumericInput, NumericInputControl, NumericInputDecrement, NumericInputIncrement, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, SUPPORTED_LANGUAGES, ScrollArea, ScrollAreaPrimitive, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, StepperContent, StepperCounter, StepperPanel, StepperProgress, Switch, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tree, TreeDragLine, TreeItem, TreeItemLabel, alertVariants, anchorVariants, bannerVariants, buttonGroupVariants, buttonVariants, cn, counterBadgeVariants, detectInitialLanguage, fabVariants, registerI18nNamespace, selectTriggerVariants, spinnerVariants, syncDsLanguage, toast, toggleVariants, useAudioGauge, useComboboxAnchor, useDsTranslation, useNotification, useNotificationQueue, useSidebar, useStepper, useTheme };
7138
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Audio, AudioPlayerBar, AudioPlayerButton, AudioPlayerCurrentTime, AudioPlayerDuration, AudioPlayerManager, AudioPlayerRow, AudioPlayerSkip, AudioPlayerSpeed, AudioPlayerTime, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataTable, DataTree, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLabelAside, FieldLabelInfo, FieldLabelRow, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Filter, FilterClearAllButton, FilterGroup, Gauge, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, List, ListCol, ListRow, NotificationQueueProvider, NotificationSlot, NumericInput, NumericInputControl, NumericInputDecrement, NumericInputIncrement, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, SUPPORTED_LANGUAGES, ScrollArea, ScrollAreaPrimitive, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, StepperContent, StepperCounter, StepperPanel, StepperProgress, Switch, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tree, TreeDragLine, TreeItem, TreeItemLabel, alertVariants, anchorVariants, bannerVariants, buttonGroupVariants, buttonVariants, cn, counterBadgeVariants, detectInitialLanguage, fabVariants, registerI18nNamespace, selectTriggerVariants, spinnerVariants, syncDsLanguage, toast, toggleVariants, useAudioGauge, useAudioPlayer, useAudioPlayerTime, useComboboxAnchor, useDsTranslation, useNotification, useNotificationQueue, useSidebar, useStepper, useTheme };