cnhis-design-vue 3.1.29-beta.5 → 3.1.29-beta.6
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/es/components/keyboard/index.d.ts +1 -0
- package/es/components/keyboard/src/Keyboard.js +11 -5
- package/es/components/keyboard/src/Keyboard.vue.d.ts +1 -0
- package/es/components/shortcut-provider/src/hooks/useShortcuts.js +5 -3
- package/es/components/shortcut-provider/src/utils/index.d.ts +4 -2
- package/es/components/shortcut-provider/src/utils/index.js +28 -7
- package/package.json +2 -2
|
@@ -21,6 +21,7 @@ declare const Keyboard: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
21
21
|
onKeydown?: ((...args: any[]) => any) | undefined;
|
|
22
22
|
}>>;
|
|
23
23
|
emit: (event: "change" | "keydown", ...args: any[]) => void;
|
|
24
|
+
popoverRef: import("vue").Ref<null>;
|
|
24
25
|
numberKeys: import("vue").Ref<string[]>;
|
|
25
26
|
days: import("vue").Ref<number[]>;
|
|
26
27
|
doses: import("vue").Ref<number[]>;
|
|
@@ -36,6 +36,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
36
36
|
const ENGLISHOTHERKEY = ["switch", " ", "undo", "Enter"];
|
|
37
37
|
const ENGLISHKEYS = ENGLISHKEY.split("").concat(ENGLISHOTHERKEY);
|
|
38
38
|
const ENGLISHKEYS_ = ENGLISHKEY.split(".")[0].split("").sort().concat(["."], ENGLISHOTHERKEY);
|
|
39
|
+
const popoverRef = ref(null);
|
|
39
40
|
const numberKeys = ref(NUMBERKEYS.split(""));
|
|
40
41
|
const days = ref(DAYS);
|
|
41
42
|
const doses = ref([2, 3, 4, 5, 6, 7, 8]);
|
|
@@ -50,7 +51,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
50
51
|
const isDay = computed(() => props.mode === "day");
|
|
51
52
|
const isDose = computed(() => props.mode === "dose");
|
|
52
53
|
function keydown(key) {
|
|
53
|
-
var _a, _b;
|
|
54
|
+
var _a, _b, _c;
|
|
54
55
|
if (props.mode === "default") {
|
|
55
56
|
if (key !== "switch") {
|
|
56
57
|
emit("keydown", key);
|
|
@@ -66,13 +67,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
66
67
|
}
|
|
67
68
|
case "enter":
|
|
68
69
|
value.value = +inputValue.value;
|
|
70
|
+
(_a = popoverRef.value) == null ? void 0 : _a.setShow(false);
|
|
69
71
|
emit("change", value.value);
|
|
70
72
|
break;
|
|
71
73
|
default:
|
|
72
74
|
if (typeof key === "number") {
|
|
73
75
|
inputValue.value = key.toString();
|
|
74
76
|
} else {
|
|
75
|
-
inputValue.value = (((
|
|
77
|
+
inputValue.value = (((_c = (_b = inputValue.value) == null ? void 0 : _b.toString) == null ? void 0 : _c.call(_b)) || "") + key;
|
|
76
78
|
}
|
|
77
79
|
break;
|
|
78
80
|
}
|
|
@@ -88,16 +90,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
88
90
|
return (_ctx, _cache) => {
|
|
89
91
|
return !unref(isDefault) ? (openBlock(), createBlock(unref(NPopover), {
|
|
90
92
|
key: 0,
|
|
93
|
+
ref_key: "popoverRef",
|
|
94
|
+
ref: popoverRef,
|
|
91
95
|
trigger: "click",
|
|
92
96
|
"show-arrow": false,
|
|
93
97
|
placement: "bottom-start",
|
|
94
|
-
style: { "padding": "0" }
|
|
98
|
+
style: { "padding": "0" },
|
|
99
|
+
"display-directive": "show"
|
|
95
100
|
}, {
|
|
96
101
|
trigger: withCtx(() => [
|
|
97
102
|
createVNode(unref(NInputNumber), {
|
|
98
103
|
value: value.value,
|
|
99
104
|
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => value.value = $event),
|
|
100
|
-
style: { "width": "200px" }
|
|
105
|
+
style: { "width": "200px" },
|
|
106
|
+
"show-button": false
|
|
101
107
|
}, null, 8, ["value"])
|
|
102
108
|
]),
|
|
103
109
|
default: withCtx(() => [
|
|
@@ -207,7 +213,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
207
213
|
])
|
|
208
214
|
]),
|
|
209
215
|
_: 1
|
|
210
|
-
})) : (openBlock(), createElementBlock("div", _hoisted_11, [
|
|
216
|
+
}, 512)) : (openBlock(), createElementBlock("div", _hoisted_11, [
|
|
211
217
|
createVNode(unref(NSpace), {
|
|
212
218
|
"wrap-item": false,
|
|
213
219
|
align: "center",
|
|
@@ -21,6 +21,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
21
21
|
onKeydown?: ((...args: any[]) => any) | undefined;
|
|
22
22
|
}>>;
|
|
23
23
|
emit: (event: "change" | "keydown", ...args: any[]) => void;
|
|
24
|
+
popoverRef: import("vue").Ref<null>;
|
|
24
25
|
numberKeys: import("vue").Ref<string[]>;
|
|
25
26
|
days: import("vue").Ref<number[]>;
|
|
26
27
|
doses: import("vue").Ref<number[]>;
|
|
@@ -3,7 +3,7 @@ import { useEventListener, useDebounceFn } from '@vueuse/core';
|
|
|
3
3
|
import { once, pick, omit, isFunction, isString } from 'lodash-es';
|
|
4
4
|
import { reactive, ref, unref, computed, getCurrentInstance, inject, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
|
|
5
5
|
import { ShortcutStatus, InjectionShortcutManager } from '../constants/index.js';
|
|
6
|
-
import { normalizeSignatureInfo, getKeySignature, getDisplaySignature, isInvalidSignature, isKeyboardEvent, isShortcutProvider } from '../utils/index.js';
|
|
6
|
+
import { normalizeSignatureInfo, getKeySignature, getDisplaySignature, isInvalidSignature, isKeyboardEvent, isShortcutProvider, isInvalidKeyboardEvent } from '../utils/index.js';
|
|
7
7
|
|
|
8
8
|
const GlobalShortcutProvider = Symbol("Glob");
|
|
9
9
|
const ShortcutManagerCacheMap = /* @__PURE__ */ new Map();
|
|
@@ -82,7 +82,7 @@ class ShortcutManager {
|
|
|
82
82
|
if (!isKeyboardEvent(event) || this.disabled)
|
|
83
83
|
return;
|
|
84
84
|
const providerWrapper = findAncestor(event.target, isShortcutProvider);
|
|
85
|
-
if (providerWrapper && providerWrapper !== unref(this.environmentEle)) {
|
|
85
|
+
if (providerWrapper && providerWrapper !== unref(this.environmentEle) || isInvalidKeyboardEvent(event)) {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
const keySignature = getKeySignature(event);
|
|
@@ -113,7 +113,9 @@ class ShortcutManager {
|
|
|
113
113
|
}
|
|
114
114
|
const globManager = new ShortcutManager().start();
|
|
115
115
|
const onceSetupWarn = once(() => ShortcutManager.log("\u975Esetup\u8BED\u5883\u4E0B\u7684shortcut\u5C06\u5F71\u54CD\u5168\u5C40"));
|
|
116
|
-
const onceRegisterWarn = once(
|
|
116
|
+
const onceRegisterWarn = once(
|
|
117
|
+
() => ShortcutManager.log("\u5728\u975Esetup\u8BED\u5883\u4E0B\u4F7F\u7528register\u51FD\u6570,\u7EC4\u4EF6\u9500\u6BC1\u65F6\u53EF\u80FD\u9700\u8981\u624B\u52A8\u8C03\u7528stop\u51FD\u6570\u4F7F\u5FEB\u6377\u952E\u5931\u6D3B")
|
|
118
|
+
);
|
|
117
119
|
function useShortcuts(scope) {
|
|
118
120
|
function useManager() {
|
|
119
121
|
return computed(() => {
|
|
@@ -2,8 +2,10 @@ import { ShortcutSignatureInfo } from '../../../../../es/components/shortcut-pro
|
|
|
2
2
|
export declare function isKeyboardEvent(event: any): event is KeyboardEvent;
|
|
3
3
|
export declare function normalizeSignatureInfo(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): Required<ShortcutSignatureInfo>;
|
|
4
4
|
export declare function getKeySignature(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): string;
|
|
5
|
-
export declare function inKeyBlackList(key: string): boolean
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function inKeyBlackList(key: string): boolean;
|
|
6
|
+
export declare function isInvalidKeyboardEvent(event: KeyboardEvent): boolean;
|
|
7
|
+
export declare function isInvalidSignatureAtInput(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): boolean;
|
|
8
|
+
export declare function isInvalidSignature(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): boolean;
|
|
7
9
|
export declare function getDisplaySignature(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): string;
|
|
8
10
|
export declare function transformKey2DisplaySignature(keySignature: string): string;
|
|
9
11
|
export declare function isShortcutProvider(ele: HTMLElement): boolean;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isString } from 'lodash-es';
|
|
2
2
|
|
|
3
|
+
function isAlphanumeric(key) {
|
|
4
|
+
return /^[\dA-Za-z]$/.test(key);
|
|
5
|
+
}
|
|
6
|
+
function isPunctuation(key) {
|
|
7
|
+
return /^[,。;‘【】、\-=|+,.\/;’\[\]\\ ]$/.test(key);
|
|
8
|
+
}
|
|
9
|
+
function isFnNumberChar(key) {
|
|
10
|
+
return /^[!@#$%^&*()_+|~!¥…()—|~]$/.test(key);
|
|
11
|
+
}
|
|
3
12
|
function isKeyboardEvent(event) {
|
|
4
13
|
return Reflect.get(event, "view") === window && Reflect.get(event, "shiftKey") != void 0;
|
|
5
14
|
}
|
|
@@ -25,24 +34,36 @@ function getKeySignature(info) {
|
|
|
25
34
|
const keyBlackList = ["CONTROL", "ALT", "SHIFT"];
|
|
26
35
|
function inKeyBlackList(key) {
|
|
27
36
|
if (!isString(key))
|
|
28
|
-
return;
|
|
37
|
+
return false;
|
|
29
38
|
return keyBlackList.includes(key.toUpperCase());
|
|
30
39
|
}
|
|
31
|
-
function
|
|
40
|
+
function isInvalidKeyboardEvent(event) {
|
|
41
|
+
const target = event.target;
|
|
42
|
+
if (target.tagName !== "INPUT")
|
|
43
|
+
return false;
|
|
44
|
+
return isInvalidSignatureAtInput(event);
|
|
45
|
+
}
|
|
46
|
+
function isInvalidSignatureAtInput(info) {
|
|
32
47
|
const { ctrl, shift, alt, key } = normalizeSignatureInfo(info);
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
48
|
+
if (ctrl || alt)
|
|
49
|
+
return false;
|
|
50
|
+
if (shift)
|
|
51
|
+
return isFnNumberChar(key);
|
|
52
|
+
return isAlphanumeric(key) || isPunctuation(key);
|
|
53
|
+
}
|
|
54
|
+
function isInvalidSignature(info) {
|
|
55
|
+
const { key } = normalizeSignatureInfo(info);
|
|
35
56
|
return inKeyBlackList(key);
|
|
36
57
|
}
|
|
37
58
|
function getDisplaySignature(info) {
|
|
38
59
|
const { ctrl, shift, alt, key } = normalizeSignatureInfo(info);
|
|
39
|
-
return `${ctrl ? "Ctrl+ " : ""}${alt ? "Alt + " : ""}${shift ? "Shift + " : ""}${inKeyBlackList(key) ? "" : key}`;
|
|
60
|
+
return `${ctrl ? "Ctrl + " : ""}${alt ? "Alt + " : ""}${shift ? "Shift + " : ""}${inKeyBlackList(key) ? "" : key.replace(" ", "SPACE")}`;
|
|
40
61
|
}
|
|
41
62
|
function transformKey2DisplaySignature(keySignature) {
|
|
42
|
-
return keySignature.replace(/_/g, " + ");
|
|
63
|
+
return keySignature.replace(" ", "SPACE").replace(/_/g, " + ");
|
|
43
64
|
}
|
|
44
65
|
function isShortcutProvider(ele) {
|
|
45
66
|
return ele && ele.getAttribute("is-shortcut-capture") != void 0;
|
|
46
67
|
}
|
|
47
68
|
|
|
48
|
-
export { getDisplaySignature, getKeySignature, inKeyBlackList, isInvalidSignature, isKeyboardEvent, isShortcutProvider, normalizeSignatureInfo, transformKey2DisplaySignature };
|
|
69
|
+
export { getDisplaySignature, getKeySignature, inKeyBlackList, isInvalidKeyboardEvent, isInvalidSignature, isInvalidSignatureAtInput, isKeyboardEvent, isShortcutProvider, normalizeSignatureInfo, transformKey2DisplaySignature };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cnhis-design-vue",
|
|
3
|
-
"version": "3.1.29-beta.
|
|
3
|
+
"version": "3.1.29-beta.6",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"module": "./es/components/index.js",
|
|
6
6
|
"main": "./es/components/index.js",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"iOS 7",
|
|
62
62
|
"last 3 iOS versions"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "512e1266b8b36792254b134e3a861ba60b14d53f"
|
|
65
65
|
}
|