@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
|
@@ -33,9 +33,12 @@ const useCurrentRoles = ()=>{
|
|
|
33
33
|
return options;
|
|
34
34
|
};
|
|
35
35
|
const CurrentUserProvider = (props)=>{
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const api = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useAPIClient)();
|
|
37
|
+
const result = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useRequest)(()=>api.request({
|
|
38
|
+
url: '/auth:check',
|
|
39
|
+
skipNotify: true,
|
|
40
|
+
skipAuth: true
|
|
41
|
+
}).then((res)=>null == res ? void 0 : res.data));
|
|
39
42
|
if (result.loading) return;
|
|
40
43
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(CurrentUserContext.Provider, {
|
|
41
44
|
value: result,
|
|
@@ -59,7 +59,9 @@ function notify(type, messages, instance) {
|
|
|
59
59
|
var _messages_map;
|
|
60
60
|
if (!(null == messages ? void 0 : messages.length)) return;
|
|
61
61
|
instance[type]({
|
|
62
|
-
message: null === (_messages_map = messages.map) || void 0 === _messages_map ? void 0 : _messages_map.call(messages, (item)=>external_react_default().createElement('div', {
|
|
62
|
+
message: null === (_messages_map = messages.map) || void 0 === _messages_map ? void 0 : _messages_map.call(messages, (item, index)=>external_react_default().createElement('div', {
|
|
63
|
+
key: "".concat(index, "_").concat(item.message)
|
|
64
|
+
}, 'string' == typeof item ? item : item.message))
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
const handleErrorMessage = (error, notification)=>{
|
|
@@ -71,7 +73,6 @@ const handleErrorMessage = (error, notification)=>{
|
|
|
71
73
|
notify('error', messages, notification);
|
|
72
74
|
};
|
|
73
75
|
};
|
|
74
|
-
const errorCache = new Map();
|
|
75
76
|
function offsetToTimeZone(offset) {
|
|
76
77
|
const hours = Math.floor(Math.abs(offset));
|
|
77
78
|
const minutes = Math.abs(offset % 1 * 60);
|
|
@@ -84,40 +85,114 @@ const getCurrentTimezone = ()=>{
|
|
|
84
85
|
const timezoneOffset = new Date().getTimezoneOffset() / -60;
|
|
85
86
|
return offsetToTimeZone(timezoneOffset);
|
|
86
87
|
};
|
|
88
|
+
const errorCache = new Map();
|
|
87
89
|
class APIClient extends sdk_namespaceObject.APIClient {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
cloneInstance() {
|
|
91
|
+
const api = new APIClient(this.options);
|
|
92
|
+
api.options = this.options;
|
|
93
|
+
api.services = this.services;
|
|
94
|
+
api.storage = this.storage;
|
|
95
|
+
api.app = this.app;
|
|
96
|
+
api.auth = this.auth;
|
|
97
|
+
api.notification = this.notification;
|
|
98
|
+
const handlers = [];
|
|
99
|
+
for (const handler of this.axios.interceptors.response['handlers'])if ('handleNotificationError' === handler.rejected['_name']) handlers.push({
|
|
100
|
+
...handler,
|
|
101
|
+
rejected: api.handleNotificationError.bind(api)
|
|
102
|
+
});
|
|
103
|
+
else handlers.push(handler);
|
|
104
|
+
api.axios.interceptors.response['handlers'] = handlers;
|
|
105
|
+
return api;
|
|
90
106
|
}
|
|
91
107
|
getHeaders() {
|
|
92
|
-
var _window_location, _window;
|
|
108
|
+
var _this_app, _window_location, _window;
|
|
93
109
|
const headers = super.getHeaders();
|
|
94
|
-
const appName = this.app.getName();
|
|
110
|
+
const appName = null === (_this_app = this.app) || void 0 === _this_app ? void 0 : _this_app.getName();
|
|
95
111
|
if (appName) headers['X-App'] = appName;
|
|
96
112
|
headers['X-Timezone'] = getCurrentTimezone();
|
|
97
113
|
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;
|
|
98
114
|
return headers;
|
|
99
115
|
}
|
|
116
|
+
service(uid) {
|
|
117
|
+
return this.services[uid];
|
|
118
|
+
}
|
|
100
119
|
interceptors() {
|
|
101
120
|
this.axios.interceptors.request.use((config)=>{
|
|
102
121
|
config.headers['X-With-ACL-Meta'] = true;
|
|
103
|
-
const
|
|
104
|
-
|
|
122
|
+
const headers = this.getHeaders();
|
|
123
|
+
Object.keys(headers).forEach((key)=>{
|
|
124
|
+
config.headers[key] = config.headers[key] || headers[key];
|
|
125
|
+
});
|
|
105
126
|
return config;
|
|
106
127
|
});
|
|
107
128
|
super.interceptors();
|
|
108
129
|
this.useNotificationMiddleware();
|
|
109
130
|
this.axios.interceptors.response.use((response)=>response, (error)=>{
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
const errs = this.toErrMessages(error);
|
|
132
|
+
if (errs.find((error)=>'ROLE_NOT_FOUND_ERR' === error.code)) {
|
|
133
|
+
this.auth.setRole(null);
|
|
134
|
+
window.location.reload();
|
|
135
|
+
}
|
|
136
|
+
if (errs.find((error)=>'TOKEN_INVALID' === error.code || 'USER_LOCKED' === error.code)) this.auth.setToken(null);
|
|
137
|
+
if (errs.find((error)=>'ROLE_NOT_FOUND_FOR_USER' === error.code)) {
|
|
138
|
+
this.auth.setRole(null);
|
|
139
|
+
window.location.reload();
|
|
140
|
+
}
|
|
141
|
+
throw error;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
toErrMessages(error) {
|
|
145
|
+
var _error_response, _error_response_data, _error_response1, _error_response_data1, _error_response2, _error_response3;
|
|
146
|
+
if ('string' == typeof (null == error ? void 0 : null === (_error_response = error.response) || void 0 === _error_response ? void 0 : _error_response.data)) {
|
|
147
|
+
var _error_response4;
|
|
148
|
+
const tempElement = document.createElement('div');
|
|
149
|
+
tempElement.innerHTML = null == error ? void 0 : null === (_error_response4 = error.response) || void 0 === _error_response4 ? void 0 : _error_response4.data;
|
|
150
|
+
return [
|
|
112
151
|
{
|
|
113
|
-
message:
|
|
152
|
+
message: tempElement.textContent || tempElement.innerText
|
|
114
153
|
}
|
|
115
154
|
];
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
155
|
+
}
|
|
156
|
+
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) || [
|
|
157
|
+
{
|
|
158
|
+
message: error.message || 'Server error'
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
async handleNotificationError(error) {
|
|
163
|
+
var _error_config, _error_response_data, _error_response, _error_response_data1, _error_response1;
|
|
164
|
+
if (this.silence) throw error;
|
|
165
|
+
const skipNotify = null === (_error_config = error.config) || void 0 === _error_config ? void 0 : _error_config.skipNotify;
|
|
166
|
+
if (skipNotify && ('function' == typeof skipNotify && skipNotify(error) || true === skipNotify)) throw error;
|
|
167
|
+
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;
|
|
168
|
+
if (redirectTo) return window.location.href = redirectTo;
|
|
169
|
+
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);
|
|
170
|
+
else {
|
|
171
|
+
var _error_response_data_error, _error_response_data2, _error_response2;
|
|
172
|
+
if (errorCache.size > 10) errorCache.clear();
|
|
173
|
+
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);
|
|
174
|
+
if (this.app.maintaining !== maintaining) this.app.maintaining = maintaining;
|
|
175
|
+
if (this.app.maintaining) {
|
|
176
|
+
var _error_response_data3, _error_response3;
|
|
177
|
+
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;
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
if (this.app.error) this.app.error = null;
|
|
181
|
+
let errs = this.toErrMessages(error);
|
|
182
|
+
errs = errs.filter((error)=>{
|
|
183
|
+
const lastTime = errorCache.get(error.message);
|
|
184
|
+
if (lastTime && new Date().getTime() - lastTime < 500) return false;
|
|
185
|
+
errorCache.set(error.message, new Date().getTime());
|
|
186
|
+
return true;
|
|
187
|
+
});
|
|
188
|
+
if (0 === errs.length) throw error;
|
|
189
|
+
notify('error', errs, this.notification);
|
|
190
|
+
}
|
|
191
|
+
throw error;
|
|
119
192
|
}
|
|
120
193
|
useNotificationMiddleware() {
|
|
194
|
+
const errorHandler = this.handleNotificationError.bind(this);
|
|
195
|
+
errorHandler['_name'] = 'handleNotificationError';
|
|
121
196
|
this.axios.interceptors.response.use((response)=>{
|
|
122
197
|
var _response_data_messages, _response_data;
|
|
123
198
|
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) {
|
|
@@ -130,43 +205,12 @@ class APIClient extends sdk_namespaceObject.APIClient {
|
|
|
130
205
|
notify('success', messages, this.notification);
|
|
131
206
|
}
|
|
132
207
|
return response;
|
|
133
|
-
},
|
|
134
|
-
var _error_response_data, _error_response, _error_response_data1, _error_response1;
|
|
135
|
-
if (this.silence) throw error;
|
|
136
|
-
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;
|
|
137
|
-
if (redirectTo) return window.location.href = redirectTo;
|
|
138
|
-
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);
|
|
139
|
-
else {
|
|
140
|
-
var _error_response_data_error, _error_response_data2, _error_response2, _error_response_data3, _error_response3, _error_response_data4, _error_response4;
|
|
141
|
-
if (errorCache.size > 10) errorCache.clear();
|
|
142
|
-
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);
|
|
143
|
-
if (this.app.maintaining !== maintaining) this.app.maintaining = maintaining;
|
|
144
|
-
if (this.app.maintaining) {
|
|
145
|
-
var _error_response_data5, _error_response5;
|
|
146
|
-
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;
|
|
147
|
-
throw error;
|
|
148
|
-
}
|
|
149
|
-
if (this.app.error) this.app.error = null;
|
|
150
|
-
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) || [
|
|
151
|
-
{
|
|
152
|
-
message: 'Server error'
|
|
153
|
-
}
|
|
154
|
-
];
|
|
155
|
-
errs = errs.filter((error)=>{
|
|
156
|
-
const lastTime = errorCache.get(error.message);
|
|
157
|
-
if (lastTime && new Date().getTime() - lastTime < 500) return false;
|
|
158
|
-
errorCache.set(error.message, new Date().getTime());
|
|
159
|
-
return true;
|
|
160
|
-
});
|
|
161
|
-
if (0 === errs.length) throw error;
|
|
162
|
-
notify('error', errs, this.notification);
|
|
163
|
-
}
|
|
164
|
-
throw error;
|
|
165
|
-
});
|
|
208
|
+
}, errorHandler);
|
|
166
209
|
}
|
|
167
210
|
silent() {
|
|
168
|
-
|
|
169
|
-
|
|
211
|
+
const api = this.cloneInstance();
|
|
212
|
+
api.silence = true;
|
|
213
|
+
return api;
|
|
170
214
|
}
|
|
171
215
|
constructor(...args){
|
|
172
216
|
super(...args), _define_property(this, "services", {}), _define_property(this, "silence", false), _define_property(this, "app", void 0), _define_property(this, "notification", external_antd_namespaceObject.notification);
|
|
@@ -152,6 +152,11 @@ class Application {
|
|
|
152
152
|
getRouteUrl(pathname) {
|
|
153
153
|
return this.options.publicPath.replace(/\/$/g, '') + pathname;
|
|
154
154
|
}
|
|
155
|
+
getHref(pathname) {
|
|
156
|
+
const name = this.name;
|
|
157
|
+
if (name && 'main' !== name) return this.getPublicPath() + 'apps/' + name + '/' + pathname.replace(/^\//g, '');
|
|
158
|
+
return this.getPublicPath() + pathname.replace(/^\//g, '');
|
|
159
|
+
}
|
|
155
160
|
getCollectionManager(dataSource) {
|
|
156
161
|
var _this_dataSourceManager_getDataSource;
|
|
157
162
|
return null === (_this_dataSourceManager_getDataSource = this.dataSourceManager.getDataSource(dataSource)) || void 0 === _this_dataSourceManager_getDataSource ? void 0 : _this_dataSourceManager_getDataSource.collectionManager;
|
|
@@ -283,6 +288,15 @@ class Application {
|
|
|
283
288
|
root.render(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {}));
|
|
284
289
|
return root;
|
|
285
290
|
}
|
|
291
|
+
addFieldInterfaceComponentOption(fieldName, componentOption) {
|
|
292
|
+
return this.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaceComponentOption(fieldName, componentOption);
|
|
293
|
+
}
|
|
294
|
+
addGlobalVar(key, value) {
|
|
295
|
+
(0, external_lodash_namespaceObject.set)(this.globalVars, key, value);
|
|
296
|
+
}
|
|
297
|
+
getGlobalVar(key) {
|
|
298
|
+
return (0, external_lodash_namespaceObject.get)(this.globalVars, key);
|
|
299
|
+
}
|
|
286
300
|
constructor(options = {}){
|
|
287
301
|
_define_property(this, "options", void 0);
|
|
288
302
|
_define_property(this, "providers", void 0);
|
|
@@ -305,6 +319,7 @@ class Application {
|
|
|
305
319
|
_define_property(this, "pluginContextMenu", void 0);
|
|
306
320
|
_define_property(this, "AttachmentPreviewManager", void 0);
|
|
307
321
|
_define_property(this, "name", void 0);
|
|
322
|
+
_define_property(this, "globalVars", void 0);
|
|
308
323
|
_define_property(this, "loading", void 0);
|
|
309
324
|
_define_property(this, "maintained", void 0);
|
|
310
325
|
_define_property(this, "maintaining", void 0);
|
|
@@ -318,6 +333,7 @@ class Application {
|
|
|
318
333
|
...components_index_js_namespaceObject,
|
|
319
334
|
CollectionField: CollectionField_js_namespaceObject.CollectionField
|
|
320
335
|
};
|
|
336
|
+
this.globalVars = {};
|
|
321
337
|
this.loading = true;
|
|
322
338
|
this.maintained = false;
|
|
323
339
|
this.maintaining = false;
|
|
@@ -351,6 +367,9 @@ class Application {
|
|
|
351
367
|
this.name = this.options.name || (0, sdk_namespaceObject.getSubAppName)(options.publicPath) || 'main';
|
|
352
368
|
this.pluginContextMenu = new external_PluginContextMenu_js_namespaceObject.PluginContextMenu(options.pluginMenuItems);
|
|
353
369
|
this.AttachmentPreviewManager = new external_AttachmentPreviewManager_js_namespaceObject.AttachmentPreviewManager(options.attachmentItem, this);
|
|
370
|
+
this.i18n.on('languageChanged', (lng)=>{
|
|
371
|
+
this.apiClient.auth.locale = lng;
|
|
372
|
+
});
|
|
354
373
|
}
|
|
355
374
|
}
|
|
356
375
|
var __webpack_export_target__ = exports;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = function(module) {
|
|
5
|
+
var getter = module && module.__esModule ? function() {
|
|
6
|
+
return module['default'];
|
|
7
|
+
} : function() {
|
|
8
|
+
return module;
|
|
9
|
+
};
|
|
10
|
+
__webpack_require__.d(getter, {
|
|
11
|
+
a: getter
|
|
12
|
+
});
|
|
13
|
+
return getter;
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
18
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = function(obj, prop) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.r = function(exports1) {
|
|
31
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
32
|
+
value: 'Module'
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __webpack_exports__ = {};
|
|
40
|
+
__webpack_require__.r(__webpack_exports__);
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
useCurrentSearchParams: ()=>useCurrentSearchParams,
|
|
43
|
+
useIsInSettingsPage: ()=>useIsInSettingsPage,
|
|
44
|
+
useLocationNoUpdate: ()=>useLocationNoUpdate,
|
|
45
|
+
CurrentTabUidContext: ()=>CurrentTabUidContext,
|
|
46
|
+
useIsSubPageClosedByPageMenu: ()=>useIsSubPageClosedByPageMenu,
|
|
47
|
+
useMatchAdmin: ()=>useMatchAdmin,
|
|
48
|
+
useMatchAdminName: ()=>useMatchAdminName,
|
|
49
|
+
useNavigateNoUpdate: ()=>useNavigateNoUpdate,
|
|
50
|
+
CurrentPageUidContext: ()=>CurrentPageUidContext,
|
|
51
|
+
useCurrentPageUid: ()=>useCurrentPageUid,
|
|
52
|
+
useLocationSearch: ()=>useLocationSearch,
|
|
53
|
+
useRouterBasename: ()=>useRouterBasename,
|
|
54
|
+
LocationSearchContext: ()=>LocationSearchContext,
|
|
55
|
+
IsSubPageClosedByPageMenuProvider: ()=>IsSubPageClosedByPageMenuProvider,
|
|
56
|
+
useIsAdminPage: ()=>useIsAdminPage,
|
|
57
|
+
useCurrentTabUid: ()=>useCurrentTabUid,
|
|
58
|
+
CustomRouterContextProvider: ()=>CustomRouterContextProvider,
|
|
59
|
+
CurrentPageUidProvider: ()=>CurrentPageUidProvider,
|
|
60
|
+
CurrentTabUidProvider: ()=>CurrentTabUidProvider
|
|
61
|
+
});
|
|
62
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
63
|
+
const external_react_namespaceObject = require("react");
|
|
64
|
+
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
65
|
+
const external_lodash_namespaceObject = require("lodash");
|
|
66
|
+
var external_lodash_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_namespaceObject);
|
|
67
|
+
const external_react_router_dom_namespaceObject = require("react-router-dom");
|
|
68
|
+
const NavigateNoUpdateContext = /*#__PURE__*/ external_react_default().createContext(null);
|
|
69
|
+
NavigateNoUpdateContext.displayName = 'NavigateNoUpdateContext';
|
|
70
|
+
const LocationNoUpdateContext = /*#__PURE__*/ external_react_default().createContext(null);
|
|
71
|
+
LocationNoUpdateContext.displayName = 'LocationNoUpdateContext';
|
|
72
|
+
const LocationSearchContext = /*#__PURE__*/ external_react_default().createContext('');
|
|
73
|
+
LocationSearchContext.displayName = 'LocationSearchContext';
|
|
74
|
+
const IsAdminPageContext = /*#__PURE__*/ external_react_default().createContext(false);
|
|
75
|
+
IsAdminPageContext.displayName = 'IsAdminPageContext';
|
|
76
|
+
const CurrentPageUidContext = /*#__PURE__*/ external_react_default().createContext('');
|
|
77
|
+
CurrentPageUidContext.displayName = 'CurrentPageUidContext';
|
|
78
|
+
const MatchAdminContext = /*#__PURE__*/ external_react_default().createContext(false);
|
|
79
|
+
MatchAdminContext.displayName = 'MatchAdminContext';
|
|
80
|
+
const MatchAdminNameContext = /*#__PURE__*/ external_react_default().createContext(false);
|
|
81
|
+
MatchAdminNameContext.displayName = 'MatchAdminNameContext';
|
|
82
|
+
const IsInSettingsPageContext = /*#__PURE__*/ external_react_default().createContext(false);
|
|
83
|
+
IsInSettingsPageContext.displayName = 'IsInSettingsPageContext';
|
|
84
|
+
const CurrentTabUidContext = /*#__PURE__*/ external_react_default().createContext('');
|
|
85
|
+
CurrentTabUidContext.displayName = 'CurrentTabUidContext';
|
|
86
|
+
const SearchParamsContext = /*#__PURE__*/ external_react_default().createContext(new URLSearchParams());
|
|
87
|
+
SearchParamsContext.displayName = 'SearchParamsContext';
|
|
88
|
+
const RouterBasenameContext = /*#__PURE__*/ external_react_default().createContext('');
|
|
89
|
+
RouterBasenameContext.displayName = 'RouterBasenameContext';
|
|
90
|
+
const IsSubPageClosedByPageMenuContext = /*#__PURE__*/ external_react_default().createContext({
|
|
91
|
+
isSubPageClosedByPageMenu: ()=>false,
|
|
92
|
+
setFieldSchema: ()=>{},
|
|
93
|
+
reset: ()=>{}
|
|
94
|
+
});
|
|
95
|
+
IsSubPageClosedByPageMenuContext.displayName = 'IsSubPageClosedByPageMenuContext';
|
|
96
|
+
const IsSubPageClosedByPageMenuProvider = (param)=>{
|
|
97
|
+
let { children } = param;
|
|
98
|
+
const params = (0, external_react_router_dom_namespaceObject.useParams)();
|
|
99
|
+
const prevParamsRef = (0, external_react_namespaceObject.useRef)({});
|
|
100
|
+
const [fieldSchema, setFieldSchema] = (0, external_react_namespaceObject.useState)(null);
|
|
101
|
+
const isSubPageClosedByPageMenu = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
102
|
+
var _fieldSchema_xcomponentprops, _prevParamsRef_current_;
|
|
103
|
+
const result = external_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']));
|
|
104
|
+
prevParamsRef.current = params;
|
|
105
|
+
return result;
|
|
106
|
+
}, [
|
|
107
|
+
fieldSchema,
|
|
108
|
+
params
|
|
109
|
+
]);
|
|
110
|
+
const reset = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
111
|
+
prevParamsRef.current = {};
|
|
112
|
+
}, []);
|
|
113
|
+
const value = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
114
|
+
isSubPageClosedByPageMenu,
|
|
115
|
+
setFieldSchema,
|
|
116
|
+
reset
|
|
117
|
+
}), [
|
|
118
|
+
isSubPageClosedByPageMenu,
|
|
119
|
+
reset
|
|
120
|
+
]);
|
|
121
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsSubPageClosedByPageMenuContext.Provider, {
|
|
122
|
+
value: value,
|
|
123
|
+
children: children
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const RouterBasenameProvider = (param)=>{
|
|
127
|
+
let { children } = param;
|
|
128
|
+
const basenameOfCurrentRouter = (0, external_react_router_dom_namespaceObject.useHref)('/');
|
|
129
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterBasenameContext.Provider, {
|
|
130
|
+
value: basenameOfCurrentRouter,
|
|
131
|
+
children: children
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const SearchParamsProvider = (param)=>{
|
|
135
|
+
let { children } = param;
|
|
136
|
+
const [searchParams] = (0, external_react_router_dom_namespaceObject.useSearchParams)();
|
|
137
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SearchParamsContext.Provider, {
|
|
138
|
+
value: searchParams,
|
|
139
|
+
children: children
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const IsInSettingsPageProvider = (param)=>{
|
|
143
|
+
let { children } = param;
|
|
144
|
+
const isInSettingsPage = (0, external_react_router_dom_namespaceObject.useLocation)().pathname.includes('/settings');
|
|
145
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsInSettingsPageContext.Provider, {
|
|
146
|
+
value: isInSettingsPage,
|
|
147
|
+
children: children
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
const MatchAdminProvider = (param)=>{
|
|
151
|
+
let { children } = param;
|
|
152
|
+
const isMatchAdmin = !!(0, external_react_router_dom_namespaceObject.useMatch)('/admin');
|
|
153
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminContext.Provider, {
|
|
154
|
+
value: isMatchAdmin,
|
|
155
|
+
children: children
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
const MatchAdminNameProvider = (param)=>{
|
|
159
|
+
let { children } = param;
|
|
160
|
+
const isMatchAdminName = !!(0, external_react_router_dom_namespaceObject.useMatch)('/admin/:name');
|
|
161
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminNameContext.Provider, {
|
|
162
|
+
value: isMatchAdminName,
|
|
163
|
+
children: children
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
const IsAdminPageProvider = (param)=>{
|
|
167
|
+
let { children } = param;
|
|
168
|
+
const location = (0, external_react_router_dom_namespaceObject.useLocation)();
|
|
169
|
+
const isAdminPage = location.pathname.startsWith('/admin');
|
|
170
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsAdminPageContext.Provider, {
|
|
171
|
+
value: isAdminPage,
|
|
172
|
+
children: children
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
const CurrentPageUidProvider = (param)=>{
|
|
176
|
+
let { children } = param;
|
|
177
|
+
const params = (0, external_react_router_dom_namespaceObject.useParams)();
|
|
178
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CurrentPageUidContext.Provider, {
|
|
179
|
+
value: params.name,
|
|
180
|
+
children: children
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
const CurrentTabUidProvider = (param)=>{
|
|
184
|
+
let { children } = param;
|
|
185
|
+
const params = (0, external_react_router_dom_namespaceObject.useParams)();
|
|
186
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CurrentTabUidContext.Provider, {
|
|
187
|
+
value: params.tabUid,
|
|
188
|
+
children: children
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
const NavigateNoUpdateProvider = (param)=>{
|
|
192
|
+
let { children } = param;
|
|
193
|
+
const navigate = (0, external_react_router_dom_namespaceObject.useNavigate)();
|
|
194
|
+
const navigateRef = external_react_default().useRef(navigate);
|
|
195
|
+
navigateRef.current = navigate;
|
|
196
|
+
const navigateNoUpdate = external_react_default().useCallback((to, options)=>{
|
|
197
|
+
navigateRef.current(to, options);
|
|
198
|
+
}, []);
|
|
199
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(NavigateNoUpdateContext.Provider, {
|
|
200
|
+
value: navigateNoUpdate,
|
|
201
|
+
children: children
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
const LocationNoUpdateProvider = (param)=>{
|
|
205
|
+
let { children } = param;
|
|
206
|
+
const location = (0, external_react_router_dom_namespaceObject.useLocation)();
|
|
207
|
+
const locationRef = external_react_default().useRef({});
|
|
208
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
209
|
+
Object.assign(locationRef.current, location);
|
|
210
|
+
}, [
|
|
211
|
+
location
|
|
212
|
+
]);
|
|
213
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationNoUpdateContext.Provider, {
|
|
214
|
+
value: locationRef.current,
|
|
215
|
+
children: children
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
const LocationSearchProvider = (param)=>{
|
|
219
|
+
let { children } = param;
|
|
220
|
+
const location = (0, external_react_router_dom_namespaceObject.useLocation)();
|
|
221
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationSearchContext.Provider, {
|
|
222
|
+
value: location.search,
|
|
223
|
+
children: children
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
const useNavigateNoUpdate = ()=>external_react_default().useContext(NavigateNoUpdateContext);
|
|
227
|
+
const useLocationNoUpdate = ()=>external_react_default().useContext(LocationNoUpdateContext);
|
|
228
|
+
const useLocationSearch = ()=>external_react_default().useContext(LocationSearchContext);
|
|
229
|
+
const useIsAdminPage = ()=>external_react_default().useContext(IsAdminPageContext);
|
|
230
|
+
const useCurrentPageUid = ()=>external_react_default().useContext(CurrentPageUidContext);
|
|
231
|
+
const useMatchAdmin = ()=>external_react_default().useContext(MatchAdminContext);
|
|
232
|
+
const useMatchAdminName = ()=>external_react_default().useContext(MatchAdminNameContext);
|
|
233
|
+
const useIsInSettingsPage = ()=>external_react_default().useContext(IsInSettingsPageContext);
|
|
234
|
+
const useCurrentTabUid = ()=>external_react_default().useContext(CurrentTabUidContext);
|
|
235
|
+
const useCurrentSearchParams = ()=>external_react_default().useContext(SearchParamsContext);
|
|
236
|
+
const useRouterBasename = ()=>external_react_default().useContext(RouterBasenameContext);
|
|
237
|
+
const useIsSubPageClosedByPageMenu = (fieldSchema)=>{
|
|
238
|
+
const { isSubPageClosedByPageMenu, setFieldSchema, reset } = external_react_default().useContext(IsSubPageClosedByPageMenuContext);
|
|
239
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
240
|
+
setFieldSchema(fieldSchema);
|
|
241
|
+
}, [
|
|
242
|
+
fieldSchema,
|
|
243
|
+
setFieldSchema
|
|
244
|
+
]);
|
|
245
|
+
return {
|
|
246
|
+
isSubPageClosedByPageMenu,
|
|
247
|
+
reset
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
const CustomRouterContextProvider = (param)=>{
|
|
251
|
+
let { children } = param;
|
|
252
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(NavigateNoUpdateProvider, {
|
|
253
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationNoUpdateProvider, {
|
|
254
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsAdminPageProvider, {
|
|
255
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationSearchProvider, {
|
|
256
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminProvider, {
|
|
257
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminNameProvider, {
|
|
258
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SearchParamsProvider, {
|
|
259
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterBasenameProvider, {
|
|
260
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsInSettingsPageProvider, {
|
|
261
|
+
children: children
|
|
262
|
+
})
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
})
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
var __webpack_export_target__ = exports;
|
|
273
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
274
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
275
|
+
value: true
|
|
276
|
+
});
|
|
@@ -47,7 +47,10 @@ const external_react_namespaceObject = require("react");
|
|
|
47
47
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
48
48
|
const external_lodash_namespaceObject = require("lodash");
|
|
49
49
|
const external_react_router_dom_namespaceObject = require("react-router-dom");
|
|
50
|
+
const VariablesProvider_js_namespaceObject = require("../variables/VariablesProvider.js");
|
|
51
|
+
var VariablesProvider_js_default = /*#__PURE__*/ __webpack_require__.n(VariablesProvider_js_namespaceObject);
|
|
50
52
|
const index_js_namespaceObject = require("./components/index.js");
|
|
53
|
+
const external_CustomRouterContextProvider_js_namespaceObject = require("./CustomRouterContextProvider.js");
|
|
51
54
|
function _define_property(obj, key, value) {
|
|
52
55
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
53
56
|
value: value,
|
|
@@ -59,6 +62,15 @@ function _define_property(obj, key, value) {
|
|
|
59
62
|
return obj;
|
|
60
63
|
}
|
|
61
64
|
class RouterManager {
|
|
65
|
+
get basename() {
|
|
66
|
+
return this.router.basename;
|
|
67
|
+
}
|
|
68
|
+
get state() {
|
|
69
|
+
return this.router.state;
|
|
70
|
+
}
|
|
71
|
+
get navigate() {
|
|
72
|
+
return this.router.navigate;
|
|
73
|
+
}
|
|
62
74
|
getRoutesTree() {
|
|
63
75
|
const routes = {};
|
|
64
76
|
for (const [name, route] of Object.entries(this.routes))(0, external_lodash_namespaceObject.set)(routes, name.split('.').join('.children.'), {
|
|
@@ -94,26 +106,46 @@ class RouterManager {
|
|
|
94
106
|
setBasename(basename) {
|
|
95
107
|
this.options.basename = basename;
|
|
96
108
|
}
|
|
97
|
-
getRouterComponent() {
|
|
109
|
+
getRouterComponent(children) {
|
|
98
110
|
const { type = 'browser', ...opts } = this.options;
|
|
99
|
-
const
|
|
100
|
-
hash: external_react_router_dom_namespaceObject.
|
|
101
|
-
browser: external_react_router_dom_namespaceObject.
|
|
102
|
-
memory: external_react_router_dom_namespaceObject.
|
|
111
|
+
const routerCreators = {
|
|
112
|
+
hash: external_react_router_dom_namespaceObject.createHashRouter,
|
|
113
|
+
browser: external_react_router_dom_namespaceObject.createBrowserRouter,
|
|
114
|
+
memory: external_react_router_dom_namespaceObject.createMemoryRouter
|
|
115
|
+
};
|
|
116
|
+
const routes = this.getRoutesTree();
|
|
117
|
+
const BaseLayoutContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(null);
|
|
118
|
+
const Provider = ()=>{
|
|
119
|
+
const BaseLayout = (0, external_react_namespaceObject.useContext)(BaseLayoutContext);
|
|
120
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CustomRouterContextProvider_js_namespaceObject.CustomRouterContextProvider, {
|
|
121
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BaseLayout, {
|
|
122
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(VariablesProvider_js_default(), {
|
|
123
|
+
children: [
|
|
124
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_router_dom_namespaceObject.Outlet, {}),
|
|
125
|
+
children
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
});
|
|
103
130
|
};
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const element = (0, external_react_router_dom_namespaceObject.useRoutes)(routes);
|
|
108
|
-
return element;
|
|
131
|
+
const ErrorElement = ()=>{
|
|
132
|
+
const error = (0, external_react_router_dom_namespaceObject.useRouteError)();
|
|
133
|
+
throw error;
|
|
109
134
|
};
|
|
135
|
+
this.router = routerCreators[type]([
|
|
136
|
+
{
|
|
137
|
+
element: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Provider, {}),
|
|
138
|
+
errorElement: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ErrorElement, {}),
|
|
139
|
+
children: routes
|
|
140
|
+
}
|
|
141
|
+
], opts);
|
|
110
142
|
const RenderRouter = (param)=>{
|
|
111
143
|
let { BaseLayout = index_js_namespaceObject.BlankComponent } = param;
|
|
112
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
116
|
-
|
|
144
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BaseLayoutContext.Provider, {
|
|
145
|
+
value: BaseLayout,
|
|
146
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.RouterContextCleaner, {
|
|
147
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_router_dom_namespaceObject.RouterProvider, {
|
|
148
|
+
router: this.router
|
|
117
149
|
})
|
|
118
150
|
})
|
|
119
151
|
});
|
|
@@ -136,8 +168,10 @@ class RouterManager {
|
|
|
136
168
|
_define_property(this, "routes", {});
|
|
137
169
|
_define_property(this, "options", void 0);
|
|
138
170
|
_define_property(this, "app", void 0);
|
|
171
|
+
_define_property(this, "router", void 0);
|
|
139
172
|
this.options = options;
|
|
140
173
|
this.app = app;
|
|
174
|
+
this.routes = options.routes || {};
|
|
141
175
|
}
|
|
142
176
|
}
|
|
143
177
|
function createRouterManager(options, app) {
|