@sankhyalabs/core 7.0.6 → 7.0.8

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.
@@ -93,6 +93,10 @@ const getOptionFormat = (value: any, descriptor: FieldDescriptor) => {
93
93
  } else {
94
94
  options = {};
95
95
  if(prop != undefined){
96
+ if (descriptor.properties?.switchLabelsAndValues) {
97
+ prop.forEach(opt => options[opt.value] = opt.label);
98
+ }
99
+
96
100
  prop.forEach(opt => options[opt.label] = opt.value);
97
101
  }
98
102
  }
@@ -424,6 +424,6 @@ export default class FloatingManager {
424
424
  }
425
425
 
426
426
  private static getHighestZIndex(){
427
- return this.overlayElements.reduce((acc, curr) => acc + Number(this.getCSSPropertyValue(curr, 'z-index') || ''), 0);
427
+ return this.overlayElements.reduce((acc, curr) => Math.max(acc, Number(this.getCSSPropertyValue(curr, 'z-index')) || 0), 0);
428
428
  }
429
429
  }
@@ -154,6 +154,18 @@ describe('getFormattedValue', () => {
154
154
  expect(getFormattedValue(value, descriptor)).toBe('option1');
155
155
  });
156
156
 
157
+ it('should return label when OPTIONSELECTOR has switchLabelsAndValues and value matches option value', () => {
158
+ const value = 'option1';
159
+ const descriptor: FieldDescriptor = {
160
+ userInterface: UserInterface.OPTIONSELECTOR,
161
+ properties: {
162
+ options: [{ label: 'Option 1', value: 'option1' }],
163
+ switchLabelsAndValues: true,
164
+ },
165
+ } as FieldDescriptor;
166
+ expect(getFormattedValue(value, descriptor)).toBe('Option 1');
167
+ });
168
+
157
169
  it('should format masked values correctly', () => {
158
170
  const value = '12345678901';
159
171
  const descriptor = { properties: { mask: 'cpf' } } as FieldDescriptor;