@bikdotai/bik-component-library 0.0.770-beta.3 → 0.0.770-beta.4
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.
|
@@ -18,7 +18,5 @@ export type DropdownProps = OpenDropdownProps & {
|
|
|
18
18
|
showLabelsOnMoreHover?: boolean;
|
|
19
19
|
backgroundColor?: string;
|
|
20
20
|
value?: string;
|
|
21
|
-
/** When true, resizes the input box to fit the selected text. Defaults to false for backward compatibility. */
|
|
22
|
-
autoResize?: boolean;
|
|
23
21
|
};
|
|
24
22
|
export declare const Dropdown: React.FC<DropdownProps>;
|
|
@@ -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"),o=require("../../constants/Theme.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),n=require("react"),o=require("../../constants/Theme.js"),r=require("../../assets/icons/chevronDown.svg.js"),l=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,g,{placeHolder:f,size:x,onSelect:j,defaultOptions:b,disabled:w,noErrorHint:O,placeHolderHeight:S,showPlaceholderWhenSelected:I=!1,inputStyle:m={},inputType:y="default",onDeleteChip:E,truncatedText:H,showLeadingIconInPlaceholder:C=!1,showTrailingIconPlaceholder:D=!1,showLabelsOnMoreHover:P=!1,value:T}=c,q=e.__rest(c,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover","value"]);const[M,L]=n.useState(!1),[W,_]=n.useState(!1),z=null!=x?x:"default",k=n.useRef(),[A,R]=n.useState(null!=b?b:[]),F=n.useRef(null),[N,U]=n.useState(void 0);n.useEffect((()=>{var e;const t=[];null===(e=null==q?void 0:q.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)})),R([...t])}),[q.options]),n.useEffect((()=>{b&&R([...b])}),[b]);const V=d.getSelectedOptionsAsText(A),$=I?f:null!==(p=null!=V?V:f)&&void 0!==p?p:"Select an option",B=null!==(h=q.buttonWidth)&&void 0!==h?h:q.width;n.useEffect((()=>{B||F.current&&U(`${F.current.offsetWidth}px`)}),[B]);const G=null!=B?B:"100%",J=null!=B?B:N;return t.jsx(t.Fragment,{children:t.jsx(i.InputStyleContext.Provider,Object.assign({value:{InputWrapper:Object.assign(Object.assign(Object.assign({height:S||("x-small"===z?24:"small"===z?32:48),width:G},B?{maxWidth:B}:{}),{zIndex:1,cursor:"pointer",padding:"x-small"===z?"4px 8px":"6px 8px",backgroundColor:void 0!==T?"#C3E4C4":W?"#E0E0E0":"#ffffff",transition:"background-color 0.3s ease"}),m),input:{minHeight:"100%",maxWidth:"100%",color:void 0!==T?"#00580E":"inherit"}}},{children:t.jsx("div",Object.assign({ref:F,onMouseEnter:()=>_(!0),onMouseLeave:()=>_(!1)},{children:t.jsxs(a.DropdownPopover,Object.assign({"data-test":q["data-test"],ref:k,onSelect:function(e){Array.isArray(e)?R([...e]):R([e]),null==j||j(e)},disabled:w,onDropdownVisbilityChange:e=>L(e)},q,{width:J},{children:["default"==y&&t.jsx(l.Input,{version:q.version,noErrorHint:O,state:w?"disabled":"none",value:void 0===T?$:T,errorMessage:q.error,variant:z,placeholder:null!=f?f:"Select an option",onChangeText:u,leftIcon:C&&(null===(v=A[0])||void 0===v?void 0:v.leadingIcon)?{icon:()=>{var e;return t.jsx(t.Fragment,{children:null===(e=A[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>{var e;return t.jsxs("div",Object.assign({style:{display:"flex"}},{children:[D&&(null===(e=A[0])||void 0===e?void 0:e.trailingIcon),t.jsx(r.default,{style:{transform:M?"rotate(180deg)":"rotate(0deg)"},onClick:u,width:"x-small"===z?16:"small"===z?20:24,height:"x-small"===z?16:"small"===z?20:24,color:o.COLORS.content.primary})]}))}},truncateText:null==H||H}),"chip"==y&&t.jsx(s.default,{placeholder:null!=f?f:"Select options",chips:A,onDeleteChip:e=>{null==E||E(e)},errorMessage:q.error,isDropdownOpened:M,sizeToUse:z,containerStyle:{width:null!==(g=q.width)&&void 0!==g?g:"100%",cursor:"pointer"},showLabelsOnMoreHover:P})]}))}))}))})};c.displayName="Dropdown",exports.Dropdown=c;
|
|
@@ -18,7 +18,5 @@ export type DropdownProps = OpenDropdownProps & {
|
|
|
18
18
|
showLabelsOnMoreHover?: boolean;
|
|
19
19
|
backgroundColor?: string;
|
|
20
20
|
value?: string;
|
|
21
|
-
/** When true, resizes the input box to fit the selected text. Defaults to false for backward compatibility. */
|
|
22
|
-
autoResize?: boolean;
|
|
23
21
|
};
|
|
24
22
|
export declare const Dropdown: React.FC<DropdownProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../_virtual/_tslib.js";import{
|
|
1
|
+
import{__rest as e}from"../../_virtual/_tslib.js";import{jsx as o,Fragment as n,jsxs as t}from"react/jsx-runtime";import{useState as l,useRef as r,useEffect as i}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 v(){}const m=m=>{var f,g,b,w,{placeHolder:x,size:j,onSelect:O,defaultOptions:I,disabled:y,noErrorHint:H,placeHolderHeight:S,showPlaceholderWhenSelected:E=!1,inputStyle:C={},inputType:T="default",onDeleteChip:D,truncatedText:P,showLeadingIconInPlaceholder:M=!1,showTrailingIconPlaceholder:W=!1,showLabelsOnMoreHover:L=!1,value:z}=m,k=e(m,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover","value"]);const[A,_]=l(!1),[N,U]=l(!1),V=null!=j?j:"default",$=r(),[q,B]=l(null!=I?I:[]),F=r(null),[G,J]=l(void 0);i((()=>{var e;const o=[];null===(e=null==k?void 0:k.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)})),B([...o])}),[k.options]),i((()=>{I&&B([...I])}),[I]);const K=h(q),Q=E?x:null!==(f=null!=K?K:x)&&void 0!==f?f:"Select an option",R=null!==(g=k.buttonWidth)&&void 0!==g?g:k.width;i((()=>{R||F.current&&J(`${F.current.offsetWidth}px`)}),[R]);const X=null!=R?R:"100%",Y=null!=R?R:G;return o(n,{children:o(c.Provider,Object.assign({value:{InputWrapper:Object.assign(Object.assign(Object.assign({height:S||("x-small"===V?24:"small"===V?32:48),width:X},R?{maxWidth:R}:{}),{zIndex:1,cursor:"pointer",padding:"x-small"===V?"4px 8px":"6px 8px",backgroundColor:void 0!==z?"#C3E4C4":N?"#E0E0E0":"#ffffff",transition:"background-color 0.3s ease"}),C),input:{minHeight:"100%",maxWidth:"100%",color:void 0!==z?"#00580E":"inherit"}}},{children:o("div",Object.assign({ref:F,onMouseEnter:()=>U(!0),onMouseLeave:()=>U(!1)},{children:t(u,Object.assign({"data-test":k["data-test"],ref:$,onSelect:function(e){Array.isArray(e)?B([...e]):B([e]),null==O||O(e)},disabled:y,onDropdownVisbilityChange:e=>_(e)},k,{width:Y},{children:["default"==T&&o(d,{version:k.version,noErrorHint:H,state:y?"disabled":"none",value:void 0===z?Q:z,errorMessage:k.error,variant:V,placeholder:null!=x?x:"Select an option",onChangeText:v,leftIcon:M&&(null===(b=q[0])||void 0===b?void 0:b.leadingIcon)?{icon:()=>{var e;return o(n,{children:null===(e=q[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>{var e;return t("div",Object.assign({style:{display:"flex"}},{children:[W&&(null===(e=q[0])||void 0===e?void 0:e.trailingIcon),o(a,{style:{transform:A?"rotate(180deg)":"rotate(0deg)"},onClick:v,width:"x-small"===V?16:"small"===V?20:24,height:"x-small"===V?16:"small"===V?20:24,color:s.content.primary})]}))}},truncateText:null==P||P}),"chip"==T&&o(p,{placeholder:null!=x?x:"Select options",chips:q,onDeleteChip:e=>{null==D||D(e)},errorMessage:k.error,isDropdownOpened:A,sizeToUse:V,containerStyle:{width:null!==(w=k.width)&&void 0!==w?w:"100%",cursor:"pointer"},showLabelsOnMoreHover:L})]}))}))}))})};m.displayName="Dropdown";export{m as Dropdown};
|