/** * Copyright Aquera Inc 2023 * * This source code is licensed under the BSD-3-Clause license found in the * LICENSE file in the root directory of this source tree. */ import {LitElement, nothing, html, CSSResultArray, TemplateResult} from 'lit'; import { customElement, state, property } from 'lit/decorators.js'; import {styles} from './nile-vertical-stepper-item.css'; import NileElement from '../internal/nile-element'; import { classMap } from 'lit/directives/class-map.js'; /** * Nile vertical-stepper-item component. * * @tag nile-vertical-stepper-item * */ @customElement('nile-vertical-stepper-item') export class NileVerticalStepperItem extends NileElement { /* Properties passed directly */ @property({attribute: true, reflect: true}) title: string = ''; @property({attribute: true, reflect: true}) subtitle: string = ''; @property({attribute: true, reflect: true}) completed: boolean = false; @property({attribute: true, reflect: true}) current: boolean = false; /* Properties passed to parent component: NileStepper */ @state() private contentBelow = false; @state() private size : 'sm' | 'lg' = 'lg'; @state() private icon = 'tick'; /* Properties Computed at parent level component NileStepper */ @state() private isFirst = false; @state() private isLast = false; @state() private isComplete = false; @state() private isCurrent = false; @state() private isManualMode = false; @state() private currentStepValue :Number; @state() private completedStepValue :Number; @state() private calculatedCompletedStepValue :Number; @state() private value :Number; @state() private haveFlex :Boolean=true; /** * The styles for nile-vertical-stepper-item * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]` */ public static get styles(): CSSResultArray { return [styles]; } /* #endregion */ /* #region Methods */ /** * Render method * @slot This is a slot test */ public render(): TemplateResult { if (this.isLast) this.style.setProperty('--vertical-stepper-flex-val', `0`); const isCurrent = this.isManualMode ? this.current : this.isCurrent; const isComplete = this.isManualMode ? this.completed : this.isComplete; let showCompletedIcon=false; if(isComplete && !isCurrent || this.completedStepValue==this.value) showCompletedIcon=true; let suffixStepperLineActive = false; if (isComplete) { suffixStepperLineActive = true; if (this.calculatedCompletedStepValue == this.value) suffixStepperLineActive = false; } let iconSize = this.size == 'sm'?14:this.size == 'lg'?16:20; return html`
${showCompletedIcon ? html`
${this.getSvg()}
` : html`
` }
${this.isLast?nothing : html`
`}
${this.title}
${this.subtitle}
`; } getSvg():TemplateResult{ let iconSize = this.size == 'sm' ? 20 : this.size == 'lg' ? 24 : 28; return html` ` } /* #endregion */ } export default NileVerticalStepperItem; declare global { interface HTMLElementTagNameMap { 'nile-vertical-stepper-item': NileVerticalStepperItem; } }