@me-framework/me-ui-antdv-next 0.0.34 → 0.0.35
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/dist/index.d.ts +7 -1
- package/dist/input-json/index.css +1 -0
- package/dist/input-json/index.d.ts +4 -0
- package/dist/input-json/index.js +208 -0
- package/dist/input-json/index.vue.d.ts +50 -0
- package/dist/input-json/types.d.ts +69 -0
- package/dist/input-number/index.css +1 -0
- package/dist/input-number/index.d.ts +4 -0
- package/dist/input-number/index.js +170 -0
- package/dist/input-number/index.vue.d.ts +44 -0
- package/dist/input-number/types.d.ts +66 -0
- package/dist/input-property/index.css +1 -1
- package/dist/input-property/index.js +280 -273
- package/dist/input-property/index.vue.d.ts +2 -2
- package/dist/input-radio/index.css +1 -1
- package/dist/input-radio/index.js +70 -33
- package/dist/input-radio/index.vue.d.ts +39 -10
- package/dist/input-radio/types.d.ts +26 -4
- package/dist/me-ui-antdv-next.js +957 -457
- package/dist/me-ui-antdv-next.umd.cjs +10 -10
- package/dist/nav/index.vue.d.ts +2 -2
- package/dist/resolver/index.js +4 -1
- package/dist/style.css +1 -1
- package/dist/text/index.css +1 -0
- package/dist/text/index.d.ts +4 -0
- package/dist/text/index.js +98 -0
- package/dist/text/index.vue.d.ts +25 -0
- package/dist/text/types.d.ts +63 -0
- package/dist/tree-menu/index.vue.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,9 +16,12 @@ import { default as MeLoginPage } from './login-page';
|
|
|
16
16
|
import { default as MeCard } from './card';
|
|
17
17
|
import { default as MeSkeleton } from './skeleton';
|
|
18
18
|
import { default as MeInputProperty } from './input-property';
|
|
19
|
+
import { default as MeInputNumber } from './input-number';
|
|
19
20
|
import { default as MeCodeBox, MeCodeItem } from './code-box';
|
|
21
|
+
import { default as MeText } from './text';
|
|
22
|
+
import { default as MeInputJson } from './input-json';
|
|
20
23
|
declare const install: (app: App) => void;
|
|
21
|
-
export { MeMessage, MeMessageComponent, MeIcon, MeBox, MeBreadcrumb, MeBody, MeMenu, MeNav, MeModal, MeTreeMenu, MeInputGps, MeInputIconSelector, MeInputRadio, MeLoadJson, MeLoginPage, MeCard, MeSkeleton, MeInputProperty, MeCodeBox, MeCodeItem, install };
|
|
24
|
+
export { MeMessage, MeMessageComponent, MeIcon, MeBox, MeBreadcrumb, MeBody, MeMenu, MeNav, MeModal, MeTreeMenu, MeInputGps, MeInputIconSelector, MeInputRadio, MeLoadJson, MeLoginPage, MeCard, MeSkeleton, MeInputProperty, MeInputNumber, MeCodeBox, MeCodeItem, MeText, MeInputJson, install };
|
|
22
25
|
export { MeMessage as $message } from './message';
|
|
23
26
|
export { loadIconfont } from './icon';
|
|
24
27
|
declare const _default: {
|
|
@@ -44,4 +47,7 @@ export * from './login-page';
|
|
|
44
47
|
export * from './card';
|
|
45
48
|
export * from './skeleton';
|
|
46
49
|
export * from './input-property';
|
|
50
|
+
export * from './input-number';
|
|
47
51
|
export * from './code-box';
|
|
52
|
+
export * from './text';
|
|
53
|
+
export * from './input-json';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.me-input-json{background-color:#fff;border:1px solid #d9d9d9;border-radius:6px;width:100%;min-height:200px;transition:border-color .2s;overflow:hidden}.me-input-json:hover{border-color:#4096ff}.me-input-json--focused{border-color:#1677ff;box-shadow:0 0 0 2px #0591ff1a}.me-input-json.is-disabled{cursor:not-allowed;color:#00000040;background-color:#0000000a;border-color:#d9d9d9}.me-input-json.is-disabled .jsoneditor{background-color:#0000}.me-input-json .jsoneditor{border:none}.me-input-json .jsoneditor-poweredBy{display:none!important}.me-input-json .jsoneditor-menu{border-bottom:1px solid #f0f0f0}.me-input-json-wrapper{display:block}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { t as e } from "../chunks/modal-C2Lx5a9H.js";
|
|
2
|
+
import { computed as t, createBlock as n, createElementVNode as r, defineComponent as i, guardReactiveProps as a, nextTick as o, normalizeClass as s, normalizeProps as c, normalizeStyle as l, onBeforeUnmount as u, openBlock as d, ref as f, resolveDynamicComponent as p, watch as m, withCtx as h } from "vue";
|
|
3
|
+
import { message as g } from "antdv-next";
|
|
4
|
+
import _ from "jsoneditor";
|
|
5
|
+
import "jsoneditor/dist/jsoneditor.min.css";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/components/input-json/index.vue
|
|
8
|
+
var v = /* @__PURE__ */ i({
|
|
9
|
+
name: "MeInputJson",
|
|
10
|
+
__name: "index",
|
|
11
|
+
props: {
|
|
12
|
+
modelValue: { default: () => ({}) },
|
|
13
|
+
mode: { default: "code" },
|
|
14
|
+
modes: { default: () => [
|
|
15
|
+
"tree",
|
|
16
|
+
"code",
|
|
17
|
+
"form",
|
|
18
|
+
"text",
|
|
19
|
+
"view"
|
|
20
|
+
] },
|
|
21
|
+
height: { default: 300 },
|
|
22
|
+
disabled: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: !1
|
|
25
|
+
},
|
|
26
|
+
mainMenuBar: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: !0
|
|
29
|
+
},
|
|
30
|
+
navigationBar: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: !0
|
|
33
|
+
},
|
|
34
|
+
statusBar: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: !0
|
|
37
|
+
},
|
|
38
|
+
search: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: !0
|
|
41
|
+
},
|
|
42
|
+
history: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: !0
|
|
45
|
+
},
|
|
46
|
+
indentation: { default: 2 },
|
|
47
|
+
modalMode: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: !1
|
|
50
|
+
},
|
|
51
|
+
open: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: !1
|
|
54
|
+
},
|
|
55
|
+
title: { default: "JSON 编辑" },
|
|
56
|
+
modalWidth: { default: 720 },
|
|
57
|
+
okText: { default: "确定" },
|
|
58
|
+
cancelText: { default: "取消" },
|
|
59
|
+
fullscreen: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: !0
|
|
62
|
+
},
|
|
63
|
+
defaultFullscreen: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: !1
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
emits: [
|
|
69
|
+
"update:modelValue",
|
|
70
|
+
"update:mode",
|
|
71
|
+
"update:open",
|
|
72
|
+
"change",
|
|
73
|
+
"ok",
|
|
74
|
+
"cancel",
|
|
75
|
+
"error",
|
|
76
|
+
"fullscreen-change"
|
|
77
|
+
],
|
|
78
|
+
setup(i, { expose: v, emit: y }) {
|
|
79
|
+
let b = i, x = y, S = f(null), C = null, w = f(!1), T = f(!!b.open), E = f(b.open ? H(b.modelValue || {}) : {}), D = f(!!b.defaultFullscreen), O = t(() => b.modalMode && D.value ? "100%" : typeof b.height == "number" ? `${b.height}px` : b.height), k = t(() => b.disabled ? "view" : b.mode), A = t(() => b.disabled ? ["view"] : b.modes), j = t(() => b.modalMode ? {
|
|
80
|
+
open: T.value,
|
|
81
|
+
title: b.title,
|
|
82
|
+
width: b.modalWidth,
|
|
83
|
+
position: "center",
|
|
84
|
+
okText: b.okText,
|
|
85
|
+
cancelText: b.cancelText,
|
|
86
|
+
fullscreen: b.fullscreen,
|
|
87
|
+
defaultFullscreen: b.defaultFullscreen,
|
|
88
|
+
"onUpdate:open": M,
|
|
89
|
+
onOk: F,
|
|
90
|
+
onCancel: N,
|
|
91
|
+
onFullscreenChange: P
|
|
92
|
+
} : { class: "me-input-json-wrapper" });
|
|
93
|
+
function M(e) {
|
|
94
|
+
T.value = e, x("update:open", e);
|
|
95
|
+
}
|
|
96
|
+
function N() {
|
|
97
|
+
x("cancel");
|
|
98
|
+
}
|
|
99
|
+
function P(e) {
|
|
100
|
+
D.value = e, x("fullscreen-change", e), o(() => {
|
|
101
|
+
C?.refresh();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function F() {
|
|
105
|
+
if (C) try {
|
|
106
|
+
let e = C.get();
|
|
107
|
+
T.value = !1, x("update:open", !1), x("ok", e), x("change", e);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
g.error(`JSON 格式错误:${e.message}`), x("error", e);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
m(() => b.open, (e) => {
|
|
113
|
+
T.value = !!e, e && (E.value = H(b.modelValue || {}));
|
|
114
|
+
}), m(S, (e) => {
|
|
115
|
+
e ? I(e) : L();
|
|
116
|
+
}, { flush: "post" });
|
|
117
|
+
function I(e, t) {
|
|
118
|
+
let n = t === void 0 ? b.modalMode ? E.value : b.modelValue || {} : t;
|
|
119
|
+
C = new _(e, {
|
|
120
|
+
mode: k.value,
|
|
121
|
+
modes: A.value,
|
|
122
|
+
language: "zh-CN",
|
|
123
|
+
indentation: b.indentation,
|
|
124
|
+
mainMenuBar: b.mainMenuBar && !b.disabled,
|
|
125
|
+
navigationBar: b.navigationBar,
|
|
126
|
+
statusBar: b.statusBar,
|
|
127
|
+
search: b.search,
|
|
128
|
+
history: b.history,
|
|
129
|
+
onChange: R,
|
|
130
|
+
onValidationError: z,
|
|
131
|
+
onModeChange: B,
|
|
132
|
+
onEditable: b.disabled ? () => !1 : void 0
|
|
133
|
+
}, n);
|
|
134
|
+
}
|
|
135
|
+
function L() {
|
|
136
|
+
C &&= (C.destroy(), null);
|
|
137
|
+
}
|
|
138
|
+
u(() => {
|
|
139
|
+
L();
|
|
140
|
+
});
|
|
141
|
+
function R() {
|
|
142
|
+
if (C) try {
|
|
143
|
+
let e = C.get();
|
|
144
|
+
w.value = !1, b.modalMode || (x("update:modelValue", e), x("change", e));
|
|
145
|
+
} catch (e) {
|
|
146
|
+
w.value = !0, x("error", e);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function z(e) {
|
|
150
|
+
w.value = e.length > 0;
|
|
151
|
+
}
|
|
152
|
+
function B(e, t) {
|
|
153
|
+
b.disabled || x("update:mode", e);
|
|
154
|
+
}
|
|
155
|
+
m(() => b.modelValue, (e) => {
|
|
156
|
+
if (!b.modalMode && C) try {
|
|
157
|
+
let t = C.get();
|
|
158
|
+
JSON.stringify(t) !== JSON.stringify(e) && C.update(e || {});
|
|
159
|
+
} catch {
|
|
160
|
+
C.set(e || {});
|
|
161
|
+
}
|
|
162
|
+
}, { deep: !0 }), m(() => b.disabled, () => {
|
|
163
|
+
if (C && S.value) {
|
|
164
|
+
let e = V();
|
|
165
|
+
L(), o(() => {
|
|
166
|
+
S.value && I(S.value, e);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
function V() {
|
|
171
|
+
try {
|
|
172
|
+
return C?.get() || {};
|
|
173
|
+
} catch {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function H(e) {
|
|
178
|
+
if (typeof e != "object" || !e) return e;
|
|
179
|
+
if (Array.isArray(e)) return e.map((e) => H(e));
|
|
180
|
+
let t = {};
|
|
181
|
+
for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[n] = H(e[n]));
|
|
182
|
+
return t;
|
|
183
|
+
}
|
|
184
|
+
return v({
|
|
185
|
+
getEditor: () => C,
|
|
186
|
+
getValue: () => V(),
|
|
187
|
+
setValue: (e) => {
|
|
188
|
+
C?.set(e);
|
|
189
|
+
}
|
|
190
|
+
}), (t, o) => (d(), n(p(i.modalMode ? e : "div"), c(a(j.value)), {
|
|
191
|
+
default: h(() => [r("div", {
|
|
192
|
+
ref_key: "editorContainerRef",
|
|
193
|
+
ref: S,
|
|
194
|
+
class: s(["me-input-json", { "is-disabled": i.disabled }]),
|
|
195
|
+
style: l({ height: O.value })
|
|
196
|
+
}, null, 6)]),
|
|
197
|
+
_: 1
|
|
198
|
+
}, 16));
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/components/input-json/index.ts
|
|
203
|
+
v.install = (e) => {
|
|
204
|
+
e.component("MeInputJson", v);
|
|
205
|
+
};
|
|
206
|
+
var y = v;
|
|
207
|
+
//#endregion
|
|
208
|
+
export { v as MeInputJson, y as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { default as JSONEditor } from 'jsoneditor';
|
|
2
|
+
import { MeInputJsonProps, MeInputJsonModel, JsonEditorMode } from './types';
|
|
3
|
+
declare const __VLS_export: import('vue').DefineComponent<MeInputJsonProps, {
|
|
4
|
+
/** 获取 JSONEditor 原始实例 */
|
|
5
|
+
getEditor: () => JSONEditor | null;
|
|
6
|
+
/** 获取当前编辑器中的值(可能抛异常) */
|
|
7
|
+
getValue: () => MeInputJsonModel;
|
|
8
|
+
/** 手动设置编辑器值 */
|
|
9
|
+
setValue: (val: MeInputJsonModel) => void;
|
|
10
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
11
|
+
error: (error: Error) => any;
|
|
12
|
+
change: (value: MeInputJsonModel) => any;
|
|
13
|
+
"fullscreen-change": (value: boolean) => any;
|
|
14
|
+
"update:open": (value: boolean) => any;
|
|
15
|
+
ok: (value: MeInputJsonModel) => any;
|
|
16
|
+
cancel: () => any;
|
|
17
|
+
"update:modelValue": (value: MeInputJsonModel) => any;
|
|
18
|
+
"update:mode": (mode: JsonEditorMode) => any;
|
|
19
|
+
}, string, import('vue').PublicProps, Readonly<MeInputJsonProps> & Readonly<{
|
|
20
|
+
onError?: ((error: Error) => any) | undefined;
|
|
21
|
+
onChange?: ((value: MeInputJsonModel) => any) | undefined;
|
|
22
|
+
"onFullscreen-change"?: ((value: boolean) => any) | undefined;
|
|
23
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
24
|
+
onOk?: ((value: MeInputJsonModel) => any) | undefined;
|
|
25
|
+
onCancel?: (() => any) | undefined;
|
|
26
|
+
"onUpdate:modelValue"?: ((value: MeInputJsonModel) => any) | undefined;
|
|
27
|
+
"onUpdate:mode"?: ((mode: JsonEditorMode) => any) | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
mode: JsonEditorMode;
|
|
30
|
+
title: string;
|
|
31
|
+
height: string | number;
|
|
32
|
+
search: boolean;
|
|
33
|
+
fullscreen: boolean;
|
|
34
|
+
defaultFullscreen: boolean;
|
|
35
|
+
open: boolean;
|
|
36
|
+
okText: string;
|
|
37
|
+
cancelText: string;
|
|
38
|
+
disabled: boolean;
|
|
39
|
+
modelValue: MeInputJsonModel;
|
|
40
|
+
modes: JsonEditorMode[];
|
|
41
|
+
mainMenuBar: boolean;
|
|
42
|
+
navigationBar: boolean;
|
|
43
|
+
statusBar: boolean;
|
|
44
|
+
history: boolean;
|
|
45
|
+
indentation: number;
|
|
46
|
+
modalMode: boolean;
|
|
47
|
+
modalWidth: number | string;
|
|
48
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
49
|
+
declare const _default: typeof __VLS_export;
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MeInputJson JSON 编辑器组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
/** JSONEditor 支持的模式 */
|
|
5
|
+
export type JsonEditorMode = 'tree' | 'view' | 'form' | 'code' | 'text' | 'preview';
|
|
6
|
+
/** v-model 绑定的 JSON 数据类型 */
|
|
7
|
+
export type MeInputJsonModel = Record<string, any> | any[];
|
|
8
|
+
/** MeInputJson Props */
|
|
9
|
+
export interface MeInputJsonProps {
|
|
10
|
+
/** v-model 绑定的 JSON 对象或数组 */
|
|
11
|
+
modelValue?: MeInputJsonModel;
|
|
12
|
+
/** 编辑器初始模式,默认 'code' */
|
|
13
|
+
mode?: JsonEditorMode;
|
|
14
|
+
/** 允许切换的模式列表,默认 ['tree', 'code', 'form', 'text', 'view'] */
|
|
15
|
+
modes?: JsonEditorMode[];
|
|
16
|
+
/** 编辑器高度,默认 300(number 为 px) */
|
|
17
|
+
height?: string | number;
|
|
18
|
+
/** 是否禁用编辑,默认 false;禁用时强制 view 模式 */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** 是否显示主菜单栏,默认 true */
|
|
21
|
+
mainMenuBar?: boolean;
|
|
22
|
+
/** 是否显示导航栏,默认 true */
|
|
23
|
+
navigationBar?: boolean;
|
|
24
|
+
/** 是否显示状态栏,默认 true */
|
|
25
|
+
statusBar?: boolean;
|
|
26
|
+
/** 是否启用搜索功能,默认 true */
|
|
27
|
+
search?: boolean;
|
|
28
|
+
/** 是否启用历史记录(撤销/重做),默认 true */
|
|
29
|
+
history?: boolean;
|
|
30
|
+
/** 缩进空格数,默认 2 */
|
|
31
|
+
indentation?: number;
|
|
32
|
+
/** 是否以弹窗模式呈现,默认 false 内嵌 */
|
|
33
|
+
modalMode?: boolean;
|
|
34
|
+
/** 弹窗显隐(v-model:open),仅 modalMode=true 时生效 */
|
|
35
|
+
open?: boolean;
|
|
36
|
+
/** 弹窗标题,默认 'JSON 编辑' */
|
|
37
|
+
title?: string;
|
|
38
|
+
/** 弹窗宽度,默认 720(number 为 px) */
|
|
39
|
+
modalWidth?: number | string;
|
|
40
|
+
/** 确定按钮文字,默认 '确定' */
|
|
41
|
+
okText?: string;
|
|
42
|
+
/** 取消按钮文字,默认 '取消' */
|
|
43
|
+
cancelText?: string;
|
|
44
|
+
/** 是否显示全屏按钮,默认 true(仅弹窗模式生效) */
|
|
45
|
+
fullscreen?: boolean;
|
|
46
|
+
/** 是否默认全屏显示,默认 false(仅弹窗模式生效) */
|
|
47
|
+
defaultFullscreen?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** MeInputJson Events */
|
|
50
|
+
export interface MeInputJsonEmits {
|
|
51
|
+
/** 更新 v-model 绑定值(内嵌模式实时同步;弹窗模式不触发,用 ok 事件接收) */
|
|
52
|
+
(e: 'update:modelValue', value: MeInputJsonModel): void;
|
|
53
|
+
/** 模式变化(v-model:mode) */
|
|
54
|
+
(e: 'update:mode', mode: JsonEditorMode): void;
|
|
55
|
+
/** 弹窗显隐更新(v-model:open) */
|
|
56
|
+
(e: 'update:open', value: boolean): void;
|
|
57
|
+
/** 数据变更事件(内嵌模式随编辑触发;弹窗模式确定时也会触发一次) */
|
|
58
|
+
(e: 'change', value: MeInputJsonModel): void;
|
|
59
|
+
/** 弹窗模式点确定且 JSON 合法后触发,携带最终值 */
|
|
60
|
+
(e: 'ok', value: MeInputJsonModel): void;
|
|
61
|
+
/** 弹窗模式取消关闭(取消按钮 / 遮罩 / Esc) */
|
|
62
|
+
(e: 'cancel'): void;
|
|
63
|
+
/** JSON 解析错误事件 */
|
|
64
|
+
(e: 'error', error: Error): void;
|
|
65
|
+
/** 弹窗全屏状态变化(仅弹窗模式生效) */
|
|
66
|
+
(e: 'fullscreen-change', value: boolean): void;
|
|
67
|
+
}
|
|
68
|
+
/** MeInputJson 组件实例类型 */
|
|
69
|
+
export type MeInputJsonInstance = InstanceType<typeof import('./index.vue').default>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.me-input-number{width:100%}.me-input-number .ant-input-number-input{font-variant-numeric:tabular-nums;font-feature-settings:"tnum"}.me-input-number--disabled{cursor:not-allowed}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { computed as e, createBlock as t, defineComponent as n, mergeProps as r, openBlock as i, ref as a, resolveComponent as o, watch as s } from "vue";
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region src/components/input-number/index.vue
|
|
4
|
+
var c = /* @__PURE__ */ n({
|
|
5
|
+
name: "MeInputNumber",
|
|
6
|
+
__name: "index",
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {},
|
|
9
|
+
precision: { default: void 0 },
|
|
10
|
+
finance: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: !1
|
|
13
|
+
},
|
|
14
|
+
thousands: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
thousandsSeparator: { default: "," },
|
|
19
|
+
decimalSeparator: { default: "." },
|
|
20
|
+
prefix: { default: "" },
|
|
21
|
+
suffix: { default: "" },
|
|
22
|
+
min: { default: void 0 },
|
|
23
|
+
max: { default: void 0 },
|
|
24
|
+
step: { default: void 0 },
|
|
25
|
+
disabled: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !1
|
|
28
|
+
},
|
|
29
|
+
readonly: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: !1
|
|
32
|
+
},
|
|
33
|
+
size: { default: "middle" },
|
|
34
|
+
variant: { default: "outlined" },
|
|
35
|
+
status: { default: "" },
|
|
36
|
+
controls: {
|
|
37
|
+
type: [Boolean, Object],
|
|
38
|
+
default: !0
|
|
39
|
+
},
|
|
40
|
+
placeholder: { default: "" },
|
|
41
|
+
allowNull: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: !0
|
|
44
|
+
},
|
|
45
|
+
autoFixOnBlur: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: !0
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
emits: [
|
|
51
|
+
"update:modelValue",
|
|
52
|
+
"change",
|
|
53
|
+
"focus",
|
|
54
|
+
"blur",
|
|
55
|
+
"pressEnter",
|
|
56
|
+
"input"
|
|
57
|
+
],
|
|
58
|
+
setup(n, { expose: c, emit: l }) {
|
|
59
|
+
let u = n, d = l, f = e(() => u.finance || u.thousands === !0), p = e(() => u.precision === void 0 ? u.finance ? 2 : 0 : u.precision), m = e(() => u.thousands === void 0 ? u.finance : u.thousands), h = e(() => p.value > 15 || typeof u.min == "string" || typeof u.max == "string"), g = a(u.modelValue);
|
|
60
|
+
s(() => u.modelValue, (e) => {
|
|
61
|
+
g.value = e;
|
|
62
|
+
});
|
|
63
|
+
let _ = e(() => u.step === void 0 ? p.value <= 0 ? 1 : Number(`1e-${p.value}`) : u.step), v = (e) => {
|
|
64
|
+
if (e == null || e === "") return "";
|
|
65
|
+
let t = String(e), n = u.decimalSeparator, r = u.thousandsSeparator, [i, a] = t.split("."), o = "", s = i;
|
|
66
|
+
i.startsWith("-") && (o = "-", s = i.slice(1));
|
|
67
|
+
let c = s;
|
|
68
|
+
m.value && r && (c = s.replace(/\B(?=(\d{3})+(?!\d))/g, r));
|
|
69
|
+
let l = o + c;
|
|
70
|
+
return a !== void 0 && (l += n + a), u.prefix && (l = u.prefix + l), u.suffix && (l += u.suffix), l;
|
|
71
|
+
}, y = (e) => {
|
|
72
|
+
if (!e) return 0;
|
|
73
|
+
let t = e;
|
|
74
|
+
if (u.prefix && t.startsWith(u.prefix) && (t = t.slice(u.prefix.length)), u.suffix && t.endsWith(u.suffix) && (t = t.slice(0, -u.suffix.length)), m.value && u.thousandsSeparator) {
|
|
75
|
+
let e = new RegExp(u.thousandsSeparator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
|
|
76
|
+
t = t.replace(e, "");
|
|
77
|
+
}
|
|
78
|
+
if (u.decimalSeparator && u.decimalSeparator !== ".") {
|
|
79
|
+
let e = new RegExp(u.decimalSeparator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
|
|
80
|
+
t = t.replace(e, ".");
|
|
81
|
+
}
|
|
82
|
+
t = t.replace(/[^\d.\-]/g, "");
|
|
83
|
+
let n = t.indexOf("-");
|
|
84
|
+
n > 0 && (t = t.slice(0, n));
|
|
85
|
+
let r = t.indexOf(".");
|
|
86
|
+
return r >= 0 && (t = t.slice(0, r + 1) + t.slice(r + 1).replace(/\./g, "")), t === "" || t === "-" ? 0 : h.value ? t : Number(t);
|
|
87
|
+
}, b = (e) => {
|
|
88
|
+
if (e == null || e === "") return u.allowNull ? null : 0;
|
|
89
|
+
let t = String(e);
|
|
90
|
+
if (t === "-" || t === ".") return u.allowNull ? null : 0;
|
|
91
|
+
let n = Number(t);
|
|
92
|
+
if (isNaN(n)) return u.allowNull ? null : 0;
|
|
93
|
+
if (p.value <= 0) {
|
|
94
|
+
let e = Math.round(n);
|
|
95
|
+
return h.value ? String(e) : e;
|
|
96
|
+
}
|
|
97
|
+
let r = 10 ** p.value, i = Math.round(n * r) / r;
|
|
98
|
+
if (h.value || f.value) {
|
|
99
|
+
let e = i.toFixed(p.value);
|
|
100
|
+
return h.value ? e : Number(e);
|
|
101
|
+
}
|
|
102
|
+
return i;
|
|
103
|
+
}, x = (e) => {
|
|
104
|
+
d("update:modelValue", e), d("change", e);
|
|
105
|
+
}, S = (e) => {
|
|
106
|
+
d("focus", e);
|
|
107
|
+
}, C = (e) => {
|
|
108
|
+
if (u.autoFixOnBlur) {
|
|
109
|
+
let e = b(g.value);
|
|
110
|
+
e !== g.value && (g.value = e, d("update:modelValue", e), d("change", e));
|
|
111
|
+
}
|
|
112
|
+
d("blur", e);
|
|
113
|
+
}, w = (e) => {
|
|
114
|
+
d("pressEnter", e);
|
|
115
|
+
}, T = (e) => {
|
|
116
|
+
d("input", e);
|
|
117
|
+
};
|
|
118
|
+
return c({ fixPrecision: () => b(g.value) }), (e, n) => {
|
|
119
|
+
let a = o("a-input-number");
|
|
120
|
+
return i(), t(a, r({
|
|
121
|
+
value: g.value,
|
|
122
|
+
"onUpdate:value": n[0] ||= (e) => g.value = e,
|
|
123
|
+
class: ["me-input-number", {
|
|
124
|
+
"me-input-number--disabled": u.disabled,
|
|
125
|
+
"me-input-number--finance": f.value
|
|
126
|
+
}],
|
|
127
|
+
min: u.min,
|
|
128
|
+
max: u.max,
|
|
129
|
+
step: _.value,
|
|
130
|
+
disabled: u.disabled,
|
|
131
|
+
readonly: u.readonly,
|
|
132
|
+
size: u.size,
|
|
133
|
+
variant: u.variant,
|
|
134
|
+
status: u.status,
|
|
135
|
+
controls: u.controls,
|
|
136
|
+
placeholder: u.placeholder,
|
|
137
|
+
formatter: v,
|
|
138
|
+
parser: y,
|
|
139
|
+
"string-mode": h.value,
|
|
140
|
+
onChange: x,
|
|
141
|
+
onFocus: S,
|
|
142
|
+
onBlur: C,
|
|
143
|
+
onPressEnter: w,
|
|
144
|
+
onInput: T
|
|
145
|
+
}, e.$attrs), null, 16, [
|
|
146
|
+
"value",
|
|
147
|
+
"class",
|
|
148
|
+
"min",
|
|
149
|
+
"max",
|
|
150
|
+
"step",
|
|
151
|
+
"disabled",
|
|
152
|
+
"readonly",
|
|
153
|
+
"size",
|
|
154
|
+
"variant",
|
|
155
|
+
"status",
|
|
156
|
+
"controls",
|
|
157
|
+
"placeholder",
|
|
158
|
+
"string-mode"
|
|
159
|
+
]);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/components/input-number/index.ts
|
|
165
|
+
c.install = (e) => {
|
|
166
|
+
e.component("MeInputNumber", c);
|
|
167
|
+
};
|
|
168
|
+
var l = c;
|
|
169
|
+
//#endregion
|
|
170
|
+
export { c as MeInputNumber, l as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { MeInputNumberProps } from './types';
|
|
2
|
+
declare const __VLS_export: import('vue').DefineComponent<MeInputNumberProps, {
|
|
3
|
+
/** 按精度修正当前值(四舍五入 + 补零) */
|
|
4
|
+
fixPrecision: () => string | number | null;
|
|
5
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
6
|
+
input: (value: string) => any;
|
|
7
|
+
change: (value: string | number | null) => any;
|
|
8
|
+
blur: (event: FocusEvent) => any;
|
|
9
|
+
focus: (event: FocusEvent) => any;
|
|
10
|
+
"update:modelValue": (value: string | number | null) => any;
|
|
11
|
+
pressEnter: (event: KeyboardEvent) => any;
|
|
12
|
+
}, string, import('vue').PublicProps, Readonly<MeInputNumberProps> & Readonly<{
|
|
13
|
+
onInput?: ((value: string) => any) | undefined;
|
|
14
|
+
onChange?: ((value: string | number | null) => any) | undefined;
|
|
15
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
16
|
+
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
17
|
+
"onUpdate:modelValue"?: ((value: string | number | null) => any) | undefined;
|
|
18
|
+
onPressEnter?: ((event: KeyboardEvent) => any) | undefined;
|
|
19
|
+
}>, {
|
|
20
|
+
size: "small" | "middle" | "large";
|
|
21
|
+
max: number | string;
|
|
22
|
+
min: number | string;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
placeholder: string;
|
|
25
|
+
precision: number;
|
|
26
|
+
finance: boolean;
|
|
27
|
+
thousands: boolean;
|
|
28
|
+
thousandsSeparator: string;
|
|
29
|
+
decimalSeparator: string;
|
|
30
|
+
prefix: string;
|
|
31
|
+
suffix: string;
|
|
32
|
+
step: number | string;
|
|
33
|
+
readonly: boolean;
|
|
34
|
+
variant: "outlined" | "filled" | "borderless";
|
|
35
|
+
status: "" | "warning" | "error";
|
|
36
|
+
controls: boolean | {
|
|
37
|
+
upIcon?: any;
|
|
38
|
+
downIcon?: any;
|
|
39
|
+
};
|
|
40
|
+
allowNull: boolean;
|
|
41
|
+
autoFixOnBlur: boolean;
|
|
42
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
43
|
+
declare const _default: typeof __VLS_export;
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { InputNumberProps } from 'antdv-next';
|
|
2
|
+
/** MeInputNumber 组件 Props */
|
|
3
|
+
export interface MeInputNumberProps {
|
|
4
|
+
/** 绑定值(支持 v-model) */
|
|
5
|
+
modelValue?: number | string | null;
|
|
6
|
+
/** 小数点位数,默认 0(整数);finance 模式下默认 2 */
|
|
7
|
+
precision?: number;
|
|
8
|
+
/** 是否启用金融格式(千分位 + 默认 2 位小数) */
|
|
9
|
+
finance?: boolean;
|
|
10
|
+
/** 是否显示千分位分隔符(finance 模式下默认 true) */
|
|
11
|
+
thousands?: boolean;
|
|
12
|
+
/** 千分位分隔符,默认 ',' */
|
|
13
|
+
thousandsSeparator?: string;
|
|
14
|
+
/** 小数点符号,默认 '.' */
|
|
15
|
+
decimalSeparator?: string;
|
|
16
|
+
/** 前缀(如货币符号 ¥ $ €) */
|
|
17
|
+
prefix?: string;
|
|
18
|
+
/** 后缀(如 % 元) */
|
|
19
|
+
suffix?: string;
|
|
20
|
+
/** 最小值 */
|
|
21
|
+
min?: number | string;
|
|
22
|
+
/** 最大值 */
|
|
23
|
+
max?: number | string;
|
|
24
|
+
/** 步长 */
|
|
25
|
+
step?: number | string;
|
|
26
|
+
/** 是否禁用 */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** 是否只读 */
|
|
29
|
+
readonly?: boolean;
|
|
30
|
+
/** 输入框尺寸 */
|
|
31
|
+
size?: 'small' | 'middle' | 'large';
|
|
32
|
+
/** 输入框风格变体 */
|
|
33
|
+
variant?: 'outlined' | 'filled' | 'borderless';
|
|
34
|
+
/** 校验状态 */
|
|
35
|
+
status?: '' | 'warning' | 'error';
|
|
36
|
+
/** 是否显示加减控制按钮 */
|
|
37
|
+
controls?: boolean | {
|
|
38
|
+
upIcon?: any;
|
|
39
|
+
downIcon?: any;
|
|
40
|
+
};
|
|
41
|
+
/** 占位文字 */
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
/** 是否允许值为 null */
|
|
44
|
+
allowNull?: boolean;
|
|
45
|
+
/** 失焦时自动修正精度,默认 true */
|
|
46
|
+
autoFixOnBlur?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** MeInputNumber 组件 Emits */
|
|
49
|
+
export interface MeInputNumberEmits {
|
|
50
|
+
/** v-model 事件 */
|
|
51
|
+
(e: 'update:modelValue', value: number | string | null): void;
|
|
52
|
+
/** 值变化事件 */
|
|
53
|
+
(e: 'change', value: number | string | null): void;
|
|
54
|
+
/** 聚焦事件 */
|
|
55
|
+
(e: 'focus', event: FocusEvent): void;
|
|
56
|
+
/** 失焦事件 */
|
|
57
|
+
(e: 'blur', event: FocusEvent): void;
|
|
58
|
+
/** 按下回车 */
|
|
59
|
+
(e: 'pressEnter', event: KeyboardEvent): void;
|
|
60
|
+
/** 输入事件 */
|
|
61
|
+
(e: 'input', value: string): void;
|
|
62
|
+
}
|
|
63
|
+
/** MeInputNumber 组件实例类型 */
|
|
64
|
+
export type MeInputNumberInstance = InstanceType<typeof import('./index.vue').default>;
|
|
65
|
+
/** 透传给 a-input-number 的 Props 类型(扩展用) */
|
|
66
|
+
export type MeInputNumberPassThroughProps = Omit<InputNumberProps, 'value' | 'defaultValue' | 'onChange' | 'formatter' | 'parser' | 'precision' | 'decimalSeparator'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.me-input-property{width:100%;position:relative}.me-input-
|
|
1
|
+
.me-input-property{width:100%;position:relative}.me-input-property__add-btn:hover{color:#4096ff;background:#0000000a}.me-input-property__value{width:100%}.me-input-property__value-type{flex:0 0 95px;width:95px}.me-input-property__value-editor{flex:1;min-width:0}.me-input-property__table{width:100%}.me-input-property__table .ant-table-row.me-input-property__row--ghost td{opacity:.4;background:#1677ff0a}.me-input-property__table .ant-input-status-error,.me-input-property__table .ant-input-number-status-error,.me-input-property__table .ant-picker-status-error{box-shadow:none!important;border-color:#d9d9d9!important}.me-input-property__table .ant-select-status-error{--ant-select-border-color:#d9d9d9!important;--ant-select-background-color:#fff!important;--ant-select-color:inherit!important;box-shadow:none!important}.me-input-property__table .me-input-property__field--error.ant-input,.me-input-property__table .me-input-property__field--error.ant-input-number,.me-input-property__table .me-input-property__field--error.ant-picker{border-color:#ff4d4f!important}.me-input-property__table .me-input-property__value.me-input-property__field--error{border-radius:6px;box-shadow:0 0 0 1px #ff4d4f}.me-input-property__drop-line{background:var(--me-primary,#1677ff);pointer-events:none;z-index:9;border-radius:2px;height:2px;display:none;position:absolute;left:0;box-shadow:0 0 0 1px #fffc}.me-input-property__drag-fallback{table-layout:fixed;border-collapse:separate;border-spacing:0;background:#fff;width:auto;display:table;box-shadow:0 4px 12px #00000026}.me-input-property__drag-fallback td{box-sizing:border-box;vertical-align:middle;background:#fff;border-bottom:1px solid #f0f0f0}.me-input-property__actions{align-items:center;gap:2px;display:inline-flex}.me-input-property__drag{cursor:grab;color:#999;border-radius:4px;justify-content:center;align-items:center;padding:2px;display:inline-flex}.me-input-property__drag:active{cursor:grabbing;color:var(--me-primary,#1677ff)}.me-input-property__drag:hover{color:var(--me-primary,#1677ff);background:#0000000a}.me-input-property__del{color:#999}.me-input-property__del:hover{color:#ff4d4f}.me-input-property__rules-btn{color:#bbb;border-radius:4px}.me-input-property__rules-btn:hover{color:var(--me-primary,#1677ff);background:#0000000a}.me-input-property__rules-btn.is-active{color:var(--me-primary,#1677ff)}.me-input-property__rule-input{width:100%}
|