@opentiny/vue-renderless 3.6.0 → 3.6.1-alpha.2
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/README.md +7 -26
- package/action-menu/index.js +15 -15
- package/action-menu/vue.js +17 -22
- package/action-sheet/index.js +53 -68
- package/action-sheet/vue.js +28 -54
- package/alert/index.js +10 -21
- package/alert/vue.js +19 -33
- package/amount/index.js +205 -308
- package/amount/vue.js +113 -187
- package/anchor/index.js +102 -173
- package/anchor/vue.js +26 -47
- package/area/index.js +93 -153
- package/area/vue.js +26 -62
- package/autocomplete/index.js +115 -157
- package/autocomplete/vue.js +84 -159
- package/autonavi-map/index.js +12 -22
- package/avatar/index.js +28 -31
- package/avatar/vue.js +16 -19
- package/badge/index.js +11 -15
- package/badge/vue.js +19 -27
- package/baidu-map/index.js +12 -22
- package/breadcrumb/index.js +8 -7
- package/breadcrumb/vue.js +15 -22
- package/breadcrumb-item/index.js +14 -26
- package/breadcrumb-item/vue.js +20 -28
- package/bulletin-board/index.js +19 -22
- package/bulletin-board/vue.js +26 -33
- package/button/index.js +14 -18
- package/button/vue.js +26 -38
- package/button-group/index.js +19 -24
- package/button-group/vue.js +32 -45
- package/calendar/index.js +168 -203
- package/calendar/vue.js +89 -100
- package/card-template/index.js +29 -37
- package/card-template/vue.js +18 -30
- package/carousel/index.js +125 -198
- package/carousel/vue.js +132 -188
- package/carousel-item/index.js +55 -80
- package/carousel-item/vue.js +42 -42
- package/cascader/index.js +329 -460
- package/cascader/vue.js +159 -319
- package/cascader-menu/index.js +32 -39
- package/cascader-menu/vue.js +21 -30
- package/cascader-node/index.js +41 -60
- package/cascader-node/vue.js +27 -59
- package/cascader-panel/index.js +229 -311
- package/cascader-panel/node.js +118 -190
- package/cascader-panel/store.js +49 -76
- package/cascader-panel/vue.js +125 -197
- package/chart-bar/index.js +129 -439
- package/chart-boxplot/index.js +78 -219
- package/chart-candle/index.js +134 -379
- package/chart-core/deps/constants.js +70 -49
- package/chart-core/deps/numerify.js +106 -147
- package/chart-core/deps/utils.js +118 -121
- package/chart-core/index.js +302 -469
- package/chart-core/modules/animation.js +7 -5
- package/chart-core/modules/extend.js +18 -19
- package/chart-core/modules/mark.js +7 -3
- package/chart-core/vue.js +81 -120
- package/chart-funnel/index.js +47 -126
- package/chart-gauge/index.js +54 -128
- package/chart-graph/index.js +22 -35
- package/chart-heatmap/index.js +116 -362
- package/chart-line/index.js +98 -289
- package/chart-liquidfill/index.js +35 -100
- package/chart-map/index.js +64 -217
- package/chart-pie/index.js +93 -274
- package/chart-radar/index.js +59 -135
- package/chart-sankey/index.js +51 -137
- package/chart-scatter/index.js +118 -313
- package/chart-sunburst/index.js +25 -33
- package/chart-tree/index.js +43 -85
- package/chart-waterfall/index.js +77 -210
- package/chart-wordcloud/index.js +36 -85
- package/checkbox/index.js +82 -133
- package/checkbox/vue.js +62 -132
- package/checkbox-button/index.js +60 -96
- package/checkbox-button/vue.js +53 -135
- package/checkbox-group/index.js +6 -11
- package/checkbox-group/vue.js +22 -27
- package/chunk-PKUHTIDK.js +37 -0
- package/col/index.js +89 -119
- package/col/vue.js +21 -31
- package/collapse/index.js +31 -40
- package/collapse/vue.js +24 -32
- package/collapse-item/index.js +22 -36
- package/collapse-item/vue.js +22 -42
- package/common/array.js +51 -56
- package/common/bigInt.js +187 -243
- package/common/browser.js +35 -31
- package/common/dataset/index.js +74 -110
- package/common/date.js +199 -201
- package/common/decimal.js +94 -142
- package/common/deps/ResizeObserver.js +188 -208
- package/common/deps/after-leave.js +12 -10
- package/common/deps/clickoutside.js +32 -36
- package/common/deps/date-util.js +139 -166
- package/common/deps/date.js +206 -241
- package/common/deps/debounce.js +8 -4
- package/common/deps/dom.js +75 -68
- package/common/deps/eSpaceCtrl.js +170 -153
- package/common/deps/fullscreen/apis.js +51 -65
- package/common/deps/fullscreen/screenfull.js +61 -45
- package/common/deps/letter-only.js +12 -8
- package/common/deps/memorize.js +100 -125
- package/common/deps/modal-queue.js +6 -2
- package/common/deps/number-only.js +13 -9
- package/common/deps/popper.js +280 -372
- package/common/deps/popup-manager.js +71 -75
- package/common/deps/repeat-click.js +14 -10
- package/common/deps/requestAnimationFrame.js +13 -13
- package/common/deps/resize-event.js +15 -10
- package/common/deps/scroll-into-view.js +13 -13
- package/common/deps/scrollbar-width.js +22 -18
- package/common/deps/throttle.js +15 -11
- package/common/deps/touch.js +24 -22
- package/common/deps/tree-model/node.js +374 -524
- package/common/deps/tree-model/tree-store.js +251 -352
- package/common/deps/tree-model/util.js +10 -4
- package/common/deps/upload-ajax.js +28 -24
- package/common/deps/vue-emitter.js +15 -11
- package/common/deps/vue-popper.js +181 -214
- package/common/deps/vue-popup.js +118 -168
- package/common/event.js +10 -9
- package/common/index.js +180 -194
- package/common/object.js +92 -91
- package/common/runtime.js +78 -51
- package/common/string.js +194 -266
- package/common/type.js +49 -51
- package/common/validate/index.js +8 -4
- package/common/validate/messages.js +64 -67
- package/common/validate/rules/enum.js +10 -6
- package/common/validate/rules/index.js +18 -14
- package/common/validate/rules/pattern.js +9 -5
- package/common/validate/rules/range.js +26 -39
- package/common/validate/rules/required.js +8 -10
- package/common/validate/rules/type.js +67 -79
- package/common/validate/rules/whitespace.js +8 -4
- package/common/validate/schema.js +159 -199
- package/common/validate/util.js +95 -82
- package/common/validate/validations/array.js +14 -17
- package/common/validate/validations/date.js +16 -20
- package/common/validate/validations/enum.js +14 -16
- package/common/validate/validations/float.js +13 -15
- package/common/validate/validations/index.js +28 -24
- package/common/validate/validations/integer.js +13 -15
- package/common/validate/validations/method.js +13 -15
- package/common/validate/validations/number.js +15 -17
- package/common/validate/validations/pattern.js +14 -16
- package/common/validate/validations/required.js +10 -14
- package/common/validate/validations/string.js +19 -15
- package/common/validate/validations/type.js +17 -13
- package/common/xss.js +202 -184
- package/company/index.js +34 -49
- package/company/vue.js +23 -29
- package/container/index.js +72 -98
- package/container/vue.js +36 -61
- package/country/index.js +33 -47
- package/country/vue.js +24 -29
- package/credit-card/index.js +72 -86
- package/credit-card/vue.js +49 -104
- package/credit-card-form/index.js +97 -129
- package/credit-card-form/vue.js +102 -133
- package/crop/index.js +175 -294
- package/crop/vue.js +132 -144
- package/currency/index.js +49 -67
- package/currency/vue.js +25 -34
- package/date-panel/index.js +384 -524
- package/date-panel/vue.js +178 -289
- package/date-picker/index.js +198 -260
- package/date-picker/vue.js +97 -155
- package/date-range/index.js +324 -435
- package/date-range/vue.js +154 -273
- package/date-table/index.js +279 -391
- package/date-table/vue.js +63 -139
- package/dept/index.js +196 -291
- package/dept/vue.js +74 -144
- package/detail-page/index.js +72 -131
- package/detail-page/vue.js +53 -128
- package/dialog-box/index.js +178 -248
- package/dialog-box/vue.js +111 -201
- package/drop-roles/index.js +44 -65
- package/drop-roles/vue.js +23 -31
- package/drop-times/index.js +21 -22
- package/drop-times/vue.js +19 -23
- package/dropdown/index.js +182 -253
- package/dropdown/vue.js +55 -101
- package/dropdown-item/index.js +113 -167
- package/dropdown-item/vue.js +73 -121
- package/dropdown-menu/index.js +85 -111
- package/dropdown-menu/vue.js +23 -36
- package/espace/index.js +86 -106
- package/espace/vue.js +26 -48
- package/exception/index.js +9 -12
- package/exception/vue.js +15 -22
- package/fall-menu/index.js +81 -110
- package/fall-menu/vue.js +32 -78
- package/file-upload/index.js +1081 -1713
- package/file-upload/vue.js +175 -417
- package/floatbar/index.js +8 -5
- package/floatbar/vue.js +13 -16
- package/form/index.js +124 -165
- package/form/vue.js +54 -66
- package/form-item/index.js +255 -328
- package/form-item/vue.js +97 -198
- package/fullscreen/index.js +95 -127
- package/fullscreen/vue.js +36 -72
- package/grid/core/index.js +7 -3
- package/grid/core/interceptor.js +28 -20
- package/grid/core/storeMap.js +11 -7
- package/grid/plugins/export.js +72 -95
- package/grid/plugins/exportExcel.js +244 -561
- package/grid/plugins/header.js +22 -21
- package/grid/plugins/resize.js +45 -62
- package/grid/static/array/arrayEach.js +7 -3
- package/grid/static/array/arrayIndexOf.js +7 -3
- package/grid/static/array/eachTree.js +17 -21
- package/grid/static/array/every.js +6 -2
- package/grid/static/array/filterTree.js +17 -12
- package/grid/static/array/find.js +7 -3
- package/grid/static/array/findTree.js +19 -30
- package/grid/static/array/helperCreateIterateHandle.js +31 -39
- package/grid/static/array/helperCreateTreeFunc.js +18 -16
- package/grid/static/array/includes.js +6 -4
- package/grid/static/array/lastArrayEach.js +7 -3
- package/grid/static/array/map.js +11 -10
- package/grid/static/array/mapTree.js +19 -23
- package/grid/static/array/slice.js +7 -3
- package/grid/static/array/sortBy.js +32 -34
- package/grid/static/array/sum.js +14 -13
- package/grid/static/array/toArray.js +6 -6
- package/grid/static/array/toTreeArray.js +13 -15
- package/grid/static/base/clear.js +18 -14
- package/grid/static/base/clone.js +11 -17
- package/grid/static/base/destructuring.js +14 -10
- package/grid/static/base/each.js +8 -4
- package/grid/static/base/eqNull.js +7 -5
- package/grid/static/base/findIndexOf.js +8 -4
- package/grid/static/base/get.js +21 -17
- package/grid/static/base/has.js +21 -20
- package/grid/static/base/hasOwnProp.js +5 -3
- package/grid/static/base/helperCreateGetObjects.js +13 -9
- package/grid/static/base/helperCreateInInObjectString.js +8 -4
- package/grid/static/base/helperCreateInTypeof.js +8 -5
- package/grid/static/base/helperCreateIndexOf.js +19 -18
- package/grid/static/base/helperCreateiterateIndexOf.js +20 -19
- package/grid/static/base/helperDefaultCompare.js +5 -1
- package/grid/static/base/helperDeleteProperty.js +7 -3
- package/grid/static/base/helperEqualCompare.js +27 -29
- package/grid/static/base/helperGetHGSKeys.js +5 -3
- package/grid/static/base/indexOf.js +7 -3
- package/grid/static/base/isArray.js +7 -3
- package/grid/static/base/isBoolean.js +5 -3
- package/grid/static/base/isDate.js +7 -3
- package/grid/static/base/isEmpty.js +7 -3
- package/grid/static/base/isEqual.js +10 -10
- package/grid/static/base/isFunction.js +5 -3
- package/grid/static/base/isNaN.js +6 -4
- package/grid/static/base/isNull.js +5 -3
- package/grid/static/base/isNumber.js +5 -3
- package/grid/static/base/isObject.js +5 -4
- package/grid/static/base/isPlainObject.js +6 -2
- package/grid/static/base/isRegExp.js +7 -3
- package/grid/static/base/isSet.js +6 -4
- package/grid/static/base/isString.js +5 -3
- package/grid/static/base/isUndefined.js +5 -3
- package/grid/static/base/keys.js +7 -3
- package/grid/static/base/lastEach.js +8 -4
- package/grid/static/base/remove.js +20 -20
- package/grid/static/base/set.js +22 -18
- package/grid/static/base/toJSONString.js +5 -3
- package/grid/static/base/toStringJSON.js +10 -5
- package/grid/static/base/uniqueId.js +6 -4
- package/grid/static/browse/browse.js +25 -22
- package/grid/static/function/property.js +6 -6
- package/grid/static/function/throttle.js +18 -14
- package/grid/static/index.js +111 -55
- package/grid/static/number/helperCreateToNumber.js +12 -10
- package/grid/static/number/toNumber.js +7 -3
- package/grid/static/object/assign.js +20 -20
- package/grid/static/object/extend.js +7 -3
- package/grid/static/object/lastObjectEach.js +9 -5
- package/grid/static/object/objectEach.js +8 -4
- package/grid/static/object/objectMap.js +11 -7
- package/grid/static/object/values.js +15 -7
- package/grid/static/static/staticDocument.js +7 -4
- package/grid/static/static/staticHGKeyRE.js +6 -2
- package/grid/static/static/staticParseInt.js +6 -2
- package/grid/static/static/staticStrUndefined.js +6 -2
- package/grid/static/static/staticWindow.js +7 -4
- package/grid/static/string/template.js +10 -8
- package/grid/static/string/toString.js +12 -8
- package/grid/utils/column.js +11 -14
- package/grid/utils/common.js +84 -102
- package/grid/utils/dom.js +104 -117
- package/grid/utils/event.js +23 -28
- package/grid/utils/index.js +8 -5
- package/hrapprover/index.js +80 -105
- package/hrapprover/vue.js +45 -90
- package/image/index.js +107 -175
- package/image/vue.js +56 -126
- package/image-viewer/index.js +328 -416
- package/image-viewer/vue.js +131 -206
- package/index-bar/index.js +42 -51
- package/index-bar/vue.js +53 -74
- package/index-bar-anchor/vue.js +14 -18
- package/input/index.js +232 -302
- package/input/vue.js +181 -284
- package/ip-address/index.js +168 -335
- package/ip-address/vue.js +95 -160
- package/layout/vue.js +7 -4
- package/link/index.js +9 -10
- package/link/vue.js +15 -23
- package/link-menu/index.js +86 -128
- package/link-menu/vue.js +55 -118
- package/list/index.js +12 -12
- package/list/vue.js +15 -15
- package/loading/index.js +22 -21
- package/loading/vue.js +15 -18
- package/locales/index.js +72 -104
- package/locales/vue.js +23 -41
- package/logon-user/index.js +14 -19
- package/logon-user/vue.js +17 -20
- package/logout/index.js +58 -96
- package/logout/vue.js +15 -19
- package/milestone/index.js +53 -76
- package/milestone/vue.js +28 -26
- package/mini-picker/index.js +155 -219
- package/mini-picker/vue.js +98 -118
- package/modal/index.js +386 -735
- package/modal/vue.js +81 -117
- package/month-range/index.js +108 -143
- package/month-range/vue.js +57 -85
- package/month-table/index.js +157 -202
- package/month-table/vue.js +42 -64
- package/multi-select/index.js +150 -214
- package/multi-select/vue.js +58 -102
- package/nav-menu/index.js +276 -410
- package/nav-menu/vue.js +110 -174
- package/notify/index.js +59 -81
- package/notify/vue.js +42 -57
- package/numeric/index.js +231 -363
- package/numeric/vue.js +78 -202
- package/option/index.js +44 -72
- package/option/vue.js +66 -179
- package/option-group/index.js +12 -17
- package/option-group/vue.js +25 -30
- package/package.json +32 -84
- package/pager-item/index.js +91 -103
- package/pager-item/vue.js +36 -48
- package/panel/index.js +22 -28
- package/panel/vue.js +17 -23
- package/picker/index.js +689 -963
- package/picker/timezone.js +1174 -974
- package/picker/vue.js +187 -389
- package/picker-column/index.js +182 -232
- package/picker-column/vue.js +71 -130
- package/pop-upload/index.js +162 -321
- package/pop-upload/vue.js +143 -273
- package/popeditor/index.js +528 -807
- package/popeditor/vue.js +165 -334
- package/popover/index.js +160 -219
- package/popover/vue.js +76 -162
- package/popup/index.js +90 -128
- package/popup/vue.js +39 -112
- package/progress/index.js +108 -171
- package/progress/vue.js +65 -115
- package/pull-refresh/index.js +118 -132
- package/pull-refresh/vue.js +38 -66
- package/radio/index.js +41 -77
- package/radio/vue.js +35 -92
- package/radio-button/index.js +35 -54
- package/radio-button/vue.js +28 -61
- package/radio-group/index.js +46 -48
- package/radio-group/vue.js +26 -30
- package/rate/index.js +158 -197
- package/rate/vue.js +90 -138
- package/roles/index.js +48 -77
- package/roles/vue.js +20 -32
- package/row/index.js +15 -16
- package/row/vue.js +20 -19
- package/scroll-text/index.js +17 -22
- package/scroll-text/vue.js +18 -27
- package/scrollbar/index.js +87 -115
- package/scrollbar/vue-bar.js +23 -46
- package/scrollbar/vue.js +25 -33
- package/search/index.js +67 -95
- package/search/vue.js +80 -100
- package/select/index.js +1094 -1584
- package/select/vue.js +342 -672
- package/select-dropdown/index.js +18 -23
- package/select-dropdown/vue.js +56 -112
- package/slide-bar/index.js +58 -85
- package/slide-bar/vue.js +21 -47
- package/slider/index.js +276 -373
- package/slider/vue.js +94 -144
- package/split/index.js +74 -123
- package/split/vue.js +63 -116
- package/steps/vue.js +8 -3
- package/switch/index.js +35 -43
- package/switch/vue.js +32 -58
- package/tab-bar/index.js +48 -46
- package/tab-bar/vue.js +14 -12
- package/tab-dropdown/index.js +11 -10
- package/tab-dropdown/vue.js +14 -11
- package/tab-item/index.js +20 -35
- package/tab-item/vue.js +22 -42
- package/tab-nav/index.js +194 -227
- package/tab-nav/vue.js +62 -83
- package/tabbar/index.js +23 -30
- package/tabbar/vue.js +22 -45
- package/tabbar-item/index.js +39 -51
- package/tabbar-item/vue.js +23 -48
- package/table/index.js +69 -103
- package/table/vue.js +37 -61
- package/tabs/index.js +125 -174
- package/tabs/vue.js +98 -143
- package/tag/index.js +13 -18
- package/tag/vue.js +11 -16
- package/tall-storage/index.js +87 -106
- package/tall-storage/vue-storage-box.js +14 -20
- package/tall-storage/vue.js +27 -35
- package/text-popup/index.js +48 -70
- package/text-popup/vue.js +27 -60
- package/time/index.js +71 -113
- package/time/vue.js +65 -108
- package/time-line/index.js +30 -56
- package/time-line/vue.js +23 -46
- package/time-panel/index.js +112 -175
- package/time-panel/scrollIntoView.js +12 -10
- package/time-panel/vue.js +64 -94
- package/time-range/index.js +123 -184
- package/time-range/vue.js +63 -115
- package/time-spinner/index.js +139 -179
- package/time-spinner/vue.js +72 -110
- package/toggle-menu/index.js +68 -98
- package/toggle-menu/vue.js +64 -54
- package/tooltip/index.js +127 -168
- package/tooltip/vue.js +81 -134
- package/top-box/index.js +46 -79
- package/top-box/vue.js +34 -62
- package/transfer/index.js +184 -263
- package/transfer/vue.js +65 -134
- package/transfer-panel/index.js +240 -329
- package/transfer-panel/vue.js +127 -232
- package/tree/index.js +422 -591
- package/tree/vue.js +163 -249
- package/tree-menu/index.js +97 -122
- package/tree-menu/vue.js +57 -39
- package/tree-node/index.js +180 -248
- package/tree-node/vue.js +107 -202
- package/upload/index.js +201 -276
- package/upload/vue.js +51 -82
- package/upload-dragger/index.js +38 -49
- package/upload-dragger/vue.js +16 -24
- package/upload-list/index.js +41 -50
- package/upload-list/vue.js +21 -27
- package/user/index.js +356 -510
- package/user/vue.js +50 -97
- package/user-account/index.js +16 -21
- package/user-account/vue.js +20 -23
- package/user-contact/index.js +11 -10
- package/user-contact/vue.js +15 -15
- package/user-head/index.js +69 -84
- package/user-head/vue.js +24 -45
- package/user-link/index.js +31 -41
- package/user-link/vue.js +23 -46
- package/wheel/index.js +136 -161
- package/wheel/vue.js +64 -95
- package/wizard/index.js +83 -102
- package/wizard/vue.js +19 -34
- package/year-table/index.js +31 -37
- package/year-table/vue.js +17 -21
- package/rich-text/clipboard.js +0 -77
- package/rich-text/index.js +0 -176
- package/rich-text/module/file-upload.js +0 -118
- package/rich-text/module/image-drop.js +0 -54
- package/rich-text/module/image-upload.js +0 -84
- package/rich-text/options.js +0 -187
- package/rich-text/table-module.js +0 -557
- package/rich-text/vue.js +0 -149
package/common/string.js
CHANGED
|
@@ -1,58 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import { isPlainObject, isNumber, isNumeric, isNull } from "@opentiny/vue-renderless/common/type";
|
|
3
|
+
import { getObj, toJsonStr } from "@opentiny/vue-renderless/common/object";
|
|
4
|
+
import { toFixed } from "@opentiny/vue-renderless/common/decimal";
|
|
5
|
+
import { nanoid } from "@opentiny/vue-renderless/common/xss.js";
|
|
6
|
+
const formatTypes = {
|
|
7
|
+
text: "text",
|
|
8
|
+
url: "url",
|
|
9
|
+
html: "html",
|
|
10
|
+
tmpl: "tmpl"
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'"':
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
export var isNullOrEmpty = function isNullOrEmpty(value) {
|
|
21
|
-
return value === null || value === undefined || typeof value === 'string' && value.trim().length === 0;
|
|
12
|
+
const escapeChars = {
|
|
13
|
+
"&": "&",
|
|
14
|
+
"<": "<",
|
|
15
|
+
">": ">",
|
|
16
|
+
'"': """,
|
|
17
|
+
"'": "'",
|
|
18
|
+
"[": "[",
|
|
19
|
+
"]": "]"
|
|
22
20
|
};
|
|
21
|
+
const isNullOrEmpty = (value) => value === null || value === void 0 || typeof value === "string" && value.trim().length === 0;
|
|
23
22
|
function cached(fn) {
|
|
24
|
-
|
|
23
|
+
let cache = /* @__PURE__ */ Object.create(null);
|
|
25
24
|
return function cachedFn(str) {
|
|
26
|
-
|
|
25
|
+
const hit = cache[str];
|
|
27
26
|
return hit || (cache[str] = fn(str));
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export var capitalize = cached(function (str) {
|
|
37
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
38
|
-
});
|
|
39
|
-
var hyphenateRE = /\B([A-Z])/g;
|
|
40
|
-
export var hyphenate = cached(function (str) {
|
|
41
|
-
return str.replace(hyphenateRE, '-$1').toLowerCase();
|
|
42
|
-
});
|
|
43
|
-
export var toJson = function toJson(string) {
|
|
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) => {
|
|
44
35
|
try {
|
|
45
36
|
return JSON.parse(string);
|
|
46
37
|
} catch (e) {
|
|
47
|
-
return
|
|
38
|
+
return void 0;
|
|
48
39
|
}
|
|
49
40
|
};
|
|
50
41
|
function getLengthInUtf16(string) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (
|
|
54
|
-
|
|
55
|
-
if (charCode <=
|
|
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) {
|
|
56
47
|
count += 2;
|
|
57
48
|
} else {
|
|
58
49
|
count += 4;
|
|
@@ -61,15 +52,15 @@ function getLengthInUtf16(string) {
|
|
|
61
52
|
return count;
|
|
62
53
|
}
|
|
63
54
|
function getLengthInUtf8(string) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
for (
|
|
67
|
-
|
|
68
|
-
if (charCode <=
|
|
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) {
|
|
69
60
|
count += 1;
|
|
70
|
-
} else if (charCode <=
|
|
61
|
+
} else if (charCode <= 2047) {
|
|
71
62
|
count += 2;
|
|
72
|
-
} else if (charCode <=
|
|
63
|
+
} else if (charCode <= 65535) {
|
|
73
64
|
count += 3;
|
|
74
65
|
} else {
|
|
75
66
|
count += 4;
|
|
@@ -78,9 +69,9 @@ function getLengthInUtf8(string) {
|
|
|
78
69
|
return count;
|
|
79
70
|
}
|
|
80
71
|
function getLengthDefault(string) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
for (
|
|
72
|
+
const len = string.length;
|
|
73
|
+
let count = 0;
|
|
74
|
+
for (let i = 0; i < len; i++) {
|
|
84
75
|
count++;
|
|
85
76
|
if (string.charCodeAt(i) >> 8) {
|
|
86
77
|
count++;
|
|
@@ -88,167 +79,133 @@ function getLengthDefault(string) {
|
|
|
88
79
|
}
|
|
89
80
|
return count;
|
|
90
81
|
}
|
|
91
|
-
|
|
92
|
-
if (!string || typeof string !==
|
|
82
|
+
const getLength = (string, regular) => {
|
|
83
|
+
if (!string || typeof string !== "string") {
|
|
93
84
|
return 0;
|
|
94
85
|
}
|
|
95
|
-
|
|
96
|
-
if (typeof regular ===
|
|
86
|
+
let count = 0;
|
|
87
|
+
if (typeof regular === "string") {
|
|
97
88
|
regular = regular.toLowerCase();
|
|
98
|
-
if (regular ===
|
|
89
|
+
if (regular === "utf-16" || regular === "utf16") {
|
|
99
90
|
count = getLengthInUtf16(string);
|
|
100
|
-
} else if (regular ===
|
|
91
|
+
} else if (regular === "utf-8" || regular === "utf8") {
|
|
101
92
|
count = getLengthInUtf8(string);
|
|
102
93
|
} else {
|
|
103
|
-
count = string.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
|
|
94
|
+
count = string.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
|
|
104
95
|
}
|
|
105
|
-
} else if (typeof regular ===
|
|
96
|
+
} else if (typeof regular === "function") {
|
|
106
97
|
return regular(string);
|
|
107
98
|
} else {
|
|
108
99
|
count = getLengthDefault(string);
|
|
109
100
|
}
|
|
110
101
|
return count;
|
|
111
102
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var len = string.length - length;
|
|
103
|
+
const fillChar = (string, length, append, chr = "0") => {
|
|
104
|
+
if (typeof string === "string" && typeof chr === "string" && isNumber(length)) {
|
|
105
|
+
let len = string.length - length;
|
|
116
106
|
if (len > 0) {
|
|
117
107
|
return append ? string.substr(0, length) : string.substr(len, length);
|
|
118
108
|
} else {
|
|
119
|
-
|
|
109
|
+
const appendStr = [];
|
|
120
110
|
len = Math.abs(len) / chr.length;
|
|
121
111
|
for (; len > 0; len--) {
|
|
122
112
|
appendStr.push(chr);
|
|
123
113
|
}
|
|
124
|
-
|
|
114
|
+
const s = appendStr.join("");
|
|
125
115
|
return append ? string + s : s + string;
|
|
126
116
|
}
|
|
127
117
|
}
|
|
128
118
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return prefix + random().toString().substr(2, length);
|
|
134
|
-
};
|
|
135
|
-
export var escapeHtml = function escapeHtml(string, isReplaceSpace) {
|
|
136
|
-
if (!string || typeof string !== 'string') {
|
|
119
|
+
const random = nanoid.random;
|
|
120
|
+
const guid = (prefix = "", length = 8) => prefix + random().toString().substr(2, length);
|
|
121
|
+
const escapeHtml = (string, isReplaceSpace) => {
|
|
122
|
+
if (!string || typeof string !== "string") {
|
|
137
123
|
return string;
|
|
138
124
|
}
|
|
139
|
-
string = string.replace(/[&<>"']/g,
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
return isReplaceSpace ? string.replace(/\s/g, ' ') : string;
|
|
125
|
+
string = string.replace(/[&<>"']/g, (chr) => escapeChars[chr]);
|
|
126
|
+
return isReplaceSpace ? string.replace(/\s/g, " ") : string;
|
|
143
127
|
};
|
|
144
|
-
|
|
145
|
-
if (!string || typeof string !==
|
|
128
|
+
const escape = (string, escapeType, isReplaceSpace) => {
|
|
129
|
+
if (!string || typeof string !== "string") {
|
|
146
130
|
return string;
|
|
147
131
|
}
|
|
148
|
-
if (typeof escapeType ===
|
|
132
|
+
if (typeof escapeType === "boolean") {
|
|
149
133
|
isReplaceSpace = !!escapeType;
|
|
150
134
|
}
|
|
151
|
-
if (escapeType ===
|
|
135
|
+
if (escapeType === "uri") {
|
|
152
136
|
return encodeURIComponent(string);
|
|
153
|
-
} else if (escapeType ===
|
|
137
|
+
} else if (escapeType === "html") {
|
|
154
138
|
return escapeHtml(string, isReplaceSpace);
|
|
155
|
-
} else if (escapeType ===
|
|
139
|
+
} else if (escapeType === "prop") {
|
|
156
140
|
string = escapeHtml(string, isReplaceSpace);
|
|
157
|
-
return string.replace(/[[\]]/g,
|
|
158
|
-
return escapeChars[chr];
|
|
159
|
-
});
|
|
141
|
+
return string.replace(/[[\]]/g, (chr) => escapeChars[chr]);
|
|
160
142
|
}
|
|
161
|
-
string = string.replace(/[<>"]/g,
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
return isReplaceSpace ? string.replace(/\s/g, ' ') : string;
|
|
143
|
+
string = string.replace(/[<>"]/g, (chr) => escapeChars[chr]);
|
|
144
|
+
return isReplaceSpace ? string.replace(/\s/g, " ") : string;
|
|
165
145
|
};
|
|
166
|
-
|
|
167
|
-
var sign = _ref.sign,
|
|
168
|
-
format = _ref.format,
|
|
169
|
-
hasSign = _ref.hasSign;
|
|
146
|
+
const getFormat = ({ sign, format: format2, hasSign }) => {
|
|
170
147
|
switch (sign) {
|
|
171
|
-
case
|
|
172
|
-
|
|
148
|
+
case "#":
|
|
149
|
+
format2 = formatTypes.text;
|
|
173
150
|
break;
|
|
174
|
-
case
|
|
175
|
-
|
|
151
|
+
case "@":
|
|
152
|
+
format2 = formatTypes.url;
|
|
176
153
|
break;
|
|
177
|
-
case
|
|
178
|
-
|
|
154
|
+
case "$":
|
|
155
|
+
format2 = formatTypes.html;
|
|
179
156
|
break;
|
|
180
|
-
case
|
|
181
|
-
|
|
157
|
+
case "%":
|
|
158
|
+
format2 = formatTypes.tmpl;
|
|
182
159
|
break;
|
|
183
160
|
default:
|
|
184
161
|
hasSign = false;
|
|
185
162
|
break;
|
|
186
163
|
}
|
|
187
|
-
return {
|
|
188
|
-
format: format,
|
|
189
|
-
hasSign: hasSign
|
|
190
|
-
};
|
|
164
|
+
return { format: format2, hasSign };
|
|
191
165
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
var format = formatTypes.html;
|
|
201
|
-
var ret = getFormat({
|
|
202
|
-
sign: sign,
|
|
203
|
-
format: format,
|
|
204
|
-
hasSign: hasSign
|
|
205
|
-
});
|
|
206
|
-
format = ret.format;
|
|
166
|
+
const fieldFormat = (string, data, type = "html") => {
|
|
167
|
+
if (typeof string === "string") {
|
|
168
|
+
return string.replace(/(\/)?\{\{([\s\S]*?)}}/g, (match, slash = "", offset = "") => {
|
|
169
|
+
const sign = offset.substr(0, 1);
|
|
170
|
+
let hasSign = true;
|
|
171
|
+
let format2 = formatTypes.html;
|
|
172
|
+
let ret = getFormat({ sign, format: format2, hasSign });
|
|
173
|
+
format2 = ret.format;
|
|
207
174
|
hasSign = ret.hasSign;
|
|
208
175
|
if (hasSign) {
|
|
209
|
-
offset = (offset ||
|
|
176
|
+
offset = (offset || "").substring(1);
|
|
210
177
|
} else if (type) {
|
|
211
|
-
|
|
178
|
+
format2 = type;
|
|
212
179
|
}
|
|
213
|
-
|
|
180
|
+
let value = getObj(data, offset);
|
|
214
181
|
if (isNull(value)) {
|
|
215
|
-
value =
|
|
182
|
+
value = "";
|
|
216
183
|
}
|
|
217
|
-
if (
|
|
218
|
-
value =
|
|
184
|
+
if (format2 === formatTypes.tmpl) {
|
|
185
|
+
value = `{{${value}}}`;
|
|
219
186
|
} else {
|
|
220
|
-
if (
|
|
187
|
+
if (format2 === formatTypes.url) {
|
|
221
188
|
value = encodeURIComponent(value);
|
|
222
189
|
} else {
|
|
223
|
-
value =
|
|
190
|
+
value = format2 === formatTypes.html ? escapeHtml(value) : value;
|
|
224
191
|
}
|
|
225
192
|
}
|
|
226
|
-
return
|
|
193
|
+
return format2 === formatTypes.url && value.length === 0 ? "" : slash + value;
|
|
227
194
|
});
|
|
228
195
|
}
|
|
229
196
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
|
-
var getResult = function getResult(_ref2) {
|
|
246
|
-
var type = _ref2.type,
|
|
247
|
-
res = _ref2.res,
|
|
248
|
-
formatText = _ref2.formatText,
|
|
249
|
-
string = _ref2.string,
|
|
250
|
-
reg = _ref2.reg,
|
|
251
|
-
args = _ref2.args;
|
|
197
|
+
const getFormatText = () => (str, reg, args, format2) => str.replace(reg, (m, i, j, k) => {
|
|
198
|
+
if (!isNullOrEmpty(i) && !isNullOrEmpty(k)) {
|
|
199
|
+
return `{${j}}`;
|
|
200
|
+
}
|
|
201
|
+
const value = args[j];
|
|
202
|
+
const string = isPlainObject(value) ? toJsonStr(value) : value;
|
|
203
|
+
if (isNullOrEmpty(value)) {
|
|
204
|
+
return "";
|
|
205
|
+
}
|
|
206
|
+
return typeof value === "string" && typeof format2 === "function" ? format2(string) : string;
|
|
207
|
+
});
|
|
208
|
+
const getResult = ({ type, res, formatText, string, reg, args }) => {
|
|
252
209
|
if (type === formatTypes.url) {
|
|
253
210
|
res = formatText(string, reg, args, encodeURIComponent);
|
|
254
211
|
} else if (type === formatTypes.html) {
|
|
@@ -258,173 +215,115 @@ var getResult = function getResult(_ref2) {
|
|
|
258
215
|
}
|
|
259
216
|
return res;
|
|
260
217
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (lastArg !==
|
|
218
|
+
const judgForFunc = (args, formatTypes2, type) => {
|
|
219
|
+
const lastArg = args[args.length - 1];
|
|
220
|
+
if (lastArg !== formatTypes2.text && lastArg !== formatTypes2.url && lastArg !== formatTypes2.html) {
|
|
264
221
|
args = Array.prototype.slice.call(args, 1);
|
|
265
222
|
} else {
|
|
266
223
|
args = Array.prototype.slice.call(args, 1, args.length - 1);
|
|
267
224
|
type = lastArg;
|
|
268
225
|
}
|
|
269
|
-
return {
|
|
270
|
-
args: args,
|
|
271
|
-
type: type
|
|
272
|
-
};
|
|
226
|
+
return { args, type };
|
|
273
227
|
};
|
|
274
|
-
|
|
275
|
-
var data = _ref3.data,
|
|
276
|
-
args = _ref3.args,
|
|
277
|
-
type = _ref3.type,
|
|
278
|
-
_arguments = _ref3._arguments;
|
|
228
|
+
const checkParam = ({ data, args, type, _arguments }) => {
|
|
279
229
|
if (Array.isArray(data)) {
|
|
280
230
|
args = data;
|
|
281
231
|
} else {
|
|
282
|
-
|
|
232
|
+
const judgObj = judgForFunc(_arguments, formatTypes, type);
|
|
283
233
|
args = judgObj.args;
|
|
284
234
|
type = judgObj.type;
|
|
285
235
|
}
|
|
286
|
-
return {
|
|
287
|
-
args: args,
|
|
288
|
-
type: type
|
|
289
|
-
};
|
|
236
|
+
return { args, type };
|
|
290
237
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (typeof string !== 'string' || arguments.length < 2) {
|
|
238
|
+
const format = function(string, data, type = "text") {
|
|
239
|
+
if (typeof string !== "string" || arguments.length < 2) {
|
|
294
240
|
return string;
|
|
295
241
|
}
|
|
296
|
-
|
|
242
|
+
let args, res;
|
|
297
243
|
if (isPlainObject(data)) {
|
|
298
244
|
return fieldFormat(string, data, type);
|
|
299
245
|
}
|
|
300
|
-
|
|
301
|
-
data: data,
|
|
302
|
-
args: args,
|
|
303
|
-
type: type,
|
|
304
|
-
_arguments: arguments
|
|
305
|
-
});
|
|
246
|
+
const ret = checkParam({ data, args, type, _arguments: arguments });
|
|
306
247
|
args = ret.args;
|
|
307
248
|
type = ret.type;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
res = getResult({
|
|
311
|
-
type: type,
|
|
312
|
-
res: res,
|
|
313
|
-
formatText: formatText,
|
|
314
|
-
string: string,
|
|
315
|
-
reg: reg,
|
|
316
|
-
args: args
|
|
317
|
-
});
|
|
249
|
+
const reg = /(\\)?\{(\d+)(\\)?}/g;
|
|
250
|
+
const formatText = getFormatText();
|
|
251
|
+
res = getResult({ type, res, formatText, string, reg, args });
|
|
318
252
|
return res;
|
|
319
253
|
};
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
var flag = typeof string === 'string' && isNumber(length) && length < string.length;
|
|
325
|
-
var truthyValue = flag && format(ellipsis, string.substr(0, length));
|
|
326
|
-
return {
|
|
327
|
-
flag: flag,
|
|
328
|
-
truthyValue: truthyValue
|
|
329
|
-
};
|
|
254
|
+
const getTruthyValue = ({ string, length, ellipsis }) => {
|
|
255
|
+
const flag = typeof string === "string" && isNumber(length) && length < string.length;
|
|
256
|
+
const truthyValue = flag && format(ellipsis, string.substr(0, length));
|
|
257
|
+
return { flag, truthyValue };
|
|
330
258
|
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var _getTruthyValue = getTruthyValue({
|
|
334
|
-
string: string,
|
|
335
|
-
length: length,
|
|
336
|
-
ellipsis: ellipsis
|
|
337
|
-
}),
|
|
338
|
-
flag = _getTruthyValue.flag,
|
|
339
|
-
truthyValue = _getTruthyValue.truthyValue;
|
|
259
|
+
const truncate = (string, length, ellipsis = "{0}...") => {
|
|
260
|
+
const { flag, truthyValue } = getTruthyValue({ string, length, ellipsis });
|
|
340
261
|
return flag ? truthyValue : string;
|
|
341
262
|
};
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
args[_key - 2] = arguments[_key];
|
|
345
|
-
}
|
|
346
|
-
var result = convert.apply(null, args);
|
|
263
|
+
const tryToConvert = (convert, defaultValue, ...args) => {
|
|
264
|
+
const result = convert.apply(null, args);
|
|
347
265
|
return isNaN(result) ? defaultValue : result;
|
|
348
266
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
export var toNumber = function toNumber(value) {
|
|
356
|
-
return isNumber(value) ? value : typeof value === 'string' ? parseFloat(value) : NaN;
|
|
357
|
-
};
|
|
358
|
-
export var tryToNumber = function tryToNumber(value, defaultValue) {
|
|
359
|
-
return tryToConvert(toNumber, defaultValue, value);
|
|
360
|
-
};
|
|
361
|
-
export var toDecimal = function toDecimal(value) {
|
|
362
|
-
var fraction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
363
|
-
var isTruncate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
364
|
-
var result = NaN;
|
|
267
|
+
const toInt = (value) => isNumber(value) ? Number(value.toFixed(0)) : typeof value === "string" ? parseInt(value, 10) : NaN;
|
|
268
|
+
const tryToInt = (value, defaultValue) => tryToConvert(toInt, defaultValue, value);
|
|
269
|
+
const toNumber = (value) => isNumber(value) ? value : typeof value === "string" ? parseFloat(value) : NaN;
|
|
270
|
+
const tryToNumber = (value, defaultValue) => tryToConvert(toNumber, defaultValue, value);
|
|
271
|
+
const toDecimal = (value, fraction = 2, isTruncate = false) => {
|
|
272
|
+
let result = NaN;
|
|
365
273
|
if (isNumber(value)) {
|
|
366
274
|
result = value;
|
|
367
275
|
}
|
|
368
|
-
if (typeof value ===
|
|
369
|
-
|
|
276
|
+
if (typeof value === "string") {
|
|
277
|
+
const val = parseFloat(value);
|
|
370
278
|
if (!isNaN(val)) {
|
|
371
279
|
result = val;
|
|
372
280
|
}
|
|
373
281
|
}
|
|
374
282
|
if (isNumber(result)) {
|
|
375
283
|
if (isTruncate) {
|
|
376
|
-
result = toFixed(
|
|
377
|
-
|
|
378
|
-
|
|
284
|
+
result = toFixed(
|
|
285
|
+
value.toString().split(".").slice(0, 2).map((str, index) => index ? str.slice(0, fraction) : str).join("."),
|
|
286
|
+
fraction
|
|
287
|
+
);
|
|
379
288
|
} else {
|
|
380
289
|
result = toFixed(result, fraction);
|
|
381
290
|
}
|
|
382
291
|
}
|
|
383
292
|
return result;
|
|
384
293
|
};
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
};
|
|
388
|
-
export var toCurrency = function toCurrency(value, fraction, placeholder, isTruncate) {
|
|
294
|
+
const tryToDecimal = (value, fraction, isTruncate, defaultValue) => tryToConvert(toDecimal, defaultValue, value, fraction, isTruncate);
|
|
295
|
+
const toCurrency = (value, fraction, placeholder, isTruncate) => {
|
|
389
296
|
if (isNumeric(value)) {
|
|
390
|
-
|
|
391
|
-
val = String(val).replace(/(^|[^\w.])(\d{4,})/g,
|
|
392
|
-
return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, '$&,');
|
|
393
|
-
});
|
|
297
|
+
let val = toDecimal(Number(value), fraction, isTruncate);
|
|
298
|
+
val = String(val).replace(/(^|[^\w.])(\d{4,})/g, ($0, $1, $2) => $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,"));
|
|
394
299
|
return placeholder ? format(placeholder, val) : val;
|
|
395
300
|
}
|
|
396
301
|
return NaN;
|
|
397
302
|
};
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
};
|
|
401
|
-
export var toBoolValue = function toBoolValue(value) {
|
|
303
|
+
const tryToCurrency = (value, fraction, placeholder, defaultValue) => isNaN(toNumber(value)) ? defaultValue : toCurrency(value, fraction, placeholder);
|
|
304
|
+
const toBoolValue = (value) => {
|
|
402
305
|
if (isNumber(value)) {
|
|
403
306
|
return value ? 1 : 0;
|
|
404
|
-
} else if (isNull(value) || value ===
|
|
307
|
+
} else if (isNull(value) || value === "false") {
|
|
405
308
|
return false;
|
|
406
|
-
} else if (value ===
|
|
309
|
+
} else if (value === "true") {
|
|
407
310
|
return true;
|
|
408
|
-
} else if (typeof value ===
|
|
311
|
+
} else if (typeof value === "boolean") {
|
|
409
312
|
return value;
|
|
410
313
|
}
|
|
411
314
|
return !!value;
|
|
412
315
|
};
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
var fraction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
416
|
-
return isNumber(value) && isNumber(total) ? "".concat(toDecimal(value * 100 / total, fraction), "%") : value;
|
|
417
|
-
};
|
|
418
|
-
export var toFileSize = function toFileSize(value, unit, currUnit) {
|
|
316
|
+
const toRate = (value, total = 1, fraction = 2) => isNumber(value) && isNumber(total) ? `${toDecimal(value * 100 / total, fraction)}%` : value;
|
|
317
|
+
const toFileSize = (value, unit, currUnit) => {
|
|
419
318
|
if (isNumeric(value)) {
|
|
420
319
|
value = Number(value);
|
|
421
320
|
if (value === 0) {
|
|
422
|
-
return
|
|
321
|
+
return `0${currUnit || unit || "B"}`;
|
|
423
322
|
}
|
|
424
|
-
|
|
425
|
-
|
|
323
|
+
const fileSize = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
324
|
+
let index = fileSize.indexOf(currUnit);
|
|
426
325
|
if (index > -1) {
|
|
427
|
-
for (
|
|
326
|
+
for (let i = 0; i < index; i++) {
|
|
428
327
|
value *= 1024;
|
|
429
328
|
}
|
|
430
329
|
}
|
|
@@ -432,15 +331,44 @@ export var toFileSize = function toFileSize(value, unit, currUnit) {
|
|
|
432
331
|
if (index < 0) {
|
|
433
332
|
index = fileSize.length - 1;
|
|
434
333
|
}
|
|
435
|
-
|
|
436
|
-
for (
|
|
437
|
-
value /= 1024
|
|
334
|
+
let level = 0;
|
|
335
|
+
for (let i = 0; i < index && (value <= -1024 || value >= 1024); i++) {
|
|
336
|
+
value /= 1024;
|
|
438
337
|
level++;
|
|
439
338
|
}
|
|
440
339
|
return toDecimal(value, 2) + fileSize[level];
|
|
441
340
|
}
|
|
442
341
|
return value;
|
|
443
342
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
343
|
+
const isKorean = (text) => /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi.test(text);
|
|
344
|
+
export {
|
|
345
|
+
camelize,
|
|
346
|
+
capitalize,
|
|
347
|
+
escape,
|
|
348
|
+
escapeChars,
|
|
349
|
+
escapeHtml,
|
|
350
|
+
fieldFormat,
|
|
351
|
+
fillChar,
|
|
352
|
+
format,
|
|
353
|
+
formatTypes,
|
|
354
|
+
getLength,
|
|
355
|
+
guid,
|
|
356
|
+
hyphenate,
|
|
357
|
+
isKorean,
|
|
358
|
+
isNullOrEmpty,
|
|
359
|
+
random,
|
|
360
|
+
toBoolValue,
|
|
361
|
+
toCurrency,
|
|
362
|
+
toDecimal,
|
|
363
|
+
toFileSize,
|
|
364
|
+
toInt,
|
|
365
|
+
toJson,
|
|
366
|
+
toNumber,
|
|
367
|
+
toRate,
|
|
368
|
+
truncate,
|
|
369
|
+
tryToConvert,
|
|
370
|
+
tryToCurrency,
|
|
371
|
+
tryToDecimal,
|
|
372
|
+
tryToInt,
|
|
373
|
+
tryToNumber
|
|
374
|
+
};
|