AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import * as SelectPrimitive from "@radix-ui/react-select"
  2. import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
  3. import * as React from "react"
  4. import { cn } from "@/lib/utils"
  5. function Select({
  6. ...props
  7. }: React.ComponentProps<typeof SelectPrimitive.Root>) {
  8. return <SelectPrimitive.Root data-slot="select" {...props} />
  9. }
  10. function SelectGroup({
  11. ...props
  12. }: React.ComponentProps<typeof SelectPrimitive.Group>) {
  13. return <SelectPrimitive.Group data-slot="select-group" {...props} />
  14. }
  15. function SelectValue({
  16. ...props
  17. }: React.ComponentProps<typeof SelectPrimitive.Value>) {
  18. return <SelectPrimitive.Value data-slot="select-value" {...props} />
  19. }
  20. function SelectTrigger({
  21. className,
  22. size = "default",
  23. children,
  24. ...props
  25. }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
  26. size?: "sm" | "default"
  27. }) {
  28. return (
  29. <SelectPrimitive.Trigger
  30. data-slot="select-trigger"
  31. data-size={size}
  32. className={cn(
  33. "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 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-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
  34. className
  35. )}
  36. {...props}
  37. >
  38. {children}
  39. <SelectPrimitive.Icon asChild>
  40. <ChevronDownIcon className="size-4 opacity-50" />
  41. </SelectPrimitive.Icon>
  42. </SelectPrimitive.Trigger>
  43. )
  44. }
  45. function SelectContent({
  46. className,
  47. children,
  48. position = "popper",
  49. side = "bottom",
  50. sideOffset = 4,
  51. align = "center",
  52. ...props
  53. }: React.ComponentProps<typeof SelectPrimitive.Content>) {
  54. return (
  55. <SelectPrimitive.Portal>
  56. <SelectPrimitive.Content
  57. data-slot="select-content"
  58. className={cn(
  59. "bg-popover text-popover-foreground 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]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
  60. position === "popper" &&
  61. "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
  62. className
  63. )}
  64. position={position}
  65. side={side}
  66. sideOffset={sideOffset}
  67. avoidCollisions={false}
  68. align={align}
  69. {...props}
  70. >
  71. <SelectScrollUpButton />
  72. <SelectPrimitive.Viewport
  73. className={cn(
  74. "p-1",
  75. position === "popper" &&
  76. "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
  77. )}
  78. >
  79. {children}
  80. </SelectPrimitive.Viewport>
  81. <SelectScrollDownButton />
  82. </SelectPrimitive.Content>
  83. </SelectPrimitive.Portal>
  84. )
  85. }
  86. function SelectLabel({
  87. className,
  88. ...props
  89. }: React.ComponentProps<typeof SelectPrimitive.Label>) {
  90. return (
  91. <SelectPrimitive.Label
  92. data-slot="select-label"
  93. className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
  94. {...props}
  95. />
  96. )
  97. }
  98. function SelectItem({
  99. className,
  100. children,
  101. ...props
  102. }: React.ComponentProps<typeof SelectPrimitive.Item>) {
  103. return (
  104. <SelectPrimitive.Item
  105. data-slot="select-item"
  106. className={cn(
  107. "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground 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 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",
  108. className
  109. )}
  110. {...props}
  111. >
  112. <span
  113. data-slot="select-item-indicator"
  114. className="absolute right-2 flex size-3.5 items-center justify-center"
  115. >
  116. <SelectPrimitive.ItemIndicator>
  117. <CheckIcon className="size-4" />
  118. </SelectPrimitive.ItemIndicator>
  119. </span>
  120. <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
  121. </SelectPrimitive.Item>
  122. )
  123. }
  124. function SelectSeparator({
  125. className,
  126. ...props
  127. }: React.ComponentProps<typeof SelectPrimitive.Separator>) {
  128. return (
  129. <SelectPrimitive.Separator
  130. data-slot="select-separator"
  131. className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
  132. {...props}
  133. />
  134. )
  135. }
  136. function SelectScrollUpButton({
  137. className,
  138. ...props
  139. }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
  140. return (
  141. <SelectPrimitive.ScrollUpButton
  142. data-slot="select-scroll-up-button"
  143. className={cn(
  144. "flex cursor-default items-center justify-center py-1",
  145. className
  146. )}
  147. {...props}
  148. >
  149. <ChevronUpIcon className="size-4" />
  150. </SelectPrimitive.ScrollUpButton>
  151. )
  152. }
  153. function SelectScrollDownButton({
  154. className,
  155. ...props
  156. }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
  157. return (
  158. <SelectPrimitive.ScrollDownButton
  159. data-slot="select-scroll-down-button"
  160. className={cn(
  161. "flex cursor-default items-center justify-center py-1",
  162. className
  163. )}
  164. {...props}
  165. >
  166. <ChevronDownIcon className="size-4" />
  167. </SelectPrimitive.ScrollDownButton>
  168. )
  169. }
  170. export {
  171. Select,
  172. SelectContent,
  173. SelectGroup,
  174. SelectItem,
  175. SelectLabel,
  176. SelectScrollDownButton,
  177. SelectScrollUpButton,
  178. SelectSeparator,
  179. SelectTrigger,
  180. SelectValue,
  181. }