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