saasufy-components 5.5.1 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/input-provider.js +22 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -692,6 +692,7 @@ This component can be configured to provide its data to multiple components (con
|
|
|
692
692
|
- `autocapitalize`: Can be `on` or `off` - It will set the auto-capitalize attribute on the inner input element. This is useful for mobile devices to enable or disable auto-capitalization of the first character which is typed into the input element.
|
|
693
693
|
- `autocorrect`: Can be `on` or `off` - It will set the auto-correct attribute on the inner input element. This is useful for mobile devices to enable or disable auto-correct.
|
|
694
694
|
- `input-props`: Can be used to set additional attributes on the inner `input` element. Must be in the format `attr1=value1,attr2=value2`.
|
|
695
|
+
- `force-init-change`: This attribute can be used to ensure that an `input-provider` of type `select` will trigger a change when initialized with a default (non-empty option). By default, the `input-provider` does not trigger a change when initialized with a default value.
|
|
695
696
|
|
|
696
697
|
### input-combiner
|
|
697
698
|
|
package/input-provider.js
CHANGED
|
@@ -70,6 +70,10 @@ class InputProvider extends HTMLElement {
|
|
|
70
70
|
|
|
71
71
|
set value(newValue) {
|
|
72
72
|
if (this.inputElement) {
|
|
73
|
+
let forceInitChange = this.forceTriggerChange;
|
|
74
|
+
if (forceInitChange) {
|
|
75
|
+
delete this.forceTriggerChange;
|
|
76
|
+
}
|
|
73
77
|
if (newValue && this.hasAttribute('computable-value')) {
|
|
74
78
|
newValue = renderTemplate(newValue);
|
|
75
79
|
}
|
|
@@ -82,15 +86,14 @@ class InputProvider extends HTMLElement {
|
|
|
82
86
|
} else {
|
|
83
87
|
this.inputElement.checked = newValue;
|
|
84
88
|
}
|
|
85
|
-
if (oldValue !== newValue) {
|
|
89
|
+
if (oldValue !== newValue || forceInitChange) {
|
|
86
90
|
this.triggerChange();
|
|
87
91
|
}
|
|
88
92
|
return;
|
|
89
93
|
}
|
|
90
94
|
oldValue = this.inputElement.value;
|
|
91
95
|
this.inputElement.value = newValue;
|
|
92
|
-
if (oldValue !== newValue ||
|
|
93
|
-
delete this.forceTriggerChange;
|
|
96
|
+
if (oldValue !== newValue || forceInitChange) {
|
|
94
97
|
this.triggerChange();
|
|
95
98
|
}
|
|
96
99
|
}
|
|
@@ -131,13 +134,18 @@ class InputProvider extends HTMLElement {
|
|
|
131
134
|
this.inputElement = document.createElement(elementType);
|
|
132
135
|
if (type === 'select') {
|
|
133
136
|
if (options) {
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
let {
|
|
138
|
+
fieldNames: optionNames,
|
|
139
|
+
fieldValues: optionValues
|
|
140
|
+
} = convertStringToFieldParams(options);
|
|
141
|
+
|
|
142
|
+
let optionElements = optionNames
|
|
143
|
+
.map((optionName) => {
|
|
144
|
+
let optionValue = optionValues[optionName] || optionName;
|
|
145
|
+
if (optionName === placeholder) {
|
|
146
|
+
return `<option value="" selected class="select-default-option">${optionName}</option>`;
|
|
139
147
|
}
|
|
140
|
-
return `<option value="${
|
|
148
|
+
return `<option value="${optionValue}">${optionName}</option>`;
|
|
141
149
|
})
|
|
142
150
|
.join('');
|
|
143
151
|
this.inputElement.innerHTML = optionElements;
|
|
@@ -176,11 +184,8 @@ class InputProvider extends HTMLElement {
|
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
|
|
179
|
-
if (type === 'select') {
|
|
180
|
-
|
|
181
|
-
if (!value) {
|
|
182
|
-
value = this.inputElement.value;
|
|
183
|
-
}
|
|
187
|
+
if (type === 'select' && !value) {
|
|
188
|
+
value = this.inputElement.value;
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
this.updateInputClassList(value);
|
|
@@ -189,6 +194,9 @@ class InputProvider extends HTMLElement {
|
|
|
189
194
|
let destroyHandlers = this.updateConsumerElementsOnEdit();
|
|
190
195
|
|
|
191
196
|
if (value) {
|
|
197
|
+
if (this.hasAttribute('force-init-change')) {
|
|
198
|
+
this.forceTriggerChange = true;
|
|
199
|
+
}
|
|
192
200
|
this.value = value;
|
|
193
201
|
}
|
|
194
202
|
|