Files
AdminGit 935b9cf92b V5.0.0 //
-> Refonte du système de GESTION DES ROULEMENTS de matériels roulants
-> Cartographie Infra + Widget
2026-10-04 23:47:21 +02:00

2 lines
4.8 KiB
JavaScript

import{h as t,r as e,c as s,H as i,g as r}from"./p-32e583ea.js";const a=({step:e,checkOnComplete:s,complete:i,passed:r,active:a,first:n,disable:l,onClick:c})=>{var d;return t("li",{role:"listitem",class:"graphic-step","data-first":n},n?null:t("wcs-progress-bar",{value:r?100:0,"aria-hidden":"true"}),t("wcs-button",{style:{backgroundColor:"white"},"aria-label":(d=e.ariaLabel)!==null&&d!==void 0?d:e.text,onClick:t=>c(e),ref:t=>{a?t.setAriaAttribute("aria-current","step"):t.setAriaAttribute("aria-current",null)},shape:"round",mode:(a||i)&&!e.disable?"plain":"stroked",disabled:l},o(e.button,s,i,a)))};const o=(e,s,i,r)=>{if(s&&i&&!r){return t("wcs-mat-icon",{size:"m",icon:"done",family:"outlined"})}switch(e.kind){case"Icon":return t("wcs-mat-icon",{size:"m",icon:e.iconName,family:e.family?e.family:"outlined"});case"Text":return e.text}};const n=":host{--wcs-horizontal-step-text-color-default:var(--wcs-semantic-color-text-secondary);--wcs-horizontal-step-text-color-active:var(--wcs-semantic-color-foreground-brand);--wcs-horizontal-step-text-color-disabled:var(--wcs-semantic-color-text-disabled);display:block}:host .steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:row;flex:1}:host .graphic-step{display:flex;position:relative;flex-direction:row;flex:1;align-items:center}:host .graphic-step wcs-button{z-index:1;mix-blend-mode:darken}:host .graphic-step[data-first]{flex:0}:host wcs-progress-bar{--wcs-progress-bar-border-radius:0;flex:1;margin:0 -1px}:host .label-container{justify-content:space-between;display:flex;flex-direction:row;margin-top:var(--wcs-semantic-spacing-base)}:host .label-container>*{width:100%;text-align:center;flex:1;color:var(--wcs-horizontal-step-text-color-default);font-weight:500}:host .label-container>*[data-disable]{color:var(--wcs-horizontal-step-text-color-disabled)}:host .label-container>*[data-current]{color:var(--wcs-horizontal-step-text-color-active)}:host .label-container>div[data-first]{margin-right:calc(var(--wcs-semantic-size-m, 40px) / 2);text-align:left;flex:0.5}:host .label-container>div[data-last]{margin-left:calc(var(--wcs-semantic-size-m, 40px) / 2);text-align:right;flex:0.5}";const l=n;const c=class{constructor(t){e(this,t);this.wcsHorizontalStepClick=s(this,"wcsHorizontalStepClick",7);this.currentStep=0;this.steps=undefined;this.mode="nonLinear";this.checkOnComplete=undefined;this.internalCurrentStepIndex=undefined}componentWillLoad(){this.internalCurrentStepIndex=this.currentStep;if(this.steps.length<1){throw new Error("You must add at least one step")}}onCurrentStepChange(t,e){if(this.internalCurrentStepIndex!==undefined){const s=Math.abs(e-t);this.el.style.setProperty("--wcs-progress-bar-animation-duration",350/s+"ms");if(t!==e){for(let i=0;i<s;i++){setTimeout((()=>{this.internalCurrentStepIndex-=e-t>0?1:-1;if(i===s-1){this.el.style.removeProperty("--wcs-progress-bar-animation-duration")}}),i*(375/s))}}}}async previous(){this.navigateToIndex(this.internalCurrentStepIndex-1,"backward")}async next(){this.navigateToIndex(this.internalCurrentStepIndex+1,"forward")}navigateToIndex(t,e){var s,i;if(t>=0&&t<=this.steps.length-1){if(((s=this.steps[t])===null||s===void 0?void 0:s.complete)||((i=this.steps[t])===null||i===void 0?void 0:i.disable)){this.navigateToIndex(t+(e==="forward"?1:-1),e)}else{this.currentStep=t}}}render(){return t(i,{key:"72063828a00d77fc1bc2a92de8979d096b806786"},t("ul",{key:"a5b2de6193a68b6b70b0857d1c50ed1c5c069863",role:"list",class:"steps"},this.steps.map(((e,s)=>t(a,{step:e,passed:s<=this.internalCurrentStepIndex,checkOnComplete:this.checkOnComplete,complete:this.isComplete(e,s),active:s===this.internalCurrentStepIndex,first:s===0,disable:this.isDisable(e,s),onClick:t=>this.wcsHorizontalStepClick.emit({step:t,index:s})})))),this.renderLabels())}isComplete(t,e){return e<=this.internalCurrentStepIndex||t.complete}renderLabels(){if(this.steps.map((t=>t.text)).every((t=>!t))){return null}else{return t("div",{class:"label-container","aria-hidden":"true"},this.steps.map(((e,s)=>t("div",{"data-first":s===0,"data-current":s===this.internalCurrentStepIndex&&!e.disable,"data-disable":this.isDisable(e,s),"data-last":s===this.steps.length-1},t("span",null,e.text)))))}}isDisable(t,e){return t.disable||this.mode==="linear"&&(!this.isNextPossibleStep(e)&&this.internalCurrentStepIndex<e)}isNextPossibleStep(t){var e;if(t===0)return true;if(((e=this.steps[t-1])===null||e===void 0?void 0:e.disable)||this.previousStepIsCompleteAndNotActive(t))return this.isNextPossibleStep(t-1);return this.internalCurrentStepIndex===t-1}previousStepIsCompleteAndNotActive(t){var e;return((e=this.steps[t-1])===null||e===void 0?void 0:e.complete)&&t-1!==this.internalCurrentStepIndex}get el(){return r(this)}static get watchers(){return{currentStep:["onCurrentStepChange"]}}};c.style=l;export{c as wcs_horizontal_stepper};
//# sourceMappingURL=p-fbd68522.entry.js.map