1 | /*
|
2 | * Copyright 2021 Palantir Technologies, Inc. All rights reserved.
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 |
|
17 | import classNames from "classnames";
|
18 | import * as React from "react";
|
19 |
|
20 | import { Classes } from "../../common";
|
21 | import { HotkeyConfig } from "../../hooks";
|
22 | import { Dialog, DialogProps } from "../dialog/dialog";
|
23 | import { Hotkey } from "./hotkey";
|
24 | import { Hotkeys } from "./hotkeys";
|
25 |
|
26 | export interface HotkeysDialog2Props extends DialogProps {
|
27 | /**
|
28 | * This string displayed as the group name in the hotkeys dialog for all
|
29 | * global hotkeys.
|
30 | */
|
31 | globalGroupName?: string;
|
32 |
|
33 | hotkeys: HotkeyConfig[];
|
34 | }
|
35 |
|
36 | export const HotkeysDialog2: React.FC<HotkeysDialog2Props> = ({ globalGroupName = "Global", hotkeys, ...props }) => {
|
37 | return (
|
38 | <Dialog {...props} className={classNames(Classes.HOTKEY_DIALOG, props.className)}>
|
39 | <div className={Classes.DIALOG_BODY}>
|
40 | <Hotkeys>
|
41 | {hotkeys.map((hotkey, index) => (
|
42 | <Hotkey
|
43 | key={index}
|
44 | {...hotkey}
|
45 | group={hotkey.global === true && hotkey.group == null ? globalGroupName : hotkey.group}
|
46 | />
|
47 | ))}
|
48 | </Hotkeys>
|
49 | </div>
|
50 | </Dialog>
|
51 | );
|
52 | };
|