@ebay/ui-core-react 8.13.0 → 8.13.1
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,Symbol.toStringTag,{value:"Module"});const t=require("../listbox-button-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../listbox-button-BRm8KnF8.js");exports.EbayListboxButton=t.ListboxButton;exports.EbayListboxButtonOption=t.ListboxOption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("../tslib.es6-C4EgNkz1.js"),z=require("classnames"),l=require("react"),N=require("../listbox-button-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("../tslib.es6-C4EgNkz1.js"),z=require("classnames"),l=require("react"),N=require("../listbox-button-BRm8KnF8.js"),w=require("../textbox-Bp4UkkZJ.js");require("../icon-CR8ApQBy.js");require("../icon-button-B1aE4GTn.js");const $=require("../flag-DU-1tRv6.js"),v={US:{countryCode:"US",callingCode:"1",mask:"(000) 000-0000"},CA:{countryCode:"CA",callingCode:"1",mask:"(000) 000-0000"},GB:{countryCode:"GB",callingCode:"44",mask:"0000 000 0000"},AU:{countryCode:"AU",callingCode:"61",mask:"0 0000 0000"},DE:{countryCode:"DE",callingCode:"49",mask:"000 00000000"},FR:{countryCode:"FR",callingCode:"33",mask:"0 00 00 00 00"},IT:{countryCode:"IT",callingCode:"39",mask:"000 000 0000"},ES:{countryCode:"ES",callingCode:"34",mask:"000 00 00 00"},IN:{countryCode:"IN",callingCode:"91",mask:"00000 00000"},JP:{countryCode:"JP",callingCode:"81",mask:"000-0000-0000"},CN:{countryCode:"CN",callingCode:"86",mask:"000 0000 0000"},BR:{countryCode:"BR",callingCode:"55",mask:"(00) 00000-0000"},MX:{countryCode:"MX",callingCode:"52",mask:"000 000 0000"}};function H(n,r){let t=r;const a=s=>{B(n,t,n.value,s.inputType)};return n.addEventListener("input",a),{update(s,c){t=c,B(n,t,s,"")},destroy(){n.removeEventListener("input",a)},get value(){return n.value}}}function B(n,r,t,a){const s=/delete.*Backwards/.test(a),c=n.selectionStart||0,u=Q(t,r);if(t!==u){n.value=u;const C=Y(u,t,c,s);C!==void 0&&n.setSelectionRange(C,C)}}function U(n){return n.replace(/\D+/g,"")}function Q(n,r){const t=U(n);let a="",s=0;if(t.length){for(const c of r)if(c==="0"){if(a+=t[s++],s===t.length)break}else a+=c;s<t.length&&(a+=" "+t.slice(s))}return a}function Y(n,r,t,a){const s=t===r.length;if(a||!s){const c=r.slice(0,t),u=r.slice(t);if(n.startsWith(c))return t;if(n.endsWith(u))return n.length-u.length;{const C=P(c);let p=0,m=0;for(;m<C.length;)P(n[p])&&m++,p++;return p}}}function P(n){return n.replace(/[.,\\/#!$%^&*;:{}=+\-_`~()\s]/g,"")}const Z=n=>n||(typeof navigator<"u"?navigator.language:"en-US"),V=n=>{var{countryCode:r,value:t,locale:a,floatingLabel:s,disabled:c,readonly:u,invalid:C,className:p,onFocus:m,onBlur:k,onChange:x,onInputChange:E,onKeyDown:I,onKeyPress:T,onKeyUp:D,onExpand:L,onCollapse:R}=n,q=X.__rest(n,["countryCode","value","locale","floatingLabel","disabled","readonly","invalid","className","onFocus","onBlur","onChange","onInputChange","onKeyDown","onKeyPress","onKeyUp","onExpand","onCollapse"]);const h=l.useMemo(()=>{const e=Z(a),o=new Intl.DisplayNames([e],{type:"region"});return Object.keys(v).map(i=>{var d;return[i,(d=o.of(i))!==null&&d!==void 0?d:""]}).sort(([,i],[,d])=>i.localeCompare(d))},[a]),[S,K]=l.useState(()=>{if(r){const e=h.findIndex(([o])=>o===r.toUpperCase());return e!==-1?e:0}return 0}),b=l.useRef(null),f=l.useRef(null);l.useEffect(()=>{if(r){const e=h.findIndex(([o])=>o===r.toUpperCase());K(e!==-1?e:0)}},[r,h]);const y=(e=S)=>{const[o]=h[e];return v[o]};l.useEffect(()=>{b.current&&y()&&(f.current||(f.current=H(b.current,y().mask)),f.current.update(b.current.value,y().mask))},[y().mask]),l.useEffect(()=>()=>{f.current&&f.current.destroy()},[]);const g=e=>{var o,i;return{value:((o=f.current)===null||o===void 0?void 0:o.value)||"",rawValue:U(((i=f.current)===null||i===void 0?void 0:i.value)||""),callingCode:y(e).callingCode,countryCode:y(e).countryCode}},F=(e,{index:o})=>{K(o),x&&x(e,g(o))},A=e=>{m&&m(e,g())},O=e=>{k&&k(e,g())},_=e=>{x&&x(e,g())},M=e=>{E&&E(e,g())},j=e=>{I&&I(e,g())},G=e=>{T&&T(e,g())},J=e=>{D&&D(e,g())},W=h.map(([e,o],i)=>{const d=v[e];return l.createElement(N.ListboxOption,{key:e,value:d.callingCode,selected:i===S,icon:l.createElement($.EbayFlagIcon,{flag:d.countryCode.toLowerCase()})},l.createElement("span",null,o," ( + ",d.callingCode," )"))});return l.createElement("span",Object.assign({},q,{className:z("phone-input",p,{"phone-input--disabled":c,"phone-input--readonly":u,"phone-input--error":C})}),l.createElement(N.ListboxButton,{split:"start",disabled:u||c,onChange:F,onExpand:L,onCollapse:R},W),l.createElement(w.EbayTextbox,{type:"tel",value:t,disabled:c,floatingLabel:s,floatingLabelStatic:!0,readOnly:u,invalid:C,onBlur:O,onFocus:A,onKeyDown:j,onKeyPress:G,onKeyUp:J,onChange:_,onInputChange:M,ref:b},l.createElement(w.EbayTextboxPrefixText,{id:"phone-prefix"},"+ ",y().callingCode)))};exports.EbayPhoneInput=V;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const M=require("./tslib.es6-C4EgNkz1.js"),n=require("react"),
|
|
2
|
-
EbayListboxButtonOption that defines the options of the listbox`);const X=()=>{const e=g!==void 0?g:a.findIndex(({props:l})=>d!==void 0&&l.value===d||l.selected),t=e>-1||h?e:void 0;return{option:a[t],index:t}},{option:D,index:I}=X(),[s,f]=n.useState(D),[o,R]=n.useState(I),[m,H]=n.useState(),[Y,Z]=n.useState(!1),[A,q]=n.useState(),{overlayStyles:ee,refs:y}=ge.useFloatingDropdown({open:m}),
|
|
1
|
+
"use strict";const M=require("./tslib.es6-C4EgNkz1.js"),n=require("react"),S=require("classnames"),V=require("./icon-CR8ApQBy.js"),xe=require("./utils-C9NL3q0j.js"),ge=require("./dropdown-B2vObM4k.js"),W=u=>{var{value:p,children:v,selected:x,onClick:d,index:g,icon:E,innerRef:O,className:k}=u,C=M.__rest(u,["value","children","selected","onClick","index","icon","innerRef","className"]);const b=S("listbox-button__option",k,{"listbox-button__option--active":x});return n.createElement("div",Object.assign({},C,{className:b,role:"option","aria-selected":x,ref:O,onClick:_=>{d(_,p,g)}}),n.createElement("span",{className:"listbox-button__value"},E,v),n.createElement(V.EbayIcon,{name:"tick16"}))},Ee=u=>{var p,{children:v,name:x,value:d,selected:g,borderless:E,fluid:O,className:k,maxHeight:C,prefixId:b,prefixLabel:_,floatingLabel:h,split:w,unselectedText:z="-",onChange:T=()=>{},onCollapse:G=()=>{},onExpand:J=()=>{}}=u,Q=M.__rest(u,["children","name","value","selected","borderless","fluid","className","maxHeight","prefixId","prefixLabel","floatingLabel","split","unselectedText","onChange","onCollapse","onExpand"]);const i=n.useRef(null),N=n.useRef(new Map),a=xe.filterByType(v,W);if(!a.length)throw new Error(`EbayListboxButton: Please use a
|
|
2
|
+
EbayListboxButtonOption that defines the options of the listbox`);const X=()=>{const e=g!==void 0?g:a.findIndex(({props:l})=>d!==void 0&&l.value===d||l.selected),t=e>-1||h?e:void 0;return{option:a[t],index:t}},{option:D,index:I}=X(),[s,f]=n.useState(D),[o,R]=n.useState(I),[m,H]=n.useState(),[Y,Z]=n.useState(!1),[A,q]=n.useState(),{overlayStyles:ee,refs:y}=ge.useFloatingDropdown({open:m}),B=y.host,te=y.overlay;n.useEffect(()=>{f(D)},[d]);const c=n.Children.toArray(v),$=e=>c[e].props.value,ne=n.useCallback(e=>c.findIndex(({props:t})=>t.value===e),[c]),oe=e=>N.current.get(e),r=()=>{H(!1),G()},se=()=>{H(!0),J()},le=()=>{m?r():se()},j=(e,t)=>{f(c[t]),R(t),r(),B.current.focus(),T(e,{index:t,selected:[String($(t))],wasClicked:A}),q(!1)},ae=()=>{r(),f(c[I])},ce=e=>{const t=i.current.children[e];t.setAttribute("aria-selected","true"),t.classList.add("listbox-button__option--active")},ie=e=>{const t=i.current.children[e];t.setAttribute("aria-selected","false"),t.classList.remove("listbox-button__option--active")},re=e=>{const t=te.current,l=oe(e);if(t.scrollHeight>t.clientHeight){const ve=t.clientHeight+t.scrollTop,U=l.offsetTop+l.offsetHeight;U>ve?t.scrollTop=U-t.clientHeight:l.offsetTop<t.scrollTop&&(t.scrollTop=l.offsetTop)}},F=e=>{ce(o===void 0||e===-1?0:e),ie(o===void 0||o===-1?0:o),re(e),R(e),f(c[e])},K=e=>setTimeout(()=>{var t;return(t=i?.current)===null||t===void 0?void 0:t.focus(e)},0),ue=()=>{le(),K({preventScroll:!0})},pe=e=>{switch(e.key){case"Escape":r();break;case"Enter":K();break}},de=e=>{switch(e.key){case" ":case"PageUp":case"PageDown":case"Home":case"End":e.preventDefault();break;case"Down":case"ArrowDown":e.preventDefault(),o!==a.length-1&&F(o<a.length-1?o+1:0);break;case"Up":case"ArrowUp":e.preventDefault(),o!==0&&F(o>0?o-1:a.length-1);break;case"Enter":r(),setTimeout(()=>f(c[o])),setTimeout(()=>B.current.focus(),0),T(e,{index:o,selected:[String($(o))],wasClicked:A});break;case"Esc":case"Escape":ae();break}},L=a.map((e,t)=>n.cloneElement(e,{index:t,key:t,selected:s&&e.props.value===s.props.value,id:e.props.id||`listbox_btn_${e.props.value}_${t}`,onClick:l=>j(l,t),innerRef:l=>{l?N.current.set(t,l):N.current.delete(t)}})),be=S("listbox-button",k,{"listbox-button--fluid":O}),fe=S("btn",{"btn--form":!E,"btn--borderless":E,"btn--floating-label":h&&s,[`btn--split-${w}`]:w&&w!=="none"}),P=b&&"expand-btn-text",me=n.createElement(n.Fragment,null,h&&n.createElement("span",{className:"btn__floating-label"},h),_&&n.createElement("span",{className:"btn__label"},_),n.createElement("span",{className:"btn__text",id:P},s?.props.icon||s?.props.children||z));return n.createElement("span",{className:be},n.createElement("button",Object.assign({},Q,{onFocus:()=>Z(!0),type:"button",className:fe,"aria-expanded":!!m,"aria-haspopup":"listbox","aria-labelledby":b&&`${b} ${P}`,onClick:ue,onMouseDown:e=>e.preventDefault(),onKeyUp:pe,ref:y.setHost}),n.createElement("span",{className:"btn__cell"},me,n.createElement(V.EbayIcon,{name:"chevronDown16"}))),(m||Y)&&n.createElement("div",{className:"listbox-button__listbox",ref:y.setOverlay,style:Object.assign(Object.assign({},ee),{maxHeight:C})},n.createElement("div",{className:"listbox-button__options",role:"listbox",tabIndex:m?0:-1,ref:i,"aria-activedescendant":(p=L[o])===null||p===void 0?void 0:p.props.id,onKeyDown:e=>de(e),onMouseDown:e=>{e.preventDefault(),q(!0)},onBlur:()=>{r(),setTimeout(()=>B.current.focus(),0)}},L)),n.createElement("select",{hidden:!0,className:"listbox-button__native",name:x,onChange:e=>j(e,ne(e.target.value)),value:s?s?.props.value:""},L.map((e,t)=>n.createElement("option",{value:e.props.value,key:t}))))};exports.ListboxButton=Ee;exports.ListboxOption=W;
|