@bikdotai/bik-component-library 0.0.646-beta.4 → 0.0.646-beta.6
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"),l=require("../../assets/icons/chevronDown.svg.js"),i=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,g,
|
|
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"),l=require("../../assets/icons/chevronDown.svg.js"),i=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,{placeHolder:j,size:f,onSelect:w,defaultOptions:S,disabled:b,noErrorHint:I,placeHolderHeight:O,showPlaceholderWhenSelected:m=!1,inputStyle:y={},inputType:D="default",onDeleteChip:q,truncatedText:H,showLeadingIconInPlaceholder:C=!1}=c,P=e.__rest(c,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder"]);const[T,E]=n.useState(!1),_=null!=f?f:"default",z=n.useRef(),[W,A]=n.useState(null!=S?S:[]);n.useEffect((()=>{var e;const t=[];null===(e=null==P?void 0:P.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])}),[P.options]),n.useEffect((()=>{S&&A([...S])}),[S]);const L=d.getSelectedOptionsAsText(W);return t.jsx(r.InputStyleContext.Provider,Object.assign({value:{InputWrapper:Object.assign({height:O||("x-small"===_?24:"small"===_?32:48),width:null!==(h=null!==(p=P.buttonWidth)&&void 0!==p?p:P.width)&&void 0!==h?h:"100%",zIndex:1,cursor:"pointer",padding:"x-small"===_?"4px 8px":"6px 8px"},y),input:{minHeight:"100%"}}},{children:t.jsxs(a.DropdownPopover,Object.assign({"data-test":P["data-test"],ref:z,onSelect:function(e){Array.isArray(e)?A([...e]):A([e]),null==w||w(e)},disabled:b,onDropdownVisbilityChange:e=>E(e)},P,{children:["default"==D&&t.jsx(i.Input,{version:P.version,noErrorHint:I,state:b?"disabled":"none",value:m?j:null!=L?L:"",errorMessage:P.error,variant:_,placeholder:null!=j?j:"Select an option",width:null!==(v=P.width)&&void 0!==v?v:"100%",onChangeText:u,leftIcon:C&&(null===(x=W[0])||void 0===x?void 0:x.leadingIcon)?{icon:()=>{var e;return t.jsx(t.Fragment,{children:null===(e=W[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>t.jsx(l.default,{style:{transform:T?"rotate(180deg)":"rotate(0deg)"},onClick:u,width:"x-small"===_?16:"small"===_?20:24,height:"x-small"===_?16:"small"===_?20:24,color:o.COLORS.content.primary})},truncateText:null==H||H}),"chip"==D&&t.jsx(s.default,{placeholder:null!=j?j:"Select options",chips:W,onDeleteChip:e=>{null==q||q(e)},isDropdownOpened:T,sizeToUse:_,containerStyle:{width:null!==(g=P.width)&&void 0!==g?g:"100%",cursor:"pointer"}})]}))}))};c.displayName="Dropdown",exports.Dropdown=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{__rest as e}from"../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as l,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 p}from"../input/context/InputStyleProvider.js";import c 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 f,g,w,x,b,{placeHolder:j,size:I,onSelect:y,defaultOptions:O,disabled:S,noErrorHint:H,placeHolderHeight:D,showPlaceholderWhenSelected:T=!1,inputStyle:C={},inputType:P="default",onDeleteChip:E,truncatedText:z,showLeadingIconInPlaceholder:W=!1}=v,A=e(v,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder"]);const[L,_]=l(!1),k=null!=I?I:"default",M=i(),[N,U]=l(null!=O?O:[]);r((()=>{var e;const o=[];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)})),U([...o])}),[A.options]),r((()=>{O&&U([...O])}),[O]);const V=h(N);return o(p.Provider,Object.assign({value:{InputWrapper:Object.assign({height:D||("x-small"===k?24:"small"===k?32:48),width:null!==(g=null!==(f=A.buttonWidth)&&void 0!==f?f:A.width)&&void 0!==g?g:"100%",zIndex:1,cursor:"pointer",padding:"x-small"===k?"4px 8px":"6px 8px"},C),input:{minHeight:"100%"}}},{children:t(u,Object.assign({"data-test":A["data-test"],ref:M,onSelect:function(e){Array.isArray(e)?U([...e]):U([e]),null==y||y(e)},disabled:S,onDropdownVisbilityChange:e=>_(e)},A,{children:["default"==P&&o(d,{version:A.version,noErrorHint:H,state:S?"disabled":"none",value:T?j:null!=V?V:"",errorMessage:A.error,variant:k,placeholder:null!=j?j:"Select an option",width:null!==(w=A.width)&&void 0!==w?w:"100%",onChangeText:m,leftIcon:W&&(null===(x=N[0])||void 0===x?void 0:x.leadingIcon)?{icon:()=>{var e;return o(n,{children:null===(e=N[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>o(a,{style:{transform:L?"rotate(180deg)":"rotate(0deg)"},onClick:m,width:"x-small"===k?16:"small"===k?20:24,height:"x-small"===k?16:"small"===k?20:24,color:s.content.primary})},truncateText:null==z||z}),"chip"==P&&o(c,{placeholder:null!=j?j:"Select options",chips:N,onDeleteChip:e=>{null==E||E(e)},isDropdownOpened:L,sizeToUse:k,containerStyle:{width:null!==(b=A.width)&&void 0!==b?b:"100%",cursor:"pointer"}})]}))}))};v.displayName="Dropdown";export{v as Dropdown};
|