@uiwwsw/virtual-keyboard 2.2.0 → 2.2.2
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/README.en.md +105 -0
- package/README.md +72 -176
- package/dist/index.js +789 -672
- package/dist/types/components/Context.d.ts +1 -0
- package/dist/types/components/Provider.d.ts +3 -1
- package/dist/types/uiLanguage.d.ts +3 -0
- package/package.json +17 -18
package/README.en.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/uiwwsw/virtual-keyboard/main/public/keyboard.svg" alt="Virtual Keyboard logo" width="96" height="96">
|
|
4
|
+
|
|
5
|
+
<h1>React Virtual Keyboard</h1>
|
|
6
|
+
|
|
7
|
+
<p>On-screen keyboard component for React</p>
|
|
8
|
+
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard"><img alt="npm version" src="https://img.shields.io/npm/v/%40uiwwsw%2Fvirtual-keyboard?style=flat-square"></a>
|
|
11
|
+
<a href="https://github.com/uiwwsw/virtual-keyboard/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/npm/l/%40uiwwsw%2Fvirtual-keyboard?style=flat-square"></a>
|
|
12
|
+
<a href="https://github.com/uiwwsw/virtual-keyboard/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/uiwwsw/virtual-keyboard/ci.yml?branch=main&label=CI&style=flat-square"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard"><img alt="react peer dependency" src="https://img.shields.io/npm/dependency-version/%40uiwwsw%2Fvirtual-keyboard/peer/react?style=flat-square"></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard"><img alt="types" src="https://img.shields.io/npm/types/%40uiwwsw%2Fvirtual-keyboard?style=flat-square"></a>
|
|
15
|
+
<a href="https://github.com/toss/es-hangul"><img alt="uses es-hangul" src="https://img.shields.io/badge/uses-es--hangul-blue?style=flat-square"></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p>
|
|
19
|
+
<a href="https://virtual-keyboard-uiwwsw.vercel.app/en/">Demo</a> ·
|
|
20
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard">npm</a> ·
|
|
21
|
+
<a href="./CHANGELOG.md">Changelog</a> ·
|
|
22
|
+
<a href="./README.md">한국어</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
On-screen keyboard component for React. Hangul two-set composition is computed by [es-hangul](https://github.com/toss/es-hangul); this library implements editing state, keypads and the wiring to a real `<input>`.
|
|
28
|
+
It is a small package with a single maintainer and almost no users.
|
|
29
|
+
|
|
30
|
+
## What works now
|
|
31
|
+
|
|
32
|
+
- `VirtualInputProvider` and `VirtualInput`, plus the types `InputMode`, `InputPolicy`, `Key`, `KeypadLayout`
|
|
33
|
+
- Input modes: `text`, `hangul`, `number`, `tel`, `alpha`, `alphanumeric`, `custom`
|
|
34
|
+
- Korean two-set input with Korean/English switching
|
|
35
|
+
- QWERTY, number and phone keypads, symbol and edit screens
|
|
36
|
+
- Custom keypads from layout JSON, including multi-character macro keys
|
|
37
|
+
- `filterKey`, `sanitizeValue` and `maxLength` for typing and pasting
|
|
38
|
+
- A real `<input inputMode="none">`; the browser handles the caret and selection
|
|
39
|
+
- A keypad of `<button>` elements inside a Shadow DOM
|
|
40
|
+
- Per-input undo and redo (up to 100 entries); copy, cut and paste buttons
|
|
41
|
+
- Physical keyboard input, light and dark themes, keypad visibility (`auto`, `always`, `never`), Korean or English labels (`locale`)
|
|
42
|
+
- TypeScript types included, ESM package
|
|
43
|
+
|
|
44
|
+
## Not done / planned
|
|
45
|
+
|
|
46
|
+
- Not tested with VoiceOver or TalkBack. Only automated axe checks pass
|
|
47
|
+
- No `type="password"`, autofill or form submission through `name`
|
|
48
|
+
- Single-line input only. No multi-line field
|
|
49
|
+
- No Korean layouts other than two-set, such as Cheonjiin
|
|
50
|
+
- Does not replace the operating system IME
|
|
51
|
+
- `number` mode is a character filter. Decimal count, sign and range checks are left to the app
|
|
52
|
+
- Suppressing the system keyboard with `inputMode="none"` differs across browsers and devices
|
|
53
|
+
- Mobile detection is a heuristic. Set `keyboardVisibility` explicitly for fixed behavior
|
|
54
|
+
- No framework-agnostic core for non-React frameworks
|
|
55
|
+
|
|
56
|
+
## Where it stands
|
|
57
|
+
|
|
58
|
+
- Weekly npm downloads (last week, api.npmjs.org): this package 80, react-simple-keyboard 237,797, simple-keyboard 80,748, es-hangul 173,386. The gap is roughly 3,000 times.
|
|
59
|
+
- One maintainer. One GitHub contributor, 1 star, 0 forks, and no known production users.
|
|
60
|
+
- React only. simple-keyboard is a framework-agnostic JavaScript core that can be used from React, Angular and Vue.
|
|
61
|
+
- simple-keyboard has a separate `simple-keyboard-layouts` package with layouts for many languages, Korean included. This package has QWERTY, number, phone and custom layouts only.
|
|
62
|
+
- Hangul composition depends on es-hangul. It is not an algorithm written here.
|
|
63
|
+
- It fits when you need Korean two-set input in React on a real `<input>` and want the browser to keep the caret and selection. For other uses, simple-keyboard is the better choice.
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
npm install @uiwwsw/virtual-keyboard
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Requires React and React DOM 18 or 19.
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
"use client";
|
|
77
|
+
import { useState } from "react";
|
|
78
|
+
import { VirtualInput, VirtualInputProvider } from "@uiwwsw/virtual-keyboard";
|
|
79
|
+
|
|
80
|
+
export default function Example() {
|
|
81
|
+
const [value, setValue] = useState("");
|
|
82
|
+
return (
|
|
83
|
+
<VirtualInputProvider locale="en" keyboardVisibility="always">
|
|
84
|
+
<VirtualInput
|
|
85
|
+
value={value}
|
|
86
|
+
onValueChange={setValue}
|
|
87
|
+
aria-label="Your message"
|
|
88
|
+
maxLength={48}
|
|
89
|
+
/>
|
|
90
|
+
</VirtualInputProvider>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Docs
|
|
96
|
+
|
|
97
|
+
- [Reference (modes, custom keys, architecture, development, built on)](https://github.com/uiwwsw/virtual-keyboard/blob/main/docs/REFERENCE.en.md)
|
|
98
|
+
- [Korean reference with the full API, accessibility, clipboard and migration notes](https://github.com/uiwwsw/virtual-keyboard/blob/main/docs/REFERENCE.md)
|
|
99
|
+
- [Changelog](https://github.com/uiwwsw/virtual-keyboard/blob/main/CHANGELOG.md)
|
|
100
|
+
- [Contributing](https://github.com/uiwwsw/virtual-keyboard/blob/main/CONTRIBUTING.md)
|
|
101
|
+
- [한국어 README](https://github.com/uiwwsw/virtual-keyboard/blob/main/README.md)
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
[MIT](https://github.com/uiwwsw/virtual-keyboard/blob/main/LICENSE)
|
package/README.md
CHANGED
|
@@ -1,8 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/uiwwsw/virtual-keyboard/main/public/keyboard.svg" alt="Virtual Keyboard 로고" width="96" height="96">
|
|
4
|
+
|
|
5
|
+
<h1>Virtual Keyboard</h1>
|
|
6
|
+
|
|
7
|
+
<p>React용 화면 키보드 컴포넌트</p>
|
|
8
|
+
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard"><img alt="npm version" src="https://img.shields.io/npm/v/%40uiwwsw%2Fvirtual-keyboard?style=flat-square"></a>
|
|
11
|
+
<a href="https://github.com/uiwwsw/virtual-keyboard/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/npm/l/%40uiwwsw%2Fvirtual-keyboard?style=flat-square"></a>
|
|
12
|
+
<a href="https://github.com/uiwwsw/virtual-keyboard/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/uiwwsw/virtual-keyboard/ci.yml?branch=main&label=CI&style=flat-square"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard"><img alt="react peer dependency" src="https://img.shields.io/npm/dependency-version/%40uiwwsw%2Fvirtual-keyboard/peer/react?style=flat-square"></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard"><img alt="types" src="https://img.shields.io/npm/types/%40uiwwsw%2Fvirtual-keyboard?style=flat-square"></a>
|
|
15
|
+
<a href="https://github.com/toss/es-hangul"><img alt="uses es-hangul" src="https://img.shields.io/badge/uses-es--hangul-blue?style=flat-square"></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p>
|
|
19
|
+
<a href="https://virtual-keyboard-uiwwsw.vercel.app/">데모</a> ·
|
|
20
|
+
<a href="https://www.npmjs.com/package/@uiwwsw/virtual-keyboard">npm</a> ·
|
|
21
|
+
<a href="./CHANGELOG.md">변경 내역</a> ·
|
|
22
|
+
<a href="./README.en.md">English</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
React용 화면 키보드 컴포넌트입니다. 한글 두벌식 조합 계산은 [es-hangul](https://github.com/toss/es-hangul)을 쓰고, 이 라이브러리는 편집 상태, 키패드, 실제 `<input>` 연결을 구현합니다.
|
|
28
|
+
단일 관리자가 유지하는 작은 패키지이며 아직 쓰는 사람이 거의 없습니다.
|
|
29
|
+
|
|
30
|
+
## 지금 되는 것
|
|
31
|
+
|
|
32
|
+
- `VirtualInputProvider`, `VirtualInput` 두 컴포넌트와 `InputMode`, `InputPolicy`, `Key`, `KeypadLayout` 타입
|
|
33
|
+
- 입력 모드: `text`, `hangul`, `number`, `tel`, `alpha`, `alphanumeric`, `custom`
|
|
34
|
+
- 한글 두벌식 입력과 한영 전환
|
|
35
|
+
- QWERTY, 숫자, 전화번호 키패드, 기호·편집 화면
|
|
36
|
+
- 레이아웃 JSON으로 만드는 사용자 정의 키패드와 여러 글자 매크로 키
|
|
37
|
+
- `filterKey`, `sanitizeValue`, `maxLength`로 입력·붙여넣기 제한
|
|
38
|
+
- `inputMode="none"`인 실제 `<input>`. 커서·선택은 브라우저가 처리
|
|
39
|
+
- Shadow DOM 안의 `<button>` 키패드
|
|
40
|
+
- 입력란별 실행 취소·다시 실행(최대 100개), 복사·잘라내기·붙여넣기 버튼
|
|
41
|
+
- 물리 키보드 입력, 라이트·다크 테마, 키패드 표시 조건(`auto`, `always`, `never`), 한국어·영어 라벨(`locale`)
|
|
42
|
+
- TypeScript 타입 포함, ESM 패키지
|
|
43
|
+
|
|
44
|
+
## 아직 안 되는 것 / 진행 예정
|
|
45
|
+
|
|
46
|
+
- VoiceOver, TalkBack으로 검증하지 않았음. axe 자동 검사만 통과
|
|
47
|
+
- `type="password"`, 자동완성, `name`을 통한 폼 제출 없음
|
|
48
|
+
- 한 줄 입력만 지원. 여러 줄 입력란 없음
|
|
49
|
+
- 천지인 등 두벌식 외 한글 배열 없음
|
|
50
|
+
- 운영체제 IME 대체 아님
|
|
51
|
+
- `number` 모드는 문자 필터. 소수점 개수, 부호, 금액 범위 검증은 앱에서 해야 함
|
|
52
|
+
- `inputMode="none"`의 시스템 키보드 억제는 브라우저·기기별로 다를 수 있음
|
|
53
|
+
- 모바일 판단은 휴리스틱. 정확한 표시가 필요하면 `keyboardVisibility`를 직접 지정해야 함
|
|
54
|
+
- React 외 프레임워크용 코어 없음
|
|
55
|
+
|
|
56
|
+
## 현재 위치
|
|
57
|
+
|
|
58
|
+
- 주간 npm 다운로드(최근 1주, api.npmjs.org): 이 패키지 80, react-simple-keyboard 237,797, simple-keyboard 80,748, es-hangul 173,386. 사용량 차이가 3,000배 가까이 납니다.
|
|
59
|
+
- 유지 관리자 1명. GitHub 기여자 1명, 스타 1개, 포크 0개. 알려진 실사용 사례가 없습니다.
|
|
60
|
+
- React 전용입니다. simple-keyboard는 프레임워크에 묶이지 않는 JavaScript 코어이고 React, Angular, Vue에서 쓸 수 있습니다.
|
|
61
|
+
- simple-keyboard는 별도 `simple-keyboard-layouts` 패키지로 한국어를 포함한 여러 언어 레이아웃을 제공합니다. 이 패키지의 레이아웃은 QWERTY, 숫자, 전화번호와 사용자 정의뿐입니다.
|
|
62
|
+
- 한글 조합 계산은 es-hangul에 의존합니다. 직접 만든 알고리즘이 아닙니다.
|
|
63
|
+
- 맞는 경우는 React에서 실제 `<input>`에 한글 두벌식 입력을 붙이고 커서·선택을 브라우저에 맡기려는 때입니다. 그 밖의 용도는 simple-keyboard가 낫습니다.
|
|
6
64
|
|
|
7
65
|
## Installation
|
|
8
66
|
|
|
@@ -10,7 +68,7 @@
|
|
|
10
68
|
npm install @uiwwsw/virtual-keyboard
|
|
11
69
|
```
|
|
12
70
|
|
|
13
|
-
React
|
|
71
|
+
React, React DOM 18 또는 19가 필요합니다.
|
|
14
72
|
|
|
15
73
|
## Usage
|
|
16
74
|
|
|
@@ -23,12 +81,10 @@ export default function App() {
|
|
|
23
81
|
|
|
24
82
|
return (
|
|
25
83
|
<VirtualInputProvider keyboardVisibility="always">
|
|
26
|
-
<p id="name-label">이름</p>
|
|
27
84
|
<VirtualInput
|
|
28
|
-
aria-
|
|
85
|
+
aria-label="이름"
|
|
29
86
|
value={name}
|
|
30
87
|
onValueChange={setName}
|
|
31
|
-
placeholder="이름을 입력하세요"
|
|
32
88
|
maxLength={40}
|
|
33
89
|
/>
|
|
34
90
|
</VirtualInputProvider>
|
|
@@ -36,173 +92,13 @@ export default function App() {
|
|
|
36
92
|
}
|
|
37
93
|
```
|
|
38
94
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`value`를 제공하면 부모가 입력 상태를 관리합니다. `defaultValue`는 최초 값에만 사용됩니다. 입력 정책은 사용자의 새 입력과 붙여넣기에 적용되며, 부모가 전달하는 `value`와 기존 값은 임의로 변경하지 않습니다.
|
|
42
|
-
|
|
43
|
-
## Input modes
|
|
44
|
-
|
|
45
|
-
| `mode` | 허용 문자 / 동작 | 기본 키패드 |
|
|
46
|
-
| -------------- | ---------------------------------------------- | ------------------- |
|
|
47
|
-
| `text` | 자유 입력, 한영 전환 가능 | QWERTY |
|
|
48
|
-
| `hangul` | 한글 자판 고정, 영문 제거. 숫자·공백·기호 허용 | QWERTY |
|
|
49
|
-
| `number` | `0–9`, `.` | 숫자 패드 |
|
|
50
|
-
| `tel` | `0–9`, `+`, `*`, `#` | 전화 패드 |
|
|
51
|
-
| `alpha` | `A–Z`, `a–z` | QWERTY |
|
|
52
|
-
| `alphanumeric` | 영문과 숫자 | 숫자 행 + QWERTY |
|
|
53
|
-
| `custom` | 사용자 정의 필터·값·레이아웃 | Provider의 레이아웃 |
|
|
54
|
-
|
|
55
|
-
`number`는 문자 필터입니다. 소수점 개수, 부호, 금액 범위 같은 업무 규칙은 앱에서 검증하세요. 모든 모드는 한 줄 입력이며 붙여넣은 줄바꿈·탭은 기본 자유 입력에서 공백으로 바뀝니다.
|
|
56
|
-
|
|
57
|
-
모드별 레이아웃보다 입력란의 `layout`이 우선합니다. `text`와 `custom` 입력란은 자신의 레이아웃이 없으면 Provider의 레이아웃을 사용합니다. 강제 언어 모드는 자유 입력의 저장된 언어 선호도를 바꾸지 않습니다.
|
|
58
|
-
|
|
59
|
-
## Custom layout
|
|
60
|
-
|
|
61
|
-
`label`은 화면 표시용이며 실제로 입력되는 것은 `value`입니다. `type`을 생략하면 문자 또는 여러 글자 매크로로 처리합니다.
|
|
62
|
-
|
|
63
|
-
```tsx
|
|
64
|
-
import {
|
|
65
|
-
VirtualInput,
|
|
66
|
-
VirtualInputProvider,
|
|
67
|
-
type KeypadLayout,
|
|
68
|
-
} from "@uiwwsw/virtual-keyboard";
|
|
69
|
-
|
|
70
|
-
const phoneLayout: KeypadLayout = [
|
|
71
|
-
[{ value: "1" }, { value: "2" }, { value: "3" }],
|
|
72
|
-
[{ value: "4" }, { value: "5" }, { value: "6" }],
|
|
73
|
-
[{ value: "7" }, { value: "8" }, { value: "9" }],
|
|
74
|
-
[
|
|
75
|
-
{ label: "휴대폰", value: "010", width: 2 },
|
|
76
|
-
{ value: "0" },
|
|
77
|
-
{ label: "⌫", value: "Backspace", type: "action" },
|
|
78
|
-
],
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
function PhoneField() {
|
|
82
|
-
return (
|
|
83
|
-
<VirtualInputProvider>
|
|
84
|
-
<VirtualInput aria-label="전화번호" mode="tel" layout={phoneLayout} />
|
|
85
|
-
</VirtualInputProvider>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
동작 키에는 `type: "action"`을 사용하세요. 지원 값은 `Backspace`, `Delete`, `Shift`, `HangulMode`, `Enter`, `ArrowLeft`, `ArrowRight`, `EnterSelectionMode`, `ExitSelectionMode`, `ToggleSelectionAdjust`, `Copy`, `Paste`, `Cut`, `SelectAll`, `Undo`, `Redo`입니다. `value: " "`는 공백, `value: "\n"`는 `Enter`로 처리합니다. `width`는 행 안에서 차지하는 상대 너비이며 `height`는 호환성을 위해 타입에 남아 있지만 행 높이를 변경하지 않습니다.
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
<VirtualInput
|
|
94
|
-
aria-label="분류 코드"
|
|
95
|
-
mode="custom"
|
|
96
|
-
filterKey={(key) => /^[ABC123]+$/.test(key)}
|
|
97
|
-
sanitizeValue={(text) => text.replace(/[^ABC123]/g, "")}
|
|
98
|
-
/>
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
`filterKey`는 문자·매크로 입력을 허용하거나 거절합니다. `sanitizeValue`는 삽입할 문자열을 정리하며 붙여넣기에도 적용됩니다. 두 함수는 같은 문자 정책을 사용하도록 작성하세요.
|
|
102
|
-
|
|
103
|
-
## API
|
|
104
|
-
|
|
105
|
-
### VirtualInputProvider
|
|
106
|
-
|
|
107
|
-
| 속성 | 타입 / 기본값 | 설명 |
|
|
108
|
-
| -------------------- | ------------------------------------------ | -------------------------------- |
|
|
109
|
-
| `children` | `ReactNode` | 입력란을 포함한 콘텐츠 |
|
|
110
|
-
| `layout` | `KeypadLayout` / QWERTY | 자유·커스텀 모드의 기본 레이아웃 |
|
|
111
|
-
| `defaultHangulMode` | `boolean` / `true` | 저장된 설정이 없을 때의 언어 |
|
|
112
|
-
| `theme` | `"light" \| "dark"` / 시스템 설정 | 키패드 테마 |
|
|
113
|
-
| `keyboardVisibility` | `"auto" \| "always" \| "never"` / `"auto"` | 화면 키패드 표시 조건 |
|
|
114
|
-
|
|
115
|
-
키패드는 현재 포커스된 편집 가능한 입력란이 있을 때 표시됩니다. 한 페이지에 Provider가 여러 개 있어도 하나만 열립니다. 장치의 화면 크기와 safe area에 맞춰 배치하고, 기존 `body` 스타일을 덮어쓰지 않습니다.
|
|
116
|
-
|
|
117
|
-
### VirtualInput
|
|
118
|
-
|
|
119
|
-
| 속성 | 타입 / 기본값 | 설명 |
|
|
120
|
-
| ----------------------- | ------------------------------------------------ | ----------------------------------------------------------- |
|
|
121
|
-
| `value`, `defaultValue` | `string` | 제어 값 / 초기 값 |
|
|
122
|
-
| `onValueChange` | `(value: string) => void` | 값이 실제로 바뀔 때 호출하는 권장 API |
|
|
123
|
-
| `onChange` | `(event: ChangeEvent<HTMLInputElement>) => void` | 기존 API 호환. `target.value`, `currentTarget.value`만 제공 |
|
|
124
|
-
| `mode` | `InputMode` / `"text"` | 입력 정책 |
|
|
125
|
-
| `layout` | `KeypadLayout` | 입력란별 키패드 |
|
|
126
|
-
| `filterKey` | `(key: string) => boolean` | 문자·매크로 필터 |
|
|
127
|
-
| `sanitizeValue` | `(text: string) => string` | 삽입 문자열 정리 |
|
|
128
|
-
| `placeholder` | `string` | 비어 있을 때 표시하는 안내 |
|
|
129
|
-
| `disabled`, `readOnly` | `boolean` / `false` | 편집 차단. 화면 키패드를 열지 않음 |
|
|
130
|
-
| `maxLength` | `number` | UTF-16 단위 최대 길이. 초과 편집은 전체 거절 |
|
|
131
|
-
| `onClipboardError` | `(error: Error) => void` | 클립보드 API 사용 실패 알림 |
|
|
132
|
-
|
|
133
|
-
`HTMLAttributes<HTMLDivElement>` 호환 속성을 지원합니다. `id`, `tabIndex`, `aria-*`는 실제 input에, `className`, `style`과 이벤트 핸들러는 컨테이너에 적용합니다. `onFocus`, `onBlur`, `onKeyDown`, 포인터·클립보드 이벤트는 input에서 버블링하며 `currentTarget`은 기존처럼 컨테이너입니다. 소비자 이벤트 핸들러의 `preventDefault()`를 존중합니다.
|
|
134
|
-
|
|
135
|
-
입력란은 한 줄 텍스트 input입니다. `inputMode="none"`으로 시스템 화면 키보드를 억제하고 가상 키패드를 사용합니다. 네이티브 IME 조합 중에는 키를 가로채지 않고 조합 완료 시 입력 정책을 적용합니다. 공개 API에 `type="password"`, 자동완성, `name`을 통한 폼 제출 설정은 제공하지 않습니다. 폼에 연결할 때는 부모의 상태로 제출을 처리하세요. `Enter`는 조합을 끝내며 `onKeyDown`에서 앱의 완료 동작을 연결할 수 있습니다. `onChange`의 호환 이벤트를 실제 DOM 이벤트로 사용하지 마세요.
|
|
136
|
-
|
|
137
|
-
### Ref API
|
|
138
|
-
|
|
139
|
-
`ref`로 `VirtualInputHandle`을 받을 수 있습니다. `focus(options?)`, `blur()`, `getValue()`, `setSelectionRange(start, end)`, `selectAll()`, `undo()`, `redo()`를 제공합니다.
|
|
140
|
-
|
|
141
|
-
```tsx
|
|
142
|
-
import { useRef } from "react";
|
|
143
|
-
import type { VirtualInputHandle } from "@uiwwsw/virtual-keyboard";
|
|
144
|
-
|
|
145
|
-
const ref = useRef<VirtualInputHandle>(null);
|
|
146
|
-
// <VirtualInput ref={ref} aria-label="이름" />
|
|
147
|
-
ref.current?.focus();
|
|
148
|
-
ref.current?.setSelectionRange(0, 2);
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Keyboard and accessibility
|
|
152
|
-
|
|
153
|
-
- 입력란에 `aria-label`, `aria-labelledby` 또는 `id`와 연결한 `label htmlFor`를 제공하세요.
|
|
154
|
-
- 물리 키보드의 영문 키를 현재 한글 모드에 맞춰 해석하며, 이미 전달된 한글 키도 지원합니다. 운영체제 IME 전체를 대체하는 입력란은 아닙니다.
|
|
155
|
-
- 한글 조합 중 Backspace는 자모를 지우고, 조합이 끝나면 글자 단위로 지웁니다. 이모지·결합 문자는 중간에서 나누지 않습니다.
|
|
156
|
-
- 방향키, Home/End, Shift + 방향키, Ctrl/Cmd + A, 복사·잘라내기·붙여넣기, Escape를 지원합니다.
|
|
157
|
-
- Ctrl/Cmd + Z로 실행 취소, Ctrl/Cmd + Shift + Z 또는 Ctrl + Y로 다시 실행합니다. 기록은 입력란별로 최대 100개를 보관하고 외부에서 제어 값이 바뀌면 초기화합니다.
|
|
158
|
-
- 키패드 상단의 숫자·기호 전환으로 숫자·구두점·특수문자를 입력할 수 있습니다.
|
|
159
|
-
- Shift는 한 번 누르면 다음 문자에 적용되고, 두 번 누르면 고정됩니다. 세 번째 입력으로 해제됩니다.
|
|
160
|
-
- 탭, 길게 누르기, 드래그, 스크롤은 실제 input의 기본 제스처로 처리합니다. 앱에서 터치 위치를 커서로 환산하거나 손을 뗄 때 다시 선택하지 않습니다.
|
|
161
|
-
- `selectionStart`·`selectionEnd`·`selectionDirection`을 편집 엔진과 동기화합니다. 자체 길게 누르기 타이머와 가짜 커서가 없어 브라우저가 정한 커서·선택 상태를 뒤늦게 덮어쓰지 않습니다.
|
|
162
|
-
- 선택하면 현재 자판 위에 `복사`·`잘라내기`·`붙여넣기`가 바로 표시됩니다. `전체 선택`은 `편집` 화면에서 사용할 수 있습니다. 선택 손잡이와 기본 복사 메뉴의 표시·모양은 기기와 브라우저가 결정합니다. `편집` 키의 화살표·범위 조절도 계속 사용할 수 있습니다.
|
|
163
|
-
- 화면 키는 손을 뗄 때 실행됩니다. 누른 채 키 밖으로 움직이거나 터치가 취소되면 실행하지 않습니다. 지우기·화살표는 길게 누르면 반복하고 키 밖으로 움직이면 멈춥니다.
|
|
164
|
-
- 키패드의 클립보드 버튼은 보안 컨텍스트와 브라우저 권한이 필요할 수 있습니다. 복사는 Clipboard API 실패 시 실제 선택 영역의 기본 복사 이벤트를 대체 경로로 시도합니다. 실패는 보이는 상태 메시지와 `onClipboardError`로 전달합니다. 기본 복사 메뉴와 물리 키보드 단축키도 지원합니다.
|
|
165
|
-
|
|
166
|
-
입력란과 키는 실제 HTML input·button으로 렌더링되며 스크린 리더에 노출됩니다. 자동 접근성 검사는 보조기기 실기기 검증을 대체하지 않습니다.
|
|
167
|
-
|
|
168
|
-
## Copy and paste
|
|
169
|
-
|
|
170
|
-
- **처음 들어와 붙여넣기:** 입력란을 탭하고 키패드 상단의 `붙여넣기`를 누릅니다. 빈 입력란과 숫자·전화번호 모드에서도 바로 사용할 수 있습니다.
|
|
171
|
-
- **복사한 내용을 다른 위치에 붙여넣기:** 글자를 선택해 `복사`한 다음 같은 입력란이나 다른 입력란에서 원하는 위치를 탭하고 `붙여넣기`를 누릅니다. 선택 범위가 있으면 그 부분을 교체합니다.
|
|
172
|
-
- 붙여넣은 내용 끝에 커서를 두고 입력란으로 포커스를 돌려 계속 입력할 수 있습니다. 붙여넣기는 한 번의 실행 취소로 되돌릴 수 있습니다.
|
|
173
|
-
|
|
174
|
-
클립보드는 붙여넣기를 명시적으로 실행할 때 읽습니다. 읽는 동안 버튼에 진행 상태를 표시하고 연속 실행을 막습니다. 대기 중 커서·값·입력란·입력 정책이 바뀌면 요청을 취소하므로 새 위치에서 다시 눌러 주세요. 빈 클립보드, 허용되지 않는 내용, 길이 제한, 부모가 거절한 값은 완료 메시지와 구분해 알립니다.
|
|
175
|
-
|
|
176
|
-
브라우저가 클립보드 읽기를 제한하면 현재 선택 범위를 유지하고 기본 붙여넣기 메뉴를 안내합니다. 입력란을 길게 눌러 `붙여넣기`를 선택하거나 Ctrl/Cmd + V를 사용할 수 있습니다. 기본 붙여넣기 이벤트에도 같은 입력 정책과 실행 취소를 적용합니다. OS의 권한 창과 붙여넣기 메뉴는 브라우저가 표시합니다. [Clipboard API의 브라우저별 제약](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#security_considerations)을 참고하세요.
|
|
177
|
-
|
|
178
|
-
## Development
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
npm ci
|
|
182
|
-
npm run dev
|
|
183
|
-
npm run check
|
|
184
|
-
npx playwright install chromium webkit
|
|
185
|
-
npm run test:e2e
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
| 명령어 | 결과 |
|
|
189
|
-
| ----------------------- | ---------------------------------------------------------- |
|
|
190
|
-
| `npm run build` | 데모 사이트 → `demo-dist/` |
|
|
191
|
-
| `npm run build-package` | 라이브러리 JavaScript·타입 → `dist/` |
|
|
192
|
-
| `npm run test:package` | 패키지 포함 파일·ESM import·서버 렌더링 검사 |
|
|
193
|
-
| `npm test` | 입력 엔진·컴포넌트 회귀 테스트 |
|
|
194
|
-
| `npm run test:e2e` | 데스크톱·모바일 Chromium 및 모바일 WebKit 동작·접근성 검사 |
|
|
195
|
-
| `npm run format` | Prettier 포맷 적용 |
|
|
196
|
-
| `npm run check` | 포맷·린트·테스트·빌드·패키지 검증 |
|
|
197
|
-
|
|
198
|
-
npm의 `package-lock.json`을 의존성 기준으로 사용합니다. Vite 라이브러리 빌드에서 React, React DOM, es-hangul은 외부 의존성으로 유지합니다. 데모를 호스팅할 때 출력 디렉터리를 `demo-dist`로 설정하세요. Next.js처럼 React Server Components를 사용하는 앱에서는 상태를 사용하는 예제 컴포넌트에 `"use client"`를 추가하세요.
|
|
199
|
-
|
|
200
|
-
[개선 내역과 검증 범위](./docs/functional-assessment.md) · [기여 안내](./CONTRIBUTING.md)
|
|
201
|
-
|
|
202
|
-
## Migration from 1.x
|
|
95
|
+
## 문서
|
|
203
96
|
|
|
204
|
-
|
|
97
|
+
- [레퍼런스(모드, 레이아웃, API, 접근성, 복사·붙여넣기, 구성, 개발, 마이그레이션, 데모)](https://github.com/uiwwsw/virtual-keyboard/blob/main/docs/REFERENCE.md)
|
|
98
|
+
- [변경 내역](https://github.com/uiwwsw/virtual-keyboard/blob/main/CHANGELOG.md)
|
|
99
|
+
- [기여 안내](https://github.com/uiwwsw/virtual-keyboard/blob/main/CONTRIBUTING.md)
|
|
100
|
+
- [English README](https://github.com/uiwwsw/virtual-keyboard/blob/main/README.en.md)
|
|
205
101
|
|
|
206
|
-
##
|
|
102
|
+
## License
|
|
207
103
|
|
|
208
|
-
|
|
104
|
+
[MIT](https://github.com/uiwwsw/virtual-keyboard/blob/main/LICENSE)
|