@bikdotai/bik-component-library 0.0.763-beta.31 → 0.0.763-beta.32
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("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),n=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),n=require("react"),l=require("../../constants/Theme.js"),o=require("../../assets/icons/chevronDown.svg.js"),r=require("../input/Input.js"),i=require("../input/context/InputStyleProvider.js"),s=require("./ChipInput.js"),a=require("./DropdownPopover/index.js"),d=require("./OpenedDropdown/utils/iterationOnOptions.js");function u(){}const c=c=>{var p,h,v,x,g,{placeHolder:f,size:j,onSelect:m,defaultOptions:w,disabled:b,noErrorHint:O,placeHolderHeight:S,showPlaceholderWhenSelected:y=!1,inputStyle:I={},inputType:H="default",onDeleteChip:D,truncatedText:P,showLeadingIconInPlaceholder:T=!1,showTrailingIconPlaceholder:q=!1,showLabelsOnMoreHover:C=!1}=c,E=e.__rest(c,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover"]);const[W,L]=n.useState(!1),M=null!=j?j:"default",_=n.useRef(),[z,A]=n.useState(null!=w?w:[]),F=n.useRef(null),[R,k]=n.useState(null);n.useEffect((()=>{var e;const t=[];console.log(E.value),null===(e=null==E?void 0:E.options)||void 0===e||e.forEach((e=>{e.options?e.options.forEach((e=>{e.selected&&t.push(Object.assign(Object.assign({},e),{label:e.label}))})):e.selected&&t.push(e)})),A([...t])}),[E.options]),n.useEffect((()=>{w&&A([...w])}),[w]);const N=d.getSelectedOptionsAsText(z),U=y?f:null!==(p=null!=N?N:f)&&void 0!==p?p:"Select an option";n.useEffect((()=>{if(F.current){const e=F.current.scrollWidth;k(e+("x-small"===M?16:"small"===M?20:24)+2*("x-small"===M?16:12)+8+2)}}),[U,M]);const V=null!==(v=null!==(h=E.buttonWidth)&&void 0!==h?h:E.inputWidth)&&void 0!==v?v:"100%",$=R?`${R}px`:V;return t.jsxs(t.Fragment,{children:[t.jsx("span",Object.assign({ref:F,style:{position:"absolute",visibility:"hidden",whiteSpace:"nowrap",fontSize:"x-small"===M?"12px":"small"===M?"14px":"16px",fontFamily:"Inter"}},{children:U})),t.jsx(i.InputStyleContext.Provider,Object.assign({value:{InputWrapper:Object.assign({height:S||("x-small"===M?24:"small"===M?32:48),width:$,maxWidth:V,zIndex:1,cursor:"pointer",padding:"x-small"===M?"4px 8px":"6px 8px"},I),input:{minHeight:"100%",maxWidth:"100%"}}},{children:t.jsxs(a.DropdownPopover,Object.assign({"data-test":E["data-test"],ref:_,onSelect:function(e){Array.isArray(e)?A([...e]):A([e]),null==m||m(e)},disabled:b,onDropdownVisbilityChange:e=>L(e)},E,{children:["default"==H&&t.jsx(r.Input,{version:E.version,noErrorHint:O,state:b?"disabled":"none",value:void 0===E.value?U:E.value,errorMessage:E.error,variant:M,placeholder:null!=f?f:"Select an option",onChangeText:u,leftIcon:T&&(null===(x=z[0])||void 0===x?void 0:x.leadingIcon)?{icon:()=>{var e;return t.jsx(t.Fragment,{children:null===(e=z[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>{var e;return t.jsxs("div",Object.assign({style:{display:"flex"}},{children:[q&&(null===(e=z[0])||void 0===e?void 0:e.trailingIcon),t.jsx(o.default,{style:{transform:W?"rotate(180deg)":"rotate(0deg)"},onClick:u,width:"x-small"===M?16:"small"===M?20:24,height:"x-small"===M?16:"small"===M?20:24,color:l.COLORS.content.primary})]}))}},truncateText:null==P||P}),"chip"==H&&t.jsx(s.default,{placeholder:null!=f?f:"Select options",chips:z,onDeleteChip:e=>{null==D||D(e)},errorMessage:E.error,isDropdownOpened:W,sizeToUse:M,containerStyle:{width:null!==(g=E.width)&&void 0!==g?g:"100%",cursor:"pointer"},showLabelsOnMoreHover:C})]}))}))]})};c.displayName="Dropdown",exports.Dropdown=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../_virtual/_tslib.js";import{
|
|
1
|
+
import{__rest as e}from"../../_virtual/_tslib.js";import{jsxs as o,Fragment as n,jsx as l}from"react/jsx-runtime";import{useState as t,useRef as i,useEffect as r}from"react";import{COLORS as s}from"../../constants/Theme.js";import a from"../../assets/icons/chevronDown.svg.js";import{Input as d}from"../input/Input.js";import{InputStyleContext as c}from"../input/context/InputStyleProvider.js";import p from"./ChipInput.js";import{DropdownPopover as u}from"./DropdownPopover/index.js";import{getSelectedOptionsAsText as h}from"./OpenedDropdown/utils/iterationOnOptions.js";function m(){}const v=v=>{var g,f,x,b,w,{placeHolder:y,size:I,onSelect:j,defaultOptions:O,disabled:S,noErrorHint:H,placeHolderHeight:T,showPlaceholderWhenSelected:D=!1,inputStyle:P={},inputType:W="default",onDeleteChip:C,truncatedText:z,showLeadingIconInPlaceholder:E=!1,showTrailingIconPlaceholder:L=!1,showLabelsOnMoreHover:M=!1}=v,A=e(v,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover"]);const[_,k]=t(!1),F=null!=I?I:"default",N=i(),[U,V]=t(null!=O?O:[]),$=i(null),[q,B]=t(null);r((()=>{var e;const o=[];console.log(A.value),null===(e=null==A?void 0:A.options)||void 0===e||e.forEach((e=>{e.options?e.options.forEach((e=>{e.selected&&o.push(Object.assign(Object.assign({},e),{label:e.label}))})):e.selected&&o.push(e)})),V([...o])}),[A.options]),r((()=>{O&&V([...O])}),[O]);const G=h(U),J=D?y:null!==(g=null!=G?G:y)&&void 0!==g?g:"Select an option";r((()=>{if($.current){const e=$.current.scrollWidth;B(e+("x-small"===F?16:"small"===F?20:24)+2*("x-small"===F?16:12)+8+2)}}),[J,F]);const K=null!==(x=null!==(f=A.buttonWidth)&&void 0!==f?f:A.inputWidth)&&void 0!==x?x:"100%",Q=q?`${q}px`:K;return o(n,{children:[l("span",Object.assign({ref:$,style:{position:"absolute",visibility:"hidden",whiteSpace:"nowrap",fontSize:"x-small"===F?"12px":"small"===F?"14px":"16px",fontFamily:"Inter"}},{children:J})),l(c.Provider,Object.assign({value:{InputWrapper:Object.assign({height:T||("x-small"===F?24:"small"===F?32:48),width:Q,maxWidth:K,zIndex:1,cursor:"pointer",padding:"x-small"===F?"4px 8px":"6px 8px"},P),input:{minHeight:"100%",maxWidth:"100%"}}},{children:o(u,Object.assign({"data-test":A["data-test"],ref:N,onSelect:function(e){Array.isArray(e)?V([...e]):V([e]),null==j||j(e)},disabled:S,onDropdownVisbilityChange:e=>k(e)},A,{children:["default"==W&&l(d,{version:A.version,noErrorHint:H,state:S?"disabled":"none",value:void 0===A.value?J:A.value,errorMessage:A.error,variant:F,placeholder:null!=y?y:"Select an option",onChangeText:m,leftIcon:E&&(null===(b=U[0])||void 0===b?void 0:b.leadingIcon)?{icon:()=>{var e;return l(n,{children:null===(e=U[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>{var e;return o("div",Object.assign({style:{display:"flex"}},{children:[L&&(null===(e=U[0])||void 0===e?void 0:e.trailingIcon),l(a,{style:{transform:_?"rotate(180deg)":"rotate(0deg)"},onClick:m,width:"x-small"===F?16:"small"===F?20:24,height:"x-small"===F?16:"small"===F?20:24,color:s.content.primary})]}))}},truncateText:null==z||z}),"chip"==W&&l(p,{placeholder:null!=y?y:"Select options",chips:U,onDeleteChip:e=>{null==C||C(e)},errorMessage:A.error,isDropdownOpened:_,sizeToUse:F,containerStyle:{width:null!==(w=A.width)&&void 0!==w?w:"100%",cursor:"pointer"},showLabelsOnMoreHover:M})]}))}))]})};v.displayName="Dropdown";export{v as Dropdown};
|