sbwb-ds 3.1.7 → 3.1.8
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.
package/dist/sbwb-ds.js
CHANGED
|
@@ -29610,7 +29610,9 @@ const Lge = xn(
|
|
|
29610
29610
|
values: r = [],
|
|
29611
29611
|
onChange: n,
|
|
29612
29612
|
onSearchChange: a,
|
|
29613
|
+
// Nova prop para capturar mudanças no texto de busca
|
|
29613
29614
|
searchValue: i,
|
|
29615
|
+
// Nova prop para controlar o valor de busca externamente
|
|
29614
29616
|
disabled: o = !1,
|
|
29615
29617
|
enableSearch: l = !0,
|
|
29616
29618
|
width: s = "100%",
|
|
@@ -29644,9 +29646,9 @@ const Lge = xn(
|
|
|
29644
29646
|
[u, r, A]
|
|
29645
29647
|
), se = Sr(
|
|
29646
29648
|
(we) => {
|
|
29647
|
-
n(we)
|
|
29649
|
+
n(we);
|
|
29648
29650
|
},
|
|
29649
|
-
[n
|
|
29651
|
+
[n]
|
|
29650
29652
|
), ne = Sr(
|
|
29651
29653
|
(we) => {
|
|
29652
29654
|
const be = r.includes(we) ? r.filter((ye) => ye !== we) : [...r, we];
|
|
@@ -29689,12 +29691,12 @@ const Lge = xn(
|
|
|
29689
29691
|
return;
|
|
29690
29692
|
const we = (be) => {
|
|
29691
29693
|
const ye = be.target;
|
|
29692
|
-
V.current && !V.current.contains(ye) && (T(!1), i === void 0 && O(""));
|
|
29694
|
+
V.current && !V.current.contains(ye) && (T(!1), i === void 0 && !a && O(""));
|
|
29693
29695
|
};
|
|
29694
29696
|
return document.addEventListener("mousedown", we), () => {
|
|
29695
29697
|
document.removeEventListener("mousedown", we);
|
|
29696
29698
|
};
|
|
29697
|
-
}, [A, i]), Vt(() => {
|
|
29699
|
+
}, [A, i, a]), Vt(() => {
|
|
29698
29700
|
if (!L)
|
|
29699
29701
|
return;
|
|
29700
29702
|
const we = {
|
package/dist/sbwb-ds.umd.cjs
CHANGED
|
@@ -6041,7 +6041,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6041
6041
|
font-weight: ${y.fonts.fontWeight.fontWeightSemiBold};
|
|
6042
6042
|
line-height: ${({size:e})=>e==="Small"?y.fonts.lineHeight.lineHeightSm(y.fonts.fontSize.fontSizeBodySm):y.fonts.lineHeight.lineHeightMd(y.fonts.fontSize.fontSizeBodyMd)};
|
|
6043
6043
|
color: ${y.colors.brandColors.colorBrandPrimary};
|
|
6044
|
-
`,IV=ee.forwardRef(({selectContainerRef:e,options:t,size:r,onSelectOption:n,values:a,searchText:i,setIsOpen:o,withCheckbox:l=!0,height:s},c)=>{const u=ee.useRef(null),[d,f]=ee.useState(0),h=ee.useCallback(()=>{const g=e.current,m=u.current;if(!g||!m)return;const C=g.getBoundingClientRect(),w=m.getBoundingClientRect(),S=window.innerHeight,b=C.top,x=S-C.bottom,_=x<w.height&&b>x;let L;_?(L=C.top-w.height,m.style.maxHeight=`${b}px`):(L=C.bottom,m.style.maxHeight=`${x}px`);let V=C.left;const H=V+w.width-window.innerWidth;H>0&&(V=Math.max(0,V-H)),m.style.position="fixed",m.style.top=`${L}px`,m.style.left=`${V}px`,m.style.width=`${Math.max(C.width,w.width)}px`,m.style.overflowY="auto",f(C.width)},[e]);ee.useLayoutEffect(()=>{h()},[h,t,i]),ee.useEffect(()=>{const g=()=>{h()};return window.addEventListener("resize",g),document.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),document.removeEventListener("scroll",g,!0)}},[h]),ee.useEffect(()=>{const g=m=>{const C=m.target;u.current&&!u.current.contains(C)&&e.current&&!e.current.contains(C)&&o(!1)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[o,e]),ee.useEffect(()=>{const g=m=>{const C=m.target;u.current&&u.current.contains(C)||e.current&&e.current.contains(C)||o(!1)};return document.addEventListener("scroll",g,!0),()=>{document.removeEventListener("scroll",g,!0)}},[o,e]);const p=i.toLowerCase();return R(o3e,{ref:g=>{u.current=g,typeof c=="function"?c(g):c&&(c.current=g)},width:`${d}px`,height:s,"data-testid":"MenuMultiSelect",id:"MenuMultiSelect",onClick:g=>g.stopPropagation(),children:t.length===0?R(l3e,{size:r,children:"Sem opções"}):t.map(g=>{const C=g.label.toLowerCase().indexOf(p),w=a.includes(g.value);return R(c3e,{children:Ve(u3e,{onClick:S=>{S.preventDefault(),S.stopPropagation(),n(g.value)},isSelected:w,"data-testid":g.value,size:r,children:[l&&R(p0,{width:"24.333px",id:g.value,onChange:S=>{S.stopPropagation(),n(g.value)},checked:w,size:r}),R(s3e,{size:r,hasDescription:!1,children:R("p",{title:g.label,children:C>=0?Ve(or,{children:[g.label.substring(0,C),R(d3e,{children:g.label.substring(C,C+i.length)}),g.label.substring(C+i.length)]}):g.label})})]})},g.value)})})});IV.displayName="MenuMultiSelect";const PV=ee.forwardRef(({id:e,options:t=[],values:r=[],onChange:n,onSearchChange:a,searchValue:i,disabled:o=!1,enableSearch:l=!0,width:s="100%",size:c="Medium",placeholder:u,label:d,helpText:f,errorText:h,variant:p="default",tableDensity:g="normal",tooltipPosition:m,tooltipMaxWidth:C,tooltipIsVisible:w,tooltipProps:S,menuSelectHeight:b,enableTagsScroll:x=!0,tagsContainerMaxHeight:_="40px"},L)=>{const V=ee.useRef(null),H=ee.useRef(null),[A,T]=ee.useState(!1),[F,N]=ee.useState(""),z=i!==void 0?i:F,[Y,q]=ee.useState(!1),ne=ee.useMemo(()=>!!h,[h]),ie=ee.useMemo(()=>Object.fromEntries(t.map(Se=>[Se.value,Se])),[t]),pe=ee.useMemo(()=>{const Se=z.toLowerCase().trim();return Se?t.filter(be=>{var ze;const we=be.label.toLowerCase(),de=((ze=be.searchText)==null?void 0:ze.toLowerCase())||"";return we.includes(Se)||de.includes(Se)}):t},[z,t]),oe=ee.useMemo(()=>!!u&&r.length===0&&!A,[u,r,A]),ce=ee.useCallback(Se=>{n(Se)
|
|
6044
|
+
`,IV=ee.forwardRef(({selectContainerRef:e,options:t,size:r,onSelectOption:n,values:a,searchText:i,setIsOpen:o,withCheckbox:l=!0,height:s},c)=>{const u=ee.useRef(null),[d,f]=ee.useState(0),h=ee.useCallback(()=>{const g=e.current,m=u.current;if(!g||!m)return;const C=g.getBoundingClientRect(),w=m.getBoundingClientRect(),S=window.innerHeight,b=C.top,x=S-C.bottom,_=x<w.height&&b>x;let L;_?(L=C.top-w.height,m.style.maxHeight=`${b}px`):(L=C.bottom,m.style.maxHeight=`${x}px`);let V=C.left;const H=V+w.width-window.innerWidth;H>0&&(V=Math.max(0,V-H)),m.style.position="fixed",m.style.top=`${L}px`,m.style.left=`${V}px`,m.style.width=`${Math.max(C.width,w.width)}px`,m.style.overflowY="auto",f(C.width)},[e]);ee.useLayoutEffect(()=>{h()},[h,t,i]),ee.useEffect(()=>{const g=()=>{h()};return window.addEventListener("resize",g),document.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),document.removeEventListener("scroll",g,!0)}},[h]),ee.useEffect(()=>{const g=m=>{const C=m.target;u.current&&!u.current.contains(C)&&e.current&&!e.current.contains(C)&&o(!1)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[o,e]),ee.useEffect(()=>{const g=m=>{const C=m.target;u.current&&u.current.contains(C)||e.current&&e.current.contains(C)||o(!1)};return document.addEventListener("scroll",g,!0),()=>{document.removeEventListener("scroll",g,!0)}},[o,e]);const p=i.toLowerCase();return R(o3e,{ref:g=>{u.current=g,typeof c=="function"?c(g):c&&(c.current=g)},width:`${d}px`,height:s,"data-testid":"MenuMultiSelect",id:"MenuMultiSelect",onClick:g=>g.stopPropagation(),children:t.length===0?R(l3e,{size:r,children:"Sem opções"}):t.map(g=>{const C=g.label.toLowerCase().indexOf(p),w=a.includes(g.value);return R(c3e,{children:Ve(u3e,{onClick:S=>{S.preventDefault(),S.stopPropagation(),n(g.value)},isSelected:w,"data-testid":g.value,size:r,children:[l&&R(p0,{width:"24.333px",id:g.value,onChange:S=>{S.stopPropagation(),n(g.value)},checked:w,size:r}),R(s3e,{size:r,hasDescription:!1,children:R("p",{title:g.label,children:C>=0?Ve(or,{children:[g.label.substring(0,C),R(d3e,{children:g.label.substring(C,C+i.length)}),g.label.substring(C+i.length)]}):g.label})})]})},g.value)})})});IV.displayName="MenuMultiSelect";const PV=ee.forwardRef(({id:e,options:t=[],values:r=[],onChange:n,onSearchChange:a,searchValue:i,disabled:o=!1,enableSearch:l=!0,width:s="100%",size:c="Medium",placeholder:u,label:d,helpText:f,errorText:h,variant:p="default",tableDensity:g="normal",tooltipPosition:m,tooltipMaxWidth:C,tooltipIsVisible:w,tooltipProps:S,menuSelectHeight:b,enableTagsScroll:x=!0,tagsContainerMaxHeight:_="40px"},L)=>{const V=ee.useRef(null),H=ee.useRef(null),[A,T]=ee.useState(!1),[F,N]=ee.useState(""),z=i!==void 0?i:F,[Y,q]=ee.useState(!1),ne=ee.useMemo(()=>!!h,[h]),ie=ee.useMemo(()=>Object.fromEntries(t.map(Se=>[Se.value,Se])),[t]),pe=ee.useMemo(()=>{const Se=z.toLowerCase().trim();return Se?t.filter(be=>{var ze;const we=be.label.toLowerCase(),de=((ze=be.searchText)==null?void 0:ze.toLowerCase())||"";return we.includes(Se)||de.includes(Se)}):t},[z,t]),oe=ee.useMemo(()=>!!u&&r.length===0&&!A,[u,r,A]),ce=ee.useCallback(Se=>{n(Se)},[n]),ae=ee.useCallback(Se=>{const be=r.includes(Se)?r.filter(we=>we!==Se):[...r,Se];ce(be)},[r,ce]),fe=ee.useCallback(()=>{q(!0),A||T(!0)},[A]),he=ee.useCallback(()=>{q(!1)},[]),xe=ee.useCallback(Se=>{Se==null||Se.stopPropagation(),!o&&(T(be=>!be),A||setTimeout(()=>{var be;(be=H.current)==null||be.focus()},0))},[o,A]),te=ee.useCallback(Se=>{var be;z===""&&Se.key==="Backspace"&&r.length>0&&ce(r.slice(0,-1)),Se.key==="Escape"&&(T(!1),(be=H.current)==null||be.blur())},[z,r,ce]),ke=ee.useCallback(Se=>{var be;Se.key==="Enter"&&(z!==""&&pe.length>0?ae(pe[0].value):z===""&&((be=H.current)==null||be.blur(),T(!1)))},[z,pe,ae]),ve=ee.useCallback(Se=>{const be=Se.target.value;i!==void 0&&a?a(be):(N(be),a&&a(be)),A||T(!0)},[A,a,i]);return ee.useEffect(()=>{if(!A)return;const Se=be=>{const we=be.target;V.current&&!V.current.contains(we)&&(T(!1),i===void 0&&!a&&N(""))};return document.addEventListener("mousedown",Se),()=>{document.removeEventListener("mousedown",Se)}},[A,i,a]),ee.useEffect(()=>{if(!L)return;const Se={focus:()=>{var be;return(be=H.current)==null?void 0:be.focus()},blur:()=>{var be;return(be=H.current)==null?void 0:be.blur()},open:()=>T(!0),close:()=>T(!1)};typeof L=="function"?L(Se):L.current=Se},[L]),Ve(K2e,{ref:V,width:s,disabled:o,id:e,tabIndex:0,onFocus:()=>!o&&q(!0),onBlur:()=>q(!1),children:[d&&p==="default"&&R(n3e,{onClick:xe,children:d}),R(t1,{isActive:ne&&p==="default",errorTooltip:!0,label:h,position:m,maxWidth:C,isAlwaysVisible:w,wrapperWidth:"auto",...S,children:Ve(Q2e,{hasError:ne,tableDensity:g,tableSelect:p==="table",onClick:xe,size:c,isOpen:A,"data-testid":"select",disabled:o,error:h,children:[R(J2e,{children:Ve(e3e,{tableSelect:p==="table",size:c,onClick:xe,enableTagsScroll:x,tagsContainerMaxHeight:_,children:[oe&&R(t3e,{name:"placeholder-name",size:c,onClick:Se=>{var be;Se.stopPropagation(),o||(T(!0),(be=H.current)==null||be.focus())},role:"button",tabIndex:o?-1:0,onKeyDown:Se=>{var be;(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),o||(T(!0),(be=H.current)==null||be.focus()))},children:u}),h&&p==="table"&&R(Zc,{id:`${e}-select-table`,errorMessage:h,size:c,tooltipIsVisible:!1}),r.map(Se=>{const be=ie[Se];return be?R(xp,{label:be.tagText??be.label,size:p==="table"?"Small":c,closeButton:!0,onClose:we=>{we.stopPropagation(),ce(r.filter(de=>de!==Se))},tableTag:p==="table",tooltipProps:{isActive:!1}},be.value):null}),l&&R(r3e,{ref:H,error:h,tableSelect:p==="table",value:z,name:"inputMultiSelect",id:"inputMultiSelect",onChange:ve,onFocus:fe,onBlur:he,onKeyDown:te,onKeyUp:ke,size:p==="table"?"Small":c,disabled:o,"aria-expanded":A,"aria-haspopup":"listbox",role:"combobox",className:"multiselect-search-field"})]})}),R(i3e,{onClick:Se=>{Se.stopPropagation(),o||T(be=>!be)},children:R(mr,{iconName:A?"ExpandLessSm":"ExpandMoreSm",color:p==="table"&&h?y.colors.feedbackColors.colorFeedbackError:y.colors.neutralColors.colorNeutralCloudy})}),A&&R(IV,{selectContainerRef:V,values:r,options:pe,onSelectOption:ae,size:p==="table"?"Small":c,searchText:z,setIsOpen:T,height:b})]})}),!h&&f&&p==="default"&&R(a3e,{children:f})]})});PV.displayName="MultiSelect";var dl={};/**
|
|
6045
6045
|
* @license React
|
|
6046
6046
|
* react-dom-server-legacy.browser.production.min.js
|
|
6047
6047
|
*
|
package/package.json
CHANGED
|
@@ -29,8 +29,8 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
|
|
|
29
29
|
options = [],
|
|
30
30
|
values = [],
|
|
31
31
|
onChange,
|
|
32
|
-
onSearchChange,
|
|
33
|
-
searchValue,
|
|
32
|
+
onSearchChange, // Nova prop para capturar mudanças no texto de busca
|
|
33
|
+
searchValue, // Nova prop para controlar o valor de busca externamente
|
|
34
34
|
disabled = false,
|
|
35
35
|
enableSearch = true,
|
|
36
36
|
width = '100%',
|
|
@@ -55,7 +55,6 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
|
|
|
55
55
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
56
56
|
|
|
57
57
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
|
58
|
-
|
|
59
58
|
const [internalSearchText, setInternalSearchText] = useState<string>('');
|
|
60
59
|
const searchText =
|
|
61
60
|
searchValue !== undefined ? searchValue : internalSearchText;
|
|
@@ -87,11 +86,8 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
|
|
|
87
86
|
const handleChange = useCallback(
|
|
88
87
|
(newValues: string[]) => {
|
|
89
88
|
onChange(newValues);
|
|
90
|
-
if (searchValue === undefined) {
|
|
91
|
-
setInternalSearchText('');
|
|
92
|
-
}
|
|
93
89
|
},
|
|
94
|
-
[onChange
|
|
90
|
+
[onChange]
|
|
95
91
|
);
|
|
96
92
|
|
|
97
93
|
const toggleOption = useCallback(
|
|
@@ -146,6 +142,7 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
|
|
|
146
142
|
if (e.key === 'Enter') {
|
|
147
143
|
if (searchText !== '' && filteredOptions.length > 0) {
|
|
148
144
|
toggleOption(filteredOptions[0].value);
|
|
145
|
+
// Não limpar o texto de busca após pressionar Enter
|
|
149
146
|
} else if (searchText === '') {
|
|
150
147
|
inputRef.current?.blur();
|
|
151
148
|
setIsOpen(false);
|
|
@@ -182,7 +179,7 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
|
|
|
182
179
|
!selectContainerRef.current.contains(target)
|
|
183
180
|
) {
|
|
184
181
|
setIsOpen(false);
|
|
185
|
-
if (searchValue === undefined) {
|
|
182
|
+
if (searchValue === undefined && !onSearchChange) {
|
|
186
183
|
setInternalSearchText('');
|
|
187
184
|
}
|
|
188
185
|
}
|
|
@@ -191,7 +188,7 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
|
|
|
191
188
|
return () => {
|
|
192
189
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
193
190
|
};
|
|
194
|
-
}, [isOpen, searchValue]);
|
|
191
|
+
}, [isOpen, searchValue, onSearchChange]);
|
|
195
192
|
|
|
196
193
|
useEffect(() => {
|
|
197
194
|
if (!ref) return;
|