@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 (57 loc) • 2.28 kB
JavaScript
import { html } from "lit";
import { ifDefined } from "lit/directives/if-defined.js";
import { createShadowHostClass } from "../../providers/shadow-dom/shadow-host-helper";
const meta = {
title: 'Components/Forms/Input Label',
component: 'modus-wc-input-label',
args: {
'label-text': 'Label',
required: false,
size: 'md',
},
argTypes: {
size: {
control: { type: 'select' },
options: ['sm', 'md', 'lg'],
},
},
};
export default meta;
const Template = {
render: (args) => html `
<modus-wc-input-label
for-id=${ifDefined(args['for-id'])}
custom-class=${ifDefined(args['custom-class'])}
label-text=${ifDefined(args['label-text'])}
?required=${args['required']}
size=${args.size}
sub-label-text=${ifDefined(args['sub-label-text'])}
></modus-wc-input-label>
`,
};
export const Default = Object.assign({}, Template);
export const Required = Object.assign(Object.assign({}, Template), { args: { required: true } });
export const ShadowDomParent = {
render: (args) => {
// Create a unique shadow host for input-label component
if (!customElements.get('input-label-shadow-host')) {
const InputLabelShadowHost = createShadowHostClass({
componentTag: 'modus-wc-input-label',
propsMapper: (v, el) => {
var _a, _b, _c, _d;
const inputLabelEl = el;
inputLabelEl.forId = (_a = v['for-id']) !== null && _a !== void 0 ? _a : '';
inputLabelEl.customClass = v['custom-class'] || '';
inputLabelEl.labelText = (_b = v['label-text']) !== null && _b !== void 0 ? _b : '';
inputLabelEl.required = Boolean(v.required);
inputLabelEl.size = (_c = v.size) !== null && _c !== void 0 ? _c : 'md';
inputLabelEl.subLabelText = (_d = v['sub-label-text']) !== null && _d !== void 0 ? _d : '';
},
});
customElements.define('input-label-shadow-host', InputLabelShadowHost);
}
return html `<input-label-shadow-host
.props=${Object.assign({}, args)}
></input-label-shadow-host>`;
},
};