@uiwwsw/virtual-keyboard 0.3.6 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +76 -30
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -17,6 +17,7 @@
17
17
 
18
18
  ## Key Features
19
19
 
20
+ - ❤️ **Without <input /> **: No input, No contentEditable. Just div.
20
21
  - ✨ **Composition-Free Input**: Directly handles Korean character composition, bypassing native IME events to prevent common bugs.
21
22
  - 🎹 **Customizable Keyboard UI**: Provides a default keyboard and supports fully custom layouts for any use case (e.g., number pads, phone keypads).
22
23
  - 📱 **Mobile-First**: Blocks the native mobile keyboard for a consistent and controlled user experience in web apps.
package/dist/index.js CHANGED
@@ -561,7 +561,7 @@ function parseKeyInput(e, hangulMode) {
561
561
  };
562
562
  }
563
563
  }
564
- if (hangulMode) {
564
+ if (hangulMode && e.key.length === 1) {
565
565
  return {
566
566
  handled: true,
567
567
  text: isHangul(e.key) ? e.key : convertQwertyToHangul(e.key),
@@ -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: #f0f2f5;
1000
- padding: calc(8px / var(--scale-factor));
1002
+ background-color: #e8eaee;
1003
+ padding: calc(12px / var(--scale-factor));
1001
1004
  box-sizing: border-box;
1002
- gap: calc(8px / var(--scale-factor));
1003
- box-shadow: 0 calc(-2px / var(--scale-factor)) calc(10px / var(--scale-factor)) rgba(0, 0, 0, 0.1);
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(8px / var(--scale-factor));
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-color: #ffffff;
1033
- border: calc(1px / var(--scale-factor)) solid #ccc;
1034
- border-radius: calc(8px / var(--scale-factor));
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: 500;
1037
- color: #333;
1040
+ font-weight: 600;
1041
+ letter-spacing: 0.01em;
1042
+ color: #1f2933;
1038
1043
  cursor: pointer;
1039
- box-shadow: 0 calc(2px / var(--scale-factor)) calc(2px / var(--scale-factor)) rgba(0, 0, 0, 0.05);
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: #f9fafb;
1052
- color: #333;
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(-2px / var(--scale-factor)) calc(10px / var(--scale-factor)) rgba(0, 0, 0, 0.15);
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) => /* @__PURE__ */ jsxDEV4("button", {
1083
- type: "button",
1084
- value: cell.value,
1085
- "data-type": cell.type,
1086
- onClick: insertCharacter,
1087
- className: `keypad-button ${cell.type === "action" ? "action" : ""}`,
1088
- children: [
1089
- getTransformedValue(cell),
1090
- /* @__PURE__ */ jsxDEV4("div", {
1091
- className: "key-popup",
1092
- children: getTransformedValue(cell)
1093
- }, undefined, false, undefined, this)
1094
- ]
1095
- }, `${i}-${j}`, true, undefined, this))
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiwwsw/virtual-keyboard",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "types": "dist/types/index.d.ts",
6
6
  "main": "dist/index.js",