@lion/form-core
Advanced tools
Comparing version 0.8.1 to 0.8.2
# Change Log | ||
## 0.8.2 | ||
### Patch Changes | ||
- d0b37e62: Do a deep equals check for choice group children that have complex modelValues, enabling modelValue setter to work on the group level. | ||
## 0.8.1 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@lion/form-core", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "Form-core contains all essential building blocks for creating form fields and fieldsets", | ||
@@ -27,3 +27,3 @@ "license": "MIT", | ||
"scripts": { | ||
"custom-elements-manifest": "custom-elements-manifest analyze --exclude 'docs/**/*'", | ||
"custom-elements-manifest": "custom-elements-manifest analyze --litelement --exclude 'docs/**/*' 'test-helpers/**/*'", | ||
"debug": "cd ../../ && npm run debug -- --group form-core", | ||
@@ -51,2 +51,3 @@ "debug:firefox": "cd ../../ && npm run debug:firefox -- --group form-core", | ||
}, | ||
"customElementsManifest": "custom-elements.json", | ||
"exports": { | ||
@@ -58,4 +59,3 @@ ".": "./index.js", | ||
"./lion-validation-feedback": "./lion-validation-feedback.js" | ||
}, | ||
"customElementsManifest": "custom-elements.json" | ||
} | ||
} | ||
} |
@@ -47,3 +47,8 @@ import { dedupeMixin } from '@lion/core'; | ||
*/ | ||
const checkCondition = (el, val) => el.choiceValue === val; | ||
const checkCondition = (el, val) => { | ||
if (typeof el.choiceValue === 'object') { | ||
return JSON.stringify(el.choiceValue) === JSON.stringify(value); | ||
} | ||
return el.choiceValue === val; | ||
}; | ||
@@ -285,3 +290,12 @@ if (this.__isInitialModelValue) { | ||
if (this.multipleChoice) { | ||
this.formElements[i].checked = value.includes(this.formElements[i].value); | ||
let valueIsIncluded = value.includes(this.formElements[i].modelValue.value); | ||
// For complex values, do a JSON Stringified includes check, because [{ v: 'foo'}].includes({ v: 'foo' }) => false | ||
if (typeof this.formElements[i].modelValue.value === 'object') { | ||
valueIsIncluded = /** @type {any[]} */ (value) | ||
.map(/** @param {Object} v */ v => JSON.stringify(v)) | ||
.includes(JSON.stringify(this.formElements[i].modelValue.value)); | ||
} | ||
this.formElements[i].checked = valueIsIncluded; | ||
} else if (check(this.formElements[i], value)) { | ||
@@ -288,0 +302,0 @@ // Allows checking against custom values e.g. formattedValue or serializedValue |
Sorry, the diff of this file is too big to display
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
633814
18710