@tachybase/client 0.23.48 → 1.0.6
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/api-client/APIClient.d.ts +5 -2
- package/es/api-client/APIClient.mjs +93 -49
- package/es/api-client/hooks/useRequest.d.ts +2 -0
- package/es/application/Application.d.ts +6 -0
- package/es/application/Application.mjs +19 -0
- package/es/application/CustomRouterContextProvider.d.ts +54 -0
- package/es/application/CustomRouterContextProvider.mjs +209 -0
- package/es/application/RouterManager.d.ts +8 -3
- package/es/application/RouterManager.mjs +48 -15
- package/es/application/hooks/index.d.ts +1 -0
- package/es/application/hooks/index.mjs +1 -0
- package/es/application/hooks/useGlobalVariable.d.ts +1 -0
- package/es/application/hooks/useGlobalVariable.mjs +18 -0
- package/es/application/schema-initializer/context/index.d.ts +1 -1
- package/es/application/schema-settings/hooks/index.d.ts +1 -1
- package/es/application/schema-settings/hooks/index.mjs +6 -8
- package/es/block-provider/hooks/index.d.ts +2 -0
- package/es/block-provider/hooks/index.mjs +29 -22
- package/es/built-in/context-menu/ContextMenu.provider.mjs +6 -6
- package/es/built-in/context-menu/ContextMenuItemsProps.d.ts +4 -4
- package/es/built-in/context-menu/ContextMenuItemsProps.mjs +6 -6
- package/es/built-in/context-menu/index.mjs +1 -1
- package/es/built-in/context-menu/useContextMenu.d.ts +2 -2
- package/es/built-in/index.mjs +8 -0
- package/es/built-in/locale/LocalePlugin.mjs +5 -1
- package/es/built-in/page-style/PageStyle.provider.mjs +2 -2
- package/es/built-in/system-settings/SystemSettingsProvider.d.ts +2 -3
- package/es/built-in/system-settings/SystemSettingsProvider.mjs +4 -3
- package/es/built-in/system-settings/SystemSettingsShortcut.mjs +11 -8
- package/es/collection-manager/Configuration/AddCollectionAction.mjs +12 -2
- package/es/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.d.ts +2 -0
- package/es/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.mjs +255 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.d.ts +89 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.mjs +96 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.d.ts +3 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.mjs +47 -0
- package/es/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.d.ts +3 -0
- package/es/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.mjs +44 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.mjs +380 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.d.ts +8 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.mjs +4 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxImportAction.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxImportAction.mjs +187 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.mjs +30 -0
- package/es/collection-manager/collectionPlugin.mjs +3 -1
- package/es/collection-manager/templates/import.mjs +1 -1
- package/es/collection-manager/templates/sql.d.ts +1 -1
- package/es/collection-manager/templates/view.d.ts +1 -1
- package/es/collection-manager/templates/xlsx.d.ts +11 -0
- package/es/collection-manager/templates/xlsx.mjs +19 -0
- package/es/data-source/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/data-source/collection-field-interface/CollectionFieldInterface.mjs +18 -0
- package/es/data-source/collection-field-interface/CollectionFieldInterfaceManager.d.ts +8 -1
- package/es/data-source/collection-field-interface/CollectionFieldInterfaceManager.mjs +20 -0
- package/es/data-source/commonsSettingsItem/fieldComponent.mjs +3 -1
- package/es/data-source/data-source/DataSource.d.ts +1 -1
- package/es/filter-provider/utils.mjs +6 -0
- package/es/i18n/i18n.mjs +7 -12
- package/es/modules/actions/delete/deleteActionSettings.mjs +10 -0
- package/es/modules/blocks/data-blocks/form/FilterItemCustomSettings.mjs +1 -1
- package/es/modules/blocks/data-blocks/form/fieldSettingsFormItem.mjs +9 -4
- package/es/modules/blocks/data-blocks/table/hooks/useTableBlockProps.mjs +6 -4
- package/es/modules/blocks/data-blocks/table/tableBlockSettings.mjs +4 -0
- package/es/modules/blocks/data-blocks/table/tableColumnSettings.mjs +44 -0
- package/es/modules/blocks/filter-blocks/collapse/filterCollapseItemFieldSettings.mjs +4 -0
- package/es/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.mjs +9 -0
- package/es/modules/fields/component/Radio/radioComponentFieldSettings.mjs +0 -4
- package/es/modules/fields/component/SubTable/secondLevelSelect.d.ts +11 -0
- package/es/modules/fields/component/SubTable/secondLevelSelect.mjs +102 -0
- package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.d.ts +79 -41
- package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.mjs +103 -100
- package/es/powered-by/index.mjs +4 -7
- package/es/schema-component/antd/action/Action.Designer.mjs +43 -5
- package/es/schema-component/antd/action/Action.Modal.mjs +19 -31
- package/es/schema-component/antd/action/Action.Modal.style.d.ts +4 -0
- package/es/schema-component/antd/action/Action.Modal.style.mjs +35 -0
- package/es/schema-component/antd/action/Action.mjs +1 -3
- package/es/schema-component/antd/action/utils.d.ts +1 -1
- package/es/schema-component/antd/action/utils.mjs +70 -70
- package/es/schema-component/antd/association-field/SubTabs/InternalCollapse.mjs +2 -1
- package/es/schema-component/antd/checkbox/Checkbox.mjs +9 -2
- package/es/schema-component/antd/index.d.ts +1 -0
- package/es/schema-component/antd/index.mjs +1 -0
- package/es/schema-component/antd/media-card/MediaCard.d.ts +11 -0
- package/es/schema-component/antd/media-card/MediaCard.mjs +35 -0
- package/es/schema-component/antd/media-card/index.d.ts +1 -0
- package/es/schema-component/antd/media-card/index.mjs +1 -0
- package/es/schema-component/antd/media-card/style.d.ts +3 -0
- package/es/schema-component/antd/media-card/style.mjs +25 -0
- package/es/schema-component/antd/page/Page.d.ts +1 -5
- package/es/schema-component/antd/page/Page.mjs +235 -144
- package/es/schema-component/antd/page/Page.style.d.ts +5 -0
- package/es/schema-component/antd/page/Page.style.mjs +45 -0
- package/es/schema-component/antd/page/PageDesigner.d.ts +3 -0
- package/es/schema-component/antd/page/PageDesigner.mjs +28 -0
- package/es/schema-component/antd/page/PageTabDesigner.d.ts +0 -3
- package/es/schema-component/antd/page/PageTabDesigner.mjs +3 -50
- package/es/schema-component/antd/page/style.d.ts +1 -1
- package/es/schema-component/antd/page/style.mjs +3 -13
- package/es/schema-component/antd/password/Password.d.ts +1 -1
- package/es/schema-component/antd/password/utils.d.ts +1 -1
- package/es/schema-component/antd/scroll-area/ScrollArea.d.ts +1 -1
- package/es/schema-component/antd/scroll-area/ScrollArea.mjs +2 -1
- package/es/schema-component/antd/variable/TextArea.mjs +1 -1
- package/es/schema-component/antd/variable/TextAreaWithGlobalScope.d.ts +13 -0
- package/es/schema-component/antd/variable/TextAreaWithGlobalScope.mjs +59 -0
- package/es/schema-component/antd/variable/index.d.ts +1 -0
- package/es/schema-component/antd/variable/index.mjs +3 -0
- package/es/schema-component/common/dnd-context/index.mjs +1 -7
- package/es/schema-component/common/sortable-item/DragHandlePageTab.d.ts +1 -0
- package/es/schema-component/common/sortable-item/DragHandlePageTab.mjs +71 -0
- package/es/schema-component/common/sortable-item/DragHandlePageTab.style.d.ts +3 -0
- package/es/schema-component/common/sortable-item/DragHandlePageTab.style.mjs +25 -0
- package/es/schema-items/GeneralSettings.mjs +5 -0
- package/es/schema-settings/EditCustomDefaultValue.mjs +1 -1
- package/es/schema-settings/SchemaSettings.mjs +1 -1
- package/es/schema-settings/SchemaSettingsDefaultValue.mjs +2 -0
- package/es/schema-settings/utils/createModalSettingsItem.d.ts +26 -0
- package/es/schema-settings/utils/createModalSettingsItem.mjs +46 -0
- package/es/schema-settings/utils/createSelectSettingsItem.d.ts +25 -0
- package/es/schema-settings/utils/createSelectSettingsItem.mjs +40 -0
- package/es/schema-settings/utils/createSwitchSettingsItem.d.ts +21 -0
- package/es/schema-settings/utils/createSwitchSettingsItem.mjs +38 -0
- package/es/schema-settings/utils/createTextSettingsItem.d.ts +9 -0
- package/es/schema-settings/utils/createTextSettingsItem.mjs +21 -0
- package/es/schema-settings/utils/index.d.ts +4 -0
- package/es/schema-settings/utils/index.mjs +4 -0
- package/es/schema-settings/utils/util.d.ts +12 -0
- package/es/schema-settings/utils/util.mjs +24 -0
- package/es/user/CurrentUserProvider.mjs +6 -3
- package/lib/api-client/APIClient.js +93 -49
- package/lib/application/Application.js +19 -0
- package/lib/application/CustomRouterContextProvider.js +276 -0
- package/lib/application/RouterManager.js +49 -15
- package/lib/application/hooks/index.js +9 -0
- package/lib/application/hooks/useGlobalVariable.js +52 -0
- package/lib/application/schema-initializer/hooks/index.js +2 -2
- package/lib/application/schema-settings/hooks/index.js +6 -8
- package/lib/block-provider/hooks/index.js +80 -59
- package/lib/built-in/context-menu/ContextMenu.provider.js +6 -6
- package/lib/built-in/context-menu/ContextMenuItemsProps.js +6 -6
- package/lib/built-in/context-menu/index.js +1 -1
- package/lib/built-in/index.js +8 -0
- package/lib/built-in/locale/LocalePlugin.js +5 -1
- package/lib/built-in/page-style/PageStyle.provider.js +2 -2
- package/lib/built-in/system-settings/SystemSettingsProvider.js +4 -3
- package/lib/built-in/system-settings/SystemSettingsShortcut.js +11 -8
- package/lib/collection-manager/Configuration/AddCollectionAction.js +12 -2
- package/lib/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.js +304 -0
- package/lib/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.js +130 -0
- package/lib/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.js +81 -0
- package/lib/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.js +78 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.js +414 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.js +53 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxImportAction.js +235 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.js +64 -0
- package/lib/collection-manager/collectionPlugin.js +3 -1
- package/lib/collection-manager/templates/import.js +1 -1
- package/lib/collection-manager/templates/xlsx.js +53 -0
- package/lib/data-source/collection-field-interface/CollectionFieldInterface.js +18 -0
- package/lib/data-source/collection-field-interface/CollectionFieldInterfaceManager.js +20 -0
- package/lib/data-source/commonsSettingsItem/fieldComponent.js +3 -1
- package/lib/filter-provider/utils.js +6 -0
- package/lib/i18n/i18n.js +7 -12
- package/lib/locale/en_US.js +1 -0
- package/lib/locale/zh-CN.js +14 -2
- package/lib/modules/actions/delete/deleteActionSettings.js +10 -0
- package/lib/modules/blocks/data-blocks/form/FilterItemCustomSettings.js +1 -1
- package/lib/modules/blocks/data-blocks/form/fieldSettingsFormItem.js +9 -4
- package/lib/modules/blocks/data-blocks/table/hooks/useTableBlockProps.js +6 -4
- package/lib/modules/blocks/data-blocks/table/tableBlockSettings.js +4 -0
- package/lib/modules/blocks/data-blocks/table/tableColumnSettings.js +44 -0
- package/lib/modules/blocks/filter-blocks/collapse/filterCollapseItemFieldSettings.js +4 -0
- package/lib/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.js +9 -0
- package/lib/modules/fields/component/Radio/radioComponentFieldSettings.js +0 -4
- package/lib/modules/fields/component/SubTable/secondLevelSelect.js +136 -0
- package/lib/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.js +104 -103
- package/lib/powered-by/index.js +4 -7
- package/lib/schema-component/antd/action/Action.Designer.js +43 -5
- package/lib/schema-component/antd/action/Action.Modal.js +19 -31
- package/lib/schema-component/antd/action/Action.Modal.style.js +69 -0
- package/lib/schema-component/antd/action/Action.js +1 -3
- package/lib/schema-component/antd/action/utils.js +70 -70
- package/lib/schema-component/antd/association-field/SubTabs/InternalCollapse.js +2 -1
- package/lib/schema-component/antd/checkbox/Checkbox.js +9 -2
- package/lib/schema-component/antd/index.js +18 -4
- package/lib/schema-component/antd/media-card/MediaCard.js +69 -0
- package/lib/schema-component/antd/media-card/index.js +65 -0
- package/lib/schema-component/antd/media-card/style.js +59 -0
- package/lib/schema-component/antd/page/Page.js +235 -144
- package/lib/schema-component/antd/page/Page.style.js +79 -0
- package/lib/schema-component/antd/page/PageDesigner.js +62 -0
- package/lib/schema-component/antd/page/PageTabDesigner.js +2 -50
- package/lib/schema-component/antd/page/style.js +3 -13
- package/lib/schema-component/antd/scroll-area/ScrollArea.js +2 -1
- package/lib/schema-component/antd/variable/TextArea.js +1 -1
- package/lib/schema-component/antd/variable/TextAreaWithGlobalScope.js +94 -0
- package/lib/schema-component/antd/variable/index.js +13 -1
- package/lib/schema-component/common/dnd-context/index.js +1 -7
- package/lib/schema-component/common/sortable-item/DragHandlePageTab.js +105 -0
- package/lib/schema-component/common/sortable-item/DragHandlePageTab.style.js +59 -0
- package/lib/schema-items/GeneralSettings.js +5 -0
- package/lib/schema-settings/EditCustomDefaultValue.js +1 -1
- package/lib/schema-settings/SchemaSettings.js +1 -1
- package/lib/schema-settings/SchemaSettingsDefaultValue.js +2 -0
- package/lib/schema-settings/utils/createModalSettingsItem.js +94 -0
- package/lib/schema-settings/utils/createSelectSettingsItem.js +88 -0
- package/lib/schema-settings/utils/createSwitchSettingsItem.js +86 -0
- package/lib/schema-settings/utils/createTextSettingsItem.js +55 -0
- package/lib/schema-settings/utils/index.js +92 -0
- package/lib/schema-settings/utils/util.js +74 -0
- package/lib/user/CurrentUserProvider.js +6 -3
- package/package.json +7 -7
|
@@ -7,9 +7,12 @@ export declare class APIClient extends APIClientSDK {
|
|
|
7
7
|
app: Application;
|
|
8
8
|
/** 该值会在 AntdAppProvider 中被重新赋值 */
|
|
9
9
|
notification: any;
|
|
10
|
-
|
|
10
|
+
cloneInstance(): APIClient;
|
|
11
11
|
getHeaders(): {};
|
|
12
|
+
service(uid: string): Result<any, any>;
|
|
12
13
|
interceptors(): void;
|
|
14
|
+
toErrMessages(error: any): any;
|
|
15
|
+
handleNotificationError(error: any): Promise<any>;
|
|
13
16
|
useNotificationMiddleware(): void;
|
|
14
|
-
silent():
|
|
17
|
+
silent(): APIClient;
|
|
15
18
|
}
|
|
@@ -15,7 +15,9 @@ function notify(type, messages, instance) {
|
|
|
15
15
|
var _messages_map;
|
|
16
16
|
if (!(null == messages ? void 0 : messages.length)) return;
|
|
17
17
|
instance[type]({
|
|
18
|
-
message: null === (_messages_map = messages.map) || void 0 === _messages_map ? void 0 : _messages_map.call(messages, (item)=>__WEBPACK_EXTERNAL_MODULE_react__["default"].createElement('div', {
|
|
18
|
+
message: null === (_messages_map = messages.map) || void 0 === _messages_map ? void 0 : _messages_map.call(messages, (item, index)=>__WEBPACK_EXTERNAL_MODULE_react__["default"].createElement('div', {
|
|
19
|
+
key: "".concat(index, "_").concat(item.message)
|
|
20
|
+
}, 'string' == typeof item ? item : item.message))
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
const handleErrorMessage = (error, notification)=>{
|
|
@@ -27,7 +29,6 @@ const handleErrorMessage = (error, notification)=>{
|
|
|
27
29
|
notify('error', messages, notification);
|
|
28
30
|
};
|
|
29
31
|
};
|
|
30
|
-
const errorCache = new Map();
|
|
31
32
|
function offsetToTimeZone(offset) {
|
|
32
33
|
const hours = Math.floor(Math.abs(offset));
|
|
33
34
|
const minutes = Math.abs(offset % 1 * 60);
|
|
@@ -40,40 +41,114 @@ const getCurrentTimezone = ()=>{
|
|
|
40
41
|
const timezoneOffset = new Date().getTimezoneOffset() / -60;
|
|
41
42
|
return offsetToTimeZone(timezoneOffset);
|
|
42
43
|
};
|
|
44
|
+
const errorCache = new Map();
|
|
43
45
|
class APIClient extends __WEBPACK_EXTERNAL_MODULE__tachybase_sdk__.APIClient {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
cloneInstance() {
|
|
47
|
+
const api = new APIClient(this.options);
|
|
48
|
+
api.options = this.options;
|
|
49
|
+
api.services = this.services;
|
|
50
|
+
api.storage = this.storage;
|
|
51
|
+
api.app = this.app;
|
|
52
|
+
api.auth = this.auth;
|
|
53
|
+
api.notification = this.notification;
|
|
54
|
+
const handlers = [];
|
|
55
|
+
for (const handler of this.axios.interceptors.response['handlers'])if ('handleNotificationError' === handler.rejected['_name']) handlers.push({
|
|
56
|
+
...handler,
|
|
57
|
+
rejected: api.handleNotificationError.bind(api)
|
|
58
|
+
});
|
|
59
|
+
else handlers.push(handler);
|
|
60
|
+
api.axios.interceptors.response['handlers'] = handlers;
|
|
61
|
+
return api;
|
|
46
62
|
}
|
|
47
63
|
getHeaders() {
|
|
48
|
-
var _window_location, _window;
|
|
64
|
+
var _this_app, _window_location, _window;
|
|
49
65
|
const headers = super.getHeaders();
|
|
50
|
-
const appName = this.app.getName();
|
|
66
|
+
const appName = null === (_this_app = this.app) || void 0 === _this_app ? void 0 : _this_app.getName();
|
|
51
67
|
if (appName) headers['X-App'] = appName;
|
|
52
68
|
headers['X-Timezone'] = getCurrentTimezone();
|
|
53
69
|
headers['X-Hostname'] = null === (_window = window) || void 0 === _window ? void 0 : null === (_window_location = _window.location) || void 0 === _window_location ? void 0 : _window_location.hostname;
|
|
54
70
|
return headers;
|
|
55
71
|
}
|
|
72
|
+
service(uid) {
|
|
73
|
+
return this.services[uid];
|
|
74
|
+
}
|
|
56
75
|
interceptors() {
|
|
57
76
|
this.axios.interceptors.request.use((config)=>{
|
|
58
77
|
config.headers['X-With-ACL-Meta'] = true;
|
|
59
|
-
const
|
|
60
|
-
|
|
78
|
+
const headers = this.getHeaders();
|
|
79
|
+
Object.keys(headers).forEach((key)=>{
|
|
80
|
+
config.headers[key] = config.headers[key] || headers[key];
|
|
81
|
+
});
|
|
61
82
|
return config;
|
|
62
83
|
});
|
|
63
84
|
super.interceptors();
|
|
64
85
|
this.useNotificationMiddleware();
|
|
65
86
|
this.axios.interceptors.response.use((response)=>response, (error)=>{
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
const errs = this.toErrMessages(error);
|
|
88
|
+
if (errs.find((error)=>'ROLE_NOT_FOUND_ERR' === error.code)) {
|
|
89
|
+
this.auth.setRole(null);
|
|
90
|
+
window.location.reload();
|
|
91
|
+
}
|
|
92
|
+
if (errs.find((error)=>'TOKEN_INVALID' === error.code || 'USER_LOCKED' === error.code)) this.auth.setToken(null);
|
|
93
|
+
if (errs.find((error)=>'ROLE_NOT_FOUND_FOR_USER' === error.code)) {
|
|
94
|
+
this.auth.setRole(null);
|
|
95
|
+
window.location.reload();
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
toErrMessages(error) {
|
|
101
|
+
var _error_response, _error_response_data, _error_response1, _error_response_data1, _error_response2, _error_response3;
|
|
102
|
+
if ('string' == typeof (null == error ? void 0 : null === (_error_response = error.response) || void 0 === _error_response ? void 0 : _error_response.data)) {
|
|
103
|
+
var _error_response4;
|
|
104
|
+
const tempElement = document.createElement('div');
|
|
105
|
+
tempElement.innerHTML = null == error ? void 0 : null === (_error_response4 = error.response) || void 0 === _error_response4 ? void 0 : _error_response4.data;
|
|
106
|
+
return [
|
|
68
107
|
{
|
|
69
|
-
message:
|
|
108
|
+
message: tempElement.textContent || tempElement.innerText
|
|
70
109
|
}
|
|
71
110
|
];
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
111
|
+
}
|
|
112
|
+
return (null == error ? void 0 : null === (_error_response1 = error.response) || void 0 === _error_response1 ? void 0 : null === (_error_response_data = _error_response1.data) || void 0 === _error_response_data ? void 0 : _error_response_data.errors) || (null == error ? void 0 : null === (_error_response2 = error.response) || void 0 === _error_response2 ? void 0 : null === (_error_response_data1 = _error_response2.data) || void 0 === _error_response_data1 ? void 0 : _error_response_data1.messages) || (null == error ? void 0 : null === (_error_response3 = error.response) || void 0 === _error_response3 ? void 0 : _error_response3.error) || [
|
|
113
|
+
{
|
|
114
|
+
message: error.message || 'Server error'
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
async handleNotificationError(error) {
|
|
119
|
+
var _error_config, _error_response_data, _error_response, _error_response_data1, _error_response1;
|
|
120
|
+
if (this.silence) throw error;
|
|
121
|
+
const skipNotify = null === (_error_config = error.config) || void 0 === _error_config ? void 0 : _error_config.skipNotify;
|
|
122
|
+
if (skipNotify && ('function' == typeof skipNotify && skipNotify(error) || true === skipNotify)) throw error;
|
|
123
|
+
const redirectTo = null == error ? void 0 : null === (_error_response = error.response) || void 0 === _error_response ? void 0 : null === (_error_response_data = _error_response.data) || void 0 === _error_response_data ? void 0 : _error_response_data.redirectTo;
|
|
124
|
+
if (redirectTo) return window.location.href = redirectTo;
|
|
125
|
+
if ((null == error ? void 0 : null === (_error_response1 = error.response) || void 0 === _error_response1 ? void 0 : null === (_error_response_data1 = _error_response1.data) || void 0 === _error_response_data1 ? void 0 : _error_response_data1.type) === 'application/json') handleErrorMessage(error, this.notification);
|
|
126
|
+
else {
|
|
127
|
+
var _error_response_data_error, _error_response_data2, _error_response2;
|
|
128
|
+
if (errorCache.size > 10) errorCache.clear();
|
|
129
|
+
const maintaining = !!(null == error ? void 0 : null === (_error_response2 = error.response) || void 0 === _error_response2 ? void 0 : null === (_error_response_data2 = _error_response2.data) || void 0 === _error_response_data2 ? void 0 : null === (_error_response_data_error = _error_response_data2.error) || void 0 === _error_response_data_error ? void 0 : _error_response_data_error.maintaining);
|
|
130
|
+
if (this.app.maintaining !== maintaining) this.app.maintaining = maintaining;
|
|
131
|
+
if (this.app.maintaining) {
|
|
132
|
+
var _error_response_data3, _error_response3;
|
|
133
|
+
this.app.error = null == error ? void 0 : null === (_error_response3 = error.response) || void 0 === _error_response3 ? void 0 : null === (_error_response_data3 = _error_response3.data) || void 0 === _error_response_data3 ? void 0 : _error_response_data3.error;
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
if (this.app.error) this.app.error = null;
|
|
137
|
+
let errs = this.toErrMessages(error);
|
|
138
|
+
errs = errs.filter((error)=>{
|
|
139
|
+
const lastTime = errorCache.get(error.message);
|
|
140
|
+
if (lastTime && new Date().getTime() - lastTime < 500) return false;
|
|
141
|
+
errorCache.set(error.message, new Date().getTime());
|
|
142
|
+
return true;
|
|
143
|
+
});
|
|
144
|
+
if (0 === errs.length) throw error;
|
|
145
|
+
notify('error', errs, this.notification);
|
|
146
|
+
}
|
|
147
|
+
throw error;
|
|
75
148
|
}
|
|
76
149
|
useNotificationMiddleware() {
|
|
150
|
+
const errorHandler = this.handleNotificationError.bind(this);
|
|
151
|
+
errorHandler['_name'] = 'handleNotificationError';
|
|
77
152
|
this.axios.interceptors.response.use((response)=>{
|
|
78
153
|
var _response_data_messages, _response_data;
|
|
79
154
|
if (null === (_response_data = response.data) || void 0 === _response_data ? void 0 : null === (_response_data_messages = _response_data.messages) || void 0 === _response_data_messages ? void 0 : _response_data_messages.length) {
|
|
@@ -86,43 +161,12 @@ class APIClient extends __WEBPACK_EXTERNAL_MODULE__tachybase_sdk__.APIClient {
|
|
|
86
161
|
notify('success', messages, this.notification);
|
|
87
162
|
}
|
|
88
163
|
return response;
|
|
89
|
-
},
|
|
90
|
-
var _error_response_data, _error_response, _error_response_data1, _error_response1;
|
|
91
|
-
if (this.silence) throw error;
|
|
92
|
-
const redirectTo = null == error ? void 0 : null === (_error_response = error.response) || void 0 === _error_response ? void 0 : null === (_error_response_data = _error_response.data) || void 0 === _error_response_data ? void 0 : _error_response_data.redirectTo;
|
|
93
|
-
if (redirectTo) return window.location.href = redirectTo;
|
|
94
|
-
if ((null == error ? void 0 : null === (_error_response1 = error.response) || void 0 === _error_response1 ? void 0 : null === (_error_response_data1 = _error_response1.data) || void 0 === _error_response_data1 ? void 0 : _error_response_data1.type) === 'application/json') handleErrorMessage(error, this.notification);
|
|
95
|
-
else {
|
|
96
|
-
var _error_response_data_error, _error_response_data2, _error_response2, _error_response_data3, _error_response3, _error_response_data4, _error_response4;
|
|
97
|
-
if (errorCache.size > 10) errorCache.clear();
|
|
98
|
-
const maintaining = !!(null == error ? void 0 : null === (_error_response2 = error.response) || void 0 === _error_response2 ? void 0 : null === (_error_response_data2 = _error_response2.data) || void 0 === _error_response_data2 ? void 0 : null === (_error_response_data_error = _error_response_data2.error) || void 0 === _error_response_data_error ? void 0 : _error_response_data_error.maintaining);
|
|
99
|
-
if (this.app.maintaining !== maintaining) this.app.maintaining = maintaining;
|
|
100
|
-
if (this.app.maintaining) {
|
|
101
|
-
var _error_response_data5, _error_response5;
|
|
102
|
-
this.app.error = null == error ? void 0 : null === (_error_response5 = error.response) || void 0 === _error_response5 ? void 0 : null === (_error_response_data5 = _error_response5.data) || void 0 === _error_response_data5 ? void 0 : _error_response_data5.error;
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
105
|
-
if (this.app.error) this.app.error = null;
|
|
106
|
-
let errs = (null == error ? void 0 : null === (_error_response3 = error.response) || void 0 === _error_response3 ? void 0 : null === (_error_response_data3 = _error_response3.data) || void 0 === _error_response_data3 ? void 0 : _error_response_data3.errors) || (null == error ? void 0 : null === (_error_response4 = error.response) || void 0 === _error_response4 ? void 0 : null === (_error_response_data4 = _error_response4.data) || void 0 === _error_response_data4 ? void 0 : _error_response_data4.messages) || [
|
|
107
|
-
{
|
|
108
|
-
message: 'Server error'
|
|
109
|
-
}
|
|
110
|
-
];
|
|
111
|
-
errs = errs.filter((error)=>{
|
|
112
|
-
const lastTime = errorCache.get(error.message);
|
|
113
|
-
if (lastTime && new Date().getTime() - lastTime < 500) return false;
|
|
114
|
-
errorCache.set(error.message, new Date().getTime());
|
|
115
|
-
return true;
|
|
116
|
-
});
|
|
117
|
-
if (0 === errs.length) throw error;
|
|
118
|
-
notify('error', errs, this.notification);
|
|
119
|
-
}
|
|
120
|
-
throw error;
|
|
121
|
-
});
|
|
164
|
+
}, errorHandler);
|
|
122
165
|
}
|
|
123
166
|
silent() {
|
|
124
|
-
|
|
125
|
-
|
|
167
|
+
const api = this.cloneInstance();
|
|
168
|
+
api.silence = true;
|
|
169
|
+
return api;
|
|
126
170
|
}
|
|
127
171
|
constructor(...args){
|
|
128
172
|
super(...args), _define_property(this, "services", {}), _define_property(this, "silence", false), _define_property(this, "app", void 0), _define_property(this, "notification", __WEBPACK_EXTERNAL_MODULE_antd__.notification);
|
|
@@ -9,6 +9,8 @@ export type ResourceActionOptions<P = any> = {
|
|
|
9
9
|
action?: string;
|
|
10
10
|
params?: P;
|
|
11
11
|
url?: string;
|
|
12
|
+
skipNotify?: boolean | ((error: any) => boolean);
|
|
13
|
+
skipAuth?: boolean;
|
|
12
14
|
};
|
|
13
15
|
export type UseRequestService<P> = AxiosRequestConfig<P> | ResourceActionOptions<P> | FunctionService;
|
|
14
16
|
export type UseRequestOptions = Options<any, any> & {
|
|
@@ -3,6 +3,7 @@ import { type RequireJS } from '@tachybase/requirejs';
|
|
|
3
3
|
import { APIClientOptions } from '@tachybase/sdk';
|
|
4
4
|
import { i18n as i18next } from 'i18next';
|
|
5
5
|
import { APIClient } from '../api-client';
|
|
6
|
+
import { CollectionFieldInterfaceComponentOption } from '../data-source';
|
|
6
7
|
import { DataSourceManager, type DataSourceManagerOptions } from '../data-source/data-source/DataSourceManager';
|
|
7
8
|
import { AttachmentPreviewManager, PluginAttachmentItemsOptions } from './AttachmentPreviewManager';
|
|
8
9
|
import { NoticeManager } from './NoticesManager';
|
|
@@ -70,6 +71,7 @@ export declare class Application {
|
|
|
70
71
|
pluginContextMenu: PluginContextMenu;
|
|
71
72
|
AttachmentPreviewManager: AttachmentPreviewManager;
|
|
72
73
|
name: string;
|
|
74
|
+
globalVars: Record<string, any>;
|
|
73
75
|
loading: boolean;
|
|
74
76
|
maintained: boolean;
|
|
75
77
|
maintaining: boolean;
|
|
@@ -86,6 +88,7 @@ export declare class Application {
|
|
|
86
88
|
getName(): string;
|
|
87
89
|
getApiUrl(pathname?: string): string;
|
|
88
90
|
getRouteUrl(pathname: string): string;
|
|
91
|
+
getHref(pathname: string): string;
|
|
89
92
|
getCollectionManager(dataSource?: string): import("..").CollectionManager;
|
|
90
93
|
/**
|
|
91
94
|
* @internal
|
|
@@ -105,4 +108,7 @@ export declare class Application {
|
|
|
105
108
|
addScopes(scopes: Record<string, any>): void;
|
|
106
109
|
getRootComponent(): () => import("react/jsx-runtime").JSX.Element;
|
|
107
110
|
mount(containerOrSelector: Element | ShadowRoot | string): import("react-dom/client").Root;
|
|
111
|
+
addFieldInterfaceComponentOption(fieldName: string, componentOption: CollectionFieldInterfaceComponentOption): void;
|
|
112
|
+
addGlobalVar(key: string, value: any): void;
|
|
113
|
+
getGlobalVar(key: any): any;
|
|
108
114
|
}
|
|
@@ -108,6 +108,11 @@ class Application {
|
|
|
108
108
|
getRouteUrl(pathname) {
|
|
109
109
|
return this.options.publicPath.replace(/\/$/g, '') + pathname;
|
|
110
110
|
}
|
|
111
|
+
getHref(pathname) {
|
|
112
|
+
const name = this.name;
|
|
113
|
+
if (name && 'main' !== name) return this.getPublicPath() + 'apps/' + name + '/' + pathname.replace(/^\//g, '');
|
|
114
|
+
return this.getPublicPath() + pathname.replace(/^\//g, '');
|
|
115
|
+
}
|
|
111
116
|
getCollectionManager(dataSource) {
|
|
112
117
|
var _this_dataSourceManager_getDataSource;
|
|
113
118
|
return null === (_this_dataSourceManager_getDataSource = this.dataSourceManager.getDataSource(dataSource)) || void 0 === _this_dataSourceManager_getDataSource ? void 0 : _this_dataSourceManager_getDataSource.collectionManager;
|
|
@@ -239,6 +244,15 @@ class Application {
|
|
|
239
244
|
root.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(App, {}));
|
|
240
245
|
return root;
|
|
241
246
|
}
|
|
247
|
+
addFieldInterfaceComponentOption(fieldName, componentOption) {
|
|
248
|
+
return this.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaceComponentOption(fieldName, componentOption);
|
|
249
|
+
}
|
|
250
|
+
addGlobalVar(key, value) {
|
|
251
|
+
(0, __WEBPACK_EXTERNAL_MODULE_lodash__.set)(this.globalVars, key, value);
|
|
252
|
+
}
|
|
253
|
+
getGlobalVar(key) {
|
|
254
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_lodash__.get)(this.globalVars, key);
|
|
255
|
+
}
|
|
242
256
|
constructor(options = {}){
|
|
243
257
|
_define_property(this, "options", void 0);
|
|
244
258
|
_define_property(this, "providers", void 0);
|
|
@@ -261,6 +275,7 @@ class Application {
|
|
|
261
275
|
_define_property(this, "pluginContextMenu", void 0);
|
|
262
276
|
_define_property(this, "AttachmentPreviewManager", void 0);
|
|
263
277
|
_define_property(this, "name", void 0);
|
|
278
|
+
_define_property(this, "globalVars", void 0);
|
|
264
279
|
_define_property(this, "loading", void 0);
|
|
265
280
|
_define_property(this, "maintained", void 0);
|
|
266
281
|
_define_property(this, "maintaining", void 0);
|
|
@@ -274,6 +289,7 @@ class Application {
|
|
|
274
289
|
...__WEBPACK_EXTERNAL_MODULE__schema_initializer_components_index_mjs__,
|
|
275
290
|
CollectionField: __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_CollectionField_mjs__.CollectionField
|
|
276
291
|
};
|
|
292
|
+
this.globalVars = {};
|
|
277
293
|
this.loading = true;
|
|
278
294
|
this.maintained = false;
|
|
279
295
|
this.maintaining = false;
|
|
@@ -307,6 +323,9 @@ class Application {
|
|
|
307
323
|
this.name = this.options.name || (0, __WEBPACK_EXTERNAL_MODULE__tachybase_sdk__.getSubAppName)(options.publicPath) || 'main';
|
|
308
324
|
this.pluginContextMenu = new __WEBPACK_EXTERNAL_MODULE__PluginContextMenu_mjs__.PluginContextMenu(options.pluginMenuItems);
|
|
309
325
|
this.AttachmentPreviewManager = new __WEBPACK_EXTERNAL_MODULE__AttachmentPreviewManager_mjs__.AttachmentPreviewManager(options.attachmentItem, this);
|
|
326
|
+
this.i18n.on('languageChanged', (lng)=>{
|
|
327
|
+
this.apiClient.auth.locale = lng;
|
|
328
|
+
});
|
|
310
329
|
}
|
|
311
330
|
}
|
|
312
331
|
export { Application };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { Schema } from '@tachybase/schema';
|
|
3
|
+
import { Location, NavigateFunction } from 'react-router-dom';
|
|
4
|
+
export declare const LocationSearchContext: React.Context<string>;
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const CurrentPageUidContext: React.Context<string>;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const CurrentTabUidContext: React.Context<string>;
|
|
13
|
+
export declare const IsSubPageClosedByPageMenuProvider: FC<{
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const CurrentPageUidProvider: FC<{
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const CurrentTabUidProvider: FC<{
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* use `useNavigateNoUpdate` to avoid components re-rendering.
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare const useNavigateNoUpdate: () => NavigateFunction;
|
|
27
|
+
/**
|
|
28
|
+
* use `useLocationNoUpdate` to avoid components re-rendering.
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare const useLocationNoUpdate: () => Location<any>;
|
|
32
|
+
export declare const useLocationSearch: () => string;
|
|
33
|
+
export declare const useIsAdminPage: () => boolean;
|
|
34
|
+
export declare const useCurrentPageUid: () => string;
|
|
35
|
+
export declare const useMatchAdmin: () => boolean;
|
|
36
|
+
export declare const useMatchAdminName: () => boolean;
|
|
37
|
+
export declare const useIsInSettingsPage: () => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare const useCurrentTabUid: () => string;
|
|
42
|
+
export declare const useCurrentSearchParams: () => URLSearchParams;
|
|
43
|
+
export declare const useRouterBasename: () => string;
|
|
44
|
+
/**
|
|
45
|
+
* Used to determine if the user closed the sub-page by clicking on the page menu
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare const useIsSubPageClosedByPageMenu: (fieldSchema: Schema) => {
|
|
49
|
+
isSubPageClosedByPageMenu: () => boolean;
|
|
50
|
+
reset: () => void;
|
|
51
|
+
};
|
|
52
|
+
export declare const CustomRouterContextProvider: FC<{
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
}>;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom__ from "react-router-dom";
|
|
5
|
+
const NavigateNoUpdateContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext(null);
|
|
6
|
+
NavigateNoUpdateContext.displayName = 'NavigateNoUpdateContext';
|
|
7
|
+
const LocationNoUpdateContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext(null);
|
|
8
|
+
LocationNoUpdateContext.displayName = 'LocationNoUpdateContext';
|
|
9
|
+
const LocationSearchContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext('');
|
|
10
|
+
LocationSearchContext.displayName = 'LocationSearchContext';
|
|
11
|
+
const IsAdminPageContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext(false);
|
|
12
|
+
IsAdminPageContext.displayName = 'IsAdminPageContext';
|
|
13
|
+
const CurrentPageUidContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext('');
|
|
14
|
+
CurrentPageUidContext.displayName = 'CurrentPageUidContext';
|
|
15
|
+
const MatchAdminContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext(false);
|
|
16
|
+
MatchAdminContext.displayName = 'MatchAdminContext';
|
|
17
|
+
const MatchAdminNameContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext(false);
|
|
18
|
+
MatchAdminNameContext.displayName = 'MatchAdminNameContext';
|
|
19
|
+
const IsInSettingsPageContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext(false);
|
|
20
|
+
IsInSettingsPageContext.displayName = 'IsInSettingsPageContext';
|
|
21
|
+
const CurrentTabUidContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext('');
|
|
22
|
+
CurrentTabUidContext.displayName = 'CurrentTabUidContext';
|
|
23
|
+
const SearchParamsContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext(new URLSearchParams());
|
|
24
|
+
SearchParamsContext.displayName = 'SearchParamsContext';
|
|
25
|
+
const RouterBasenameContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext('');
|
|
26
|
+
RouterBasenameContext.displayName = 'RouterBasenameContext';
|
|
27
|
+
const IsSubPageClosedByPageMenuContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext({
|
|
28
|
+
isSubPageClosedByPageMenu: ()=>false,
|
|
29
|
+
setFieldSchema: ()=>{},
|
|
30
|
+
reset: ()=>{}
|
|
31
|
+
});
|
|
32
|
+
IsSubPageClosedByPageMenuContext.displayName = 'IsSubPageClosedByPageMenuContext';
|
|
33
|
+
const IsSubPageClosedByPageMenuProvider = (param)=>{
|
|
34
|
+
let { children } = param;
|
|
35
|
+
const params = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useParams)();
|
|
36
|
+
const prevParamsRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)({});
|
|
37
|
+
const [fieldSchema, setFieldSchema] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(null);
|
|
38
|
+
const isSubPageClosedByPageMenu = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
39
|
+
var _fieldSchema_xcomponentprops, _prevParamsRef_current_;
|
|
40
|
+
const result = __WEBPACK_EXTERNAL_MODULE_lodash__["default"].isEmpty(params['*']) && (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.openMode) === 'page' && !!(null === (_prevParamsRef_current_ = prevParamsRef.current['*']) || void 0 === _prevParamsRef_current_ ? void 0 : _prevParamsRef_current_.includes(fieldSchema['x-uid']));
|
|
41
|
+
prevParamsRef.current = params;
|
|
42
|
+
return result;
|
|
43
|
+
}, [
|
|
44
|
+
fieldSchema,
|
|
45
|
+
params
|
|
46
|
+
]);
|
|
47
|
+
const reset = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
48
|
+
prevParamsRef.current = {};
|
|
49
|
+
}, []);
|
|
50
|
+
const value = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
51
|
+
isSubPageClosedByPageMenu,
|
|
52
|
+
setFieldSchema,
|
|
53
|
+
reset
|
|
54
|
+
}), [
|
|
55
|
+
isSubPageClosedByPageMenu,
|
|
56
|
+
reset
|
|
57
|
+
]);
|
|
58
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(IsSubPageClosedByPageMenuContext.Provider, {
|
|
59
|
+
value: value,
|
|
60
|
+
children: children
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const RouterBasenameProvider = (param)=>{
|
|
64
|
+
let { children } = param;
|
|
65
|
+
const basenameOfCurrentRouter = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useHref)('/');
|
|
66
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(RouterBasenameContext.Provider, {
|
|
67
|
+
value: basenameOfCurrentRouter,
|
|
68
|
+
children: children
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const SearchParamsProvider = (param)=>{
|
|
72
|
+
let { children } = param;
|
|
73
|
+
const [searchParams] = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useSearchParams)();
|
|
74
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(SearchParamsContext.Provider, {
|
|
75
|
+
value: searchParams,
|
|
76
|
+
children: children
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const IsInSettingsPageProvider = (param)=>{
|
|
80
|
+
let { children } = param;
|
|
81
|
+
const isInSettingsPage = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useLocation)().pathname.includes('/settings');
|
|
82
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(IsInSettingsPageContext.Provider, {
|
|
83
|
+
value: isInSettingsPage,
|
|
84
|
+
children: children
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const MatchAdminProvider = (param)=>{
|
|
88
|
+
let { children } = param;
|
|
89
|
+
const isMatchAdmin = !!(0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useMatch)('/admin');
|
|
90
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(MatchAdminContext.Provider, {
|
|
91
|
+
value: isMatchAdmin,
|
|
92
|
+
children: children
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const MatchAdminNameProvider = (param)=>{
|
|
96
|
+
let { children } = param;
|
|
97
|
+
const isMatchAdminName = !!(0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useMatch)('/admin/:name');
|
|
98
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(MatchAdminNameContext.Provider, {
|
|
99
|
+
value: isMatchAdminName,
|
|
100
|
+
children: children
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const IsAdminPageProvider = (param)=>{
|
|
104
|
+
let { children } = param;
|
|
105
|
+
const location = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useLocation)();
|
|
106
|
+
const isAdminPage = location.pathname.startsWith('/admin');
|
|
107
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(IsAdminPageContext.Provider, {
|
|
108
|
+
value: isAdminPage,
|
|
109
|
+
children: children
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const CurrentPageUidProvider = (param)=>{
|
|
113
|
+
let { children } = param;
|
|
114
|
+
const params = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useParams)();
|
|
115
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(CurrentPageUidContext.Provider, {
|
|
116
|
+
value: params.name,
|
|
117
|
+
children: children
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const CurrentTabUidProvider = (param)=>{
|
|
121
|
+
let { children } = param;
|
|
122
|
+
const params = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useParams)();
|
|
123
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(CurrentTabUidContext.Provider, {
|
|
124
|
+
value: params.tabUid,
|
|
125
|
+
children: children
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const NavigateNoUpdateProvider = (param)=>{
|
|
129
|
+
let { children } = param;
|
|
130
|
+
const navigate = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useNavigate)();
|
|
131
|
+
const navigateRef = __WEBPACK_EXTERNAL_MODULE_react__["default"].useRef(navigate);
|
|
132
|
+
navigateRef.current = navigate;
|
|
133
|
+
const navigateNoUpdate = __WEBPACK_EXTERNAL_MODULE_react__["default"].useCallback((to, options)=>{
|
|
134
|
+
navigateRef.current(to, options);
|
|
135
|
+
}, []);
|
|
136
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(NavigateNoUpdateContext.Provider, {
|
|
137
|
+
value: navigateNoUpdate,
|
|
138
|
+
children: children
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
const LocationNoUpdateProvider = (param)=>{
|
|
142
|
+
let { children } = param;
|
|
143
|
+
const location = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useLocation)();
|
|
144
|
+
const locationRef = __WEBPACK_EXTERNAL_MODULE_react__["default"].useRef({});
|
|
145
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
146
|
+
Object.assign(locationRef.current, location);
|
|
147
|
+
}, [
|
|
148
|
+
location
|
|
149
|
+
]);
|
|
150
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(LocationNoUpdateContext.Provider, {
|
|
151
|
+
value: locationRef.current,
|
|
152
|
+
children: children
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const LocationSearchProvider = (param)=>{
|
|
156
|
+
let { children } = param;
|
|
157
|
+
const location = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useLocation)();
|
|
158
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(LocationSearchContext.Provider, {
|
|
159
|
+
value: location.search,
|
|
160
|
+
children: children
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
const useNavigateNoUpdate = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(NavigateNoUpdateContext);
|
|
164
|
+
const useLocationNoUpdate = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(LocationNoUpdateContext);
|
|
165
|
+
const useLocationSearch = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(LocationSearchContext);
|
|
166
|
+
const useIsAdminPage = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(IsAdminPageContext);
|
|
167
|
+
const useCurrentPageUid = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(CurrentPageUidContext);
|
|
168
|
+
const useMatchAdmin = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(MatchAdminContext);
|
|
169
|
+
const useMatchAdminName = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(MatchAdminNameContext);
|
|
170
|
+
const useIsInSettingsPage = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(IsInSettingsPageContext);
|
|
171
|
+
const useCurrentTabUid = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(CurrentTabUidContext);
|
|
172
|
+
const useCurrentSearchParams = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(SearchParamsContext);
|
|
173
|
+
const useRouterBasename = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(RouterBasenameContext);
|
|
174
|
+
const useIsSubPageClosedByPageMenu = (fieldSchema)=>{
|
|
175
|
+
const { isSubPageClosedByPageMenu, setFieldSchema, reset } = __WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(IsSubPageClosedByPageMenuContext);
|
|
176
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
177
|
+
setFieldSchema(fieldSchema);
|
|
178
|
+
}, [
|
|
179
|
+
fieldSchema,
|
|
180
|
+
setFieldSchema
|
|
181
|
+
]);
|
|
182
|
+
return {
|
|
183
|
+
isSubPageClosedByPageMenu,
|
|
184
|
+
reset
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
const CustomRouterContextProvider = (param)=>{
|
|
188
|
+
let { children } = param;
|
|
189
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(NavigateNoUpdateProvider, {
|
|
190
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(LocationNoUpdateProvider, {
|
|
191
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(IsAdminPageProvider, {
|
|
192
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(LocationSearchProvider, {
|
|
193
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(MatchAdminProvider, {
|
|
194
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(MatchAdminNameProvider, {
|
|
195
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(SearchParamsProvider, {
|
|
196
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(RouterBasenameProvider, {
|
|
197
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(IsInSettingsPageProvider, {
|
|
198
|
+
children: children
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
export { CurrentPageUidContext, CurrentPageUidProvider, CurrentTabUidContext, CurrentTabUidProvider, CustomRouterContextProvider, IsSubPageClosedByPageMenuProvider, LocationSearchContext, useCurrentPageUid, useCurrentSearchParams, useCurrentTabUid, useIsAdminPage, useIsInSettingsPage, useIsSubPageClosedByPageMenu, useLocationNoUpdate, useLocationSearch, useMatchAdmin, useMatchAdminName, useNavigateNoUpdate, useRouterBasename };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ComponentType } from 'react';
|
|
1
|
+
import React, { ComponentType, PropsWithChildren } from 'react';
|
|
2
2
|
import { BrowserRouterProps, HashRouterProps, MemoryRouterProps, RouteObject } from 'react-router-dom';
|
|
3
3
|
import { Application } from './Application';
|
|
4
4
|
export interface BrowserRouterOptions extends Omit<BrowserRouterProps, 'children'> {
|
|
@@ -12,6 +12,7 @@ export interface MemoryRouterOptions extends Omit<MemoryRouterProps, 'children'>
|
|
|
12
12
|
}
|
|
13
13
|
export type RouterOptions = (HashRouterOptions | BrowserRouterOptions | MemoryRouterOptions) & {
|
|
14
14
|
renderComponent?: RenderComponentType;
|
|
15
|
+
routes?: Record<string, RouteType>;
|
|
15
16
|
};
|
|
16
17
|
export type ComponentTypeAndString<T = any> = ComponentType<T> | string;
|
|
17
18
|
export interface RouteType extends Omit<RouteObject, 'children' | 'Component'> {
|
|
@@ -22,6 +23,10 @@ export declare class RouterManager {
|
|
|
22
23
|
protected routes: Record<string, RouteType>;
|
|
23
24
|
protected options: RouterOptions;
|
|
24
25
|
app: Application;
|
|
26
|
+
private router;
|
|
27
|
+
get basename(): any;
|
|
28
|
+
get state(): any;
|
|
29
|
+
get navigate(): any;
|
|
25
30
|
constructor(options: RouterOptions, app: Application);
|
|
26
31
|
/**
|
|
27
32
|
* @internal
|
|
@@ -34,8 +39,8 @@ export declare class RouterManager {
|
|
|
34
39
|
/**
|
|
35
40
|
* @internal
|
|
36
41
|
*/
|
|
37
|
-
getRouterComponent(): ({ BaseLayout, }: {
|
|
38
|
-
BaseLayout?: ComponentType<any
|
|
42
|
+
getRouterComponent(children?: React.ReactNode): ({ BaseLayout, }: {
|
|
43
|
+
BaseLayout?: React.ComponentType<PropsWithChildren<any>>;
|
|
39
44
|
children?: React.ReactNode;
|
|
40
45
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
41
46
|
add(name: string, route: RouteType): void;
|