{"version":3,"file":"index.cjs","names":["SelectPrimitive","ChevronDown","useTheme","Check"],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as SelectPrimitive from \"@radix-ui/react-select\";\nimport clsx from \"clsx\";\nimport { Check, ChevronDown } from \"lucide-react\";\nimport React, { createContext, forwardRef, useContext, useEffect, useMemo, useState } from \"react\";\nimport { useTheme } from \"../ThemeProvider\";\n\ntype SelectSize = \"sm\" | \"md\" | \"lg\";\n\ninterface SelectSizeContextType {\n  size: SelectSize;\n  setSize: (size: SelectSize) => void;\n}\n\nconst SelectSizeContext = createContext<SelectSizeContextType | null>(null);\n\nconst useSelectSizeContext = () => useContext(SelectSizeContext);\n\nexport interface SelectProps extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Root> {\n  size?: SelectSize;\n}\n\nexport const Select = ({ size = \"md\", ...props }: SelectProps) => {\n  const [currentSize, setCurrentSize] = useState<SelectSize>(size);\n\n  useEffect(() => {\n    setCurrentSize(size);\n  }, [size]);\n\n  const contextValue = useMemo(\n    () => ({ size: currentSize, setSize: setCurrentSize }),\n    [currentSize],\n  );\n\n  return (\n    <SelectSizeContext.Provider value={contextValue}>\n      <SelectPrimitive.Root {...props} />\n    </SelectSizeContext.Provider>\n  );\n};\n\nexport interface SelectGroupProps\n  extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Group> {\n  className?: string;\n  style?: React.CSSProperties;\n}\n\nexport const SelectGroup = forwardRef<\n  React.ComponentRef<typeof SelectPrimitive.Group>,\n  SelectGroupProps\n>(({ className, style, ...props }, ref) => (\n  <SelectPrimitive.Group\n    ref={ref}\n    className={clsx(\"openui-select-group\", className)}\n    style={style}\n    {...props}\n  />\n));\n\nexport const SelectValue = SelectPrimitive.Value;\n\nexport interface SelectTriggerProps\n  extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> {\n  className?: string;\n  style?: React.CSSProperties;\n  children?: React.ReactNode;\n  hideDropdownIcon?: boolean;\n  size?: SelectSize;\n}\n\nconst sizeMap: Record<string, string> = {\n  sm: \"openui-select-trigger-sm\",\n  md: \"openui-select-trigger-md\",\n  lg: \"openui-select-trigger-lg\",\n};\n\nexport const SelectTrigger = forwardRef<\n  React.ComponentRef<typeof SelectPrimitive.Trigger>,\n  SelectTriggerProps\n>(({ className, style, children, hideDropdownIcon, size, ...props }, ref) => {\n  const sizeContext = useSelectSizeContext();\n  const resolvedSize = size ?? sizeContext?.size ?? \"md\";\n\n  useEffect(() => {\n    if (sizeContext && sizeContext.size !== resolvedSize) {\n      sizeContext.setSize(resolvedSize);\n    }\n  }, [resolvedSize, sizeContext]);\n\n  return (\n    <SelectPrimitive.Trigger\n      ref={ref}\n      className={clsx(\"openui-select-trigger\", sizeMap[resolvedSize], className)}\n      style={style}\n      {...props}\n    >\n      {children}\n      <SelectPrimitive.Icon asChild>\n        {!hideDropdownIcon && <ChevronDown className=\"openui-select-trigger-icon\" />}\n      </SelectPrimitive.Icon>\n    </SelectPrimitive.Trigger>\n  );\n});\n\nexport interface SelectContentProps\n  extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> {\n  className?: string;\n  style?: React.CSSProperties;\n  children?: React.ReactNode;\n  position?: \"item-aligned\" | \"popper\";\n}\n\nexport const SelectContent = forwardRef<\n  React.ComponentRef<typeof SelectPrimitive.Content>,\n  SelectContentProps\n>(({ className, children, position = \"popper\", ...props }, ref) => {\n  const { portalThemeClassName } = useTheme();\n  const sizeContext = useSelectSizeContext();\n\n  return (\n    <SelectPrimitive.Portal>\n      <SelectPrimitive.Content\n        ref={ref}\n        className={clsx(\n          \"openui-select-content\",\n          sizeContext && `openui-select-content-${sizeContext.size}`,\n          className,\n          portalThemeClassName,\n        )}\n        position={position}\n        sideOffset={2}\n        {...props}\n      >\n        <SelectPrimitive.Viewport className=\"openui-select-viewport\" data-position={position}>\n          {children}\n        </SelectPrimitive.Viewport>\n      </SelectPrimitive.Content>\n    </SelectPrimitive.Portal>\n  );\n});\n\nexport interface SelectLabelProps\n  extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label> {\n  className?: string;\n  style?: React.CSSProperties;\n}\n\nexport const SelectLabel = forwardRef<\n  React.ComponentRef<typeof SelectPrimitive.Label>,\n  SelectLabelProps\n>(({ className, style, ...props }, ref) => (\n  <SelectPrimitive.Label\n    ref={ref}\n    className={clsx(\"openui-select-label\", className)}\n    style={style}\n    {...props}\n  />\n));\n\nexport interface SelectItemProps\n  extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> {\n  className?: string;\n  style?: React.CSSProperties;\n  children?: React.ReactNode;\n  textValue?: string;\n  showTick?: boolean;\n}\n\nexport const SelectItem = forwardRef<\n  React.ComponentRef<typeof SelectPrimitive.Item>,\n  SelectItemProps\n>(({ className, style, children, showTick = true, textValue, ...props }, ref) => (\n  <SelectPrimitive.Item\n    ref={ref}\n    className={clsx(\n      \"openui-select-item\",\n      showTick ? \"openui-select-item--with-tick\" : \"openui-select-item--without-tick\",\n      className,\n    )}\n    style={style}\n    {...props}\n  >\n    {showTick && (\n      <span className=\"openui-select-item-check-wrapper\">\n        <SelectPrimitive.ItemIndicator>\n          <Check className=\"openui-select-item-check-icon\" />\n        </SelectPrimitive.ItemIndicator>\n      </span>\n    )}\n    <SelectPrimitive.ItemText className=\"openui-select-item-text\">\n      {children}\n    </SelectPrimitive.ItemText>\n    {textValue && <span className=\"openui-select-item-text-value\">{textValue}</span>}\n  </SelectPrimitive.Item>\n));\n\nexport interface SelectSeparatorProps\n  extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator> {\n  className?: string;\n  style?: React.CSSProperties;\n}\n\nexport const SelectSeparator = forwardRef<\n  React.ComponentRef<typeof SelectPrimitive.Separator>,\n  SelectSeparatorProps\n>(({ className, style, ...props }, ref) => (\n  <SelectPrimitive.Separator\n    ref={ref}\n    className={clsx(\"openui-select-separator\", className)}\n    style={style}\n    {...props}\n  />\n));\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,qBAAA,GAAA,MAAA,eAAgE,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