CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/account/editor-settings/x11-keyboard.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { useIntl } from "react-intl";
7
8
import {
9
LabeledRow,
10
Loading,
11
SelectorInput,
12
} from "@cocalc/frontend/components";
13
import { PHYSICAL_KEYBOARDS } from "@cocalc/frontend/frame-editors/x11-editor/xpra/keyboards";
14
15
interface PhysicalKeyboardProps {
16
physical_keyboard: string;
17
on_change: (selected: string) => void;
18
}
19
20
export function EditorSettingsPhysicalKeyboard(
21
props: PhysicalKeyboardProps,
22
): JSX.Element {
23
const intl = useIntl();
24
25
if (props.physical_keyboard === "NO_DATA") {
26
return <Loading />;
27
} else {
28
const label = intl.formatMessage({
29
id: "account.editor-settings.x11-physical-keyboard.label",
30
defaultMessage: "Keyboard layout (for X11 Desktop)",
31
});
32
33
return (
34
<LabeledRow label={label}>
35
<SelectorInput
36
options={PHYSICAL_KEYBOARDS}
37
selected={props.physical_keyboard}
38
on_change={props.on_change}
39
showSearch={true}
40
/>
41
</LabeledRow>
42
);
43
}
44
}
45
46
interface KeyboardVariantProps {
47
keyboard_variant: string;
48
on_change: (selected: string) => void;
49
keyboard_variant_options: { value: string; display: string }[];
50
}
51
52
export function EditorSettingsKeyboardVariant(
53
props: KeyboardVariantProps,
54
): JSX.Element {
55
const intl = useIntl();
56
57
if (props.keyboard_variant === "NO_DATA") {
58
return <Loading />;
59
} else {
60
const label = intl.formatMessage({
61
id: "account.editor-settings.x11-keyboard-variant.label",
62
defaultMessage: "Keyboard variant (for X11 Desktop)",
63
});
64
65
return (
66
<LabeledRow label={label}>
67
<SelectorInput
68
options={props.keyboard_variant_options}
69
selected={props.keyboard_variant}
70
on_change={props.on_change}
71
showSearch={true}
72
/>
73
</LabeledRow>
74
);
75
}
76
}
77
78