@ebay/ui-core-react
Version:
Skin components build off React
2 lines (1 loc) • 2.06 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("../tslib.es6-C4EgNkz1.js"),t=require("react"),b=require("classnames"),g=require("../icons/ebay-icon-stepper-confirmation-24/index.js"),_=require("../icons/ebay-icon-stepper-attention-24/index.js"),S=require("../icons/ebay-icon-stepper-upcoming-24/index.js"),f=e=>{var{direction:r="row",defaultState:s="active",children:a,className:p}=e,l=y.__rest(e,["direction","defaultState","children","className"]);const c=t.Children.toArray(a),o=v(c,s);return t.createElement("div",Object.assign({},l,{className:b(p,"progress-stepper",{"progress-stepper--vertical":r==="column"})}),t.createElement("div",{role:"list",className:"progress-stepper__items"},c.map((i,n)=>t.createElement(t.Fragment,{key:n},n>0&&t.createElement("hr",{className:"progress-stepper__separator",role:"presentation"}),t.cloneElement(i,Object.assign(Object.assign({state:N(n,o)},i.props),{current:o===n}))))))};function v(e,r){const s=e.findIndex(a=>a.props.current);if(s===-1)switch(r){case"complete":return e.length-1;case"upcoming":return 0}return s}function N(e,r){if(e<=r)return"complete";if(e>r)return"upcoming"}const h={complete:g.EbayIconStepperConfirmation24,attention:_.EbayIconStepperAttention24,upcoming:S.EbayIconStepperUpcoming24,active:g.EbayIconStepperConfirmation24},I=e=>{var{current:r,state:s="complete",children:a,className:p}=e,l=y.__rest(e,["current","state","children","className"]);const c=t.Children.toArray(a),o=c.find(m=>m.type===u),i=c.filter(m=>m.type!==u),n=b(p,"progress-stepper__item",{"progress-stepper__item--attention":s==="attention"}),d=h[s],E=r?"current":s;return t.createElement("div",Object.assign({},l,{className:n,role:"listitem","aria-current":r?"step":void 0}),t.createElement("div",{className:"progress-stepper__icon"},t.createElement(d,{"aria-label":E})),t.createElement("div",{className:"progress-stepper__text"},o,i))},u=({as:e="h4",children:r})=>t.createElement(e,{},r);exports.EbayProgressStep=I;exports.EbayProgressStepper=f;exports.EbayProgressTitle=u;