@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
58 lines (54 loc) • 3.83 kB
JavaScript
import { p as proxyCustomElement, H, h, c as Host } from './p-X1tirp06.js';
import { i as inheritAriaAttributes } from './p-VPqXjOQn.js';
const modusWcInputLabelCss = "modus-wc-input-label.modus-wc-input-label-host{align-items:center;display:flex}modus-wc-input-label .modus-wc-input-label{font-weight:var(--modus-wc-font-weight-bold)}modus-wc-input-label .modus-wc-input-label.modus-wc-input-label-size-sm{font-size:var(--modus-wc-font-size-xs)}modus-wc-input-label .modus-wc-input-label.modus-wc-input-label-size-sm .modus-wc-input-label-sublabel{font-size:var(--modus-wc-font-size-2xs)}modus-wc-input-label .modus-wc-input-label.modus-wc-input-label-size-md{font-size:var(--modus-wc-font-size-sm)}modus-wc-input-label .modus-wc-input-label.modus-wc-input-label-size-md .modus-wc-input-label-sublabel{font-size:var(--modus-wc-font-size-xs)}modus-wc-input-label .modus-wc-input-label.modus-wc-input-label-size-lg{font-size:var(--modus-wc-font-size-md)}modus-wc-input-label .modus-wc-input-label.modus-wc-input-label-size-lg .modus-wc-input-label-sublabel{font-size:var(--modus-wc-font-size-sm)}modus-wc-input-label .modus-wc-input-label .required-indicator{color:var(--modus-wc-color-error)}[data-theme=modus-classic-light] modus-wc-input-label .modus-wc-input-label{color:var(--modus-wc-color-gray-8)}[data-theme=modus-classic-dark] modus-wc-input-label .modus-wc-input-label{color:var(--modus-wc-color-gray-2)}";
const ModusWcInputLabel = /*@__PURE__*/ proxyCustomElement(class ModusWcInputLabel extends H {
constructor() {
super();
this.__registerHost();
this.inheritedAttributes = {};
/** Additional classes for custom styling. */
this.customClass = '';
/** Whether the label indicates a required field. */
this.required = false;
/** The size of the label. */
this.size = 'md';
this.getClasses = () => {
const classList = ['modus-wc-input-label'];
// The order CSS classes are added matters to CSS specificity
if (this.size)
classList.push(`modus-wc-input-label-size-${this.size}`);
if (this.customClass)
classList.push(this.customClass);
return classList.join(' ');
};
}
componentWillLoad() {
this.inheritedAttributes = inheritAriaAttributes(this.el);
}
render() {
return (h(Host, { key: '656cb5bbca9a3438f159e667e909e972fb3897c0', class: "modus-wc-input-label-host" }, h("label", Object.assign({ key: '98657e371d885ca06260dce54821a3dd6b5892dc', class: this.getClasses(), htmlFor: this.forId }, this.inheritedAttributes), this.labelText, this.required && (h("span", { key: '964b3bcce25ac6e5d6bd891ad250920b047b6342', "aria-hidden": "true", class: "required-indicator" }, '\u00A0*')), this.subLabelText && (h("div", { key: 'ebe343cc6d109e299714e7d0bc9518d36823a9a9', class: "modus-wc-input-label-sublabel" }, this.subLabelText)), h("slot", { key: '32979693b95bf9ea6ac09c54502cdc67a6643ceb' }))));
}
get el() { return this; }
static get style() { return modusWcInputLabelCss; }
}, [4, "modus-wc-input-label", {
"forId": [1, "for-id"],
"customClass": [1, "custom-class"],
"labelText": [1, "label-text"],
"required": [4],
"size": [1],
"subLabelText": [1, "sub-label-text"]
}]);
function defineCustomElement() {
if (typeof customElements === "undefined") {
return;
}
const components = ["modus-wc-input-label"];
components.forEach(tagName => { switch (tagName) {
case "modus-wc-input-label":
if (!customElements.get(tagName)) {
customElements.define(tagName, ModusWcInputLabel);
}
break;
} });
}
export { ModusWcInputLabel as M, defineCustomElement as d };