@duetds/components
Version:
This package includes Duet Components and related tools.
78 lines (73 loc) • 6.66 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const __chunk_1 = require('./chunk-7888512a.js');
const __chunk_3 = require('./chunk-af70acd5.js');
const __chunk_5 = require('./chunk-4d3bde67.js');
class DuetTextarea {
constructor(hostRef) {
__chunk_1.registerInstance(this, hostRef);
/**
* Theme of the textarea. Can be one of: default, turva.
*/
this.theme = "";
/**
* Expands the textarea to fill 100% of the container width.
*/
this.expand = false;
/**
* Makes the textarea component disabled. This prevents users from being able to interact with the textarea, and conveys its inactive state to assistive technologies.
*/
this.disabled = false;
/**
* Automatically focus the textarea.
*/
this.autofocus = false;
/**
* Set whether the textarea is required or not.
*/
this.required = false;
/**
* Label for the textarea.
*/
this.label = "label";
/**
* Visually hide the label, but still show it to screen readers.
*/
this.labelHidden = false;
/**
* Indicate whether value should have spelling checked.
*/
this.spellCheck = false;
}
/**
* Component lifecycle events.
*/
componentWillLoad() {
// Check whether global Turva theme is active
if (this.theme !== "default" && document.documentElement.classList.contains("duet-theme-turva")) {
this.theme = "turva";
}
}
/**
* render() function
* Always the last one in the class.
*/
render() {
// Set constants for input classes used.
if (this.expand) {
this.element.classList.add("duet-expand");
}
const containerClasses = __chunk_3.classNames("duet-textarea-container", {
"duet-theme-turva": this.theme === "turva",
"duet-label-hidden": this.labelHidden,
});
const inputClasses = __chunk_3.classNames("duet-textarea", {
disabled: this.disabled,
});
const identifier = this.identifier || __chunk_5.createUniqueID("DuetCheckbox");
return (__chunk_1.h("div", { class: containerClasses }, __chunk_1.h("label", { class: "duet-label", htmlFor: identifier }, this.label), __chunk_1.h("textarea", { class: inputClasses, value: this.value, autofocus: this.autofocus, disabled: this.disabled, "label-hidden": this.labelHidden, "aria-controls": this.accessibleControls, "aria-autocomplete": this.accessibleAutocomplete, "aria-active-descendant": this.accessibleActiveDescendant, "aria-owns": this.accessibleOwns, maxlength: this.maxLength, minlength: this.minLength, placeholder: this.placeholder, spellcheck: this.spellCheck, required: this.required, role: this.role, name: this.name, id: identifier }), __chunk_1.h("span", { class: "duet-textarea-help" }, this.helpText)));
}
get element() { return __chunk_1.getElement(this); }
static get style() { return ":host{background:transparent;margin:0;margin-right:8px;margin-bottom:12px;display:-ms-inline-flexbox;display:inline-flex;vertical-align:bottom;max-width:100%}.duet-label,:host{-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-box-sizing:border-box;box-sizing:border-box;border:0;padding:0}.duet-label{background:transparent;margin:0;margin-bottom:8px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:localtapiola-sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-size:1rem;background:#fff;color:#00294d;font-weight:600;line-height:1.25;-webkit-transition:.3s ease;transition:.3s ease;z-index:100;width:100%;cursor:pointer;position:relative;display:block}.duet-theme-turva .duet-label{color:#111;font-family:turva-sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}.duet-label-hidden .duet-label{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.duet-textarea{-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-box-sizing:border-box;box-sizing:border-box;background:transparent;border:0;padding:0;margin:0;padding:13.5px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:localtapiola-sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;border:2px solid #cfd2d4;border-radius:4px;font-size:1rem;background:#fff;color:#00294d;font-weight:400;line-height:1.25;-webkit-transition:.3s ease;transition:.3s ease;z-index:100;min-width:13.75rem;min-height:160px;resize:vertical;width:100%;position:relative;display:block}.duet-theme-turva .duet-textarea{font-family:turva-sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;border-color:#d1d1d1;color:#111}.duet-textarea-container{-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-box-sizing:border-box;box-sizing:border-box;background:transparent;border:0;padding:0;margin:0;position:relative;width:100%;height:100%}.duet-textarea::-webkit-input-placeholder{color:#cfd2d4}.duet-theme-turva .duet-textarea::-webkit-input-placeholder{color:#d1d1d1}.duet-textarea::-moz-placeholder{color:#cfd2d4;opacity:1!important}.duet-theme-turva .duet-textarea::-moz-placeholder{color:#d1d1d1}.duet-textarea:-ms-input-placeholder{color:#cfd2d4}.duet-theme-turva .duet-textarea:-ms-input-placeholder{color:#d1d1d1}.duet-textarea.disabled,.duet-textarea[disabled]{cursor:not-allowed!important;border-color:#f5f8fa!important;background:#f5f8fa!important;color:#657787!important}.duet-theme-turva .duet-textarea.disabled,.duet-theme-turva .duet-textarea[disabled]{border-color:#f9f9f9!important;background:#f9f9f9!important;color:#757575!important}.duet-textarea:hover{border-color:#657787}.duet-theme-turva .duet-textarea:hover{border-color:#757575}.duet-textarea:focus{border-color:#0077b3;outline:0}.duet-theme-turva .duet-textarea:focus{border-color:#111}.duet-textarea:not(:placeholder-shown):focus:required:invalid{border-color:#de2362}.duet-theme-turva .duet-textarea:not(:placeholder-shown):focus:required:invalid{border-color:#e02a0d}.duet-textarea:focus:required:valid{border-color:#0077b3}.duet-theme-turva .duet-textarea:focus:required:valid{border-color:#111}"; }
}
exports.duet_textarea = DuetTextarea;