@bikdotai/bik-component-library 0.0.673-beta.0 → 0.0.673-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../utils/StringUtils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../utils/StringUtils.js"),l=require("../../constants/Theme.js"),r=require("../../assets/icons/chevronDown.svg.js"),i=require("../../assets/icons/cross.svg.js"),n=require("../../assets/icons/errorInfo.svg.js"),o=require("../input/Input.styled.js"),a=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),d=require("../TypographyStyle.js"),h=require("./Common.styled.js");exports.default=j=>{let{chips:g,onDeleteChip:u,containerStyle:p={},sizeToUse:x="default",isDropdownOpened:O,placeholder:b="Select..",errorMessage:y="",showLabelsOnMoreHover:m=!1}=j;const[v,f]=t.useState(),[q,C]=t.useState(0),[S,T]=t.useState([]);return t.useEffect((()=>{if(!g)return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(g);let s=g.filter((s=>(e+=s.label.length,e<=t)));0===s.length&&g.length>0&&(s=[g[0]]),f(s);const l=g.filter((e=>!s.includes(e))).map((e=>e.label));T(l),C(g.length-s.length)}),[g]),e.jsxs(e.Fragment,{children:[e.jsxs(h.ChipInputWrapper,Object.assign({style:Object.assign({},p),error:!!y},{children:[e.jsxs("div",Object.assign({className:"chips-container"},{children:[null==v?void 0:v.map(((t,l)=>e.jsx("div",Object.assign({style:{zIndex:2}},{children:e.jsx(a.Tag,Object.assign({tagText:s.default.truncateText(t.selectedLabel||t.label,40),TrailingIcon:()=>e.jsx(i.default,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{u(t)}})},{children:t.selectedLabel||t.label}))}),l))),!!q&&e.jsx("div",Object.assign({style:{position:"relative",zIndex:10,pointerEvents:"auto"}},{children:e.jsx(c.Tooltip,Object.assign({body:"",placement:"bottom",tooltipContent:m&&S.length>0?e.jsx("div",Object.assign({style:{padding:"4px"}},{children:S.map(((t,s)=>e.jsx(d.BodyCaption,Object.assign({style:{color:l.COLORS.text.white}},{children:t}),s)))})):void 0},{children:e.jsx(d.BodyCaption,Object.assign({color:l.COLORS.content.placeholder},{children:`+${q} more`}))}))})),0===g.length&&e.jsx("div",Object.assign({style:{color:l.COLORS.content.placeholder}},{children:b}))]})),e.jsx("div",{children:e.jsx(r.default,{style:{transform:O?"rotate(180deg)":"rotate(0deg)"},width:"x-small"===x?16:"small"===x?20:24,height:"x-small"===x?16:"small"===x?20:24,color:l.COLORS.content.primary})})]})),!!y&&e.jsxs(o.InputFooter,Object.assign({invalid:!0},{children:[!!y&&e.jsx(n.default,{width:16,height:16}),y]}))]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as t,jsx as s}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as s}from"react/jsx-runtime";import{useState as o,useEffect as l}from"react";import i from"../../utils/StringUtils.js";import{COLORS as r}from"../../constants/Theme.js";import n from"../../assets/icons/chevronDown.svg.js";import c from"../../assets/icons/cross.svg.js";import a from"../../assets/icons/errorInfo.svg.js";import{InputFooter as d}from"../input/Input.styled.js";import{Tag as h}from"../tag/Tag.js";import{Tooltip as m}from"../tooltips/Tooltip.js";import{BodyCaption as p}from"../TypographyStyle.js";import{ChipInputWrapper as g}from"./Common.styled.js";const j=j=>{let{chips:b,onDeleteChip:f,containerStyle:v={},sizeToUse:y="default",isDropdownOpened:O,placeholder:u="Select..",errorMessage:x="",showLabelsOnMoreHover:T=!1}=j;const[w,I]=o(),[C,S]=o(0),[z,D]=o([]);return l((()=>{if(!b)return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(b);let s=b.filter((s=>(e+=s.label.length,e<=t)));0===s.length&&b.length>0&&(s=[b[0]]),I(s);const o=b.filter((e=>!s.includes(e))).map((e=>e.label));D(o),S(b.length-s.length)}),[b]),e(t,{children:[e(g,Object.assign({style:Object.assign({},v),error:!!x},{children:[e("div",Object.assign({className:"chips-container"},{children:[null==w?void 0:w.map(((e,t)=>s("div",Object.assign({style:{zIndex:2}},{children:s(h,Object.assign({tagText:i.truncateText(e.selectedLabel||e.label,40),TrailingIcon:()=>s(c,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{f(e)}})},{children:e.selectedLabel||e.label}))}),t))),!!C&&s("div",Object.assign({style:{position:"relative",zIndex:10,pointerEvents:"auto"}},{children:s(m,Object.assign({body:"",placement:"bottom",tooltipContent:T&&z.length>0?s("div",Object.assign({style:{padding:"4px"}},{children:z.map(((e,t)=>s(p,Object.assign({style:{color:r.text.white}},{children:e}),t)))})):void 0},{children:s(p,Object.assign({color:r.content.placeholder},{children:`+${C} more`}))}))})),0===b.length&&s("div",Object.assign({style:{color:r.content.placeholder}},{children:u}))]})),s("div",{children:s(n,{style:{transform:O?"rotate(180deg)":"rotate(0deg)"},width:"x-small"===y?16:"small"===y?20:24,height:"x-small"===y?16:"small"===y?20:24,color:r.content.primary})})]})),!!x&&e(d,Object.assign({invalid:!0},{children:[!!x&&s(a,{width:16,height:16}),x]}))]})};export{j as default};
|