({ items, key, value })
| 103 | } |
| 104 | |
| 105 | static getSelectedItem({ items, key, value }) { |
| 106 | let idx = items.findIndex((item) => { |
| 107 | if (item.key && key) { |
| 108 | return isEqual(item.key, key); |
| 109 | } |
| 110 | if (isObject(item.value) || isObject(value)) { |
| 111 | return isEqual(item.value, value); |
| 112 | } |
| 113 | // convert to string to make sure types match |
| 114 | return isEqual(String(item.value), String(value)); |
| 115 | }); |
| 116 | if (idx === -1) { |
| 117 | idx = 0; |
| 118 | } |
| 119 | return { |
| 120 | selectedItem: items[idx] || {}, |
| 121 | idx, |
| 122 | }; |
| 123 | } |
| 124 | |
| 125 | constructor(props) { |
| 126 | super(props); |
nothing calls this directly
no outgoing calls
no test coverage detected