tycho-components 0.2.1-SNAPSHOT-2 → 0.2.1-SNAPSHOT-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppTable/types/AppPage.d.ts +2 -0
- package/dist/SentenceView/SentenceMorphemeTiers.js +1 -1
- package/dist/VirtualKeyboard/KeyboardCustomLayout.d.ts +4 -0
- package/dist/VirtualKeyboard/KeyboardCustomLayout.js +33 -0
- package/dist/VirtualKeyboard/VirtualKeyboard.js +76 -5
- package/dist/configs/types/Parameter.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import SentenceUtils from '../functions/SentenceUtils';
|
|
|
4
4
|
import SentenceMorphemeTags from './SentenceMorphemeTags';
|
|
5
5
|
import './style.scss';
|
|
6
6
|
export default function SentenceMorphemeTiers({ struct, morphemeTiers, }) {
|
|
7
|
-
const { t } = useTranslation(
|
|
7
|
+
const { t } = useTranslation('sentence');
|
|
8
8
|
const { skipToken } = SentenceUtils;
|
|
9
9
|
return (_jsxs(_Fragment, { children: [_jsxs("tr", { children: [_jsx("td", { children: t('label.morphemes') }), struct.tokens.map((thisToken, idx) => {
|
|
10
10
|
const elements = [];
|
|
@@ -5,4 +5,8 @@ export type KeyboardLayout = {
|
|
|
5
5
|
};
|
|
6
6
|
display: Record<string, string>;
|
|
7
7
|
};
|
|
8
|
+
export declare const COMBINING_MACRON = "\u0304";
|
|
9
|
+
export declare const COMBINING_DIAERESIS = "\u0308";
|
|
10
|
+
export declare const COMBINING_DOT_ABOVE = "\u0307";
|
|
8
11
|
export declare const KeyboardCustomLayouts: Record<string, KeyboardLayout>;
|
|
12
|
+
export declare const deadKeyMap: Record<string, Record<string, string>>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export const COMBINING_MACRON = '\u0304';
|
|
2
|
+
export const COMBINING_DIAERESIS = '\u0308';
|
|
3
|
+
export const COMBINING_DOT_ABOVE = '\u0307';
|
|
1
4
|
export const KeyboardCustomLayouts = {
|
|
2
5
|
kadiwéu: {
|
|
3
6
|
layout: {
|
|
@@ -22,4 +25,34 @@ export const KeyboardCustomLayouts = {
|
|
|
22
25
|
'{space}': '␣',
|
|
23
26
|
},
|
|
24
27
|
},
|
|
28
|
+
linklado: {
|
|
29
|
+
layout: {
|
|
30
|
+
default: [
|
|
31
|
+
'1 2 3 4 5 6 7 8 9 0',
|
|
32
|
+
'q w e r t y u ᵾ i ɨ o p',
|
|
33
|
+
"a s d f g h j k l ' ~",
|
|
34
|
+
'z x c v b n ñ m',
|
|
35
|
+
'{shift} {space} {bksp}',
|
|
36
|
+
],
|
|
37
|
+
shift: [
|
|
38
|
+
'! ¯ ¨ ´ ` ^ ˙ * ( )',
|
|
39
|
+
'Q W E R T Y U Ʉ I Ɨ O P',
|
|
40
|
+
'A S D F G H J K L',
|
|
41
|
+
'Z X C V B N Ñ M',
|
|
42
|
+
'{shift} {space} {bksp}',
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
display: {
|
|
46
|
+
'{bksp}': '⌫',
|
|
47
|
+
'{shift}': '⇧',
|
|
48
|
+
'{space}': '␣',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export const deadKeyMap = {
|
|
53
|
+
'~': { a: 'ã', o: 'õ', A: 'Ã', O: 'Õ' },
|
|
54
|
+
'`': { a: 'à', e: 'è', i: 'ì', o: 'ò', u: 'ù' },
|
|
55
|
+
"'": { a: 'á', e: 'é', i: 'í', o: 'ó', u: 'ú', c: 'ć' },
|
|
56
|
+
'^': { a: 'â', e: 'ê', i: 'î', o: 'ô', u: 'û' },
|
|
57
|
+
'"': { a: 'ä', e: 'ë', i: 'ï', o: 'ö', u: 'ü', y: 'ÿ' },
|
|
25
58
|
};
|
|
@@ -7,7 +7,7 @@ import Keyboard from 'react-simple-keyboard';
|
|
|
7
7
|
import 'react-simple-keyboard/build/css/index.css';
|
|
8
8
|
import KeyboardLayouts from 'simple-keyboard-layouts';
|
|
9
9
|
import { Button, getCurrentInput, getCurrentOnChange, removeCurrentInput, selectFieldTheme, } from 'tycho-storybook';
|
|
10
|
-
import { KeyboardCustomLayouts } from './KeyboardCustomLayout';
|
|
10
|
+
import { COMBINING_DIAERESIS, COMBINING_DOT_ABOVE, COMBINING_MACRON, deadKeyMap, KeyboardCustomLayouts, } from './KeyboardCustomLayout';
|
|
11
11
|
import './style.scss';
|
|
12
12
|
export default function VirtualKeyboard({ onClose, defaultLayout, closeLabel = 'Close', }) {
|
|
13
13
|
const outerTheme = useTheme();
|
|
@@ -20,6 +20,7 @@ export default function VirtualKeyboard({ onClose, defaultLayout, closeLabel = '
|
|
|
20
20
|
const [layout, setLayout] = useState();
|
|
21
21
|
const [layoutName, setLayoutName] = useState('default');
|
|
22
22
|
const [selected, setSelected] = useState(defaultLayout);
|
|
23
|
+
const [deadKey, setDeadKey] = useState(null);
|
|
23
24
|
const getLayoutByName = (name) => layouts.get(name) || KeyboardCustomLayouts[name];
|
|
24
25
|
const handleChangeLayout = (lang) => {
|
|
25
26
|
setSelected(lang);
|
|
@@ -45,11 +46,67 @@ export default function VirtualKeyboard({ onClose, defaultLayout, closeLabel = '
|
|
|
45
46
|
const start = input.selectionStart || 0;
|
|
46
47
|
const end = input.selectionEnd || 0;
|
|
47
48
|
const value = input.value;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
let newValue = value;
|
|
50
|
+
if (button === '{bksp}') {
|
|
51
|
+
newValue = value.slice(0, -1);
|
|
52
|
+
input.setSelectionRange(start - 1, start - 1);
|
|
53
|
+
}
|
|
54
|
+
else if (deadKey) {
|
|
55
|
+
if (deadKey === '¯') {
|
|
56
|
+
// Macron dead key → works on ANY letter
|
|
57
|
+
newValue =
|
|
58
|
+
value.slice(0, start) +
|
|
59
|
+
button +
|
|
60
|
+
COMBINING_MACRON +
|
|
61
|
+
value.slice(end);
|
|
62
|
+
input.setSelectionRange(start + 2, start + 2);
|
|
63
|
+
}
|
|
64
|
+
else if (deadKey === '¨') {
|
|
65
|
+
// Diaeresis: works universally
|
|
66
|
+
newValue =
|
|
67
|
+
value.slice(0, start) +
|
|
68
|
+
button +
|
|
69
|
+
COMBINING_DIAERESIS +
|
|
70
|
+
value.slice(end);
|
|
71
|
+
input.setSelectionRange(start + 2, start + 2);
|
|
72
|
+
}
|
|
73
|
+
else if (deadKey === '˙') {
|
|
74
|
+
// dot above
|
|
75
|
+
newValue =
|
|
76
|
+
value.slice(0, start) +
|
|
77
|
+
button +
|
|
78
|
+
COMBINING_DOT_ABOVE +
|
|
79
|
+
value.slice(end);
|
|
80
|
+
input.setSelectionRange(start + 2, start + 2);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Normal accent map
|
|
84
|
+
const composed = deadKeyMap[deadKey]?.[button];
|
|
85
|
+
if (composed) {
|
|
86
|
+
newValue = value.slice(0, start) + composed + value.slice(end);
|
|
87
|
+
input.setSelectionRange(start + 1, start + 1);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// no composition found → insert both
|
|
91
|
+
newValue =
|
|
92
|
+
value.slice(0, start) + deadKey + button + value.slice(end);
|
|
93
|
+
input.setSelectionRange(start + 2, start + 2);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
setDeadKey(null);
|
|
97
|
+
}
|
|
98
|
+
else if (deadKeyMap[button] ||
|
|
99
|
+
button === '¯' ||
|
|
100
|
+
button === '¨' ||
|
|
101
|
+
button === '˙') {
|
|
102
|
+
setDeadKey(button);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
newValue = value.slice(0, start) + button + value.slice(end);
|
|
107
|
+
input.setSelectionRange(start + 1, start + 1);
|
|
108
|
+
}
|
|
51
109
|
input.value = newValue;
|
|
52
|
-
input.setSelectionRange(start + 1, start + 1);
|
|
53
110
|
input.focus();
|
|
54
111
|
onChange({ target: input });
|
|
55
112
|
}
|
|
@@ -61,6 +118,20 @@ export default function VirtualKeyboard({ onClose, defaultLayout, closeLabel = '
|
|
|
61
118
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
62
119
|
layout: layout }) }), _jsxs("div", { className: "footer", children: [_jsx(ThemeProvider, { theme: selectFieldTheme(outerTheme), children: _jsx(Select, { value: selected, fullWidth: true, variant: "filled", color: "primary", className: "select-layout", onChange: (e) => {
|
|
63
120
|
handleChangeLayout(e.target.value);
|
|
121
|
+
}, MenuProps: {
|
|
122
|
+
anchorOrigin: {
|
|
123
|
+
vertical: 'top',
|
|
124
|
+
horizontal: 'left',
|
|
125
|
+
},
|
|
126
|
+
transformOrigin: {
|
|
127
|
+
vertical: 'bottom',
|
|
128
|
+
horizontal: 'left',
|
|
129
|
+
},
|
|
130
|
+
PaperProps: {
|
|
131
|
+
style: {
|
|
132
|
+
maxHeight: 200,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
64
135
|
}, children: layoutNames.map((option, idx) => (_jsx(MenuItem, { value: option, children: option }, idx.valueOf()))) }) }), _jsx(Button, { onClick: () => {
|
|
65
136
|
removeCurrentInput();
|
|
66
137
|
onClose();
|