@nocobase/client 0.8.1-alpha.4 → 0.9.0-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/es/acl/ACLProvider.d.ts +16 -2
- package/es/acl/ACLProvider.js +271 -100
- package/es/acl/Configuration/ConfigureCenter.d.ts +2 -0
- package/es/acl/Configuration/ConfigureCenter.js +254 -0
- package/es/acl/Configuration/MenuConfigure.js +2 -2
- package/es/acl/Configuration/PermisionProvider.d.ts +4 -0
- package/es/acl/Configuration/PermisionProvider.js +132 -0
- package/es/acl/Configuration/RoleConfigure.js +98 -23
- package/es/acl/Configuration/RoleTable.d.ts +1 -1
- package/es/acl/Configuration/RoleTable.js +6 -3
- package/es/acl/Configuration/RolesResourcesActions.js +2 -2
- package/es/acl/Configuration/index.d.ts +1 -0
- package/es/acl/Configuration/index.js +2 -1
- package/es/acl/Configuration/schemas/roleCollections.js +41 -13
- package/es/acl/Configuration/schemas/roles.js +42 -2
- package/es/acl/Configuration/schemas/scopes.js +2 -0
- package/es/acl/index.d.ts +1 -0
- package/es/acl/index.js +2 -1
- package/es/acl/style.less +10 -0
- package/es/antd-config-provider/index.d.ts +3 -1
- package/es/antd-config-provider/index.js +25 -6
- package/es/antd-config-provider/loadConstrueLocale.d.ts +1 -0
- package/es/antd-config-provider/loadConstrueLocale.js +293 -0
- package/es/api-client/APIClient.js +5 -0
- package/es/block-provider/FormBlockProvider.js +5 -2
- package/es/block-provider/KanbanBlockProvider.js +3 -3
- package/es/block-provider/SharedFilterProvider.d.ts +1 -0
- package/es/block-provider/SharedFilterProvider.js +22 -6
- package/es/collection-manager/CollectionHistoryProvider.js +14 -2
- package/es/collection-manager/hooks/useCollection.d.ts +1 -0
- package/es/collection-manager/hooks/useCollection.js +10 -0
- package/es/collection-manager/interfaces/index.d.ts +0 -1
- package/es/collection-manager/interfaces/index.js +0 -1
- package/es/collection-manager/interfaces/o2m.js +1 -0
- package/es/collection-manager/interfaces/properties/operators.js +7 -0
- package/es/collection-manager/interfaces/subTable.js +1 -0
- package/es/collection-manager/templates/calendar.js +5 -0
- package/es/formula/Expression.d.ts +2 -0
- package/es/formula/Expression.js +296 -0
- package/es/formula/Result.d.ts +2 -0
- package/es/formula/Result.js +91 -0
- package/es/formula/index.d.ts +6 -0
- package/es/formula/index.js +8 -0
- package/es/i18n/i18n.js +7 -12
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -2
- package/es/locale/en_US.d.ts +108 -28
- package/es/locale/en_US.js +108 -28
- package/es/locale/index.d.ts +201 -4
- package/es/locale/index.js +191 -58
- package/es/locale/ja_JP.d.ts +4 -0
- package/es/locale/ja_JP.js +4 -0
- package/es/locale/zh_CN.d.ts +11 -1
- package/es/locale/zh_CN.js +12 -2
- package/es/plugin-manager/PluginManager.js +19 -13
- package/es/pm/PluginManagerLink.js +38 -43
- package/es/pm/index.d.ts +1 -0
- package/es/pm/index.js +84 -35
- package/es/record-provider/index.d.ts +1 -0
- package/es/record-provider/index.js +7 -4
- package/es/route-switch/antd/admin-layout/index.d.ts +1 -0
- package/es/route-switch/antd/admin-layout/index.js +4 -6
- package/es/schema-component/antd/action/Action.js +19 -16
- package/es/schema-component/antd/association-filter/AssociationFilter.Item.js +24 -23
- package/es/schema-component/antd/cron/Cron.d.ts +0 -1
- package/es/schema-component/antd/cron/Cron.js +16 -19
- package/es/schema-component/antd/cron/locale/index.d.ts +37 -0
- package/es/schema-component/antd/cron/locale/index.js +6 -0
- package/es/schema-component/antd/filter/useFilterActionProps.js +17 -23
- package/es/schema-component/antd/form-item/FormItem.js +5 -4
- package/es/schema-component/antd/index.d.ts +1 -2
- package/es/schema-component/antd/index.js +1 -2
- package/es/schema-component/antd/page/FixedBlock.d.ts +1 -1
- package/es/schema-component/antd/page/FixedBlock.js +70 -21
- package/es/schema-component/antd/page/Page.js +15 -10
- package/es/schema-component/antd/remote-select/RemoteSelect.js +12 -2
- package/es/schema-component/antd/table/Table.Array.js +1 -1
- package/es/schema-component/antd/table-v2/Table.js +13 -6
- package/es/schema-component/antd/table-v2/TableBlockDesigner.js +24 -8
- package/es/schema-component/hooks/useDesignable.d.ts +1 -1
- package/es/schema-component/hooks/useDesignable.js +45 -16
- package/es/schema-component/hooks/useFieldTitle.js +3 -1
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +3 -0
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +1 -0
- package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -0
- package/es/schema-initializer/utils.js +6 -9
- package/es/schema-templates/BlockTemplate.js +2 -2
- package/es/schema-templates/SchemaTemplateManagerProvider.js +1 -1
- package/es/system-settings/SystemSettingsShortcut.js +1 -1
- package/lib/acl/ACLProvider.d.ts +16 -2
- package/lib/acl/ACLProvider.js +283 -102
- package/lib/acl/Configuration/ConfigureCenter.d.ts +2 -0
- package/lib/acl/Configuration/ConfigureCenter.js +278 -0
- package/lib/acl/Configuration/MenuConfigure.js +3 -3
- package/lib/acl/Configuration/PermisionProvider.d.ts +4 -0
- package/lib/acl/Configuration/PermisionProvider.js +156 -0
- package/lib/acl/Configuration/RoleConfigure.js +107 -23
- package/lib/acl/Configuration/RoleTable.d.ts +1 -1
- package/lib/acl/Configuration/RoleTable.js +8 -4
- package/lib/acl/Configuration/RolesResourcesActions.js +2 -2
- package/lib/acl/Configuration/index.d.ts +1 -0
- package/lib/acl/Configuration/index.js +15 -1
- package/lib/acl/Configuration/schemas/roleCollections.js +41 -13
- package/lib/acl/Configuration/schemas/roles.js +47 -2
- package/lib/acl/Configuration/schemas/scopes.js +2 -0
- package/lib/acl/index.d.ts +1 -0
- package/lib/acl/index.js +3 -1
- package/lib/acl/style.less +10 -0
- package/lib/antd-config-provider/index.d.ts +3 -1
- package/lib/antd-config-provider/index.js +40 -6
- package/lib/antd-config-provider/loadConstrueLocale.d.ts +1 -0
- package/lib/antd-config-provider/loadConstrueLocale.js +304 -0
- package/lib/api-client/APIClient.js +5 -0
- package/lib/block-provider/FormBlockProvider.js +9 -3
- package/lib/block-provider/KanbanBlockProvider.js +3 -3
- package/lib/block-provider/SharedFilterProvider.d.ts +1 -0
- package/lib/block-provider/SharedFilterProvider.js +26 -7
- package/lib/collection-manager/CollectionHistoryProvider.js +14 -1
- package/lib/collection-manager/hooks/useCollection.d.ts +1 -0
- package/lib/collection-manager/hooks/useCollection.js +10 -0
- package/lib/collection-manager/interfaces/index.d.ts +0 -1
- package/lib/collection-manager/interfaces/index.js +0 -13
- package/lib/collection-manager/interfaces/o2m.js +1 -0
- package/lib/collection-manager/interfaces/properties/operators.js +7 -0
- package/lib/collection-manager/interfaces/subTable.js +1 -0
- package/lib/collection-manager/templates/calendar.js +5 -0
- package/lib/formula/Expression.d.ts +2 -0
- package/lib/formula/Expression.js +319 -0
- package/lib/formula/Result.d.ts +2 -0
- package/lib/formula/Result.js +114 -0
- package/lib/formula/index.d.ts +6 -0
- package/lib/formula/index.js +22 -0
- package/lib/i18n/i18n.js +7 -14
- package/lib/index.d.ts +2 -1
- package/lib/index.js +26 -13
- package/lib/locale/en_US.d.ts +108 -28
- package/lib/locale/en_US.js +108 -28
- package/lib/locale/index.d.ts +201 -4
- package/lib/locale/index.js +197 -67
- package/lib/locale/ja_JP.d.ts +4 -0
- package/lib/locale/ja_JP.js +4 -0
- package/lib/locale/zh_CN.d.ts +11 -1
- package/lib/locale/zh_CN.js +12 -2
- package/lib/plugin-manager/PluginManager.js +20 -13
- package/lib/pm/PluginManagerLink.js +37 -43
- package/lib/pm/index.d.ts +1 -0
- package/lib/pm/index.js +90 -35
- package/lib/record-provider/index.d.ts +1 -0
- package/lib/record-provider/index.js +7 -4
- package/lib/route-switch/antd/admin-layout/index.d.ts +1 -0
- package/lib/route-switch/antd/admin-layout/index.js +5 -4
- package/lib/schema-component/antd/action/Action.js +19 -16
- package/lib/schema-component/antd/association-filter/AssociationFilter.Item.js +22 -21
- package/lib/schema-component/antd/cron/Cron.d.ts +0 -1
- package/lib/schema-component/antd/cron/Cron.js +19 -24
- package/lib/schema-component/antd/cron/locale/index.d.ts +37 -0
- package/lib/schema-component/antd/cron/locale/index.js +18 -0
- package/lib/schema-component/antd/filter/useFilterActionProps.js +16 -23
- package/lib/schema-component/antd/form-item/FormItem.js +6 -4
- package/lib/schema-component/antd/index.d.ts +1 -2
- package/lib/schema-component/antd/index.js +8 -21
- package/lib/schema-component/antd/page/FixedBlock.d.ts +1 -1
- package/lib/schema-component/antd/page/FixedBlock.js +71 -21
- package/lib/schema-component/antd/page/Page.js +14 -9
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +18 -3
- package/lib/schema-component/antd/table/Table.Array.js +1 -1
- package/lib/schema-component/antd/table-v2/Table.js +14 -6
- package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +25 -8
- package/lib/schema-component/hooks/useDesignable.d.ts +1 -1
- package/lib/schema-component/hooks/useDesignable.js +47 -18
- package/lib/schema-component/hooks/useFieldTitle.js +4 -1
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +3 -0
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +1 -0
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -0
- package/lib/schema-initializer/utils.js +6 -9
- package/lib/schema-templates/BlockTemplate.js +2 -2
- package/lib/schema-templates/SchemaTemplateManagerProvider.js +1 -1
- package/lib/system-settings/SystemSettingsShortcut.js +1 -1
- package/package.json +6 -11
- package/es/collection-manager/interfaces/formula.d.ts +0 -2
- package/es/collection-manager/interfaces/formula.js +0 -74
- package/es/schema-component/antd/formula-input/Compute.d.ts +0 -3
- package/es/schema-component/antd/formula-input/Compute.js +0 -55
- package/es/schema-component/antd/formula-input/FormulaInput.d.ts +0 -3
- package/es/schema-component/antd/formula-input/FormulaInput.js +0 -167
- package/es/schema-component/antd/formula-input/index.d.ts +0 -1
- package/es/schema-component/antd/formula-input/index.js +0 -7
- package/lib/collection-manager/interfaces/formula.d.ts +0 -2
- package/lib/collection-manager/interfaces/formula.js +0 -83
- package/lib/schema-component/antd/formula-input/Compute.d.ts +0 -3
- package/lib/schema-component/antd/formula-input/Compute.js +0 -79
- package/lib/schema-component/antd/formula-input/FormulaInput.d.ts +0 -3
- package/lib/schema-component/antd/formula-input/FormulaInput.js +0 -191
- package/lib/schema-component/antd/formula-input/index.d.ts +0 -1
- package/lib/schema-component/antd/formula-input/index.js +0 -18
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
-
|
|
3
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
-
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
|
|
7
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
-
|
|
13
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
14
|
-
|
|
15
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
|
|
17
|
-
import { onFormSubmitValidateStart } from '@formily/core';
|
|
18
|
-
import { connect, mapProps, useField, useFormEffects } from '@formily/react';
|
|
19
|
-
import { Menu, Dropdown } from 'antd';
|
|
20
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
21
|
-
import ContentEditable from 'react-contenteditable';
|
|
22
|
-
import { useTranslation } from 'react-i18next';
|
|
23
|
-
import * as math from 'mathjs';
|
|
24
|
-
|
|
25
|
-
var AntdFormulaInput = function AntdFormulaInput(props) {
|
|
26
|
-
var value = props.value,
|
|
27
|
-
onChange = props.onChange,
|
|
28
|
-
supports = props.supports,
|
|
29
|
-
useCurrentFields = props.useCurrentFields;
|
|
30
|
-
var field = useField();
|
|
31
|
-
|
|
32
|
-
var _useTranslation = useTranslation(),
|
|
33
|
-
t = _useTranslation.t;
|
|
34
|
-
|
|
35
|
-
var fields = useCurrentFields();
|
|
36
|
-
var inputRef = useRef();
|
|
37
|
-
|
|
38
|
-
var _useState = useState(false),
|
|
39
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
dropdownVisible = _useState2[0],
|
|
41
|
-
setDropdownVisible = _useState2[1];
|
|
42
|
-
|
|
43
|
-
var _useState3 = useState(null),
|
|
44
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
-
html = _useState4[0],
|
|
46
|
-
setHtml = _useState4[1];
|
|
47
|
-
|
|
48
|
-
var numColumns = new Map();
|
|
49
|
-
var scope = {};
|
|
50
|
-
fields.filter(function (field) {
|
|
51
|
-
return supports.includes(field.interface);
|
|
52
|
-
}).forEach(function (field) {
|
|
53
|
-
numColumns.set(field.name, field.uiSchema.title);
|
|
54
|
-
scope[field.name] = 1;
|
|
55
|
-
});
|
|
56
|
-
var keys = Array.from(numColumns.keys());
|
|
57
|
-
useEffect(function () {
|
|
58
|
-
if (value) {
|
|
59
|
-
var newHtml = value;
|
|
60
|
-
numColumns.forEach(function (value, key) {
|
|
61
|
-
newHtml = newHtml.replaceAll(key, "<span contentEditable=\"false\" ><input disabled=\"disabled\" style=\"width:".concat(18 * value.length, "px;max-width: 120px\" value=\"").concat(value, "\"/><span hidden>").concat(key, "</span></span>"));
|
|
62
|
-
});
|
|
63
|
-
newHtml = "".concat(newHtml, "<span style=\"padding-left: 5px\"></span>"); // set extra span for cursor focus on last position
|
|
64
|
-
|
|
65
|
-
setHtml(newHtml);
|
|
66
|
-
} else {
|
|
67
|
-
setHtml('');
|
|
68
|
-
}
|
|
69
|
-
}, [value]);
|
|
70
|
-
var items = keys.map(function (key) {
|
|
71
|
-
return {
|
|
72
|
-
label: numColumns.get(key),
|
|
73
|
-
key: key
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
var menu = /*#__PURE__*/React.createElement(Menu, {
|
|
77
|
-
onClick: function () {
|
|
78
|
-
var _onClick = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(args) {
|
|
79
|
-
var replaceFormula;
|
|
80
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
81
|
-
while (1) {
|
|
82
|
-
switch (_context.prev = _context.next) {
|
|
83
|
-
case 0:
|
|
84
|
-
replaceFormula = field.value.replace('@', args.key);
|
|
85
|
-
|
|
86
|
-
if (onChange && replaceFormula != field.value) {
|
|
87
|
-
onChange(replaceFormula);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
setDropdownVisible(false);
|
|
91
|
-
inputRef.current.focus();
|
|
92
|
-
|
|
93
|
-
case 4:
|
|
94
|
-
case "end":
|
|
95
|
-
return _context.stop();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}, _callee);
|
|
99
|
-
}));
|
|
100
|
-
|
|
101
|
-
function onClick(_x) {
|
|
102
|
-
return _onClick.apply(this, arguments);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return onClick;
|
|
106
|
-
}(),
|
|
107
|
-
items: items
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
var handleChange = function handleChange(e) {
|
|
111
|
-
if (onChange) {
|
|
112
|
-
if (e.currentTarget.textContent == '') {
|
|
113
|
-
onChange(null);
|
|
114
|
-
} else {
|
|
115
|
-
onChange(e.currentTarget.textContent);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
var handleKeyDown = function handleKeyDown(e) {
|
|
121
|
-
var key = e.key;
|
|
122
|
-
|
|
123
|
-
switch (key) {
|
|
124
|
-
case 'Enter':
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
break;
|
|
127
|
-
|
|
128
|
-
case '@':
|
|
129
|
-
case 'Process':
|
|
130
|
-
setDropdownVisible(true);
|
|
131
|
-
break;
|
|
132
|
-
|
|
133
|
-
default:
|
|
134
|
-
setDropdownVisible(false);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
useFormEffects(function () {
|
|
140
|
-
onFormSubmitValidateStart(function () {
|
|
141
|
-
try {
|
|
142
|
-
math.evaluate(field.value, scope);
|
|
143
|
-
field.feedbacks = [];
|
|
144
|
-
} catch (e) {
|
|
145
|
-
console.error(field.value, scope, e.message);
|
|
146
|
-
field.setFeedback({
|
|
147
|
-
type: 'error',
|
|
148
|
-
code: 'FormulaError',
|
|
149
|
-
messages: [t('Formula error.')]
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
155
|
-
overlay: menu,
|
|
156
|
-
visible: dropdownVisible
|
|
157
|
-
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
158
|
-
innerRef: inputRef,
|
|
159
|
-
className: "ant-input",
|
|
160
|
-
onChange: handleChange,
|
|
161
|
-
onKeyDown: handleKeyDown,
|
|
162
|
-
html: html || ''
|
|
163
|
-
}));
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export var FormulaInput = connect(AntdFormulaInput, mapProps({}));
|
|
167
|
-
export default FormulaInput;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Formula: any;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formula = void 0;
|
|
7
|
-
|
|
8
|
-
var _properties = require("./properties");
|
|
9
|
-
|
|
10
|
-
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; }
|
|
11
|
-
|
|
12
|
-
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; }
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
16
|
-
var formula = {
|
|
17
|
-
name: 'formula',
|
|
18
|
-
type: 'object',
|
|
19
|
-
group: 'advanced',
|
|
20
|
-
order: 1,
|
|
21
|
-
title: '{{t("Formula")}}',
|
|
22
|
-
description: '{{t("Formula description")}}',
|
|
23
|
-
sortable: true,
|
|
24
|
-
default: {
|
|
25
|
-
type: 'formula',
|
|
26
|
-
// name,
|
|
27
|
-
uiSchema: {
|
|
28
|
-
type: 'number',
|
|
29
|
-
// title,
|
|
30
|
-
"x-disabled": true,
|
|
31
|
-
'x-component': 'Formula.Result',
|
|
32
|
-
'x-component-props': {
|
|
33
|
-
stringMode: true,
|
|
34
|
-
step: '1'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
properties: _objectSpread(_objectSpread({}, _properties.defaultProps), {}, {
|
|
39
|
-
'expression': {
|
|
40
|
-
type: 'string',
|
|
41
|
-
title: '{{t("Expression")}}',
|
|
42
|
-
required: true,
|
|
43
|
-
description: '{{t("Input +, -, *, /, ( ) to calculate, input @ to open field variables.")}}',
|
|
44
|
-
'x-component': 'Formula.Expression',
|
|
45
|
-
'x-decorator': 'FormItem',
|
|
46
|
-
'x-component-props': {
|
|
47
|
-
'supports': ['number', 'percent', 'integer'],
|
|
48
|
-
'useCurrentFields': '{{ useCurrentFields }}'
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
'uiSchema.x-component-props.step': {
|
|
52
|
-
type: 'string',
|
|
53
|
-
title: '{{t("Precision")}}',
|
|
54
|
-
'x-component': 'Select',
|
|
55
|
-
'x-decorator': 'FormItem',
|
|
56
|
-
required: true,
|
|
57
|
-
default: '0',
|
|
58
|
-
enum: [{
|
|
59
|
-
value: '0',
|
|
60
|
-
label: '1'
|
|
61
|
-
}, {
|
|
62
|
-
value: '0.1',
|
|
63
|
-
label: '1.0'
|
|
64
|
-
}, {
|
|
65
|
-
value: '0.01',
|
|
66
|
-
label: '1.00'
|
|
67
|
-
}, {
|
|
68
|
-
value: '0.001',
|
|
69
|
-
label: '1.000'
|
|
70
|
-
}, {
|
|
71
|
-
value: '0.0001',
|
|
72
|
-
label: '1.0000'
|
|
73
|
-
}, {
|
|
74
|
-
value: '0.00001',
|
|
75
|
-
label: '1.00000'
|
|
76
|
-
}]
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
|
-
filterable: {
|
|
80
|
-
operators: _properties.operators.number
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
exports.formula = formula;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = exports.Compute = void 0;
|
|
9
|
-
|
|
10
|
-
var _core = require("@formily/core");
|
|
11
|
-
|
|
12
|
-
var _react = require("@formily/react");
|
|
13
|
-
|
|
14
|
-
var _antd = require("antd");
|
|
15
|
-
|
|
16
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
17
|
-
|
|
18
|
-
var math = _interopRequireWildcard(require("mathjs"));
|
|
19
|
-
|
|
20
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
21
|
-
|
|
22
|
-
var _hooks = require("../../../collection-manager/hooks");
|
|
23
|
-
|
|
24
|
-
var _ReadPretty = require("../input-number/ReadPretty");
|
|
25
|
-
|
|
26
|
-
var _excluded = ["onChange"];
|
|
27
|
-
|
|
28
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
36
|
-
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; }
|
|
37
|
-
|
|
38
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
|
-
|
|
40
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
41
|
-
|
|
42
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
43
|
-
|
|
44
|
-
var AntdCompute = function AntdCompute(props) {
|
|
45
|
-
var onChange = props.onChange,
|
|
46
|
-
others = _objectWithoutProperties(props, _excluded);
|
|
47
|
-
|
|
48
|
-
var _useCollection = (0, _hooks.useCollection)(),
|
|
49
|
-
getField = _useCollection.getField;
|
|
50
|
-
|
|
51
|
-
var fieldSchema = (0, _react.useFieldSchema)();
|
|
52
|
-
var options = getField(fieldSchema.name);
|
|
53
|
-
var expression = options.expression;
|
|
54
|
-
(0, _react.useFormEffects)(function () {
|
|
55
|
-
(0, _core.onFormValuesChange)(function (form) {
|
|
56
|
-
var scope = _lodash.default.cloneDeep(form.values);
|
|
57
|
-
|
|
58
|
-
var result;
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
result = math.evaluate(expression, scope);
|
|
62
|
-
result = Number.isFinite(result) ? math.round(result, 9) : null;
|
|
63
|
-
} catch (_unused) {}
|
|
64
|
-
|
|
65
|
-
if (onChange) {
|
|
66
|
-
onChange(result);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
return /*#__PURE__*/_react2.default.createElement(_antd.InputNumber, _objectSpread(_objectSpread({}, others), {}, {
|
|
71
|
-
readOnly: true,
|
|
72
|
-
stringMode: true
|
|
73
|
-
}));
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
var Compute = (0, _react.connect)(AntdCompute, (0, _react.mapReadPretty)(_ReadPretty.ReadPretty));
|
|
77
|
-
exports.Compute = Compute;
|
|
78
|
-
var _default = Compute;
|
|
79
|
-
exports.default = _default;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = exports.FormulaInput = void 0;
|
|
9
|
-
|
|
10
|
-
var _core = require("@formily/core");
|
|
11
|
-
|
|
12
|
-
var _react = require("@formily/react");
|
|
13
|
-
|
|
14
|
-
var _antd = require("antd");
|
|
15
|
-
|
|
16
|
-
var _react2 = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
|
-
var _reactContenteditable = _interopRequireDefault(require("react-contenteditable"));
|
|
19
|
-
|
|
20
|
-
var _reactI18next = require("react-i18next");
|
|
21
|
-
|
|
22
|
-
var math = _interopRequireWildcard(require("mathjs"));
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
31
|
-
|
|
32
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
33
|
-
|
|
34
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
35
|
-
|
|
36
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
37
|
-
|
|
38
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
39
|
-
|
|
40
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
41
|
-
|
|
42
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
43
|
-
|
|
44
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
|
-
|
|
46
|
-
var AntdFormulaInput = function AntdFormulaInput(props) {
|
|
47
|
-
var value = props.value,
|
|
48
|
-
onChange = props.onChange,
|
|
49
|
-
supports = props.supports,
|
|
50
|
-
useCurrentFields = props.useCurrentFields;
|
|
51
|
-
var field = (0, _react.useField)();
|
|
52
|
-
|
|
53
|
-
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
54
|
-
t = _useTranslation.t;
|
|
55
|
-
|
|
56
|
-
var fields = useCurrentFields();
|
|
57
|
-
var inputRef = (0, _react2.useRef)();
|
|
58
|
-
|
|
59
|
-
var _useState = (0, _react2.useState)(false),
|
|
60
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
-
dropdownVisible = _useState2[0],
|
|
62
|
-
setDropdownVisible = _useState2[1];
|
|
63
|
-
|
|
64
|
-
var _useState3 = (0, _react2.useState)(null),
|
|
65
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
66
|
-
html = _useState4[0],
|
|
67
|
-
setHtml = _useState4[1];
|
|
68
|
-
|
|
69
|
-
var numColumns = new Map();
|
|
70
|
-
var scope = {};
|
|
71
|
-
fields.filter(function (field) {
|
|
72
|
-
return supports.includes(field.interface);
|
|
73
|
-
}).forEach(function (field) {
|
|
74
|
-
numColumns.set(field.name, field.uiSchema.title);
|
|
75
|
-
scope[field.name] = 1;
|
|
76
|
-
});
|
|
77
|
-
var keys = Array.from(numColumns.keys());
|
|
78
|
-
(0, _react2.useEffect)(function () {
|
|
79
|
-
if (value) {
|
|
80
|
-
var newHtml = value;
|
|
81
|
-
numColumns.forEach(function (value, key) {
|
|
82
|
-
newHtml = newHtml.replaceAll(key, "<span contentEditable=\"false\" ><input disabled=\"disabled\" style=\"width:".concat(18 * value.length, "px;max-width: 120px\" value=\"").concat(value, "\"/><span hidden>").concat(key, "</span></span>"));
|
|
83
|
-
});
|
|
84
|
-
newHtml = "".concat(newHtml, "<span style=\"padding-left: 5px\"></span>"); // set extra span for cursor focus on last position
|
|
85
|
-
|
|
86
|
-
setHtml(newHtml);
|
|
87
|
-
} else {
|
|
88
|
-
setHtml('');
|
|
89
|
-
}
|
|
90
|
-
}, [value]);
|
|
91
|
-
var items = keys.map(function (key) {
|
|
92
|
-
return {
|
|
93
|
-
label: numColumns.get(key),
|
|
94
|
-
key: key
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
var menu = /*#__PURE__*/_react2.default.createElement(_antd.Menu, {
|
|
99
|
-
onClick: function () {
|
|
100
|
-
var _onClick = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(args) {
|
|
101
|
-
var replaceFormula;
|
|
102
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
103
|
-
while (1) {
|
|
104
|
-
switch (_context.prev = _context.next) {
|
|
105
|
-
case 0:
|
|
106
|
-
replaceFormula = field.value.replace('@', args.key);
|
|
107
|
-
|
|
108
|
-
if (onChange && replaceFormula != field.value) {
|
|
109
|
-
onChange(replaceFormula);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
setDropdownVisible(false);
|
|
113
|
-
inputRef.current.focus();
|
|
114
|
-
|
|
115
|
-
case 4:
|
|
116
|
-
case "end":
|
|
117
|
-
return _context.stop();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}, _callee);
|
|
121
|
-
}));
|
|
122
|
-
|
|
123
|
-
function onClick(_x) {
|
|
124
|
-
return _onClick.apply(this, arguments);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return onClick;
|
|
128
|
-
}(),
|
|
129
|
-
items: items
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
var handleChange = function handleChange(e) {
|
|
133
|
-
if (onChange) {
|
|
134
|
-
if (e.currentTarget.textContent == '') {
|
|
135
|
-
onChange(null);
|
|
136
|
-
} else {
|
|
137
|
-
onChange(e.currentTarget.textContent);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var handleKeyDown = function handleKeyDown(e) {
|
|
143
|
-
var key = e.key;
|
|
144
|
-
|
|
145
|
-
switch (key) {
|
|
146
|
-
case 'Enter':
|
|
147
|
-
e.preventDefault();
|
|
148
|
-
break;
|
|
149
|
-
|
|
150
|
-
case '@':
|
|
151
|
-
case 'Process':
|
|
152
|
-
setDropdownVisible(true);
|
|
153
|
-
break;
|
|
154
|
-
|
|
155
|
-
default:
|
|
156
|
-
setDropdownVisible(false);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
(0, _react.useFormEffects)(function () {
|
|
162
|
-
(0, _core.onFormSubmitValidateStart)(function () {
|
|
163
|
-
try {
|
|
164
|
-
math.evaluate(field.value, scope);
|
|
165
|
-
field.feedbacks = [];
|
|
166
|
-
} catch (e) {
|
|
167
|
-
console.error(field.value, scope, e.message);
|
|
168
|
-
field.setFeedback({
|
|
169
|
-
type: 'error',
|
|
170
|
-
code: 'FormulaError',
|
|
171
|
-
messages: [t('Formula error.')]
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
return /*#__PURE__*/_react2.default.createElement(_antd.Dropdown, {
|
|
177
|
-
overlay: menu,
|
|
178
|
-
visible: dropdownVisible
|
|
179
|
-
}, /*#__PURE__*/_react2.default.createElement(_reactContenteditable.default, {
|
|
180
|
-
innerRef: inputRef,
|
|
181
|
-
className: "ant-input",
|
|
182
|
-
onChange: handleChange,
|
|
183
|
-
onKeyDown: handleKeyDown,
|
|
184
|
-
html: html || ''
|
|
185
|
-
}));
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
var FormulaInput = (0, _react.connect)(AntdFormulaInput, (0, _react.mapProps)({}));
|
|
189
|
-
exports.FormulaInput = FormulaInput;
|
|
190
|
-
var _default = FormulaInput;
|
|
191
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Formula: any;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Formula = void 0;
|
|
7
|
-
|
|
8
|
-
var _Compute = require("./Compute");
|
|
9
|
-
|
|
10
|
-
var _FormulaInput = require("./FormulaInput");
|
|
11
|
-
|
|
12
|
-
var Formula = function Formula() {
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.Formula = Formula;
|
|
17
|
-
Formula.Expression = _FormulaInput.FormulaInput;
|
|
18
|
-
Formula.Result = _Compute.Compute;
|