saasufy-components 6.0.4 → 6.1.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 +5 -2
- package/package.json +1 -1
- package/utils.js +6 -3
package/README.md
CHANGED
|
@@ -693,6 +693,7 @@ This component can be configured to provide its data to multiple components (con
|
|
|
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
695
|
- `skip-init-change`: This attribute can be used to prevent an `input-provider` of type `select` from triggering a change when initialized with a default option. By default, the `input-provider` will trigger a change when initialized with a default value.
|
|
696
|
+
- `force-init-change`: This attribute can be used to force an `input-provider` to always trigger a change when initialized, even if the value is empty.
|
|
696
697
|
|
|
697
698
|
### input-combiner
|
|
698
699
|
|
package/input-provider.js
CHANGED
|
@@ -137,7 +137,7 @@ class InputProvider extends HTMLElement {
|
|
|
137
137
|
let {
|
|
138
138
|
fieldNames: optionNames,
|
|
139
139
|
fieldValues: optionValues
|
|
140
|
-
} = convertStringToFieldParams(options);
|
|
140
|
+
} = convertStringToFieldParams(options, true);
|
|
141
141
|
|
|
142
142
|
let optionElements = optionNames
|
|
143
143
|
.map((optionName) => {
|
|
@@ -193,7 +193,10 @@ class InputProvider extends HTMLElement {
|
|
|
193
193
|
|
|
194
194
|
let destroyHandlers = this.updateConsumerElementsOnEdit();
|
|
195
195
|
|
|
196
|
-
if (
|
|
196
|
+
if (this.hasAttribute('force-init-change')) {
|
|
197
|
+
this.forceTriggerChange = true;
|
|
198
|
+
this.value = value;
|
|
199
|
+
} else if (value) {
|
|
197
200
|
if (type === 'select' && !this.hasAttribute('skip-init-change')) {
|
|
198
201
|
this.forceTriggerChange = true;
|
|
199
202
|
}
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -373,7 +373,9 @@ export function generateRandomHexString(byteLength) {
|
|
|
373
373
|
}).join('');
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
export const fieldPartsRegExp = /(
|
|
376
|
+
export const fieldPartsRegExp = /("[^"]*"|'[^']*'|\([^)]*\)|[^,()"']+)+/g;
|
|
377
|
+
export const fieldPartsRegExpWithEmpty = /((^|(?<=,))((?=,)|$)|"[^"]*"|'[^']*'|\([^)]*\)|[^,()"']+)+/g
|
|
378
|
+
|
|
377
379
|
export const quotedContentRegExp = /^\s*["']?(.*?)["']?\s*$/;
|
|
378
380
|
|
|
379
381
|
export function toBoolean(value) {
|
|
@@ -396,8 +398,9 @@ export function getTypeCastFunction(type) {
|
|
|
396
398
|
return typeCastFunctions[type] || ((value) => value);
|
|
397
399
|
}
|
|
398
400
|
|
|
399
|
-
export function convertStringToFieldParams(string) {
|
|
400
|
-
let
|
|
401
|
+
export function convertStringToFieldParams(string, allowEmpty) {
|
|
402
|
+
let partsRegExp = allowEmpty ? fieldPartsRegExpWithEmpty : fieldPartsRegExp;
|
|
403
|
+
let parts = ((string || '').match(partsRegExp) || []).map(field => field.trim());
|
|
401
404
|
let fieldTypeValues = parts.map((part) => {
|
|
402
405
|
let subParts = part.split('=');
|
|
403
406
|
let nameType = (subParts[0] || '').split(':');
|