@trimble-oss/moduswebcomponents
Version:
Modus Web Components is a modern, accessible UI library built with Stencil JS that provides reusable web components following Trimble's Modus design system. This updated version focuses on improved flexibility, enhanced theming options, comprehensive cust
131 lines (130 loc) • 4.77 kB
JavaScript
import { h, Host } from "@stencil/core";
import { convertPropsToClasses } from "./modus-wc-stepper.tailwind";
import { inheritAriaAttributes } from "../utils";
/**
* Used to show a list of steps in a process.
*/
export class ModusWcStepper {
constructor() {
this.inheritedAttributes = {};
/** Custom CSS class to apply to the steps element. */
this.customClass = '';
/** The steps to display. */
this.steps = [];
}
componentWillLoad() {
this.inheritedAttributes = inheritAriaAttributes(this.el);
}
getClasses() {
const classList = ['modus-wc-steps'];
const propClasses = convertPropsToClasses({
orientation: this.orientation,
});
// The order CSS classes are added matters to CSS specificity
if (propClasses)
classList.push(propClasses);
if (this.customClass)
classList.push(this.customClass);
return classList.join(' ');
}
getClassesForStep(step) {
const classList = ['modus-wc-step'];
// The order CSS classes are added matters to CSS specificity
if (step.color)
classList.push(`modus-wc-step-${step.color}`);
if (step.customClass)
classList.push(step.customClass);
return classList.join(' ');
}
render() {
return (h(Host, { key: '90dc5cae7581d6f374b0032f900d867ca5f06ad8' }, h("div", Object.assign({ key: 'f2ac196ec804295540608d7e585018f803936f6f', class: this.getClasses() }, this.inheritedAttributes), this.steps.map((step, index) => {
return (h("li", { class: this.getClassesForStep(step), key: index, "data-content": step.content }, step.label));
}))));
}
static get is() { return "modus-wc-stepper"; }
static get originalStyleUrls() {
return {
"$": ["modus-wc-stepper.scss"]
};
}
static get styleUrls() {
return {
"$": ["modus-wc-stepper.css"]
};
}
static get properties() {
return {
"customClass": {
"type": "string",
"attribute": "custom-class",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string | undefined",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "Custom CSS class to apply to the steps element."
},
"getter": false,
"setter": false,
"reflect": false,
"defaultValue": "''"
},
"orientation": {
"type": "string",
"attribute": "orientation",
"mutable": false,
"complexType": {
"original": "Orientation",
"resolved": "\"horizontal\" | \"vertical\" | undefined",
"references": {
"Orientation": {
"location": "import",
"path": "../types",
"id": "src/components/types.ts::Orientation"
}
}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "The orientation of the steps."
},
"getter": false,
"setter": false,
"reflect": false
},
"steps": {
"type": "unknown",
"attribute": "steps",
"mutable": false,
"complexType": {
"original": "IStepperItem[]",
"resolved": "IStepperItem[]",
"references": {
"IStepperItem": {
"location": "local",
"path": "/home/runner/work/modus-wc-2.0/modus-wc-2.0/src/components/modus-wc-stepper/modus-wc-stepper.tsx",
"id": "src/components/modus-wc-stepper/modus-wc-stepper.tsx::IStepperItem"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "The steps to display."
},
"getter": false,
"setter": false,
"defaultValue": "[]"
}
};
}
static get elementRef() { return "el"; }
}