@cocreate/conditional-logic
Advanced tools
Comparing version 1.1.29 to 1.2.0
@@ -0,1 +1,13 @@ | ||
# [1.2.0](https://github.com/CoCreate-app/CoCreate-conditional-logic/compare/v1.1.29...v1.2.0) (2021-10-14) | ||
### Bug Fixes | ||
* updated dependencies ([40531bd](https://github.com/CoCreate-app/CoCreate-conditional-logic/commit/40531bd7b22011d0f041d3c868c17df92378c93a)) | ||
### Features | ||
* supports using as a action. action name is showHide ([5afc8a3](https://github.com/CoCreate-app/CoCreate-conditional-logic/commit/5afc8a327ffa3d5f6e9276d69989f2795045aa69)) | ||
## [1.1.29](https://github.com/CoCreate-app/CoCreate-conditional-logic/compare/v1.1.28...v1.1.29) (2021-10-13) | ||
@@ -2,0 +14,0 @@ |
{ | ||
"name": "@cocreate/conditional-logic", | ||
"version": "1.1.29", | ||
"version": "1.2.0", | ||
"description": "Simple JS component show & hide elements conditionally with inputs,checkbox,radio,btn etc.Great for creating tabs, accordions, dynamic forms, etc. Easy Configuration using HTML5 data attributes and/or JavaScript API.", | ||
@@ -64,6 +64,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@cocreate/docs": "^1.2.30", | ||
"@cocreate/observer": "^1.3.28", | ||
"@cocreate/utils": "^1.1.29" | ||
"@cocreate/docs": "^1.2.32", | ||
"@cocreate/observer": "^1.3.29", | ||
"@cocreate/utils": "^1.1.31" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /* | ||
*/ | ||
/*globals CustomEvent, CoCreate*/ | ||
import observer from '@cocreate/observer' | ||
@@ -24,8 +24,15 @@ | ||
el = el.closest('select'); | ||
let actions = el.getAttribute('actions'); | ||
if (actions && actions.includes('validate')){ | ||
el.removeEventListener('change', selectShowHideEle); | ||
el.removeEventListener('change', selectShowHideEle); | ||
el.removeEventListener("click", clickShowHideEle); | ||
el.addEventListener("change", selectShowHideEle); | ||
el.addEventListener("click", clickShowHideEle); | ||
el.addEventListener("change", selectShowHideEle); | ||
} | ||
else { | ||
el.removeEventListener('change', selectShowHideEle); | ||
el.removeEventListener("click", clickShowHideEle); | ||
el.addEventListener("change", selectShowHideEle); | ||
el.addEventListener("click", clickShowHideEle); | ||
} | ||
} | ||
@@ -55,8 +62,11 @@ | ||
function clickShowHideEle(e) { | ||
var show = this.getAttribute('show'); | ||
var hide = this.getAttribute('hide'); | ||
let tagName = this.tagName.toLowerCase(); | ||
let element = e.currentTarget; | ||
if (!element) | ||
element = e; | ||
var show = element.getAttribute('show'); | ||
var hide = element.getAttribute('hide'); | ||
let tagName = element.tagName.toLowerCase(); | ||
if (tagName == 'input' && this.getAttribute("type").toLowerCase() == 'radio') { | ||
let name = this.getAttribute("name"); | ||
if (tagName == 'input' && element.getAttribute("type").toLowerCase() == 'radio') { | ||
let name = element.getAttribute("name"); | ||
let radios = document.querySelectorAll(tagName + '[name="' + name + '"]'); | ||
@@ -99,2 +109,7 @@ for (let radio of radios) { | ||
} | ||
document.dispatchEvent(new CustomEvent('showHide', { | ||
detail: {} | ||
})); | ||
} | ||
@@ -117,3 +132,12 @@ | ||
CoCreate.action.init({ | ||
action: "showHide", | ||
endEvent: "showHide", | ||
callback: (btn, data) => { | ||
clickShowHideEle(btn); | ||
} | ||
}); | ||
const CoCreateConditionalLogic = { initElements, selectShowHideEle, clickShowHideEle }; | ||
export default CoCreateConditionalLogic; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56217
273
Updated@cocreate/docs@^1.2.32
Updated@cocreate/observer@^1.3.29
Updated@cocreate/utils@^1.1.31