{"version":3,"sources":["webpack:///./node_modules/digital-guidelines-core/dist/esm/som-input.entry.js","webpack:///./node_modules/digital-guidelines-core/dist/esm/functions-e19590df.js"],"names":["somInputCss","SomInput","hostRef","this","somFocus","somInput","somBlur","somChange","label","help","error","required","type","placeholder","name","value","disabled","readonly","inputAriaLabel","grouped","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","style","focusElement","element","delay","Promise","resolve","setTimeout","focus","getFocusableElementList","find","items","fn","Array","prototype","i","found","length","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,8EAGA,MAAMA,EAAc,uDAEpB,IAAIC,EAAW,MACb,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,EAOhBR,KAAKS,KAAO,OAIZT,KAAKU,YAAc,GAInBV,KAAKW,KAAO,GAIZX,KAAKY,MAAQ,GAKbZ,KAAKa,UAAW,EAKhBb,KAAKc,UAAW,EAIhBd,KAAKe,eAAiB,KAKtBf,KAAKgB,SAAU,EACfhB,KAAKiB,aA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BC,WAAY,gBACZC,YAAa,iBACbC,cAAe,gBACfC,iBAAkB,uBAEdC,EAAiB/B,OAAOgC,KAAKN,GACnC,IAAIR,GAAQ,EACRD,EAAI,EACR,OAAQC,GAASD,EAAIc,EAAeZ,OAAQ,CAC1C,MAAMc,EAAIF,EAAed,QACLiB,IAAhB5C,EAAGa,MAAM8B,GACXf,GAAQ,EAGRD,GAAK,EAGT,GAAIC,EAAO,CACT,MAAMe,EAAIF,EAAed,GACzB,OAAOS,EAAYO,GAErB,OAAO,KAET,SAASE,IACP,MAAM7C,EAAKkC,SAASC,cAAc,eAC5BW,EAAa,CACjBC,UAAW,eACXC,WAAY,gBACZC,aAAc,eACdC,gBAAiB,sBAEbC,EAAgBzC,OAAOgC,KAAKI,GAClC,IAAIlB,GAAQ,EACRD,EAAI,EACR,OAAQC,GAASD,EAAIwB,EAActB,OAAQ,CACzC,MAAMc,EAAIQ,EAAcxB,QACJiB,IAAhB5C,EAAGa,MAAM8B,GACXf,GAAQ,EAGRD,GAAK,EAGT,GAAIC,EAAO,CACT,MAAMe,EAAIQ,EAAcxB,GACxB,OAAOmB,EAAWH,GAEpB,OAAO,KAET,SAASS,EAA6BC,EAAMC,GAE1C,MAAMC,EAAkBtB,IACxB,IAAIuB,EACJ,MAAMC,EAAyBC,IAEzBA,EAAIvE,SAAWkE,IACjBA,EAAK5D,oBAAoB8D,EAAiBC,GAC1CF,MAGJE,EAA0BC,EAAsB7D,KAAK/B,MACjD0F,GACFF,EAAKjE,iBAAiBmE,EAAiBC,GAG3C,SAASG,EAAwBL,GAC/BM,sBAAsB,KACpBzC,WAAW,KACTmC,KACC,KAIP,SAASO,EAAaC,EAAQC,GAC5B,IAAIC,EAAOD,EAAME,WACjB,MAAgB,OAATD,EAAe,CACpB,GAAIA,IAASF,EACX,OAAO,EAETE,EAAOA,EAAKC,WAEd,OAAO","file":"js/chunk-b4fe67fa.4e322b8a.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 somInputCss = \"som-input{}som-input input:required{box-shadow:none}\";\n\nlet SomInput = 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 the type.\n * Possible values: `\"email\"`, `\"number\"`, `\"password\"`, `\"search\"`, `\"tel\"`, `\"text\"`, `\"url\"`\n *\n * Defaults to `\"text\"`.\n */\n this.type = 'text';\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 text input value.\n */\n this.value = '';\n /**\n * This property can be used to disable the text input.\n * Defaults to `false`.\n */\n this.disabled = false;\n /**\n * This property can be used to set the text input as readonly.\n * Defaults to `false`.\n */\n this.readonly = false;\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 /**\n * This property can be used when using a grouped text input and passing a children component to be used as grouped element.\n * Defaults to `false`.\n */\n this.grouped = false;\n this.currentValue = '';\n this.inputId = generateId('som-input');\n }\n handleValueChange() {\n this.currentValue = this.value;\n }\n /**\n * Public method that sets focus to the text input 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: this.grouped ? 'input-group' : null }, h(\"input\", Object.assign({ id: this.inputId, class: `form-control ${isInError ? 'is-invalid' : ''}`, type: this.type, placeholder: this.placeholder, name: this.name, value: this.currentValue, disabled: this.disabled, readonly: this.readonly, required: this.required, \"aria-label\": this.inputAriaLabel, \"aria-describedby\": this.helpElementId }, ariaInvalid)), this.grouped ? (h(\"div\", { class: \"input-group-append\" }, h(\"slot\", null))) : null)));\n }\n get el() { return getElement(this); }\n static get watchers() { return {\n \"value\": [\"handleValueChange\"]\n }; }\n};\nSomInput.style = somInputCss;\n\nexport { SomInput as som_input };\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":""}