@bothub-chat/ui
Version:
Bothub UI Components
2 lines (1 loc) • 658 B
JavaScript
import{jsxs as r,jsx as e}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 s}from"./menu/index.js";const d=({label:d,preview:f=!0,color:p="#1c64f2",onChange:h})=>{const u=o(null),[C,g]=n(!1),j=l((r=>{null==h||h(r)}),[]);return r(t,{ref:u,children:[d&&e(c,{children:d}),r(i,{$active:C,onClick:()=>g(!C),children:[e(m,{children:p}),f&&e(a,{style:{backgroundColor:p}})]}),C&&e(s,{color:p,parentRef:u,onChange:j,onClose:()=>g(!1)})]})};export{d as ColorPicker};