saasufy-components 8.2.1 → 8.2.2

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/input-provider.js CHANGED
@@ -2,7 +2,8 @@ import {
2
2
  debouncer,
3
3
  renderTemplate,
4
4
  updateConsumerElements,
5
- convertStringToFieldParams
5
+ convertStringToFieldParams,
6
+ convertStringToFieldTypeValues
6
7
  } from './utils.js';
7
8
 
8
9
  const DEFAULT_DEBOUNCE_DELAY = 800;
@@ -136,18 +137,13 @@ class InputProvider extends HTMLElement {
136
137
  this.inputElement = document.createElement(elementType);
137
138
  if (type === 'select') {
138
139
  if (options != null) {
139
- let {
140
- fieldNames: optionNames,
141
- fieldValues: optionValues
142
- } = convertStringToFieldParams(options, true, true);
143
-
144
- let optionElements = optionNames
145
- .map((optionName) => {
146
- let optionValue = optionValues[optionName] || optionName;
147
- if (optionName === placeholder) {
148
- return `<option value="" selected class="select-default-option">${optionName}</option>`;
140
+ let fieldTypeValues = convertStringToFieldTypeValues(options, true, true);
141
+ let optionElements = fieldTypeValues
142
+ .map((option) => {
143
+ if (option.field === placeholder) {
144
+ return `<option value="" selected class="select-default-option">${option.field}</option>`;
149
145
  }
150
- return `<option value="${optionValue}">${optionName}</option>`;
146
+ return `<option value="${option.value}">${option.field}</option>`;
151
147
  })
152
148
  .join('');
153
149
  this.inputElement.innerHTML = optionElements;
package/model-input.js CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  debouncer,
4
4
  updateConsumerElements,
5
5
  convertStringToFieldParams,
6
+ convertStringToFieldTypeValues,
6
7
  formatError
7
8
  } from './utils.js';
8
9
  import AGModel from '/node_modules/ag-model/ag-model.js';
@@ -207,18 +208,13 @@ class ModelInput extends SocketConsumer {
207
208
  let optionList = null;
208
209
  if (type === 'select') {
209
210
  if (options != null) {
210
- let {
211
- fieldNames: optionNames,
212
- fieldValues: optionValues
213
- } = convertStringToFieldParams(options, true, true);
214
-
215
- let optionElements = optionNames
216
- .map((optionName) => {
217
- let optionValue = optionValues[optionName] || optionName;
218
- if (optionName === placeholder) {
219
- return `<option value="" selected class="select-default-option">${optionName}</option>`;
211
+ let fieldTypeValues = convertStringToFieldTypeValues(options, true, true);
212
+ let optionElements = fieldTypeValues
213
+ .map((option) => {
214
+ if (option.field === placeholder) {
215
+ return `<option value="" selected class="select-default-option">${option.field}</option>`;
220
216
  }
221
- return `<option value="${optionValue}">${optionName}</option>`;
217
+ return `<option value="${option.value}">${option.field}</option>`;
222
218
  })
223
219
  .join('');
224
220
  this.inputElement.innerHTML = optionElements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "8.2.1",
3
+ "version": "8.2.2",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/utils.js CHANGED
@@ -462,10 +462,10 @@ export function getTypeCastFunction(type) {
462
462
  return typeCastFunctions[type] || ((value) => value);
463
463
  }
464
464
 
465
- export function convertStringToFieldParams(string, allowEmpty, unescapeEqual) {
465
+ export function convertStringToFieldTypeValues(string, allowEmpty, unescapeEqual) {
466
466
  let partsRegExp = allowEmpty ? fieldPartsRegExpWithEmpty : fieldPartsRegExp;
467
467
  let parts = ((string || '').match(partsRegExp) || []).map(field => field.trim());
468
- let fieldTypeValues = parts.map((part) => {
468
+ return parts.map((part) => {
469
469
  let subParts;
470
470
  if (unescapeEqual) {
471
471
  subParts = part.split(unescapedEqualRegExp).map(unescapeEqualSigns);
@@ -473,25 +473,29 @@ export function convertStringToFieldParams(string, allowEmpty, unescapeEqual) {
473
473
  subParts = part.split(unescapedEqualRegExp);
474
474
  }
475
475
  let nameType = (subParts[0] || '').split(':');
476
- let name = nameType[0];
476
+ let field = nameType[0];
477
477
  let type = nameType[1] || 'text';
478
478
  let value = subParts.slice(1).join('=').replace(quotedContentRegExp, '$1');
479
479
  return {
480
- name,
480
+ field,
481
481
  type,
482
482
  value
483
483
  }
484
484
  });
485
- let fieldNames = fieldTypeValues.map(item => item.name);
485
+ }
486
+
487
+ export function convertStringToFieldParams(string, allowEmpty, unescapeEqual) {
488
+ let fieldTypeValues = convertStringToFieldTypeValues(string, allowEmpty, unescapeEqual);
489
+ let fieldNames = fieldTypeValues.map(item => item.field);
486
490
  let fieldTypes = Object.fromEntries(
487
- fieldTypeValues.map(item => [ item.name, item.type ])
491
+ fieldTypeValues.map(item => [ item.field, item.type ])
488
492
  );
489
493
  let fieldValues = Object.fromEntries(
490
494
  fieldTypeValues.map(
491
495
  (item) => {
492
- let type = fieldTypes[item.name];
496
+ let type = fieldTypes[item.field];
493
497
  let Type = getTypeCastFunction(type);
494
- return [ item.name, Type(item.value) ];
498
+ return [ item.field, Type(item.value) ];
495
499
  }
496
500
  )
497
501
  );