@invana/ui 0.0.4 → 0.0.6

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.cjs CHANGED
@@ -2746,6 +2746,75 @@ var MenuItem = ({
2746
2746
  )
2747
2747
  ] });
2748
2748
  };
2749
+ var NavItems = ({
2750
+ items,
2751
+ orientation = "horizontal",
2752
+ tooltipSide = orientation === "vertical" ? "right" : "bottom",
2753
+ iconClassName = orientation === "vertical" ? "w-5 h-5" : "w-4 h-4 flex-shrink-0"
2754
+ }) => {
2755
+ const isVertical = orientation === "vertical";
2756
+ const [activeItem, setActiveItem] = React23__namespace.default.useState(null);
2757
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: items.map((item) => {
2758
+ const isActive = activeItem === item.name;
2759
+ const padding = item.label ? "px-3 py-1.5" : "px-2 py-2";
2760
+ const itemClass = `inline-flex border-0 items-center justify-center gap-2
2761
+ whitespace-nowrap rounded-md cursor-pointer transition-colors
2762
+ ring-1 ring-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
2763
+ ${padding}
2764
+ hover:bg-primary/10 hover:text-primary hover:ring-primary/25
2765
+ ${isActive ? `bg-primary/15 text-primary ring-primary/25 ${item.activeClass || ""}` : ""}
2766
+ ${item.className || ""}`;
2767
+ const icon = /* @__PURE__ */ jsxRuntime.jsx(
2768
+ item.icon,
2769
+ {
2770
+ strokeWidth: item.iconStroke || 2,
2771
+ className: item.iconClassName || iconClassName
2772
+ }
2773
+ );
2774
+ const label = item.label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: item.label });
2775
+ return /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.default.Fragment, { children: [
2776
+ /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2777
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: item.href ? /* @__PURE__ */ jsxRuntime.jsxs(
2778
+ "a",
2779
+ {
2780
+ href: item.href,
2781
+ onClick: () => setActiveItem(item.name),
2782
+ className: itemClass,
2783
+ children: [
2784
+ icon,
2785
+ label
2786
+ ]
2787
+ }
2788
+ ) : item.onClick ? /* @__PURE__ */ jsxRuntime.jsxs(
2789
+ "button",
2790
+ {
2791
+ type: "button",
2792
+ onClick: () => {
2793
+ item.onClick?.();
2794
+ setActiveItem(isActive ? null : item.name);
2795
+ },
2796
+ className: itemClass,
2797
+ children: [
2798
+ icon,
2799
+ label
2800
+ ]
2801
+ }
2802
+ ) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: itemClass, children: [
2803
+ icon,
2804
+ label
2805
+ ] }) }),
2806
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: item.tooltipSide || tooltipSide, children: item.tooltip || item.name })
2807
+ ] }),
2808
+ item.showSeperator && /* @__PURE__ */ jsxRuntime.jsx(
2809
+ Separator,
2810
+ {
2811
+ orientation: isVertical ? "horizontal" : "vertical",
2812
+ className: isVertical ? "" : "h-4"
2813
+ }
2814
+ )
2815
+ ] }, item.key || item.name);
2816
+ }) });
2817
+ };
2749
2818
  var NavBase = ({ className = "", orientation, sections }) => {
2750
2819
  const isVertical = orientation === "vertical";
2751
2820
  const containerClass = isVertical ? `flex flex-col items-center h-full ${className}` : `flex items-center w-full ${className}`;
@@ -2759,75 +2828,7 @@ var NavBase = ({ className = "", orientation, sections }) => {
2759
2828
  sections.end?.content && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${sectionWrapperClass} ${isVertical ? "" : "ml-auto"} ${sections.end.className || ""}`, children: sections.end.content })
2760
2829
  ] });
2761
2830
  };
2762
- var NavHorizontalItems = ({ items }) => {
2763
- const [activeItem, setActiveItem] = React23__namespace.default.useState(null);
2764
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.default.Fragment, { children: [
2765
- /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2766
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: item.href ? /* @__PURE__ */ jsxRuntime.jsxs(
2767
- "a",
2768
- {
2769
- href: item.href,
2770
- onClick: () => setActiveItem(item.name),
2771
- className: `flex border-0 items-center justify-center gap-2
2772
- transition-colors rounded-md h-full whitespace-nowrap
2773
- hover:bg-muted hover:text-foreground ${item.label ? "px-3" : "px-2"} ${item.className || ""}
2774
- ${activeItem === item.name ? "bg-primary/15 text-primary ring-1 ring-primary/25" : ""}`,
2775
- children: [
2776
- /* @__PURE__ */ jsxRuntime.jsx(
2777
- item.icon,
2778
- {
2779
- strokeWidth: item.iconStroke || 2,
2780
- className: item.iconClassName || "w-4 h-4 flex-shrink-0"
2781
- }
2782
- ),
2783
- item.label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: item.label })
2784
- ]
2785
- }
2786
- ) : item.onClick ? /* @__PURE__ */ jsxRuntime.jsxs(
2787
- Button,
2788
- {
2789
- size: item.label ? "sm" : "icon",
2790
- variant: "ghost",
2791
- onClick: () => {
2792
- if (item.onClick) item.onClick();
2793
- setActiveItem(item.name === activeItem ? null : item.name);
2794
- },
2795
- className: `h-full gap-2 whitespace-nowrap ${item.label ? "w-auto px-3" : ""} ${item.className || ""}
2796
- ${activeItem === item.name ? ` ${item?.activeClass || ""}` : ""}`,
2797
- children: [
2798
- /* @__PURE__ */ jsxRuntime.jsx(
2799
- item.icon,
2800
- {
2801
- strokeWidth: item.iconStroke || 2,
2802
- className: item.iconClassName || "w-4 h-4 flex-shrink-0"
2803
- }
2804
- ),
2805
- item.label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: item.label })
2806
- ]
2807
- }
2808
- ) : /* @__PURE__ */ jsxRuntime.jsxs(
2809
- "div",
2810
- {
2811
- className: `flex border-0 items-center justify-center gap-2 h-full whitespace-nowrap
2812
- transition-colors rounded-md ${item.label ? "px-3" : "px-2"} ${item.className || ""}
2813
- ${activeItem === item.name ? "bg-primary/15 text-primary ring-1 ring-primary/25" : ""}`,
2814
- children: [
2815
- /* @__PURE__ */ jsxRuntime.jsx(
2816
- item.icon,
2817
- {
2818
- strokeWidth: item.iconStroke || 2,
2819
- className: item.iconClassName || "w-4 h-4 flex-shrink-0"
2820
- }
2821
- ),
2822
- item.label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: item.label })
2823
- ]
2824
- }
2825
- ) }),
2826
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: item.tooltipSide || "bottom", children: item.tooltip || item.name })
2827
- ] }),
2828
- item.showSeperator && /* @__PURE__ */ jsxRuntime.jsx(Separator, { orientation: "vertical", className: "h-4" })
2829
- ] }, item.key || item.name)) });
2830
- };
2831
+ var NavHorizontalItems = ({ items }) => /* @__PURE__ */ jsxRuntime.jsx(NavItems, { items, orientation: "horizontal" });
2831
2832
  var NavHorizontal = ({
2832
2833
  left,
2833
2834
  leftNavItems,
@@ -2866,48 +2867,7 @@ var NavHorizontal = ({
2866
2867
  }
2867
2868
  );
2868
2869
  };
2869
- var NavVerticalItems = ({ items }) => {
2870
- const [activeItem, setActiveItem] = React23__namespace.default.useState(null);
2871
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.default.Fragment, { children: [
2872
- /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2873
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: item.href ? /* @__PURE__ */ jsxRuntime.jsx(
2874
- "a",
2875
- {
2876
- href: item.href,
2877
- onClick: () => setActiveItem(item.name),
2878
- className: ` flex border-0 items-center justify-center
2879
- transition-colors rounded-md
2880
- hover:text-primary/80 px-2 py-2 ${item.className || ""}
2881
- ${activeItem === item.name ? "bg-accent text-accent-foreground" : ""}`,
2882
- children: /* @__PURE__ */ jsxRuntime.jsx(item.icon, { strokeWidth: item.iconStroke ? item.iconStroke : 2, className: item.iconClassName ? item.iconClassName : "w-5 h-5" })
2883
- }
2884
- ) : item.onClick ? /* @__PURE__ */ jsxRuntime.jsx(
2885
- Button,
2886
- {
2887
- size: "nav-icon",
2888
- variant: "ghost",
2889
- onClick: () => {
2890
- if (item.onClick) item.onClick();
2891
- setActiveItem(item.name === activeItem ? null : item.name);
2892
- },
2893
- className: `${item.className || ""}
2894
- ${activeItem === item.name ? ` ${item?.activeClass || ""}` : ""}`,
2895
- children: /* @__PURE__ */ jsxRuntime.jsx(item.icon, { strokeWidth: item.iconStroke ? item.iconStroke : 2, className: item.iconClassName ? item.iconClassName : "w-5 h-5" })
2896
- }
2897
- ) : /* @__PURE__ */ jsxRuntime.jsx(
2898
- "div",
2899
- {
2900
- className: ` flex border-0 items-center justify-center
2901
- transition-colors rounded-md px-2 py-2 ${item.className || ""}
2902
- ${activeItem === item.name ? "bg-accent text-accent-foreground" : ""}`,
2903
- children: /* @__PURE__ */ jsxRuntime.jsx(item.icon, { strokeWidth: item.iconStroke ? item.iconStroke : 2, className: item.iconClassName ? item.iconClassName : "w-5 h-5" })
2904
- }
2905
- ) }),
2906
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: item.tooltipSide ? item.tooltipSide : "right", children: item.tooltip || item.name })
2907
- ] }, item.name),
2908
- item.showSeperator && /* @__PURE__ */ jsxRuntime.jsx(Separator, {})
2909
- ] }, item.name)) });
2910
- };
2870
+ var NavVerticalItems = ({ items }) => /* @__PURE__ */ jsxRuntime.jsx(NavItems, { items, orientation: "vertical" });
2911
2871
  var NavVertical = ({
2912
2872
  className = "",
2913
2873
  top,
@@ -2983,6 +2943,124 @@ function PanelContent({
2983
2943
  footerContent ? /* @__PURE__ */ jsxRuntime.jsx(CardFooter, { className: footerClassName, children: footerContent }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
2984
2944
  ] }) });
2985
2945
  }
2946
+ function OptionRow({ option }) {
2947
+ const Icon = option.icon;
2948
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
2949
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
2950
+ Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 16, className: "shrink-0" }),
2951
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: option.label }),
2952
+ option.badge != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto pl-2", children: option.badge })
2953
+ ] }),
2954
+ option.description != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: option.description })
2955
+ ] });
2956
+ }
2957
+ function RichSelect({
2958
+ options,
2959
+ value,
2960
+ onChange,
2961
+ multiple = false,
2962
+ label,
2963
+ placeholder,
2964
+ renderOption,
2965
+ renderValue,
2966
+ align = "start",
2967
+ tooltip,
2968
+ tooltipSide = "top",
2969
+ disabled,
2970
+ triggerClassName,
2971
+ contentClassName,
2972
+ className
2973
+ }) {
2974
+ const selectedValues = Array.isArray(value) ? value : value ? [value] : [];
2975
+ const selectedOptions = selectedValues.map((v) => options.find((o) => o.value === v)).filter((o) => o != null);
2976
+ const toggle = (optionValue) => {
2977
+ const next = selectedValues.includes(optionValue) ? selectedValues.filter((v) => v !== optionValue) : [...selectedValues, optionValue];
2978
+ onChange(next);
2979
+ };
2980
+ const triggerLabel = (() => {
2981
+ if (renderValue) return renderValue(selectedOptions);
2982
+ if (selectedOptions.length === 0) {
2983
+ return placeholder ?? label ?? "Select\u2026";
2984
+ }
2985
+ if (selectedOptions.length === 1) {
2986
+ const only = selectedOptions[0];
2987
+ const Icon = only.icon;
2988
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
2989
+ Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 16, className: "shrink-0" }),
2990
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: only.label })
2991
+ ] });
2992
+ }
2993
+ return `${label ?? "Selected"}: ${selectedOptions.length}`;
2994
+ })();
2995
+ const trigger = /* @__PURE__ */ jsxRuntime.jsxs(
2996
+ Button,
2997
+ {
2998
+ variant: "outline",
2999
+ size: "sm",
3000
+ disabled,
3001
+ className: cn(
3002
+ "ring-offset-background justify-between gap-2",
3003
+ triggerClassName,
3004
+ className
3005
+ ),
3006
+ children: [
3007
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex min-w-0 items-center gap-2", children: triggerLabel }),
3008
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 shrink-0 opacity-60" })
3009
+ ]
3010
+ }
3011
+ );
3012
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
3013
+ tooltip != null ? /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { delayDuration: 0, children: [
3014
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: trigger }) }),
3015
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: tooltipSide, children: tooltip })
3016
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: trigger }),
3017
+ /* @__PURE__ */ jsxRuntime.jsxs(
3018
+ DropdownMenuContent,
3019
+ {
3020
+ align,
3021
+ className: cn("min-w-[14rem] bg-popover", contentClassName),
3022
+ children: [
3023
+ label && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3024
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { children: label }),
3025
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {})
3026
+ ] }),
3027
+ multiple ? options.map((option) => {
3028
+ const selected = selectedValues.includes(option.value);
3029
+ return /* @__PURE__ */ jsxRuntime.jsx(
3030
+ DropdownMenuCheckboxItem,
3031
+ {
3032
+ checked: selected,
3033
+ disabled: option.disabled,
3034
+ onSelect: (e) => e.preventDefault(),
3035
+ onCheckedChange: () => toggle(option.value),
3036
+ children: renderOption ? renderOption(option, { selected }) : /* @__PURE__ */ jsxRuntime.jsx(OptionRow, { option })
3037
+ },
3038
+ option.value
3039
+ );
3040
+ }) : /* @__PURE__ */ jsxRuntime.jsx(
3041
+ DropdownMenuRadioGroup,
3042
+ {
3043
+ value: selectedValues[0],
3044
+ onValueChange: (v) => onChange(v),
3045
+ children: options.map((option) => {
3046
+ const selected = selectedValues.includes(option.value);
3047
+ return /* @__PURE__ */ jsxRuntime.jsx(
3048
+ DropdownMenuRadioItem,
3049
+ {
3050
+ value: option.value,
3051
+ disabled: option.disabled,
3052
+ children: renderOption ? renderOption(option, { selected }) : /* @__PURE__ */ jsxRuntime.jsx(OptionRow, { option })
3053
+ },
3054
+ option.value
3055
+ );
3056
+ })
3057
+ }
3058
+ )
3059
+ ]
3060
+ }
3061
+ )
3062
+ ] });
3063
+ }
2986
3064
  function TabbedPanel({
2987
3065
  tabs,
2988
3066
  defaultTab,
@@ -3759,6 +3837,7 @@ exports.MenubarTrigger = MenubarTrigger;
3759
3837
  exports.NavBase = NavBase;
3760
3838
  exports.NavHorizontal = NavHorizontal;
3761
3839
  exports.NavHorizontalItems = NavHorizontalItems;
3840
+ exports.NavItems = NavItems;
3762
3841
  exports.NavVertical = NavVertical;
3763
3842
  exports.NavVerticalItems = NavVerticalItems;
3764
3843
  exports.NavigationMenu = NavigationMenu;
@@ -3785,6 +3864,7 @@ exports.Progress = Progress;
3785
3864
  exports.ResizableHandle = ResizableHandle;
3786
3865
  exports.ResizablePanel = ResizablePanel;
3787
3866
  exports.ResizablePanelGroup = ResizablePanelGroup;
3867
+ exports.RichSelect = RichSelect;
3788
3868
  exports.ScrollArea = ScrollArea;
3789
3869
  exports.ScrollBar = ScrollBar;
3790
3870
  exports.SearchInput = SearchInput;