@dreamworld/dw-form
Advanced tools
Comparing version 1.1.0-dw-composite-form.9 to 1.1.0-dw-composite-form.10
@@ -43,3 +43,3 @@ /** | ||
return html` | ||
<dw-composite-form-element @value-changed="${this._onValueChanged}" .inputValue="${this._inputs}"> | ||
<dw-composite-form-element @value-changed="${this._onValueChanged}" .value="${this._inputs}"> | ||
<section class="layout horizontal"> | ||
@@ -46,0 +46,0 @@ <dw-input |
@@ -14,3 +14,3 @@ /** | ||
// These are lodash element needed by this element. | ||
import debounce from 'lodash-es/debounce'; | ||
import debounce from 'lodash-es/debounce'; | ||
@@ -36,9 +36,3 @@ // These are dw element needed by this element. | ||
*/ | ||
value: { type: Object }, | ||
/** | ||
* Input Property | ||
* Used to set pre-filled value of the element | ||
*/ | ||
inputValue: { type: Object } | ||
value: { type: Object } | ||
} | ||
@@ -57,3 +51,2 @@ } | ||
this.value = {}; | ||
this.inputValue = {}; | ||
this._dispatchValueChangeEvent = debounce(this._dispatchValueChangeEvent, 100); | ||
@@ -64,2 +57,8 @@ this._onElementValueChange = this._onElementValueChange.bind(this); | ||
this._onUnregisterDwFormElement = this._onUnregisterDwFormElement.bind(this); | ||
/** | ||
* Instance property | ||
* Default value is false | ||
* Becomes true when value is changed internally. | ||
*/ | ||
this._changedInternally = false; | ||
} | ||
@@ -79,2 +78,3 @@ | ||
this._elements = []; | ||
this._changedInternally = null; | ||
} | ||
@@ -85,12 +85,15 @@ | ||
*/ | ||
set inputValue(val) { | ||
if (val === this._inputValue) { | ||
set value(val) { | ||
if (val === this._value || this._changedInternally) { | ||
return; | ||
} | ||
let oldValue = this._inputValue; | ||
this._inputValue = val; | ||
this.value = { ...val }; | ||
this._changedInternally = false; | ||
let oldValue = this._value; | ||
this._value = val; | ||
this._setChildElementValue(); | ||
this.requestUpdate('inputValue', oldValue); | ||
this.requestUpdate('value', oldValue); | ||
} | ||
@@ -101,4 +104,4 @@ | ||
*/ | ||
get inputValue() { | ||
return this._inputValue; | ||
get value() { | ||
return this._value; | ||
} | ||
@@ -155,5 +158,7 @@ | ||
_onElementValueChange(e) { | ||
this._changedInternally = true; | ||
let value = e.target.value; | ||
let name = e.target.name; | ||
this.value = { ...this.value }; | ||
this.value[name] = value; | ||
@@ -168,5 +173,7 @@ this._dispatchValueChangeEvent(); | ||
_onElementCheckedChange(e) { | ||
this._changedInternally = true; | ||
let value = e.target.checked; | ||
let name = e.target.name; | ||
this.value = { ...this.value }; | ||
this.value[name] = value; | ||
@@ -173,0 +180,0 @@ this._dispatchValueChangeEvent(); |
{ | ||
"name": "@dreamworld/dw-form", | ||
"version": "1.1.0-dw-composite-form.9", | ||
"version": "1.1.0-dw-composite-form.10", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dw-form.js", |
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
27844
640