@uyghurcommunity/keyboard 0.0.0-stage → 0.2.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 ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ - 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.
6
+ - Add independent options for automatic initial hamza, secondary keys, compact mode and light or dark themes.
7
+ - Keep virtual keys at least 44 by 44 CSS pixels and add arrow navigation, visible focus, and English and Uyghur accessible labels.
8
+ - Add a single-file browser module and plain HTML, React and Vue embedding examples.
9
+ - 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,207 @@
1
- # Temporary Holding Version
1
+ # ئۇيغۇرچە كۇنۇپكا تاختىسى · Uyghur Keyboard
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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.2.0**. To build a local installable package, run:
20
+
21
+ ```sh
22
+ npm test
23
+ npm run check
24
+ npm pack
25
+ ```
26
+
27
+ 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/`.
28
+
29
+ ## Embed with one script
30
+
31
+ 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.
32
+
33
+ ### Plain HTML
34
+
35
+ ```html
36
+ <meta name="viewport" content="width=device-width, initial-scale=1">
37
+ <style>textarea { font-size: 16px; }</style>
38
+ <label for="ug-writing">Uyghur text</label>
39
+ <textarea id="ug-writing"></textarea>
40
+ <uyghur-keyboard for="ug-writing" layout="uey-desktop" lang="en"
41
+ auto-hamza secondary-keys></uyghur-keyboard>
42
+ <script type="module" src="/uyghur-keyboard.js"></script>
43
+ ```
44
+
45
+ ### React
46
+
47
+ ```jsx
48
+ import { useId } from 'react';
49
+
50
+ export function UyghurEditor() {
51
+ const id = useId();
52
+ return (
53
+ <section>
54
+ <label htmlFor={id}>Uyghur text</label>
55
+ <textarea id={id} style={{ fontSize: 16 }} />
56
+ <uyghur-keyboard for={id} layout="uly" lang="en" compact="" />
57
+ </section>
58
+ );
59
+ }
60
+ ```
61
+
62
+ ### Vue
63
+
64
+ ```vue
65
+ <template>
66
+ <section>
67
+ <label for="uyghur-editor">Uyghur text</label>
68
+ <textarea id="uyghur-editor" style="font-size: 16px"></textarea>
69
+ <component :is="'uyghur-keyboard'" for="uyghur-editor"
70
+ layout="usy" lang="en" theme="dark" />
71
+ </section>
72
+ </template>
73
+ ```
74
+
75
+ ## Vanilla JavaScript
76
+
77
+ In an npm project with a module bundler:
78
+
79
+ ```js
80
+ import { createKeyboard } from '@uyghurcommunity/keyboard';
81
+
82
+ const input = document.querySelector('textarea');
83
+ const keyboard = createKeyboard(input, {
84
+ physical: false,
85
+ layout: 'phonetic',
86
+ direction: 'rtl',
87
+ // container: document.querySelector('#keyboard'),
88
+ });
89
+
90
+ keyboard.insert('سالام');
91
+ keyboard.backspace();
92
+ keyboard.setPhysicalMapping(true);
93
+ keyboard.setLayout('uey-desktop');
94
+ keyboard.setTheme('dark');
95
+ keyboard.setVisible(false);
96
+ keyboard.destroy();
97
+ ```
98
+
99
+ 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`.
100
+
101
+ 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.
102
+
103
+ ### Options
104
+
105
+ | Option | Default | Behavior |
106
+ | --- | --- | --- |
107
+ | `layout` | `phonetic` | Choose `phonetic`, `uey-desktop`, `uly`, `usy`, or a supplied custom layout ID. |
108
+ | `layouts` | — | Add plain data layouts to the built-ins. |
109
+ | `physical` | `false` | Apply the active layout's physical map when it has one. |
110
+ | `autoHamza` | `false` | Insert `ئ` before a single Arabic-script vowel typed at the beginning of a word. |
111
+ | `secondaryKeys` | `false` | Show supplemental keys such as Arabic punctuation. |
112
+ | `compact` | `false` | Reduce padding and gaps while keeping 44 × 44 CSS-pixel minimum touch targets. |
113
+ | `theme` | `light` | Choose `light` or `dark`. |
114
+ | `locale` | `ug` | Use Uyghur or English (`en`) names for controls. |
115
+ | `container` | After the target | Mount in the supplied element or shadow root. |
116
+ | `direction` | Active layout direction | Set `rtl`, `ltr` or `auto`, or use `preserve` to leave direction to the host. |
117
+ | `label` | Localized keyboard label | Accessible name for the keyboard group. |
118
+
119
+ 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.
120
+
121
+ `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.
122
+
123
+ ### Web Component
124
+
125
+ ```html
126
+ <textarea id="uyghur-text"></textarea>
127
+ <uyghur-keyboard for="uyghur-text"></uyghur-keyboard>
128
+
129
+ <script type="module">
130
+ import '@uyghurcommunity/keyboard/element';
131
+ </script>
132
+ ```
133
+
134
+ 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.
135
+
136
+ 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.
137
+
138
+ ## Phonetic map
139
+
140
+ This optional convenience map applies to the default layout. Virtual keys provide all Uyghur letters, and uppercase physical mappings provide common additional forms.
141
+
142
+ ```text
143
+ Lowercase:
144
+ a ا b ب c چ d د e ە f ف g گ h ھ i ى j ج
145
+ k ك l ل m م n ن o و p پ q ق r ر s س t ت
146
+ u ۇ v ۆ w ۋ x خ y ي z ز
147
+
148
+ Uppercase:
149
+ A ئا E ئە I ئى O ئو U ئۇ G غ N ڭ S ش
150
+ V ئۆ W ئۈ C ج Y ې Z ژ
151
+ ```
152
+
153
+ 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.
154
+
155
+ ## Layouts, navigation and themes
156
+
157
+ 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.
158
+
159
+ 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.
160
+
161
+ ## Events
162
+
163
+ 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.
164
+
165
+ The keyboard also emits a bubbling, composed `uyghur-input` event:
166
+
167
+ ```js
168
+ keyboard.element.addEventListener('uyghur-input', ({ detail }) => {
169
+ console.log(detail.value, detail.inputType, detail.text);
170
+ });
171
+ ```
172
+
173
+ Disabled, read-only, and actively composing targets reject virtual changes. Virtual buttons are native buttons with accessible labels; using the physical map is optional.
174
+
175
+ ## Pure selection helpers
176
+
177
+ ```js
178
+ import { replaceSelection, deleteSelectionBackward } from '@uyghurcommunity/keyboard';
179
+
180
+ replaceSelection('ab', 1, 1, 'ئ');
181
+ // { value: 'aئb', start: 2, end: 2 }
182
+
183
+ deleteSelectionBackward('A👩‍💻ب', 6, 6);
184
+ // { value: 'Aب', start: 1, end: 1 }
185
+ ```
186
+
187
+ Offsets are UTF-16 offsets, matching `selectionStart`/`selectionEnd`. Grapheme-aware deletion uses `Intl.Segmenter`; environments without it fall back to whole Unicode code points.
188
+
189
+ ## Contributing
190
+
191
+ 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.
192
+
193
+ ## License
194
+
195
+ [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.
196
+
197
+ ## Typography
198
+
199
+ 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.
200
+
201
+ 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.
202
+
203
+ 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.
204
+
205
+ ## Demonstration motion
206
+
207
+ 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.