PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / trunk
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance vtrunk
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / team-updraft / lib-onboarding-wizard / Wizard / Onboarding / src / components / Fields / DropdownInput.tsx

DropdownInput.tsx in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance trunk, at vendor/team-updraft/lib-onboarding-wizard/Wizard/Onboarding/src/components/Fields/DropdownInput.tsx

136 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use client"
2
3 import * as React from "react"
4 import * as SelectPrimitive from "@radix-ui/react-select"
5 import Icon from "../../utils/Icon" // Import Icon component
6
7 import { cn } from "../../utils/cn"
8
9 const Select = SelectPrimitive.Root
10
11 const SelectGroup = SelectPrimitive.Group
12
13 const SelectValue = SelectPrimitive.Value
14
15 const SelectTrigger = React.forwardRef<
16 React.ElementRef<typeof SelectPrimitive.Trigger>,
17 React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
18 >(({ className, children, ...props }, ref) => (
19 <SelectPrimitive.Trigger
20 ref={ref}
21 className={cn(
22 "flex w-full items-center rounded-md border border-gray-400 bg-white px-3 py-2 text-md ring-offset-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 relative pr-8 group",
23 className
24 )}
25 {...props}
26 >
27 {children}
28 <SelectPrimitive.Icon
29 className="absolute right-3 top-1/2 -translate-y-1/2 opacity-50 transition-transform duration-200 group-data-[state=open]:rotate-180"
30 >
31 <Icon name="expand" size={16} />
32 </SelectPrimitive.Icon>
33 </SelectPrimitive.Trigger>
34 ))
35 SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
36
37 const SelectContent = React.forwardRef<
38 React.ElementRef<typeof SelectPrimitive.Content>,
39 React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
40 >(({ className, children, position = "popper", ...props }, ref) => (
41 <SelectPrimitive.Portal container={document.getElementById('onboarding-modal-root')}>
42 <SelectPrimitive.Content
43 ref={ref}
44 className={cn(
45 "relative z-[100003] min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white text-gray-900 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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]:-translate-y-1",
46 position === "popper" &&
47 "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
48 className
49 )}
50 position={position}
51 {...props}
52 >
53 <SelectPrimitive.Viewport
54 className={cn(
55 // Make the options list scrollable and prevent it from exceeding the view.
56 // 60 = 240px (~5 items). When options exceed this, the list scrolls.
57 "p-1 max-h-60 overflow-y-auto custom-scrollbar [scrollbar-gutter:stable]", // show scrollbar gutter + styled scrollbar
58
59 position === "popper" &&
60 "w-full min-w-[var(--radix-select-trigger-width)]"
61 )}
62 >
63 {children}
64 </SelectPrimitive.Viewport>
65 </SelectPrimitive.Content>
66 </SelectPrimitive.Portal>
67 ))
68 SelectContent.displayName = SelectPrimitive.Content.displayName
69
70 const SelectLabel = React.forwardRef<
71 React.ElementRef<typeof SelectPrimitive.Label>,
72 React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
73 >(({ className, ...props }, ref) => (
74 <SelectPrimitive.Label
75 ref={ref}
76 className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
77 {...props}
78 />
79 ))
80 SelectLabel.displayName = SelectPrimitive.Label.displayName
81
82 interface SelectItemProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> {
83 premiumLabel?: React.ReactNode; // New prop for the premium label
84 }
85
86 const SelectItem = React.forwardRef<
87 React.ElementRef<typeof SelectPrimitive.Item>,
88 SelectItemProps // Use the new interface
89 >(({ className, children, premiumLabel, ...props }, ref) => ( // Destructure premiumLabel
90 <SelectPrimitive.Item
91 ref={ref}
92 className={cn(
93 "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-3 pr-8 text-md outline-none focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 flex-nowrap justify-between", // Added flex-nowrap and justify-between here
94 className
95 )}
96 {...props}
97 >
98 <SelectPrimitive.ItemText>
99 {children}
100 </SelectPrimitive.ItemText>
101 {premiumLabel && ( // Render premiumLabel as a sibling
102 <span className="text-orange-dark text-sm font-medium flex-shrink-0 ml-2">
103 {premiumLabel}
104 </span>
105 )}
106 <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
107 <SelectPrimitive.ItemIndicator>
108 <Icon name="CheckRoundedIcon" size={16} color="blue" />
109 </SelectPrimitive.ItemIndicator>
110 </span>
111 </SelectPrimitive.Item>
112 ))
113 SelectItem.displayName = SelectPrimitive.Item.displayName
114
115 const SelectSeparator = React.forwardRef<
116 React.ElementRef<typeof SelectPrimitive.Separator>,
117 React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
118 >(({ className, ...props }, ref) => (
119 <SelectPrimitive.Separator
120 ref={ref}
121 className={cn("-mx-1 my-1 h-px bg-gray-100", className)}
122 {...props}
123 />
124 ))
125 SelectSeparator.displayName = SelectPrimitive.Separator.displayName
126
127 export {
128 Select,
129 SelectGroup,
130 SelectValue,
131 SelectTrigger,
132 SelectContent,
133 SelectLabel,
134 SelectItem,
135 SelectSeparator,
136 }