@uiwwsw/virtual-keyboard 0.3.7 → 0.4.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 +5 -1
- package/dist/index.js +75 -29
- package/dist/types/App.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
|
12
|
-
[**Visit the Demo →**](https://composed-input
|
|
12
|
+
[**Visit the Demo →**](https://composed-input.vercel.app/)
|
|
13
|
+
|
|
14
|
+
> 📱 데모 페이지에는 모바일 고정 키보드와 숫자·다이얼러 전용 모드를 직접 전환해 볼 수 있는 섹션이 준비되어 있습니다.
|
|
15
|
+
> 실제 모바일 기기 혹은 DevTools 기기 모드(User-Agent 를 모바일로 전환)에 맞춰 접속하면 네이티브 키보드 대신 이 라이브러리의 가상 키보드가 표시됩니다.
|
|
13
16
|
|
|
14
17
|
---
|
|
15
18
|
|
|
@@ -17,6 +20,7 @@
|
|
|
17
20
|
|
|
18
21
|
## Key Features
|
|
19
22
|
|
|
23
|
+
- ❤️ **Without <input /> **: No input, No contentEditable. Just div.
|
|
20
24
|
- ✨ **Composition-Free Input**: Directly handles Korean character composition, bypassing native IME events to prevent common bugs.
|
|
21
25
|
- 🎹 **Customizable Keyboard UI**: Provides a default keyboard and supports fully custom layouts for any use case (e.g., number pads, phone keypads).
|
|
22
26
|
- 📱 **Mobile-First**: Blocks the native mobile keyboard for a consistent and controlled user experience in web apps.
|
package/dist/index.js
CHANGED
|
@@ -965,6 +965,9 @@ function VirtualKeypad({
|
|
|
965
965
|
return;
|
|
966
966
|
const { value, dataset } = target;
|
|
967
967
|
const type = dataset.type;
|
|
968
|
+
if (typeof navigator !== "undefined" && "vibrate" in navigator) {
|
|
969
|
+
navigator.vibrate?.(10);
|
|
970
|
+
}
|
|
968
971
|
if (type === "action") {
|
|
969
972
|
if (value === "Shift") {
|
|
970
973
|
toggleShift();
|
|
@@ -996,18 +999,19 @@ function VirtualKeypad({
|
|
|
996
999
|
display: flex;
|
|
997
1000
|
flex-direction: column;
|
|
998
1001
|
position: fixed;
|
|
999
|
-
background-color: #
|
|
1000
|
-
padding: calc(
|
|
1002
|
+
background-color: #e8eaee;
|
|
1003
|
+
padding: calc(12px / var(--scale-factor));
|
|
1001
1004
|
box-sizing: border-box;
|
|
1002
|
-
gap: calc(
|
|
1003
|
-
|
|
1005
|
+
gap: calc(10px / var(--scale-factor));
|
|
1006
|
+
border-radius: calc(18px / var(--scale-factor));
|
|
1007
|
+
box-shadow: 0 calc(-6px / var(--scale-factor)) calc(30px / var(--scale-factor)) rgba(15, 23, 42, 0.2);
|
|
1004
1008
|
user-select: none;
|
|
1005
1009
|
touch-action: manipulation;
|
|
1006
1010
|
}
|
|
1007
1011
|
.keypad-row {
|
|
1008
1012
|
display: flex;
|
|
1009
1013
|
flex: 1;
|
|
1010
|
-
gap: calc(
|
|
1014
|
+
gap: calc(10px / var(--scale-factor));
|
|
1011
1015
|
}
|
|
1012
1016
|
@keyframes key-pop {
|
|
1013
1017
|
from {
|
|
@@ -1029,17 +1033,23 @@ function VirtualKeypad({
|
|
|
1029
1033
|
display: flex;
|
|
1030
1034
|
justify-content: center;
|
|
1031
1035
|
align-items: center;
|
|
1032
|
-
background
|
|
1033
|
-
border: calc(1px / var(--scale-factor)) solid
|
|
1034
|
-
border-radius: calc(
|
|
1036
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, #dfe3eb 100%);
|
|
1037
|
+
border: calc(1px / var(--scale-factor)) solid rgba(148, 163, 184, 0.7);
|
|
1038
|
+
border-radius: calc(12px / var(--scale-factor));
|
|
1035
1039
|
font-size: calc(18px / var(--scale-factor));
|
|
1036
|
-
font-weight:
|
|
1037
|
-
|
|
1040
|
+
font-weight: 600;
|
|
1041
|
+
letter-spacing: 0.01em;
|
|
1042
|
+
color: #1f2933;
|
|
1038
1043
|
cursor: pointer;
|
|
1039
|
-
box-shadow:
|
|
1044
|
+
box-shadow:
|
|
1045
|
+
0 calc(2px / var(--scale-factor)) calc(4px / var(--scale-factor)) rgba(15, 23, 42, 0.12),
|
|
1046
|
+
inset 0 calc(1px / var(--scale-factor)) calc(1px / var(--scale-factor)) rgba(255, 255, 255, 0.65);
|
|
1047
|
+
transition: transform 80ms ease, box-shadow 80ms ease, background 120ms ease;
|
|
1040
1048
|
}
|
|
1041
1049
|
.keypad-button:active {
|
|
1042
1050
|
animation: key-press 0.05s forwards;
|
|
1051
|
+
box-shadow: 0 calc(1px / var(--scale-factor)) calc(2px / var(--scale-factor)) rgba(15, 23, 42, 0.18);
|
|
1052
|
+
background: linear-gradient(180deg, rgba(248, 249, 251, 0.95) 0%, #c9d2df 100%);
|
|
1043
1053
|
}
|
|
1044
1054
|
.key-popup {
|
|
1045
1055
|
display: none;
|
|
@@ -1048,10 +1058,10 @@ function VirtualKeypad({
|
|
|
1048
1058
|
bottom: 80%;
|
|
1049
1059
|
min-width: 100%;
|
|
1050
1060
|
padding: calc(8px / var(--scale-factor)) calc(12px / var(--scale-factor));
|
|
1051
|
-
background-color:
|
|
1052
|
-
color: #
|
|
1061
|
+
background-color: rgba(248, 250, 252, 0.98);
|
|
1062
|
+
color: #0f172a;
|
|
1053
1063
|
border-radius: calc(10px / var(--scale-factor));
|
|
1054
|
-
box-shadow: 0 calc(-
|
|
1064
|
+
box-shadow: 0 calc(-4px / var(--scale-factor)) calc(18px / var(--scale-factor)) rgba(15, 23, 42, 0.18);
|
|
1055
1065
|
pointer-events: none;
|
|
1056
1066
|
font-size: calc(26px / var(--scale-factor));
|
|
1057
1067
|
font-weight: 500;
|
|
@@ -1063,7 +1073,23 @@ function VirtualKeypad({
|
|
|
1063
1073
|
display: block;
|
|
1064
1074
|
animation: key-pop 0.1s ease-out forwards;
|
|
1065
1075
|
}
|
|
1066
|
-
|
|
1076
|
+
.keypad-button.action {
|
|
1077
|
+
background: linear-gradient(180deg, #f8fafc 0%, #cbd5f5 100%);
|
|
1078
|
+
color: #1e3a8a;
|
|
1079
|
+
border-color: rgba(59, 130, 246, 0.55);
|
|
1080
|
+
}
|
|
1081
|
+
.keypad-button.active-modifier {
|
|
1082
|
+
background: linear-gradient(180deg, #e0ecff 0%, #99b7ff 100%);
|
|
1083
|
+
color: #1e3a8a;
|
|
1084
|
+
box-shadow:
|
|
1085
|
+
0 calc(3px / var(--scale-factor)) calc(6px / var(--scale-factor)) rgba(37, 99, 235, 0.25),
|
|
1086
|
+
inset 0 calc(1px / var(--scale-factor)) calc(1px / var(--scale-factor)) rgba(255, 255, 255, 0.55);
|
|
1087
|
+
}
|
|
1088
|
+
.keypad-button:focus-visible {
|
|
1089
|
+
outline: none;
|
|
1090
|
+
box-shadow: 0 0 0 calc(3px / var(--scale-factor)) rgba(59, 130, 246, 0.35);
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1067
1093
|
`,
|
|
1068
1094
|
children: /* @__PURE__ */ jsxDEV4("div", {
|
|
1069
1095
|
onFocus: handleFocus,
|
|
@@ -1079,20 +1105,40 @@ function VirtualKeypad({
|
|
|
1079
1105
|
},
|
|
1080
1106
|
children: layout?.map((row, i) => /* @__PURE__ */ jsxDEV4("div", {
|
|
1081
1107
|
className: "keypad-row",
|
|
1082
|
-
children: row.map((cell, j) =>
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1108
|
+
children: row.map((cell, j) => {
|
|
1109
|
+
const buttonClasses = ["keypad-button"];
|
|
1110
|
+
if (cell.type === "action") {
|
|
1111
|
+
buttonClasses.push("action");
|
|
1112
|
+
}
|
|
1113
|
+
if (cell.value === "Shift" && shift) {
|
|
1114
|
+
buttonClasses.push("active-modifier");
|
|
1115
|
+
}
|
|
1116
|
+
if (cell.value === "HangulMode" && hangulMode) {
|
|
1117
|
+
buttonClasses.push("active-modifier");
|
|
1118
|
+
}
|
|
1119
|
+
const style = {};
|
|
1120
|
+
if (cell.width) {
|
|
1121
|
+
style.flex = `0 0 calc(${cell.width}px / var(--scale-factor))`;
|
|
1122
|
+
}
|
|
1123
|
+
if (cell.height) {
|
|
1124
|
+
style.height = `calc(${cell.height}px / var(--scale-factor))`;
|
|
1125
|
+
}
|
|
1126
|
+
return /* @__PURE__ */ jsxDEV4("button", {
|
|
1127
|
+
type: "button",
|
|
1128
|
+
value: cell.value,
|
|
1129
|
+
"data-type": cell.type,
|
|
1130
|
+
onClick: insertCharacter,
|
|
1131
|
+
className: buttonClasses.join(" "),
|
|
1132
|
+
style,
|
|
1133
|
+
children: [
|
|
1134
|
+
getTransformedValue(cell),
|
|
1135
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
1136
|
+
className: "key-popup",
|
|
1137
|
+
children: getTransformedValue(cell)
|
|
1138
|
+
}, undefined, false, undefined, this)
|
|
1139
|
+
]
|
|
1140
|
+
}, `${i}-${j}`, true, undefined, this);
|
|
1141
|
+
})
|
|
1096
1142
|
}, i, false, undefined, this))
|
|
1097
1143
|
}, undefined, false, undefined, this)
|
|
1098
1144
|
}, undefined, false, undefined, this);
|
package/dist/types/App.d.ts
CHANGED