UNPKG

@bothub-chat/ui

Version:

Bothub UI Components

2 lines (1 loc) 676 B
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useRef as o,useState as n,useCallback as l}from"react";import{ColorPickerStyled as t,ColorPickerLabel as c,ColorPickerBottom as i,ColorPickerHex as m,ColorPickerPreview as a}from"./styled.js";import{ColorPickerMenu as f}from"./menu/index.js";const p=({label:p,preview:s=!0,color:d="#1c64f2",onChange:u})=>{const h=o(null),[C,g]=n(!1),j=l(e=>{null==u||u(e)},[]);return e(t,{ref:h,children:[p&&r(c,{children:p}),e(i,{$active:C,onClick:e=>{e.preventDefault(),g(!C)},children:[r(m,{children:d}),s&&r(a,{style:{backgroundColor:d}})]}),C&&r(f,{color:d,parentRef:h,onChange:j,onClose:()=>g(!1)})]})};export{p as ColorPicker};