haya-select 1.0.33 → 1.0.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haya-select",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -557,6 +557,10 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
557
557
  const toggledValue = toggled[option.value]
558
558
  const toggledOption = toggleOptions.find((element) => element.value == toggledValue)
559
559
 
560
+ if (!toggledOption) {
561
+ throw new Error(`Couldn't find a toggle option for value: ${toggledValue}`)
562
+ }
563
+
560
564
  return toggledOption.icon
561
565
  }
562
566
  }
@@ -565,12 +569,14 @@ export default memo(shapeComponent(class HayaSelect extends ShapeComponent {
565
569
  const {toggleOptions} = this.props || {}
566
570
  const toggled = this.getToggled()
567
571
  const icon = this.iconForOption(currentValue)
572
+ const toggleValue = toggled[currentValue.value]
573
+ const toggleOption = toggleOptions.find((toggleOptionI) => toggleOptionI.value == toggleValue)
568
574
 
569
575
  return (
570
576
  <div
571
577
  className="haya-select-option-presentation"
572
- data-toggle-icon={toggleOptions && toggled && toggleOptions[toggled[currentValue.value]]?.icon}
573
- data-toggle-value={toggleOptions && toggled && toggleOptions[toggled[currentValue.value]]?.value}
578
+ data-toggle-icon={toggleOption?.icon}
579
+ data-toggle-value={toggleOption?.value}
574
580
  data-value={currentValue.value}
575
581
  >
576
582
  {toggleOptions && !(currentValue.value in toggled) &&