UNPKG

1.86 kBTypeScriptView Raw
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
17import classNames from "classnames";
18import * as React from "react";
19
20import { Classes } from "../../common";
21import { HotkeyConfig } from "../../hooks";
22import { Dialog, DialogProps } from "../dialog/dialog";
23import { Hotkey } from "./hotkey";
24import { Hotkeys } from "./hotkeys";
25
26export 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
36export 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};