From 8ad8e75daf2d3f5eb402d07453685d529560caa9 Mon Sep 17 00:00:00 2001 From: Daniel Bendel Date: Wed, 7 Dec 2016 10:06:21 +0100 Subject: [PATCH] chore(all): dist build --- dist/amd/validation/validationRenderer.js | 7 +- dist/aurelia-materialize-bridge.js | 265 +++++++++--------- .../commonjs/validation/validationRenderer.js | 7 +- .../dev/validation/validationRenderer.js.map | 2 +- dist/dev/validation/validationRenderer.js | 7 +- dist/es6/validation/validationRenderer.js | 265 +++++++++--------- dist/system/validation/validationRenderer.js | 7 +- dist/temp/aurelia-materialize-bridge.js | 7 +- 8 files changed, 301 insertions(+), 266 deletions(-) diff --git a/dist/amd/validation/validationRenderer.js b/dist/amd/validation/validationRenderer.js index ce04de61..b537cd33 100644 --- a/dist/amd/validation/validationRenderer.js +++ b/dist/amd/validation/validationRenderer.js @@ -159,7 +159,12 @@ define(['exports'], function (exports) { if (!selectWrapper) { return; } - this.removeMessage(selectWrapper, error); + + if ($(selectWrapper.parentElement).children().hasClass('md-input-validation')) { + this.removeMessage(selectWrapper.parentElement, error); + } else { + this.removeMessage(selectWrapper, error); + } var _input2 = selectWrapper.querySelector('input'); if (_input2 && selectWrapper.querySelectorAll('.' + this.className).length === 0) { diff --git a/dist/aurelia-materialize-bridge.js b/dist/aurelia-materialize-bridge.js index b3593679..0982958b 100644 --- a/dist/aurelia-materialize-bridge.js +++ b/dist/aurelia-materialize-bridge.js @@ -2909,136 +2909,141 @@ export class MdStaggeredList { } } -export class MaterializeFormValidationRenderer { - - className = 'md-input-validation'; - classNameFirst = 'md-input-validation-first'; - - render(instruction) { - for (let { error, elements } of instruction.unrender) { - for (let element of elements) { - this.remove(element, error); - } - } - for (let { error, elements } of instruction.render) { - for (let element of elements) { - this.add(element, error); - } - } - } - - add(element, error) { - switch (element.tagName) { - case 'MD-INPUT': { - let label = element.querySelector('label'); - let input = element.querySelector('input') || element.querySelector('textarea'); - if (label) { - label.removeAttribute('data-error'); - } - if (input) { - input.classList.remove('valid'); - input.classList.add('invalid'); - error.target = input; - if (input.hasAttribute('data-show-errortext')) { - this.addMessage(element, error); - } - } - break; - } - case 'SELECT': { - const selectWrapper = element.closest('.select-wrapper'); - if (!selectWrapper) { - return; - } - let input = selectWrapper.querySelector('input'); - if (input) { - input.classList.remove('valid'); - input.classList.add('invalid'); - error.target = input; - if (!(input.hasAttribute('data-show-errortext') && - input.getAttribute('data-show-errortext') === 'false')) { - this.addMessage(selectWrapper, error); - } - } - break; - } - case 'INPUT' : { - if (element.hasAttribute('md-datepicker')) { - element.classList.remove('valid'); - element.classList.add('invalid'); - if (!(element.hasAttribute('data-show-errortext') && - element.getAttribute('data-show-errortext') === 'false')) { - this.addMessage(element.parentNode, error); - } - } - break; - } - default: break; - } - } - - remove(element, error) { - switch (element.tagName) { - case 'MD-INPUT': { - this.removeMessage(element, error); - - let input = element.querySelector('input') || element.querySelector('textarea'); - if (input && element.querySelectorAll('.' + this.className).length === 0) { - input.classList.remove('invalid'); - input.classList.add('valid'); - } - break; - } - case 'SELECT': { - const selectWrapper = element.closest('.select-wrapper'); - if (!selectWrapper) { - return; - } - this.removeMessage(selectWrapper, error); - - let input = selectWrapper.querySelector('input'); - if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) { - input.classList.remove('invalid'); - input.classList.add('valid'); - } - break; - } - case 'INPUT' : { - if (element.hasAttribute('md-datepicker')) { - this.removeMessage(element.parentNode, error); - if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) { - element.classList.remove('invalid'); - element.classList.add('valid'); - } - } - break; - } - default: break; - } - } - - addMessage(element, error) { - let message = document.createElement('div'); - message.id = `md-input-validation-${error.id}`; - message.textContent = error.message; - message.className = this.className; - if (element.querySelectorAll('.' + this.className).length === 0) { - message.className += ' ' + this.classNameFirst; - } - message.style.opacity = 0; - element.appendChild(message, element.nextSibling); - window.getComputedStyle(message).opacity; - message.style.opacity = 1; - } - - removeMessage(element, error) { - let message = element.querySelector(`#md-input-validation-${error.id}`); - if (message) { - element.removeChild(message); - } - } - -} +export class MaterializeFormValidationRenderer { + + className = 'md-input-validation'; + classNameFirst = 'md-input-validation-first'; + + render(instruction) { + for (let { error, elements } of instruction.unrender) { + for (let element of elements) { + this.remove(element, error); + } + } + for (let { error, elements } of instruction.render) { + for (let element of elements) { + this.add(element, error); + } + } + } + + add(element, error) { + switch (element.tagName) { + case 'MD-INPUT': { + let label = element.querySelector('label'); + let input = element.querySelector('input') || element.querySelector('textarea'); + if (label) { + label.removeAttribute('data-error'); + } + if (input) { + input.classList.remove('valid'); + input.classList.add('invalid'); + error.target = input; + if (input.hasAttribute('data-show-errortext')) { + this.addMessage(element, error); + } + } + break; + } + case 'SELECT': { + const selectWrapper = element.closest('.select-wrapper'); + if (!selectWrapper) { + return; + } + let input = selectWrapper.querySelector('input'); + if (input) { + input.classList.remove('valid'); + input.classList.add('invalid'); + error.target = input; + if (!(input.hasAttribute('data-show-errortext') && + input.getAttribute('data-show-errortext') === 'false')) { + this.addMessage(selectWrapper, error); + } + } + break; + } + case 'INPUT' : { + if (element.hasAttribute('md-datepicker')) { + element.classList.remove('valid'); + element.classList.add('invalid'); + if (!(element.hasAttribute('data-show-errortext') && + element.getAttribute('data-show-errortext') === 'false')) { + this.addMessage(element.parentNode, error); + } + } + break; + } + default: break; + } + } + + remove(element, error) { + switch (element.tagName) { + case 'MD-INPUT': { + this.removeMessage(element, error); + + let input = element.querySelector('input') || element.querySelector('textarea'); + if (input && element.querySelectorAll('.' + this.className).length === 0) { + input.classList.remove('invalid'); + input.classList.add('valid'); + } + break; + } + case 'SELECT': { + const selectWrapper = element.closest('.select-wrapper'); + if (!selectWrapper) { + return; + } + + if ($(selectWrapper.parentElement).children().hasClass('md-input-validation') ) { + this.removeMessage(selectWrapper.parentElement, error); + } else { + this.removeMessage(selectWrapper, error); + } + + let input = selectWrapper.querySelector('input'); + if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) { + input.classList.remove('invalid'); + input.classList.add('valid'); + } + break; + } + case 'INPUT' : { + if (element.hasAttribute('md-datepicker')) { + this.removeMessage(element.parentNode, error); + if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) { + element.classList.remove('invalid'); + element.classList.add('valid'); + } + } + break; + } + default: break; + } + } + + addMessage(element, error) { + let message = document.createElement('div'); + message.id = `md-input-validation-${error.id}`; + message.textContent = error.message; + message.className = this.className; + if (element.querySelectorAll('.' + this.className).length === 0) { + message.className += ' ' + this.classNameFirst; + } + message.style.opacity = 0; + element.appendChild(message, element.nextSibling); + window.getComputedStyle(message).opacity; + message.style.opacity = 1; + } + + removeMessage(element, error) { + let message = element.querySelector(`#md-input-validation-${error.id}`); + if (message) { + element.removeChild(message); + } + } + +} @customAttribute('md-waves') @inject(Element) diff --git a/dist/commonjs/validation/validationRenderer.js b/dist/commonjs/validation/validationRenderer.js index f18bade9..8b336094 100644 --- a/dist/commonjs/validation/validationRenderer.js +++ b/dist/commonjs/validation/validationRenderer.js @@ -154,7 +154,12 @@ var MaterializeFormValidationRenderer = exports.MaterializeFormValidationRendere if (!selectWrapper) { return; } - this.removeMessage(selectWrapper, error); + + if ($(selectWrapper.parentElement).children().hasClass('md-input-validation')) { + this.removeMessage(selectWrapper.parentElement, error); + } else { + this.removeMessage(selectWrapper, error); + } var _input2 = selectWrapper.querySelector('input'); if (_input2 && selectWrapper.querySelectorAll('.' + this.className).length === 0) { diff --git a/dist/dev/dist/dev/validation/validationRenderer.js.map b/dist/dev/dist/dev/validation/validationRenderer.js.map index 8cbf78e5..5ec76c9e 100644 --- a/dist/dev/dist/dev/validation/validationRenderer.js.map +++ b/dist/dev/dist/dev/validation/validationRenderer.js.map @@ -1 +1 @@ -{"version":3,"sources":["validation/validationRenderer.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;mDAAa;;;;eAEX,YAAY;eACZ,iBAAiB;;;oDAEjB,yBAAO,aAAa;AAClB,+BAAgC,YAAY,QAAZ,8GAAhC,IAAsD;;;;;;;;;;;;;gBAA3C,oBAA2C;gBAApC,0BAAoC;;AACpD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AAqB,MAAM,KAAK,cAAL,CADoC;WAAjE;AAGA,kBAAQ,KAAR,CAAc,OAAd,GAAwB,CAAxB,CARyB;AASzB,kBAAQ,WAAR,CAAoB,OAApB,EAA6B,QAAQ,WAAR,CAA7B,CATyB;AAUzB,iBAAO,gBAAP,CAAwB,OAAxB,EAAiC,OAAjC,CAVyB;AAWzB,kBAAQ,KAAR,CAAc,OAAd,GAAwB,CAAxB,CAXyB;;;oDAc3B,uCAAc,SAAS,OAAO;AAC5B,cAAI,UAAU,QAAQ,aAAR,2BAA8C,MAAM,EAAN,CAAxD,CADwB;AAE5B,cAAI,OAAJ,EAAa;AACX,oBAAQ,WAAR,CAAoB,OAApB,EADW;WAAb","file":"validation/validationRenderer.js","sourceRoot":"/source/","sourcesContent":["export class MaterializeFormValidationRenderer {\r\n\r\n className = 'md-input-validation';\r\n classNameFirst = 'md-input-validation-first';\r\n\r\n render(instruction) {\r\n for (let { error, elements } of instruction.unrender) {\r\n for (let element of elements) {\r\n this.remove(element, error);\r\n }\r\n }\r\n for (let { error, elements } of instruction.render) {\r\n for (let element of elements) {\r\n this.add(element, error);\r\n }\r\n }\r\n }\r\n\r\n add(element, error) {\r\n switch (element.tagName) {\r\n case 'MD-INPUT': {\r\n let label = element.querySelector('label');\r\n let input = element.querySelector('input') || element.querySelector('textarea');\r\n if (label) {\r\n label.removeAttribute('data-error');\r\n }\r\n if (input) {\r\n input.classList.remove('valid');\r\n input.classList.add('invalid');\r\n error.target = input;\r\n if (input.hasAttribute('data-show-errortext')) {\r\n this.addMessage(element, error);\r\n }\r\n }\r\n break;\r\n }\r\n case 'SELECT': {\r\n const selectWrapper = element.closest('.select-wrapper');\r\n if (!selectWrapper) {\r\n return;\r\n }\r\n let input = selectWrapper.querySelector('input');\r\n if (input) {\r\n input.classList.remove('valid');\r\n input.classList.add('invalid');\r\n error.target = input;\r\n if (!(input.hasAttribute('data-show-errortext') &&\r\n input.getAttribute('data-show-errortext') === 'false')) {\r\n this.addMessage(selectWrapper, error);\r\n }\r\n }\r\n break;\r\n }\r\n case 'INPUT' : {\r\n if (element.hasAttribute('md-datepicker')) {\r\n element.classList.remove('valid');\r\n element.classList.add('invalid');\r\n if (!(element.hasAttribute('data-show-errortext') &&\r\n element.getAttribute('data-show-errortext') === 'false')) {\r\n this.addMessage(element.parentNode, error);\r\n }\r\n }\r\n break;\r\n }\r\n default: break;\r\n }\r\n }\r\n\r\n remove(element, error) {\r\n switch (element.tagName) {\r\n case 'MD-INPUT': {\r\n this.removeMessage(element, error);\r\n\r\n let input = element.querySelector('input') || element.querySelector('textarea');\r\n if (input && element.querySelectorAll('.' + this.className).length === 0) {\r\n input.classList.remove('invalid');\r\n input.classList.add('valid');\r\n }\r\n break;\r\n }\r\n case 'SELECT': {\r\n const selectWrapper = element.closest('.select-wrapper');\r\n if (!selectWrapper) {\r\n return;\r\n }\r\n this.removeMessage(selectWrapper, error);\r\n\r\n let input = selectWrapper.querySelector('input');\r\n if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) {\r\n input.classList.remove('invalid');\r\n input.classList.add('valid');\r\n }\r\n break;\r\n }\r\n case 'INPUT' : {\r\n if (element.hasAttribute('md-datepicker')) {\r\n this.removeMessage(element.parentNode, error);\r\n if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) {\r\n element.classList.remove('invalid');\r\n element.classList.add('valid');\r\n }\r\n }\r\n break;\r\n }\r\n default: break;\r\n }\r\n }\r\n\r\n addMessage(element, error) {\r\n let message = document.createElement('div');\r\n message.id = `md-input-validation-${error.id}`;\r\n message.textContent = error.message;\r\n message.className = this.className;\r\n if (element.querySelectorAll('.' + this.className).length === 0) {\r\n message.className += ' ' + this.classNameFirst;\r\n }\r\n message.style.opacity = 0;\r\n element.appendChild(message, element.nextSibling);\r\n window.getComputedStyle(message).opacity;\r\n message.style.opacity = 1;\r\n }\r\n\r\n removeMessage(element, error) {\r\n let message = element.querySelector(`#md-input-validation-${error.id}`);\r\n if (message) {\r\n element.removeChild(message);\r\n }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B,OAAtB,EAFqF;mBAAvF;iBAFF;AAOA,sBARa;eAAf;AA9BA;AAwCS,oBAAT;AAxCA,WADqB;;;oDA6CvB,iCAAW,SAAS,OAAO;AACzB,cAAI,UAAU,SAAS,aAAT,CAAuB,KAAvB,CAAV,CADqB;AAEzB,kBAAQ,EAAR,4BAAoC,MAAM,EAAN,CAFX;AAGzB,kBAAQ,WAAR,GAAsB,MAAM,OAAN,CAHG;AAIzB,kBAAQ,SAAR,GAAoB,KAAK,SAAL,CAJK;AAKzB,cAAI,QAAQ,gBAAR,CAAyB,MAAM,KAAK,SAAL,CAA/B,CAA+C,MAA/C,KAA0D,CAA1D,EAA6D;AAC/D,oBAAQ,SAAR,IAAqB,MAAM,KAAK,cAAL,CADoC;WAAjE;AAGA,kBAAQ,KAAR,CAAc,OAAd,GAAwB,CAAxB,CARyB;AASzB,kBAAQ,WAAR,CAAoB,OAApB,EAA6B,QAAQ,WAAR,CAA7B,CATyB;AAUzB,iBAAO,gBAAP,CAAwB,OAAxB,EAAiC,OAAjC,CAVyB;AAWzB,kBAAQ,KAAR,CAAc,OAAd,GAAwB,CAAxB,CAXyB;;;oDAc3B,uCAAc,SAAS,OAAO;AAC5B,cAAI,UAAU,QAAQ,aAAR,2BAA8C,MAAM,EAAN,CAAxD,CADwB;AAE5B,cAAI,OAAJ,EAAa;AACX,oBAAQ,WAAR,CAAoB,OAApB,EADW;WAAb","file":"validation/validationRenderer.js","sourceRoot":"/source/","sourcesContent":["export class MaterializeFormValidationRenderer {\n\n className = 'md-input-validation';\n classNameFirst = 'md-input-validation-first';\n\n render(instruction) {\n for (let { error, elements } of instruction.unrender) {\n for (let element of elements) {\n this.remove(element, error);\n }\n }\n for (let { error, elements } of instruction.render) {\n for (let element of elements) {\n this.add(element, error);\n }\n }\n }\n\n add(element, error) {\n switch (element.tagName) {\n case 'MD-INPUT': {\n let label = element.querySelector('label');\n let input = element.querySelector('input') || element.querySelector('textarea');\n if (label) {\n label.removeAttribute('data-error');\n }\n if (input) {\n input.classList.remove('valid');\n input.classList.add('invalid');\n error.target = input;\n if (input.hasAttribute('data-show-errortext')) {\n this.addMessage(element, error);\n }\n }\n break;\n }\n case 'SELECT': {\n const selectWrapper = element.closest('.select-wrapper');\n if (!selectWrapper) {\n return;\n }\n let input = selectWrapper.querySelector('input');\n if (input) {\n input.classList.remove('valid');\n input.classList.add('invalid');\n error.target = input;\n if (!(input.hasAttribute('data-show-errortext') &&\n input.getAttribute('data-show-errortext') === 'false')) {\n this.addMessage(selectWrapper, error);\n }\n }\n break;\n }\n case 'INPUT' : {\n if (element.hasAttribute('md-datepicker')) {\n element.classList.remove('valid');\n element.classList.add('invalid');\n if (!(element.hasAttribute('data-show-errortext') &&\n element.getAttribute('data-show-errortext') === 'false')) {\n this.addMessage(element.parentNode, error);\n }\n }\n break;\n }\n default: break;\n }\n }\n\n remove(element, error) {\n switch (element.tagName) {\n case 'MD-INPUT': {\n this.removeMessage(element, error);\n\n let input = element.querySelector('input') || element.querySelector('textarea');\n if (input && element.querySelectorAll('.' + this.className).length === 0) {\n input.classList.remove('invalid');\n input.classList.add('valid');\n }\n break;\n }\n case 'SELECT': {\n const selectWrapper = element.closest('.select-wrapper');\n if (!selectWrapper) {\n return;\n }\n\n if ($(selectWrapper.parentElement).children().hasClass('md-input-validation') ) {\n this.removeMessage(selectWrapper.parentElement, error);\n } else {\n this.removeMessage(selectWrapper, error);\n }\n\n let input = selectWrapper.querySelector('input');\n if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) {\n input.classList.remove('invalid');\n input.classList.add('valid');\n }\n break;\n }\n case 'INPUT' : {\n if (element.hasAttribute('md-datepicker')) {\n this.removeMessage(element.parentNode, error);\n if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) {\n element.classList.remove('invalid');\n element.classList.add('valid');\n }\n }\n break;\n }\n default: break;\n }\n }\n\n addMessage(element, error) {\n let message = document.createElement('div');\n message.id = `md-input-validation-${error.id}`;\n message.textContent = error.message;\n message.className = this.className;\n if (element.querySelectorAll('.' + this.className).length === 0) {\n message.className += ' ' + this.classNameFirst;\n }\n message.style.opacity = 0;\n element.appendChild(message, element.nextSibling);\n window.getComputedStyle(message).opacity;\n message.style.opacity = 1;\n }\n\n removeMessage(element, error) {\n let message = element.querySelector(`#md-input-validation-${error.id}`);\n if (message) {\n element.removeChild(message);\n }\n }\n\n}\n"]} \ No newline at end of file diff --git a/dist/dev/validation/validationRenderer.js b/dist/dev/validation/validationRenderer.js index 3ea3f8b0..a211d918 100644 --- a/dist/dev/validation/validationRenderer.js +++ b/dist/dev/validation/validationRenderer.js @@ -162,7 +162,12 @@ System.register([], function (_export, _context) { if (!selectWrapper) { return; } - this.removeMessage(selectWrapper, error); + + if ($(selectWrapper.parentElement).children().hasClass('md-input-validation')) { + this.removeMessage(selectWrapper.parentElement, error); + } else { + this.removeMessage(selectWrapper, error); + } var _input2 = selectWrapper.querySelector('input'); if (_input2 && selectWrapper.querySelectorAll('.' + this.className).length === 0) { diff --git a/dist/es6/validation/validationRenderer.js b/dist/es6/validation/validationRenderer.js index 6e7b8aab..a6435037 100644 --- a/dist/es6/validation/validationRenderer.js +++ b/dist/es6/validation/validationRenderer.js @@ -1,130 +1,135 @@ -export class MaterializeFormValidationRenderer { - - className = 'md-input-validation'; - classNameFirst = 'md-input-validation-first'; - - render(instruction) { - for (let { error, elements } of instruction.unrender) { - for (let element of elements) { - this.remove(element, error); - } - } - for (let { error, elements } of instruction.render) { - for (let element of elements) { - this.add(element, error); - } - } - } - - add(element, error) { - switch (element.tagName) { - case 'MD-INPUT': { - let label = element.querySelector('label'); - let input = element.querySelector('input') || element.querySelector('textarea'); - if (label) { - label.removeAttribute('data-error'); - } - if (input) { - input.classList.remove('valid'); - input.classList.add('invalid'); - error.target = input; - if (input.hasAttribute('data-show-errortext')) { - this.addMessage(element, error); - } - } - break; - } - case 'SELECT': { - const selectWrapper = element.closest('.select-wrapper'); - if (!selectWrapper) { - return; - } - let input = selectWrapper.querySelector('input'); - if (input) { - input.classList.remove('valid'); - input.classList.add('invalid'); - error.target = input; - if (!(input.hasAttribute('data-show-errortext') && - input.getAttribute('data-show-errortext') === 'false')) { - this.addMessage(selectWrapper, error); - } - } - break; - } - case 'INPUT' : { - if (element.hasAttribute('md-datepicker')) { - element.classList.remove('valid'); - element.classList.add('invalid'); - if (!(element.hasAttribute('data-show-errortext') && - element.getAttribute('data-show-errortext') === 'false')) { - this.addMessage(element.parentNode, error); - } - } - break; - } - default: break; - } - } - - remove(element, error) { - switch (element.tagName) { - case 'MD-INPUT': { - this.removeMessage(element, error); - - let input = element.querySelector('input') || element.querySelector('textarea'); - if (input && element.querySelectorAll('.' + this.className).length === 0) { - input.classList.remove('invalid'); - input.classList.add('valid'); - } - break; - } - case 'SELECT': { - const selectWrapper = element.closest('.select-wrapper'); - if (!selectWrapper) { - return; - } - this.removeMessage(selectWrapper, error); - - let input = selectWrapper.querySelector('input'); - if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) { - input.classList.remove('invalid'); - input.classList.add('valid'); - } - break; - } - case 'INPUT' : { - if (element.hasAttribute('md-datepicker')) { - this.removeMessage(element.parentNode, error); - if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) { - element.classList.remove('invalid'); - element.classList.add('valid'); - } - } - break; - } - default: break; - } - } - - addMessage(element, error) { - let message = document.createElement('div'); - message.id = `md-input-validation-${error.id}`; - message.textContent = error.message; - message.className = this.className; - if (element.querySelectorAll('.' + this.className).length === 0) { - message.className += ' ' + this.classNameFirst; - } - message.style.opacity = 0; - element.appendChild(message, element.nextSibling); - window.getComputedStyle(message).opacity; - message.style.opacity = 1; - } - - removeMessage(element, error) { - let message = element.querySelector(`#md-input-validation-${error.id}`); - if (message) { - element.removeChild(message); - } - } - -} +export class MaterializeFormValidationRenderer { + + className = 'md-input-validation'; + classNameFirst = 'md-input-validation-first'; + + render(instruction) { + for (let { error, elements } of instruction.unrender) { + for (let element of elements) { + this.remove(element, error); + } + } + for (let { error, elements } of instruction.render) { + for (let element of elements) { + this.add(element, error); + } + } + } + + add(element, error) { + switch (element.tagName) { + case 'MD-INPUT': { + let label = element.querySelector('label'); + let input = element.querySelector('input') || element.querySelector('textarea'); + if (label) { + label.removeAttribute('data-error'); + } + if (input) { + input.classList.remove('valid'); + input.classList.add('invalid'); + error.target = input; + if (input.hasAttribute('data-show-errortext')) { + this.addMessage(element, error); + } + } + break; + } + case 'SELECT': { + const selectWrapper = element.closest('.select-wrapper'); + if (!selectWrapper) { + return; + } + let input = selectWrapper.querySelector('input'); + if (input) { + input.classList.remove('valid'); + input.classList.add('invalid'); + error.target = input; + if (!(input.hasAttribute('data-show-errortext') && + input.getAttribute('data-show-errortext') === 'false')) { + this.addMessage(selectWrapper, error); + } + } + break; + } + case 'INPUT' : { + if (element.hasAttribute('md-datepicker')) { + element.classList.remove('valid'); + element.classList.add('invalid'); + if (!(element.hasAttribute('data-show-errortext') && + element.getAttribute('data-show-errortext') === 'false')) { + this.addMessage(element.parentNode, error); + } + } + break; + } + default: break; + } + } + + remove(element, error) { + switch (element.tagName) { + case 'MD-INPUT': { + this.removeMessage(element, error); + + let input = element.querySelector('input') || element.querySelector('textarea'); + if (input && element.querySelectorAll('.' + this.className).length === 0) { + input.classList.remove('invalid'); + input.classList.add('valid'); + } + break; + } + case 'SELECT': { + const selectWrapper = element.closest('.select-wrapper'); + if (!selectWrapper) { + return; + } + + if ($(selectWrapper.parentElement).children().hasClass('md-input-validation') ) { + this.removeMessage(selectWrapper.parentElement, error); + } else { + this.removeMessage(selectWrapper, error); + } + + let input = selectWrapper.querySelector('input'); + if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) { + input.classList.remove('invalid'); + input.classList.add('valid'); + } + break; + } + case 'INPUT' : { + if (element.hasAttribute('md-datepicker')) { + this.removeMessage(element.parentNode, error); + if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) { + element.classList.remove('invalid'); + element.classList.add('valid'); + } + } + break; + } + default: break; + } + } + + addMessage(element, error) { + let message = document.createElement('div'); + message.id = `md-input-validation-${error.id}`; + message.textContent = error.message; + message.className = this.className; + if (element.querySelectorAll('.' + this.className).length === 0) { + message.className += ' ' + this.classNameFirst; + } + message.style.opacity = 0; + element.appendChild(message, element.nextSibling); + window.getComputedStyle(message).opacity; + message.style.opacity = 1; + } + + removeMessage(element, error) { + let message = element.querySelector(`#md-input-validation-${error.id}`); + if (message) { + element.removeChild(message); + } + } + +} diff --git a/dist/system/validation/validationRenderer.js b/dist/system/validation/validationRenderer.js index fdb4bb25..a86509b2 100644 --- a/dist/system/validation/validationRenderer.js +++ b/dist/system/validation/validationRenderer.js @@ -162,7 +162,12 @@ System.register([], function (_export, _context) { if (!selectWrapper) { return; } - this.removeMessage(selectWrapper, error); + + if ($(selectWrapper.parentElement).children().hasClass('md-input-validation')) { + this.removeMessage(selectWrapper.parentElement, error); + } else { + this.removeMessage(selectWrapper, error); + } var _input2 = selectWrapper.querySelector('input'); if (_input2 && selectWrapper.querySelectorAll('.' + this.className).length === 0) { diff --git a/dist/temp/aurelia-materialize-bridge.js b/dist/temp/aurelia-materialize-bridge.js index a1e27387..a8f3caa7 100644 --- a/dist/temp/aurelia-materialize-bridge.js +++ b/dist/temp/aurelia-materialize-bridge.js @@ -3738,7 +3738,12 @@ var MaterializeFormValidationRenderer = exports.MaterializeFormValidationRendere if (!selectWrapper) { return; } - this.removeMessage(selectWrapper, error); + + if ($(selectWrapper.parentElement).children().hasClass('md-input-validation')) { + this.removeMessage(selectWrapper.parentElement, error); + } else { + this.removeMessage(selectWrapper, error); + } var _input2 = selectWrapper.querySelector('input'); if (_input2 && selectWrapper.querySelectorAll('.' + this.className).length === 0) {