cnhis-design-vue 3.1.15-beta.9 → 3.1.16-beta.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 (38) hide show
  1. package/es/packages/big-table/src/hooks/useAnnotation.js +1 -2
  2. package/es/packages/big-table/src/hooks/useColumnConfigAdaptor.js +7 -2
  3. package/es/packages/big-table/src/hooks/useEdit.js +16 -8
  4. package/es/packages/fabric-chart/src/hooks/useDraw.js +1 -0
  5. package/es/packages/fabric-chart/src/hooks/useLeft.js +1 -2
  6. package/es/packages/form-config/index.d.ts +1749 -0
  7. package/es/packages/form-config/src/FormConfig.vue.d.ts +1749 -0
  8. package/es/packages/form-config/src/components/FormConfigEdit.js +3 -3
  9. package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +1747 -0
  10. package/es/packages/form-config/style/index.css +1 -1
  11. package/es/packages/form-render/src/components/renderer/combination/index.js +3 -3
  12. package/es/packages/form-render/src/components/renderer/formItem.js +1 -2
  13. package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +2 -2
  14. package/es/packages/form-render/src/types/fieldItem.d.ts +8 -0
  15. package/es/packages/form-render/src/utils/index.d.ts +1 -0
  16. package/es/packages/form-render/src/utils/index.js +9 -2
  17. package/es/packages/form-table/src/hooks/useNuiThemeOverrides.js +1 -1
  18. package/es/packages/index.css +1 -1
  19. package/es/packages/index.d.ts +1 -0
  20. package/es/packages/index.js +1 -1
  21. package/es/packages/shortcut-provider/index.d.ts +17 -2
  22. package/es/packages/shortcut-provider/index.js +1 -1
  23. package/es/packages/shortcut-provider/src/ShortcutProvider.js +5 -1
  24. package/es/packages/shortcut-provider/src/ShortcutProvider.vue.d.ts +17 -2
  25. package/es/packages/shortcut-provider/src/hooks/index.js +1 -1
  26. package/es/packages/shortcut-provider/src/hooks/useShortcuts.d.ts +10 -10
  27. package/es/packages/shortcut-provider/src/hooks/useShortcuts.js +45 -38
  28. package/es/packages/shortcut-provider/src/types/index.d.ts +2 -19
  29. package/es/packages/shortcut-setter/index.d.ts +2 -6040
  30. package/es/packages/shortcut-setter/src/ShortcutSetter.js +60 -10
  31. package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +1 -6041
  32. package/es/packages/shortcut-setter/src/ShortcutSetterItem.js +26 -95
  33. package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue.d.ts +30 -3363
  34. package/es/packages/shortcut-setter/src/types/index.d.ts +6 -0
  35. package/es/packages/shortcut-setter/src/types/index.js +1 -0
  36. package/package.json +1 -1
  37. package/es/packages/shortcut-setter/constant/index.d.ts +0 -4
  38. package/es/packages/shortcut-setter/constant/index.js +0 -7
@@ -6,7 +6,6 @@
6
6
  padding: 16px;
7
7
  box-sizing: border-box;
8
8
  width: 200px;
9
- min-height: 400px;
10
9
  background: white;
11
10
  }
12
11
  .form-config__materialHeader {
@@ -17,6 +16,7 @@
17
16
  }
