amis-core 6.4.0 → 6.4.1
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/esm/Root.js +1 -1
- package/esm/RootRenderer.js +1 -1
- package/esm/SchemaRenderer.js +1 -1
- package/esm/Scoped.js +1 -1
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.js +1 -1
- package/esm/actions/AjaxAction.js +1 -1
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +1 -1
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +1 -1
- package/esm/actions/DialogAction.js +1 -1
- package/esm/actions/DrawerAction.js +1 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/EventAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/PrintAction.js +1 -1
- package/esm/actions/StatusAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/WaitAction.js +1 -1
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/ErrorBoundary.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.js +1 -1
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +1 -1
- package/esm/index.js +2 -2
- package/esm/locale.js +1 -1
- package/esm/node_modules/@babel/runtime/helpers/esm/classCallCheck.js +12 -0
- package/esm/node_modules/@babel/runtime/helpers/esm/createClass.js +26 -0
- package/esm/node_modules/@babel/runtime/helpers/esm/defineProperty.js +23 -0
- package/esm/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +19 -0
- package/esm/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +14 -0
- package/esm/node_modules/@babel/runtime/helpers/esm/typeof.js +16 -0
- package/esm/node_modules/@rc-component/mini-decimal/es/BigIntDecimal.js +184 -0
- package/esm/node_modules/@rc-component/mini-decimal/es/MiniDecimal.js +56 -0
- package/esm/node_modules/@rc-component/mini-decimal/es/NumberDecimal.js +119 -0
- package/esm/node_modules/@rc-component/mini-decimal/es/numberUtil.js +105 -0
- package/esm/node_modules/@rc-component/mini-decimal/es/supportUtil.js +10 -0
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.js +1 -1
- package/esm/renderers/Item.js +1 -1
- package/esm/renderers/Options.js +1 -1
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.js +1 -1
- package/esm/store/app.js +1 -1
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.js +1 -1
- package/esm/store/form.js +1 -1
- package/esm/store/formItem.js +1 -1
- package/esm/store/iRenderer.js +1 -1
- package/esm/store/index.js +1 -1
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.js +1 -1
- package/esm/store/service.js +1 -1
- package/esm/store/status.js +1 -1
- package/esm/store/table.js +1 -1
- package/esm/store/table2.js +1 -1
- package/esm/theme.js +1 -1
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +1 -1
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/browser.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/concatData.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.js +1 -1
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +1 -1
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.js +1 -1
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/labelToString.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.js +1 -1
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.js +1 -1
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/printElement.js +1 -1
- package/esm/utils/renderer-event.js +1 -1
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +5 -2
- package/esm/utils/style-helper.js +1 -1
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validateId.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +1 -1
- package/lib/SchemaRenderer.js +1 -1
- package/lib/Scoped.js +1 -1
- package/lib/StatusScoped.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +1 -1
- package/lib/actions/Action.js +1 -1
- package/lib/actions/AjaxAction.js +1 -1
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +1 -1
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +1 -1
- package/lib/actions/DialogAction.js +1 -1
- package/lib/actions/DrawerAction.js +1 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/EventAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/PrintAction.js +1 -1
- package/lib/actions/StatusAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/WaitAction.js +1 -1
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/ErrorBoundary.js +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.js +1 -1
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +1 -1
- package/lib/index.js +2 -2
- package/lib/locale.js +1 -1
- package/lib/node_modules/@babel/runtime/helpers/esm/classCallCheck.js +16 -0
- package/lib/node_modules/@babel/runtime/helpers/esm/createClass.js +30 -0
- package/lib/node_modules/@babel/runtime/helpers/esm/defineProperty.js +27 -0
- package/lib/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +23 -0
- package/lib/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +18 -0
- package/lib/node_modules/@babel/runtime/helpers/esm/typeof.js +20 -0
- package/lib/node_modules/@rc-component/mini-decimal/es/BigIntDecimal.js +188 -0
- package/lib/node_modules/@rc-component/mini-decimal/es/MiniDecimal.js +61 -0
- package/lib/node_modules/@rc-component/mini-decimal/es/NumberDecimal.js +123 -0
- package/lib/node_modules/@rc-component/mini-decimal/es/numberUtil.js +114 -0
- package/lib/node_modules/@rc-component/mini-decimal/es/supportUtil.js +14 -0
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.js +1 -1
- package/lib/renderers/Item.js +1 -1
- package/lib/renderers/Options.js +1 -1
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.js +1 -1
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +25 -24
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.js +1 -1
- package/lib/store/form.d.ts +11 -10
- package/lib/store/form.js +1 -1
- package/lib/store/formItem.js +1 -1
- package/lib/store/iRenderer.js +1 -1
- package/lib/store/index.js +1 -1
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.js +1 -1
- package/lib/store/service.js +1 -1
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +21 -20
- package/lib/store/table.js +1 -1
- package/lib/store/table2.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +1 -1
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/browser.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/concatData.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.js +1 -1
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +1 -1
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.js +1 -1
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.js +1 -1
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/labelToString.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.js +1 -1
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/printElement.js +1 -1
- package/lib/utils/renderer-event.js +1 -1
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +5 -2
- package/lib/utils/style-helper.js +1 -1
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validateId.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +2 -2
package/esm/Root.js
CHANGED
package/esm/RootRenderer.js
CHANGED
package/esm/SchemaRenderer.js
CHANGED
package/esm/Scoped.js
CHANGED
package/esm/StatusScoped.js
CHANGED
package/esm/WithRootStore.js
CHANGED
package/esm/WithStore.js
CHANGED
package/esm/actions/Action.js
CHANGED
package/esm/env.js
CHANGED
package/esm/envOverwrite.js
CHANGED
package/esm/factory.js
CHANGED
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.4.
|
|
2
|
+
* amis-core v6.4.1
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -148,7 +148,7 @@ export { StoreNode } from './store/node.js';
|
|
|
148
148
|
*/
|
|
149
149
|
var classPrefix = getClassPrefix();
|
|
150
150
|
// @ts-ignore
|
|
151
|
-
var version = '6.4.
|
|
151
|
+
var version = '6.4.1';
|
|
152
152
|
function render(schema, props, options, pathPrefix) {
|
|
153
153
|
if (props === void 0) { props = {}; }
|
|
154
154
|
if (options === void 0) { options = {}; }
|
package/esm/locale.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.4.1
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
function _classCallCheck(instance, Constructor) {
|
|
7
|
+
if (!(instance instanceof Constructor)) {
|
|
8
|
+
throw new TypeError("Cannot call a class as a function");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { _classCallCheck as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.4.1
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import toPropertyKey from './toPropertyKey.js';
|
|
7
|
+
|
|
8
|
+
function _defineProperties(target, props) {
|
|
9
|
+
for (var i = 0; i < props.length; i++) {
|
|
10
|
+
var descriptor = props[i];
|
|
11
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
12
|
+
descriptor.configurable = true;
|
|
13
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
14
|
+
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
18
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
19
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
20
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
21
|
+
writable: false
|
|
22
|
+
});
|
|
23
|
+
return Constructor;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { _createClass as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.4.1
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import toPropertyKey from './toPropertyKey.js';
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) {
|
|
9
|
+
key = toPropertyKey(key);
|
|
10
|
+
if (key in obj) {
|
|
11
|
+
Object.defineProperty(obj, key, {
|
|
12
|
+
value: value,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
obj[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { _defineProperty as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.4.1
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import _typeof from './typeof.js';
|
|
7
|
+
|
|
8
|
+
function toPrimitive(t, r) {
|
|
9
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
10
|
+
var e = t[Symbol.toPrimitive];
|
|
11
|
+
if (void 0 !== e) {
|
|
12
|
+
var i = e.call(t, r || "default");
|
|
13
|
+
if ("object" != _typeof(i)) return i;
|
|
14
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
15
|
+
}
|
|
16
|
+
return ("string" === r ? String : Number)(t);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { toPrimitive as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.4.1
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import _typeof from './typeof.js';
|
|
7
|
+
import toPrimitive from './toPrimitive.js';
|
|
8
|
+
|
|
9
|
+
function toPropertyKey(t) {
|
|
10
|
+
var i = toPrimitive(t, "string");
|
|
11
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { toPropertyKey as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.4.1
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
function _typeof(o) {
|
|
7
|
+
"@babel/helpers - typeof";
|
|
8
|
+
|
|
9
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
10
|
+
return typeof o;
|
|
11
|
+
} : function (o) {
|
|
12
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
13
|
+
}, _typeof(o);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { _typeof as default };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* amis-core v6.4.1
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import _classCallCheck from '../../../@babel/runtime/helpers/esm/classCallCheck.js';
|
|
7
|
+
import _createClass from '../../../@babel/runtime/helpers/esm/createClass.js';
|
|
8
|
+
import _defineProperty from '../../../@babel/runtime/helpers/esm/defineProperty.js';
|
|
9
|
+
import { trimNumber, isEmpty, isE, num2str, validateNumber } from './numberUtil.js';
|
|
10
|
+
|
|
11
|
+
var BigIntDecimal = /*#__PURE__*/function () {
|
|
12
|
+
/** BigInt will convert `0009` to `9`. We need record the len of decimal */
|
|
13
|
+
|
|
14
|
+
function BigIntDecimal(value) {
|
|
15
|
+
_classCallCheck(this, BigIntDecimal);
|
|
16
|
+
_defineProperty(this, "origin", '');
|
|
17
|
+
_defineProperty(this, "negative", void 0);
|
|
18
|
+
_defineProperty(this, "integer", void 0);
|
|
19
|
+
_defineProperty(this, "decimal", void 0);
|
|
20
|
+
_defineProperty(this, "decimalLen", void 0);
|
|
21
|
+
_defineProperty(this, "empty", void 0);
|
|
22
|
+
_defineProperty(this, "nan", void 0);
|
|
23
|
+
if (isEmpty(value)) {
|
|
24
|
+
this.empty = true;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.origin = String(value);
|
|
28
|
+
|
|
29
|
+
// Act like Number convert
|
|
30
|
+
if (value === '-' || Number.isNaN(value)) {
|
|
31
|
+
this.nan = true;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var mergedValue = value;
|
|
35
|
+
|
|
36
|
+
// We need convert back to Number since it require `toFixed` to handle this
|
|
37
|
+
if (isE(mergedValue)) {
|
|
38
|
+
mergedValue = Number(mergedValue);
|
|
39
|
+
}
|
|
40
|
+
mergedValue = typeof mergedValue === 'string' ? mergedValue : num2str(mergedValue);
|
|
41
|
+
if (validateNumber(mergedValue)) {
|
|
42
|
+
var trimRet = trimNumber(mergedValue);
|
|
43
|
+
this.negative = trimRet.negative;
|
|
44
|
+
var numbers = trimRet.trimStr.split('.');
|
|
45
|
+
this.integer = BigInt(numbers[0]);
|
|
46
|
+
var decimalStr = numbers[1] || '0';
|
|
47
|
+
this.decimal = BigInt(decimalStr);
|
|
48
|
+
this.decimalLen = decimalStr.length;
|
|
49
|
+
} else {
|
|
50
|
+
this.nan = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_createClass(BigIntDecimal, [{
|
|
54
|
+
key: "getMark",
|
|
55
|
+
value: function getMark() {
|
|
56
|
+
return this.negative ? '-' : '';
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "getIntegerStr",
|
|
60
|
+
value: function getIntegerStr() {
|
|
61
|
+
return this.integer.toString();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @private get decimal string
|
|
66
|
+
*/
|
|
67
|
+
}, {
|
|
68
|
+
key: "getDecimalStr",
|
|
69
|
+
value: function getDecimalStr() {
|
|
70
|
+
return this.decimal.toString().padStart(this.decimalLen, '0');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @private Align BigIntDecimal with same decimal length. e.g. 12.3 + 5 = 1230000
|
|
75
|
+
* This is used for add function only.
|
|
76
|
+
*/
|
|
77
|
+
}, {
|
|
78
|
+
key: "alignDecimal",
|
|
79
|
+
value: function alignDecimal(decimalLength) {
|
|
80
|
+
var str = "".concat(this.getMark()).concat(this.getIntegerStr()).concat(this.getDecimalStr().padEnd(decimalLength, '0'));
|
|
81
|
+
return BigInt(str);
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "negate",
|
|
85
|
+
value: function negate() {
|
|
86
|
+
var clone = new BigIntDecimal(this.toString());
|
|
87
|
+
clone.negative = !clone.negative;
|
|
88
|
+
return clone;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "cal",
|
|
92
|
+
value: function cal(offset, calculator, calDecimalLen) {
|
|
93
|
+
var maxDecimalLength = Math.max(this.getDecimalStr().length, offset.getDecimalStr().length);
|
|
94
|
+
var myAlignedDecimal = this.alignDecimal(maxDecimalLength);
|
|
95
|
+
var offsetAlignedDecimal = offset.alignDecimal(maxDecimalLength);
|
|
96
|
+
var valueStr = calculator(myAlignedDecimal, offsetAlignedDecimal).toString();
|
|
97
|
+
var nextDecimalLength = calDecimalLen(maxDecimalLength);
|
|
98
|
+
|
|
99
|
+
// We need fill string length back to `maxDecimalLength` to avoid parser failed
|
|
100
|
+
var _trimNumber = trimNumber(valueStr),
|
|
101
|
+
negativeStr = _trimNumber.negativeStr,
|
|
102
|
+
trimStr = _trimNumber.trimStr;
|
|
103
|
+
var hydrateValueStr = "".concat(negativeStr).concat(trimStr.padStart(nextDecimalLength + 1, '0'));
|
|
104
|
+
return new BigIntDecimal("".concat(hydrateValueStr.slice(0, -nextDecimalLength), ".").concat(hydrateValueStr.slice(-nextDecimalLength)));
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "add",
|
|
108
|
+
value: function add(value) {
|
|
109
|
+
if (this.isInvalidate()) {
|
|
110
|
+
return new BigIntDecimal(value);
|
|
111
|
+
}
|
|
112
|
+
var offset = new BigIntDecimal(value);
|
|
113
|
+
if (offset.isInvalidate()) {
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
return this.cal(offset, function (num1, num2) {
|
|
117
|
+
return num1 + num2;
|
|
118
|
+
}, function (len) {
|
|
119
|
+
return len;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "multi",
|
|
124
|
+
value: function multi(value) {
|
|
125
|
+
var target = new BigIntDecimal(value);
|
|
126
|
+
if (this.isInvalidate() || target.isInvalidate()) {
|
|
127
|
+
return new BigIntDecimal(NaN);
|
|
128
|
+
}
|
|
129
|
+
return this.cal(target, function (num1, num2) {
|
|
130
|
+
return num1 * num2;
|
|
131
|
+
}, function (len) {
|
|
132
|
+
return len * 2;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "isEmpty",
|
|
137
|
+
value: function isEmpty() {
|
|
138
|
+
return this.empty;
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "isNaN",
|
|
142
|
+
value: function isNaN() {
|
|
143
|
+
return this.nan;
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "isInvalidate",
|
|
147
|
+
value: function isInvalidate() {
|
|
148
|
+
return this.isEmpty() || this.isNaN();
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "equals",
|
|
152
|
+
value: function equals(target) {
|
|
153
|
+
return this.toString() === (target === null || target === void 0 ? void 0 : target.toString());
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
key: "lessEquals",
|
|
157
|
+
value: function lessEquals(target) {
|
|
158
|
+
return this.add(target.negate().toString()).toNumber() <= 0;
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "toNumber",
|
|
162
|
+
value: function toNumber() {
|
|
163
|
+
if (this.isNaN()) {
|
|
164
|
+
return NaN;
|
|
165
|
+
}
|
|
166
|
+
return Number(this.toString());
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "toString",
|
|
170
|
+
value: function toString() {
|
|
171
|
+
var safe = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
172
|
+
if (!safe) {
|
|
173
|
+
return this.origin;
|
|
174
|
+
}
|
|
175
|
+
if (this.isInvalidate()) {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
return trimNumber("".concat(this.getMark()).concat(this.getIntegerStr(), ".").concat(this.getDecimalStr())).fullStr;
|
|
179
|
+
}
|
|
180
|
+
}]);
|
|
181
|
+
return BigIntDecimal;
|
|
182
|
+
}();
|
|
183
|
+
|
|
184
|
+
export { BigIntDecimal as default };
|