cnhis-design-vue 3.1.13-beta.2 → 3.1.13-beta.3
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/form-render/src/components/renderer/input.js +3 -3
- package/es/packages/form-render/src/components/renderer/simpleComponent.js +2 -15
- package/es/packages/form-render/src/utils/index.d.ts +5 -2
- package/es/packages/form-render/src/utils/index.js +16 -2
- package/es/packages/index.css +11 -0
- package/es/packages/index.d.ts +4 -1
- package/es/packages/index.js +9 -1
- package/es/packages/shortcut-provider/index.d.ts +17 -0
- package/es/packages/shortcut-provider/index.js +13 -0
- package/es/packages/shortcut-provider/src/ShortcutProvider.js +4 -0
- package/es/packages/shortcut-provider/src/ShortcutProvider.vue.d.ts +15 -0
- package/es/packages/shortcut-provider/src/ShortcutProvider.vue_vue_type_script_setup_true_lang.js +32 -0
- package/es/packages/shortcut-provider/src/constants/index.d.ts +7 -0
- package/es/packages/shortcut-provider/src/constants/index.js +8 -0
- package/es/packages/shortcut-provider/src/hooks/index.d.ts +2 -0
- package/es/packages/shortcut-provider/src/hooks/index.js +2 -0
- package/es/packages/shortcut-provider/src/hooks/useShortcutSignature.d.ts +4 -0
- package/es/packages/shortcut-provider/src/hooks/useShortcutSignature.js +12 -0
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.d.ts +30 -0
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.js +157 -0
- package/es/packages/shortcut-provider/src/types/index.d.ts +30 -0
- package/es/packages/shortcut-provider/src/types/index.js +1 -0
- package/es/packages/shortcut-provider/src/utils/index.d.ts +7 -0
- package/es/packages/shortcut-provider/src/utils/index.js +49 -0
- package/es/packages/shortcut-provider/style/index.css +3 -0
- package/es/packages/shortcut-setter/constant/index.d.ts +4 -0
- package/es/packages/shortcut-setter/constant/index.js +7 -0
- package/es/packages/shortcut-setter/index.d.ts +4258 -0
- package/es/packages/shortcut-setter/index.js +11 -0
- package/es/packages/shortcut-setter/src/ShortcutSetter.js +4 -0
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +4258 -0
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue_vue_type_script_setup_true_lang.js +38 -0
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.js +4 -0
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue.d.ts +4238 -0
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue_vue_type_script_setup_true_lang.js +125 -0
- package/es/packages/shortcut-setter/style/index.css +8 -0
- package/es/src/types/index.d.ts +1 -0
- package/package.json +1 -1
package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue_vue_type_script_setup_true_lang.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { defineComponent, computed, ref, openBlock, createElementBlock, createVNode, unref, withModifiers, createElementVNode, withCtx, createTextVNode, toDisplayString } from 'vue';
|
|
2
|
+
import { debounce, isString } from 'lodash-es';
|
|
3
|
+
import { useMessage, NInput, NButton, NPopconfirm } from 'naive-ui';
|
|
4
|
+
import { useShortcuts } from '../../../packages/shortcut-provider';
|
|
5
|
+
import { transformKey2DisplaySignature, getDisplaySignature } from '../../../packages/shortcut-provider/src/utils';
|
|
6
|
+
import { ShortcutInputState } from '../../../packages/shortcut-setter/constant';
|
|
7
|
+
|
|
8
|
+
const _hoisted_1 = { class: "shortcut-setter-item__wrapper" };
|
|
9
|
+
const _hoisted_2 = { class: "shortcut-setter-item__operation" };
|
|
10
|
+
const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u91CD\u7F6E");
|
|
11
|
+
const _hoisted_4 = /* @__PURE__ */ createTextVNode(" \u786E\u8BA4\u91CD\u7F6E\u5FEB\u6377\u952E\u5417 ");
|
|
12
|
+
var script = /* @__PURE__ */ defineComponent({
|
|
13
|
+
__name: "ShortcutSetterItem",
|
|
14
|
+
props: {
|
|
15
|
+
glob: { type: Boolean, required: false },
|
|
16
|
+
value: { type: null, required: true },
|
|
17
|
+
onChange: { type: null, required: true },
|
|
18
|
+
onFocus: { type: null, required: true },
|
|
19
|
+
fieldItem: { type: null, required: true }
|
|
20
|
+
},
|
|
21
|
+
setup(__props) {
|
|
22
|
+
const props = __props;
|
|
23
|
+
const { query, update, updateState } = useShortcuts(props.glob);
|
|
24
|
+
const shortcutItem = computed(() => {
|
|
25
|
+
return query(props.fieldItem.val_key);
|
|
26
|
+
});
|
|
27
|
+
const disabledState = computed(() => {
|
|
28
|
+
var _a;
|
|
29
|
+
return !!((_a = shortcutItem.value) == null ? void 0 : _a.disabled);
|
|
30
|
+
});
|
|
31
|
+
const currentSetShortcut = computed(() => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
return transformKey2DisplaySignature((_b = (_a = shortcutItem.value) == null ? void 0 : _a.currentKeySignature) != null ? _b : "");
|
|
34
|
+
});
|
|
35
|
+
const state = ref(ShortcutInputState.STATIC);
|
|
36
|
+
const currentEditShortcut = ref("");
|
|
37
|
+
const showContent = computed(() => {
|
|
38
|
+
return state.value === ShortcutInputState.STATIC ? currentSetShortcut.value : currentEditShortcut.value;
|
|
39
|
+
});
|
|
40
|
+
function onInputFocus() {
|
|
41
|
+
state.value = ShortcutInputState.EDIT;
|
|
42
|
+
}
|
|
43
|
+
const inputRef = ref();
|
|
44
|
+
function onInputBlur() {
|
|
45
|
+
var _a;
|
|
46
|
+
state.value = ShortcutInputState.STATIC;
|
|
47
|
+
currentEditShortcut.value = "";
|
|
48
|
+
(_a = inputRef.value) == null ? void 0 : _a.blur();
|
|
49
|
+
}
|
|
50
|
+
const onInputKeyDown = debounce((event) => {
|
|
51
|
+
currentEditShortcut.value = getDisplaySignature(event);
|
|
52
|
+
}, 200, { leading: true, trailing: false });
|
|
53
|
+
const $message = useMessage();
|
|
54
|
+
function updateDecorator(fn, afterUpdate) {
|
|
55
|
+
try {
|
|
56
|
+
fn();
|
|
57
|
+
} catch (e) {
|
|
58
|
+
isString(e) && $message.error(e);
|
|
59
|
+
currentEditShortcut.value = "";
|
|
60
|
+
} finally {
|
|
61
|
+
afterUpdate == null ? void 0 : afterUpdate();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const onInputKeyUp = debounce((event) => {
|
|
65
|
+
updateDecorator(() => update(props.fieldItem.val_key, event), () => event.target.blur());
|
|
66
|
+
}, 200, { leading: true, trailing: false });
|
|
67
|
+
function onStop() {
|
|
68
|
+
if (!shortcutItem.value)
|
|
69
|
+
return;
|
|
70
|
+
updateDecorator(() => updateState(props.fieldItem.val_key, !disabledState.value), onInputBlur);
|
|
71
|
+
}
|
|
72
|
+
function onReset() {
|
|
73
|
+
if (!shortcutItem.value)
|
|
74
|
+
return;
|
|
75
|
+
updateDecorator(() => update(props.fieldItem.val_key, shortcutItem.value.defaultShortcut), onInputBlur);
|
|
76
|
+
}
|
|
77
|
+
return (_ctx, _cache) => {
|
|
78
|
+
return openBlock(), createElementBlock("section", _hoisted_1, [
|
|
79
|
+
createVNode(unref(NInput), {
|
|
80
|
+
ref_key: "inputRef",
|
|
81
|
+
ref: inputRef,
|
|
82
|
+
disabled: unref(disabledState),
|
|
83
|
+
value: unref(showContent),
|
|
84
|
+
onFocus: onInputFocus,
|
|
85
|
+
onBlur: onInputBlur,
|
|
86
|
+
onKeydown: withModifiers(unref(onInputKeyDown), ["prevent", "stop"]),
|
|
87
|
+
onKeyup: withModifiers(unref(onInputKeyUp), ["prevent", "stop"])
|
|
88
|
+
}, null, 8, ["disabled", "value", "onKeydown", "onKeyup"]),
|
|
89
|
+
createElementVNode("section", _hoisted_2, [
|
|
90
|
+
createVNode(unref(NButton), {
|
|
91
|
+
text: "",
|
|
92
|
+
onClick: onStop,
|
|
93
|
+
type: unref(disabledState) ? "info" : "warning"
|
|
94
|
+
}, {
|
|
95
|
+
default: withCtx(() => [
|
|
96
|
+
createTextVNode(toDisplayString(unref(disabledState) ? "\u542F\u7528" : "\u7981\u7528"), 1)
|
|
97
|
+
]),
|
|
98
|
+
_: 1
|
|
99
|
+
}, 8, ["type"]),
|
|
100
|
+
createVNode(unref(NPopconfirm), { onPositiveClick: onReset }, {
|
|
101
|
+
trigger: withCtx(() => [
|
|
102
|
+
createVNode(unref(NButton), {
|
|
103
|
+
disabled: unref(disabledState),
|
|
104
|
+
text: "",
|
|
105
|
+
onClick: onInputBlur,
|
|
106
|
+
type: "info"
|
|
107
|
+
}, {
|
|
108
|
+
default: withCtx(() => [
|
|
109
|
+
_hoisted_3
|
|
110
|
+
]),
|
|
111
|
+
_: 1
|
|
112
|
+
}, 8, ["disabled"])
|
|
113
|
+
]),
|
|
114
|
+
default: withCtx(() => [
|
|
115
|
+
_hoisted_4
|
|
116
|
+
]),
|
|
117
|
+
_: 1
|
|
118
|
+
})
|
|
119
|
+
])
|
|
120
|
+
]);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export { script as default };
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export declare type Func<T extends Array<any> = any[], P = any> = (...args: T) =
|
|
|
7
7
|
export declare type WithNull<T> = T | null;
|
|
8
8
|
export declare type WithUndefined<T> = T | undefined;
|
|
9
9
|
export declare type ArrayAble<T> = T | T[];
|
|
10
|
+
export declare type MapValue<T> = T extends Map<any, infer P> ? P : any;
|