UNPKG

@postnord/web-components

Version:

PostNord Web Components

87 lines (81 loc) 8.26 kB
/*! * Built with Stencil * By PostNord. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-78a59ba0.js'); const helpers = require('./helpers-2e2349b4.js'); const pnTextareaCss = "pn-textarea{display:inline-flex;flex-direction:column}pn-textarea .pn-textarea-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;transition-property:color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1);-webkit-tap-highlight-color:transparent}pn-textarea .pn-textarea-label>span{font-size:0.875em}pn-textarea .pn-textarea-text{color:#5e554a;font-weight:400;display:block;margin:0.25em 0 0 0}pn-textarea .pn-textarea-text>span{display:block;font-size:0.875em}pn-textarea .pn-textarea-text>pn-icon{margin-right:0.25em}pn-textarea .pn-textarea-element{color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1);width:100%;resize:none}pn-textarea .pn-textarea-element:-webkit-autofill,pn-textarea .pn-textarea-element:-webkit-autofill:hover,pn-textarea .pn-textarea-element:-webkit-autofill:focus,pn-textarea .pn-textarea-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}pn-textarea .pn-textarea-element:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}pn-textarea .pn-textarea-element::placeholder{color:#5e554a;font-weight:normal}pn-textarea .pn-textarea-element:hover{border-color:#005d92}pn-textarea .pn-textarea-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}pn-textarea .pn-textarea-element::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}pn-textarea .pn-textarea-element::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}pn-textarea .pn-textarea-element::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}pn-textarea .pn-textarea-element::-webkit-scrollbar-thumb:hover{background-color:#5e554a}pn-textarea .pn-textarea-element::-webkit-scrollbar-corner,pn-textarea .pn-textarea-element::-webkit-scrollbar-button{display:none}pn-textarea .pn-textarea-element:read-only{border-color:#ffffff}pn-textarea .pn-textarea-element::-webkit-resizer{background-image:url(\"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%3E%0A%20%20%3Cpath%20d%3D%22M7%2017L17%207M12%2017L17%2012%22%20stroke%3D%22%23005D92%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%2F%3E%0A%3C%2Fsvg%3E\");background-repeat:no-repeat;background-position:center}pn-textarea .pn-textarea[data-valid]>.pn-textarea-label{color:#005e41}pn-textarea .pn-textarea[data-valid]>.pn-textarea-element{border-color:#005e41}pn-textarea .pn-textarea[data-valid]>.pn-textarea-element:hover{border-color:#002f24}pn-textarea .pn-textarea[data-valid]>.pn-textarea-element:focus-visible{background-color:#ffffff;border-color:#005e41;outline-color:#005e41}pn-textarea .pn-textarea[data-error]>.pn-textarea-label{color:#a70707}pn-textarea .pn-textarea[data-error]>.pn-textarea-element{border-color:#a70707}pn-textarea .pn-textarea[data-error]>.pn-textarea-element:hover{border-color:#500715}pn-textarea .pn-textarea[data-error]>.pn-textarea-element:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}pn-textarea .pn-textarea[data-error]>.pn-textarea-text[role=alert]{color:#a70707}pn-textarea .pn-textarea[data-resize]>.pn-textarea-element{resize:vertical}"; const PnTextareaStyle0 = pnTextareaCss; const PnTextarea = class { constructor(hostRef) { index.registerInstance(this, hostRef); } id = `pn-textarea-${helpers.uuidv4()}`; idHelper = `${this.id}-text`; get hostElement() { return index.getElement(this); } /** The textarea content */ content; /** The label describing the textarea. */ label; /** The textarea content, do not provide slotted content. */ value = ''; /** Helper text that will appear underneath the textarea. Will be overwritten if you set an `error` string */ helpertext; /** A unique ID connecting the element to the label. @category HTML Textarea */ textareaid = this.id; /** HTML name. @category HTML Textarea */ name; /** Set the associated form. @category HTML Textarea*/ form; /** Set the row count for the textarea. @category HTML Textarea */ rows = 2; /** Set the col count for the textarea. @category HTML Textarea */ cols = 20; /** Set the wrap control. @category HTML Textarea */ wrap = 'soft'; /** The maximum number of characters the user should be able to add, also adds a visible counter. @category HTML Textarea */ maxlength; /** Allow the browser to autocomplete the textarea. @category HTML Textarea */ autocomplete = 'off'; /** Allow the browser to spellcheck the textarea. @category HTML Textarea */ spellcheck = false; /** Placeholder for the textarea. @category HTML Textarea */ placeholder; /** Allow the user to resize the textarea vertically. Handle width in your own layout. @category HTML Textarea */ resize = false; /** Make the textarea required. @category HTML Textarea */ required = false; /** Set the textarea as `valid`, will make the Label and focus rings green. @category State */ valid = false; /** Set the textarea as `invalid`, will make the Label and focus rings red. @category State */ invalid = false; /** Same as `invalid`, but will display the string as an error message under the textarea. @category State */ error; /** Disable the textarea. @category State */ disabled = false; /** Make the textarea readonly. @category State */ readonly = false; componentWillLoad() { if (this.textareaid !== this.id) { this.idHelper = `${this.textareaid}-helper`; } } setVal(event) { const value = event.target.value; this.value = value; } hasError() { return this.invalid || !!this.error; } hasMessage() { return !!(this.helpertext?.length || this.error?.length); } render() { return (index.h(index.Host, { key: '5a142dbaa2f6ea08d868668bf3f12e43be23f935' }, index.h("div", { key: '2858929a5c5daedaa477dcb720a232e63e3c0c85', class: "pn-textarea", "data-valid": this.valid, "data-error": this.hasError(), "data-resize": this.resize }, index.h("label", { key: 'ea30152404c7dacafbac4f7bbede2a5e65245ef1', class: "pn-textarea-label", htmlFor: this.textareaid }, index.h("span", { key: 'd095e7a14076c808d6ae13684e5961ae74ce11e6' }, this.label), this.maxlength >= 1 && index.h("span", { key: 'd689bbda3d391099285f7d1609668647935e5f13' }, `${this.value?.length || 0}/${this.maxlength}`)), index.h("textarea", { key: 'f10f5a7a970171be0cf570bd64d5fdf99a16b1b2', class: "pn-textarea-element", id: this.textareaid, name: this.name, rows: this.rows, cols: this.cols, wrap: this.wrap, autocomplete: this.autocomplete, spellcheck: this.spellcheck, placeholder: this.placeholder, maxlength: this.maxlength, required: this.required, disabled: this.disabled, readonly: this.readonly, "aria-describedby": this.hasMessage() ? this.idHelper : null, onInput: e => this.setVal(e), value: this.value }), this.hasMessage() && (index.h("p", { key: '2baf7a99cdf2cc870572af6673396ab29f605822', id: this.idHelper, class: "pn-textarea-text", role: this.error?.length ? 'alert' : null }, index.h("span", { key: '83020c2c03bde268b582d3ec0a8fb8589d4b3e39' }, this.error || this.helpertext)))))); } }; PnTextarea.style = PnTextareaStyle0; exports.pn_textarea = PnTextarea; //# sourceMappingURL=pn-textarea.cjs.entry.js.map