@uiwwsw/virtual-keyboard 0.3.4 → 0.3.5

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.md CHANGED
@@ -1,84 +1,106 @@
1
+ <div align="center">
2
+
3
+ # virtual-keyboard
4
+
5
+ **A revolutionary virtual keyboard solution for React that solves the Korean `composition` issue.**
6
+
1
7
  [![npm version](https://img.shields.io/npm/v/@uiwwsw/virtual-keyboard.svg)](https://www.npmjs.com/package/@uiwwsw/virtual-keyboard)
8
+ [![Publish](https://github.com/uiwwsw/virtual-keyboard/actions/workflows/publish.yml/badge.svg)](https://github.com/uiwwsw/virtual-keyboard/actions/workflows/publish.yml)
2
9
  [![License](https://img.shields.io/github/license/uiwwsw/virtual-keyboard)](https://github.com/uiwwsw/virtual-keyboard/blob/main/LICENSE)
3
10
  [![Stars](https://img.shields.io/github/stars/uiwwsw/virtual-keyboard?style=flat)](https://github.com/uiwwsw/virtual-keyboard/stargazers)
4
11
 
5
- # virtual-keyboard: 한글 Composition 이슈를 해결한 혁신적인 가상 키보드 솔루션
12
+ </div>
13
+
6
14
  ![Virtual Keyboard Banner](https://raw.githubusercontent.com/uiwwsw/virtual-keyboard/main/docs/banner.png)
7
15
 
16
+ [**Visit the Demo →**](https://composed-input-y46p.vercel.app/)
8
17
 
9
- [데모](https://composed-input-y46p.vercel.app/)
18
+ ---
10
19
 
11
- > 🚀 **웹 한글 입력의 혁신: Composition 오류 없는 완벽한 입력 환경 제공**
12
- > **기존 가상 키보드의 한계를 넘어, 한글 조합 이슈를 근본적으로 해결합니다.**
13
- > 커스텀 디자인된 키보드와 함께, 웹에서 네이티브와 같은 한글 UX를 경험하세요.
20
+ `virtual-keyboard` is a React component library that provides a custom virtual keyboard and input field, specifically designed to solve the infamous Korean `composition` event issues in web environments. It offers a seamless and native-like typing experience, free from common bugs like character duplication, cursor jumping, and broken compositions.
14
21
 
15
- ---
22
+ ## Key Features
16
23
 
17
- ## 설치
24
+ - ✨ **Composition-Free Input**: Directly handles Korean character composition, bypassing native IME events to prevent common bugs.
25
+ - 🎹 **Customizable Keyboard UI**: Provides a default keyboard and supports fully custom layouts for any use case (e.g., number pads, phone keypads).
26
+ - 📱 **Mobile-First**: Blocks the native mobile keyboard for a consistent and controlled user experience in web apps.
27
+ - ⚛️ **React-Friendly API**: Simple, component-based architecture using `Provider` and `Input` for easy integration.
28
+
29
+ ## Installation
18
30
 
19
31
  ```bash
20
32
  npm install @uiwwsw/virtual-keyboard
21
33
  ```
22
34
 
23
- ---
24
-
25
- ## 🥁 왜 `virtual-keyboard`가 획기적인가요?
35
+ ## Usage
26
36
 
27
- 기존 웹 환경에서 한글 입력 시 발생하는 `composition` 이벤트의 불안정성은
28
- **크로스워드, 게임 UI, 커스텀 에디터, 모바일 웹앱** 등에서 치명적인 문제로 작용했습니다.
29
- ❌ 네이티브 키보드와의 충돌
30
- ❌ 예측 불가능한 커서 이동
31
- ❌ 조합 중인 한글 깨짐
32
- 이러한 고질적인 문제들은 개발자와 사용자 모두에게 큰 불편함을 주었습니다.
37
+ Wrap your input fields with the `VirtualInputProvider`. This provider manages the keyboard's state and renders the UI.
33
38
 
34
- `virtual-keyboard`는 이러한 문제를 **근본적으로 해결**합니다.
35
- **기존의 `composition` 이벤트를 우회하고, 라이브러리 자체적으로 한글 조합 로직을 완벽하게 제어**함으로써,
36
- 어떤 환경에서도 안정적이고 예측 가능한 한글 입력 경험을 제공합니다.
37
- 이는 단순한 가상 키보드를 넘어, **웹 한글 입력 방식의 패러다임을 바꾸는 혁신**입니다.
38
-
39
- ---
39
+ ### Basic Usage
40
40
 
41
- ## 🧩 `virtual-keyboard`는 무엇으로 구성되어 있나요?
41
+ Use the default QWERTY keyboard for Korean and English input.
42
42
 
43
- `virtual-keyboard`는 다음 두 가지 핵심 요소로 구성된 통합 솔루션입니다:
43
+ ```tsx
44
+ import { VirtualInput, VirtualInputProvider } from '@uiwwsw/virtual-keyboard';
44
45
 
45
- ### 1. 🧠 `전용 Input` — 한글 Composition 이슈를 해결한 혁신적인 입력 필드
46
+ function App() {
47
+ return (
48
+ <VirtualInputProvider>
49
+ <p>Your virtual input is here:</p>
50
+ <VirtualInput placeholder="텍스트를 입력하세요..." />
51
+ </VirtualInputProvider>
52
+ );
53
+ }
54
+ ```
46
55
 
47
- - **Composition Free**: 네이티브 IME의 `composition` 이벤트를 사용하지 않고, 라이브러리 내부에서 한글 조합을 직접 처리하여 **조합 중인 한글 깨짐, 커서 이동 오류 등의 문제를 원천 봉쇄**합니다.
48
- - 커스텀 API 제공: 개발자가 입력 로직을 완벽하게 제어할 수 있도록 유연한 API를 제공합니다.
49
- - 버추얼 키보드와 네이티브처럼 연동: `VirtualKeyboard`와 완벽하게 통합되어 마치 하나의 시스템처럼 작동합니다.
50
- - 다양한 커스텀 키보드 지원: 전화번호 전용 키패드, 숫자 전용 키패드, 천지인 등 특정 목적에 맞는 커스텀 키보드를 쉽게 구현하고 연동할 수 있습니다.
56
+ ### Custom Layout
57
+
58
+ You can provide a custom layout for specialized inputs, such as a number pad for phone numbers.
59
+
60
+ ```tsx
61
+ import { VirtualInput, VirtualInputProvider } from '@uiwwsw/virtual-keyboard';
62
+
63
+ const numberPadLayout = [
64
+ [{ value: "1" }, { value: "2" }, { value: "3" }],
65
+ [{ value: "4" }, { value: "5" }, { value: "6" }],
66
+ [{ value: "7" }, { value: "8" }, { value: "9" }],
67
+ // You can define special keys like 'Backspace'
68
+ [{ value: "010" }, { value: "0" }, { value: "Backspace", type: "action" }],
69
+ ];
70
+
71
+ function App() {
72
+ return (
73
+ <VirtualInputProvider layout={numberPadLayout}>
74
+ <p>Enter your phone number:</p>
75
+ <VirtualInput placeholder="010-0000-0000" />
76
+ </VirtualInputProvider>
77
+ );
78
+ }
79
+ ```
51
80
 
52
- ### 2. 🎹 `VirtualKeyboard` — 웹 전용 **고성능 가상 한글 키보드 UI**
81
+ ## Components API
53
82
 
54
- - **모바일 네이티브 키보드 차단**: 모바일 웹 환경에서 불필요한 네이티브 키보드 노출을 막아 **일관된 입력 UX를 제공**합니다.
55
- - `전용 Input`과 자동 연동: 별도의 설정 없이 `전용 Input`과 매끄럽게 연결됩니다.
56
- - 가볍고 설치 없는 웹 앱 최적화: 웹 애플리케이션에 특화된 경량 솔루션으로, 사용자에게 추가 설치 부담을 주지 않습니다.
83
+ ### `<VirtualInputProvider />`
57
84
 
58
- ---
85
+ The main provider that manages the keyboard state and UI.
59
86
 
60
- ## 🎯 주요 사용 사례
87
+ | Prop | Type | Description |
88
+ | :-------- | :--------------------------------- | :----------------------------------------------------------------------- |
89
+ | `layout` | `Key[][][]` (optional) | A 2D array to define a custom keyboard layout. |
90
+ | `children`| `ReactNode` | Must contain at least one `VirtualInput` component. |
61
91
 
62
- - 🔤 **크로스워드, 퍼즐 게임**: 정확하고 오류 없는 글자 입력이 필수적인 게임 환경.
63
- - 🧱 **커스텀 에디터, 드로잉 툴**: 자체적인 커서 시스템이나 복잡한 입력 로직을 필요로 하는 애플리케이션.
64
- - 📱 **모바일 웹 앱**: 키보드 UI를 완벽하게 커스터마이징하고 일관된 사용자 경험을 제공하고자 할 때.
65
- - 🌐 **다국어 웹 앱**: 특히 한글과 같이 복잡한 입력기를 직접 제어하여 안정적인 다국어 입력 환경을 구축하고자 할 때.
66
-
67
- ---
92
+ ### `<VirtualInput />`
68
93
 
69
- ## 🚧 Coming Soon...
94
+ The replacement for the standard `<input>` element. It accepts all standard input element props like `value`, `defaultValue`, `placeholder`, `onChange`, etc.
70
95
 
71
- - 조합 상태 시각화 (`onComposeUpdate`)
72
- - 커스텀 키보드 레이아웃 지원
73
- - `<textarea>` 유사 인터페이스 확장
96
+ ## Star History
74
97
 
75
- ---
98
+ [![Star History Chart](https://api.star-history.com/svg?repos=uiwwsw/virtual-keyboard&type=Date)](https://www.star-history.com/#uiwwsw/virtual-keyboard&Date)
76
99
 
77
- ## 📌 요약하면
100
+ ## Contributors
78
101
 
79
- > `virtual-keyboard`은 단순한 가상 키보드가 아닙니다.
80
- > **웹 한글 입력의 고질적인 `composition` 이슈를 해결하고, 개발자가 입력 과정을 완벽하게 제어할 수 있도록 돕는 혁신적인 `전용 Input`과 고성능 `VirtualKeyboard`를 통합한 솔루션**입니다.
102
+ [![contributors](https://contrib.rocks/image?repo=uiwwsw/virtual-keyboard)](https://github.com/uiwwsw/virtual-keyboard/graphs/contributors)
81
103
 
82
- ## Star History
104
+ ## License
83
105
 
84
- [![Star History Chart](https://api.star-history.com/svg?repos=uiwwsw/virtual-keyboard&type=Date)](https://www.star-history.com/#uiwwsw/virtual-keyboard&Date)
106
+ [MIT](./LICENSE)
package/dist/index.js CHANGED
@@ -580,6 +580,7 @@ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
580
580
  function VirtualInput({
581
581
  value: controlledValue,
582
582
  defaultValue,
583
+ placeholder,
583
584
  onChange,
584
585
  ...props
585
586
  }) {
@@ -762,7 +763,8 @@ function VirtualInput({
762
763
  }
763
764
  if (!result.handled || !result.text)
764
765
  return;
765
- let { text, composing } = result;
766
+ const { composing } = result;
767
+ let { text } = result;
766
768
  if (shift && text.length === 1 && text.match(/[a-z]/i)) {
767
769
  text = text.toUpperCase();
768
770
  }
@@ -830,16 +832,23 @@ function VirtualInput({
830
832
  return /* @__PURE__ */ jsxDEV3(ShadowWrapper, {
831
833
  tagName: "virtual-input",
832
834
  css: `
833
- .wrap {
835
+ .wrap {
834
836
  white-space: pre;
835
837
  position: relative;
836
838
  cursor: text;
837
839
  border-radius: 4px;
838
- user-select: none;
840
+ user-select: none;
839
841
  }
840
842
  .wrap::after {
841
843
  content: " ";
842
844
  }
845
+ .placeholder {
846
+ position: absolute;
847
+ left: 0;
848
+ top: 0;
849
+ color: #aaa;
850
+ pointer-events: none;
851
+ }
843
852
  .letter {
844
853
  position: relative;
845
854
  outline: none;
@@ -847,7 +856,7 @@ function VirtualInput({
847
856
  .letter.selected {
848
857
  background-color: #b4d5fe;
849
858
  }
850
- @keyframes blink {
859
+ @keyframes blink {
851
860
  0%,
852
861
  49% {
853
862
  opacity: 1;
@@ -860,12 +869,13 @@ function VirtualInput({
860
869
  .blink {
861
870
  animation: blink 1s step-start infinite;
862
871
  }
863
- `,
872
+ `,
864
873
  children: /* @__PURE__ */ jsxDEV3("div", {
865
874
  ...props,
866
875
  ref: divRef,
867
876
  className: "wrap",
868
877
  role: "textbox",
878
+ "aria-placeholder": placeholder,
869
879
  tabIndex: 0,
870
880
  style: {
871
881
  minHeight: "1.5em",
@@ -880,6 +890,10 @@ function VirtualInput({
880
890
  onClick: handleClickWrap,
881
891
  onPaste: handlePaste,
882
892
  children: [
893
+ !internalValue && placeholder && /* @__PURE__ */ jsxDEV3("span", {
894
+ className: "placeholder",
895
+ children: placeholder
896
+ }, undefined, false, undefined, this),
883
897
  letters.map((char, i) => /* @__PURE__ */ jsxDEV3("span", {
884
898
  children: [
885
899
  caretIndex === i && isFocused && !hasSelection && /* @__PURE__ */ jsxDEV3(BlinkingCaret, {}, undefined, false, undefined, this),
@@ -4,6 +4,7 @@ export interface VirtualInputHandle {
4
4
  export interface VirtualInputProps {
5
5
  value?: string;
6
6
  defaultValue?: string;
7
+ placeholder?: string;
7
8
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
8
9
  }
9
- export declare function VirtualInput({ value: controlledValue, defaultValue, onChange, ...props }: VirtualInputProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function VirtualInput({ value: controlledValue, defaultValue, placeholder, onChange, ...props }: VirtualInputProps): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiwwsw/virtual-keyboard",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "types": "dist/types/index.d.ts",
6
6
  "main": "dist/index.js",