vap1 0.2.2 → 0.2.4
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/components/Box/Box.js +75 -42
- package/components/Box/SelectBar.js +51 -24
- package/components/Box/_register.d.ts +4 -0
- package/components/Box/_register.js +10 -8
- package/components/Box/index.js +1 -1
- package/components/Lists/SList.js +76 -48
- package/components/SearchBar/ActionButtons.js +75 -42
- package/components/SearchBar/ByField.js +80 -52
- package/components/SearchBar/ByKeyword.js +44 -17
- package/components/SearchBar/SearchField.js +8 -8
- package/components/SearchBar/SearchTags.js +4 -4
- package/components/SearchBar/_register.js +9 -8
- package/components/SearchBar/index.js +22 -11
- package/components/Tables/ApiTable.d.ts +1 -1
- package/components/Tables/ApiTable.js +19 -8
- package/components/Tables/ApiTableModal.d.ts +1 -1
- package/components/Tables/ApiTableModal.js +40 -13
- package/components/Tables/Components/ActionBar.js +53 -26
- package/components/Tables/Components/Actions.js +40 -29
- package/components/Tables/Components/Summary.js +2 -2
- package/components/Tables/Components/index.js +3 -3
- package/components/Tables/STable.js +21 -10
- package/components/Tables/TopTable.d.ts +3 -2
- package/components/Tables/TopTable.js +64 -37
- package/components/Tables/TopTableModal.js +21 -10
- package/components/Tables/Util.d.ts +2 -2
- package/components/Tables/Util.js +11 -9
- package/components/Tables/VTable.d.ts +2 -2
- package/components/Tables/VTable.js +137 -65
- package/components/Tables/index.d.ts +7 -2
- package/components/Tables/index.js +5 -5
- package/components/TreeSelect/BaseTreeSelect.js +81 -45
- package/components/TreeSelect/DTreeSelect.js +191 -66
- package/components/TreeSelect/FTreeSelect.js +67 -20
- package/components/TreeSelect/STreeSelect.js +22 -11
- package/components/Trees/ActionTree.js +562 -431
- package/components/Trees/BaseTree.js +85 -38
- package/components/Trees/COTree/COButton.js +48 -21
- package/components/Trees/COTree/COSelect.js +31 -20
- package/components/Trees/COTree/COTree.js +223 -107
- package/components/Trees/COTree/COTreeUtil.js +160 -115
- package/components/Trees/DTree.js +139 -68
- package/components/Trees/FTree.js +76 -29
- package/components/Trees/STree.js +59 -23
- package/components/UForm/FormWrapper.js +70 -53
- package/components/UForm/UDescriptions.js +38 -38
- package/components/UForm/UForm.js +240 -135
- package/components/UForm/UFormModal.js +99 -44
- package/components/UForm/UInfo.js +33 -22
- package/components/UForm/UInfoModal.js +31 -20
- package/components/UForm/UModal.js +40 -13
- package/components/UForm/_FormUtils.js +29 -18
- package/components/UForm/_input.js +75 -39
- package/components/UForm/_register.js +11 -9
- package/components/Upload/UploadFile.js +38 -11
- package/components/Upload/UploadImage.js +50 -23
- package/components/Upload/UploadModal.js +149 -84
- package/components/Upload/useUpload.js +35 -19
- package/components/_RegisterUtil.js +20 -8
- package/components/_adapt/Alert.js +20 -9
- package/components/_adapt/Breadcrumb.js +18 -7
- package/components/_adapt/Button.js +24 -13
- package/components/_adapt/Col.js +34 -23
- package/components/_adapt/Collapse.js +21 -10
- package/components/_adapt/ColorPicker.js +55 -28
- package/components/_adapt/ConfigProvider.js +14 -3
- package/components/_adapt/Drawer.js +18 -7
- package/components/_adapt/Dropdown.js +23 -12
- package/components/_adapt/FloatButton.js +21 -10
- package/components/_adapt/Icon.js +18 -7
- package/components/_adapt/Input.js +17 -6
- package/components/_adapt/InputNumber.js +16 -5
- package/components/_adapt/Layout.js +84 -28
- package/components/_adapt/Menu.js +28 -17
- package/components/_adapt/Modal.js +72 -25
- package/components/_adapt/Pagination.js +14 -3
- package/components/_adapt/Popconfirm.js +17 -6
- package/components/_adapt/Popover.js +17 -6
- package/components/_adapt/Progress.js +42 -11
- package/components/_adapt/Radio.js +21 -10
- package/components/_adapt/Row.js +18 -7
- package/components/_adapt/Select.js +54 -43
- package/components/_adapt/Slider.js +1 -1
- package/components/_adapt/Space.js +2 -2
- package/components/_adapt/Table.js +16 -5
- package/components/_adapt/Tabs.js +17 -6
- package/components/_adapt/Tag.js +19 -8
- package/components/_adapt/Tooltip.js +15 -4
- package/components/_adapt/TreeSelect.js +18 -7
- package/components/_adapt/notification.js +1 -1
- package/components/_adapt/todo/Image.js +2 -2
- package/components/_adapt/todo/NotEffectOnV15.js +1 -1
- package/components/_adapt/todo/Segmented.js +2 -2
- package/components/_adapt/utils.js +28 -8
- package/components/_common/AutoComplete.js +101 -34
- package/components/_common/CountUp.js +30 -14
- package/components/_common/DateRange.d.ts +10 -2
- package/components/_common/DateRange.js +65 -69
- package/components/_common/HighLight.js +22 -6
- package/components/_common/I18N.js +27 -2
- package/components/_common/Loading.js +25 -9
- package/components/_common/MonthRange.js +26 -26
- package/components/_common/PromiseLabel.js +68 -15
- package/components/_common/Role.js +2 -2
- package/components/_common/Upagination.js +45 -34
- package/components/_setup/Const.js +2 -2
- package/components/_setup/I18N/enUS.js +2 -2
- package/components/_setup/I18N/zhCN.js +3 -3
- package/components/_setup/I18N/zhHK.js +2 -2
- package/components/_setup/ICON/IconTypes.js +2 -2
- package/components/_setup/SearchField/SearchFieldAdvance.js +22 -11
- package/components/_setup/SearchField/SearchFieldDate.js +116 -79
- package/components/_setup/SearchField/SearchFieldInput.js +21 -10
- package/components/_setup/SearchField/SearchFieldSelect.js +55 -44
- package/components/_setup/SearchField/SearchFieldTree.js +63 -52
- package/components/_setup/SelectBar/SelectList.js +21 -10
- package/components/_setup/SelectBar/SelectTree.js +17 -6
- package/components/_setup/UForm/UFormAdvanceInput.js +105 -78
- package/components/_setup/UForm/UFormCOTree.js +21 -10
- package/components/_setup/UForm/UFormCrontab.js +51 -35
- package/components/_setup/UForm/UFormDate.js +160 -124
- package/components/_setup/UForm/UFormInput.js +113 -72
- package/components/_setup/UForm/UFormJSON.js +95 -57
- package/components/_setup/UForm/UFormJSONTable.js +79 -41
- package/components/_setup/UForm/UFormOrg.js +112 -48
- package/components/_setup/UForm/UFormRole.js +31 -20
- package/components/_setup/UForm/UFormSelect.js +116 -86
- package/components/_setup/UForm/UFormTree.js +52 -41
- package/components/_setup/UForm/UFormUpload.js +62 -34
- package/components/_setup/UForm/_utils.js +9 -9
- package/deps/JsonView.js +18 -7
- package/deps/SpringBoot.js +1 -1
- package/deps/SpringCloud.js +4 -4
- package/deps/_editor/advance/_Image.js +33 -20
- package/deps/_editor/base/Element.js +28 -17
- package/deps/_editor/base/Leaf.js +18 -7
- package/deps/_editor/base/Support.js +4 -4
- package/deps/_editor/i18n.js +1 -1
- package/deps/_editor/tools/Button.js +31 -19
- package/deps/_editor/tools/ToolBar.js +3 -3
- package/deps/_editor/tools/_BlockButton.js +49 -27
- package/deps/_editor/tools/_InsertButton.js +32 -28
- package/deps/_editor/tools/_MarkButton.js +15 -14
- package/deps/_editor/tools/_TxtButton.js +90 -58
- package/deps/api-audit.js +1 -1
- package/deps/echarts.js +65 -18
- package/deps/editor.js +52 -26
- package/deps/registerEditor.js +18 -7
- package/hooks/_list.js +1 -1
- package/hooks/useAjax.js +43 -19
- package/hooks/useAjaxAction.js +57 -20
- package/hooks/useAjaxQuery.js +121 -51
- package/hooks/useApi.js +35 -8
- package/hooks/useApiBase.js +291 -184
- package/hooks/useApiGlobal.js +40 -13
- package/hooks/useApp.js +4 -4
- package/hooks/useArray.js +114 -52
- package/hooks/useDefault.js +19 -3
- package/hooks/useDoLoad.js +25 -9
- package/hooks/useEffectFunction.js +4 -3
- package/hooks/useEffectOnce.js +5 -5
- package/hooks/useError.js +21 -5
- package/hooks/useFirstMountState.js +3 -3
- package/hooks/useGenkey.js +7 -7
- package/hooks/useGetSet.js +9 -9
- package/hooks/useGlobal.js +58 -29
- package/hooks/useHover.js +25 -9
- package/hooks/useMemoPromise.js +62 -22
- package/hooks/useModals.js +71 -36
- package/hooks/useMountedState.js +6 -6
- package/hooks/useOpenState.js +26 -10
- package/hooks/usePromise.js +15 -13
- package/hooks/useQueue.js +35 -8
- package/hooks/useSetState.js +25 -8
- package/hooks/useStateList.js +30 -18
- package/hooks/useSyncExternalStore.js +31 -15
- package/hooks/useToggle.js +6 -3
- package/hooks/useUnmountPromise.js +11 -11
- package/hooks/useUpdate.js +20 -4
- package/hooks/useUpdateEffect.js +5 -5
- package/login/Base65.js +15 -14
- package/login/Password.js +91 -38
- package/login/SM4.js +50 -49
- package/login/cems/index.js +2 -2
- package/login/jit/index.js +16 -71
- package/login/jit/pnxclient.js +6 -4
- package/login/vap/index.js +1 -1
- package/login/xrtx/index.js +2 -2
- package/package.json +1 -1
- package/screen/Comment.js +16 -5
- package/screen/Page.js +14 -14
- package/screen/render.js +2 -2
- package/uform/FormEditor.js +43 -26
- package/uform/FormViewer.js +30 -19
- package/uform/hooks/useEditor.js +83 -47
- package/uform/hooks/useForm.js +2 -2
- package/uform/index.js +10 -10
- package/uform/inputs/_advance.js +12 -12
- package/uform/inputs/_date.js +63 -52
- package/uform/inputs/_input.js +49 -38
- package/uform/inputs/_select.js +53 -42
- package/uform/inputs/_specific.js +33 -22
- package/uform/inputs/index.js +5 -5
- package/uform/inputs/register.js +14 -14
- package/uform/panel/Editor/GroupEditor.js +31 -31
- package/uform/panel/Editor/ListEditor.js +22 -22
- package/uform/panel/Editor/_FieldItems.js +16 -16
- package/uform/panel/Editor/_GroupCollapse.js +9 -9
- package/uform/panel/Editor/_GroupDefault.js +9 -9
- package/uform/panel/Editor/_GroupStep.js +18 -18
- package/uform/panel/Editor/_GroupTab.js +16 -16
- package/uform/panel/Editor/index.js +17 -17
- package/uform/panel/Items/index.js +22 -11
- package/uform/panel/Propreties/CanvasProperties.js +14 -14
- package/uform/panel/Propreties/Component/FieldPlugin.js +5 -5
- package/uform/panel/Propreties/Component/LinkAsyncFunction.js +22 -47
- package/uform/panel/Propreties/Component/LinkSyncFunction.js +20 -43
- package/uform/panel/Propreties/Component/Links.js +40 -29
- package/uform/panel/Propreties/Component/OptionTable.js +97 -52
- package/uform/panel/Propreties/Component/RegexpModal.js +11 -11
- package/uform/panel/Propreties/Component/Validate.js +35 -24
- package/uform/panel/Propreties/Component/ValidateAsyncFunction.js +13 -24
- package/uform/panel/Propreties/Component/ValidateSyncFunction.js +15 -38
- package/uform/panel/Propreties/FieldOptions.js +78 -44
- package/uform/panel/Propreties/FieldProperties.js +47 -20
- package/uform/panel/Propreties/GroupProperties.js +9 -9
- package/uform/panel/Propreties/_ItemAdvance.js +37 -26
- package/uform/panel/Propreties/_ItemBase.js +30 -19
- package/uform/panel/Propreties/_ItemLink.js +20 -9
- package/uform/panel/Propreties/_ItemValidate.js +33 -22
- package/uform/plugins/index.js +7 -7
- package/uform/utils/Convert.js +137 -94
- package/uform/utils/SchemaConvert.js +43 -68
- package/uform/utils/arr.js +103 -75
- package/utils/Ajax.d.ts +1 -11
- package/utils/Ajax.js +154 -68
- package/utils/ArrayUtil.js +14 -12
- package/utils/CacheUtil.js +19 -13
- package/utils/Const.js +13 -13
- package/utils/CustomApp.js +15 -10
- package/utils/EventUtil.js +78 -14
- package/utils/Format.js +59 -38
- package/utils/Global.js +8 -8
- package/utils/Logger.js +56 -11
- package/utils/PageUtil.d.ts +12 -6
- package/utils/PageUtil.js +105 -35
- package/utils/Renders/ApiGetRender.js +187 -100
- package/utils/Renders/ApiPostRender.js +123 -69
- package/utils/Renders/DateRender.js +9 -9
- package/utils/Renders/DictRender.js +82 -55
- package/utils/Renders/FileRender.js +34 -12
- package/utils/Renders/ListRender.js +21 -21
- package/utils/Renders/NumberRender.js +14 -13
- package/utils/Renders/StatusRender.js +20 -20
- package/utils/Renders/StringRender.js +17 -17
- package/utils/Renders/_define.d.ts +2 -2
- package/utils/Renders/_define.js +7 -7
- package/utils/StringUtil.js +98 -67
- package/utils/TreeUtil.js +71 -20
- package/utils/VAP.js +14 -14
- package/utils/XHR.js +27 -11
- package/utils/_AjaxUtil.d.ts +10 -0
- package/utils/_AjaxUtil.js +35 -12
- package/utils/_Support.js +26 -26
- package/utils/i18n.js +78 -44
- package/utils/index.d.ts +9 -1
- package/utils/index.js +34 -5
- package/utils/screenful.js +82 -29
- package/widget/index.js +4 -4
package/hooks/useMemoPromise.js
CHANGED
|
@@ -8,34 +8,74 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
11
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
39
|
exports.useMemoPromise = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
var react_1 = require("react");
|
|
41
|
+
var useUpdate_1 = require("./useUpdate");
|
|
42
|
+
var useEffectFunction_1 = require("./useEffectFunction");
|
|
16
43
|
/**
|
|
17
44
|
* 说明, useMemoPromise 在值没有返回时, value 是 null 如用于解构则报错 ,
|
|
18
45
|
* 如 const [loading,{a,b}] = useMemoPromise<{a:boolen,b:string}>();
|
|
19
46
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(0, useEffectFunction_1.useEffectFunction)(()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
var useMemoPromise = function (factory, deps) {
|
|
48
|
+
var ref = (0, react_1.useRef)([true, null, null]);
|
|
49
|
+
var update = (0, useUpdate_1.useUpdate)();
|
|
50
|
+
(0, useEffectFunction_1.useEffectFunction)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
var result, e_1;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
ref.current[0] = true;
|
|
56
|
+
update();
|
|
57
|
+
_a.label = 1;
|
|
58
|
+
case 1:
|
|
59
|
+
_a.trys.push([1, 3, , 4]);
|
|
60
|
+
return [4 /*yield*/, factory()];
|
|
61
|
+
case 2:
|
|
62
|
+
result = _a.sent();
|
|
63
|
+
;
|
|
64
|
+
ref.current[1] = result;
|
|
65
|
+
ref.current[2] = null;
|
|
66
|
+
return [3 /*break*/, 4];
|
|
67
|
+
case 3:
|
|
68
|
+
e_1 = _a.sent();
|
|
69
|
+
// ref.current[1] = null;
|
|
70
|
+
ref.current[2] = e_1;
|
|
71
|
+
return [3 /*break*/, 4];
|
|
72
|
+
case 4:
|
|
73
|
+
ref.current[0] = false;
|
|
74
|
+
update();
|
|
75
|
+
return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); }, deps);
|
|
39
79
|
return ref.current;
|
|
40
80
|
;
|
|
41
81
|
};
|
package/hooks/useModals.js
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
2
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
30
|
exports.useModals = void 0;
|
|
4
|
-
|
|
31
|
+
var react_1 = require("react");
|
|
5
32
|
/**
|
|
6
33
|
* useModals 提供了常用页面处理弹框的一个快捷封装
|
|
7
34
|
* 用于 添加、编辑 数据 ,及查看数据详情的 UModal
|
|
@@ -9,15 +36,15 @@ const react_1 = require("react");
|
|
|
9
36
|
*
|
|
10
37
|
* 此Hook 没有提供任何数据操作,通常与 useApi返回的模型结合使用。
|
|
11
38
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
39
|
+
var useModals = function () {
|
|
40
|
+
var _a = __read((0, react_1.useState)({
|
|
14
41
|
modalProps: {
|
|
15
42
|
open: false, data: null, isEdit: false,
|
|
16
|
-
onCancel: (extra)
|
|
17
|
-
setState(prev
|
|
18
|
-
|
|
43
|
+
onCancel: function (extra) {
|
|
44
|
+
setState(function (prev) {
|
|
45
|
+
var result = {
|
|
19
46
|
open: false, openDetail: false, openUpload: false, isEdit: false, data: prev.data,
|
|
20
|
-
modalProps:
|
|
47
|
+
modalProps: __assign(__assign({}, prev.modalProps), { open: false })
|
|
21
48
|
};
|
|
22
49
|
if (extra !== undefined)
|
|
23
50
|
result.extra = extra;
|
|
@@ -31,68 +58,76 @@ const useModals = () => {
|
|
|
31
58
|
isEdit: false,
|
|
32
59
|
data: {},
|
|
33
60
|
extra: null,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
61
|
+
}), 2), modalState = _a[0], setState = _a[1];
|
|
62
|
+
var hide = function (extra) { return setState(function (prev) {
|
|
63
|
+
var result = {
|
|
37
64
|
open: false, openDetail: false, openUpload: false, isEdit: false, data: prev.data,
|
|
38
|
-
modalProps:
|
|
65
|
+
modalProps: __assign(__assign({}, prev.modalProps), { open: false, isEdit: false, data: null })
|
|
39
66
|
};
|
|
40
67
|
if (extra !== undefined)
|
|
41
68
|
result.extra = extra;
|
|
42
69
|
return result;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
open: true, openDetail: false, openUpload: false, isEdit: false,
|
|
47
|
-
|
|
70
|
+
}); };
|
|
71
|
+
var showInfo = function (data, extra) { return setState(function (prev) {
|
|
72
|
+
var result = {
|
|
73
|
+
open: true, openDetail: false, openUpload: false, isEdit: false,
|
|
74
|
+
data: data,
|
|
75
|
+
modalProps: __assign(__assign({}, prev.modalProps), { open: true, data: data, isEdit: false })
|
|
48
76
|
};
|
|
49
77
|
if (extra !== undefined)
|
|
50
78
|
result.extra = extra;
|
|
51
79
|
return result;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
|
|
80
|
+
}); };
|
|
81
|
+
var showAdd = function (extra) { return setState(function (prev) {
|
|
82
|
+
var result = {
|
|
55
83
|
open: true, openDetail: false, openUpload: false, data: null, isEdit: false,
|
|
56
|
-
modalProps:
|
|
84
|
+
modalProps: __assign(__assign({}, prev.modalProps), { open: true, data: null, isEdit: false })
|
|
57
85
|
};
|
|
58
86
|
if (extra !== undefined)
|
|
59
87
|
result.extra = extra;
|
|
60
88
|
return result;
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
open: true, openDetail: false, openUpload: false,
|
|
65
|
-
|
|
89
|
+
}); };
|
|
90
|
+
var showEdit = function (data, extra) { return setState(function (prev) {
|
|
91
|
+
var result = {
|
|
92
|
+
open: true, openDetail: false, openUpload: false,
|
|
93
|
+
data: data,
|
|
94
|
+
isEdit: true,
|
|
95
|
+
modalProps: __assign(__assign({}, prev.modalProps), { open: true, data: data, isEdit: true })
|
|
66
96
|
};
|
|
67
97
|
if (data !== undefined)
|
|
68
98
|
result.data = data;
|
|
69
99
|
if (extra !== undefined)
|
|
70
100
|
result.extra = extra;
|
|
71
101
|
return result;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
}); };
|
|
103
|
+
var showUpload = function (extra) { return setState(function (prev) {
|
|
104
|
+
var result = {
|
|
75
105
|
open: false, openDetail: false, openUpload: true, data: prev.data, isEdit: false,
|
|
76
|
-
modalProps:
|
|
106
|
+
modalProps: __assign(__assign({}, prev.modalProps), { open: false })
|
|
77
107
|
};
|
|
78
108
|
if (extra !== undefined)
|
|
79
109
|
result.extra = extra;
|
|
80
110
|
return result;
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
|
|
111
|
+
}); };
|
|
112
|
+
var showDetail = function (data, extra) { return setState(function (prev) {
|
|
113
|
+
var result = {
|
|
84
114
|
open: false, openDetail: true, openUpload: false, data: prev.data, isEdit: false,
|
|
85
|
-
modalProps:
|
|
115
|
+
modalProps: __assign(__assign({}, prev.modalProps), { open: false })
|
|
86
116
|
};
|
|
87
117
|
if (data !== undefined)
|
|
88
118
|
result.data = data;
|
|
89
119
|
if (extra !== undefined)
|
|
90
120
|
result.extra = extra;
|
|
91
121
|
return result;
|
|
92
|
-
});
|
|
122
|
+
}); };
|
|
93
123
|
return {
|
|
94
|
-
modalState,
|
|
95
|
-
hide
|
|
124
|
+
modalState: modalState,
|
|
125
|
+
hide: hide,
|
|
126
|
+
showInfo: showInfo,
|
|
127
|
+
showAdd: showAdd,
|
|
128
|
+
showEdit: showEdit,
|
|
129
|
+
showUpload: showUpload,
|
|
130
|
+
showDetail: showDetail,
|
|
96
131
|
};
|
|
97
132
|
};
|
|
98
133
|
exports.useModals = useModals;
|
package/hooks/useMountedState.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useMountedState = void 0;
|
|
4
|
-
|
|
4
|
+
var react_1 = require("react");
|
|
5
5
|
/**
|
|
6
6
|
* 使用方法参考
|
|
7
7
|
* https://github.com/streamich/react-use/blob/master/docs/useMountedState.md
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(0, react_1.useEffect)(()
|
|
9
|
+
var useMountedState = function () {
|
|
10
|
+
var mountedRef = (0, react_1.useRef)(false);
|
|
11
|
+
var get = (0, react_1.useCallback)(function () { return mountedRef.current; }, []);
|
|
12
|
+
(0, react_1.useEffect)(function () {
|
|
13
13
|
mountedRef.current = true;
|
|
14
|
-
return ()
|
|
14
|
+
return function () {
|
|
15
15
|
mountedRef.current = false;
|
|
16
16
|
};
|
|
17
17
|
}, []);
|
package/hooks/useOpenState.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
2
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
19
|
exports.useOpenState = void 0;
|
|
4
|
-
|
|
20
|
+
var react_1 = require("react");
|
|
5
21
|
/**
|
|
6
22
|
* 一个打开,关闭的 hook
|
|
7
23
|
* 通用用于 Modal, Drawer, PopHover, DrowDown 等组件
|
|
8
24
|
* 除了 open属性外,可额外携带两个数据
|
|
9
25
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
26
|
+
var useOpenState = function () {
|
|
27
|
+
var _a = __read((0, react_1.useState)([false, {}, null]), 2), _b = __read(_a[0], 3), open = _b[0], data = _b[1], extra = _b[2], setState = _a[1];
|
|
12
28
|
return {
|
|
13
|
-
open,
|
|
14
|
-
data,
|
|
15
|
-
extra,
|
|
16
|
-
show: (data, extra)
|
|
17
|
-
|
|
29
|
+
open: open,
|
|
30
|
+
data: data,
|
|
31
|
+
extra: extra,
|
|
32
|
+
show: function (data, extra) { return setState(function (prev) {
|
|
33
|
+
var ext = extra === undefined ? prev[2] : extra;
|
|
18
34
|
return [true, data, ext];
|
|
19
|
-
}),
|
|
20
|
-
hide: ()
|
|
35
|
+
}); },
|
|
36
|
+
hide: function () { return setState(function (prev) { return [false, prev[1], prev[2]]; }); },
|
|
21
37
|
};
|
|
22
38
|
};
|
|
23
39
|
exports.useOpenState = useOpenState;
|
package/hooks/usePromise.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.usePromise = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var useMountedState_1 = require("./useMountedState");
|
|
6
6
|
/**
|
|
7
7
|
* 使用方法参考
|
|
8
8
|
* https://github.com/streamich/react-use/blob/master/docs/usePromise.md
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return (0, react_1.useCallback)((promise)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
var usePromise = function () {
|
|
11
|
+
var isMounted = (0, useMountedState_1.useMountedState)();
|
|
12
|
+
return (0, react_1.useCallback)(function (promise) {
|
|
13
|
+
return new Promise(function (resolve, reject) {
|
|
14
|
+
var onValue = function (value) {
|
|
15
|
+
isMounted() && resolve(value);
|
|
16
|
+
};
|
|
17
|
+
var onError = function (error) {
|
|
18
|
+
isMounted() && reject(error);
|
|
19
|
+
};
|
|
20
|
+
promise.then(onValue, onError);
|
|
21
|
+
});
|
|
22
|
+
}, []);
|
|
21
23
|
};
|
|
22
24
|
exports.usePromise = usePromise;
|
package/hooks/useQueue.js
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
2
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
28
|
exports.useQueue = void 0;
|
|
4
|
-
|
|
29
|
+
var react_1 = require("react");
|
|
5
30
|
/**
|
|
6
31
|
* 使用方法参考
|
|
7
32
|
* https://github.com/streamich/react-use/blob/master/docs/useQueue.md
|
|
8
33
|
* */
|
|
9
|
-
|
|
10
|
-
|
|
34
|
+
var useQueue = function (initialValue) {
|
|
35
|
+
if (initialValue === void 0) { initialValue = []; }
|
|
36
|
+
var _a = __read((0, react_1.useState)(initialValue), 2), state = _a[0], set = _a[1];
|
|
11
37
|
return {
|
|
12
|
-
add: (value)
|
|
13
|
-
set((queue)
|
|
38
|
+
add: function (value) {
|
|
39
|
+
set(function (queue) { return __spreadArray(__spreadArray([], __read(queue), false), [value], false); });
|
|
14
40
|
},
|
|
15
|
-
remove: ()
|
|
16
|
-
|
|
17
|
-
set((
|
|
41
|
+
remove: function () {
|
|
42
|
+
var result;
|
|
43
|
+
set(function (_a) {
|
|
44
|
+
var _b = __read(_a), first = _b[0], rest = _b.slice(1);
|
|
18
45
|
result = first;
|
|
19
46
|
return rest;
|
|
20
47
|
});
|
package/hooks/useSetState.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
2
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
19
|
exports.useSetState = void 0;
|
|
4
|
-
|
|
20
|
+
var react_1 = require("react");
|
|
5
21
|
/**
|
|
6
22
|
* 使用方法参考
|
|
7
23
|
* https://github.com/streamich/react-use/blob/master/docs/useSetState.md
|
|
@@ -10,17 +26,18 @@ const react_1 = require("react");
|
|
|
10
26
|
* 扩展点 2: 支持 callBack
|
|
11
27
|
*
|
|
12
28
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
var useSetState = function (initialState) {
|
|
30
|
+
if (initialState === void 0) { initialState = {}; }
|
|
31
|
+
var _a = __read((0, react_1.useState)(initialState), 2), state = _a[0], set = _a[1];
|
|
32
|
+
var setState = function (patch, callback) { return set(function (prevState) {
|
|
33
|
+
var next = patch instanceof Function ? patch(prevState) : patch;
|
|
17
34
|
if (next == null)
|
|
18
35
|
return prevState;
|
|
19
|
-
|
|
36
|
+
var nextState = Object.assign({}, prevState, next);
|
|
20
37
|
if (callback)
|
|
21
|
-
setTimeout(()
|
|
38
|
+
setTimeout(function () { return callback(nextState); }, 1);
|
|
22
39
|
return nextState;
|
|
23
|
-
});
|
|
40
|
+
}); };
|
|
24
41
|
return [state, setState];
|
|
25
42
|
};
|
|
26
43
|
exports.useSetState = useSetState;
|
package/hooks/useStateList.js
CHANGED
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.useStateList = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
var react_1 = require("react");
|
|
16
|
+
var useMountedState_1 = require("./useMountedState");
|
|
17
|
+
var useUpdateEffect_1 = require("./useUpdateEffect");
|
|
18
|
+
var useUpdate_1 = require("./useUpdate");
|
|
8
19
|
/**
|
|
9
20
|
* 使用方法参考
|
|
10
21
|
* https://github.com/streamich/react-use/blob/master/docs/useStateList.md
|
|
11
22
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
var useStateList = function (stateSet) {
|
|
24
|
+
if (stateSet === void 0) { stateSet = []; }
|
|
25
|
+
var isMounted = (0, useMountedState_1.useMountedState)();
|
|
26
|
+
var update = (0, useUpdate_1.useUpdate)();
|
|
27
|
+
var index = (0, react_1.useRef)(0);
|
|
16
28
|
// If new state list is shorter that before - switch to the last element
|
|
17
|
-
(0, useUpdateEffect_1.useUpdateEffect)(()
|
|
29
|
+
(0, useUpdateEffect_1.useUpdateEffect)(function () {
|
|
18
30
|
if (stateSet.length <= index.current) {
|
|
19
31
|
index.current = stateSet.length - 1;
|
|
20
32
|
update();
|
|
21
33
|
}
|
|
22
34
|
}, [stateSet.length]);
|
|
23
|
-
|
|
24
|
-
next: ()
|
|
25
|
-
prev: ()
|
|
26
|
-
setStateAt: (newIndex)
|
|
35
|
+
var actions = (0, react_1.useMemo)(function () { return ({
|
|
36
|
+
next: function () { return actions.setStateAt(index.current + 1); },
|
|
37
|
+
prev: function () { return actions.setStateAt(index.current - 1); },
|
|
38
|
+
setStateAt: function (newIndex) {
|
|
27
39
|
// do nothing on unmounted component
|
|
28
40
|
if (!isMounted())
|
|
29
41
|
return;
|
|
@@ -42,18 +54,18 @@ const useStateList = (stateSet = []) => {
|
|
|
42
54
|
: stateSet.length + (newIndex % stateSet.length);
|
|
43
55
|
update();
|
|
44
56
|
},
|
|
45
|
-
setState: (state)
|
|
57
|
+
setState: function (state) {
|
|
46
58
|
// do nothing on unmounted component
|
|
47
59
|
if (!isMounted())
|
|
48
60
|
return;
|
|
49
|
-
|
|
61
|
+
var newIndex = stateSet.length ? stateSet.indexOf(state) : -1;
|
|
50
62
|
if (newIndex === -1) {
|
|
51
|
-
throw new Error(
|
|
63
|
+
throw new Error("State '".concat(state, "' is not a valid state (does not exist in state list)"));
|
|
52
64
|
}
|
|
53
65
|
index.current = newIndex;
|
|
54
66
|
update();
|
|
55
67
|
},
|
|
56
|
-
}), [stateSet]);
|
|
57
|
-
return
|
|
68
|
+
}); }, [stateSet]);
|
|
69
|
+
return __assign({ state: stateSet[index.current], currentIndex: index.current }, actions);
|
|
58
70
|
};
|
|
59
71
|
exports.useStateList = useStateList;
|
|
@@ -1,34 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// import { globalDefault } from '../utils/_Support';
|
|
3
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o), r, ar = [], e;
|
|
7
|
+
try {
|
|
8
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
9
|
+
}
|
|
10
|
+
catch (error) { e = { error: error }; }
|
|
11
|
+
finally {
|
|
12
|
+
try {
|
|
13
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
14
|
+
}
|
|
15
|
+
finally { if (e) throw e.error; }
|
|
16
|
+
}
|
|
17
|
+
return ar;
|
|
18
|
+
};
|
|
3
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
20
|
exports.useSyncExternalStore = void 0;
|
|
5
21
|
// export const useSyncExternalStore = globalDefault<UseSyncExternalStore>('useSyncExternalStore' as any, (s, g, t) => { return {} as any });
|
|
6
22
|
// https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
var _is = function (x, y) { return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y); };
|
|
24
|
+
var is = typeof Object.is === 'function' ? Object.is : _is;
|
|
25
|
+
var react_1 = require("react");
|
|
26
|
+
var useSyncExternalStore = function (subscribe, getSnapshot, getServerSnapshot) {
|
|
27
|
+
var value = getSnapshot();
|
|
28
|
+
var _a = __read((0, react_1.useState)({ inst: { value: value, getSnapshot: getSnapshot } }), 2), inst = _a[0].inst, forceUpdate = _a[1];
|
|
13
29
|
// Track the latest getSnapshot function with a ref. This needs to be updated
|
|
14
30
|
// in the layout phase so we can access it during the tearing check that
|
|
15
31
|
// happens on subscribe.
|
|
16
|
-
(0, react_1.useLayoutEffect)(()
|
|
32
|
+
(0, react_1.useLayoutEffect)(function () {
|
|
17
33
|
inst.value = value;
|
|
18
34
|
inst.getSnapshot = getSnapshot;
|
|
19
35
|
if (checkIfSnapshotChanged(inst)) {
|
|
20
36
|
// Force a re-render.
|
|
21
|
-
forceUpdate({ inst });
|
|
37
|
+
forceUpdate({ inst: inst });
|
|
22
38
|
}
|
|
23
39
|
}, [subscribe, value, getSnapshot]);
|
|
24
|
-
(0, react_1.useEffect)(()
|
|
40
|
+
(0, react_1.useEffect)(function () {
|
|
25
41
|
// Check for changes right before subscribing. Subsequent changes will be
|
|
26
42
|
// detected in the subscription handler.
|
|
27
43
|
if (checkIfSnapshotChanged(inst)) {
|
|
28
44
|
// Force a re-render.
|
|
29
|
-
forceUpdate({ inst });
|
|
45
|
+
forceUpdate({ inst: inst });
|
|
30
46
|
}
|
|
31
|
-
|
|
47
|
+
var handleStoreChange = function () {
|
|
32
48
|
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
33
49
|
// up to the consumer of this library to wrap their subscription event
|
|
34
50
|
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
@@ -37,7 +53,7 @@ const useSyncExternalStore = (subscribe, getSnapshot, getServerSnapshot) => {
|
|
|
37
53
|
// read from the store.
|
|
38
54
|
if (checkIfSnapshotChanged(inst)) {
|
|
39
55
|
// Force a re-render.
|
|
40
|
-
forceUpdate({ inst });
|
|
56
|
+
forceUpdate({ inst: inst });
|
|
41
57
|
}
|
|
42
58
|
};
|
|
43
59
|
// Subscribe to the store and return a clean-up function.
|
|
@@ -48,10 +64,10 @@ const useSyncExternalStore = (subscribe, getSnapshot, getServerSnapshot) => {
|
|
|
48
64
|
};
|
|
49
65
|
exports.useSyncExternalStore = useSyncExternalStore;
|
|
50
66
|
function checkIfSnapshotChanged(inst) {
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
68
|
+
var prevValue = inst.value;
|
|
53
69
|
try {
|
|
54
|
-
|
|
70
|
+
var nextValue = latestGetSnapshot();
|
|
55
71
|
return !is(prevValue, nextValue);
|
|
56
72
|
}
|
|
57
73
|
catch (error) {
|