UNPKG

@bothub-chat/ui

Version:

Bothub UI Components

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