@opentiny/vue-renderless 3.1.0-alpha.0 → 3.5.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/action-menu/index.js +10 -0
- package/action-menu/vue.js +26 -0
- package/amount/index.js +334 -0
- package/amount/vue.js +206 -0
- package/area/index.js +162 -0
- package/area/vue.js +68 -0
- package/autonavi-map/index.js +28 -0
- package/avatar/index.js +5 -1
- package/avatar/vue.js +2 -1
- package/baidu-map/index.js +28 -0
- package/breadcrumb/index.js +9 -0
- package/breadcrumb/vue.js +25 -3
- package/breadcrumb-item/index.js +26 -0
- package/breadcrumb-item/vue.js +20 -11
- package/bulletin-board/index.js +4 -1
- package/button-group/vue.js +1 -1
- package/calendar/index.js +14 -14
- package/card-template/index.js +1 -1
- package/cascader/index.js +21 -7
- package/cascader/vue.js +1 -2
- package/cascader-node/index.js +3 -1
- package/cascader-panel/index.js +12 -4
- package/cascader-panel/vue.js +1 -2
- package/chart-bar/index.js +533 -0
- package/chart-boxplot/index.js +270 -0
- package/chart-candle/index.js +428 -0
- package/chart-core/deps/constants.js +65 -0
- package/chart-core/deps/numerify.js +286 -0
- package/chart-core/deps/utils.js +205 -0
- package/chart-core/index.js +541 -0
- package/chart-core/modules/animation.js +10 -0
- package/chart-core/modules/extend.js +36 -0
- package/chart-core/modules/mark.js +7 -0
- package/chart-core/vue.js +128 -0
- package/chart-funnel/index.js +155 -0
- package/chart-gauge/index.js +153 -0
- package/chart-graph/index.js +38 -0
- package/chart-heatmap/index.js +407 -0
- package/chart-line/index.js +358 -0
- package/chart-liquidfill/index.js +119 -0
- package/chart-map/index.js +261 -0
- package/chart-pie/index.js +327 -0
- package/chart-radar/index.js +181 -0
- package/chart-sankey/index.js +166 -0
- package/chart-scatter/index.js +360 -0
- package/chart-sunburst/index.js +36 -0
- package/chart-tree/index.js +107 -0
- package/chart-waterfall/index.js +231 -0
- package/chart-wordcloud/index.js +109 -0
- package/checkbox/index.js +4 -4
- package/checkbox-button/index.js +3 -1
- package/common/bigInt.js +5 -2
- package/common/date.js +17 -17
- package/common/deps/date-util.js +15 -5
- package/common/deps/date.js +6 -6
- package/common/deps/dom.js +18 -6
- package/common/deps/eSpaceCtrl.js +286 -0
- package/common/deps/fullscreen/apis.js +22 -22
- package/common/deps/memorize.js +3 -3
- package/common/deps/modal-queue.js +2 -0
- package/common/deps/popper.js +12 -10
- package/common/deps/popup-manager.js +16 -5
- package/common/deps/resize-event.js +6 -2
- package/common/deps/scrollbar-width.js +6 -2
- package/common/deps/tree-model/node.js +30 -10
- package/common/deps/tree-model/tree-store.js +33 -21
- package/common/deps/tree-model/util.js +6 -2
- package/common/deps/upload-ajax.js +7 -1
- package/common/deps/vue-popper.js +2 -2
- package/common/string.js +1 -1
- package/company/index.js +56 -0
- package/company/vue.js +35 -0
- package/country/index.js +54 -0
- package/country/vue.js +35 -0
- package/credit-card-form/index.js +1 -0
- package/currency/index.js +78 -0
- package/currency/vue.js +39 -0
- package/date-panel/index.js +16 -6
- package/date-picker/index.js +9 -5
- package/date-range/index.js +28 -9
- package/date-table/index.js +3 -1
- package/dept/index.js +318 -0
- package/dept/vue.js +163 -0
- package/detail-page/index.js +4 -1
- package/dialog-box/index.js +14 -4
- package/dialog-box/vue.js +7 -3
- package/drop-roles/index.js +73 -0
- package/drop-roles/vue.js +38 -0
- package/dropdown/index.js +5 -4
- package/dropdown/vue.js +5 -3
- package/dropdown-item/index.js +15 -0
- package/dropdown-item/vue.js +27 -13
- package/espace/index.js +129 -0
- package/espace/vue.js +52 -0
- package/exception/index.js +1 -1
- package/file-upload/index.js +336 -291
- package/form/index.js +3 -1
- package/form/vue.js +15 -0
- package/form-item/index.js +15 -5
- package/fullscreen/index.js +4 -4
- package/fullscreen/vue.js +3 -3
- package/grid/core/interceptor.js +4 -7
- package/grid/plugins/export.js +2 -2
- package/grid/plugins/exportExcel.js +28 -10
- package/grid/static/array/findTree.js +1 -1
- package/grid/static/base/helperCreateGetObjects.js +1 -1
- package/grid/static/base/helperEqualCompare.js +2 -2
- package/grid/static/base/helperGetHGSKeys.js +1 -1
- package/grid/static/base/uniqueId.js +1 -1
- package/grid/static/object/assign.js +3 -3
- package/grid/static/string/toString.js +3 -3
- package/hrapprover/index.js +118 -0
- package/hrapprover/vue.js +102 -0
- package/locales/index.js +116 -0
- package/locales/vue.js +46 -0
- package/logon-user/index.js +23 -0
- package/logon-user/vue.js +22 -0
- package/logout/index.js +118 -0
- package/logout/vue.js +22 -0
- package/milestone/index.js +2 -1
- package/mini-picker/index.js +1 -1
- package/mini-picker/vue.js +1 -1
- package/modal/index.js +4 -2
- package/month-table/index.js +2 -2
- package/nav-menu/index.js +2 -2
- package/numeric/index.js +5 -2
- package/package.json +33 -136
- package/pager-item/vue.js +6 -2
- package/picker/index.js +43 -17
- package/picker/timezone.js +2 -2
- package/picker-column/index.js +7 -3
- package/pop-upload/index.js +5 -3
- package/popeditor/index.js +15 -7
- package/popover/index.js +87 -54
- package/popover/vue.js +13 -9
- package/rate/index.js +2 -2
- package/rich-text/clipboard.js +77 -0
- package/rich-text/index.js +176 -0
- package/rich-text/module/file-upload.js +118 -0
- package/rich-text/module/image-drop.js +54 -0
- package/rich-text/module/image-upload.js +84 -0
- package/rich-text/options.js +187 -0
- package/rich-text/table-module.js +557 -0
- package/rich-text/vue.js +149 -0
- package/roles/index.js +87 -0
- package/roles/vue.js +39 -0
- package/search/index.js +32 -27
- package/search/vue.js +7 -2
- package/select/index.js +328 -304
- package/select/vue.js +19 -9
- package/select-dropdown/index.js +1 -1
- package/slider/index.js +9 -11
- package/slider/vue.js +3 -3
- package/split/vue.js +1 -1
- package/tab-nav/index.js +0 -6
- package/tab-nav/vue.js +0 -14
- package/table/index.js +1 -1
- package/text-popup/index.js +6 -4
- package/time/index.js +3 -1
- package/time-range/index.js +6 -2
- package/time-spinner/index.js +15 -5
- package/toggle-menu/index.js +11 -0
- package/toggle-menu/vue.js +2 -1
- package/tooltip/index.js +46 -35
- package/tooltip/vue.js +5 -1
- package/tree/index.js +57 -21
- package/tree-menu/index.js +3 -1
- package/tree-node/index.js +7 -3
- package/upload/index.js +14 -5
- package/user/index.js +634 -0
- package/user/vue.js +113 -0
- package/user-account/index.js +23 -0
- package/user-account/vue.js +25 -0
- package/user-contact/index.js +1 -4
- package/user-head/index.js +33 -11
- package/user-head/vue.js +10 -7
- package/user-link/index.js +43 -0
- package/user-link/vue.js +60 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handleMoreClick, handleItemClick } from './index';
|
|
2
|
+
export var api = ['state', 'handleMoreClick', 'handleItemClick'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var computed = _ref.computed,
|
|
5
|
+
reactive = _ref.reactive;
|
|
6
|
+
var emit = _ref2.emit;
|
|
7
|
+
var api = {
|
|
8
|
+
handleMoreClick: handleMoreClick(emit),
|
|
9
|
+
handleItemClick: handleItemClick(emit)
|
|
10
|
+
};
|
|
11
|
+
var state = reactive({
|
|
12
|
+
visibleOptions: computed(function () {
|
|
13
|
+
return props.options.slice(0, props.maxShowNum);
|
|
14
|
+
}),
|
|
15
|
+
moreOptions: computed(function () {
|
|
16
|
+
return props.options.slice(props.maxShowNum);
|
|
17
|
+
}),
|
|
18
|
+
spacing: computed(function () {
|
|
19
|
+
return String(props.spacing).includes('px') ? props.spacing : props.spacing + 'px';
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
Object.assign(api, {
|
|
23
|
+
state: state
|
|
24
|
+
});
|
|
25
|
+
return api;
|
|
26
|
+
};
|
package/amount/index.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { on, off } from '@opentiny/vue-renderless/common/deps/dom';
|
|
5
|
+
import { formatNumber } from '@opentiny/vue-renderless/common/decimal';
|
|
6
|
+
import { getMiniDecimal, equalsDecimal } from '@opentiny/vue-renderless/common/bigInt';
|
|
7
|
+
import { isNumber } from '@opentiny/vue-renderless/common/type';
|
|
8
|
+
export var initService = function initService(service) {
|
|
9
|
+
var _ref = service || {},
|
|
10
|
+
_ref$utils = _ref.utils,
|
|
11
|
+
utils = _ref$utils === void 0 ? {} : _ref$utils;
|
|
12
|
+
var noopFn = function noopFn() {
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
getCurrencyPrecision: utils.getCurrencyPrecision || noopFn,
|
|
17
|
+
getNumberFormat: utils.getNumberFormat || noopFn
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export var getDecimal = function getDecimal(props) {
|
|
21
|
+
return function (value) {
|
|
22
|
+
return getMiniDecimal(value, props.plugin);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export var closePopper = function closePopper(state) {
|
|
26
|
+
return function () {
|
|
27
|
+
state.visible = false;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export var popInput = function popInput(_ref2) {
|
|
31
|
+
var editorState = _ref2.editorState,
|
|
32
|
+
props = _ref2.props,
|
|
33
|
+
state = _ref2.state,
|
|
34
|
+
api = _ref2.api;
|
|
35
|
+
return function (value) {
|
|
36
|
+
value = api.onInputPreprocess(value);
|
|
37
|
+
var _state$format = state.format,
|
|
38
|
+
fraction = _state$format.fraction,
|
|
39
|
+
groupSeparator = _state$format.groupSeparator;
|
|
40
|
+
value = value.replace(/^-+/, '-');
|
|
41
|
+
var groups = value.split(groupSeparator).map(function (val) {
|
|
42
|
+
return val.trim();
|
|
43
|
+
});
|
|
44
|
+
value = groups.join('');
|
|
45
|
+
if (value !== '-' && api.getDecimal(value).isNaN()) {
|
|
46
|
+
value = editorState.lastInput;
|
|
47
|
+
} else {
|
|
48
|
+
value = value.split('.').map(function (a, i) {
|
|
49
|
+
return i && props.strictInput && typeof fraction === 'number' ? a.substr(0, fraction) : a;
|
|
50
|
+
}).join('.');
|
|
51
|
+
}
|
|
52
|
+
editorState.lastInput = value;
|
|
53
|
+
editorState.amount = value;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export var toggleVisible = function toggleVisible(_ref3) {
|
|
57
|
+
var api = _ref3.api,
|
|
58
|
+
props = _ref3.props,
|
|
59
|
+
state = _ref3.state,
|
|
60
|
+
editorState = _ref3.editorState;
|
|
61
|
+
return function () {
|
|
62
|
+
if (props.disabled || !props.popUp) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
state.lock = true;
|
|
66
|
+
state.visible = !state.visible;
|
|
67
|
+
if (state.visible) {
|
|
68
|
+
var date = state.date,
|
|
69
|
+
currency = state.currency;
|
|
70
|
+
Object.assign(editorState, {
|
|
71
|
+
amount: state.amount,
|
|
72
|
+
date: date,
|
|
73
|
+
currency: currency
|
|
74
|
+
});
|
|
75
|
+
api.addOutSideEvent(state.visible);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export var innerFormat = function innerFormat(_ref4) {
|
|
80
|
+
var state = _ref4.state,
|
|
81
|
+
props = _ref4.props;
|
|
82
|
+
return function (value) {
|
|
83
|
+
var _state$format2 = state.format,
|
|
84
|
+
fraction = _state$format2.fraction,
|
|
85
|
+
zeroize = _state$format2.zeroize,
|
|
86
|
+
rounding = _state$format2.rounding;
|
|
87
|
+
var modelTruncation = props.modelTruncation;
|
|
88
|
+
var fractionLen = (value.split('.')[1] || '').length;
|
|
89
|
+
if (value === '-') {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
if (!modelTruncation && fractionLen > fraction) {
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
return formatNumber(value, {
|
|
96
|
+
fraction: fraction,
|
|
97
|
+
zeroize: zeroize,
|
|
98
|
+
groupSeparator: '',
|
|
99
|
+
decimalSeparator: '.',
|
|
100
|
+
rounding: rounding
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export var save = function save(_ref5) {
|
|
105
|
+
var api = _ref5.api,
|
|
106
|
+
state = _ref5.state,
|
|
107
|
+
editorState = _ref5.editorState;
|
|
108
|
+
return function () {
|
|
109
|
+
var amount = editorState.amount,
|
|
110
|
+
date = editorState.date,
|
|
111
|
+
currency = editorState.currency;
|
|
112
|
+
Object.assign(state, {
|
|
113
|
+
amount: amount,
|
|
114
|
+
date: date,
|
|
115
|
+
currency: currency
|
|
116
|
+
});
|
|
117
|
+
api.closePopper();
|
|
118
|
+
var num = api.innerFormat(String(state.amount));
|
|
119
|
+
state.amount = isNaN(num) ? 0 : num;
|
|
120
|
+
if (!equalsDecimal(state.lastInput, state.amount) || state.lastCurrency !== currency || state.lastDate !== date) {
|
|
121
|
+
api.emitChange();
|
|
122
|
+
}
|
|
123
|
+
state.lastInput = state.amount;
|
|
124
|
+
state.lastCurrency = currency;
|
|
125
|
+
state.lastDate = date;
|
|
126
|
+
api.initText();
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
export var reset = function reset(_ref6) {
|
|
130
|
+
var state = _ref6.state,
|
|
131
|
+
editorState = _ref6.editorState;
|
|
132
|
+
return function () {
|
|
133
|
+
var amount = state.amount,
|
|
134
|
+
date = state.date,
|
|
135
|
+
currency = state.currency;
|
|
136
|
+
Object.assign(editorState, {
|
|
137
|
+
amount: amount,
|
|
138
|
+
date: date,
|
|
139
|
+
currency: currency
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
export var emitChange = function emitChange(_ref7) {
|
|
144
|
+
var emit = _ref7.emit,
|
|
145
|
+
state = _ref7.state;
|
|
146
|
+
return function () {
|
|
147
|
+
var date = state.date,
|
|
148
|
+
currency = state.currency;
|
|
149
|
+
var emitAmount = Number(state.amount);
|
|
150
|
+
emit('update:modelValue', emitAmount);
|
|
151
|
+
emit('update:currency', currency);
|
|
152
|
+
emit('update:date', date);
|
|
153
|
+
emit('change', {
|
|
154
|
+
amount: emitAmount,
|
|
155
|
+
date: date,
|
|
156
|
+
currency: currency
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
export var inputFocus = function inputFocus(_ref8) {
|
|
161
|
+
var state = _ref8.state,
|
|
162
|
+
props = _ref8.props;
|
|
163
|
+
return function () {
|
|
164
|
+
var amount = String(state.amount);
|
|
165
|
+
state.isFocus = true;
|
|
166
|
+
state.lock = false;
|
|
167
|
+
var fraction = state.format.fraction;
|
|
168
|
+
var fractionLen = (amount.split('.')[1] || '').length;
|
|
169
|
+
if (fractionLen < fraction && props.holdZero) {
|
|
170
|
+
amount = formatNumber(amount, {
|
|
171
|
+
fraction: fraction
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
state.amountText = amount;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
export var inputBlur = function inputBlur(_ref9) {
|
|
178
|
+
var api = _ref9.api,
|
|
179
|
+
state = _ref9.state,
|
|
180
|
+
props = _ref9.props;
|
|
181
|
+
return function () {
|
|
182
|
+
if (state.amountText !== '') {
|
|
183
|
+
var amount = api.innerFormat(String(state.amountText));
|
|
184
|
+
if (isNaN(amount)) {
|
|
185
|
+
state.amount = '';
|
|
186
|
+
}
|
|
187
|
+
state.amount = props.holdZero ? amount : api.getDecimal(amount).toString();
|
|
188
|
+
}
|
|
189
|
+
state.isFocus = false;
|
|
190
|
+
state.amountText = formatNumber(state.amount, state.format);
|
|
191
|
+
if (!equalsDecimal(state.lastInput, state.amount)) {
|
|
192
|
+
api.emitChange();
|
|
193
|
+
}
|
|
194
|
+
state.lastInput = state.amount;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
export var handelClick = function handelClick(_ref10) {
|
|
198
|
+
var api = _ref10.api,
|
|
199
|
+
refs = _ref10.refs;
|
|
200
|
+
return function (e) {
|
|
201
|
+
var contains = refs.root.contains(e.target);
|
|
202
|
+
if (!contains) {
|
|
203
|
+
api.closePopper();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export var addOutSideEvent = function addOutSideEvent(api) {
|
|
208
|
+
return function (visible) {
|
|
209
|
+
if (visible) {
|
|
210
|
+
on(document, 'click', api.handelClick);
|
|
211
|
+
} else {
|
|
212
|
+
off(document, 'click', api.handelClick);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
export var initText = function initText(_ref11) {
|
|
217
|
+
var state = _ref11.state;
|
|
218
|
+
return function () {
|
|
219
|
+
var amount = String(state.amount);
|
|
220
|
+
state.amountText = amount ? state.isFocus ? amount : formatNumber(state.amount, state.format) : '';
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
export var onInputPreprocess = function onInputPreprocess(props) {
|
|
224
|
+
return function (value) {
|
|
225
|
+
var inputElem = event.target;
|
|
226
|
+
if (value) {
|
|
227
|
+
var i = value.lastIndexOf('-');
|
|
228
|
+
if (i === 0 && !props.negative || i > 0) {
|
|
229
|
+
var tmpArr = value.split('');
|
|
230
|
+
tmpArr.splice(i, 1);
|
|
231
|
+
inputElem.value = value = tmpArr.join('');
|
|
232
|
+
inputElem.selectionStart = inputElem.selectionEnd = i;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return value;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
export var onInput = function onInput(_ref12) {
|
|
239
|
+
var state = _ref12.state,
|
|
240
|
+
props = _ref12.props,
|
|
241
|
+
api = _ref12.api;
|
|
242
|
+
return function (value) {
|
|
243
|
+
value = api.onInputPreprocess(value);
|
|
244
|
+
var _state$format3 = state.format,
|
|
245
|
+
fraction = _state$format3.fraction,
|
|
246
|
+
groupSeparator = _state$format3.groupSeparator;
|
|
247
|
+
value = event.target.value.replace(/^-+/, '-');
|
|
248
|
+
var groups = value.split(groupSeparator).map(function (val) {
|
|
249
|
+
return val.trim();
|
|
250
|
+
});
|
|
251
|
+
value = groups.join('');
|
|
252
|
+
if (value !== '-' && api.getDecimal(value).isNaN()) {
|
|
253
|
+
value = state.lastInput;
|
|
254
|
+
} else {
|
|
255
|
+
value = value.split('.').map(function (a, i) {
|
|
256
|
+
return i && props.strictInput && typeof fraction === 'number' ? a.substr(0, fraction) : a;
|
|
257
|
+
}).join('.');
|
|
258
|
+
}
|
|
259
|
+
event.target.value = value;
|
|
260
|
+
state.amount = value;
|
|
261
|
+
state.amountText = value;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
export var getPrecision = function getPrecision(_ref13) {
|
|
265
|
+
var service = _ref13.service,
|
|
266
|
+
props = _ref13.props,
|
|
267
|
+
currency = _ref13.currency;
|
|
268
|
+
var _props$format = props.format,
|
|
269
|
+
format = _props$format === void 0 ? {} : _props$format,
|
|
270
|
+
r = props.rounding,
|
|
271
|
+
digits = props.digits,
|
|
272
|
+
type = props.type;
|
|
273
|
+
var fraction;
|
|
274
|
+
var rounding = format.rounding;
|
|
275
|
+
var getCurrencyPrecision = service.getCurrencyPrecision,
|
|
276
|
+
getNumberFormat = service.getNumberFormat;
|
|
277
|
+
var serFra = getCurrencyPrecision(type, currency) || {};
|
|
278
|
+
var serFmt = getNumberFormat() || {};
|
|
279
|
+
var defaultFmt = {
|
|
280
|
+
groupSeparator: ',',
|
|
281
|
+
groupSize: 3,
|
|
282
|
+
decimalSeparator: '.',
|
|
283
|
+
zeroize: props.holdZero
|
|
284
|
+
};
|
|
285
|
+
fraction = isNumber(format.fraction) ? format.fraction : isNumber(serFra.fraction) ? serFra.fraction : digits;
|
|
286
|
+
if (r === false) {
|
|
287
|
+
rounding = 0;
|
|
288
|
+
} else {
|
|
289
|
+
rounding = isNumber(rounding) ? rounding : isNumber(serFra.rounding) ? serFra.rounding : 5;
|
|
290
|
+
}
|
|
291
|
+
return _objectSpread(_objectSpread(_objectSpread({}, defaultFmt), {}, {
|
|
292
|
+
fraction: fraction,
|
|
293
|
+
rounding: rounding
|
|
294
|
+
}, serFmt), format);
|
|
295
|
+
};
|
|
296
|
+
export var getAmountText = function getAmountText(_ref14) {
|
|
297
|
+
var state = _ref14.state,
|
|
298
|
+
props = _ref14.props;
|
|
299
|
+
return function () {
|
|
300
|
+
return props.hideCurrency ? typeof state.amountText === 'string' ? state.amountText.replace(state.currency, '') : state.amountText : state.amountText;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
export var watchModelValue = function watchModelValue(_ref15) {
|
|
304
|
+
var api = _ref15.api,
|
|
305
|
+
state = _ref15.state;
|
|
306
|
+
return function () {
|
|
307
|
+
var value = api.initAmount();
|
|
308
|
+
state.amount = value;
|
|
309
|
+
state.lastInput = value;
|
|
310
|
+
api.initText();
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
export var watchCurrency = function watchCurrency(_ref16) {
|
|
314
|
+
var api = _ref16.api,
|
|
315
|
+
state = _ref16.state,
|
|
316
|
+
editorState = _ref16.editorState;
|
|
317
|
+
return function (value) {
|
|
318
|
+
state.currency = value;
|
|
319
|
+
editorState.currency = value;
|
|
320
|
+
state.lastCurrency = value;
|
|
321
|
+
api.initText();
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
export var initAmount = function initAmount(props) {
|
|
325
|
+
return function () {
|
|
326
|
+
var value = props.modelValue;
|
|
327
|
+
value = value === null || isNaN(Number(value)) ? '' : value;
|
|
328
|
+
if (!props.negative && value && Number(value) < 0) {
|
|
329
|
+
value -= 0;
|
|
330
|
+
value = Math.abs(value);
|
|
331
|
+
}
|
|
332
|
+
return value;
|
|
333
|
+
};
|
|
334
|
+
};
|
package/amount/vue.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { closePopper, popInput, save, reset, inputBlur, emitChange, inputFocus, toggleVisible, addOutSideEvent, handelClick, initText, onInput, getPrecision, getDecimal, innerFormat, getAmountText, initService, watchModelValue, watchCurrency, onInputPreprocess, initAmount } from './index';
|
|
5
|
+
export var api = ['t', 'popInput', 'state', 'editorState', 'save', 'reset', 'inputBlur', 'init', 'toggleVisible', 'inputFocus', 'closePopper', 'onInput', 'getAmountText'];
|
|
6
|
+
var initState = function initState(_ref) {
|
|
7
|
+
var reactive = _ref.reactive,
|
|
8
|
+
computed = _ref.computed,
|
|
9
|
+
props = _ref.props,
|
|
10
|
+
$service = _ref.$service,
|
|
11
|
+
editorState = _ref.editorState;
|
|
12
|
+
var state = reactive({
|
|
13
|
+
visible: false,
|
|
14
|
+
amount: props.modelValue || '',
|
|
15
|
+
currency: props.currency,
|
|
16
|
+
date: props.date,
|
|
17
|
+
overMaxLen: false,
|
|
18
|
+
isFocus: false,
|
|
19
|
+
lock: false,
|
|
20
|
+
amountText: '',
|
|
21
|
+
lastInput: props.modelValue,
|
|
22
|
+
lastCurrency: props.currency,
|
|
23
|
+
lastDate: props.date,
|
|
24
|
+
format: computed(function () {
|
|
25
|
+
return _objectSpread(_objectSpread({}, getPrecision({
|
|
26
|
+
service: $service,
|
|
27
|
+
props: props,
|
|
28
|
+
currency: editorState.currency
|
|
29
|
+
})), {}, {
|
|
30
|
+
prefix: state.currency
|
|
31
|
+
});
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
return state;
|
|
35
|
+
};
|
|
36
|
+
var initEditorState = function initEditorState(_ref2) {
|
|
37
|
+
var reactive = _ref2.reactive,
|
|
38
|
+
props = _ref2.props;
|
|
39
|
+
return reactive({
|
|
40
|
+
amount: '',
|
|
41
|
+
date: '',
|
|
42
|
+
currency: props.currency,
|
|
43
|
+
lastInput: props.modelValue
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var initApi = function initApi(_ref3) {
|
|
47
|
+
var api = _ref3.api,
|
|
48
|
+
t = _ref3.t,
|
|
49
|
+
editorState = _ref3.editorState,
|
|
50
|
+
props = _ref3.props,
|
|
51
|
+
state = _ref3.state,
|
|
52
|
+
emit = _ref3.emit,
|
|
53
|
+
refs = _ref3.refs;
|
|
54
|
+
Object.assign(api, {
|
|
55
|
+
state: state,
|
|
56
|
+
t: t,
|
|
57
|
+
editorState: editorState,
|
|
58
|
+
getDecimal: getDecimal(props),
|
|
59
|
+
innerFormat: innerFormat({
|
|
60
|
+
state: state,
|
|
61
|
+
props: props
|
|
62
|
+
}),
|
|
63
|
+
getAmountText: getAmountText({
|
|
64
|
+
state: state,
|
|
65
|
+
props: props
|
|
66
|
+
}),
|
|
67
|
+
initAmount: initAmount(props),
|
|
68
|
+
onInputPreprocess: onInputPreprocess(props),
|
|
69
|
+
onInput: onInput({
|
|
70
|
+
state: state,
|
|
71
|
+
props: props,
|
|
72
|
+
api: api
|
|
73
|
+
}),
|
|
74
|
+
initText: initText({
|
|
75
|
+
state: state
|
|
76
|
+
}),
|
|
77
|
+
inputFocus: inputFocus({
|
|
78
|
+
state: state,
|
|
79
|
+
props: props
|
|
80
|
+
}),
|
|
81
|
+
inputBlur: inputBlur({
|
|
82
|
+
api: api,
|
|
83
|
+
props: props,
|
|
84
|
+
state: state
|
|
85
|
+
}),
|
|
86
|
+
closePopper: closePopper(state),
|
|
87
|
+
emitChange: emitChange({
|
|
88
|
+
emit: emit,
|
|
89
|
+
state: state
|
|
90
|
+
}),
|
|
91
|
+
popInput: popInput({
|
|
92
|
+
editorState: editorState,
|
|
93
|
+
api: api,
|
|
94
|
+
state: state,
|
|
95
|
+
props: props
|
|
96
|
+
}),
|
|
97
|
+
save: save({
|
|
98
|
+
api: api,
|
|
99
|
+
state: state,
|
|
100
|
+
editorState: editorState,
|
|
101
|
+
props: props
|
|
102
|
+
}),
|
|
103
|
+
reset: reset({
|
|
104
|
+
api: api,
|
|
105
|
+
state: state,
|
|
106
|
+
editorState: editorState
|
|
107
|
+
}),
|
|
108
|
+
handelClick: handelClick({
|
|
109
|
+
api: api,
|
|
110
|
+
refs: refs
|
|
111
|
+
}),
|
|
112
|
+
addOutSideEvent: addOutSideEvent(api),
|
|
113
|
+
watchModelValue: watchModelValue({
|
|
114
|
+
api: api,
|
|
115
|
+
state: state
|
|
116
|
+
}),
|
|
117
|
+
watchCurrency: watchCurrency({
|
|
118
|
+
api: api,
|
|
119
|
+
state: state,
|
|
120
|
+
editorState: editorState
|
|
121
|
+
}),
|
|
122
|
+
toggleVisible: toggleVisible({
|
|
123
|
+
api: api,
|
|
124
|
+
props: props,
|
|
125
|
+
state: state,
|
|
126
|
+
editorState: editorState
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
var initWatch = function initWatch(_ref4) {
|
|
131
|
+
var watch = _ref4.watch,
|
|
132
|
+
props = _ref4.props,
|
|
133
|
+
state = _ref4.state,
|
|
134
|
+
api = _ref4.api;
|
|
135
|
+
watch(function () {
|
|
136
|
+
return props.modelValue;
|
|
137
|
+
}, api.watchModelValue, {
|
|
138
|
+
immediate: true
|
|
139
|
+
});
|
|
140
|
+
watch(function () {
|
|
141
|
+
return props.currency;
|
|
142
|
+
}, api.watchCurrency, {
|
|
143
|
+
immediate: true
|
|
144
|
+
});
|
|
145
|
+
watch(function () {
|
|
146
|
+
return props.date;
|
|
147
|
+
}, function (value) {
|
|
148
|
+
state.date = value;
|
|
149
|
+
state.lastDate = value;
|
|
150
|
+
}, {
|
|
151
|
+
immediate: true
|
|
152
|
+
});
|
|
153
|
+
watch(function () {
|
|
154
|
+
return props.rounding;
|
|
155
|
+
}, function (value) {
|
|
156
|
+
state.format.rounding = value;
|
|
157
|
+
});
|
|
158
|
+
watch(function () {
|
|
159
|
+
return props.digits;
|
|
160
|
+
}, function (value) {
|
|
161
|
+
state.format.fraction = value;
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
export var renderless = function renderless(props, _ref5, _ref6) {
|
|
165
|
+
var onUnmounted = _ref5.onUnmounted,
|
|
166
|
+
computed = _ref5.computed,
|
|
167
|
+
reactive = _ref5.reactive,
|
|
168
|
+
watch = _ref5.watch;
|
|
169
|
+
var t = _ref6.t,
|
|
170
|
+
emit = _ref6.emit,
|
|
171
|
+
refs = _ref6.refs,
|
|
172
|
+
service = _ref6.service;
|
|
173
|
+
var api = {};
|
|
174
|
+
var $service = initService(service);
|
|
175
|
+
var editorState = initEditorState({
|
|
176
|
+
reactive: reactive,
|
|
177
|
+
props: props
|
|
178
|
+
});
|
|
179
|
+
var state = initState({
|
|
180
|
+
reactive: reactive,
|
|
181
|
+
computed: computed,
|
|
182
|
+
props: props,
|
|
183
|
+
$service: $service,
|
|
184
|
+
editorState: editorState
|
|
185
|
+
});
|
|
186
|
+
initApi({
|
|
187
|
+
api: api,
|
|
188
|
+
t: t,
|
|
189
|
+
editorState: editorState,
|
|
190
|
+
props: props,
|
|
191
|
+
state: state,
|
|
192
|
+
emit: emit,
|
|
193
|
+
refs: refs
|
|
194
|
+
});
|
|
195
|
+
api.getDecimal(0);
|
|
196
|
+
initWatch({
|
|
197
|
+
watch: watch,
|
|
198
|
+
props: props,
|
|
199
|
+
state: state,
|
|
200
|
+
api: api
|
|
201
|
+
});
|
|
202
|
+
onUnmounted(function () {
|
|
203
|
+
return api.addOutSideEvent(false);
|
|
204
|
+
});
|
|
205
|
+
return api;
|
|
206
|
+
};
|