{"version":3,"sources":["webpack:///./node_modules/digital-guidelines-core/dist/esm/som-textarea.entry.js","webpack:///./node_modules/digital-guidelines-core/dist/esm/functions-e19590df.js"],"names":["somTextareaCss","DEFAULT_ROWS","SomTextarea","hostRef","this","somFocus","somInput","somBlur","somChange","label","help","error","required","placeholder","name","value","disabled","readonly","rows","maxLength","inputAriaLabel","currentValue","inputId","htmlElement","e","emit","target","addEventListener","handleFocusCb","handleInputCb","handleBlurCb","handleChangeCb","removeEventListener","helpElementId","handleFocus","bind","handleInput","handleBlur","handleChange","el","querySelector","registerEvents","unregisterEvents","isInError","ariaInvalid","labelFor","helpId","slot","class","Object","assign","id","maxlength","length","style","focusElement","element","delay","Promise","resolve","setTimeout","focus","getFocusableElementList","find","items","fn","Array","prototype","i","found","lastId","generateId","prefix","whichTransitionEvent","document","createElement","transitions","transition","OTransition","MozTransition","WebkitTransition","transitionKeys","keys","t","undefined","whichAnimationEvent","animations","animation","OAnimation","MozAnimation","WebkitAnimation","animationKeys","waitForCSSTransitionToFinish","elem","callback","transitionEvent","onTransitionCompletedCb","onTransitionCompleted","evt","runAfterNextFrameRender","requestAnimationFrame","isDescendant","parent","child","node","parentNode"],"mappings":"gHAAA,iFAGA,MAAMA,EAAiB,wPAEjBC,EAAe,EACrB,IAAIC,EAAc,MAChB,YAAYC,GACV,eAAiBC,KAAMD,GACvBC,KAAKC,SAAW,eAAYD,KAAM,WAAY,GAC9CA,KAAKE,SAAW,eAAYF,KAAM,WAAY,GAC9CA,KAAKG,QAAU,eAAYH,KAAM,UAAW,GAC5CA,KAAKI,UAAY,eAAYJ,KAAM,YAAa,GAIhDA,KAAKK,MAAQ,GAIbL,KAAKM,KAAO,GAIZN,KAAKO,MAAQ,KAKbP,KAAKQ,UAAW,EAIhBR,KAAKS,YAAc,GAInBT,KAAKU,KAAO,GAIZV,KAAKW,MAAQ,GAKbX,KAAKY,UAAW,EAKhBZ,KAAKa,UAAW,EAKhBb,KAAKc,KAAOjB,EAIZG,KAAKe,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,SAASO,EAAaC,EAAQC,GAC5B,IAAIC,EAAOD,EAAME,WACjB,MAAgB,OAATD,EAAe,CACpB,GAAIA,IAASF,EACX,OAAO,EAETE,EAAOA,EAAKC,WAEd,OAAO","file":"js/chunk-b4ffdb06.95e26285.js","sourcesContent":["import { r as registerInstance, c as createEvent, h, g as getElement } from './index-4ec8feae.js';\nimport { g as generateId, f as focusElement } from './functions-e19590df.js';\n\nconst somTextareaCss = \"som-textarea .textarea-container{position:relative}som-textarea .textarea-container textarea{padding-bottom:1.5rem}som-textarea .textarea-container .max-nb-chars{position:absolute;right:0.75rem;bottom:0.5rem;text-align:right;font-size:0.6875rem}\";\n\nconst DEFAULT_ROWS = 3;\nlet SomTextarea = class {\n constructor(hostRef) {\n registerInstance(this, hostRef);\n this.somFocus = createEvent(this, \"somFocus\", 7);\n this.somInput = createEvent(this, \"somInput\", 7);\n this.somBlur = createEvent(this, \"somBlur\", 7);\n this.somChange = createEvent(this, \"somChange\", 7);\n /**\n * This property can be used to set a label.\n */\n this.label = '';\n /**\n * This property can be used to set a help text.\n */\n this.help = '';\n /**\n * This property can be used to set an error. If a non-empty string is given, it will be used as the error message.\n */\n this.error = null;\n /**\n * This property can be used to set the input as required.\n * Defaults to `false`.\n */\n this.required = false;\n /**\n * This property can be used to set a placeholder text.\n */\n this.placeholder = '';\n /**\n * This property can be used to set the form field name (used when submitting the form).\n */\n this.name = '';\n /**\n * This property can be used to set the textarea value.\n */\n this.value = '';\n /**\n * This property can be used to disable the textarea.\n * Defaults to `false`.\n */\n this.disabled = false;\n /**\n * This property is used to set the textarea as readonly.\n * Defaults to `false`.\n */\n this.readonly = false;\n /**\n * This property is used to set the textarea's number of rows'.\n * Defaults to `3`.\n */\n this.rows = DEFAULT_ROWS;\n /**\n * This property is used to set the textarea's maximum characters limit.\n */\n this.maxLength = null;\n /**\n * This property can be used to set the ARIA label associated with this input (for screen readers).\n */\n this.inputAriaLabel = null;\n this.currentValue = '';\n this.inputId = generateId('som-textarea');\n }\n handleValueChange() {\n this.currentValue = this.value;\n }\n handleRowsChange() {\n if (!this.rows) {\n // Makes sure to always handle the default case\n this.rows = DEFAULT_ROWS;\n }\n }\n /**\n * Public method that sets focus to the textarea element.\n * @returns Promise will resolve after focus.\n */\n setFocus() {\n return focusElement(this.htmlElement);\n }\n handleFocus(e) {\n this.somFocus.emit(e);\n }\n handleInput(e) {\n this.currentValue = e.target.value;\n this.somInput.emit(e);\n }\n handleBlur(e) {\n this.somBlur.emit(e);\n }\n handleChange(e) {\n this.somChange.emit(e);\n }\n isInError() {\n return this.error !== null;\n }\n registerEvents() {\n this.htmlElement.addEventListener('focus', this.handleFocusCb);\n this.htmlElement.addEventListener('input', this.handleInputCb);\n this.htmlElement.addEventListener('blur', this.handleBlurCb);\n this.htmlElement.addEventListener('change', this.handleChangeCb);\n }\n unregisterEvents() {\n this.htmlElement.removeEventListener('focus', this.handleFocusCb);\n this.htmlElement.removeEventListener('input', this.handleInputCb);\n this.htmlElement.removeEventListener('blur', this.handleBlurCb);\n this.htmlElement.removeEventListener('change', this.handleChangeCb);\n }\n componentWillLoad() {\n this.helpElementId = `${this.inputId}-help`;\n this.currentValue = this.value;\n this.handleFocusCb = this.handleFocus.bind(this);\n this.handleInputCb = this.handleInput.bind(this);\n this.handleBlurCb = this.handleBlur.bind(this);\n this.handleChangeCb = this.handleChange.bind(this);\n }\n componentDidLoad() {\n this.htmlElement = this.el.querySelector(`#${this.inputId}`);\n this.registerEvents();\n }\n componentWillUnload() {\n this.unregisterEvents();\n }\n render() {\n const isInError = this.isInError();\n const ariaInvalid = isInError ? { 'aria-invalid': 'true' } : {};\n return (h(\"som-form-field\", { label: this.label, labelFor: this.inputId, help: this.help, helpId: this.helpElementId, required: this.required, error: this.error }, h(\"div\", { slot: \"content\", class: \"textarea-container\" }, h(\"textarea\", Object.assign({ id: this.inputId, class: `form-control ${isInError ? 'is-invalid' : ''}`, placeholder: this.placeholder, name: this.name, value: this.currentValue, disabled: this.disabled, readonly: this.readonly, required: this.required, rows: this.rows, maxlength: this.maxLength, \"aria-label\": this.inputAriaLabel, \"aria-describedby\": this.helpElementId }, ariaInvalid)), this.maxLength && this.maxLength > 0 ? (h(\"div\", { class: `max-nb-chars ${this.currentValue.length >= this.maxLength ? 'text-danger' : ''}` }, this.currentValue.length, \"/\", this.maxLength)) : null)));\n }\n get el() { return getElement(this); }\n static get watchers() { return {\n \"value\": [\"handleValueChange\"],\n \"rows\": [\"handleRowsChange\"]\n }; }\n};\nSomTextarea.style = somTextareaCss;\n\nexport { SomTextarea as som_textarea };\n","function focusElement(element, delay = 0) {\n return new Promise((resolve) => {\n // We need to put the `element.focus()` call on top of the stack to make sure IE executes the focus after everything else. This can be done with `setTimeout`.\n setTimeout(() => {\n element.focus();\n resolve();\n }, delay);\n });\n}\nfunction getFocusableElementList() {\n return 'a[href], area[href], input:not([disabled]), input:not([hidden]), select:not([disabled]), select:not([hidden]), textarea:not([disabled]), textarea:not([hidden]), button:not([disabled]), [tabindex=\"0\"]';\n}\nfunction find(items, fn) {\n // Use default find if supported\n if (Array.prototype.find) {\n return items.find(fn);\n }\n // `find` method is not defined on `Array`, so we implement it\n let i = 0;\n let found = null;\n while (!found && i < items.length) {\n found = fn(items[i]) ? items[i] : null;\n i += 1;\n }\n return found;\n}\n// Use this function to generate an ID.\n// For example, this will ensure that each 'som-radio-button' components will have a unique ID automatically.\nlet lastId = 0;\nfunction generateId(prefix = 'id') {\n lastId += 1;\n return `${prefix}${lastId}`;\n}\nfunction whichTransitionEvent() {\n const el = document.createElement('fakeelement');\n const transitions = {\n transition: 'transitionend',\n OTransition: 'oTransitionEnd',\n MozTransition: 'transitionend',\n WebkitTransition: 'webkitTransitionEnd',\n };\n const transitionKeys = Object.keys(transitions);\n let found = false;\n let i = 0;\n while (!found && i < transitionKeys.length) {\n const t = transitionKeys[i];\n if (el.style[t] !== undefined) {\n found = true;\n }\n else {\n i += 1;\n }\n }\n if (found) {\n const t = transitionKeys[i];\n return transitions[t];\n }\n return null;\n}\nfunction whichAnimationEvent() {\n const el = document.createElement('fakeelement');\n const animations = {\n animation: 'animationend',\n OAnimation: 'oAnimationEnd',\n MozAnimation: 'animationend',\n WebkitAnimation: 'webkitAnimationEnd',\n };\n const animationKeys = Object.keys(animations);\n let found = false;\n let i = 0;\n while (!found && i < animationKeys.length) {\n const t = animationKeys[i];\n if (el.style[t] !== undefined) {\n found = true;\n }\n else {\n i += 1;\n }\n }\n if (found) {\n const t = animationKeys[i];\n return animations[t];\n }\n return null;\n}\nfunction waitForCSSTransitionToFinish(elem, callback) {\n // Listen for a transition animation animation\n const transitionEvent = whichTransitionEvent();\n let onTransitionCompletedCb;\n const onTransitionCompleted = (evt) => {\n // Make sure to wait for the proper transition event\n if (evt.target === elem) {\n elem.removeEventListener(transitionEvent, onTransitionCompletedCb);\n callback();\n }\n };\n onTransitionCompletedCb = onTransitionCompleted.bind(this);\n if (transitionEvent) {\n elem.addEventListener(transitionEvent, onTransitionCompletedCb);\n }\n}\nfunction runAfterNextFrameRender(callback) {\n requestAnimationFrame(() => {\n setTimeout(() => {\n callback();\n }, 0);\n });\n}\n// Returns true of an element is a child of another element; false otherwise\nfunction isDescendant(parent, child) {\n let node = child.parentNode;\n while (node !== null) {\n if (node === parent) {\n return true;\n }\n node = node.parentNode;\n }\n return false;\n}\n\nexport { waitForCSSTransitionToFinish as a, whichAnimationEvent as b, find as c, getFocusableElementList as d, focusElement as f, generateId as g, isDescendant as i, runAfterNextFrameRender as r, whichTransitionEvent as w };\n"],"sourceRoot":""}