UNPKG

@bothub-chat/ui

Version:

Bothub UI Components

2 lines (1 loc) 1.43 kB
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{SelectFieldValue as o,SelectFieldValueText as i,SelectFieldValues as n,SelectFieldValueList as r,SelectFieldValueListItem as t,SelectFieldValueColor as c,SelectFieldColorValueText as d}from"../../styled.js";import"tslib";import{IconProvider as a}from"../../../icon/context.js";import"../../../icon/styled.js";import{Tooltip as s}from"../../../tooltip/index.js";import"../../../../theme/index.js";import{useTheme as h}from"../../../../theme/hook.js";import{TooltipConsumer as m}from"../../../tooltip/context.js";const p=({value:p,handleValueDelete:u})=>{const b=h();return p&&["string","object"].includes(typeof p)?"string"==typeof p?e(o,{children:e(i,{children:p})}):Array.isArray(p)?e(n,{children:e(r,{children:p.map(((l,o)=>{var i,n,r;return"string"==typeof l?e(t,{onDelete:u.bind(null,l),children:l},l):e(t,{onDelete:u.bind(null,l),children:null!==(i=l.label)&&void 0!==i?i:l.value},null!==(r=null!==(n=l.id)&&void 0!==n?n:l.value)&&void 0!==r?r:o)}))})}):l(o,{children:[p.icon&&e(a,{fill:b.colors.base.white,size:18,children:p.icon}),p.color&&e(c,{$color:p.color}),p.label&&e(s,{label:p.label,placement:"top-left",disabled:p.label.length<=128,children:e(m,{children:({handleTooltipMouseEnter:l,handleTooltipMouseLeave:o})=>e(d,{onMouseEnter:l,onMouseLeave:o,children:p.label})})}),!p.label&&p.value&&e(d,{children:p.value})]}):null};export{p as SelectFieldInputValue};