@factoringplus/pl-components-pack-v3 0.1.14 → 0.1.17
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/pl-components-pack-v3.es.js +1462 -2
- package/dist/pl-components-pack-v3.umd.js +10 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,938 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { defineComponent, openBlock, createElementBlock, createElementVNode, warn, getCurrentInstance, computed, ref, inject, unref, mergeProps, renderSlot, shallowRef, watch, nextTick, onMounted, onUpdated, resolveComponent, withDirectives, normalizeClass, normalizeStyle, createCommentVNode, Fragment, createBlock, withCtx, resolveDynamicComponent, withModifiers, createVNode, toDisplayString, vShow, onUnmounted, reactive } from "vue";
|
|
21
|
+
function fromPairs(pairs) {
|
|
22
|
+
var index = -1, length = pairs == null ? 0 : pairs.length, result = {};
|
|
23
|
+
while (++index < length) {
|
|
24
|
+
var pair = pairs[index];
|
|
25
|
+
result[pair[0]] = pair[1];
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
const isClient = typeof window !== "undefined";
|
|
30
|
+
const isNumber = (val) => typeof val === "number";
|
|
31
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
32
|
+
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
33
|
+
const isString = (val) => typeof val === "string";
|
|
34
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
35
|
+
const isUndefined = (val) => val === void 0;
|
|
36
|
+
var _export_sfc$1 = (sfc, props) => {
|
|
37
|
+
const target = sfc.__vccOpts || sfc;
|
|
38
|
+
for (const [key, val] of props) {
|
|
39
|
+
target[key] = val;
|
|
40
|
+
}
|
|
41
|
+
return target;
|
|
42
|
+
};
|
|
43
|
+
const _sfc_main$6 = defineComponent({
|
|
44
|
+
name: "CircleCheck"
|
|
45
|
+
});
|
|
46
|
+
const _hoisted_1$5 = {
|
|
47
|
+
class: "icon",
|
|
48
|
+
width: "200",
|
|
49
|
+
height: "200",
|
|
50
|
+
viewBox: "0 0 1024 1024",
|
|
51
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
52
|
+
};
|
|
53
|
+
const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("path", {
|
|
54
|
+
fill: "currentColor",
|
|
55
|
+
d: "M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"
|
|
56
|
+
}, null, -1);
|
|
57
|
+
const _hoisted_3$3 = /* @__PURE__ */ createElementVNode("path", {
|
|
58
|
+
fill: "currentColor",
|
|
59
|
+
d: "M745.344 361.344a32 32 0 0145.312 45.312l-288 288a32 32 0 01-45.312 0l-160-160a32 32 0 1145.312-45.312L480 626.752l265.344-265.408z"
|
|
60
|
+
}, null, -1);
|
|
61
|
+
const _hoisted_4$1 = [
|
|
62
|
+
_hoisted_2$4,
|
|
63
|
+
_hoisted_3$3
|
|
64
|
+
];
|
|
65
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
66
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$5, _hoisted_4$1);
|
|
67
|
+
}
|
|
68
|
+
var circleCheck = /* @__PURE__ */ _export_sfc$1(_sfc_main$6, [["render", _sfc_render$4]]);
|
|
69
|
+
const _sfc_main$5 = defineComponent({
|
|
70
|
+
name: "CircleClose"
|
|
71
|
+
});
|
|
72
|
+
const _hoisted_1$4 = {
|
|
73
|
+
class: "icon",
|
|
74
|
+
width: "200",
|
|
75
|
+
height: "200",
|
|
76
|
+
viewBox: "0 0 1024 1024",
|
|
77
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
78
|
+
};
|
|
79
|
+
const _hoisted_2$3 = /* @__PURE__ */ createElementVNode("path", {
|
|
80
|
+
fill: "currentColor",
|
|
81
|
+
d: "M466.752 512l-90.496-90.496a32 32 0 0145.248-45.248L512 466.752l90.496-90.496a32 32 0 1145.248 45.248L557.248 512l90.496 90.496a32 32 0 11-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 01-45.248-45.248L466.752 512z"
|
|
82
|
+
}, null, -1);
|
|
83
|
+
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("path", {
|
|
84
|
+
fill: "currentColor",
|
|
85
|
+
d: "M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"
|
|
86
|
+
}, null, -1);
|
|
87
|
+
const _hoisted_4 = [
|
|
88
|
+
_hoisted_2$3,
|
|
89
|
+
_hoisted_3$2
|
|
90
|
+
];
|
|
91
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
92
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$4, _hoisted_4);
|
|
93
|
+
}
|
|
94
|
+
var circleClose = /* @__PURE__ */ _export_sfc$1(_sfc_main$5, [["render", _sfc_render$3]]);
|
|
95
|
+
const _sfc_main$4 = defineComponent({
|
|
96
|
+
name: "Loading"
|
|
97
|
+
});
|
|
98
|
+
const _hoisted_1$3 = {
|
|
99
|
+
class: "icon",
|
|
100
|
+
width: "200",
|
|
101
|
+
height: "200",
|
|
102
|
+
viewBox: "0 0 1024 1024",
|
|
103
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
104
|
+
};
|
|
105
|
+
const _hoisted_2$2 = /* @__PURE__ */ createElementVNode("path", {
|
|
106
|
+
fill: "currentColor",
|
|
107
|
+
d: "M512 64a32 32 0 0132 32v192a32 32 0 01-64 0V96a32 32 0 0132-32zm0 640a32 32 0 0132 32v192a32 32 0 11-64 0V736a32 32 0 0132-32zm448-192a32 32 0 01-32 32H736a32 32 0 110-64h192a32 32 0 0132 32zm-640 0a32 32 0 01-32 32H96a32 32 0 010-64h192a32 32 0 0132 32zM195.2 195.2a32 32 0 0145.248 0L376.32 331.008a32 32 0 01-45.248 45.248L195.2 240.448a32 32 0 010-45.248zm452.544 452.544a32 32 0 0145.248 0L828.8 783.552a32 32 0 01-45.248 45.248L647.744 692.992a32 32 0 010-45.248zM828.8 195.264a32 32 0 010 45.184L692.992 376.32a32 32 0 01-45.248-45.248l135.808-135.808a32 32 0 0145.248 0zm-452.544 452.48a32 32 0 010 45.248L240.448 828.8a32 32 0 01-45.248-45.248l135.808-135.808a32 32 0 0145.248 0z"
|
|
108
|
+
}, null, -1);
|
|
109
|
+
const _hoisted_3$1 = [
|
|
110
|
+
_hoisted_2$2
|
|
111
|
+
];
|
|
112
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
113
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$3, _hoisted_3$1);
|
|
114
|
+
}
|
|
115
|
+
var loading = /* @__PURE__ */ _export_sfc$1(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
116
|
+
const _sfc_main$3 = defineComponent({
|
|
117
|
+
name: "View"
|
|
118
|
+
});
|
|
119
|
+
const _hoisted_1$2 = {
|
|
120
|
+
class: "icon",
|
|
121
|
+
width: "200",
|
|
122
|
+
height: "200",
|
|
123
|
+
viewBox: "0 0 1024 1024",
|
|
124
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
125
|
+
};
|
|
126
|
+
const _hoisted_2$1 = /* @__PURE__ */ createElementVNode("path", {
|
|
127
|
+
fill: "currentColor",
|
|
128
|
+
d: "M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352zm0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288zm0 64a224 224 0 110 448 224 224 0 010-448zm0 64a160.192 160.192 0 00-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160z"
|
|
129
|
+
}, null, -1);
|
|
130
|
+
const _hoisted_3 = [
|
|
131
|
+
_hoisted_2$1
|
|
132
|
+
];
|
|
133
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
134
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$2, _hoisted_3);
|
|
135
|
+
}
|
|
136
|
+
var view = /* @__PURE__ */ _export_sfc$1(_sfc_main$3, [["render", _sfc_render$1]]);
|
|
137
|
+
const wrapperKey = Symbol();
|
|
138
|
+
const propKey = "__elPropsReservedKey";
|
|
139
|
+
function buildProp(option, key) {
|
|
140
|
+
if (!isObject(option) || !!option[propKey])
|
|
141
|
+
return option;
|
|
142
|
+
const { values, required, default: defaultValue, type, validator } = option;
|
|
143
|
+
const _validator = values || validator ? (val) => {
|
|
144
|
+
let valid = false;
|
|
145
|
+
let allowedValues = [];
|
|
146
|
+
if (values) {
|
|
147
|
+
allowedValues = Array.from(values);
|
|
148
|
+
if (hasOwn(option, "default")) {
|
|
149
|
+
allowedValues.push(defaultValue);
|
|
150
|
+
}
|
|
151
|
+
valid || (valid = allowedValues.includes(val));
|
|
152
|
+
}
|
|
153
|
+
if (validator)
|
|
154
|
+
valid || (valid = validator(val));
|
|
155
|
+
if (!valid && allowedValues.length > 0) {
|
|
156
|
+
const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
|
|
157
|
+
warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
|
|
158
|
+
}
|
|
159
|
+
return valid;
|
|
160
|
+
} : void 0;
|
|
161
|
+
const prop = {
|
|
162
|
+
type: isObject(type) && Object.getOwnPropertySymbols(type).includes(wrapperKey) ? type[wrapperKey] : type,
|
|
163
|
+
required: !!required,
|
|
164
|
+
validator: _validator,
|
|
165
|
+
[propKey]: true
|
|
166
|
+
};
|
|
167
|
+
if (hasOwn(option, "default"))
|
|
168
|
+
prop.default = defaultValue;
|
|
169
|
+
return prop;
|
|
170
|
+
}
|
|
171
|
+
const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [
|
|
172
|
+
key,
|
|
173
|
+
buildProp(option, key)
|
|
174
|
+
]));
|
|
175
|
+
const definePropType = (val) => ({ [wrapperKey]: val });
|
|
176
|
+
const iconPropType = definePropType([
|
|
177
|
+
String,
|
|
178
|
+
Object,
|
|
179
|
+
Function
|
|
180
|
+
]);
|
|
181
|
+
const ValidateComponentsMap = {
|
|
182
|
+
validating: loading,
|
|
183
|
+
success: circleCheck,
|
|
184
|
+
error: circleClose
|
|
185
|
+
};
|
|
186
|
+
const withInstall = (main, extra) => {
|
|
187
|
+
main.install = (app) => {
|
|
188
|
+
for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
|
|
189
|
+
app.component(comp.name, comp);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
if (extra) {
|
|
193
|
+
for (const [key, comp] of Object.entries(extra)) {
|
|
194
|
+
main[key] = comp;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return main;
|
|
198
|
+
};
|
|
199
|
+
function addUnit(value, defaultUnit = "px") {
|
|
200
|
+
if (!value)
|
|
201
|
+
return "";
|
|
202
|
+
if (isString(value)) {
|
|
203
|
+
return value;
|
|
204
|
+
} else if (isNumber(value)) {
|
|
205
|
+
return `${value}${defaultUnit}`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const UPDATE_MODEL_EVENT = "update:modelValue";
|
|
209
|
+
const componentSizes = ["default", "small", "large"];
|
|
210
|
+
const isKorean = (text) => /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi.test(text);
|
|
211
|
+
const mutable = (val) => val;
|
|
212
|
+
const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
|
|
213
|
+
const LISTENER_PREFIX = /^on[A-Z]/;
|
|
214
|
+
const useAttrs = (params = {}) => {
|
|
215
|
+
const { excludeListeners = false, excludeKeys = [] } = params;
|
|
216
|
+
const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
|
|
217
|
+
const instance = getCurrentInstance();
|
|
218
|
+
if (!instance) {
|
|
219
|
+
return computed(() => ({}));
|
|
220
|
+
}
|
|
221
|
+
return computed(() => {
|
|
222
|
+
var _a;
|
|
223
|
+
return fromPairs(Object.entries((_a = instance.proxy) == null ? void 0 : _a.$attrs).filter(([key]) => !allExcludeKeys.includes(key) && !(excludeListeners && LISTENER_PREFIX.test(key))));
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
const elFormKey = Symbol("elForm");
|
|
227
|
+
const elFormItemKey = Symbol("elFormItem");
|
|
228
|
+
const configProviderContextKey = Symbol();
|
|
229
|
+
const useProp = (name) => {
|
|
230
|
+
const vm = getCurrentInstance();
|
|
231
|
+
return computed(() => {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
return (_b = (_a = vm.proxy) == null ? void 0 : _a.$props[name]) != null ? _b : void 0;
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
const globalConfig = ref();
|
|
237
|
+
function useGlobalConfig(key, defaultValue = void 0) {
|
|
238
|
+
const config = getCurrentInstance() ? inject(configProviderContextKey, globalConfig) : globalConfig;
|
|
239
|
+
if (key) {
|
|
240
|
+
return computed(() => {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
return (_b = (_a = config.value) == null ? void 0 : _a[key]) != null ? _b : defaultValue;
|
|
243
|
+
});
|
|
244
|
+
} else {
|
|
245
|
+
return config;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const useSizeProp = buildProp({
|
|
249
|
+
type: String,
|
|
250
|
+
values: componentSizes,
|
|
251
|
+
required: false
|
|
252
|
+
});
|
|
253
|
+
const useSize = (fallback, ignore = {}) => {
|
|
254
|
+
const emptyRef = ref(void 0);
|
|
255
|
+
const size = ignore.prop ? emptyRef : useProp("size");
|
|
256
|
+
const globalConfig2 = ignore.global ? emptyRef : useGlobalConfig("size");
|
|
257
|
+
const form = ignore.form ? { size: void 0 } : inject(elFormKey, void 0);
|
|
258
|
+
const formItem = ignore.formItem ? { size: void 0 } : inject(elFormItemKey, void 0);
|
|
259
|
+
return computed(() => size.value || unref(fallback) || (formItem == null ? void 0 : formItem.size) || (form == null ? void 0 : form.size) || globalConfig2.value || "default");
|
|
260
|
+
};
|
|
261
|
+
const useDisabled = (fallback) => {
|
|
262
|
+
const disabled = useProp("disabled");
|
|
263
|
+
const form = inject(elFormKey, void 0);
|
|
264
|
+
return computed(() => disabled.value || unref(fallback) || (form == null ? void 0 : form.disabled) || false);
|
|
265
|
+
};
|
|
266
|
+
const useFormItem = () => {
|
|
267
|
+
const form = inject(elFormKey, void 0);
|
|
268
|
+
const formItem = inject(elFormItemKey, void 0);
|
|
269
|
+
return {
|
|
270
|
+
form,
|
|
271
|
+
formItem
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
const defaultNamespace = "el";
|
|
275
|
+
const statePrefix = "is-";
|
|
276
|
+
const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
277
|
+
let cls = `${namespace}-${block}`;
|
|
278
|
+
if (blockSuffix) {
|
|
279
|
+
cls += `-${blockSuffix}`;
|
|
280
|
+
}
|
|
281
|
+
if (element) {
|
|
282
|
+
cls += `__${element}`;
|
|
283
|
+
}
|
|
284
|
+
if (modifier) {
|
|
285
|
+
cls += `--${modifier}`;
|
|
286
|
+
}
|
|
287
|
+
return cls;
|
|
288
|
+
};
|
|
289
|
+
const useNamespace = (block) => {
|
|
290
|
+
const globalConfig2 = useGlobalConfig("namespace");
|
|
291
|
+
const namespace = computed(() => globalConfig2.value || defaultNamespace);
|
|
292
|
+
const b = (blockSuffix = "") => _bem(unref(namespace), block, blockSuffix, "", "");
|
|
293
|
+
const e = (element) => element ? _bem(unref(namespace), block, "", element, "") : "";
|
|
294
|
+
const m = (modifier) => modifier ? _bem(unref(namespace), block, "", "", modifier) : "";
|
|
295
|
+
const be = (blockSuffix, element) => blockSuffix && element ? _bem(unref(namespace), block, blockSuffix, element, "") : "";
|
|
296
|
+
const em = (element, modifier) => element && modifier ? _bem(unref(namespace), block, "", element, modifier) : "";
|
|
297
|
+
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(unref(namespace), block, blockSuffix, "", modifier) : "";
|
|
298
|
+
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(unref(namespace), block, blockSuffix, element, modifier) : "";
|
|
299
|
+
const is = (name, ...args) => {
|
|
300
|
+
const state = args.length >= 1 ? args[0] : true;
|
|
301
|
+
return name && state ? `${statePrefix}${name}` : "";
|
|
302
|
+
};
|
|
303
|
+
return {
|
|
304
|
+
namespace,
|
|
305
|
+
b,
|
|
306
|
+
e,
|
|
307
|
+
m,
|
|
308
|
+
be,
|
|
309
|
+
em,
|
|
310
|
+
bm,
|
|
311
|
+
bem,
|
|
312
|
+
is
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
const iconProps = buildProps({
|
|
316
|
+
size: {
|
|
317
|
+
type: definePropType([Number, String])
|
|
318
|
+
},
|
|
319
|
+
color: {
|
|
320
|
+
type: String
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
const __default__$1 = {
|
|
324
|
+
name: "ElIcon",
|
|
325
|
+
inheritAttrs: false
|
|
326
|
+
};
|
|
327
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$1), {
|
|
328
|
+
props: iconProps,
|
|
329
|
+
setup(__props) {
|
|
330
|
+
const props = __props;
|
|
331
|
+
const ns = useNamespace("icon");
|
|
332
|
+
const style = computed(() => {
|
|
333
|
+
if (!props.size && !props.color)
|
|
334
|
+
return {};
|
|
335
|
+
return {
|
|
336
|
+
fontSize: isUndefined(props.size) ? void 0 : addUnit(props.size),
|
|
337
|
+
"--color": props.color
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
return (_ctx, _cache) => {
|
|
341
|
+
return openBlock(), createElementBlock("i", mergeProps({
|
|
342
|
+
class: unref(ns).b(),
|
|
343
|
+
style: unref(style)
|
|
344
|
+
}, _ctx.$attrs), [
|
|
345
|
+
renderSlot(_ctx.$slots, "default")
|
|
346
|
+
], 16);
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
}));
|
|
350
|
+
const ElIcon = withInstall(_sfc_main$2);
|
|
351
|
+
let hiddenTextarea = void 0;
|
|
352
|
+
const HIDDEN_STYLE = `
|
|
353
|
+
height:0 !important;
|
|
354
|
+
visibility:hidden !important;
|
|
355
|
+
overflow:hidden !important;
|
|
356
|
+
position:absolute !important;
|
|
357
|
+
z-index:-1000 !important;
|
|
358
|
+
top:0 !important;
|
|
359
|
+
right:0 !important;
|
|
360
|
+
`;
|
|
361
|
+
const CONTEXT_STYLE = [
|
|
362
|
+
"letter-spacing",
|
|
363
|
+
"line-height",
|
|
364
|
+
"padding-top",
|
|
365
|
+
"padding-bottom",
|
|
366
|
+
"font-family",
|
|
367
|
+
"font-weight",
|
|
368
|
+
"font-size",
|
|
369
|
+
"text-rendering",
|
|
370
|
+
"text-transform",
|
|
371
|
+
"width",
|
|
372
|
+
"text-indent",
|
|
373
|
+
"padding-left",
|
|
374
|
+
"padding-right",
|
|
375
|
+
"border-width",
|
|
376
|
+
"box-sizing"
|
|
377
|
+
];
|
|
378
|
+
function calculateNodeStyling(targetElement) {
|
|
379
|
+
const style = window.getComputedStyle(targetElement);
|
|
380
|
+
const boxSizing = style.getPropertyValue("box-sizing");
|
|
381
|
+
const paddingSize = parseFloat(style.getPropertyValue("padding-bottom")) + parseFloat(style.getPropertyValue("padding-top"));
|
|
382
|
+
const borderSize = parseFloat(style.getPropertyValue("border-bottom-width")) + parseFloat(style.getPropertyValue("border-top-width"));
|
|
383
|
+
const contextStyle = CONTEXT_STYLE.map((name) => `${name}:${style.getPropertyValue(name)}`).join(";");
|
|
384
|
+
return { contextStyle, paddingSize, borderSize, boxSizing };
|
|
385
|
+
}
|
|
386
|
+
function calcTextareaHeight(targetElement, minRows = 1, maxRows) {
|
|
387
|
+
var _a;
|
|
388
|
+
if (!hiddenTextarea) {
|
|
389
|
+
hiddenTextarea = document.createElement("textarea");
|
|
390
|
+
document.body.appendChild(hiddenTextarea);
|
|
391
|
+
}
|
|
392
|
+
const { paddingSize, borderSize, boxSizing, contextStyle } = calculateNodeStyling(targetElement);
|
|
393
|
+
hiddenTextarea.setAttribute("style", `${contextStyle};${HIDDEN_STYLE}`);
|
|
394
|
+
hiddenTextarea.value = targetElement.value || targetElement.placeholder || "";
|
|
395
|
+
let height = hiddenTextarea.scrollHeight;
|
|
396
|
+
const result = {};
|
|
397
|
+
if (boxSizing === "border-box") {
|
|
398
|
+
height = height + borderSize;
|
|
399
|
+
} else if (boxSizing === "content-box") {
|
|
400
|
+
height = height - paddingSize;
|
|
401
|
+
}
|
|
402
|
+
hiddenTextarea.value = "";
|
|
403
|
+
const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
|
|
404
|
+
if (isNumber(minRows)) {
|
|
405
|
+
let minHeight = singleRowHeight * minRows;
|
|
406
|
+
if (boxSizing === "border-box") {
|
|
407
|
+
minHeight = minHeight + paddingSize + borderSize;
|
|
408
|
+
}
|
|
409
|
+
height = Math.max(minHeight, height);
|
|
410
|
+
result.minHeight = `${minHeight}px`;
|
|
411
|
+
}
|
|
412
|
+
if (isNumber(maxRows)) {
|
|
413
|
+
let maxHeight = singleRowHeight * maxRows;
|
|
414
|
+
if (boxSizing === "border-box") {
|
|
415
|
+
maxHeight = maxHeight + paddingSize + borderSize;
|
|
416
|
+
}
|
|
417
|
+
height = Math.min(maxHeight, height);
|
|
418
|
+
}
|
|
419
|
+
result.height = `${height}px`;
|
|
420
|
+
(_a = hiddenTextarea.parentNode) == null ? void 0 : _a.removeChild(hiddenTextarea);
|
|
421
|
+
hiddenTextarea = void 0;
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
const inputProps = buildProps({
|
|
425
|
+
size: useSizeProp,
|
|
426
|
+
disabled: Boolean,
|
|
427
|
+
modelValue: {
|
|
428
|
+
type: definePropType(void 0),
|
|
429
|
+
default: ""
|
|
430
|
+
},
|
|
431
|
+
type: {
|
|
432
|
+
type: String,
|
|
433
|
+
default: "text"
|
|
434
|
+
},
|
|
435
|
+
resize: {
|
|
436
|
+
type: String,
|
|
437
|
+
values: ["none", "both", "horizontal", "vertical"]
|
|
438
|
+
},
|
|
439
|
+
autosize: {
|
|
440
|
+
type: definePropType([Boolean, Object]),
|
|
441
|
+
default: false
|
|
442
|
+
},
|
|
443
|
+
autocomplete: {
|
|
444
|
+
type: String,
|
|
445
|
+
default: "off"
|
|
446
|
+
},
|
|
447
|
+
placeholder: {
|
|
448
|
+
type: String
|
|
449
|
+
},
|
|
450
|
+
form: {
|
|
451
|
+
type: String,
|
|
452
|
+
default: ""
|
|
453
|
+
},
|
|
454
|
+
readonly: {
|
|
455
|
+
type: Boolean,
|
|
456
|
+
default: false
|
|
457
|
+
},
|
|
458
|
+
clearable: {
|
|
459
|
+
type: Boolean,
|
|
460
|
+
default: false
|
|
461
|
+
},
|
|
462
|
+
showPassword: {
|
|
463
|
+
type: Boolean,
|
|
464
|
+
default: false
|
|
465
|
+
},
|
|
466
|
+
showWordLimit: {
|
|
467
|
+
type: Boolean,
|
|
468
|
+
default: false
|
|
469
|
+
},
|
|
470
|
+
suffixIcon: {
|
|
471
|
+
type: iconPropType,
|
|
472
|
+
default: ""
|
|
473
|
+
},
|
|
474
|
+
prefixIcon: {
|
|
475
|
+
type: iconPropType,
|
|
476
|
+
default: ""
|
|
477
|
+
},
|
|
478
|
+
label: {
|
|
479
|
+
type: String
|
|
480
|
+
},
|
|
481
|
+
tabindex: {
|
|
482
|
+
type: [Number, String]
|
|
483
|
+
},
|
|
484
|
+
validateEvent: {
|
|
485
|
+
type: Boolean,
|
|
486
|
+
default: true
|
|
487
|
+
},
|
|
488
|
+
inputStyle: {
|
|
489
|
+
type: definePropType([Object, Array, String]),
|
|
490
|
+
default: () => mutable({})
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
const inputEmits = {
|
|
494
|
+
[UPDATE_MODEL_EVENT]: (value) => isString(value),
|
|
495
|
+
input: (value) => isString(value),
|
|
496
|
+
change: (value) => isString(value),
|
|
497
|
+
focus: (evt) => evt instanceof FocusEvent,
|
|
498
|
+
blur: (evt) => evt instanceof FocusEvent,
|
|
499
|
+
clear: () => true,
|
|
500
|
+
mouseleave: (evt) => evt instanceof MouseEvent,
|
|
501
|
+
mouseenter: (evt) => evt instanceof MouseEvent,
|
|
502
|
+
keydown: (evt) => evt instanceof KeyboardEvent,
|
|
503
|
+
compositionstart: (evt) => evt instanceof CompositionEvent,
|
|
504
|
+
compositionupdate: (evt) => evt instanceof CompositionEvent,
|
|
505
|
+
compositionend: (evt) => evt instanceof CompositionEvent
|
|
506
|
+
};
|
|
507
|
+
var _export_sfc = (sfc, props) => {
|
|
508
|
+
const target = sfc.__vccOpts || sfc;
|
|
509
|
+
for (const [key, val] of props) {
|
|
510
|
+
target[key] = val;
|
|
511
|
+
}
|
|
512
|
+
return target;
|
|
513
|
+
};
|
|
514
|
+
const PENDANT_MAP = {
|
|
515
|
+
suffix: "append",
|
|
516
|
+
prefix: "prepend"
|
|
517
|
+
};
|
|
518
|
+
const _sfc_main$1 = defineComponent({
|
|
519
|
+
name: "ElInput",
|
|
520
|
+
components: { ElIcon, CircleClose: circleClose, IconView: view },
|
|
521
|
+
inheritAttrs: false,
|
|
522
|
+
props: inputProps,
|
|
523
|
+
emits: inputEmits,
|
|
524
|
+
setup(props, { slots, emit, attrs: rawAttrs }) {
|
|
525
|
+
const instance = getCurrentInstance();
|
|
526
|
+
const attrs = useAttrs();
|
|
527
|
+
const { form, formItem } = useFormItem();
|
|
528
|
+
const inputSize = useSize();
|
|
529
|
+
const inputDisabled = useDisabled();
|
|
530
|
+
const nsInput = useNamespace("input");
|
|
531
|
+
const nsTextarea = useNamespace("textarea");
|
|
532
|
+
const input2 = ref();
|
|
533
|
+
const textarea = ref();
|
|
534
|
+
const focused = ref(false);
|
|
535
|
+
const hovering = ref(false);
|
|
536
|
+
const isComposing = ref(false);
|
|
537
|
+
const passwordVisible = ref(false);
|
|
538
|
+
const _textareaCalcStyle = shallowRef(props.inputStyle);
|
|
539
|
+
const inputOrTextarea = computed(() => input2.value || textarea.value);
|
|
540
|
+
const needStatusIcon = computed(() => {
|
|
541
|
+
var _a;
|
|
542
|
+
return (_a = form == null ? void 0 : form.statusIcon) != null ? _a : false;
|
|
543
|
+
});
|
|
544
|
+
const validateState = computed(() => (formItem == null ? void 0 : formItem.validateState) || "");
|
|
545
|
+
const validateIcon = computed(() => ValidateComponentsMap[validateState.value]);
|
|
546
|
+
const containerStyle = computed(() => rawAttrs.style);
|
|
547
|
+
const computedTextareaStyle = computed(() => [
|
|
548
|
+
props.inputStyle,
|
|
549
|
+
_textareaCalcStyle.value,
|
|
550
|
+
{ resize: props.resize }
|
|
551
|
+
]);
|
|
552
|
+
const nativeInputValue = computed(() => props.modelValue === null || props.modelValue === void 0 ? "" : String(props.modelValue));
|
|
553
|
+
const showClear = computed(() => props.clearable && !inputDisabled.value && !props.readonly && !!nativeInputValue.value && (focused.value || hovering.value));
|
|
554
|
+
const showPwdVisible = computed(() => props.showPassword && !inputDisabled.value && !props.readonly && (!!nativeInputValue.value || focused.value));
|
|
555
|
+
const isWordLimitVisible = computed(() => props.showWordLimit && !!attrs.value.maxlength && (props.type === "text" || props.type === "textarea") && !inputDisabled.value && !props.readonly && !props.showPassword);
|
|
556
|
+
const textLength = computed(() => Array.from(nativeInputValue.value).length);
|
|
557
|
+
const inputExceed = computed(() => !!isWordLimitVisible.value && textLength.value > Number(attrs.value.maxlength));
|
|
558
|
+
const resizeTextarea = () => {
|
|
559
|
+
const { type, autosize } = props;
|
|
560
|
+
if (!isClient || type !== "textarea")
|
|
561
|
+
return;
|
|
562
|
+
if (autosize) {
|
|
563
|
+
const minRows = isObject(autosize) ? autosize.minRows : void 0;
|
|
564
|
+
const maxRows = isObject(autosize) ? autosize.maxRows : void 0;
|
|
565
|
+
_textareaCalcStyle.value = __spreadValues({}, calcTextareaHeight(textarea.value, minRows, maxRows));
|
|
566
|
+
} else {
|
|
567
|
+
_textareaCalcStyle.value = {
|
|
568
|
+
minHeight: calcTextareaHeight(textarea.value).minHeight
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
const setNativeInputValue = () => {
|
|
573
|
+
const input22 = inputOrTextarea.value;
|
|
574
|
+
if (!input22 || input22.value === nativeInputValue.value)
|
|
575
|
+
return;
|
|
576
|
+
input22.value = nativeInputValue.value;
|
|
577
|
+
};
|
|
578
|
+
const calcIconOffset = (place) => {
|
|
579
|
+
const { el } = instance.vnode;
|
|
580
|
+
if (!el)
|
|
581
|
+
return;
|
|
582
|
+
const elList = Array.from(el.querySelectorAll(`.${nsInput.e(place)}`));
|
|
583
|
+
const target = elList.find((item) => item.parentNode === el);
|
|
584
|
+
if (!target)
|
|
585
|
+
return;
|
|
586
|
+
const pendant = PENDANT_MAP[place];
|
|
587
|
+
if (slots[pendant]) {
|
|
588
|
+
target.style.transform = `translateX(${place === "suffix" ? "-" : ""}${el.querySelector(`.${nsInput.be("group", pendant)}`).offsetWidth}px)`;
|
|
589
|
+
} else {
|
|
590
|
+
target.removeAttribute("style");
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
const updateIconOffset = () => {
|
|
594
|
+
calcIconOffset("prefix");
|
|
595
|
+
calcIconOffset("suffix");
|
|
596
|
+
};
|
|
597
|
+
const handleInput = (event) => {
|
|
598
|
+
const { value } = event.target;
|
|
599
|
+
if (isComposing.value)
|
|
600
|
+
return;
|
|
601
|
+
if (value === nativeInputValue.value)
|
|
602
|
+
return;
|
|
603
|
+
emit(UPDATE_MODEL_EVENT, value);
|
|
604
|
+
emit("input", value);
|
|
605
|
+
nextTick(setNativeInputValue);
|
|
606
|
+
};
|
|
607
|
+
const handleChange = (event) => {
|
|
608
|
+
emit("change", event.target.value);
|
|
609
|
+
};
|
|
610
|
+
const focus = () => {
|
|
611
|
+
nextTick(() => {
|
|
612
|
+
var _a;
|
|
613
|
+
(_a = inputOrTextarea.value) == null ? void 0 : _a.focus();
|
|
614
|
+
});
|
|
615
|
+
};
|
|
616
|
+
const blur = () => {
|
|
617
|
+
var _a;
|
|
618
|
+
(_a = inputOrTextarea.value) == null ? void 0 : _a.blur();
|
|
619
|
+
};
|
|
620
|
+
const handleFocus = (event) => {
|
|
621
|
+
focused.value = true;
|
|
622
|
+
emit("focus", event);
|
|
623
|
+
};
|
|
624
|
+
const handleBlur = (event) => {
|
|
625
|
+
var _a;
|
|
626
|
+
focused.value = false;
|
|
627
|
+
emit("blur", event);
|
|
628
|
+
if (props.validateEvent) {
|
|
629
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur");
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
const select = () => {
|
|
633
|
+
var _a;
|
|
634
|
+
(_a = inputOrTextarea.value) == null ? void 0 : _a.select();
|
|
635
|
+
};
|
|
636
|
+
const handleCompositionStart = (event) => {
|
|
637
|
+
emit("compositionstart", event);
|
|
638
|
+
isComposing.value = true;
|
|
639
|
+
};
|
|
640
|
+
const handleCompositionUpdate = (event) => {
|
|
641
|
+
var _a;
|
|
642
|
+
emit("compositionupdate", event);
|
|
643
|
+
const text = (_a = event.target) == null ? void 0 : _a.value;
|
|
644
|
+
const lastCharacter = text[text.length - 1] || "";
|
|
645
|
+
isComposing.value = !isKorean(lastCharacter);
|
|
646
|
+
};
|
|
647
|
+
const handleCompositionEnd = (event) => {
|
|
648
|
+
emit("compositionend", event);
|
|
649
|
+
if (isComposing.value) {
|
|
650
|
+
isComposing.value = false;
|
|
651
|
+
handleInput(event);
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
const clear = () => {
|
|
655
|
+
emit(UPDATE_MODEL_EVENT, "");
|
|
656
|
+
emit("change", "");
|
|
657
|
+
emit("clear");
|
|
658
|
+
emit("input", "");
|
|
659
|
+
};
|
|
660
|
+
const handlePasswordVisible = () => {
|
|
661
|
+
passwordVisible.value = !passwordVisible.value;
|
|
662
|
+
focus();
|
|
663
|
+
};
|
|
664
|
+
const suffixVisible = computed(() => !!slots.suffix || !!props.suffixIcon || showClear.value || props.showPassword || isWordLimitVisible.value || !!validateState.value && needStatusIcon.value);
|
|
665
|
+
watch(() => props.modelValue, () => {
|
|
666
|
+
var _a;
|
|
667
|
+
nextTick(resizeTextarea);
|
|
668
|
+
if (props.validateEvent) {
|
|
669
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
watch(nativeInputValue, () => setNativeInputValue());
|
|
673
|
+
watch(() => props.type, () => {
|
|
674
|
+
nextTick(() => {
|
|
675
|
+
setNativeInputValue();
|
|
676
|
+
resizeTextarea();
|
|
677
|
+
updateIconOffset();
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
onMounted(() => {
|
|
681
|
+
setNativeInputValue();
|
|
682
|
+
updateIconOffset();
|
|
683
|
+
nextTick(resizeTextarea);
|
|
684
|
+
});
|
|
685
|
+
onUpdated(() => {
|
|
686
|
+
nextTick(updateIconOffset);
|
|
687
|
+
});
|
|
688
|
+
const onMouseLeave = (evt) => {
|
|
689
|
+
hovering.value = false;
|
|
690
|
+
emit("mouseleave", evt);
|
|
691
|
+
};
|
|
692
|
+
const onMouseEnter = (evt) => {
|
|
693
|
+
hovering.value = true;
|
|
694
|
+
emit("mouseenter", evt);
|
|
695
|
+
};
|
|
696
|
+
const handleKeydown = (evt) => {
|
|
697
|
+
emit("keydown", evt);
|
|
698
|
+
};
|
|
699
|
+
return {
|
|
700
|
+
input: input2,
|
|
701
|
+
textarea,
|
|
702
|
+
attrs,
|
|
703
|
+
inputSize,
|
|
704
|
+
validateState,
|
|
705
|
+
validateIcon,
|
|
706
|
+
containerStyle,
|
|
707
|
+
computedTextareaStyle,
|
|
708
|
+
inputDisabled,
|
|
709
|
+
showClear,
|
|
710
|
+
showPwdVisible,
|
|
711
|
+
isWordLimitVisible,
|
|
712
|
+
textLength,
|
|
713
|
+
hovering,
|
|
714
|
+
inputExceed,
|
|
715
|
+
passwordVisible,
|
|
716
|
+
inputOrTextarea,
|
|
717
|
+
suffixVisible,
|
|
718
|
+
needStatusIcon,
|
|
719
|
+
resizeTextarea,
|
|
720
|
+
handleInput,
|
|
721
|
+
handleChange,
|
|
722
|
+
handleFocus,
|
|
723
|
+
handleBlur,
|
|
724
|
+
handleCompositionStart,
|
|
725
|
+
handleCompositionUpdate,
|
|
726
|
+
handleCompositionEnd,
|
|
727
|
+
handlePasswordVisible,
|
|
728
|
+
clear,
|
|
729
|
+
select,
|
|
730
|
+
focus,
|
|
731
|
+
blur,
|
|
732
|
+
onMouseLeave,
|
|
733
|
+
onMouseEnter,
|
|
734
|
+
handleKeydown,
|
|
735
|
+
nsInput,
|
|
736
|
+
nsTextarea
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
const _hoisted_1$1 = ["type", "disabled", "readonly", "autocomplete", "tabindex", "aria-label", "placeholder"];
|
|
741
|
+
const _hoisted_2 = ["tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder"];
|
|
742
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
743
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
744
|
+
const _component_circle_close = resolveComponent("circle-close");
|
|
745
|
+
const _component_icon_view = resolveComponent("icon-view");
|
|
746
|
+
return withDirectives((openBlock(), createElementBlock("div", {
|
|
747
|
+
class: normalizeClass([
|
|
748
|
+
_ctx.type === "textarea" ? _ctx.nsTextarea.b() : _ctx.nsInput.b(),
|
|
749
|
+
_ctx.nsInput.m(_ctx.inputSize),
|
|
750
|
+
_ctx.nsInput.is("disabled", _ctx.inputDisabled),
|
|
751
|
+
_ctx.nsInput.is("exceed", _ctx.inputExceed),
|
|
752
|
+
{
|
|
753
|
+
[_ctx.nsInput.b("group")]: _ctx.$slots.prepend || _ctx.$slots.append,
|
|
754
|
+
[_ctx.nsInput.bm("group", "append")]: _ctx.$slots.append,
|
|
755
|
+
[_ctx.nsInput.bm("group", "prepend")]: _ctx.$slots.prepend,
|
|
756
|
+
[_ctx.nsInput.m("prefix")]: _ctx.$slots.prefix || _ctx.prefixIcon,
|
|
757
|
+
[_ctx.nsInput.m("suffix")]: _ctx.$slots.suffix || _ctx.suffixIcon || _ctx.clearable || _ctx.showPassword,
|
|
758
|
+
[_ctx.nsInput.m("suffix--password-clear")]: _ctx.showClear && _ctx.showPwdVisible
|
|
759
|
+
},
|
|
760
|
+
_ctx.$attrs.class
|
|
761
|
+
]),
|
|
762
|
+
style: normalizeStyle(_ctx.containerStyle),
|
|
763
|
+
onMouseenter: _cache[17] || (_cache[17] = (...args) => _ctx.onMouseEnter && _ctx.onMouseEnter(...args)),
|
|
764
|
+
onMouseleave: _cache[18] || (_cache[18] = (...args) => _ctx.onMouseLeave && _ctx.onMouseLeave(...args))
|
|
765
|
+
}, [
|
|
766
|
+
createCommentVNode(" input "),
|
|
767
|
+
_ctx.type !== "textarea" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
768
|
+
createCommentVNode(" prepend slot "),
|
|
769
|
+
_ctx.$slots.prepend ? (openBlock(), createElementBlock("div", {
|
|
770
|
+
key: 0,
|
|
771
|
+
class: normalizeClass(_ctx.nsInput.be("group", "prepend"))
|
|
772
|
+
}, [
|
|
773
|
+
renderSlot(_ctx.$slots, "prepend")
|
|
774
|
+
], 2)) : createCommentVNode("v-if", true),
|
|
775
|
+
createElementVNode("input", mergeProps({
|
|
776
|
+
ref: "input",
|
|
777
|
+
class: _ctx.nsInput.e("inner")
|
|
778
|
+
}, _ctx.attrs, {
|
|
779
|
+
type: _ctx.showPassword ? _ctx.passwordVisible ? "text" : "password" : _ctx.type,
|
|
780
|
+
disabled: _ctx.inputDisabled,
|
|
781
|
+
readonly: _ctx.readonly,
|
|
782
|
+
autocomplete: _ctx.autocomplete,
|
|
783
|
+
tabindex: _ctx.tabindex,
|
|
784
|
+
"aria-label": _ctx.label,
|
|
785
|
+
placeholder: _ctx.placeholder,
|
|
786
|
+
style: _ctx.inputStyle,
|
|
787
|
+
onCompositionstart: _cache[0] || (_cache[0] = (...args) => _ctx.handleCompositionStart && _ctx.handleCompositionStart(...args)),
|
|
788
|
+
onCompositionupdate: _cache[1] || (_cache[1] = (...args) => _ctx.handleCompositionUpdate && _ctx.handleCompositionUpdate(...args)),
|
|
789
|
+
onCompositionend: _cache[2] || (_cache[2] = (...args) => _ctx.handleCompositionEnd && _ctx.handleCompositionEnd(...args)),
|
|
790
|
+
onInput: _cache[3] || (_cache[3] = (...args) => _ctx.handleInput && _ctx.handleInput(...args)),
|
|
791
|
+
onFocus: _cache[4] || (_cache[4] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
|
|
792
|
+
onBlur: _cache[5] || (_cache[5] = (...args) => _ctx.handleBlur && _ctx.handleBlur(...args)),
|
|
793
|
+
onChange: _cache[6] || (_cache[6] = (...args) => _ctx.handleChange && _ctx.handleChange(...args)),
|
|
794
|
+
onKeydown: _cache[7] || (_cache[7] = (...args) => _ctx.handleKeydown && _ctx.handleKeydown(...args))
|
|
795
|
+
}), null, 16, _hoisted_1$1),
|
|
796
|
+
createCommentVNode(" prefix slot "),
|
|
797
|
+
_ctx.$slots.prefix || _ctx.prefixIcon ? (openBlock(), createElementBlock("span", {
|
|
798
|
+
key: 1,
|
|
799
|
+
class: normalizeClass(_ctx.nsInput.e("prefix"))
|
|
800
|
+
}, [
|
|
801
|
+
createElementVNode("span", {
|
|
802
|
+
class: normalizeClass(_ctx.nsInput.e("prefix-inner"))
|
|
803
|
+
}, [
|
|
804
|
+
renderSlot(_ctx.$slots, "prefix"),
|
|
805
|
+
_ctx.prefixIcon ? (openBlock(), createBlock(_component_el_icon, {
|
|
806
|
+
key: 0,
|
|
807
|
+
class: normalizeClass(_ctx.nsInput.e("icon"))
|
|
808
|
+
}, {
|
|
809
|
+
default: withCtx(() => [
|
|
810
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.prefixIcon)))
|
|
811
|
+
]),
|
|
812
|
+
_: 1
|
|
813
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true)
|
|
814
|
+
], 2)
|
|
815
|
+
], 2)) : createCommentVNode("v-if", true),
|
|
816
|
+
createCommentVNode(" suffix slot "),
|
|
817
|
+
_ctx.suffixVisible ? (openBlock(), createElementBlock("span", {
|
|
818
|
+
key: 2,
|
|
819
|
+
class: normalizeClass(_ctx.nsInput.e("suffix"))
|
|
820
|
+
}, [
|
|
821
|
+
createElementVNode("span", {
|
|
822
|
+
class: normalizeClass(_ctx.nsInput.e("suffix-inner"))
|
|
823
|
+
}, [
|
|
824
|
+
!_ctx.showClear || !_ctx.showPwdVisible || !_ctx.isWordLimitVisible ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
825
|
+
renderSlot(_ctx.$slots, "suffix"),
|
|
826
|
+
_ctx.suffixIcon ? (openBlock(), createBlock(_component_el_icon, {
|
|
827
|
+
key: 0,
|
|
828
|
+
class: normalizeClass(_ctx.nsInput.e("icon"))
|
|
829
|
+
}, {
|
|
830
|
+
default: withCtx(() => [
|
|
831
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.suffixIcon)))
|
|
832
|
+
]),
|
|
833
|
+
_: 1
|
|
834
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true)
|
|
835
|
+
], 64)) : createCommentVNode("v-if", true),
|
|
836
|
+
_ctx.showClear ? (openBlock(), createBlock(_component_el_icon, {
|
|
837
|
+
key: 1,
|
|
838
|
+
class: normalizeClass([_ctx.nsInput.e("icon"), _ctx.nsInput.e("clear")]),
|
|
839
|
+
onMousedown: _cache[8] || (_cache[8] = withModifiers(() => {
|
|
840
|
+
}, ["prevent"])),
|
|
841
|
+
onClick: _ctx.clear
|
|
842
|
+
}, {
|
|
843
|
+
default: withCtx(() => [
|
|
844
|
+
createVNode(_component_circle_close)
|
|
845
|
+
]),
|
|
846
|
+
_: 1
|
|
847
|
+
}, 8, ["class", "onClick"])) : createCommentVNode("v-if", true),
|
|
848
|
+
_ctx.showPwdVisible ? (openBlock(), createBlock(_component_el_icon, {
|
|
849
|
+
key: 2,
|
|
850
|
+
class: normalizeClass([_ctx.nsInput.e("icon"), _ctx.nsInput.e("clear")]),
|
|
851
|
+
onClick: _ctx.handlePasswordVisible
|
|
852
|
+
}, {
|
|
853
|
+
default: withCtx(() => [
|
|
854
|
+
createVNode(_component_icon_view)
|
|
855
|
+
]),
|
|
856
|
+
_: 1
|
|
857
|
+
}, 8, ["class", "onClick"])) : createCommentVNode("v-if", true),
|
|
858
|
+
_ctx.isWordLimitVisible ? (openBlock(), createElementBlock("span", {
|
|
859
|
+
key: 3,
|
|
860
|
+
class: normalizeClass(_ctx.nsInput.e("count"))
|
|
861
|
+
}, [
|
|
862
|
+
createElementVNode("span", {
|
|
863
|
+
class: normalizeClass(_ctx.nsInput.e("count-inner"))
|
|
864
|
+
}, toDisplayString(_ctx.textLength) + " / " + toDisplayString(_ctx.attrs.maxlength), 3)
|
|
865
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
866
|
+
], 2),
|
|
867
|
+
_ctx.validateState && _ctx.validateIcon && _ctx.needStatusIcon ? (openBlock(), createBlock(_component_el_icon, {
|
|
868
|
+
key: 0,
|
|
869
|
+
class: normalizeClass([_ctx.nsInput.e("icon"), _ctx.nsInput.e("validateIcon")])
|
|
870
|
+
}, {
|
|
871
|
+
default: withCtx(() => [
|
|
872
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.validateIcon)))
|
|
873
|
+
]),
|
|
874
|
+
_: 1
|
|
875
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true)
|
|
876
|
+
], 2)) : createCommentVNode("v-if", true),
|
|
877
|
+
createCommentVNode(" append slot "),
|
|
878
|
+
_ctx.$slots.append ? (openBlock(), createElementBlock("div", {
|
|
879
|
+
key: 3,
|
|
880
|
+
class: normalizeClass(_ctx.nsInput.be("group", "append"))
|
|
881
|
+
}, [
|
|
882
|
+
renderSlot(_ctx.$slots, "append")
|
|
883
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
884
|
+
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
885
|
+
createCommentVNode(" textarea "),
|
|
886
|
+
createElementVNode("textarea", mergeProps({
|
|
887
|
+
ref: "textarea",
|
|
888
|
+
class: _ctx.nsTextarea.e("inner")
|
|
889
|
+
}, _ctx.attrs, {
|
|
890
|
+
tabindex: _ctx.tabindex,
|
|
891
|
+
disabled: _ctx.inputDisabled,
|
|
892
|
+
readonly: _ctx.readonly,
|
|
893
|
+
autocomplete: _ctx.autocomplete,
|
|
894
|
+
style: _ctx.computedTextareaStyle,
|
|
895
|
+
"aria-label": _ctx.label,
|
|
896
|
+
placeholder: _ctx.placeholder,
|
|
897
|
+
onCompositionstart: _cache[9] || (_cache[9] = (...args) => _ctx.handleCompositionStart && _ctx.handleCompositionStart(...args)),
|
|
898
|
+
onCompositionupdate: _cache[10] || (_cache[10] = (...args) => _ctx.handleCompositionUpdate && _ctx.handleCompositionUpdate(...args)),
|
|
899
|
+
onCompositionend: _cache[11] || (_cache[11] = (...args) => _ctx.handleCompositionEnd && _ctx.handleCompositionEnd(...args)),
|
|
900
|
+
onInput: _cache[12] || (_cache[12] = (...args) => _ctx.handleInput && _ctx.handleInput(...args)),
|
|
901
|
+
onFocus: _cache[13] || (_cache[13] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
|
|
902
|
+
onBlur: _cache[14] || (_cache[14] = (...args) => _ctx.handleBlur && _ctx.handleBlur(...args)),
|
|
903
|
+
onChange: _cache[15] || (_cache[15] = (...args) => _ctx.handleChange && _ctx.handleChange(...args)),
|
|
904
|
+
onKeydown: _cache[16] || (_cache[16] = (...args) => _ctx.handleKeydown && _ctx.handleKeydown(...args))
|
|
905
|
+
}), null, 16, _hoisted_2),
|
|
906
|
+
_ctx.isWordLimitVisible ? (openBlock(), createElementBlock("span", {
|
|
907
|
+
key: 0,
|
|
908
|
+
class: normalizeClass(_ctx.nsInput.e("count"))
|
|
909
|
+
}, toDisplayString(_ctx.textLength) + " / " + toDisplayString(_ctx.attrs.maxlength), 3)) : createCommentVNode("v-if", true)
|
|
910
|
+
], 64))
|
|
911
|
+
], 38)), [
|
|
912
|
+
[vShow, _ctx.type !== "hidden"]
|
|
913
|
+
]);
|
|
914
|
+
}
|
|
915
|
+
var Input = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
|
|
916
|
+
const ElInput = withInstall(Input);
|
|
2
917
|
var base = "";
|
|
3
|
-
var button = "";
|
|
4
918
|
var input = "";
|
|
5
919
|
/**
|
|
6
920
|
* Vue Currency Input 2.4.0
|
|
7
921
|
* (c) 2018-2022 Matthias Stiller
|
|
8
922
|
* @license MIT
|
|
9
923
|
*/
|
|
924
|
+
const escapeRegExp = (str) => {
|
|
925
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
926
|
+
};
|
|
927
|
+
const removeLeadingZeros = (str) => {
|
|
928
|
+
return str.replace(/^0+(0$|[^0])/, "$1");
|
|
929
|
+
};
|
|
930
|
+
const count = (str, search) => {
|
|
931
|
+
return (str.match(new RegExp(escapeRegExp(search), "g")) || []).length;
|
|
932
|
+
};
|
|
933
|
+
const substringBefore = (str, search) => {
|
|
934
|
+
return str.substring(0, str.indexOf(search));
|
|
935
|
+
};
|
|
10
936
|
var CurrencyDisplay;
|
|
11
937
|
(function(CurrencyDisplay2) {
|
|
12
938
|
CurrencyDisplay2["symbol"] = "symbol";
|
|
@@ -22,4 +948,538 @@ var ValueScaling;
|
|
|
22
948
|
ValueScaling2["millions"] = "millions";
|
|
23
949
|
ValueScaling2["billions"] = "billions";
|
|
24
950
|
})(ValueScaling || (ValueScaling = {}));
|
|
951
|
+
const DECIMAL_SEPARATORS = [",", ".", "\u066B"];
|
|
952
|
+
const INTEGER_PATTERN = "(0|[1-9]\\d*)";
|
|
953
|
+
class CurrencyFormat {
|
|
954
|
+
constructor(options) {
|
|
955
|
+
var _a, _b, _c, _d, _e, _f;
|
|
956
|
+
const { currency, currencyDisplay, locale, precision, accountingSign } = options;
|
|
957
|
+
this.locale = locale;
|
|
958
|
+
this.options = {
|
|
959
|
+
style: "currency",
|
|
960
|
+
currency,
|
|
961
|
+
currencySign: accountingSign ? "accounting" : void 0,
|
|
962
|
+
currencyDisplay: currencyDisplay !== CurrencyDisplay.hidden ? currencyDisplay : void 0
|
|
963
|
+
};
|
|
964
|
+
const numberFormat = new Intl.NumberFormat(locale, this.options);
|
|
965
|
+
const formatParts = numberFormat.formatToParts(123456);
|
|
966
|
+
this.currency = (_a = formatParts.find(({ type }) => type === "currency")) === null || _a === void 0 ? void 0 : _a.value;
|
|
967
|
+
this.digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => i.toLocaleString(locale));
|
|
968
|
+
this.decimalSymbol = (_b = formatParts.find(({ type }) => type === "decimal")) === null || _b === void 0 ? void 0 : _b.value;
|
|
969
|
+
this.groupingSymbol = (_c = formatParts.find(({ type }) => type === "group")) === null || _c === void 0 ? void 0 : _c.value;
|
|
970
|
+
this.minusSign = (_d = numberFormat.formatToParts(-1).find(({ type }) => type === "minusSign")) === null || _d === void 0 ? void 0 : _d.value;
|
|
971
|
+
if (this.decimalSymbol === void 0) {
|
|
972
|
+
this.minimumFractionDigits = this.maximumFractionDigits = 0;
|
|
973
|
+
} else if (typeof precision === "number") {
|
|
974
|
+
this.minimumFractionDigits = this.maximumFractionDigits = precision;
|
|
975
|
+
} else {
|
|
976
|
+
this.minimumFractionDigits = (_e = precision === null || precision === void 0 ? void 0 : precision.min) !== null && _e !== void 0 ? _e : numberFormat.resolvedOptions().minimumFractionDigits;
|
|
977
|
+
this.maximumFractionDigits = (_f = precision === null || precision === void 0 ? void 0 : precision.max) !== null && _f !== void 0 ? _f : numberFormat.resolvedOptions().maximumFractionDigits;
|
|
978
|
+
}
|
|
979
|
+
const getPrefix = (str) => {
|
|
980
|
+
return substringBefore(str, this.digits[1]);
|
|
981
|
+
};
|
|
982
|
+
const getSuffix = (str) => {
|
|
983
|
+
return str.substring(str.lastIndexOf(this.decimalSymbol ? this.digits[0] : this.digits[1]) + 1);
|
|
984
|
+
};
|
|
985
|
+
this.prefix = getPrefix(numberFormat.format(1));
|
|
986
|
+
this.suffix = getSuffix(numberFormat.format(1));
|
|
987
|
+
this.negativePrefix = getPrefix(numberFormat.format(-1));
|
|
988
|
+
this.negativeSuffix = getSuffix(numberFormat.format(-1));
|
|
989
|
+
}
|
|
990
|
+
parse(str) {
|
|
991
|
+
if (str) {
|
|
992
|
+
const negative = this.isNegative(str);
|
|
993
|
+
str = this.normalizeDigits(str);
|
|
994
|
+
str = this.stripCurrency(str, negative);
|
|
995
|
+
str = this.stripSignLiterals(str);
|
|
996
|
+
const fraction = this.decimalSymbol ? `(?:${escapeRegExp(this.decimalSymbol)}(\\d*))?` : "";
|
|
997
|
+
const match = this.stripGroupingSeparator(str).match(new RegExp(`^${INTEGER_PATTERN}${fraction}$`));
|
|
998
|
+
if (match && this.isValidIntegerFormat(this.decimalSymbol ? str.split(this.decimalSymbol)[0] : str, Number(match[1]))) {
|
|
999
|
+
return Number(`${negative ? "-" : ""}${this.onlyDigits(match[1])}.${this.onlyDigits(match[2] || "")}`);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
isValidIntegerFormat(formattedNumber, integerNumber) {
|
|
1005
|
+
const options = __spreadProps(__spreadValues({}, this.options), { minimumFractionDigits: 0 });
|
|
1006
|
+
return [
|
|
1007
|
+
this.stripCurrency(this.normalizeDigits(integerNumber.toLocaleString(this.locale, __spreadProps(__spreadValues({}, options), {
|
|
1008
|
+
useGrouping: true
|
|
1009
|
+
}))), false),
|
|
1010
|
+
this.stripCurrency(this.normalizeDigits(integerNumber.toLocaleString(this.locale, __spreadProps(__spreadValues({}, options), {
|
|
1011
|
+
useGrouping: false
|
|
1012
|
+
}))), false)
|
|
1013
|
+
].includes(formattedNumber);
|
|
1014
|
+
}
|
|
1015
|
+
format(value, options = {
|
|
1016
|
+
minimumFractionDigits: this.minimumFractionDigits,
|
|
1017
|
+
maximumFractionDigits: this.maximumFractionDigits
|
|
1018
|
+
}) {
|
|
1019
|
+
return value != null ? value.toLocaleString(this.locale, __spreadValues(__spreadValues({}, this.options), options)) : "";
|
|
1020
|
+
}
|
|
1021
|
+
toFraction(str) {
|
|
1022
|
+
return `${this.digits[0]}${this.decimalSymbol}${this.onlyLocaleDigits(str.substr(1)).substr(0, this.maximumFractionDigits)}`;
|
|
1023
|
+
}
|
|
1024
|
+
isFractionIncomplete(str) {
|
|
1025
|
+
return !!this.normalizeDigits(this.stripGroupingSeparator(str)).match(new RegExp(`^${INTEGER_PATTERN}${escapeRegExp(this.decimalSymbol)}$`));
|
|
1026
|
+
}
|
|
1027
|
+
isNegative(str) {
|
|
1028
|
+
return str.startsWith(this.negativePrefix) || this.minusSign === void 0 && (str.startsWith("(") || str.startsWith("-")) || this.minusSign !== void 0 && str.replace("-", this.minusSign).startsWith(this.minusSign);
|
|
1029
|
+
}
|
|
1030
|
+
insertCurrency(str, negative) {
|
|
1031
|
+
return `${negative ? this.negativePrefix : this.prefix}${str}${negative ? this.negativeSuffix : this.suffix}`;
|
|
1032
|
+
}
|
|
1033
|
+
stripGroupingSeparator(str) {
|
|
1034
|
+
return this.groupingSymbol !== void 0 ? str.replace(new RegExp(escapeRegExp(this.groupingSymbol), "g"), "") : str;
|
|
1035
|
+
}
|
|
1036
|
+
stripSignLiterals(str) {
|
|
1037
|
+
if (this.minusSign !== void 0) {
|
|
1038
|
+
return str.replace("-", this.minusSign).replace(this.minusSign, "");
|
|
1039
|
+
} else {
|
|
1040
|
+
return str.replace(/[-()]/g, "");
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
stripCurrency(str, negative) {
|
|
1044
|
+
return str.replace(negative ? this.negativePrefix : this.prefix, "").replace(negative ? this.negativeSuffix : this.suffix, "");
|
|
1045
|
+
}
|
|
1046
|
+
normalizeDecimalSeparator(str, from) {
|
|
1047
|
+
DECIMAL_SEPARATORS.forEach((s) => {
|
|
1048
|
+
str = str.substr(0, from) + str.substr(from).replace(s, this.decimalSymbol);
|
|
1049
|
+
});
|
|
1050
|
+
return str;
|
|
1051
|
+
}
|
|
1052
|
+
normalizeDigits(str) {
|
|
1053
|
+
if (this.digits[0] !== "0") {
|
|
1054
|
+
this.digits.forEach((digit, index) => {
|
|
1055
|
+
str = str.replace(new RegExp(digit, "g"), String(index));
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
return str;
|
|
1059
|
+
}
|
|
1060
|
+
onlyDigits(str) {
|
|
1061
|
+
return this.normalizeDigits(str).replace(/\D+/g, "");
|
|
1062
|
+
}
|
|
1063
|
+
onlyLocaleDigits(str) {
|
|
1064
|
+
return str.replace(new RegExp(`[^${this.digits.join("")}]*`, "g"), "");
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
class AbstractInputMask {
|
|
1068
|
+
constructor(currencyFormat) {
|
|
1069
|
+
this.currencyFormat = currencyFormat;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
class DefaultInputMask extends AbstractInputMask {
|
|
1073
|
+
conformToMask(str, previousConformedValue = "") {
|
|
1074
|
+
const negative = this.currencyFormat.isNegative(str);
|
|
1075
|
+
const isEmptyNegativeValue = (str2) => str2 === "" && negative && !(this.currencyFormat.minusSign === void 0 ? previousConformedValue === this.currencyFormat.negativePrefix + this.currencyFormat.negativeSuffix : previousConformedValue === this.currencyFormat.negativePrefix);
|
|
1076
|
+
const checkIncompleteValue = (str2) => {
|
|
1077
|
+
if (isEmptyNegativeValue(str2)) {
|
|
1078
|
+
return "";
|
|
1079
|
+
} else if (this.currencyFormat.maximumFractionDigits > 0) {
|
|
1080
|
+
if (this.currencyFormat.isFractionIncomplete(str2)) {
|
|
1081
|
+
return str2;
|
|
1082
|
+
} else if (str2.startsWith(this.currencyFormat.decimalSymbol)) {
|
|
1083
|
+
return this.currencyFormat.toFraction(str2);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
return null;
|
|
1087
|
+
};
|
|
1088
|
+
let value = str;
|
|
1089
|
+
value = this.currencyFormat.stripCurrency(value, negative);
|
|
1090
|
+
value = this.currencyFormat.stripSignLiterals(value);
|
|
1091
|
+
const incompleteValue = checkIncompleteValue(value);
|
|
1092
|
+
if (incompleteValue != null) {
|
|
1093
|
+
return this.currencyFormat.insertCurrency(incompleteValue, negative);
|
|
1094
|
+
}
|
|
1095
|
+
const [integer, ...fraction] = value.split(this.currencyFormat.decimalSymbol);
|
|
1096
|
+
const integerDigits = removeLeadingZeros(this.currencyFormat.onlyDigits(integer));
|
|
1097
|
+
const fractionDigits = this.currencyFormat.onlyDigits(fraction.join("")).substr(0, this.currencyFormat.maximumFractionDigits);
|
|
1098
|
+
const invalidFraction = fraction.length > 0 && fractionDigits.length === 0;
|
|
1099
|
+
const invalidNegativeValue = integerDigits === "" && negative && (this.currencyFormat.minusSign === void 0 ? previousConformedValue === str.slice(0, -2) + this.currencyFormat.negativeSuffix : previousConformedValue === str.slice(0, -1));
|
|
1100
|
+
if (invalidFraction || invalidNegativeValue || isEmptyNegativeValue(integerDigits)) {
|
|
1101
|
+
return previousConformedValue;
|
|
1102
|
+
} else if (integerDigits.match(/\d+/)) {
|
|
1103
|
+
return {
|
|
1104
|
+
numberValue: Number(`${negative ? "-" : ""}${integerDigits}.${fractionDigits}`),
|
|
1105
|
+
fractionDigits
|
|
1106
|
+
};
|
|
1107
|
+
} else {
|
|
1108
|
+
return "";
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
class AutoDecimalDigitsInputMask extends AbstractInputMask {
|
|
1113
|
+
conformToMask(str, previousConformedValue = "") {
|
|
1114
|
+
if (str === "" || this.currencyFormat.parse(previousConformedValue) === 0 && this.currencyFormat.stripCurrency(previousConformedValue, true).slice(0, -1) === this.currencyFormat.stripCurrency(str, true)) {
|
|
1115
|
+
return "";
|
|
1116
|
+
}
|
|
1117
|
+
const negative = this.currencyFormat.isNegative(str);
|
|
1118
|
+
const numberValue = this.currencyFormat.stripSignLiterals(str) === "" ? -0 : Number(`${negative ? "-" : ""}${removeLeadingZeros(this.currencyFormat.onlyDigits(str))}`) / Math.pow(10, this.currencyFormat.maximumFractionDigits);
|
|
1119
|
+
return {
|
|
1120
|
+
numberValue,
|
|
1121
|
+
fractionDigits: numberValue.toFixed(this.currencyFormat.maximumFractionDigits).slice(-this.currencyFormat.maximumFractionDigits)
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
const DEFAULT_OPTIONS = {
|
|
1126
|
+
locale: void 0,
|
|
1127
|
+
currency: void 0,
|
|
1128
|
+
currencyDisplay: void 0,
|
|
1129
|
+
exportValueAsInteger: false,
|
|
1130
|
+
hideGroupingSeparatorOnFocus: true,
|
|
1131
|
+
hideCurrencySymbolOnFocus: true,
|
|
1132
|
+
hideNegligibleDecimalDigitsOnFocus: true,
|
|
1133
|
+
precision: void 0,
|
|
1134
|
+
autoDecimalDigits: false,
|
|
1135
|
+
valueRange: void 0,
|
|
1136
|
+
autoSign: true,
|
|
1137
|
+
useGrouping: true,
|
|
1138
|
+
valueScaling: void 0
|
|
1139
|
+
};
|
|
1140
|
+
class CurrencyInput {
|
|
1141
|
+
constructor(el, options) {
|
|
1142
|
+
this.el = el;
|
|
1143
|
+
this.numberValue = null;
|
|
1144
|
+
this.addEventListener();
|
|
1145
|
+
this.init(options);
|
|
1146
|
+
this.setValue(this.currencyFormat.parse(this.el.value));
|
|
1147
|
+
}
|
|
1148
|
+
setOptions(options) {
|
|
1149
|
+
this.init(options);
|
|
1150
|
+
this.applyFixedFractionFormat(this.numberValue, true);
|
|
1151
|
+
}
|
|
1152
|
+
getValue() {
|
|
1153
|
+
const numberValue = this.valueScaling && this.numberValue != null ? this.toInteger(this.numberValue, this.valueScaling) : this.numberValue;
|
|
1154
|
+
return { number: numberValue, formatted: this.formattedValue };
|
|
1155
|
+
}
|
|
1156
|
+
setValue(value) {
|
|
1157
|
+
const newValue = this.valueScaling !== void 0 && value != null ? this.toFloat(value, this.valueScaling) : value;
|
|
1158
|
+
if (newValue !== this.numberValue) {
|
|
1159
|
+
this.applyFixedFractionFormat(newValue);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
dispatchEvent(eventName) {
|
|
1163
|
+
this.el.dispatchEvent(new CustomEvent(eventName, { detail: this.getValue() }));
|
|
1164
|
+
}
|
|
1165
|
+
init(options) {
|
|
1166
|
+
this.options = __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options);
|
|
1167
|
+
if (this.options.autoDecimalDigits) {
|
|
1168
|
+
this.options.hideNegligibleDecimalDigitsOnFocus = false;
|
|
1169
|
+
this.el.setAttribute("inputmode", "numeric");
|
|
1170
|
+
} else {
|
|
1171
|
+
this.el.setAttribute("inputmode", "decimal");
|
|
1172
|
+
}
|
|
1173
|
+
this.currencyFormat = new CurrencyFormat(this.options);
|
|
1174
|
+
this.numberMask = this.options.autoDecimalDigits ? new AutoDecimalDigitsInputMask(this.currencyFormat) : new DefaultInputMask(this.currencyFormat);
|
|
1175
|
+
const valueScalingOptions = {
|
|
1176
|
+
[ValueScaling.precision]: this.currencyFormat.maximumFractionDigits,
|
|
1177
|
+
[ValueScaling.thousands]: 3,
|
|
1178
|
+
[ValueScaling.millions]: 6,
|
|
1179
|
+
[ValueScaling.billions]: 9
|
|
1180
|
+
};
|
|
1181
|
+
if (this.options.exportValueAsInteger) {
|
|
1182
|
+
this.valueScaling = valueScalingOptions[ValueScaling.precision];
|
|
1183
|
+
} else {
|
|
1184
|
+
this.valueScaling = this.options.valueScaling ? valueScalingOptions[this.options.valueScaling] : void 0;
|
|
1185
|
+
}
|
|
1186
|
+
this.valueScalingFractionDigits = this.valueScaling !== void 0 && this.options.valueScaling !== ValueScaling.precision ? this.valueScaling + this.currencyFormat.maximumFractionDigits : this.currencyFormat.maximumFractionDigits;
|
|
1187
|
+
this.minValue = this.getMinValue();
|
|
1188
|
+
this.maxValue = this.getMaxValue();
|
|
1189
|
+
}
|
|
1190
|
+
getMinValue() {
|
|
1191
|
+
var _a, _b;
|
|
1192
|
+
let min = this.toFloat(-Number.MAX_SAFE_INTEGER);
|
|
1193
|
+
if (((_a = this.options.valueRange) === null || _a === void 0 ? void 0 : _a.min) !== void 0) {
|
|
1194
|
+
min = Math.max((_b = this.options.valueRange) === null || _b === void 0 ? void 0 : _b.min, this.toFloat(-Number.MAX_SAFE_INTEGER));
|
|
1195
|
+
}
|
|
1196
|
+
if (!this.options.autoSign && min < 0) {
|
|
1197
|
+
min = 0;
|
|
1198
|
+
}
|
|
1199
|
+
return min;
|
|
1200
|
+
}
|
|
1201
|
+
getMaxValue() {
|
|
1202
|
+
var _a, _b;
|
|
1203
|
+
let max = this.toFloat(Number.MAX_SAFE_INTEGER);
|
|
1204
|
+
if (((_a = this.options.valueRange) === null || _a === void 0 ? void 0 : _a.max) !== void 0) {
|
|
1205
|
+
max = Math.min((_b = this.options.valueRange) === null || _b === void 0 ? void 0 : _b.max, this.toFloat(Number.MAX_SAFE_INTEGER));
|
|
1206
|
+
}
|
|
1207
|
+
if (!this.options.autoSign && max < 0) {
|
|
1208
|
+
max = this.toFloat(Number.MAX_SAFE_INTEGER);
|
|
1209
|
+
}
|
|
1210
|
+
return max;
|
|
1211
|
+
}
|
|
1212
|
+
toFloat(value, maxFractionDigits) {
|
|
1213
|
+
return value / Math.pow(10, maxFractionDigits !== null && maxFractionDigits !== void 0 ? maxFractionDigits : this.valueScalingFractionDigits);
|
|
1214
|
+
}
|
|
1215
|
+
toInteger(value, maxFractionDigits) {
|
|
1216
|
+
return Number(value.toFixed(maxFractionDigits !== null && maxFractionDigits !== void 0 ? maxFractionDigits : this.valueScalingFractionDigits).split(".").join(""));
|
|
1217
|
+
}
|
|
1218
|
+
validateValueRange(value) {
|
|
1219
|
+
return value != null ? Math.min(Math.max(value, this.minValue), this.maxValue) : value;
|
|
1220
|
+
}
|
|
1221
|
+
applyFixedFractionFormat(number, forcedChange = false) {
|
|
1222
|
+
this.format(this.currencyFormat.format(this.validateValueRange(number)));
|
|
1223
|
+
if (number !== this.numberValue || forcedChange) {
|
|
1224
|
+
this.dispatchEvent("change");
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
format(value, hideNegligibleDecimalDigits = false) {
|
|
1228
|
+
if (value != null) {
|
|
1229
|
+
if (this.decimalSymbolInsertedAt !== void 0) {
|
|
1230
|
+
value = this.currencyFormat.normalizeDecimalSeparator(value, this.decimalSymbolInsertedAt);
|
|
1231
|
+
this.decimalSymbolInsertedAt = void 0;
|
|
1232
|
+
}
|
|
1233
|
+
const conformedValue = this.numberMask.conformToMask(value, this.formattedValue);
|
|
1234
|
+
let formattedValue;
|
|
1235
|
+
if (typeof conformedValue === "object") {
|
|
1236
|
+
const { numberValue, fractionDigits } = conformedValue;
|
|
1237
|
+
let { maximumFractionDigits, minimumFractionDigits } = this.currencyFormat;
|
|
1238
|
+
if (this.focus) {
|
|
1239
|
+
minimumFractionDigits = hideNegligibleDecimalDigits ? fractionDigits.replace(/0+$/, "").length : Math.min(maximumFractionDigits, fractionDigits.length);
|
|
1240
|
+
} else if (Number.isInteger(numberValue) && !this.options.autoDecimalDigits && (this.options.precision === void 0 || minimumFractionDigits === 0)) {
|
|
1241
|
+
minimumFractionDigits = maximumFractionDigits = 0;
|
|
1242
|
+
}
|
|
1243
|
+
formattedValue = this.toInteger(Math.abs(numberValue)) > Number.MAX_SAFE_INTEGER ? this.formattedValue : this.currencyFormat.format(numberValue, {
|
|
1244
|
+
useGrouping: this.options.useGrouping && !(this.focus && this.options.hideGroupingSeparatorOnFocus),
|
|
1245
|
+
minimumFractionDigits,
|
|
1246
|
+
maximumFractionDigits
|
|
1247
|
+
});
|
|
1248
|
+
} else {
|
|
1249
|
+
formattedValue = conformedValue;
|
|
1250
|
+
}
|
|
1251
|
+
if (this.options.autoSign) {
|
|
1252
|
+
if (this.maxValue <= 0 && !this.currencyFormat.isNegative(formattedValue) && this.currencyFormat.parse(formattedValue) !== 0) {
|
|
1253
|
+
formattedValue = formattedValue.replace(this.currencyFormat.prefix, this.currencyFormat.negativePrefix);
|
|
1254
|
+
}
|
|
1255
|
+
if (this.minValue >= 0) {
|
|
1256
|
+
formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.prefix);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
if (this.options.currencyDisplay === CurrencyDisplay.hidden || this.focus && this.options.hideCurrencySymbolOnFocus) {
|
|
1260
|
+
formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.minusSign !== void 0 ? this.currencyFormat.minusSign : "(").replace(this.currencyFormat.negativeSuffix, this.currencyFormat.minusSign !== void 0 ? "" : ")").replace(this.currencyFormat.prefix, "").replace(this.currencyFormat.suffix, "");
|
|
1261
|
+
}
|
|
1262
|
+
this.el.value = formattedValue;
|
|
1263
|
+
this.numberValue = this.currencyFormat.parse(formattedValue);
|
|
1264
|
+
} else {
|
|
1265
|
+
this.el.value = "";
|
|
1266
|
+
this.numberValue = null;
|
|
1267
|
+
}
|
|
1268
|
+
this.formattedValue = this.el.value;
|
|
1269
|
+
this.dispatchEvent("input");
|
|
1270
|
+
}
|
|
1271
|
+
addEventListener() {
|
|
1272
|
+
this.el.addEventListener("input", (e) => {
|
|
1273
|
+
if (!e.detail) {
|
|
1274
|
+
const { value, selectionStart } = this.el;
|
|
1275
|
+
const inputEvent = e;
|
|
1276
|
+
if (selectionStart && inputEvent.data && DECIMAL_SEPARATORS.includes(inputEvent.data)) {
|
|
1277
|
+
this.decimalSymbolInsertedAt = selectionStart - 1;
|
|
1278
|
+
}
|
|
1279
|
+
this.format(value);
|
|
1280
|
+
if (this.focus && selectionStart != null) {
|
|
1281
|
+
const getCaretPositionAfterFormat = () => {
|
|
1282
|
+
const { prefix, suffix, decimalSymbol, maximumFractionDigits, groupingSymbol } = this.currencyFormat;
|
|
1283
|
+
let caretPositionFromLeft = value.length - selectionStart;
|
|
1284
|
+
const newValueLength = this.formattedValue.length;
|
|
1285
|
+
if (this.currencyFormat.minusSign === void 0 && (value.startsWith("(") || value.startsWith("-")) && !value.endsWith(")")) {
|
|
1286
|
+
return newValueLength - this.currencyFormat.negativeSuffix.length > 1 ? this.formattedValue.substring(selectionStart).length : 1;
|
|
1287
|
+
}
|
|
1288
|
+
if (this.formattedValue.substr(selectionStart, 1) === groupingSymbol && count(this.formattedValue, groupingSymbol) === count(value, groupingSymbol) + 1) {
|
|
1289
|
+
return newValueLength - caretPositionFromLeft - 1;
|
|
1290
|
+
}
|
|
1291
|
+
if (newValueLength < caretPositionFromLeft) {
|
|
1292
|
+
return selectionStart;
|
|
1293
|
+
}
|
|
1294
|
+
if (decimalSymbol !== void 0 && value.indexOf(decimalSymbol) !== -1) {
|
|
1295
|
+
const decimalSymbolPosition = value.indexOf(decimalSymbol) + 1;
|
|
1296
|
+
if (Math.abs(newValueLength - value.length) > 1 && selectionStart <= decimalSymbolPosition) {
|
|
1297
|
+
return this.formattedValue.indexOf(decimalSymbol) + 1;
|
|
1298
|
+
} else {
|
|
1299
|
+
if (!this.options.autoDecimalDigits && selectionStart > decimalSymbolPosition) {
|
|
1300
|
+
if (this.currencyFormat.onlyDigits(value.substr(decimalSymbolPosition)).length - 1 === maximumFractionDigits) {
|
|
1301
|
+
caretPositionFromLeft -= 1;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
return this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === CurrencyDisplay.hidden ? newValueLength - caretPositionFromLeft : Math.max(newValueLength - Math.max(caretPositionFromLeft, suffix.length), prefix.length);
|
|
1307
|
+
};
|
|
1308
|
+
this.setCaretPosition(getCaretPositionAfterFormat());
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}, { capture: true });
|
|
1312
|
+
this.el.addEventListener("focus", () => {
|
|
1313
|
+
this.focus = true;
|
|
1314
|
+
setTimeout(() => {
|
|
1315
|
+
const { value, selectionStart, selectionEnd } = this.el;
|
|
1316
|
+
this.format(value, this.options.hideNegligibleDecimalDigitsOnFocus);
|
|
1317
|
+
if (selectionStart != null && selectionEnd != null && Math.abs(selectionStart - selectionEnd) > 0) {
|
|
1318
|
+
this.setCaretPosition(0, this.el.value.length);
|
|
1319
|
+
} else if (selectionStart != null) {
|
|
1320
|
+
const caretPositionOnFocus = this.getCaretPositionOnFocus(value, selectionStart);
|
|
1321
|
+
this.setCaretPosition(caretPositionOnFocus);
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
});
|
|
1325
|
+
this.el.addEventListener("blur", () => {
|
|
1326
|
+
this.focus = false;
|
|
1327
|
+
this.applyFixedFractionFormat(this.numberValue);
|
|
1328
|
+
});
|
|
1329
|
+
this.el.addEventListener("change", (e) => {
|
|
1330
|
+
if (!e.detail) {
|
|
1331
|
+
this.dispatchEvent("change");
|
|
1332
|
+
}
|
|
1333
|
+
}, { capture: true });
|
|
1334
|
+
}
|
|
1335
|
+
getCaretPositionOnFocus(value, selectionStart) {
|
|
1336
|
+
if (this.numberValue == null) {
|
|
1337
|
+
return selectionStart;
|
|
1338
|
+
}
|
|
1339
|
+
const { prefix, negativePrefix, suffix, negativeSuffix, groupingSymbol, currency } = this.currencyFormat;
|
|
1340
|
+
const isNegative = this.numberValue < 0;
|
|
1341
|
+
const currentPrefix = isNegative ? negativePrefix : prefix;
|
|
1342
|
+
const prefixLength = currentPrefix.length;
|
|
1343
|
+
if (this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === CurrencyDisplay.hidden) {
|
|
1344
|
+
if (isNegative) {
|
|
1345
|
+
if (selectionStart <= 1) {
|
|
1346
|
+
return 1;
|
|
1347
|
+
} else if (value.endsWith(")") && selectionStart > value.indexOf(")")) {
|
|
1348
|
+
return this.formattedValue.length - 1;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
} else {
|
|
1352
|
+
const suffixLength = isNegative ? negativeSuffix.length : suffix.length;
|
|
1353
|
+
if (selectionStart >= value.length - suffixLength) {
|
|
1354
|
+
return this.formattedValue.length - suffixLength;
|
|
1355
|
+
} else if (selectionStart < prefixLength) {
|
|
1356
|
+
return prefixLength;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
let result = selectionStart;
|
|
1360
|
+
if (this.options.hideCurrencySymbolOnFocus && this.options.currencyDisplay !== CurrencyDisplay.hidden && selectionStart >= prefixLength && currency !== void 0 && currentPrefix.includes(currency)) {
|
|
1361
|
+
result -= prefixLength;
|
|
1362
|
+
if (isNegative) {
|
|
1363
|
+
result += 1;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
if (this.options.hideGroupingSeparatorOnFocus && groupingSymbol !== void 0) {
|
|
1367
|
+
result -= count(value.substring(0, selectionStart), groupingSymbol);
|
|
1368
|
+
}
|
|
1369
|
+
return result;
|
|
1370
|
+
}
|
|
1371
|
+
setCaretPosition(start, end = start) {
|
|
1372
|
+
this.el.setSelectionRange(start, end);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
const findInput = (el) => (el === null || el === void 0 ? void 0 : el.matches("input")) ? el : el === null || el === void 0 ? void 0 : el.querySelector("input");
|
|
1376
|
+
var useCurrencyInput = (options) => {
|
|
1377
|
+
var _a;
|
|
1378
|
+
let numberInput;
|
|
1379
|
+
let input2;
|
|
1380
|
+
const inputRef = ref(null);
|
|
1381
|
+
const formattedValue = ref(null);
|
|
1382
|
+
const instance = getCurrentInstance();
|
|
1383
|
+
const emit = (event, value) => instance === null || instance === void 0 ? void 0 : instance.emit(event, value);
|
|
1384
|
+
const lazyModel = (_a = instance === null || instance === void 0 ? void 0 : instance.attrs.modelModifiers) === null || _a === void 0 ? void 0 : _a.lazy;
|
|
1385
|
+
const numberValue = computed(() => instance === null || instance === void 0 ? void 0 : instance.props["modelValue"]);
|
|
1386
|
+
const inputEvent = "update:modelValue";
|
|
1387
|
+
const changeEvent = lazyModel ? "update:modelValue" : "change";
|
|
1388
|
+
const hasInputEventListener = !lazyModel;
|
|
1389
|
+
const hasChangeEventListener = lazyModel || !(instance === null || instance === void 0 ? void 0 : instance.attrs.onChange);
|
|
1390
|
+
const onInput = (e) => {
|
|
1391
|
+
if (e.detail) {
|
|
1392
|
+
if (numberValue.value !== e.detail.number) {
|
|
1393
|
+
emit(inputEvent, e.detail.number);
|
|
1394
|
+
}
|
|
1395
|
+
formattedValue.value = e.detail.formatted;
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
const onChange = (e) => {
|
|
1399
|
+
if (e.detail) {
|
|
1400
|
+
emit(changeEvent, e.detail.number);
|
|
1401
|
+
formattedValue.value = e.detail.formatted;
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
watch(inputRef, (value) => {
|
|
1405
|
+
var _a2, _b;
|
|
1406
|
+
if (value) {
|
|
1407
|
+
input2 = findInput((_b = (_a2 = value) === null || _a2 === void 0 ? void 0 : _a2.$el) !== null && _b !== void 0 ? _b : value);
|
|
1408
|
+
if (input2) {
|
|
1409
|
+
numberInput = new CurrencyInput(input2, options);
|
|
1410
|
+
if (hasInputEventListener) {
|
|
1411
|
+
input2.addEventListener("input", onInput);
|
|
1412
|
+
}
|
|
1413
|
+
if (hasChangeEventListener) {
|
|
1414
|
+
input2.addEventListener("change", onChange);
|
|
1415
|
+
}
|
|
1416
|
+
numberInput.setValue(numberValue.value);
|
|
1417
|
+
} else {
|
|
1418
|
+
console.error('No input element found. Please make sure that the "inputRef" template ref is properly assigned.');
|
|
1419
|
+
}
|
|
1420
|
+
} else {
|
|
1421
|
+
numberInput = null;
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
onUnmounted(() => {
|
|
1425
|
+
if (hasInputEventListener) {
|
|
1426
|
+
input2 === null || input2 === void 0 ? void 0 : input2.removeEventListener("input", onInput);
|
|
1427
|
+
}
|
|
1428
|
+
if (hasChangeEventListener) {
|
|
1429
|
+
input2 === null || input2 === void 0 ? void 0 : input2.removeEventListener("change", onChange);
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
return {
|
|
1433
|
+
inputRef,
|
|
1434
|
+
formattedValue,
|
|
1435
|
+
setValue: (value) => numberInput === null || numberInput === void 0 ? void 0 : numberInput.setValue(value),
|
|
1436
|
+
setOptions: (options2) => numberInput === null || numberInput === void 0 ? void 0 : numberInput.setOptions(options2)
|
|
1437
|
+
};
|
|
1438
|
+
};
|
|
25
1439
|
var plCurrency_vue_vue_type_style_index_0_lang = "";
|
|
1440
|
+
const _hoisted_1 = /* @__PURE__ */ createElementVNode("span", { class: "pl-currency__rub-icon" }, "\u20BD", -1);
|
|
1441
|
+
const __default__ = {
|
|
1442
|
+
name: "PlCurrency"
|
|
1443
|
+
};
|
|
1444
|
+
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
1445
|
+
props: {
|
|
1446
|
+
modelValue: String,
|
|
1447
|
+
width: String
|
|
1448
|
+
},
|
|
1449
|
+
emits: ["update:modelValue"],
|
|
1450
|
+
setup(__props, { emit }) {
|
|
1451
|
+
const innerValue = ref(null);
|
|
1452
|
+
const options = reactive({
|
|
1453
|
+
currency: "EUR",
|
|
1454
|
+
currencyDisplay: "hidden",
|
|
1455
|
+
precision: 2
|
|
1456
|
+
});
|
|
1457
|
+
const { inputRef } = useCurrencyInput(options);
|
|
1458
|
+
watch(innerValue, (newValue) => {
|
|
1459
|
+
emit("update:modelValue", newValue);
|
|
1460
|
+
});
|
|
1461
|
+
return (_ctx, _cache) => {
|
|
1462
|
+
const _component_el_input = ElInput;
|
|
1463
|
+
return openBlock(), createBlock(_component_el_input, mergeProps({
|
|
1464
|
+
style: `width: ${__props.width};`
|
|
1465
|
+
}, _ctx.$attrs, {
|
|
1466
|
+
ref_key: "inputRef",
|
|
1467
|
+
ref: inputRef,
|
|
1468
|
+
modelValue: innerValue.value,
|
|
1469
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => innerValue.value = $event),
|
|
1470
|
+
class: "pl-currency"
|
|
1471
|
+
}), {
|
|
1472
|
+
append: withCtx(() => [
|
|
1473
|
+
_hoisted_1
|
|
1474
|
+
]),
|
|
1475
|
+
_: 1
|
|
1476
|
+
}, 16, ["style", "modelValue"]);
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1480
|
+
const PlCurrencyPlugin = {
|
|
1481
|
+
install(app) {
|
|
1482
|
+
app.component(_sfc_main);
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
export { PlCurrencyPlugin as default };
|