cnhis-design-vue 3.1.15-beta.1 → 3.1.15-beta.2
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/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +9 -5
- package/es/packages/form-render/src/components/renderer/combination.js +11 -8
- package/es/packages/form-render/src/utils/index.d.ts +1 -0
- package/es/packages/form-render/src/utils/index.js +30 -2
- package/es/packages/shortcut-provider/index.d.ts +2 -11
- package/es/packages/shortcut-provider/src/ShortcutProvider.js +1 -5
- package/es/packages/shortcut-provider/src/ShortcutProvider.vue.d.ts +2 -11
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.d.ts +11 -8
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.js +44 -28
- package/es/packages/shortcut-provider/src/types/index.d.ts +32 -4
- package/es/packages/shortcut-provider/src/utils/index.d.ts +3 -0
- package/es/packages/shortcut-provider/src/utils/index.js +15 -5
- package/es/packages/shortcut-setter/index.d.ts +6 -4
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +6 -4
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.js +6 -4
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue.d.ts +6 -4
- package/package.json +1 -1
|
@@ -2314,7 +2314,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2314
2314
|
"span-method": colspanMethod,
|
|
2315
2315
|
"footer-span-method": footerRowspanMethod,
|
|
2316
2316
|
"tooltip-config": {
|
|
2317
|
-
enterable: false
|
|
2317
|
+
enterable: false,
|
|
2318
|
+
..._ctx.$attrs.tooltipConfig || {}
|
|
2318
2319
|
},
|
|
2319
2320
|
"checkbox-config": {
|
|
2320
2321
|
checkField: "checked",
|
|
@@ -2330,10 +2331,12 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2330
2331
|
checkField: "checked",
|
|
2331
2332
|
trigger: "cell",
|
|
2332
2333
|
reserve: true,
|
|
2333
|
-
highlight: true
|
|
2334
|
+
highlight: true,
|
|
2335
|
+
..._ctx.$attrs.radioConfig || {}
|
|
2334
2336
|
},
|
|
2335
2337
|
"scroll-y": {
|
|
2336
|
-
gt: 50
|
|
2338
|
+
gt: 50,
|
|
2339
|
+
..._ctx.$attrs.scrollY || {}
|
|
2337
2340
|
},
|
|
2338
2341
|
"row-style": unref(getRowStyle),
|
|
2339
2342
|
"edit-config": state.editConfig,
|
|
@@ -2343,7 +2346,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2343
2346
|
loadMethod: unref(loadExpandMethod),
|
|
2344
2347
|
toggleMethod: unref(toggleExpandMethod),
|
|
2345
2348
|
iconOpen: "iconfont icon-a-xitongtubiaozhediejian",
|
|
2346
|
-
iconClose: "iconfont icon-a-xitongtubiaotianjia"
|
|
2349
|
+
iconClose: "iconfont icon-a-xitongtubiaotianjia",
|
|
2350
|
+
..._ctx.$attrs.expandConfig || {}
|
|
2347
2351
|
},
|
|
2348
2352
|
"keyboard-config": _ctx.columnConfig.keyboardConfig || {},
|
|
2349
2353
|
"edit-rules": _ctx.columnConfig.editRules || {},
|
|
@@ -2413,7 +2417,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2413
2417
|
}
|
|
2414
2418
|
})]),
|
|
2415
2419
|
_: 3
|
|
2416
|
-
}, 16, ["height", "seq-config", "tree-config", "cell-class-name", "row-config", "show-footer", "checkbox-config", "row-style", "edit-config", "expand-config", "keyboard-config", "edit-rules", "menu-config", "onScroll", "onKeydown"]), createCommentVNode(" `${refreshRow}\u6761\u66F4\u65B0` "), withDirectives(createElementVNode("div", {
|
|
2420
|
+
}, 16, ["height", "seq-config", "tree-config", "cell-class-name", "row-config", "show-footer", "tooltip-config", "checkbox-config", "radio-config", "scroll-y", "row-style", "edit-config", "expand-config", "keyboard-config", "edit-rules", "menu-config", "onScroll", "onKeydown"]), createCommentVNode(" `${refreshRow}\u6761\u66F4\u65B0` "), withDirectives(createElementVNode("div", {
|
|
2417
2421
|
class: "refresh",
|
|
2418
2422
|
onClick: hanldeClickRefresh
|
|
2419
2423
|
}, [createVNode(unref(NIcon), {
|
|
@@ -3,7 +3,7 @@ import { isField } from '@formily/core';
|
|
|
3
3
|
import { Path } from '../../../../../node_modules/@formily/path/esm/index.js';
|
|
4
4
|
import { flatten, isNumber } from 'lodash-es';
|
|
5
5
|
import { useFormField } from '../../../../../packages/form-render';
|
|
6
|
-
import { arrayed, assignUpdateValue, formRenderLog } from '../../utils/index.js';
|
|
6
|
+
import { arrayed, assignUpdateValue, mergeDeepProperties, formRenderLog } from '../../utils/index.js';
|
|
7
7
|
import { connect, mapProps } from '@formily/vue';
|
|
8
8
|
import { useDebounceFn, isObject } from '@vueuse/core';
|
|
9
9
|
import { NButton } from 'naive-ui';
|
|
@@ -64,7 +64,7 @@ const script = defineComponent({
|
|
|
64
64
|
});
|
|
65
65
|
function add() {
|
|
66
66
|
groupNum.value++;
|
|
67
|
-
_values.value.push({});
|
|
67
|
+
_values.value.push(mergeDeepProperties({}, props.getProperties()));
|
|
68
68
|
emitChange();
|
|
69
69
|
}
|
|
70
70
|
function remove(idx) {
|
|
@@ -82,7 +82,7 @@ const script = defineComponent({
|
|
|
82
82
|
immediate: true
|
|
83
83
|
});
|
|
84
84
|
const _values = ref([{}]);
|
|
85
|
-
function initValues(data) {
|
|
85
|
+
function initValues(data, withInitialData = false) {
|
|
86
86
|
if (!data)
|
|
87
87
|
return;
|
|
88
88
|
try {
|
|
@@ -92,10 +92,10 @@ const script = defineComponent({
|
|
|
92
92
|
parsed.forEach((v, idx) => {
|
|
93
93
|
if (idx > maxGroupNum.value - 1)
|
|
94
94
|
return;
|
|
95
|
-
if (isObject(v))
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
if (isObject(v)) {
|
|
96
|
+
_values.value[idx] = v;
|
|
97
|
+
withInitialData && mergeDeepProperties(v, props.getProperties());
|
|
98
|
+
}
|
|
99
99
|
});
|
|
100
100
|
groupNum.value = Math.min(_values.value.length, maxGroupNum.value);
|
|
101
101
|
} catch (e) {
|
|
@@ -115,7 +115,10 @@ const script = defineComponent({
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
watch(() => props.value, (value) => initValues(value));
|
|
118
|
-
onMounted(() =>
|
|
118
|
+
onMounted(() => {
|
|
119
|
+
initValues(props.value || "[{}]", true);
|
|
120
|
+
emitChange();
|
|
121
|
+
});
|
|
119
122
|
function stop(event) {
|
|
120
123
|
event.stopPropagation();
|
|
121
124
|
}
|
|
@@ -12,6 +12,7 @@ export declare function transformDateFormat(format?: string): "date" | "datetime
|
|
|
12
12
|
export declare function isIdCard(idCardNo: string): boolean;
|
|
13
13
|
export declare function isMobile(mobile: string): boolean;
|
|
14
14
|
export declare function parseBirthday(birthday: string): AgeContext;
|
|
15
|
+
export declare function mergeDeepProperties(target: AnyObject, fieldList: FieldItem[], traverseProperties?: string[], property?: string, targetProperty?: string): AnyObject;
|
|
15
16
|
export declare function parseIdCard(idCardNo: string): IdCardParseInfo;
|
|
16
17
|
export declare function injectOrProvide<T>(key: InjectionKey<T>, creator: () => T): T;
|
|
17
18
|
export declare function traverseDependKey(dependKeys: DependKeyType, handler: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { inject, provide, computed, createVNode, Fragment } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { isObject } from '@vue/shared';
|
|
3
|
+
import { isArray, isString, isFunction } from 'lodash-es';
|
|
3
4
|
import { FIELD_SEX_VALUE } from '../constants/index.js';
|
|
4
5
|
import { isField } from '@formily/core';
|
|
5
6
|
import differenceInDays from '../../../../node_modules/date-fns/esm/differenceInDays/index.js';
|
|
@@ -46,6 +47,33 @@ function parseBirthday(birthday) {
|
|
|
46
47
|
result.age = result.year = differenceInYears(d, birthDate);
|
|
47
48
|
return result;
|
|
48
49
|
}
|
|
50
|
+
function mergeDeepProperties(target, fieldList, traverseProperties = ["children", "properties", "suffixConfig"], property = "val_key", targetProperty = "default_val") {
|
|
51
|
+
function traverse(_target, _fieldList) {
|
|
52
|
+
_fieldList.forEach((field) => {
|
|
53
|
+
if (!isObject(field))
|
|
54
|
+
return;
|
|
55
|
+
if (targetPropertyFor(field) != null && _target[propertyFor(field)] == null) {
|
|
56
|
+
_target[propertyFor(field)] = targetPropertyFor(field);
|
|
57
|
+
}
|
|
58
|
+
traverseProperties.forEach((p) => {
|
|
59
|
+
if (!field[p])
|
|
60
|
+
return;
|
|
61
|
+
if (!_target[propertyFor(field)]) {
|
|
62
|
+
_target[propertyFor(field)] = {};
|
|
63
|
+
}
|
|
64
|
+
traverse(_target[propertyFor(field)], arrayed(field[p]));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
traverse(target, fieldList);
|
|
69
|
+
return target;
|
|
70
|
+
function propertyFor(field) {
|
|
71
|
+
return field[property];
|
|
72
|
+
}
|
|
73
|
+
function targetPropertyFor(field) {
|
|
74
|
+
return field[targetProperty];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
49
77
|
function parseIdCard(idCardNo) {
|
|
50
78
|
const parseInner = (certificateNo, idxSexStart, birthYearSpan) => {
|
|
51
79
|
const res = {};
|
|
@@ -172,4 +200,4 @@ function createInputSlot(props) {
|
|
|
172
200
|
});
|
|
173
201
|
}
|
|
174
202
|
|
|
175
|
-
export { arrayed, assignUpdateValue, createInputSlot, createLinebarId, createSlot, elementIdEscape, fieldKeyEscape, formRenderLog, getParentLinebar, injectOrProvide, isIdCard, isMobile, parseBirthday, parseIdCard, queryDecorator, queryInput, transformDateFormat, traverseDependKey, traverseSchema, uuidGenerator };
|
|
203
|
+
export { arrayed, assignUpdateValue, createInputSlot, createLinebarId, createSlot, elementIdEscape, fieldKeyEscape, formRenderLog, getParentLinebar, injectOrProvide, isIdCard, isMobile, mergeDeepProperties, parseBirthday, parseIdCard, queryDecorator, queryInput, transformDateFormat, traverseDependKey, traverseSchema, uuidGenerator };
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { SFCWithInstall } from '../../../es/src/types';
|
|
2
2
|
export * from './src/hooks';
|
|
3
3
|
export * from './src/types';
|
|
4
|
-
declare const ShortcutProvider: SFCWithInstall<import("vue").DefineComponent<{
|
|
5
|
-
cacheKey: StringConstructor;
|
|
6
|
-
}, {
|
|
4
|
+
declare const ShortcutProvider: SFCWithInstall<import("vue").DefineComponent<{}, {
|
|
7
5
|
shortcutWrapperRef: import("vue").Ref<HTMLElement | undefined>;
|
|
8
|
-
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
-
cacheKey: StringConstructor;
|
|
10
|
-
}>> & {
|
|
11
|
-
[x: `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;
|
|
12
|
-
}>>;
|
|
13
6
|
manager: import("./src/hooks").ShortcutManager;
|
|
14
|
-
},
|
|
15
|
-
cacheKey: StringConstructor;
|
|
16
|
-
}>>, {}>>;
|
|
7
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>>;
|
|
17
8
|
export default ShortcutProvider;
|
|
@@ -5,13 +5,9 @@ import _export_sfc from '../../../_virtual/plugin-vue_export-helper.js';
|
|
|
5
5
|
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
7
|
__name: "ShortcutProvider",
|
|
8
|
-
props: {
|
|
9
|
-
cacheKey: String
|
|
10
|
-
},
|
|
11
8
|
setup(__props) {
|
|
12
|
-
const props = __props;
|
|
13
9
|
const shortcutWrapperRef = ref();
|
|
14
|
-
const manager = new ShortcutManager(shortcutWrapperRef
|
|
10
|
+
const manager = new ShortcutManager(shortcutWrapperRef).start();
|
|
15
11
|
provide(InjectionShortcutManager, manager);
|
|
16
12
|
onBeforeUnmount(() => {
|
|
17
13
|
manager.destroy();
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { ShortcutManager } from '../../../../es/packages/shortcut-provider';
|
|
2
|
-
declare const _default: import("vue").DefineComponent<{
|
|
3
|
-
cacheKey: StringConstructor;
|
|
4
|
-
}, {
|
|
2
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
5
3
|
shortcutWrapperRef: import("vue").Ref<HTMLElement | undefined>;
|
|
6
|
-
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
-
cacheKey: StringConstructor;
|
|
8
|
-
}>> & {
|
|
9
|
-
[x: `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;
|
|
10
|
-
}>>;
|
|
11
4
|
manager: ShortcutManager;
|
|
12
|
-
},
|
|
13
|
-
cacheKey: StringConstructor;
|
|
14
|
-
}>>, {}>;
|
|
5
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
15
6
|
export default _default;
|
|
@@ -5,12 +5,13 @@ export declare class ShortcutManager {
|
|
|
5
5
|
private readonly shortcutCache;
|
|
6
6
|
private readonly environmentEle;
|
|
7
7
|
private handle?;
|
|
8
|
+
disabled: boolean;
|
|
8
9
|
static log(message: string, dryRun?: boolean): string;
|
|
9
|
-
constructor(environmentEle?: MaybeRef<HTMLElement | undefined
|
|
10
|
-
get traverse():
|
|
11
|
-
query(key: string):
|
|
12
|
-
|
|
13
|
-
update(key: string, info
|
|
10
|
+
constructor(environmentEle?: MaybeRef<HTMLElement | undefined>);
|
|
11
|
+
get traverse(): Omit<ShortcutItem, "callback">[];
|
|
12
|
+
query(key: string): Omit<ShortcutItem, "callback">;
|
|
13
|
+
updateDisabled(key: string, state?: boolean): Promise<void>;
|
|
14
|
+
update(key: string, info?: KeyboardEvent | Partial<ShortcutSignatureInfo>): Promise<void>;
|
|
14
15
|
register(shortcutItem: ShortcutItem): {
|
|
15
16
|
stop: () => void;
|
|
16
17
|
signature: () => string;
|
|
@@ -23,8 +24,10 @@ export declare function useShortcuts(glob?: boolean): {
|
|
|
23
24
|
stop: () => void;
|
|
24
25
|
signature: () => string;
|
|
25
26
|
};
|
|
26
|
-
traverse: () =>
|
|
27
|
-
query: (key: string) =>
|
|
27
|
+
traverse: () => Omit<ShortcutItem, "callback">[];
|
|
28
|
+
query: (key: string) => Omit<ShortcutItem, "callback">;
|
|
28
29
|
update: (key: string, info: KeyboardEvent | Partial<ShortcutSignatureInfo>) => void;
|
|
29
|
-
|
|
30
|
+
onReset: (key: string) => void;
|
|
31
|
+
updateDisabled: (key: string, state?: boolean) => void;
|
|
32
|
+
updateManagerDisabled: (disabled?: boolean) => void;
|
|
30
33
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { ShortcutStatus, InjectionShortcutManager } from '../../../../packages/shortcut-provider/src/constants';
|
|
2
|
-
import { getKeySignature, getDisplaySignature, isKeyboardEvent, findAncestor, isShortcutProvider } from '../../../../packages/shortcut-provider/src/utils';
|
|
3
|
-
import { reactive, unref, getCurrentInstance, inject, onBeforeUnmount } from 'vue';
|
|
4
|
-
import {
|
|
2
|
+
import { normalizeSignatureInfo, getKeySignature, getDisplaySignature, isInvalidSignature, isKeyboardEvent, findAncestor, isShortcutProvider } from '../../../../packages/shortcut-provider/src/utils';
|
|
3
|
+
import { reactive, ref, unref, getCurrentInstance, inject, onBeforeUnmount } from 'vue';
|
|
4
|
+
import { useEventListener, useDebounceFn } from '@vueuse/core';
|
|
5
5
|
import { pick, omit, isFunction, isString } from 'lodash-es';
|
|
6
6
|
|
|
7
7
|
class ShortcutManager {
|
|
8
|
-
constructor(environmentEle
|
|
8
|
+
constructor(environmentEle) {
|
|
9
9
|
this.shortcutCallbackMap = reactive(/* @__PURE__ */ new Map());
|
|
10
|
+
this.shortcutCache = ref({});
|
|
11
|
+
this.disabled = false;
|
|
10
12
|
this.environmentEle = environmentEle || window;
|
|
11
|
-
this.shortcutCache = useStorage(cacheKey, {}, localStorage, {
|
|
12
|
-
listenToStorageChanges: true,
|
|
13
|
-
deep: true
|
|
14
|
-
});
|
|
15
13
|
}
|
|
16
14
|
static log(message, dryRun = false) {
|
|
17
15
|
const _message = `[ShortcutManager] ${message}`;
|
|
@@ -24,30 +22,43 @@ class ShortcutManager {
|
|
|
24
22
|
query(key) {
|
|
25
23
|
return this.shortcutCache.value[key];
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
this.query(key) && (this.query(key).disabled = !!state);
|
|
29
|
-
}
|
|
30
|
-
update(key, info) {
|
|
25
|
+
async updateDisabled(key, state) {
|
|
31
26
|
var _a;
|
|
27
|
+
const item = this.query(key);
|
|
28
|
+
await ((_a = item.onUpdateDisabled) == null ? void 0 : _a.call(item, key, state));
|
|
29
|
+
item.disabled = !!state;
|
|
30
|
+
}
|
|
31
|
+
async update(key, info) {
|
|
32
|
+
var _a, _b;
|
|
32
33
|
const oldKeySignature = (_a = this.query(key)) == null ? void 0 : _a.currentKeySignature;
|
|
33
|
-
|
|
34
|
-
return;
|
|
35
|
-
if (Object.values(this.shortcutCache.value).some((v) => v.currentKeySignature === getKeySignature(info))) {
|
|
36
|
-
throw `\u91CD\u590D\u7684\u5FEB\u6377\u952E=> ${getDisplaySignature(info)}`;
|
|
37
|
-
}
|
|
34
|
+
info && checkSignature(this.shortcutCache, info);
|
|
38
35
|
const item = this.query(key);
|
|
39
36
|
if (!item)
|
|
40
37
|
return;
|
|
41
|
-
item.
|
|
42
|
-
|
|
38
|
+
const newInfo = await ((_b = item.onUpdate) == null ? void 0 : _b.call(item, key, info ? normalizeSignatureInfo(info) : void 0)) || info;
|
|
39
|
+
if (!newInfo)
|
|
40
|
+
return;
|
|
41
|
+
checkSignature(this.shortcutCache, newInfo);
|
|
42
|
+
item.currentKeySignature = getKeySignature(newInfo);
|
|
43
|
+
this.shortcutCallbackMap.set(item.currentKeySignature, this.shortcutCallbackMap.get(oldKeySignature));
|
|
43
44
|
this.shortcutCallbackMap.delete(oldKeySignature);
|
|
45
|
+
function checkSignature(shortcutCache, info2) {
|
|
46
|
+
if (oldKeySignature === getKeySignature(info2))
|
|
47
|
+
return;
|
|
48
|
+
if (Object.values(shortcutCache.value).some((v) => v.currentKeySignature === getKeySignature(info2))) {
|
|
49
|
+
throw `\u91CD\u590D\u7684\u5FEB\u6377\u952E=> ${getDisplaySignature(info2)}`;
|
|
50
|
+
}
|
|
51
|
+
if (isInvalidSignature(info2)) {
|
|
52
|
+
throw `\u975E\u6CD5\u7684\u5FEB\u6377\u952E=>${info2.key}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
56
|
register(shortcutItem) {
|
|
46
57
|
const item = this.query(shortcutItem.key);
|
|
47
58
|
if (item) {
|
|
48
59
|
item.status = ShortcutStatus.ACTIVE;
|
|
49
60
|
this.shortcutCallbackMap.set(item.currentKeySignature, shortcutItem.callback);
|
|
50
|
-
Object.assign(item, pick(shortcutItem, ["debounce", "debounceOption", "label", "
|
|
61
|
+
Object.assign(item, pick(shortcutItem, ["debounce", "debounceOption", "label", "order", "key"]));
|
|
51
62
|
return createHandler(item);
|
|
52
63
|
}
|
|
53
64
|
this.shortcutCache.value[shortcutItem.key] = omit(shortcutItem, ["callback"]);
|
|
@@ -68,7 +79,7 @@ class ShortcutManager {
|
|
|
68
79
|
return this;
|
|
69
80
|
}
|
|
70
81
|
this.handle = async (event) => {
|
|
71
|
-
if (!isKeyboardEvent(event))
|
|
82
|
+
if (!isKeyboardEvent(event) || this.disabled)
|
|
72
83
|
return;
|
|
73
84
|
const providerWrapper = findAncestor(event.target, isShortcutProvider);
|
|
74
85
|
if (providerWrapper && providerWrapper !== unref(this.environmentEle)) {
|
|
@@ -107,10 +118,9 @@ function useShortcuts(glob = false) {
|
|
|
107
118
|
function createShortcutItem(shortcut) {
|
|
108
119
|
return {
|
|
109
120
|
...shortcut,
|
|
110
|
-
currentKeySignature: getKeySignature(shortcut.
|
|
121
|
+
currentKeySignature: getKeySignature(shortcut.shortcutSignature),
|
|
111
122
|
key: keyFor(shortcut),
|
|
112
123
|
status: ShortcutStatus.ACTIVE,
|
|
113
|
-
disabled: false,
|
|
114
124
|
callback: callbackFor(shortcut)
|
|
115
125
|
};
|
|
116
126
|
function callbackFor(shortcut2) {
|
|
@@ -132,10 +142,10 @@ function useShortcuts(glob = false) {
|
|
|
132
142
|
}
|
|
133
143
|
function register(shortcut) {
|
|
134
144
|
const { stop, signature } = manager.register(createShortcutItem(shortcut));
|
|
135
|
-
if (getCurrentInstance()) {
|
|
145
|
+
if (getCurrentInstance() && !glob) {
|
|
136
146
|
onBeforeUnmount(stop);
|
|
137
147
|
} else {
|
|
138
|
-
ShortcutManager.log("\u5728\u975Esetup\u8BED\u5883\u4E0B\u4F7F\u7528register\u51FD\u6570,\u7EC4\u4EF6\u9500\u6BC1\u65F6\u9700\u8981\u624B\u52A8\u8C03\u7528stop\u51FD\u6570\u4F7F\u5FEB\u6377\u952E\u5931\u6D3B");
|
|
148
|
+
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");
|
|
139
149
|
}
|
|
140
150
|
return { stop, signature };
|
|
141
151
|
}
|
|
@@ -148,10 +158,16 @@ function useShortcuts(glob = false) {
|
|
|
148
158
|
function update(key, info) {
|
|
149
159
|
manager.update(key, info);
|
|
150
160
|
}
|
|
151
|
-
function
|
|
152
|
-
manager.
|
|
161
|
+
function onReset(key) {
|
|
162
|
+
manager.update(key);
|
|
163
|
+
}
|
|
164
|
+
function updateDisabled(key, state) {
|
|
165
|
+
manager.updateDisabled(key, state);
|
|
166
|
+
}
|
|
167
|
+
function updateManagerDisabled(disabled) {
|
|
168
|
+
manager.disabled = !!disabled;
|
|
153
169
|
}
|
|
154
|
-
return { register, traverse, query, update,
|
|
170
|
+
return { register, traverse, query, update, onReset, updateDisabled, updateManagerDisabled };
|
|
155
171
|
}
|
|
156
172
|
|
|
157
173
|
export { ShortcutManager, useShortcuts };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayAble } from '../../../../../es/src/types';
|
|
1
|
+
import { ArrayAble, WithUndefined } from '../../../../../es/src/types';
|
|
2
2
|
import { VNode } from 'vue';
|
|
3
3
|
import { ShortcutStatus } from '../../../../../es/packages/shortcut-provider/src/constants';
|
|
4
4
|
declare type Render = () => ArrayAble<VNode>;
|
|
@@ -8,25 +8,53 @@ export interface ShortcutSignatureInfo {
|
|
|
8
8
|
alt?: boolean;
|
|
9
9
|
key: string;
|
|
10
10
|
}
|
|
11
|
+
declare type UpdateResult = Promise<WithUndefined<ShortcutSignatureInfo> | void>;
|
|
11
12
|
export declare type ShortcutOption = {
|
|
12
13
|
label: string | Render;
|
|
13
|
-
|
|
14
|
+
shortcutSignature: ShortcutSignatureInfo;
|
|
14
15
|
callback(): void;
|
|
15
16
|
} & Partial<{
|
|
17
|
+
/**
|
|
18
|
+
* @description 重置时回调
|
|
19
|
+
* @param key
|
|
20
|
+
*/
|
|
21
|
+
onReset(key: string): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* @description 更新快捷键回调
|
|
24
|
+
* @param key
|
|
25
|
+
* @param newSignature 用户输入的快捷键签名
|
|
26
|
+
* @return
|
|
27
|
+
*/
|
|
28
|
+
onUpdate(key: string, newSignature?: ShortcutSignatureInfo): UpdateResult;
|
|
29
|
+
/**
|
|
30
|
+
* @description 更新快捷键disabled状态回调
|
|
31
|
+
* @param key
|
|
32
|
+
* @param newState
|
|
33
|
+
*/
|
|
34
|
+
onUpdateDisabled(key: string, newState?: boolean): Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* 快捷键输入框展位文本
|
|
37
|
+
*/
|
|
16
38
|
placeholder: string;
|
|
39
|
+
/**
|
|
40
|
+
* 快捷键输入框编辑状态下的展位文本
|
|
41
|
+
*/
|
|
17
42
|
editPlaceholder: string;
|
|
18
43
|
key: string;
|
|
19
44
|
order: number;
|
|
45
|
+
disabled: boolean;
|
|
20
46
|
debounce: boolean;
|
|
21
47
|
debounceOption: {
|
|
22
48
|
duration?: number;
|
|
23
49
|
};
|
|
24
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 快捷键编辑组件的操作按钮
|
|
52
|
+
*/
|
|
53
|
+
operation: Array<'state' | 'reset'>;
|
|
25
54
|
}>;
|
|
26
55
|
export interface ShortcutItem extends ShortcutOption {
|
|
27
56
|
status: ShortcutStatus;
|
|
28
57
|
currentKeySignature: string;
|
|
29
58
|
key: string;
|
|
30
|
-
disabled: boolean;
|
|
31
59
|
}
|
|
32
60
|
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ShortcutSignatureInfo } from '../../../../../es/packages/shortcut-provider/src/types';
|
|
2
2
|
export declare function isKeyboardEvent(event: any): event is KeyboardEvent;
|
|
3
|
+
export declare function normalizeSignatureInfo(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): Required<ShortcutSignatureInfo>;
|
|
3
4
|
export declare function getKeySignature(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): string;
|
|
5
|
+
export declare function inKeyBlackList(key: string): boolean | undefined;
|
|
6
|
+
export declare function isInvalidSignature(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): boolean | undefined;
|
|
4
7
|
export declare function getDisplaySignature(info: KeyboardEvent | Partial<ShortcutSignatureInfo>): string;
|
|
5
8
|
export declare function transformKey2DisplaySignature(keySignature: string): string;
|
|
6
9
|
export declare function isShortcutProvider(ele: HTMLElement): boolean;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isString } from 'lodash-es';
|
|
2
|
+
|
|
1
3
|
function isKeyboardEvent(event) {
|
|
2
4
|
return Reflect.get(event, "view") === window && Reflect.get(event, "shiftKey") != void 0;
|
|
3
5
|
}
|
|
@@ -21,12 +23,20 @@ function getKeySignature(info) {
|
|
|
21
23
|
return `${ctrl ? "Ctrl_" : ""}${shift ? "Shift_" : ""}${alt ? "Alt_" : ""}${key}`;
|
|
22
24
|
}
|
|
23
25
|
const keyBlackList = ["CONTROL", "ALT", "SHIFT"];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
function inKeyBlackList(key) {
|
|
27
|
+
if (!isString(key))
|
|
28
|
+
return;
|
|
29
|
+
return keyBlackList.includes(key.toUpperCase());
|
|
30
|
+
}
|
|
31
|
+
function isInvalidSignature(info) {
|
|
32
|
+
const { ctrl, shift, alt, key } = normalizeSignatureInfo(info);
|
|
33
|
+
if (!ctrl && !shift && !alt)
|
|
34
|
+
return !/F\d/.test(key);
|
|
35
|
+
return inKeyBlackList(key);
|
|
36
|
+
}
|
|
27
37
|
function getDisplaySignature(info) {
|
|
28
38
|
const { ctrl, shift, alt, key } = normalizeSignatureInfo(info);
|
|
29
|
-
return `${ctrl ? "Ctrl+ " : ""}${alt ? "Alt + " : ""}${shift ? "Shift + " : ""}${
|
|
39
|
+
return `${ctrl ? "Ctrl+ " : ""}${alt ? "Alt + " : ""}${shift ? "Shift + " : ""}${inKeyBlackList(key) ? "" : key}`;
|
|
30
40
|
}
|
|
31
41
|
function transformKey2DisplaySignature(keySignature) {
|
|
32
42
|
return keySignature.replace(/_/g, " + ");
|
|
@@ -46,4 +56,4 @@ function findAncestor(ele, finder) {
|
|
|
46
56
|
return next;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
export { findAncestor, getDisplaySignature, getKeySignature, isKeyboardEvent, isShortcutProvider, transformKey2DisplaySignature };
|
|
59
|
+
export { findAncestor, getDisplaySignature, getKeySignature, inKeyBlackList, isInvalidSignature, isKeyboardEvent, isShortcutProvider, normalizeSignatureInfo, transformKey2DisplaySignature };
|
|
@@ -59,10 +59,12 @@ declare const ShortcutSetter: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
59
59
|
editPlaceholder: string;
|
|
60
60
|
operation: ("disabled" | "reset")[];
|
|
61
61
|
};
|
|
62
|
-
query: (key: string) =>
|
|
62
|
+
query: (key: string) => Omit<import("..").ShortcutItem, "callback">;
|
|
63
63
|
update: (key: string, info: KeyboardEvent | Partial<import("..").ShortcutSignatureInfo>) => void;
|
|
64
|
-
updateState:
|
|
65
|
-
|
|
64
|
+
updateState: any;
|
|
65
|
+
onReset: (key: string) => void;
|
|
66
|
+
updateManagerDisabled: (disabled?: boolean | undefined) => void;
|
|
67
|
+
shortcutItem: import("vue").ComputedRef<Omit<import("..").ShortcutItem, "callback">>;
|
|
66
68
|
disabledState: import("vue").ComputedRef<boolean>;
|
|
67
69
|
currentSetShortcut: import("vue").ComputedRef<string>;
|
|
68
70
|
state: import("vue").Ref<import("./constant").ShortcutInputState>;
|
|
@@ -79,7 +81,7 @@ declare const ShortcutSetter: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
79
81
|
updateDecorator: (fn: () => unknown, afterUpdate?: (() => void) | undefined) => void;
|
|
80
82
|
onInputKeyUp: import("lodash").DebouncedFuncLeading<(event: KeyboardEvent) => void>;
|
|
81
83
|
onStop: () => void;
|
|
82
|
-
|
|
84
|
+
onSignatureReset: () => void;
|
|
83
85
|
NButton: import("vue").DefineComponent<{
|
|
84
86
|
readonly color: StringConstructor;
|
|
85
87
|
readonly textColor: StringConstructor;
|
|
@@ -59,10 +59,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
59
59
|
editPlaceholder: string;
|
|
60
60
|
operation: ("disabled" | "reset")[];
|
|
61
61
|
};
|
|
62
|
-
query: (key: string) =>
|
|
62
|
+
query: (key: string) => Omit<import("../../../../es/packages/shortcut-provider").ShortcutItem, "callback">;
|
|
63
63
|
update: (key: string, info: KeyboardEvent | Partial<import("../../../../es/packages/shortcut-provider").ShortcutSignatureInfo>) => void;
|
|
64
|
-
updateState:
|
|
65
|
-
|
|
64
|
+
updateState: any;
|
|
65
|
+
onReset: (key: string) => void;
|
|
66
|
+
updateManagerDisabled: (disabled?: boolean | undefined) => void;
|
|
67
|
+
shortcutItem: import("vue").ComputedRef<Omit<import("../../../../es/packages/shortcut-provider").ShortcutItem, "callback">>;
|
|
66
68
|
disabledState: import("vue").ComputedRef<boolean>;
|
|
67
69
|
currentSetShortcut: import("vue").ComputedRef<string>;
|
|
68
70
|
state: import("vue").Ref<import("../constant").ShortcutInputState>;
|
|
@@ -79,7 +81,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
79
81
|
updateDecorator: (fn: () => unknown, afterUpdate?: (() => void) | undefined) => void;
|
|
80
82
|
onInputKeyUp: import("lodash").DebouncedFuncLeading<(event: KeyboardEvent) => void>;
|
|
81
83
|
onStop: () => void;
|
|
82
|
-
|
|
84
|
+
onSignatureReset: () => void;
|
|
83
85
|
NButton: import("vue").DefineComponent<{
|
|
84
86
|
readonly color: StringConstructor;
|
|
85
87
|
readonly textColor: StringConstructor;
|
|
@@ -24,7 +24,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
24
24
|
},
|
|
25
25
|
setup(__props) {
|
|
26
26
|
const props = __props;
|
|
27
|
-
const { query, update, updateState } = useShortcuts(props.glob);
|
|
27
|
+
const { query, update, updateState, onReset, updateManagerDisabled } = useShortcuts(props.glob);
|
|
28
28
|
const shortcutItem = computed(() => {
|
|
29
29
|
return query(props.fieldItem.val_key);
|
|
30
30
|
});
|
|
@@ -49,11 +49,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
49
49
|
return isEditState.value ? props.placeholder : props.editPlaceholder;
|
|
50
50
|
});
|
|
51
51
|
function onInputFocus() {
|
|
52
|
+
updateManagerDisabled(true);
|
|
52
53
|
state.value = ShortcutInputState.EDIT;
|
|
53
54
|
}
|
|
54
55
|
const inputRef = ref();
|
|
55
56
|
function onInputBlur() {
|
|
56
57
|
var _a;
|
|
58
|
+
updateManagerDisabled(false);
|
|
57
59
|
state.value = ShortcutInputState.STATIC;
|
|
58
60
|
currentEditShortcut.value = "";
|
|
59
61
|
(_a = inputRef.value) == null ? void 0 : _a.blur();
|
|
@@ -78,10 +80,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
78
80
|
return;
|
|
79
81
|
updateDecorator(() => updateState(props.fieldItem.val_key, !disabledState.value), onInputBlur);
|
|
80
82
|
}
|
|
81
|
-
function
|
|
83
|
+
function onSignatureReset() {
|
|
82
84
|
if (!shortcutItem.value)
|
|
83
85
|
return;
|
|
84
|
-
updateDecorator(() =>
|
|
86
|
+
updateDecorator(() => onReset(props.fieldItem.val_key), onInputBlur);
|
|
85
87
|
}
|
|
86
88
|
return (_ctx, _cache) => {
|
|
87
89
|
return openBlock(), createElementBlock("section", _hoisted_1, [
|
|
@@ -110,7 +112,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
110
112
|
}, 8, ["type"])) : createCommentVNode("v-if", true),
|
|
111
113
|
hasOperation("reset") ? (openBlock(), createBlock(unref(NPopconfirm), {
|
|
112
114
|
key: 1,
|
|
113
|
-
onPositiveClick:
|
|
115
|
+
onPositiveClick: onSignatureReset
|
|
114
116
|
}, {
|
|
115
117
|
trigger: withCtx(() => [
|
|
116
118
|
createVNode(unref(NButton), {
|
|
@@ -49,10 +49,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
49
49
|
editPlaceholder: string;
|
|
50
50
|
operation: Array<'disabled' | 'reset'>;
|
|
51
51
|
};
|
|
52
|
-
query: (key: string) =>
|
|
52
|
+
query: (key: string) => Omit<import("../../../../es/packages/shortcut-provider").ShortcutItem, "callback">;
|
|
53
53
|
update: (key: string, info: KeyboardEvent | Partial<import("../../../../es/packages/shortcut-provider").ShortcutSignatureInfo>) => void;
|
|
54
|
-
updateState:
|
|
55
|
-
|
|
54
|
+
updateState: any;
|
|
55
|
+
onReset: (key: string) => void;
|
|
56
|
+
updateManagerDisabled: (disabled?: boolean | undefined) => void;
|
|
57
|
+
shortcutItem: import("vue").ComputedRef<Omit<import("../../../../es/packages/shortcut-provider").ShortcutItem, "callback">>;
|
|
56
58
|
disabledState: import("vue").ComputedRef<boolean>;
|
|
57
59
|
currentSetShortcut: import("vue").ComputedRef<string>;
|
|
58
60
|
state: import("vue").Ref<ShortcutInputState>;
|
|
@@ -69,7 +71,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
69
71
|
updateDecorator: (fn: () => unknown, afterUpdate?: () => void) => void;
|
|
70
72
|
onInputKeyUp: import("lodash").DebouncedFuncLeading<(event: KeyboardEvent) => void>;
|
|
71
73
|
onStop: () => void;
|
|
72
|
-
|
|
74
|
+
onSignatureReset: () => void;
|
|
73
75
|
NButton: import("vue").DefineComponent<{
|
|
74
76
|
readonly color: StringConstructor;
|
|
75
77
|
readonly textColor: StringConstructor;
|