18
17
  .form-config__materialContent {
19
18
  padding: 8px;
19
+ min-height: 400px;
20
20
  display: flex;
21
21
  flex-direction: column;
22
22
  gap: 8px;
@@ -37,20 +37,20 @@ const script = defineComponent({
37
37
  const emitChange = useDebounceFn(function emitChange2() {
38
38
  emit("update:value", JSON.stringify(combinationData.value));
39
39
  }, 300);
40
- const combinationData = ref([{}]);
40
+ const combinationData = ref([]);
41
41
  const currentGroupNum = computed(() => combinationData.value.length);
42
42
  function setCombinationData(data, withInitialData = false) {
43
43
  const parsedData = getParsedData(data);
44
44
  if (!needLoad(parsedData))
45
45
  return;
46
46
  parsedData.splice(maxGroupNum.value);
47
- parsedData.forEach(setCombinationData2);
47
+ parsedData.forEach(setCombinationItemData);
48
48
  combinationData.value.splice(parsedData.length);
49
49
  combinationData.value.forEach(setFormRenderData);
50
50
  function needLoad(_data) {
51
51
  return !!_data && !isEqual(_data, combinationData.value);
52
52
  }
53
- function setCombinationData2(v, idx) {
53
+ function setCombinationItemData(v, idx) {
54
54
  if (!isObject(v))
55
55
  return;
56
56
  combinationData.value[idx] = v;
@@ -1,7 +1,6 @@
1
1
  import { defineComponent, inject, computed, createVNode } from 'vue';
2
2
  import { isVoidField } from '@formily/core';
3
3
  import { connect, mapProps } from '@formily/vue';
4
- import { isBoolean } from 'lodash-es';
5
4
  import { NFormItem } from 'naive-ui';
6
5
  import AnnotationEdit from '../../../../../packages/annotation-edit';
7
6
  import { InjectionAnnotation } from '../../../../../packages/form-render/src/constants';
@@ -36,7 +35,7 @@ const script = defineComponent({
36
35
  }, null);
37
36
  }
38
37
  const showAnnotation = computed(() => {
39
- return annotation.value && (!isBoolean(props.annotation) || props.annotation);
38
+ return annotation.value && props.annotation !== false;
40
39
  });
41
40
  const showLabel = computed(() => props.label && props.label !== " ");
42
41
  function renderLabel() {
@@ -1,7 +1,7 @@
1
1
  import { isObject } from '@vueuse/core';
2
2
  import { pick } from 'lodash-es';
3
3
  import { useFormValidator, useTypeNormalize } from '../../../../packages/form-render';
4
- import { fieldKeyEscape, arrayed, createLinebarId, elementIdEscape, transformDateFormat } from '../utils/index.js';
4
+ import { fieldKeyEscape, arrayed, createLinebarId, elementIdEscape, parseNumberFromMaybeString, transformDateFormat } from '../utils/index.js';
5
5
 
6
6
  function useFieldListAdaptor(collector, uuid) {
7
7
  const { createValidatorSchema } = useFormValidator();
@@ -54,7 +54,7 @@ function useFieldListAdaptor(collector, uuid) {
54
54
  ...pick(item, ["lazyRequest", "urlConfig"]),
55
55
  options: item.option,
56
56
  multiple: item.multi_select === "0",
57
- maxTagCount: +item.multi_select_value
57
+ maxTagCount: parseNumberFromMaybeString(item.multi_select_value)
58
58
  });
59
59
  return schema;
60
60
  };
@@ -111,6 +111,14 @@ export declare type FieldItem = {
111
111
  placeholder: string;
112
112
  validate: ValidateItem;
113
113
  option: OptionItem[];
114
+ /**
115
+ * 是否开启多选('0'表示开启, 值是反的)
116
+ */
117
+ multi_select: FormCommonState;
118
+ /**
119
+ * 多选时最大选择数量
120
+ */
121
+ multi_select_value: number | string;
114
122
  /**
115
123
  * 用于cascader控件提供层级参数
116
124
  */
@@ -15,6 +15,7 @@ export declare function parseBirthday(birthday: string): AgeContext;
15
15
  export declare function mergeDeepProperties(target: AnyObject, fieldList: FieldItem[], traverseProperties?: string[], property?: string, targetProperty?: string): AnyObject;
16
16
  export declare function parseIdCard(idCardNo: string): IdCardParseInfo;
17
17
  export declare function injectOrProvide<T>(key: InjectionKey<T>, creator: () => T): T;
18
+ export declare function parseNumberFromMaybeString(value: unknown): unknown;
18
19
  export declare function traverseDependKey(dependKeys: DependKeyType, handler: {
19
20
  (dependKey: string, valueKey: string, required?: boolean): void;
20
21
  }): void;
@@ -1,6 +1,6 @@
1
1
  import { inject, provide, computed, createVNode, Fragment } from 'vue';
2
2
  import { isObject } from '@vue/shared';
3
- import { isString, isArray, isFunction } from 'lodash-es';
3
+ import { isNumber, isString, isArray, isFunction } from 'lodash-es';
4
4
  import { FIELD_SEX_VALUE } from '../constants/index.js';
5
5
  import { isField } from '@formily/core';
6
6
  import { differenceInDays, differenceInMonths, differenceInYears } from 'date-fns';
@@ -101,6 +101,13 @@ function injectOrProvide(key, creator) {
101
101
  }
102
102
  return injected;
103
103
  }
104
+ function parseNumberFromMaybeString(value) {
105
+ if (isNumber(value))
106
+ return value;
107
+ if (isString(value))
108
+ return +value;
109
+ return value;
110
+ }
104
111
  function traverseDependKey(dependKeys, handler) {
105
112
  if (!dependKeys)
106
113
  return;
@@ -213,4 +220,4 @@ function createInputSlot(props) {
213
220
  });
214
221
  }
215
222
 
216
- export { arrayed, assignUpdateValue, createInputSlot, createLinebarId, createSlot, elementIdEscape, fieldKeyEscape, formRenderLog, getParentLinebar, injectOrProvide, isIdCard, isMobile, mergeDeepProperties, parseBirthday, parseIdCard, queryDecorator, queryInput, transformDateFormat, traverseDependKey, traverseSchema, uuidGenerator };
223
+ export { arrayed, assignUpdateValue, createInputSlot, createLinebarId, createSlot, elementIdEscape, fieldKeyEscape, formRenderLog, getParentLinebar, injectOrProvide, isIdCard, isMobile, mergeDeepProperties, parseBirthday, parseIdCard, parseNumberFromMaybeString, queryDecorator, queryInput, transformDateFormat, traverseDependKey, traverseSchema, uuidGenerator };
@@ -1,7 +1,7 @@
1
1
  function useNuiThemeOverrides() {
2
2
  const nuiThemeOverrides = {
3
3
  Input: { paddingMedium: "8px", paddingSmall: "8px", paddingLarge: "8px", paddingTiny: "8px" },
4
- InternalSelection: { paddingSingle: "8px", paddingMultiple: "8px" },
4
+ InternalSelection: { paddingSingle: "8px", paddingMultiple: "2px" },
5
5
  Form: {
6
6
  feedbackHeightMedium: "16px",
7
7
  feedbackHeightLarge: "16px",
@@ -3186,7 +3186,6 @@ body > .vxe-table--tooltip-wrapper {
3186
3186
  padding: 16px;
3187
3187
  box-sizing: border-box;
3188
3188
  width: 200px;
3189
- min-height: 400px;
3190
3189
  background: white;
3191
3190
  }
3192
3191
  .form-config__materialHeader {
@@ -3197,6 +3196,7 @@ body > .vxe-table--tooltip-wrapper {
3197
3196
  }
3198
3197
  .form-config__materialContent {
3199
3198
  padding: 8px;
3199
+ min-height: 400px;
3200
3200
  display: flex;
3201
3201
  flex-direction: column;
3202
3202
  gap: 8px;
@@ -22,6 +22,7 @@ import CShortcutSetter from './shortcut-setter';
22
22
  import CFormConfig from './form-config';
23
23
  export * from './form-render';
24
24
  export * from './shortcut-provider';
25
+ export * from './shortcut-setter';
25
26
  export * from './big-table';
26
27
  export * from './button-print';
27
28
  export * from './form-config';
@@ -54,7 +54,7 @@ export { FormItemDepsCollector, useFormItemDeps } from './form-render/src/hooks/
54
54
  export { useInitialData } from './form-render/src/hooks/useInitialData.js';
55
55
  export { useAnchor } from './form-render/src/hooks/useAnchor.js';
56
56
  export { useFormContext } from './form-render/src/hooks/useFormContext.js';
57
- export { ShortcutManager, useShortcuts } from './shortcut-provider/src/hooks/useShortcuts.js';
57
+ export { GlobalShortcutProvider, ShortcutManager, useShortcuts } from './shortcut-provider/src/hooks/useShortcuts.js';
58
58
  export { useShortcutSignature } from './shortcut-provider/src/hooks/useShortcutSignature.js';
59
59
  export { useColumnConfigAdaptor } from './big-table/src/hooks/useColumnConfigAdaptor.js';
60
60
  export { Print } from './button-print/src/utils/print.js';
@@ -1,8 +1,23 @@
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<{}, {
4
+ declare const ShortcutProvider: SFCWithInstall<import("vue").DefineComponent<{
5
+ scope: {
6
+ type: (SymbolConstructor | StringConstructor)[];
7
+ };
8
+ }, {
9
+ props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
10
+ scope: {
11
+ type: (SymbolConstructor | StringConstructor)[];
12
+ };
13
+ }>> & {
14
+ [x: `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;
15
+ }>>;
5
16
  shortcutWrapperRef: import("vue").Ref<HTMLElement | undefined>;
6
17
  manager: import("./src/hooks").ShortcutManager;
7
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>>;
18
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
19
+ scope: {
20
+ type: (SymbolConstructor | StringConstructor)[];
21
+ };
22
+ }>>, {}>>;
8
23
  export default ShortcutProvider;
@@ -1,7 +1,7 @@
1
1
  import { COMPONENT_NAMESPACE } from '../../src/global/variable';
2
2
  import { safeComponentRegister } from '../../src/utils';
3
3
  import script from './src/ShortcutProvider.js';
4
- export { ShortcutManager, useShortcuts } from './src/hooks/useShortcuts.js';
4
+ export { GlobalShortcutProvider, ShortcutManager, useShortcuts } from './src/hooks/useShortcuts.js';
5
5
  export { useShortcutSignature } from './src/hooks/useShortcutSignature.js';
6
6
 
7
7
  const ShortcutProvider = script;
@@ -5,9 +5,13 @@ 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
+ scope: { type: [String, Symbol] }
10
+ },
8
11
  setup(__props) {
12
+ const props = __props;
9
13
  const shortcutWrapperRef = ref();
10
- const manager = new ShortcutManager(shortcutWrapperRef).start();
14
+ const manager = new ShortcutManager(shortcutWrapperRef, props.scope || String(Date.now())).start();
11
15
  provide(InjectionShortcutManager, manager);
12
16
  onBeforeUnmount(() => {
13
17
  manager.destroy();
@@ -1,6 +1,21 @@
1
1
  import { ShortcutManager } from '../../../../es/packages/shortcut-provider';
2
- declare const _default: import("vue").DefineComponent<{}, {
2
+ declare const _default: import("vue").DefineComponent<{
3
+ scope: {
4
+ type: (SymbolConstructor | StringConstructor)[];
5
+ };
6
+ }, {
7
+ props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
8
+ scope: {
9
+ type: (SymbolConstructor | StringConstructor)[];
10
+ };
11
+ }>> & {
12
+ [x: `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;
13
+ }>>;
3
14
  shortcutWrapperRef: import("vue").Ref<HTMLElement | undefined>;
4
15
  manager: ShortcutManager;
5
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
16
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
17
+ scope: {
18
+ type: (SymbolConstructor | StringConstructor)[];
19
+ };
20
+ }>>, {}>;
6
21
  export default _default;
@@ -1,2 +1,2 @@
1
- export { ShortcutManager, useShortcuts } from './useShortcuts.js';
1
+ export { GlobalShortcutProvider, ShortcutManager, useShortcuts } from './useShortcuts.js';
2
2
  export { useShortcutSignature } from './useShortcutSignature.js';
@@ -1,5 +1,6 @@
1
- import { ShortcutItem, ShortcutOption, ShortcutSignatureInfo } from '../../../../../es/packages/shortcut-provider/src/types';
2
1
  import { MaybeRef } from '@vueuse/core';
2
+ import { ShortcutItem, ShortcutOption, ShortcutSignatureInfo } from '../../../../../es/packages/shortcut-provider/src/types';
3
+ export declare const GlobalShortcutProvider: unique symbol;
3
4
  export declare class ShortcutManager {
4
5
  private readonly shortcutCallbackMap;
5
6
  private readonly shortcutCache;
@@ -7,27 +8,26 @@ export declare class ShortcutManager {
7
8
  private handle?;
8
9
  disabled: boolean;
9
10
  static log(message: string, dryRun?: boolean): string;
10
- constructor(environmentEle?: MaybeRef<HTMLElement | undefined>);
11
+ constructor(environmentEle?: MaybeRef<HTMLElement | undefined>, scope?: string | Symbol);
11
12
  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>;
13
+ private query;
14
+ update(key: string, info: KeyboardEvent | Partial<ShortcutSignatureInfo>): Promise<void>;
15
15
  register(shortcutItem: ShortcutItem): {
16
16
  stop: () => void;
17
+ start: () => void;
17
18
  signature: () => string;
18
19
  };
19
20
  start(): this;
20
21
  destroy(): void;
22
+ clear(): void;
21
23
  }
22
- export declare function useShortcuts(glob?: boolean): {
24
+ export declare function useShortcuts(scope?: MaybeRef<string | Symbol | undefined>): {
23
25
  register: (shortcut: ShortcutOption) => {
24
26
  stop: () => void;
25
27
  signature: () => string;
26
28
  };
27
29
  traverse: () => Omit<ShortcutItem, "callback">[];
28
- query: (key: string) => Omit<ShortcutItem, "callback">;
29
- update: (key: string, info: KeyboardEvent | Partial<ShortcutSignatureInfo>) => void;
30
- onReset: (key: string) => void;
31
- updateDisabled: (key: string, state?: boolean) => void;
30
+ clear: () => void;
31
+ update: (key: string, info: KeyboardEvent | Partial<ShortcutSignatureInfo>) => Promise<void>;
32
32
  updateManagerDisabled: (disabled?: boolean) => void;
33
33
  };
@@ -1,15 +1,18 @@
1
- import { ShortcutStatus, InjectionShortcutManager } from '../../../../packages/shortcut-provider/src/constants';
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
1
  import { useEventListener, useDebounceFn } from '@vueuse/core';
5
2
  import { pick, omit, isFunction, isString } from 'lodash-es';
3
+ import { reactive, ref, unref, computed, getCurrentInstance, inject, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
4
+ import { ShortcutStatus, InjectionShortcutManager } from '../../../../packages/shortcut-provider/src/constants';
5
+ import { normalizeSignatureInfo, getKeySignature, getDisplaySignature, isInvalidSignature, isKeyboardEvent, findAncestor, isShortcutProvider } from '../../../../packages/shortcut-provider/src/utils';
6
6
 
7
+ const GlobalShortcutProvider = Symbol("Glob");
8
+ const ShortcutManagerCacheMap = /* @__PURE__ */ new Map();
7
9
  class ShortcutManager {
8
- constructor(environmentEle) {
10
+ constructor(environmentEle, scope = GlobalShortcutProvider) {
9
11
  this.shortcutCallbackMap = reactive(/* @__PURE__ */ new Map());
10
12
  this.shortcutCache = ref({});
11
13
  this.disabled = false;
12
14
  this.environmentEle = environmentEle || window;
15
+ ShortcutManagerCacheMap.set(scope, this);
13
16
  }
14
17
  static log(message, dryRun = false) {
15
18
  const _message = `[ShortcutManager] ${message}`;
@@ -22,12 +25,6 @@ class ShortcutManager {
22
25
  query(key) {
23
26
  return this.shortcutCache.value[key];
24
27
  }
25
- async updateDisabled(key, state) {
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
28
  async update(key, info) {
32
29
  var _a, _b;
33
30
  const oldKeySignature = (_a = this.query(key)) == null ? void 0 : _a.currentKeySignature;
@@ -35,11 +32,10 @@ class ShortcutManager {
35
32
  const item = this.query(key);
36
33
  if (!item)
37
34
  return;
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);
35
+ await ((_b = item.onUpdate) == null ? void 0 : _b.call(item, key, info ? normalizeSignatureInfo(info) : void 0));
36
+ checkSignature(this.shortcutCache, info);
37
+ item.currentKeySignature = getKeySignature(info);
38
+ item.shortcutSignature = normalizeSignatureInfo(info);
43
39
  this.shortcutCallbackMap.set(item.currentKeySignature, this.shortcutCallbackMap.get(oldKeySignature));
44
40
  this.shortcutCallbackMap.delete(oldKeySignature);
45
41
  function checkSignature(shortcutCache, info2) {
@@ -69,6 +65,9 @@ class ShortcutManager {
69
65
  stop: () => {
70
66
  shortcut.status = ShortcutStatus.INACTIVE;
71
67
  },
68
+ start: () => {
69
+ shortcut.status = ShortcutStatus.ACTIVE;
70
+ },
72
71
  signature: () => shortcut.currentKeySignature
73
72
  };
74
73
  }
@@ -101,23 +100,35 @@ class ShortcutManager {
101
100
  var _a;
102
101
  this.handle && ((_a = unref(this.environmentEle)) == null ? void 0 : _a.removeEventListener("keyup", this.handle, { capture: true }));
103
102
  this.handle = void 0;
103
+ this.clear();
104
+ }
105
+ clear() {
104
106
  this.shortcutCallbackMap.clear();
107
+ this.shortcutCache.value = {};
105
108
  }
106
109
  }
107
110
  const globManager = new ShortcutManager().start();
108
- function useShortcuts(glob = false) {
111
+ function useShortcuts(scope) {
109
112
  function useManager() {
110
- if (getCurrentInstance() && !glob) {
111
- return inject(InjectionShortcutManager, globManager);
112
- } else {
113
- ShortcutManager.log("\u975Esetup\u8BED\u5883\u4E0B\u7684shortcut\u5C06\u5F71\u54CD\u5168\u5C40");
114
- return globManager;
115
- }
113
+ return computed(() => {
114
+ if (unref(scope)) {
115
+ const result = ShortcutManagerCacheMap.get(unref(scope));
116
+ if (!result)
117
+ ShortcutManager.log(`\u4E0D\u5B58\u5728\u7684scope=>${scope}, \u5C06\u4F7F\u7528\u5168\u5C40\u5FEB\u6377\u952E`);
118
+ return result || globManager;
119
+ } else if (getCurrentInstance()) {
120
+ return inject(InjectionShortcutManager, globManager);
121
+ } else {
122
+ ShortcutManager.log("\u975Esetup\u8BED\u5883\u4E0B\u7684shortcut\u5C06\u5F71\u54CD\u5168\u5C40");
123
+ return globManager;
124
+ }
125
+ });
116
126
  }
117
127
  const manager = useManager();
118
128
  function createShortcutItem(shortcut) {
119
129
  return {
120
130
  ...shortcut,
131
+ shortcutSignature: normalizeSignatureInfo(shortcut.shortcutSignature),
121
132
  currentKeySignature: getKeySignature(shortcut.shortcutSignature),
122
133
  key: keyFor(shortcut),
123
134
  status: ShortcutStatus.ACTIVE,
@@ -141,33 +152,29 @@ function useShortcuts(glob = false) {
141
152
  }
142
153
  }
143
154
  function register(shortcut) {
144
- const { stop, signature } = manager.register(createShortcutItem(shortcut));
145
- if (getCurrentInstance() && !glob) {
155
+ const { stop, signature, start } = unref(manager).register(createShortcutItem(shortcut));
156
+ if (getCurrentInstance()) {
146
157
  onBeforeUnmount(stop);
158
+ onDeactivated(stop);
159
+ onActivated(start);
147
160
  } else {
148
161
  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");
149
162
  }
150
163
  return { stop, signature };
151
164
  }
152
165
  function traverse() {
153
- return glob ? globManager.traverse : manager.traverse;
154
- }
155
- function query(key) {
156
- return manager.query(key);
166
+ return unref(manager).traverse;
157
167
  }
158
168
  function update(key, info) {
159
- manager.update(key, info);
160
- }
161
- function onReset(key) {
162
- manager.update(key);
163
- }
164
- function updateDisabled(key, state) {
165
- manager.updateDisabled(key, state);
169
+ return unref(manager).update(key, info);
166
170
  }
167
171
  function updateManagerDisabled(disabled) {
168
- manager.disabled = !!disabled;
172
+ unref(manager).disabled = !!disabled;
173
+ }
174
+ function clear() {
175
+ unref(manager).clear();
169
176
  }
170
- return { register, traverse, query, update, onReset, updateDisabled, updateManagerDisabled };
177
+ return { register, traverse, clear, update, updateManagerDisabled };
171
178
  }
172
179
 
173
- export { ShortcutManager, useShortcuts };
180
+ export { GlobalShortcutProvider, ShortcutManager, useShortcuts };
@@ -1,37 +1,21 @@
1
- import { ArrayAble, WithUndefined } from '../../../../../es/src/types';
2
- import { VNode } from 'vue';
3
1
  import { ShortcutStatus } from '../../../../../es/packages/shortcut-provider/src/constants';
4
- declare type Render = () => ArrayAble<VNode>;
5
2
  export interface ShortcutSignatureInfo {
6
3
  ctrl?: boolean;
7
4
  shift?: boolean;
8
5
  alt?: boolean;
9
6
  key: string;
10
7
  }
11
- declare type UpdateResult = Promise<WithUndefined<ShortcutSignatureInfo> | void>;
12
8
  export declare type ShortcutOption = {
13
- label: string | Render;
9
+ label: string;
14
10
  shortcutSignature: ShortcutSignatureInfo;
15
11
  callback(): void;
16
12
  } & Partial<{
17
- /**
18
- * @description 重置时回调
19
- * @param key
20
- */
21
- onReset(key: string): Promise<any>;
22
13
  /**
23
14
  * @description 更新快捷键回调
24
15
  * @param key
25
16
  * @param newSignature 用户输入的快捷键签名
26
- * @return
27
- */
28
- onUpdate(key: string, newSignature?: ShortcutSignatureInfo): UpdateResult;
29
- /**
30
- * @description 更新快捷键disabled状态回调
31
- * @param key
32
- * @param newState
33
17
  */
34
- onUpdateDisabled(key: string, newState?: boolean): Promise<any>;
18
+ onUpdate(key: string, newSignature?: ShortcutSignatureInfo): Promise<void>;
35
19
  /**
36
20
  * 快捷键输入框展位文本
37
21
  */
@@ -57,4 +41,3 @@ export interface ShortcutItem extends ShortcutOption {
57
41
  currentKeySignature: string;
58
42
  key: string;
59
43
  }
60
- export {};