@invana/ui 0.0.4 → 0.0.5

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
@@ -2983,6 +2983,124 @@ function PanelContent({
2983
2983
  footerContent ? /* @__PURE__ */ jsxRuntime.jsx(CardFooter, { className: footerClassName, children: footerContent }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
2984
2984
  ] }) });
2985
2985
  }
2986
+ function OptionRow({ option }) {
2987
+ const Icon = option.icon;
2988
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
2989
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
2990
+ Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 16, className: "shrink-0" }),
2991
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: option.label }),
2992
+ option.badge != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto pl-2", children: option.badge })
2993
+ ] }),
2994
+ option.description != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: option.description })
2995
+ ] });
2996
+ }
2997
+ function RichSelect({
2998
+ options,
2999
+ value,
3000
+ onChange,
3001
+ multiple = false,
3002
+ label,
3003
+ placeholder,
3004
+ renderOption,
3005
+ renderValue,
3006
+ align = "start",
3007
+ tooltip,
3008
+ tooltipSide = "top",
3009
+ disabled,
3010
+ triggerClassName,
3011
+ contentClassName,
3012
+ className
3013
+ }) {
3014
+ const selectedValues = Array.isArray(value) ? value : value ? [value] : [];
3015
+ const selectedOptions = selectedValues.map((v) => options.find((o) => o.value === v)).filter((o) => o != null);
3016
+ const toggle = (optionValue) => {
3017
+ const next = selectedValues.includes(optionValue) ? selectedValues.filter((v) => v !== optionValue) : [...selectedValues, optionValue];
3018
+ onChange(next);
3019
+ };
3020
+ const triggerLabel = (() => {
3021
+ if (renderValue) return renderValue(selectedOptions);
3022
+ if (selectedOptions.length === 0) {
3023
+ return placeholder ?? label ?? "Select\u2026";
3024
+ }
3025
+ if (selectedOptions.length === 1) {
3026
+ const only = selectedOptions[0];
3027
+ const Icon = only.icon;
3028
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
3029
+ Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 16, className: "shrink-0" }),
3030
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: only.label })
3031
+ ] });
3032
+ }
3033
+ return `${label ?? "Selected"}: ${selectedOptions.length}`;
3034
+ })();
3035
+ const trigger = /* @__PURE__ */ jsxRuntime.jsxs(
3036
+ Button,
3037
+ {
3038
+ variant: "outline",
3039
+ size: "sm",
3040
+ disabled,
3041
+ className: cn(
3042
+ "ring-offset-background justify-between gap-2",
3043
+ triggerClassName,
3044
+ className
3045
+ ),
3046
+ children: [
3047
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex min-w-0 items-center gap-2", children: triggerLabel }),
3048
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 shrink-0 opacity-60" })
3049
+ ]
3050
+ }
3051
+ );
3052
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
3053
+ tooltip != null ? /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { delayDuration: 0, children: [
3054
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: trigger }) }),
3055
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: tooltipSide, children: tooltip })
3056
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: trigger }),
3057
+ /* @__PURE__ */ jsxRuntime.jsxs(
3058
+ DropdownMenuContent,
3059
+ {
3060
+ align,
3061
+ className: cn("min-w-[14rem] bg-popover", contentClassName),
3062
+ children: [
3063
+ label && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3064
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { children: label }),
3065
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {})
3066
+ ] }),
3067
+ multiple ? options.map((option) => {
3068
+ const selected = selectedValues.includes(option.value);
3069
+ return /* @__PURE__ */ jsxRuntime.jsx(
3070
+ DropdownMenuCheckboxItem,
3071
+ {
3072
+ checked: selected,
3073
+ disabled: option.disabled,
3074
+ onSelect: (e) => e.preventDefault(),
3075
+ onCheckedChange: () => toggle(option.value),
3076
+ children: renderOption ? renderOption(option, { selected }) : /* @__PURE__ */ jsxRuntime.jsx(OptionRow, { option })
3077
+ },
3078
+ option.value
3079
+ );
3080
+ }) : /* @__PURE__ */ jsxRuntime.jsx(
3081
+ DropdownMenuRadioGroup,
3082
+ {
3083
+ value: selectedValues[0],
3084
+ onValueChange: (v) => onChange(v),
3085
+ children: options.map((option) => {
3086
+ const selected = selectedValues.includes(option.value);
3087
+ return /* @__PURE__ */ jsxRuntime.jsx(
3088
+ DropdownMenuRadioItem,
3089
+ {
3090
+ value: option.value,
3091
+ disabled: option.disabled,
3092
+ children: renderOption ? renderOption(option, { selected }) : /* @__PURE__ */ jsxRuntime.jsx(OptionRow, { option })
3093
+ },
3094
+ option.value
3095
+ );
3096
+ })
3097
+ }
3098
+ )
3099
+ ]
3100
+ }
3101
+ )
3102
+ ] });
3103
+ }
2986
3104
  function TabbedPanel({
2987
3105
  tabs,
2988
3106
  defaultTab,
@@ -3785,6 +3903,7 @@ exports.Progress = Progress;
3785
3903
  exports.ResizableHandle = ResizableHandle;
3786
3904
  exports.ResizablePanel = ResizablePanel;
3787
3905
  exports.ResizablePanelGroup = ResizablePanelGroup;
3906
+ exports.RichSelect = RichSelect;
3788
3907
  exports.ScrollArea = ScrollArea;
3789
3908
  exports.ScrollBar = ScrollBar;
3790
3909
  exports.SearchInput = SearchInput;