@uiwwsw/virtual-keyboard 1.1.0 → 1.1.1
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 +49 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,9 +53,36 @@ function App() {
|
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
### Input Modes
|
|
57
|
+
|
|
58
|
+
You can now assign an input policy per `VirtualInput`.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { VirtualInput, VirtualInputProvider } from "@uiwwsw/virtual-keyboard";
|
|
62
|
+
|
|
63
|
+
function App() {
|
|
64
|
+
return (
|
|
65
|
+
<VirtualInputProvider>
|
|
66
|
+
<VirtualInput mode="number" placeholder="숫자만 입력" />
|
|
67
|
+
<VirtualInput mode="tel" placeholder="전화번호만 입력" />
|
|
68
|
+
<VirtualInput mode="alpha" placeholder="영문만 입력" />
|
|
69
|
+
</VirtualInputProvider>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Supported modes:
|
|
75
|
+
- `text`
|
|
76
|
+
- `number`
|
|
77
|
+
- `tel`
|
|
78
|
+
- `hangul`
|
|
79
|
+
- `alpha`
|
|
80
|
+
- `alphanumeric`
|
|
81
|
+
- `custom`
|
|
82
|
+
|
|
56
83
|
### Custom Layout
|
|
57
84
|
|
|
58
|
-
You can provide a custom layout for specialized inputs, such as a number pad for phone numbers.
|
|
85
|
+
You can still provide a custom layout for specialized inputs, such as a number pad for phone numbers.
|
|
59
86
|
|
|
60
87
|
```tsx
|
|
61
88
|
import { VirtualInput, VirtualInputProvider } from "@uiwwsw/virtual-keyboard";
|
|
@@ -70,14 +97,26 @@ const numberPadLayout = [
|
|
|
70
97
|
|
|
71
98
|
function App() {
|
|
72
99
|
return (
|
|
73
|
-
<VirtualInputProvider
|
|
100
|
+
<VirtualInputProvider>
|
|
74
101
|
<p>Enter your phone number:</p>
|
|
75
|
-
<VirtualInput placeholder="010-0000-0000" />
|
|
102
|
+
<VirtualInput layout={numberPadLayout} mode="tel" placeholder="010-0000-0000" />
|
|
76
103
|
</VirtualInputProvider>
|
|
77
104
|
);
|
|
78
105
|
}
|
|
79
106
|
```
|
|
80
107
|
|
|
108
|
+
### Custom Filter / Sanitizer
|
|
109
|
+
|
|
110
|
+
For advanced cases, you can override key filtering and pasted value sanitization.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<VirtualInput
|
|
114
|
+
mode="custom"
|
|
115
|
+
filterKey={(key) => /[ABC123]/.test(key)}
|
|
116
|
+
sanitizeValue={(value) => value.replace(/[^ABC123]/g, "")}
|
|
117
|
+
/>
|
|
118
|
+
```
|
|
119
|
+
|
|
81
120
|
## Components API
|
|
82
121
|
|
|
83
122
|
### `<VirtualInputProvider />`
|
|
@@ -86,13 +125,19 @@ The main provider that manages the keyboard state and UI.
|
|
|
86
125
|
|
|
87
126
|
| Prop | Type | Description |
|
|
88
127
|
| :--------- | :--------------------- | :-------------------------------------------------- |
|
|
89
|
-
| `layout` | `Key[][][]` (optional) |
|
|
128
|
+
| `layout` | `Key[][][]` (optional) | Default fallback layout when an input does not provide its own mode/layout. |
|
|
90
129
|
| `children` | `ReactNode` | Must contain at least one `VirtualInput` component. |
|
|
91
130
|
|
|
92
131
|
### `<VirtualInput />`
|
|
93
132
|
|
|
94
133
|
The replacement for the standard `<input>` element. It accepts all standard input element props like `value`, `defaultValue`, `placeholder`, `onChange`, etc.
|
|
95
134
|
|
|
135
|
+
Additional props:
|
|
136
|
+
- `mode?: "text" | "number" | "tel" | "hangul" | "alpha" | "alphanumeric" | "custom"`
|
|
137
|
+
- `layout?: KeypadLayout`
|
|
138
|
+
- `filterKey?: (key: string) => boolean`
|
|
139
|
+
- `sanitizeValue?: (value: string) => string`
|
|
140
|
+
|
|
96
141
|
## Star History
|
|
97
142
|
|
|
98
143
|
[](https://www.star-history.com/#uiwwsw/virtual-keyboard&Date)
|