@legumeinfo/web-components
Version:
Web Components for the Legume Information System and other AgBio databases
69 lines • 2.67 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { LitElement, html, css } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
/**
* @htmlElement `<lis-form-input-example-element>`
*
* A Web Component that provides a consistent example text element for form inputs.
*
* @example
* The element's {@link text | `text`} attribute/property can be set via HTML or
* JavaScript.
*
* For example:
* ```html
* <!-- set the text via HTML -->
* <lis-from-input-example-element text="This is the example text"></lis-from-input-example-element>
*
* <!-- set the text via JavaScript -->
* <lis-from-input-example-element id="example"></lis-from-input-example-element>
*
* <script type="text/javascript">
* // get the example element.
* const exampleElement = document.getElementById('example');
* // set the element's example property
* exampleElement.text = 'This is also example text';
* </script>
* ```
*/
let LisFormInputExampleElement = class LisFormInputExampleElement extends LitElement {
/** @ignore */
// disable Shadow DOM to inherit global styles
createRenderRoot() {
return this;
}
/** @ignore */
// returns the modal heading portion of the component
_getexampleElement() {
if (!this.text) {
return html ``;
}
return html `<span class="uk-text-small"
>e.g. ${unsafeHTML(this.text)}</span
>`;
}
/** @ignore */
// used by Lit to draw the template
render() {
const exampleElement = this._getexampleElement();
return html `${exampleElement}`;
}
};
/** @ignore */
// used by Lit to style the Shadow DOM
// not necessary but exclusion breaks TypeDoc
LisFormInputExampleElement.styles = css ``;
__decorate([
property({ type: String })
], LisFormInputExampleElement.prototype, "text", void 0);
LisFormInputExampleElement = __decorate([
customElement('lis-form-input-example-element')
], LisFormInputExampleElement);
export { LisFormInputExampleElement };
//# sourceMappingURL=lis-form-input-example-element.js.map