-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Controls: Fix controls without options and add warning
- Loading branch information
Showing
5 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { OptionsObject } from '../types'; | ||
|
||
export const selectedKey = (value: any, options: OptionsObject) => { | ||
const entry = Object.entries(options).find(([_key, val]) => val === value); | ||
const entry = options && Object.entries(options).find(([_key, val]) => val === value); | ||
return entry ? entry[0] : undefined; | ||
}; | ||
|
||
export const selectedKeys = (value: any[], options: OptionsObject) => | ||
value | ||
value && options | ||
? Object.entries(options) | ||
.filter((entry) => value.includes(entry[1])) | ||
.map((entry) => entry[0]) | ||
: []; | ||
|
||
export const selectedValues = (keys: string[], options: OptionsObject) => | ||
keys.map((key) => options[key]); | ||
keys && options && keys.map((key) => options[key]); |