@ebay/ui-core-react 7.3.5 → 7.3.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,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),
|
|
2
|
-
EbayListboxButtonOption that defines the options of the listbox`);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),O=require("classnames"),$=require("../icon-TuxfQndO.js"),be=require("../common/component-utils/utils/index.js"),F=({value:m,children:y,selected:r,onClick:f,index:d,innerRef:g,className:k,...h})=>{const p=O("listbox-button__option",k,{"listbox-button__option--active":r});return o.createElement("div",{...h,className:p,role:"option","aria-selected":r,ref:g,onClick:v=>{f(v,m,d)}},o.createElement("span",{className:"listbox-button__value"},y),o.createElement($.EbayIcon,{name:"tick16"}))},me=({children:m,name:y,value:r,selected:f,borderless:d,fluid:g,className:k,maxHeight:h,prefixId:p,prefixLabel:v,floatingLabel:x,unselectedText:V="-",onChange:S=()=>{},onCollapse:j=()=>{},onExpand:W=()=>{},...z})=>{var K;const i=o.useRef(null),N=o.useRef(),B=o.useRef(new Map),E=o.useRef(),c=be.filterByType(m,F);if(!c.length)throw new Error(`EbayListboxButton: Please use a
|
|
2
|
+
EbayListboxButtonOption that defines the options of the listbox`);const G=()=>{const e=f!==void 0?f:c.findIndex(({props:s})=>r!==void 0&&s.value===r),t=e>-1||x?e:void 0;return{option:c[t],index:t}},{option:T,index:C}=G(),[a,b]=o.useState(T),[n,D]=o.useState(C),[_,I]=o.useState(),[J,Q]=o.useState(!1),[L,A]=o.useState();o.useEffect(()=>{b(T)},[r]);const l=o.Children.toArray(m),R=e=>l[e].props.value,X=o.useCallback(e=>l.findIndex(({props:t})=>t.value===e),[l]),Y=e=>B.current.get(e),u=()=>{I(!1),j()},Z=()=>{I(!0),W()},ee=()=>{_?u():Z()},H=(e,t)=>{b(l[t]),D(t),u(),E.current.focus(),S(e,{index:t,selected:[R(t)],wasClicked:L}),A(!1)},te=()=>{u(),b(l[C])},oe=e=>{const t=i.current.children[e];t.setAttribute("aria-selected","true"),t.classList.add("listbox-button__option--active")},ne=e=>{const t=i.current.children[e];t.setAttribute("aria-selected","false"),t.classList.remove("listbox-button__option--active")},se=e=>{const t=N.current,s=Y(e);if(t.scrollHeight>t.clientHeight){const pe=t.clientHeight+t.scrollTop,M=s.offsetTop+s.offsetHeight;M>pe?t.scrollTop=M-t.clientHeight:s.offsetTop<t.scrollTop&&(t.scrollTop=s.offsetTop)}},P=e=>{oe(n===void 0||e===-1?0:e),ne(n===void 0||n===-1?0:n),se(e),D(e),b(l[e])},U=e=>setTimeout(()=>{var t;return(t=i==null?void 0:i.current)==null?void 0:t.focus(e)},0),ae=()=>{ee(),U({preventScroll:!0})},ce=e=>{switch(e.key){case"Escape":u();break;case"Enter":U();break}},le=e=>{switch(e.key){case" ":case"PageUp":case"PageDown":case"Home":case"End":e.preventDefault();break;case"Down":case"ArrowDown":e.preventDefault(),n!==c.length-1&&P(n<c.length-1?n+1:0);break;case"Up":case"ArrowUp":e.preventDefault(),n!==0&&P(n>0?n-1:c.length-1);break;case"Enter":u(),setTimeout(()=>b(l[n])),setTimeout(()=>E.current.focus(),0),S(e,{index:n,selected:[R(n)],wasClicked:L});break;case"Esc":case"Escape":te();break}},w=c.map((e,t)=>o.cloneElement(e,{index:t,key:t,selected:a&&e.props.value===a.props.value,id:e.props.id||`listbox_btn_${e.props.value}_${t}`,onClick:s=>H(s,t),innerRef:s=>s?B.current.set(t,s):B.current.delete(t)})),re=O("listbox-button",k,{"listbox-button--fluid":g}),ie=O("btn",{"btn--form":!d,"btn--borderless":d,"btn--floating-label":x&&a}),q=p&&"expand-btn-text",ue=o.createElement(o.Fragment,null,x&&o.createElement("span",{className:"btn__floating-label"},x),v&&o.createElement("span",{className:"btn__label"},v),o.createElement("span",{className:"btn__text",id:q},(a==null?void 0:a.props.children)||V));return o.createElement("span",{className:re},o.createElement("button",{...z,onFocus:()=>Q(!0),type:"button",className:ie,"aria-expanded":!!_,"aria-haspopup":"listbox","aria-labelledby":p&&`${p} ${q}`,onClick:ae,onMouseDown:e=>e.preventDefault(),onKeyUp:ce,ref:E},o.createElement("span",{className:"btn__cell"},ue,o.createElement($.EbayIcon,{name:"chevronDown12"}))),(_||J)&&o.createElement("div",{className:"listbox-button__listbox",ref:N,style:{maxHeight:h}},o.createElement("div",{className:"listbox-button__options",role:"listbox",tabIndex:_?0:-1,ref:i,"aria-activedescendant":(K=w[n])==null?void 0:K.props.id,onKeyDown:e=>le(e),onMouseDown:e=>{e.preventDefault(),A(!0)},onBlur:()=>{u(),setTimeout(()=>E.current.focus(),0)}},w)),o.createElement("select",{hidden:!0,className:"listbox-button__native",name:y,onChange:e=>H(e,X(e.target.value)),value:a?a==null?void 0:a.props.value:""},w.map((e,t)=>o.createElement("option",{value:e.props.value,key:t}))))};exports.EbayListboxButton=me;exports.EbayListboxButtonOption=F;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox-button-option.d.ts","sourceRoot":"","sources":["../../src/ebay-listbox-button/listbox-button-option.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,cAAc,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIxE,KAAK,4BAA4B,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjF,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACxC,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,4BAA4B,
|
|
1
|
+
{"version":3,"file":"listbox-button-option.d.ts","sourceRoot":"","sources":["../../src/ebay-listbox-button/listbox-button-option.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,cAAc,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIxE,KAAK,4BAA4B,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjF,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACxC,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,4BAA4B,CAwBnD,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -5,7 +5,7 @@ export type ChangeEventProps = {
|
|
|
5
5
|
selected: string[];
|
|
6
6
|
wasClicked: boolean;
|
|
7
7
|
};
|
|
8
|
-
export type EbayListboxButtonProps = Omit<ComponentProps<'
|
|
8
|
+
export type EbayListboxButtonProps = Omit<ComponentProps<'button'>, 'onChange'> & {
|
|
9
9
|
selected?: number;
|
|
10
10
|
borderless?: boolean;
|
|
11
11
|
fluid?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox-button.d.ts","sourceRoot":"","sources":["../../src/ebay-listbox-button/listbox-button.tsx"],"names":[],"mappings":"AAAA,OAAc,EAEV,cAAc,EAAE,EAAE,EACrB,MAAM,OAAO,CAAA;AAGd,OAAO,EAAE,sBAAsB,EAAO,MAAM,6BAA6B,CAAA;AAIzE,MAAM,MAAM,gBAAgB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAA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