@opentiny/vue-renderless 3.21.2 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/amount/index.js +4 -4
- package/anchor/index.js +1 -1
- package/async-flowchart/index.js +1 -1
- package/autocomplete/index.js +4 -1
- package/autocomplete/vue.js +3 -3
- package/base-select/index.js +20 -21
- package/base-select/vue.js +2 -2
- package/calendar/index.js +2 -2
- package/calendar-bar/index.js +2 -2
- package/calendar-bar/vue.js +1 -1
- package/calendar-view/index.js +91 -25
- package/calendar-view/vue.js +6 -4
- package/card/index.js +1 -1
- package/card-template/index.js +1 -1
- package/carousel/index.js +4 -4
- package/carousel/vue.js +1 -1
- package/cascader/index.js +21 -11
- package/cascader/vue.js +6 -5
- package/cascader-menu/vue.js +2 -2
- package/cascader-mobile/index.js +1 -1
- package/cascader-node/vue.js +11 -1
- package/cascader-panel/index.js +4 -4
- package/cascader-panel/node.js +3 -4
- package/cascader-panel/vue.js +1 -1
- package/cascader-select/column-index.js +2 -2
- package/cascader-view/index.js +1 -1
- package/chart-bar/index.js +1 -1
- package/chart-candle/index.js +1 -1
- package/chart-core/deps/utils.js +6 -6
- package/chart-core/index.js +1 -1
- package/chart-funnel/index.js +1 -1
- package/chart-gauge/index.js +1 -1
- package/chart-line/index.js +1 -1
- package/chart-map/index.js +1 -1
- package/chart-pie/index.js +1 -1
- package/chart-radar/index.js +1 -1
- package/chart-sankey/index.js +1 -1
- package/chart-scatter/index.js +1 -1
- package/chart-waterfall/index.js +1 -1
- package/chart-wordcloud/index.js +1 -1
- package/checkbox/index.js +1 -1
- package/collapse-item/vue.js +1 -1
- package/column-list-item/index.js +1 -1
- package/common/deps/dom.js +20 -196
- package/common/deps/infinite-scroll.js +4 -43
- package/common/deps/popup-manager.js +1 -200
- package/container/index.js +2 -2
- package/crop/index.js +3 -3
- package/currency/index.js +2 -2
- package/date-panel/index.js +82 -26
- package/date-panel/vue.js +53 -21
- package/date-picker/vue.js +1 -1
- package/date-picker-mobile/index.js +1 -1
- package/date-range/index.js +74 -37
- package/date-range/vue.js +27 -23
- package/date-table/index.js +8 -5
- package/date-table/vue.js +1 -1
- package/dialog-box/index.js +3 -3
- package/dialog-box/vue.js +1 -1
- package/dialog-select/index.js +15 -4
- package/dialog-select/vue.js +7 -4
- package/drawer/index.js +2 -2
- package/drop-times/index.js +1 -1
- package/dropdown/index.js +11 -3
- package/dropdown/vue.js +2 -2
- package/dropdown-item/index.js +1 -1
- package/dropdown-item/mf.js +1 -1
- package/dropdown-menu/index.js +1 -1
- package/espace/vue.js +2 -2
- package/fall-menu/index.js +3 -3
- package/file-upload/index.js +16 -13
- package/file-upload/vue.js +2 -2
- package/filter/vue.js +1 -1
- package/filter-panel/vue.js +1 -2
- package/floating-button/index.js +1 -1
- package/flowchart/index.js +3 -3
- package/flowchart/vue.js +1 -1
- package/fluent-editor/index.js +5 -7
- package/fluent-editor/options.js +2 -2
- package/form/index.js +20 -2
- package/form-item/index.js +6 -6
- package/fullscreen/index.js +1 -1
- package/fullscreen/vue.js +1 -1
- package/grid/plugins/export.js +8 -2
- package/grid/plugins/exportExcel.js +3 -3
- package/grid/plugins/resize.js +2 -2
- package/grid/static/base/helperEqualCompare.js +1 -1
- package/grid/static/base/isPlainObject.js +1 -1
- package/grid/utils/common.js +2 -2
- package/grid/utils/dom.js +12 -7
- package/grid/utils/event.js +4 -4
- package/hrapprover/index.js +1 -1
- package/image/index.js +3 -3
- package/image-viewer/index.js +4 -6
- package/image-viewer/vue.js +1 -1
- package/input/index.js +2 -2
- package/input/vue.js +1 -1
- package/ip-address/index.js +17 -21
- package/ip-address/vue.js +1 -1
- package/link-menu/index.js +1 -1
- package/link-menu/vue.js +1 -1
- package/load-list/index.js +1 -1
- package/load-list/vue.js +4 -4
- package/loading/index.js +2 -2
- package/menu/vue.js +1 -1
- package/milestone/index.js +6 -45
- package/modal/index.js +5 -5
- package/month-range/index.js +48 -5
- package/month-range/vue.js +19 -15
- package/month-table/index.js +5 -5
- package/month-table/vue.js +1 -1
- package/nav-menu/index.js +7 -7
- package/notify/index.js +3 -3
- package/number-animation/index.js +53 -0
- package/number-animation/vue.js +27 -0
- package/numeric/index.js +5 -5
- package/option/index.js +1 -1
- package/option/vue.js +2 -1
- package/package.json +3 -2
- package/pager/index.js +28 -16
- package/pager/vue.js +27 -16
- package/panel/index.js +1 -1
- package/picker/index.js +28 -23
- package/picker/vue.js +6 -6
- package/picker-column/index.js +1 -1
- package/pop-upload/vue.js +1 -1
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +6 -6
- package/popeditor/vue.js +2 -2
- package/popover/index.js +3 -3
- package/popover/vue.js +1 -1
- package/popup/index.js +3 -3
- package/pull-refresh/index.js +1 -1
- package/pull-refresh-mobile-first/index.js +1 -1
- package/pull-refresh-mobile-first/vue.js +4 -4
- package/quarter-panel/index.js +2 -2
- package/quarter-panel/vue.js +1 -1
- package/radio-group/index.js +1 -1
- package/rate/index.js +1 -1
- package/rate/vue.js +1 -1
- package/recycle-scroller/index.js +2 -2
- package/recycle-scroller/vue.js +1 -1
- package/rich-text/index.js +1 -1
- package/rich-text/table-module.js +2 -2
- package/river/river.js +1 -1
- package/river/vue.js +1 -1
- package/scrollbar/vue-bar.js +1 -1
- package/scrollbar/vue.js +1 -1
- package/search/index.js +3 -3
- package/select/index.js +26 -22
- package/select/vue.js +8 -7
- package/select-dropdown/vue.js +5 -5
- package/selected-box/index.js +1 -1
- package/signature/index.js +1 -1
- package/signature/vue.js +2 -2
- package/skeleton/index.js +1 -1
- package/slider/index.js +4 -4
- package/slider-button-group/slide-button.js +2 -2
- package/split/index.js +2 -2
- package/split/vue.js +1 -1
- package/statistic/index.js +1 -1
- package/steps/index.js +2 -3
- package/steps/slide-bar.js +2 -2
- package/sticky/vue.js +4 -4
- package/tab-bar/index.js +2 -2
- package/tab-item-mf/vue.js +1 -1
- package/tab-nav/index.js +4 -4
- package/tabbar/index.js +1 -1
- package/tabbar/vue.js +1 -1
- package/tabbar-item/index.js +1 -1
- package/tabs-mf/index.js +9 -5
- package/tabs-mf/vue-bar.js +5 -4
- package/tabs-mf/vue-swipe.js +1 -1
- package/tabs-mf/vue.js +2 -2
- package/tabs-mf/wheel.js +3 -3
- package/tag-group/vue.js +2 -2
- package/tall-storage/index.js +1 -1
- package/tall-storage/vue.js +1 -1
- package/time/index.js +1 -1
- package/time/vue.js +1 -1
- package/time-line/index.js +1 -1
- package/time-line-new/index.js +1 -1
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +1 -1
- package/time-range/index.js +1 -1
- package/time-range/vue.js +1 -1
- package/time-spinner/index.js +4 -4
- package/time-spinner/vue.js +1 -1
- package/timeline-item/index.js +1 -1
- package/toggle-menu/index.js +1 -1
- package/tooltip/index.js +2 -2
- package/tooltip/vue.js +2 -2
- package/top-box/index.js +3 -3
- package/transfer/index.js +42 -1
- package/transfer/vue.js +64 -24
- package/transfer-panel/index.js +6 -1
- package/tree/index.js +9 -9
- package/tree/vue.js +2 -2
- package/tree-node/index.js +1 -1
- package/tree-node/vue.js +1 -1
- package/tree-select/index.js +68 -22
- package/tree-select/vue.js +27 -3
- package/types/async-flowchart.type.d.ts +2 -14
- package/types/breadcrumb-item.type.d.ts +5 -1
- package/types/breadcrumb.type.d.ts +5 -1
- package/types/button-group.type.d.ts +5 -1
- package/types/button.type.d.ts +2 -2
- package/types/cascader.type.d.ts +6 -1
- package/types/date-table.type.d.ts +1 -120
- package/types/dropdown.type.d.ts +1 -1
- package/types/label.type.d.ts +1 -53
- package/types/loading.type.d.ts +12 -0
- package/types/numeric.type.d.ts +3 -22
- package/types/pager.type.d.ts +12 -7
- package/types/popconfirm.type.d.ts +2 -0
- package/types/steps.type.d.ts +1 -0
- package/types/tag-group.type.d.ts +2 -14
- package/types/tag.type.d.ts +4 -4
- package/types/tooltip.type.d.ts +3 -13
- package/types/transfer.type.d.ts +3 -0
- package/types/user-head.type.d.ts +0 -4
- package/upload/index.js +1 -1
- package/upload-list/index.js +1 -1
- package/upload-list/vue.js +4 -4
- package/user/index.js +7 -7
- package/user/vue.js +15 -2
- package/user-contact/vue.js +2 -2
- package/virtual-scroll-box/index.js +2 -2
- package/wizard/index.js +3 -3
- package/year-range/index.js +61 -11
- package/year-range/vue.js +33 -20
- package/year-table/index.js +10 -5
- package/avatar/index.js +0 -30
- package/avatar/vue.js +0 -22
- package/common/array.js +0 -115
- package/common/bigInt.js +0 -315
- package/common/browser.js +0 -81
- package/common/calendar/calendar.js +0 -97
- package/common/dataset/index.js +0 -99
- package/common/date.js +0 -354
- package/common/decimal.js +0 -155
- package/common/deps/ResizeObserver.js +0 -456
- package/common/deps/after-leave.js +0 -27
- package/common/deps/clickoutside.js +0 -75
- package/common/deps/date-util.js +0 -255
- package/common/deps/date.js +0 -286
- package/common/deps/debounce.js +0 -8
- package/common/deps/eSpaceCtrl.js +0 -304
- package/common/deps/fastdom/async.js +0 -41
- package/common/deps/fastdom/index.js +0 -9
- package/common/deps/fastdom/sandbox.js +0 -53
- package/common/deps/fastdom/singleton.js +0 -88
- package/common/deps/fullscreen/apis.js +0 -143
- package/common/deps/fullscreen/screenfull.js +0 -165
- package/common/deps/memorize.js +0 -124
- package/common/deps/observe-visibility.js +0 -106
- package/common/deps/popper.js +0 -616
- package/common/deps/repeat-click.js +0 -29
- package/common/deps/resize-event.js +0 -39
- package/common/deps/scroll-into-view.js +0 -29
- package/common/deps/scrollbar-width.js +0 -33
- package/common/deps/throttle.js +0 -45
- package/common/deps/touch-emulator.js +0 -103
- package/common/deps/touch.js +0 -37
- package/common/deps/tree-model/node.js +0 -475
- package/common/deps/tree-model/tree-store.js +0 -312
- package/common/deps/tree-model/util.js +0 -24
- package/common/deps/upload-ajax.js +0 -81
- package/common/deps/useEventListener.js +0 -54
- package/common/deps/useInstanceSlots.js +0 -22
- package/common/deps/useRect.js +0 -25
- package/common/deps/useRelation.js +0 -89
- package/common/deps/useTouch.js +0 -68
- package/common/deps/useUserAgent.js +0 -16
- package/common/deps/useWindowSize.js +0 -23
- package/common/deps/vue-emitter.js +0 -34
- package/common/deps/vue-popper.js +0 -180
- package/common/deps/vue-popup.js +0 -138
- package/common/event.js +0 -46
- package/common/form/const.js +0 -10
- package/common/function.js +0 -28
- package/common/global.js +0 -11
- package/common/index.js +0 -259
- package/common/object.js +0 -227
- package/common/prop-util.js +0 -43
- package/common/runtime.js +0 -79
- package/common/string.js +0 -417
- package/common/type.js +0 -66
- package/common/validate/index.js +0 -10
- package/common/validate/messages.js +0 -65
- package/common/validate/rules/enum.js +0 -12
- package/common/validate/rules/index.js +0 -18
- package/common/validate/rules/pattern.js +0 -20
- package/common/validate/rules/range.js +0 -52
- package/common/validate/rules/required.js +0 -11
- package/common/validate/rules/type.js +0 -100
- package/common/validate/rules/whitespace.js +0 -10
- package/common/validate/schema.js +0 -290
- package/common/validate/util.js +0 -211
- package/common/validate/validations/array.js +0 -22
- package/common/validate/validations/date.js +0 -31
- package/common/validate/validations/enum.js +0 -22
- package/common/validate/validations/float.js +0 -22
- package/common/validate/validations/index.js +0 -46
- package/common/validate/validations/integer.js +0 -22
- package/common/validate/validations/method.js +0 -21
- package/common/validate/validations/number.js +0 -25
- package/common/validate/validations/pattern.js +0 -21
- package/common/validate/validations/required.js +0 -11
- package/common/validate/validations/string.js +0 -33
- package/common/validate/validations/type.js +0 -29
- package/index-bar/index.js +0 -66
- package/index-bar/vue.js +0 -73
- package/index-bar-anchor/vue.js +0 -16
- package/label/index.js +0 -56
- package/label/vue.js +0 -26
- package/list/index.js +0 -13
- package/list/vue.js +0 -17
- package/mask/index.js +0 -13
- package/mask/vue.js +0 -18
- package/mini-picker/index.js +0 -165
- package/mini-picker/vue.js +0 -122
- package/multi-select/index.js +0 -394
- package/multi-select/vue.js +0 -113
- package/multi-select-item/index.js +0 -23
- package/multi-select-item/vue.js +0 -31
- package/toast/index.js +0 -7
- package/toast/vue.js +0 -19
- package/types/toast.type.d.ts +0 -63
- package/wheel/index.js +0 -165
- package/wheel/vue.js +0 -79
package/common/string.js
DELETED
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import "../chunk-G2ADBYYC.js";
|
|
2
|
-
import { isPlainObject, isNumber, isNumeric, isNull } from "./type";
|
|
3
|
-
import { getObj, toJsonStr } from "./object";
|
|
4
|
-
import { toFixed, Decimal } from "./decimal";
|
|
5
|
-
import { globalEnvironment, isBrowser } from "./browser";
|
|
6
|
-
const formatTypes = {
|
|
7
|
-
text: "text",
|
|
8
|
-
url: "url",
|
|
9
|
-
html: "html",
|
|
10
|
-
tmpl: "tmpl"
|
|
11
|
-
};
|
|
12
|
-
const escapeChars = {
|
|
13
|
-
"&": "&",
|
|
14
|
-
"<": "<",
|
|
15
|
-
">": ">",
|
|
16
|
-
'"': """,
|
|
17
|
-
"'": "'",
|
|
18
|
-
"[": "[",
|
|
19
|
-
"]": "]"
|
|
20
|
-
};
|
|
21
|
-
const isNullOrEmpty = (value) => value === null || value === void 0 || typeof value === "string" && value.trim().length === 0;
|
|
22
|
-
function cached(fn) {
|
|
23
|
-
let cache = /* @__PURE__ */ Object.create(null);
|
|
24
|
-
return function cachedFn(str) {
|
|
25
|
-
const hit = cache[str];
|
|
26
|
-
return hit || (cache[str] = fn(str));
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const camelizeRE = /-(\w)/g;
|
|
30
|
-
const camelize = cached((str) => str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""));
|
|
31
|
-
const capitalize = cached((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
|
32
|
-
const hyphenateRE = /\B([A-Z])/g;
|
|
33
|
-
const hyphenate = cached((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
34
|
-
const toJson = (string) => {
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(string);
|
|
37
|
-
} catch (e) {
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
function getLengthInUtf16(string) {
|
|
42
|
-
const len = string.length;
|
|
43
|
-
let count = 0;
|
|
44
|
-
for (let i = 0; i < len; i++) {
|
|
45
|
-
let charCode = string.charCodeAt(i);
|
|
46
|
-
if (charCode <= 65535) {
|
|
47
|
-
count += 2;
|
|
48
|
-
} else {
|
|
49
|
-
count += 4;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return count;
|
|
53
|
-
}
|
|
54
|
-
function getLengthInUtf8(string) {
|
|
55
|
-
const len = string.length;
|
|
56
|
-
let count = 0;
|
|
57
|
-
for (let i = 0; i < len; i++) {
|
|
58
|
-
let charCode = string.charCodeAt(i);
|
|
59
|
-
if (charCode <= 127) {
|
|
60
|
-
count += 1;
|
|
61
|
-
} else if (charCode <= 2047) {
|
|
62
|
-
count += 2;
|
|
63
|
-
} else if (charCode <= 65535) {
|
|
64
|
-
count += 3;
|
|
65
|
-
} else {
|
|
66
|
-
count += 4;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return count;
|
|
70
|
-
}
|
|
71
|
-
function getLengthDefault(string) {
|
|
72
|
-
const len = string.length;
|
|
73
|
-
let count = 0;
|
|
74
|
-
for (let i = 0; i < len; i++) {
|
|
75
|
-
count++;
|
|
76
|
-
if (string.charCodeAt(i) >> 8) {
|
|
77
|
-
count++;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return count;
|
|
81
|
-
}
|
|
82
|
-
const getLength = (string, regular) => {
|
|
83
|
-
if (!string || typeof string !== "string") {
|
|
84
|
-
return 0;
|
|
85
|
-
}
|
|
86
|
-
let count = 0;
|
|
87
|
-
if (typeof regular === "string") {
|
|
88
|
-
regular = regular.toLowerCase();
|
|
89
|
-
if (regular === "utf-16" || regular === "utf16") {
|
|
90
|
-
count = getLengthInUtf16(string);
|
|
91
|
-
} else if (regular === "utf-8" || regular === "utf8") {
|
|
92
|
-
count = getLengthInUtf8(string);
|
|
93
|
-
} else {
|
|
94
|
-
count = string.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
|
|
95
|
-
}
|
|
96
|
-
} else if (typeof regular === "function") {
|
|
97
|
-
return regular(string);
|
|
98
|
-
} else {
|
|
99
|
-
count = getLengthDefault(string);
|
|
100
|
-
}
|
|
101
|
-
return count;
|
|
102
|
-
};
|
|
103
|
-
const fillChar = (string, length, append, chr = "0") => {
|
|
104
|
-
if (typeof string === "string" && typeof chr === "string" && isNumber(length)) {
|
|
105
|
-
let len = string.length - length;
|
|
106
|
-
if (len > 0) {
|
|
107
|
-
return append ? string.substr(0, length) : string.substr(len, length);
|
|
108
|
-
} else {
|
|
109
|
-
const appendStr = [];
|
|
110
|
-
len = Math.abs(len) / chr.length;
|
|
111
|
-
for (; len > 0; len--) {
|
|
112
|
-
appendStr.push(chr);
|
|
113
|
-
}
|
|
114
|
-
const s = appendStr.join("");
|
|
115
|
-
return append ? string + s : s + string;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
const random = () => {
|
|
120
|
-
let MAX_UINT32_PLUS_ONE = 4294967296;
|
|
121
|
-
return globalEnvironment.crypto.getRandomValues(new globalEnvironment.Uint32Array(1))[0] / MAX_UINT32_PLUS_ONE;
|
|
122
|
-
};
|
|
123
|
-
const guid = (prefix = "", length = 8) => prefix + random().toString().substr(2, length);
|
|
124
|
-
const escapeHtml = (string, isReplaceSpace) => {
|
|
125
|
-
if (!string || typeof string !== "string") {
|
|
126
|
-
return string;
|
|
127
|
-
}
|
|
128
|
-
string = string.replace(/[&<>"']/g, (chr) => escapeChars[chr]);
|
|
129
|
-
return isReplaceSpace ? string.replace(/\s/g, " ") : string;
|
|
130
|
-
};
|
|
131
|
-
const escape = (string, escapeType, isReplaceSpace) => {
|
|
132
|
-
if (!string || typeof string !== "string") {
|
|
133
|
-
return string;
|
|
134
|
-
}
|
|
135
|
-
if (typeof escapeType === "boolean") {
|
|
136
|
-
isReplaceSpace = !!escapeType;
|
|
137
|
-
}
|
|
138
|
-
if (escapeType === "uri") {
|
|
139
|
-
return encodeURIComponent(string);
|
|
140
|
-
} else if (escapeType === "html") {
|
|
141
|
-
return escapeHtml(string, isReplaceSpace);
|
|
142
|
-
} else if (escapeType === "prop") {
|
|
143
|
-
string = escapeHtml(string, isReplaceSpace);
|
|
144
|
-
return string.replace(/[[\]]/g, (chr) => escapeChars[chr]);
|
|
145
|
-
}
|
|
146
|
-
string = string.replace(/[<>"]/g, (chr) => escapeChars[chr]);
|
|
147
|
-
return isReplaceSpace ? string.replace(/\s/g, " ") : string;
|
|
148
|
-
};
|
|
149
|
-
const getFormat = ({ sign, format: format2, hasSign }) => {
|
|
150
|
-
switch (sign) {
|
|
151
|
-
case "#":
|
|
152
|
-
format2 = formatTypes.text;
|
|
153
|
-
break;
|
|
154
|
-
case "@":
|
|
155
|
-
format2 = formatTypes.url;
|
|
156
|
-
break;
|
|
157
|
-
case "$":
|
|
158
|
-
format2 = formatTypes.html;
|
|
159
|
-
break;
|
|
160
|
-
case "%":
|
|
161
|
-
format2 = formatTypes.tmpl;
|
|
162
|
-
break;
|
|
163
|
-
default:
|
|
164
|
-
hasSign = false;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
return { format: format2, hasSign };
|
|
168
|
-
};
|
|
169
|
-
const fieldFormat = (string, data, type = "html") => {
|
|
170
|
-
if (typeof string === "string") {
|
|
171
|
-
return string.replace(/(\/)?\{\{([\s\S]*?)}}/g, (match, slash = "", offset = "") => {
|
|
172
|
-
const sign = offset.substr(0, 1);
|
|
173
|
-
let hasSign = true;
|
|
174
|
-
let format2 = formatTypes.html;
|
|
175
|
-
let ret = getFormat({ sign, format: format2, hasSign });
|
|
176
|
-
format2 = ret.format;
|
|
177
|
-
hasSign = ret.hasSign;
|
|
178
|
-
if (hasSign) {
|
|
179
|
-
offset = (offset || "").substring(1);
|
|
180
|
-
} else if (type) {
|
|
181
|
-
format2 = type;
|
|
182
|
-
}
|
|
183
|
-
let value = getObj(data, offset);
|
|
184
|
-
if (isNull(value)) {
|
|
185
|
-
value = "";
|
|
186
|
-
}
|
|
187
|
-
if (format2 === formatTypes.tmpl) {
|
|
188
|
-
value = `{{${value}}}`;
|
|
189
|
-
} else {
|
|
190
|
-
if (format2 === formatTypes.url) {
|
|
191
|
-
value = encodeURIComponent(value);
|
|
192
|
-
} else {
|
|
193
|
-
value = format2 === formatTypes.html ? escapeHtml(value) : value;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return format2 === formatTypes.url && value.length === 0 ? "" : slash + value;
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
const getFormatText = () => (str, reg, args, format2) => str.replace(reg, (m, i, j, k) => {
|
|
201
|
-
if (!isNullOrEmpty(i) && !isNullOrEmpty(k)) {
|
|
202
|
-
return `{${j}}`;
|
|
203
|
-
}
|
|
204
|
-
const value = args[j];
|
|
205
|
-
const string = isPlainObject(value) ? toJsonStr(value) : value;
|
|
206
|
-
if (isNullOrEmpty(value)) {
|
|
207
|
-
return "";
|
|
208
|
-
}
|
|
209
|
-
return typeof value === "string" && typeof format2 === "function" ? format2(string) : string;
|
|
210
|
-
});
|
|
211
|
-
const getResult = ({ type, res, formatText, string, reg, args }) => {
|
|
212
|
-
if (type === formatTypes.url) {
|
|
213
|
-
res = formatText(string, reg, args, encodeURIComponent);
|
|
214
|
-
} else if (type === formatTypes.html) {
|
|
215
|
-
res = formatText(string, reg, args, escapeHtml);
|
|
216
|
-
} else {
|
|
217
|
-
res = formatText(string, reg, args);
|
|
218
|
-
}
|
|
219
|
-
return res;
|
|
220
|
-
};
|
|
221
|
-
const judgForFunc = (args, formatTypes2, type) => {
|
|
222
|
-
const lastArg = args[args.length - 1];
|
|
223
|
-
if (lastArg !== formatTypes2.text && lastArg !== formatTypes2.url && lastArg !== formatTypes2.html) {
|
|
224
|
-
args = Array.prototype.slice.call(args, 1);
|
|
225
|
-
} else {
|
|
226
|
-
args = Array.prototype.slice.call(args, 1, args.length - 1);
|
|
227
|
-
type = lastArg;
|
|
228
|
-
}
|
|
229
|
-
return { args, type };
|
|
230
|
-
};
|
|
231
|
-
const checkParam = ({ data, args, type, _arguments }) => {
|
|
232
|
-
if (Array.isArray(data)) {
|
|
233
|
-
args = data;
|
|
234
|
-
} else {
|
|
235
|
-
const judgObj = judgForFunc(_arguments, formatTypes, type);
|
|
236
|
-
args = judgObj.args;
|
|
237
|
-
type = judgObj.type;
|
|
238
|
-
}
|
|
239
|
-
return { args, type };
|
|
240
|
-
};
|
|
241
|
-
const format = function(string, data, type = "text") {
|
|
242
|
-
if (typeof string !== "string" || arguments.length < 2) {
|
|
243
|
-
return string;
|
|
244
|
-
}
|
|
245
|
-
let args, res;
|
|
246
|
-
if (isPlainObject(data)) {
|
|
247
|
-
return fieldFormat(string, data, type);
|
|
248
|
-
}
|
|
249
|
-
const ret = checkParam({ data, args, type, _arguments: arguments });
|
|
250
|
-
args = ret.args;
|
|
251
|
-
type = ret.type;
|
|
252
|
-
const reg = /(\\)?\{(\d+)(\\)?}/g;
|
|
253
|
-
const formatText = getFormatText();
|
|
254
|
-
res = getResult({ type, res, formatText, string, reg, args });
|
|
255
|
-
return res;
|
|
256
|
-
};
|
|
257
|
-
const getTruthyValue = ({ string, length, ellipsis }) => {
|
|
258
|
-
const flag = typeof string === "string" && isNumber(length) && length < string.length;
|
|
259
|
-
const truthyValue = flag && format(ellipsis, string.substr(0, length));
|
|
260
|
-
return { flag, truthyValue };
|
|
261
|
-
};
|
|
262
|
-
const truncate = (string, length, ellipsis = "{0}...") => {
|
|
263
|
-
const { flag, truthyValue } = getTruthyValue({ string, length, ellipsis });
|
|
264
|
-
return flag ? truthyValue : string;
|
|
265
|
-
};
|
|
266
|
-
const tryToConvert = (convert, defaultValue, ...args) => {
|
|
267
|
-
const result = convert.apply(null, args);
|
|
268
|
-
return isNaN(result) ? defaultValue : result;
|
|
269
|
-
};
|
|
270
|
-
const toInt = (value) => isNumber(value) ? Number(value.toFixed(0)) : typeof value === "string" ? parseInt(value, 10) : NaN;
|
|
271
|
-
const tryToInt = (value, defaultValue) => tryToConvert(toInt, defaultValue, value);
|
|
272
|
-
const toNumber = (value) => isNumber(value) ? value : typeof value === "string" ? parseFloat(value) : NaN;
|
|
273
|
-
const tryToNumber = (value, defaultValue) => tryToConvert(toNumber, defaultValue, value);
|
|
274
|
-
const toDecimal = (value, fraction = 2, isTruncate = false) => {
|
|
275
|
-
let result = NaN;
|
|
276
|
-
if (isNumber(value)) {
|
|
277
|
-
result = value;
|
|
278
|
-
}
|
|
279
|
-
if (typeof value === "string") {
|
|
280
|
-
const val = parseFloat(value);
|
|
281
|
-
if (!isNaN(val)) {
|
|
282
|
-
result = val;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
if (isNumber(result)) {
|
|
286
|
-
if (isTruncate) {
|
|
287
|
-
result = toFixed(
|
|
288
|
-
value.toString().split(".").slice(0, 2).map((str, index) => index ? str.slice(0, fraction) : str).join("."),
|
|
289
|
-
fraction
|
|
290
|
-
);
|
|
291
|
-
} else {
|
|
292
|
-
result = toFixed(result, fraction);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return result;
|
|
296
|
-
};
|
|
297
|
-
const tryToDecimal = (value, fraction, isTruncate, defaultValue) => tryToConvert(toDecimal, defaultValue, value, fraction, isTruncate);
|
|
298
|
-
const toCurrency = (value, fraction, placeholder, isTruncate) => {
|
|
299
|
-
if (isNumeric(value)) {
|
|
300
|
-
let val = toDecimal(Number(value), fraction, isTruncate);
|
|
301
|
-
val = String(val).replace(/(^|[^\w.])(\d{4,})/g, ($0, $1, $2) => $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,"));
|
|
302
|
-
return placeholder ? format(placeholder, val) : val;
|
|
303
|
-
}
|
|
304
|
-
return NaN;
|
|
305
|
-
};
|
|
306
|
-
const tryToCurrency = (value, fraction, placeholder, defaultValue) => isNaN(toNumber(value)) ? defaultValue : toCurrency(value, fraction, placeholder);
|
|
307
|
-
const toBoolValue = (value) => {
|
|
308
|
-
if (isNumber(value)) {
|
|
309
|
-
return value ? 1 : 0;
|
|
310
|
-
} else if (isNull(value) || value === "false") {
|
|
311
|
-
return false;
|
|
312
|
-
} else if (value === "true") {
|
|
313
|
-
return true;
|
|
314
|
-
} else if (typeof value === "boolean") {
|
|
315
|
-
return value;
|
|
316
|
-
}
|
|
317
|
-
return !!value;
|
|
318
|
-
};
|
|
319
|
-
const toRate = (value, total = 1, fraction = 2) => isNumber(value) && isNumber(total) ? toDecimal(Decimal(value).mul(100).div(total).toNumber(), fraction) + "%" : value;
|
|
320
|
-
const toFileSize = (value, unit, currUnit) => {
|
|
321
|
-
if (isNumeric(value)) {
|
|
322
|
-
value = Number(value);
|
|
323
|
-
if (value === 0) {
|
|
324
|
-
return `0${currUnit || unit || "B"}`;
|
|
325
|
-
}
|
|
326
|
-
const fileSize = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
327
|
-
let index = fileSize.indexOf(currUnit);
|
|
328
|
-
if (index > -1) {
|
|
329
|
-
for (let i = 0; i < index; i++) {
|
|
330
|
-
value *= 1024;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
index = fileSize.indexOf(unit);
|
|
334
|
-
if (index < 0) {
|
|
335
|
-
index = fileSize.length - 1;
|
|
336
|
-
}
|
|
337
|
-
let level = 0;
|
|
338
|
-
for (let i = 0; i < index && (value <= -1024 || value >= 1024); i++) {
|
|
339
|
-
value /= 1024;
|
|
340
|
-
level++;
|
|
341
|
-
}
|
|
342
|
-
return toDecimal(value, 2) + fileSize[level];
|
|
343
|
-
}
|
|
344
|
-
return value;
|
|
345
|
-
};
|
|
346
|
-
const formatFileSize = (size, baseUnit = "") => {
|
|
347
|
-
if ([void 0, null].includes(size)) {
|
|
348
|
-
return "";
|
|
349
|
-
} else if (!isNumber(size) || size <= 0) {
|
|
350
|
-
return size + baseUnit;
|
|
351
|
-
}
|
|
352
|
-
const unitArr = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
353
|
-
let unitIndex = Math.max(unitArr.indexOf((baseUnit + "").toLocaleUpperCase()), 0);
|
|
354
|
-
while (size >= 1024 && unitIndex < unitArr.length - 1) {
|
|
355
|
-
size = size / 1024;
|
|
356
|
-
unitIndex++;
|
|
357
|
-
}
|
|
358
|
-
while (size < 1 && unitIndex > 0) {
|
|
359
|
-
size = size * 1024;
|
|
360
|
-
unitIndex--;
|
|
361
|
-
}
|
|
362
|
-
return parseFloat(toDecimal(size, 2, true)) + unitArr[unitIndex];
|
|
363
|
-
};
|
|
364
|
-
const isKorean = (text) => /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi.test(text);
|
|
365
|
-
const omitText = (text, font, w) => {
|
|
366
|
-
let t;
|
|
367
|
-
if (!isBrowser)
|
|
368
|
-
return { t: text, o: false };
|
|
369
|
-
const canvas = document.createElement("canvas");
|
|
370
|
-
const ctx = canvas.getContext("2d");
|
|
371
|
-
ctx.font = font;
|
|
372
|
-
let metric = ctx.measureText(text);
|
|
373
|
-
if (metric.width < w) {
|
|
374
|
-
return { t: text, o: false };
|
|
375
|
-
} else {
|
|
376
|
-
for (let i = -1; ; i--) {
|
|
377
|
-
t = text.slice(0, i) + "...";
|
|
378
|
-
metric = ctx.measureText(t);
|
|
379
|
-
if (metric.width < w) {
|
|
380
|
-
return { t, o: true };
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
export {
|
|
386
|
-
camelize,
|
|
387
|
-
capitalize,
|
|
388
|
-
escape,
|
|
389
|
-
escapeChars,
|
|
390
|
-
escapeHtml,
|
|
391
|
-
fieldFormat,
|
|
392
|
-
fillChar,
|
|
393
|
-
format,
|
|
394
|
-
formatFileSize,
|
|
395
|
-
formatTypes,
|
|
396
|
-
getLength,
|
|
397
|
-
guid,
|
|
398
|
-
hyphenate,
|
|
399
|
-
isKorean,
|
|
400
|
-
isNullOrEmpty,
|
|
401
|
-
omitText,
|
|
402
|
-
random,
|
|
403
|
-
toBoolValue,
|
|
404
|
-
toCurrency,
|
|
405
|
-
toDecimal,
|
|
406
|
-
toFileSize,
|
|
407
|
-
toInt,
|
|
408
|
-
toJson,
|
|
409
|
-
toNumber,
|
|
410
|
-
toRate,
|
|
411
|
-
truncate,
|
|
412
|
-
tryToConvert,
|
|
413
|
-
tryToCurrency,
|
|
414
|
-
tryToDecimal,
|
|
415
|
-
tryToInt,
|
|
416
|
-
tryToNumber
|
|
417
|
-
};
|
package/common/type.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import "../chunk-G2ADBYYC.js";
|
|
2
|
-
const toString = Object.prototype.toString;
|
|
3
|
-
const hasOwn = Object.prototype.hasOwnProperty;
|
|
4
|
-
const getProto = Object.getPrototypeOf;
|
|
5
|
-
const fnToString = hasOwn.toString;
|
|
6
|
-
const ObjectFunctionString = fnToString.call(Object);
|
|
7
|
-
const class2type = {
|
|
8
|
-
"[object Error]": "error",
|
|
9
|
-
"[object Object]": "object",
|
|
10
|
-
"[object RegExp]": "regExp",
|
|
11
|
-
"[object Date]": "date",
|
|
12
|
-
"[object Array]": "array",
|
|
13
|
-
"[object Function]": "function",
|
|
14
|
-
"[object AsyncFunction]": "asyncFunction",
|
|
15
|
-
"[object String]": "string",
|
|
16
|
-
"[object Number]": "number",
|
|
17
|
-
"[object Boolean]": "boolean"
|
|
18
|
-
};
|
|
19
|
-
const isNull = (x) => x === null || x === void 0;
|
|
20
|
-
const typeOf = (obj) => isNull(obj) ? String(obj) : class2type[toString.call(obj)] || "object";
|
|
21
|
-
const isObject = (obj) => typeOf(obj) === "object";
|
|
22
|
-
const isFunction = (fn) => ["asyncFunction", "function"].includes(typeOf(fn));
|
|
23
|
-
const isPlainObject = (obj) => {
|
|
24
|
-
if (!obj || toString.call(obj) !== "[object Object]") {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
const proto = getProto(obj);
|
|
28
|
-
if (!proto) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
const Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
|
|
32
|
-
return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
|
|
33
|
-
};
|
|
34
|
-
const isEmptyObject = (obj) => {
|
|
35
|
-
const type = typeOf(obj);
|
|
36
|
-
if (type === "object" || type === "array") {
|
|
37
|
-
for (const name in obj) {
|
|
38
|
-
if (hasOwn.call(obj, name)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
45
|
-
const isNumber = (value) => typeof value === "number" && isFinite(value);
|
|
46
|
-
const isNumeric = (value) => value - parseFloat(value) >= 0;
|
|
47
|
-
const isDate = (value) => typeOf(value) === "date";
|
|
48
|
-
const isSame = (x, y) => x === y || typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y);
|
|
49
|
-
const isRegExp = (value) => typeOf(value) === "regExp";
|
|
50
|
-
const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
51
|
-
export {
|
|
52
|
-
hasOwn,
|
|
53
|
-
isDate,
|
|
54
|
-
isEmptyObject,
|
|
55
|
-
isFunction,
|
|
56
|
-
isNull,
|
|
57
|
-
isNumber,
|
|
58
|
-
isNumeric,
|
|
59
|
-
isObject,
|
|
60
|
-
isPlainObject,
|
|
61
|
-
isPromise,
|
|
62
|
-
isRegExp,
|
|
63
|
-
isSame,
|
|
64
|
-
toString,
|
|
65
|
-
typeOf
|
|
66
|
-
};
|
package/common/validate/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import "../../chunk-G2ADBYYC.js";
|
|
2
|
-
import Schema from "./schema";
|
|
3
|
-
import validators from "./validations/index";
|
|
4
|
-
import getDefaultMessage from "./messages";
|
|
5
|
-
Schema.validators = validators;
|
|
6
|
-
Schema.getDefaultMessage = getDefaultMessage;
|
|
7
|
-
var validate_default = Schema;
|
|
8
|
-
export {
|
|
9
|
-
validate_default as default
|
|
10
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import "../../chunk-G2ADBYYC.js";
|
|
2
|
-
const getTypesObj = (translate) => ({
|
|
3
|
-
string: translate("validation.types.string"),
|
|
4
|
-
method: translate("validation.types.method"),
|
|
5
|
-
array: translate("validation.types.array"),
|
|
6
|
-
object: translate("validation.types.object"),
|
|
7
|
-
number: translate("validation.types.number"),
|
|
8
|
-
date: translate("validation.types.date"),
|
|
9
|
-
boolean: translate("validation.types.boolean"),
|
|
10
|
-
integer: translate("validation.types.integer"),
|
|
11
|
-
float: translate("validation.types.float"),
|
|
12
|
-
regexp: translate("validation.types.regexp"),
|
|
13
|
-
email: translate("validation.types.email"),
|
|
14
|
-
url: translate("validation.types.url"),
|
|
15
|
-
hex: translate("validation.types.hex"),
|
|
16
|
-
digits: translate("validation.types.digits"),
|
|
17
|
-
time: translate("validation.types.time"),
|
|
18
|
-
dateYM: translate("validation.types.dateYM"),
|
|
19
|
-
dateYMD: translate("validation.types.dateYMD"),
|
|
20
|
-
dateTime: translate("validation.types.dateTime"),
|
|
21
|
-
longDateTime: translate("validation.types.longDateTime"),
|
|
22
|
-
version: translate("validation.types.version"),
|
|
23
|
-
speczh: translate("validation.types.speczh"),
|
|
24
|
-
specialch: translate("validation.types.specialch"),
|
|
25
|
-
specialch2: translate("validation.types.hex"),
|
|
26
|
-
acceptImg: translate("validation.types.acceptImg"),
|
|
27
|
-
acceptFile: translate("validation.types.acceptFile"),
|
|
28
|
-
fileSize: translate("validation.types.fileSize")
|
|
29
|
-
});
|
|
30
|
-
var messages_default = (translate = (value) => value) => ({
|
|
31
|
-
default: translate("validation.default"),
|
|
32
|
-
required: translate("validation.required"),
|
|
33
|
-
enum: translate("validation.enum"),
|
|
34
|
-
whitespace: translate("validation.whitespace"),
|
|
35
|
-
date: {
|
|
36
|
-
format: translate("validation.date.format"),
|
|
37
|
-
parse: translate("validation.date.parse"),
|
|
38
|
-
invalid: translate("validation.date.invalid")
|
|
39
|
-
},
|
|
40
|
-
types: getTypesObj(translate),
|
|
41
|
-
string: {
|
|
42
|
-
len: translate("validation.string.len"),
|
|
43
|
-
min: translate("validation.string.min"),
|
|
44
|
-
max: translate("validation.string.max"),
|
|
45
|
-
range: translate("validation.string.range")
|
|
46
|
-
},
|
|
47
|
-
number: {
|
|
48
|
-
len: translate("validation.number.len"),
|
|
49
|
-
min: translate("validation.number.min"),
|
|
50
|
-
max: translate("validation.number.max"),
|
|
51
|
-
range: translate("validation.number.range")
|
|
52
|
-
},
|
|
53
|
-
array: {
|
|
54
|
-
len: translate("validation.array.len"),
|
|
55
|
-
min: translate("validation.array.min"),
|
|
56
|
-
max: translate("validation.array.max"),
|
|
57
|
-
range: translate("validation.array.range")
|
|
58
|
-
},
|
|
59
|
-
pattern: {
|
|
60
|
-
mismatch: translate("validation.pattern.mismatch")
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
export {
|
|
64
|
-
messages_default as default
|
|
65
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import * as util from "../util";
|
|
3
|
-
const ENUM = "enum";
|
|
4
|
-
function enum_default(rule, checkValue, source, errors, options) {
|
|
5
|
-
rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];
|
|
6
|
-
if (!rule[ENUM].includes(checkValue)) {
|
|
7
|
-
errors.push(util.format(options.messages[ENUM], "", rule[ENUM].join(", ")));
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
enum_default as default
|
|
12
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import type from "./type";
|
|
3
|
-
import range from "./range";
|
|
4
|
-
import enumRule from "./enum";
|
|
5
|
-
import pattern from "./pattern";
|
|
6
|
-
import required from "./required";
|
|
7
|
-
import whitespace from "./whitespace";
|
|
8
|
-
var rules_default = {
|
|
9
|
-
type,
|
|
10
|
-
range,
|
|
11
|
-
pattern,
|
|
12
|
-
required,
|
|
13
|
-
whitespace,
|
|
14
|
-
enum: enumRule
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
rules_default as default
|
|
18
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import * as util from "../util";
|
|
3
|
-
function pattern_default(rule, checkValue, source, errors, options) {
|
|
4
|
-
if (rule.pattern) {
|
|
5
|
-
if (rule.pattern instanceof RegExp) {
|
|
6
|
-
rule.pattern.lastIndex = 0;
|
|
7
|
-
if (!rule.pattern.test(checkValue)) {
|
|
8
|
-
errors.push(util.format(options.messages.pattern.mismatch, "", checkValue, rule.pattern));
|
|
9
|
-
}
|
|
10
|
-
} else if (typeof rule.pattern === "string") {
|
|
11
|
-
const _pattern = new RegExp(rule.pattern);
|
|
12
|
-
if (!_pattern.test(checkValue)) {
|
|
13
|
-
errors.push(util.format(options.messages.pattern.mismatch, "", checkValue, rule.pattern));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
pattern_default as default
|
|
20
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import * as util from "../util";
|
|
3
|
-
import { isNumber } from "../../type";
|
|
4
|
-
import { getLength } from "../../string";
|
|
5
|
-
function getErro({ min, max, val, key, rule, errors, util: util2, options }) {
|
|
6
|
-
if (min && !max && val < rule.min) {
|
|
7
|
-
errors.push(util2.format(options.messages[key].min, "", rule.min));
|
|
8
|
-
} else if (max && !min && val > rule.max) {
|
|
9
|
-
errors.push(util2.format(options.messages[key].max, "", rule.max));
|
|
10
|
-
} else if (min && max && (val < rule.min || val > rule.max)) {
|
|
11
|
-
errors.push(util2.format(options.messages[key].range, "", rule.min, rule.max));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function range_default(rule, checkValue, source, errors, options) {
|
|
15
|
-
const len = isNumber(rule.len);
|
|
16
|
-
const min = isNumber(rule.min);
|
|
17
|
-
const max = isNumber(rule.max);
|
|
18
|
-
let val = checkValue;
|
|
19
|
-
let key = null;
|
|
20
|
-
const num = isNumber(Number(checkValue));
|
|
21
|
-
const str = typeof checkValue === "string";
|
|
22
|
-
const arr = Array.isArray(checkValue);
|
|
23
|
-
if (num) {
|
|
24
|
-
key = "number";
|
|
25
|
-
} else if (str) {
|
|
26
|
-
key = "string";
|
|
27
|
-
} else if (arr) {
|
|
28
|
-
key = "array";
|
|
29
|
-
}
|
|
30
|
-
if (!key) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (arr) {
|
|
34
|
-
val = checkValue.length;
|
|
35
|
-
}
|
|
36
|
-
if (str) {
|
|
37
|
-
val = getLength(checkValue, "string");
|
|
38
|
-
}
|
|
39
|
-
if (rule.type === "number") {
|
|
40
|
-
val = checkValue;
|
|
41
|
-
}
|
|
42
|
-
if (len) {
|
|
43
|
-
if (val !== rule.len) {
|
|
44
|
-
errors.push(util.format(options.messages[key].len, "", rule.len));
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
getErro({ min, max, val, key, rule, errors, util, options });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export {
|
|
51
|
-
range_default as default
|
|
52
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import * as util from "../util";
|
|
3
|
-
import { hasOwn } from "../../type";
|
|
4
|
-
function required_default({ rule, checkValue, source, errors, options, type }) {
|
|
5
|
-
if (rule.required && (!hasOwn.call(source, rule.field) || util.isEmptyValue(checkValue, type || rule.type))) {
|
|
6
|
-
errors.push(util.format(options.messages.required, ""));
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
required_default as default
|
|
11
|
-
};
|