@uyghurcommunity/keyboard 0.0.0-stage → 0.3.0
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/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +213 -2
- package/dist/uyghur-keyboard.js +738 -0
- package/docs/layouts.md +43 -0
- package/package.json +26 -4
- package/src/element.d.ts +1 -0
- package/src/element.js +3 -0
- package/src/index.d.ts +65 -0
- package/src/index.js +473 -0
- package/src/layouts.js +121 -0
- package/src/navigation.js +45 -0
- package/src/style.js +97 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
- **The standard Uyghur computer layout (`uey-desktop`) is now the default**, for `createKeyboard()` and `<uyghur-keyboard>`. It is the layout built into Windows, macOS and Linux and taught by typing trainers, so the on-screen keys match a real Uyghur keyboard. It is listed first and labelled "Standard Uyghur (UEY)".
|
|
6
|
+
- To keep the previous behaviour, pass `layout: 'phonetic'` (or `layout="phonetic"` on the element).
|
|
7
|
+
- Export `DEFAULT_LAYOUT`. A new test pins every letter of the standard layout, base and Shift, to its key.
|
|
8
|
+
- **Key legends:** on the standard layout, each key shows its Shift letter (D: د and ژ) and its Latin key cap, like a printed Uyghur keyboard. Turn them off with `legends: false` or `setLegends(false)`.
|
|
9
|
+
- **Pressed keys light up:** pressing a key on a real keyboard highlights the matching on-screen key, by key position (`KeyboardEvent.code`) whatever layout the operating system uses, so the keyboard doubles as a layout guide.
|
|
10
|
+
- Shift and Delete show Uyghur UI icons instead of the ⇧ and ⌫ characters.
|
|
11
|
+
- Demo page: options and notes in Uyghur, a layout guide, an install command with a copy button, and Uyghur UI icons instead of arrow characters.
|
|
12
|
+
|
|
13
|
+
## 0.2.0
|
|
14
|
+
|
|
15
|
+
- Add data-driven layouts with a layout selector and a controller API. Keep the original phonetic layout and exported mappings as the default. Add Arabic desktop (UEY), Latin (ULY) and Cyrillic (USY) layouts.
|
|
16
|
+
- Add independent options for automatic initial hamza, secondary keys, compact mode and light or dark themes.
|
|
17
|
+
- Keep virtual keys at least 44 by 44 CSS pixels and add arrow navigation, visible focus, and English and Uyghur accessible labels.
|
|
18
|
+
- Add a single-file browser module and plain HTML, React and Vue embedding examples.
|
|
19
|
+
- Mark new Uyghur labels, keyboard inventories and typing examples for native-speaker review.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 UyghurCommunity
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,214 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ئۇيغۇرچە كۇنۇپكا تاختىسى · Uyghur Keyboard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A dependency-free virtual keyboard and Web Component for Uyghur Arabic, Latin and Cyrillic text entry. This project runs locally in the browser and sends no text to a server.
|
|
4
|
+
|
|
5
|
+
[Browser demo](https://uyghurcommunity.github.io/uyghur-keyboard/) · [UyghurCommunity](https://github.com/UyghurCommunity)
|
|
6
|
+
|
|
7
|
+
## ئۇيغۇرچە
|
|
8
|
+
|
|
9
|
+
ھەر قانداق تېكىست كىرگۈزۈش رامكىسى ياكى كۆپ قۇرلۇق يېزىش مەيدانىغا ئۇيغۇرچە كۇنۇپكا تاختىسى قوشۇڭ. كورسىر ۋە تاللانغان تېكىست ئورنى ساقلىنىدۇ. ئۆچۈرۈش كۇنۇپكىسى بىرلەشمە ھەرپ ۋە ئېموجىنى پۈتۈن ئۆچۈرىدۇ.
|
|
10
|
+
|
|
11
|
+
- ئۇيغۇرچە ھەرپلەر ۋە ھەمزىلىك سوزۇق تاۋۇش كۇنۇپكىلىرى
|
|
12
|
+
- ئېكراندىكى كۇنۇپكىلار، كۇنۇپكا تاختىسى ۋە تېگىش ئارقىلىق ئىشلىتىش
|
|
13
|
+
- ئىختىيارىي فىزىكىلىق ھەرپ ماسلاشتۇرۇش؛ كۆڭۈلدىكى ھالەتتە تاقاق
|
|
14
|
+
- RTL، تاللانغان تېكىستنى ئالماشتۇرۇش، `beforeinput` ۋە `input` ھادىسىلىرى
|
|
15
|
+
- يەرلىك تور تەركىبى، TypeScript تىپلىرى ۋە تازا ئۆچۈرۈش API سى
|
|
16
|
+
|
|
17
|
+
## Package and source
|
|
18
|
+
|
|
19
|
+
Package name **`@uyghurcommunity/keyboard`** · Version **0.3.0**. Install it from npm:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install @uyghurcommunity/keyboard
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To work on the source, run:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm test
|
|
29
|
+
npm run check
|
|
30
|
+
npm pack
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The browser bundle is included in the repository and package. To run the demo locally, start `python3 -m http.server 4173` from this checkout and open `http://localhost:4173/`.
|
|
34
|
+
|
|
35
|
+
## Embed with one script
|
|
36
|
+
|
|
37
|
+
Copy [`dist/uyghur-keyboard.js`](dist/uyghur-keyboard.js) into the site’s public files and serve it as `/uyghur-keyboard.js`. The module registers the Web Component when loaded. For React and Vue, put the same script tag in your app’s HTML entry point.
|
|
38
|
+
|
|
39
|
+
### Plain HTML
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
43
|
+
<style>textarea { font-size: 16px; }</style>
|
|
44
|
+
<label for="ug-writing">Uyghur text</label>
|
|
45
|
+
<textarea id="ug-writing"></textarea>
|
|
46
|
+
<uyghur-keyboard for="ug-writing" layout="uey-desktop" lang="en"
|
|
47
|
+
auto-hamza secondary-keys></uyghur-keyboard>
|
|
48
|
+
<script type="module" src="/uyghur-keyboard.js"></script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### React
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
import { useId } from 'react';
|
|
55
|
+
|
|
56
|
+
export function UyghurEditor() {
|
|
57
|
+
const id = useId();
|
|
58
|
+
return (
|
|
59
|
+
<section>
|
|
60
|
+
<label htmlFor={id}>Uyghur text</label>
|
|
61
|
+
<textarea id={id} style={{ fontSize: 16 }} />
|
|
62
|
+
<uyghur-keyboard for={id} layout="uly" lang="en" compact="" />
|
|
63
|
+
</section>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Vue
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<template>
|
|
72
|
+
<section>
|
|
73
|
+
<label for="uyghur-editor">Uyghur text</label>
|
|
74
|
+
<textarea id="uyghur-editor" style="font-size: 16px"></textarea>
|
|
75
|
+
<component :is="'uyghur-keyboard'" for="uyghur-editor"
|
|
76
|
+
layout="usy" lang="en" theme="dark" />
|
|
77
|
+
</section>
|
|
78
|
+
</template>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Vanilla JavaScript
|
|
82
|
+
|
|
83
|
+
In an npm project with a module bundler:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
import { createKeyboard } from '@uyghurcommunity/keyboard';
|
|
87
|
+
|
|
88
|
+
const input = document.querySelector('textarea');
|
|
89
|
+
const keyboard = createKeyboard(input, {
|
|
90
|
+
physical: false,
|
|
91
|
+
layout: 'uey-desktop', // the default: the standard Uyghur computer layout
|
|
92
|
+
direction: 'rtl',
|
|
93
|
+
// container: document.querySelector('#keyboard'),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
keyboard.insert('سالام');
|
|
97
|
+
keyboard.backspace();
|
|
98
|
+
keyboard.setPhysicalMapping(true);
|
|
99
|
+
keyboard.setLayout('phonetic');
|
|
100
|
+
keyboard.setTheme('dark');
|
|
101
|
+
keyboard.setVisible(false);
|
|
102
|
+
keyboard.destroy();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Without a bundler, import `./src/index.js` from a local HTTP server. Mount only after the input is in the document, or supply an attached `container`.
|
|
106
|
+
|
|
107
|
+
Supported targets: `textarea` and text-selection-capable inputs (`text`, `search`, `tel`, `url`, `password`). `email` and numeric/date inputs do not support the required selection API.
|
|
108
|
+
|
|
109
|
+
### Options
|
|
110
|
+
|
|
111
|
+
| Option | Default | Behavior |
|
|
112
|
+
| --- | --- | --- |
|
|
113
|
+
| `layout` | `uey-desktop` | The standard Uyghur computer layout (as on Windows, macOS and Linux). Or choose `phonetic`, `uly`, `usy`, or a supplied custom layout ID. |
|
|
114
|
+
| `layouts` | — | Add plain data layouts to the built-ins. |
|
|
115
|
+
| `physical` | `false` | Apply the active layout's physical map when it has one. |
|
|
116
|
+
| `autoHamza` | `false` | Insert `ئ` before a single Arabic-script vowel typed at the beginning of a word. |
|
|
117
|
+
| `secondaryKeys` | `false` | Show supplemental keys such as Uyghur punctuation (، ؛ ؟ « »). |
|
|
118
|
+
| `legends` | `true` | On the standard layout, show each key's Shift letter and Latin key cap. Pressing a real key always lights up its on-screen key. |
|
|
119
|
+
| `compact` | `false` | Reduce padding and gaps while keeping 44 × 44 CSS-pixel minimum touch targets. |
|
|
120
|
+
| `theme` | `light` | Choose `light` or `dark`. |
|
|
121
|
+
| `locale` | `ug` | Use Uyghur or English (`en`) names for controls. |
|
|
122
|
+
| `container` | After the target | Mount in the supplied element or shadow root. |
|
|
123
|
+
| `direction` | Active layout direction | Set `rtl`, `ltr` or `auto`, or use `preserve` to leave direction to the host. |
|
|
124
|
+
| `label` | Localized keyboard label | Accessible name for the keyboard group. |
|
|
125
|
+
|
|
126
|
+
Read `keyboard.layout` for the current layout and call `setLayout(id)` to change it. `setPhysicalMapping`, `setAutoHamza`, `setSecondaryKeys`, `setCompact` and `setTheme` update an existing keyboard. `insert(text)` inserts exactly the supplied text. Automatic hamza applies to individual virtual keys and physical key events outside composition.
|
|
127
|
+
|
|
128
|
+
`destroy()` removes listeners and markup. It restores the target's original direction unless the consumer has changed it while mounted. Repeated destruction is safe. `setVisible(false)` hides virtual keys; physical mapping remains independently controlled.
|
|
129
|
+
|
|
130
|
+
### Web Component
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<textarea id="uyghur-text"></textarea>
|
|
134
|
+
<uyghur-keyboard for="uyghur-text"></uyghur-keyboard>
|
|
135
|
+
|
|
136
|
+
<script type="module">
|
|
137
|
+
import '@uyghurcommunity/keyboard/element';
|
|
138
|
+
</script>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The element accepts `layout`, `lang` and `theme`, plus the boolean attributes `physical`, `auto-hamza`, `secondary-keys` and `compact`. Assign to the element’s `layout` property to change the layout. Read it to get the current UI selection. The element creates its keyboard in a shadow root and cleans up on disconnect. Change `for` to rebind it to another input. For direct source use, replace the package import with `./src/element.js`. Browser import maps or a bundler are needed for bare npm imports.
|
|
142
|
+
|
|
143
|
+
Calling `defineUyghurKeyboard()` from the main module registers the component manually. Importing the main package in Node or during server rendering does not access `document` or register elements.
|
|
144
|
+
|
|
145
|
+
## Phonetic map
|
|
146
|
+
|
|
147
|
+
This optional convenience map applies to the `phonetic` layout (`layout: 'phonetic'`). The default layout, `uey-desktop`, uses the standard Uyghur computer positions instead (A ھ, S س, D د, F ا …). Virtual keys provide all Uyghur letters, and uppercase physical mappings provide common additional forms.
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
Lowercase:
|
|
151
|
+
a ا b ب c چ d د e ە f ف g گ h ھ i ى j ج
|
|
152
|
+
k ك l ل m م n ن o و p پ q ق r ر s س t ت
|
|
153
|
+
u ۇ v ۆ w ۋ x خ y ي z ز
|
|
154
|
+
|
|
155
|
+
Uppercase:
|
|
156
|
+
A ئا E ئە I ئى O ئو U ئۇ G غ N ڭ S ش
|
|
157
|
+
V ئۆ W ئۈ C ج Y ې Z ژ
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Ctrl, Command, Alt shortcuts, unmapped keys, and active IME composition are passed through. The map is off by default. Native undo grouping for programmatic insertions depends on the host browser; the library does not implement its own undo stack.
|
|
161
|
+
|
|
162
|
+
## Layouts, navigation and themes
|
|
163
|
+
|
|
164
|
+
See [layout details, sources, and custom layout format](docs/layouts.md). Use Tab to enter the keys, arrows to move, Home or End to jump to the ends of a row, and Space or Enter to activate a key.
|
|
165
|
+
|
|
166
|
+
The `light` and `dark` themes use CSS custom properties. Set `--ug-bg`, `--ug-key`, `--ug-ink`, `--ug-line`, `--ug-hover` and `--ug-focus` on a parent element or the Web Component to customize the colors.
|
|
167
|
+
|
|
168
|
+
## Events
|
|
169
|
+
|
|
170
|
+
Each edit first emits cancellable `beforeinput` on the target, then applies the edit and emits `input`. A cancelled `beforeinput` leaves the value unchanged. Framework-controlled inputs should update their model from the `input` event.
|
|
171
|
+
|
|
172
|
+
The keyboard also emits a bubbling, composed `uyghur-input` event:
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
keyboard.element.addEventListener('uyghur-input', ({ detail }) => {
|
|
176
|
+
console.log(detail.value, detail.inputType, detail.text);
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Disabled, read-only, and actively composing targets reject virtual changes. Virtual buttons are native buttons with accessible labels; using the physical map is optional.
|
|
181
|
+
|
|
182
|
+
## Pure selection helpers
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
import { replaceSelection, deleteSelectionBackward } from '@uyghurcommunity/keyboard';
|
|
186
|
+
|
|
187
|
+
replaceSelection('ab', 1, 1, 'ئ');
|
|
188
|
+
// { value: 'aئb', start: 2, end: 2 }
|
|
189
|
+
|
|
190
|
+
deleteSelectionBackward('A👩💻ب', 6, 6);
|
|
191
|
+
// { value: 'Aب', start: 1, end: 1 }
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Offsets are UTF-16 offsets, matching `selectionStart`/`selectionEnd`. Grapheme-aware deletion uses `Intl.Segmenter`; environments without it fall back to whole Unicode code points.
|
|
195
|
+
|
|
196
|
+
## Contributing
|
|
197
|
+
|
|
198
|
+
Bug reports with browser details, accessibility fixes, reviewed layout improvements, and integration examples are welcome. Run `npm test` and `npm run check` before submitting a pull request. Run `npm run build` after editing the source to refresh the browser module. The new layout inventories, Uyghur labels, typing behavior and fixtures need native-speaker review.
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
[MIT](LICENSE), © 2026 UyghurCommunity. Uyghur typography uses externally linked ALKATIP Basma with system Tahoma/Arial fallbacks. The font is not bundled or covered by this code license. No external dataset is bundled.
|
|
203
|
+
|
|
204
|
+
## Typography
|
|
205
|
+
|
|
206
|
+
The demo and keyboard keys use **ALKATIP Basma**, requested from OnlineWebFonts using WOFF2 with WOFF/TTF fallbacks and `font-display: swap`. Font binaries are not included in the package. The font host receives the browser's normal font request; typed text is never included in that request. If loading is blocked, the interface falls back to system fonts.
|
|
207
|
+
|
|
208
|
+
Standalone keyboard instances register one shared `@font-face` stylesheet in their owner document. This allows the same face to render keys inside Web Component shadow roots. The registration is reference-counted and removed when the last keyboard that owns it is destroyed. A document stylesheet with the ID `uyghur-keyboard-alkatip-font` can supply the face instead; consumer-owned stylesheets are preserved on cleanup.
|
|
209
|
+
|
|
210
|
+
The `.alkatip-basma` helper sets the font, `direction: rtl`, `unicode-bidi: embed`, and `line-height: 2.2`. Apply it to Uyghur containers; keep explicit LTR code blocks and identifiers in their own direction context. The library styles keyboard keys without changing the consumer's input font or overriding its configured input direction.
|
|
211
|
+
|
|
212
|
+
## Demonstration motion
|
|
213
|
+
|
|
214
|
+
The website includes an original five-keycap sculpture that assembles the Uyghur greeting «سالام». Typing in either demo field lights the artwork without copying, editing, or animating the actual input text. Its visible motion button pauses/resumes the decoration and entrance effects. Reduced-motion preferences are respected from first paint, and continuous CSS animations pause when the card is offscreen or the document is hidden. All content remains visible without the motion script. This artwork is website-only; the npm keyboard behavior is unchanged.
|