@bpmn-io/form-js-editor 0.13.1 → 0.14.1

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/dist/index.es.js CHANGED
@@ -7513,7 +7513,7 @@ function Label(props) {
7513
7513
  id,
7514
7514
  label: 'Label',
7515
7515
  setValue,
7516
- validate: validateFactory(getValue())
7516
+ validate: validateFactory(getValue(), entry => entry.label)
7517
7517
  });
7518
7518
  }
7519
7519
  function Value$1(props) {
@@ -7539,7 +7539,7 @@ function Value$1(props) {
7539
7539
  id,
7540
7540
  label: 'Value',
7541
7541
  setValue,
7542
- validate: validateFactory(getValue())
7542
+ validate: validateFactory(getValue(), entry => entry.value)
7543
7543
  });
7544
7544
  }
7545
7545
 
@@ -7781,13 +7781,13 @@ function StaticValuesSourceEntry(props) {
7781
7781
  const addEntry = e => {
7782
7782
  e.stopPropagation();
7783
7783
  const index = values.length + 1;
7784
- const entry = getIndexedEntry(index);
7784
+ const entry = getIndexedEntry(index, values);
7785
7785
  editField(field, VALUES_SOURCES_PATHS[VALUES_SOURCES.STATIC], arrayAdd(values, values.length, entry));
7786
7786
  };
7787
7787
  const removeEntry = entry => {
7788
7788
  editField(field, VALUES_SOURCES_PATHS[VALUES_SOURCES.STATIC], without(values, entry));
7789
7789
  };
7790
- const validateFactory = key => {
7790
+ const validateFactory = (key, getValue) => {
7791
7791
  return value => {
7792
7792
  if (value === key) {
7793
7793
  return;
@@ -7795,7 +7795,7 @@ function StaticValuesSourceEntry(props) {
7795
7795
  if (isUndefined(value) || !value.length) {
7796
7796
  return 'Must not be empty.';
7797
7797
  }
7798
- const isValueAssigned = values.find(entry => entry.value === value);
7798
+ const isValueAssigned = values.find(entry => getValue(entry) === value);
7799
7799
  if (isValueAssigned) {
7800
7800
  return 'Must be unique.';
7801
7801
  }
@@ -7826,17 +7826,23 @@ function StaticValuesSourceEntry(props) {
7826
7826
 
7827
7827
  // helper
7828
7828
 
7829
- function getIndexedEntry(index) {
7829
+ function getIndexedEntry(index, values) {
7830
7830
  const entry = {
7831
7831
  label: 'Value',
7832
7832
  value: 'value'
7833
7833
  };
7834
+ while (labelOrValueIsAlreadyAssignedForIndex(index, values)) {
7835
+ index++;
7836
+ }
7834
7837
  if (index > 1) {
7835
7838
  entry.label += ` ${index}`;
7836
7839
  entry.value += `${index}`;
7837
7840
  }
7838
7841
  return entry;
7839
7842
  }
7843
+ function labelOrValueIsAlreadyAssignedForIndex(index, values) {
7844
+ return values.some(existingEntry => existingEntry.label === `Value ${index}` || existingEntry.value === `value${index}`);
7845
+ }
7840
7846
 
7841
7847
  function AdornerEntry(props) {
7842
7848
  const {
@@ -8065,7 +8071,7 @@ function ValidationGroup(field, editField) {
8065
8071
  } = field;
8066
8072
  const validate = get(field, ['validate'], {});
8067
8073
  const isCustomValidation = [undefined, VALIDATION_TYPE_OPTIONS.custom.value].includes(validate.validationType);
8068
- if (!(INPUTS.includes(type) && type !== 'checkbox' && type !== 'checklist' && type !== 'taglist')) {
8074
+ if (!INPUTS.includes(type)) {
8069
8075
  return null;
8070
8076
  }
8071
8077
  const onChange = key => {
@@ -8337,12 +8343,13 @@ function CustomValuesGroup(field, editField) {
8337
8343
  }
8338
8344
  const addEntry = event => {
8339
8345
  event.stopPropagation();
8340
- const index = Object.keys(properties).length + 1;
8341
- const key = `key${index}`,
8342
- value = 'value';
8346
+ let index = Object.keys(properties).length + 1;
8347
+ while (`key${index}` in properties) {
8348
+ index++;
8349
+ }
8343
8350
  editField(field, ['properties'], {
8344
8351
  ...properties,
8345
- [key]: value
8352
+ [`key${index}`]: 'value'
8346
8353
  });
8347
8354
  };
8348
8355
  const validateFactory = key => {