@tachybase/client 0.23.58 → 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.
Files changed (133) hide show
  1. package/es/api-client/APIClient.d.ts +5 -2
  2. package/es/api-client/APIClient.mjs +93 -49
  3. package/es/api-client/hooks/useRequest.d.ts +2 -0
  4. package/es/application/Application.d.ts +3 -0
  5. package/es/application/Application.mjs +11 -0
  6. package/es/application/CustomRouterContextProvider.d.ts +54 -0
  7. package/es/application/CustomRouterContextProvider.mjs +209 -0
  8. package/es/application/RouterManager.d.ts +8 -3
  9. package/es/application/RouterManager.mjs +48 -15
  10. package/es/application/schema-initializer/context/index.d.ts +1 -1
  11. package/es/block-provider/hooks/index.d.ts +2 -0
  12. package/es/block-provider/hooks/index.mjs +25 -21
  13. package/es/built-in/context-menu/ContextMenu.provider.mjs +6 -6
  14. package/es/built-in/context-menu/ContextMenuItemsProps.d.ts +4 -4
  15. package/es/built-in/context-menu/ContextMenuItemsProps.mjs +6 -6
  16. package/es/built-in/context-menu/index.mjs +1 -1
  17. package/es/built-in/context-menu/useContextMenu.d.ts +2 -2
  18. package/es/built-in/index.mjs +5 -0
  19. package/es/built-in/page-style/PageStyle.provider.mjs +2 -2
  20. package/es/collection-manager/templates/sql.d.ts +1 -1
  21. package/es/collection-manager/templates/view.d.ts +1 -1
  22. package/es/data-source/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
  23. package/es/data-source/collection-field-interface/CollectionFieldInterface.mjs +18 -0
  24. package/es/data-source/collection-field-interface/CollectionFieldInterfaceManager.d.ts +8 -1
  25. package/es/data-source/collection-field-interface/CollectionFieldInterfaceManager.mjs +20 -0
  26. package/es/data-source/commonsSettingsItem/fieldComponent.mjs +3 -1
  27. package/es/data-source/data-source/DataSource.d.ts +1 -1
  28. package/es/filter-provider/utils.mjs +6 -0
  29. package/es/i18n/i18n.mjs +7 -12
  30. package/es/modules/actions/delete/deleteActionSettings.mjs +10 -0
  31. package/es/modules/blocks/data-blocks/form/FilterItemCustomSettings.mjs +1 -1
  32. package/es/modules/blocks/data-blocks/form/fieldSettingsFormItem.mjs +9 -4
  33. package/es/modules/blocks/data-blocks/table/hooks/useTableBlockProps.mjs +2 -2
  34. package/es/modules/blocks/data-blocks/table/tableBlockSettings.mjs +4 -0
  35. package/es/modules/blocks/data-blocks/table/tableColumnSettings.mjs +44 -0
  36. package/es/modules/blocks/filter-blocks/collapse/filterCollapseItemFieldSettings.mjs +4 -0
  37. package/es/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.mjs +9 -0
  38. package/es/modules/fields/component/SubTable/secondLevelSelect.d.ts +11 -0
  39. package/es/modules/fields/component/SubTable/secondLevelSelect.mjs +102 -0
  40. package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.d.ts +79 -41
  41. package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.mjs +103 -100
  42. package/es/powered-by/index.mjs +4 -7
  43. package/es/schema-component/antd/action/Action.Designer.mjs +38 -3
  44. package/es/schema-component/antd/action/Action.Modal.mjs +0 -1
  45. package/es/schema-component/antd/action/Action.mjs +1 -3
  46. package/es/schema-component/antd/association-field/SubTabs/InternalCollapse.mjs +2 -1
  47. package/es/schema-component/antd/checkbox/Checkbox.mjs +6 -4
  48. package/es/schema-component/antd/index.d.ts +1 -0
  49. package/es/schema-component/antd/index.mjs +1 -0
  50. package/es/schema-component/antd/media-card/MediaCard.d.ts +11 -0
  51. package/es/schema-component/antd/media-card/MediaCard.mjs +35 -0
  52. package/es/schema-component/antd/media-card/index.d.ts +1 -0
  53. package/es/schema-component/antd/media-card/index.mjs +1 -0
  54. package/es/schema-component/antd/media-card/style.d.ts +3 -0
  55. package/es/schema-component/antd/media-card/style.mjs +25 -0
  56. package/es/schema-component/antd/page/Page.mjs +34 -24
  57. package/es/schema-component/antd/password/utils.d.ts +1 -1
  58. package/es/schema-component/common/dnd-context/index.mjs +1 -7
  59. package/es/schema-component/common/sortable-item/DragHandlePageTab.d.ts +1 -0
  60. package/es/schema-component/common/sortable-item/DragHandlePageTab.mjs +71 -0
  61. package/es/schema-component/common/sortable-item/DragHandlePageTab.style.d.ts +3 -0
  62. package/es/schema-component/common/sortable-item/DragHandlePageTab.style.mjs +25 -0
  63. package/es/schema-items/GeneralSettings.mjs +5 -0
  64. package/es/schema-settings/EditCustomDefaultValue.mjs +1 -1
  65. package/es/schema-settings/SchemaSettings.mjs +1 -1
  66. package/es/schema-settings/SchemaSettingsDefaultValue.mjs +2 -0
  67. package/es/schema-settings/utils/createModalSettingsItem.d.ts +26 -0
  68. package/es/schema-settings/utils/createModalSettingsItem.mjs +46 -0
  69. package/es/schema-settings/utils/createSelectSettingsItem.d.ts +25 -0
  70. package/es/schema-settings/utils/createSelectSettingsItem.mjs +40 -0
  71. package/es/schema-settings/utils/createSwitchSettingsItem.d.ts +21 -0
  72. package/es/schema-settings/utils/createSwitchSettingsItem.mjs +38 -0
  73. package/es/schema-settings/utils/createTextSettingsItem.d.ts +9 -0
  74. package/es/schema-settings/utils/createTextSettingsItem.mjs +21 -0
  75. package/es/schema-settings/utils/index.d.ts +4 -0
  76. package/es/schema-settings/utils/index.mjs +4 -0
  77. package/es/schema-settings/utils/util.d.ts +12 -0
  78. package/es/schema-settings/utils/util.mjs +24 -0
  79. package/es/user/CurrentUserProvider.mjs +6 -3
  80. package/lib/api-client/APIClient.js +93 -49
  81. package/lib/application/Application.js +11 -0
  82. package/lib/application/CustomRouterContextProvider.js +276 -0
  83. package/lib/application/RouterManager.js +49 -15
  84. package/lib/application/schema-initializer/hooks/index.js +2 -2
  85. package/lib/block-provider/hooks/index.js +76 -58
  86. package/lib/built-in/context-menu/ContextMenu.provider.js +6 -6
  87. package/lib/built-in/context-menu/ContextMenuItemsProps.js +6 -6
  88. package/lib/built-in/context-menu/index.js +1 -1
  89. package/lib/built-in/index.js +5 -0
  90. package/lib/built-in/page-style/PageStyle.provider.js +2 -2
  91. package/lib/data-source/collection-field-interface/CollectionFieldInterface.js +18 -0
  92. package/lib/data-source/collection-field-interface/CollectionFieldInterfaceManager.js +20 -0
  93. package/lib/data-source/commonsSettingsItem/fieldComponent.js +3 -1
  94. package/lib/filter-provider/utils.js +6 -0
  95. package/lib/i18n/i18n.js +7 -12
  96. package/lib/locale/en_US.js +1 -0
  97. package/lib/locale/zh-CN.js +10 -1
  98. package/lib/modules/actions/delete/deleteActionSettings.js +10 -0
  99. package/lib/modules/blocks/data-blocks/form/FilterItemCustomSettings.js +1 -1
  100. package/lib/modules/blocks/data-blocks/form/fieldSettingsFormItem.js +9 -4
  101. package/lib/modules/blocks/data-blocks/table/hooks/useTableBlockProps.js +2 -2
  102. package/lib/modules/blocks/data-blocks/table/tableBlockSettings.js +4 -0
  103. package/lib/modules/blocks/data-blocks/table/tableColumnSettings.js +44 -0
  104. package/lib/modules/blocks/filter-blocks/collapse/filterCollapseItemFieldSettings.js +4 -0
  105. package/lib/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.js +9 -0
  106. package/lib/modules/fields/component/SubTable/secondLevelSelect.js +136 -0
  107. package/lib/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.js +104 -103
  108. package/lib/powered-by/index.js +4 -7
  109. package/lib/schema-component/antd/action/Action.Designer.js +38 -3
  110. package/lib/schema-component/antd/action/Action.Modal.js +0 -1
  111. package/lib/schema-component/antd/action/Action.js +1 -3
  112. package/lib/schema-component/antd/association-field/SubTabs/InternalCollapse.js +2 -1
  113. package/lib/schema-component/antd/checkbox/Checkbox.js +6 -4
  114. package/lib/schema-component/antd/index.js +18 -4
  115. package/lib/schema-component/antd/media-card/MediaCard.js +69 -0
  116. package/lib/schema-component/antd/media-card/index.js +65 -0
  117. package/lib/schema-component/antd/media-card/style.js +59 -0
  118. package/lib/schema-component/antd/page/Page.js +34 -24
  119. package/lib/schema-component/common/dnd-context/index.js +1 -7
  120. package/lib/schema-component/common/sortable-item/DragHandlePageTab.js +105 -0
  121. package/lib/schema-component/common/sortable-item/DragHandlePageTab.style.js +59 -0
  122. package/lib/schema-items/GeneralSettings.js +5 -0
  123. package/lib/schema-settings/EditCustomDefaultValue.js +1 -1
  124. package/lib/schema-settings/SchemaSettings.js +1 -1
  125. package/lib/schema-settings/SchemaSettingsDefaultValue.js +2 -0
  126. package/lib/schema-settings/utils/createModalSettingsItem.js +94 -0
  127. package/lib/schema-settings/utils/createSelectSettingsItem.js +88 -0
  128. package/lib/schema-settings/utils/createSwitchSettingsItem.js +86 -0
  129. package/lib/schema-settings/utils/createTextSettingsItem.js +55 -0
  130. package/lib/schema-settings/utils/index.js +92 -0
  131. package/lib/schema-settings/utils/util.js +74 -0
  132. package/lib/user/CurrentUserProvider.js +6 -3
  133. package/package.json +7 -7
@@ -0,0 +1,46 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__util_mjs__ from "./util.mjs";
5
+ function createModalSettingsItem(options) {
6
+ const { name, parentSchemaKey, valueKeys, schema, title, useSubmit = __WEBPACK_EXTERNAL_MODULE__util_mjs__.useHookDefault, useVisible, defaultValue: propsDefaultValue, useDefaultValue = __WEBPACK_EXTERNAL_MODULE__util_mjs__.useHookDefault, width, type = 'common' } = options;
7
+ return {
8
+ name,
9
+ type: 'actionModal',
10
+ useVisible,
11
+ useComponentProps () {
12
+ const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.useSchemaByType)(type);
13
+ const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
14
+ const defaultValue = useDefaultValue(propsDefaultValue);
15
+ const values = parentSchemaKey ? __WEBPACK_EXTERNAL_MODULE_lodash__["default"].get(fieldSchema, parentSchemaKey) : void 0;
16
+ const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
17
+ const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
18
+ const onSubmit = useSubmit();
19
+ const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useColumnSchema)() || {};
20
+ return {
21
+ title: 'function' == typeof title ? title(t) : compile(title),
22
+ width,
23
+ schema: schema({
24
+ ...defaultValue,
25
+ ...values
26
+ }),
27
+ onSubmit (values) {
28
+ const newSchema = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.getNewSchema)({
29
+ fieldSchema,
30
+ parentSchemaKey: parentSchemaKey,
31
+ value: values,
32
+ valueKeys
33
+ });
34
+ if (tableColumnSchema) {
35
+ dn.emit('patch', {
36
+ schema: newSchema
37
+ });
38
+ dn.refresh();
39
+ } else dn.deepMerge(newSchema);
40
+ return null == onSubmit ? void 0 : onSubmit(values);
41
+ }
42
+ };
43
+ }
44
+ };
45
+ }
46
+ export { createModalSettingsItem };
@@ -0,0 +1,25 @@
1
+ import { SelectProps } from 'antd';
2
+ import { TFunction } from 'i18next';
3
+ import { SchemaSettingsItemType } from '../../application';
4
+ interface CreateSelectSchemaSettingsItemProps {
5
+ name: string;
6
+ title: string | ((t: TFunction<'translation', undefined>) => string);
7
+ options?: SelectProps['options'];
8
+ useOptions?: () => SelectProps['options'];
9
+ schemaKey: string;
10
+ defaultValue?: string | number;
11
+ useDefaultValue?: () => string | number;
12
+ useVisible?: () => boolean;
13
+ /**
14
+ * @default 'common'
15
+ */
16
+ type?: 'common' | 'field';
17
+ }
18
+ /**
19
+ * create `select` type schema settings item
20
+ *
21
+ * @internal
22
+ * @unstable
23
+ */
24
+ export declare const createSelectSchemaSettingsItem: (options: CreateSelectSchemaSettingsItemProps) => SchemaSettingsItemType;
25
+ export {};
@@ -0,0 +1,40 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__util_mjs__ from "./util.mjs";
5
+ const createSelectSchemaSettingsItem = (options)=>{
6
+ const { name, title, options: propsOptions, useOptions = __WEBPACK_EXTERNAL_MODULE__util_mjs__.useHookDefault, schemaKey, useVisible, type = 'common', defaultValue: propsDefaultValue, useDefaultValue = __WEBPACK_EXTERNAL_MODULE__util_mjs__.useHookDefault } = options;
7
+ return {
8
+ name,
9
+ type: 'select',
10
+ useVisible,
11
+ useComponentProps () {
12
+ const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.useSchemaByType)(type);
13
+ const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useColumnSchema)() || {};
14
+ const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
15
+ const options = useOptions(propsOptions);
16
+ const defaultValue = useDefaultValue(propsDefaultValue);
17
+ const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
18
+ const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
19
+ return {
20
+ title: 'function' == typeof title ? title(t) : compile(title),
21
+ options,
22
+ value: __WEBPACK_EXTERNAL_MODULE_lodash__["default"].get(fieldSchema, schemaKey, defaultValue),
23
+ onChange (v) {
24
+ const newSchema = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.getNewSchema)({
25
+ fieldSchema,
26
+ schemaKey,
27
+ value: v
28
+ });
29
+ if (tableColumnSchema) {
30
+ dn.emit('patch', {
31
+ schema: newSchema
32
+ });
33
+ dn.refresh();
34
+ } else dn.deepMerge(newSchema);
35
+ }
36
+ };
37
+ }
38
+ };
39
+ };
40
+ export { createSelectSchemaSettingsItem };
@@ -0,0 +1,21 @@
1
+ import { TFunction } from 'i18next';
2
+ import { SchemaSettingsItemType } from '../../application';
3
+ export interface CreateSwitchSchemaSettingsItemProps {
4
+ name: string;
5
+ title: string | ((t: TFunction<'translation', undefined>) => string);
6
+ schemaKey: string;
7
+ defaultValue?: boolean;
8
+ useDefaultValue?: () => boolean;
9
+ useVisible?: () => boolean;
10
+ /**
11
+ * @default 'common'
12
+ */
13
+ type?: 'common' | 'field';
14
+ }
15
+ /**
16
+ * create `switch` type schema settings item
17
+ *
18
+ * @internal
19
+ * @unstable
20
+ */
21
+ export declare function createSwitchSettingsItem(options: CreateSwitchSchemaSettingsItemProps): SchemaSettingsItemType;
@@ -0,0 +1,38 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__util_mjs__ from "./util.mjs";
5
+ function createSwitchSettingsItem(options) {
6
+ const { name, useVisible, schemaKey, title, type = 'common', defaultValue: propsDefaultValue, useDefaultValue = __WEBPACK_EXTERNAL_MODULE__util_mjs__.useHookDefault } = options;
7
+ return {
8
+ name,
9
+ useVisible,
10
+ type: 'switch',
11
+ useComponentProps () {
12
+ const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.useSchemaByType)(type);
13
+ const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
14
+ const defaultValue = useDefaultValue(propsDefaultValue);
15
+ const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
16
+ const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
17
+ const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useColumnSchema)() || {};
18
+ return {
19
+ title: 'function' == typeof title ? title(t) : compile(title),
20
+ checked: !!__WEBPACK_EXTERNAL_MODULE_lodash__["default"].get(fieldSchema, schemaKey, defaultValue),
21
+ onChange (v) {
22
+ const newSchema = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.getNewSchema)({
23
+ fieldSchema,
24
+ schemaKey,
25
+ value: v
26
+ });
27
+ if (tableColumnSchema) {
28
+ dn.emit('patch', {
29
+ schema: newSchema
30
+ });
31
+ dn.refresh();
32
+ } else dn.deepMerge(newSchema);
33
+ }
34
+ };
35
+ }
36
+ };
37
+ }
38
+ export { createSwitchSettingsItem };
@@ -0,0 +1,9 @@
1
+ import { TFunction } from 'i18next';
2
+ import { SchemaSettingsItemType } from '../../application';
3
+ export interface CreateTextSchemaSettingsItemProps {
4
+ name: string;
5
+ useVisible?: () => boolean;
6
+ title: string | ((t: TFunction<'translation', undefined>) => string);
7
+ useTextClick: () => void;
8
+ }
9
+ export declare function createTextSettingsItem(options: CreateTextSchemaSettingsItemProps): SchemaSettingsItemType;
@@ -0,0 +1,21 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__util_mjs__ from "./util.mjs";
4
+ function createTextSettingsItem(options) {
5
+ const { name, useVisible, title, useTextClick = __WEBPACK_EXTERNAL_MODULE__util_mjs__.useHookDefault } = options;
6
+ return {
7
+ name,
8
+ type: 'item',
9
+ useVisible,
10
+ useComponentProps () {
11
+ const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
12
+ const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
13
+ const onClick = useTextClick();
14
+ return {
15
+ title: 'function' == typeof title ? title(t) : compile(title),
16
+ onClick
17
+ };
18
+ }
19
+ };
20
+ }
21
+ export { createTextSettingsItem };
@@ -0,0 +1,4 @@
1
+ export * from './createModalSettingsItem';
2
+ export * from './createSelectSettingsItem';
3
+ export * from './createSwitchSettingsItem';
4
+ export * from './createTextSettingsItem';
@@ -0,0 +1,4 @@
1
+ export * from "./createModalSettingsItem.mjs";
2
+ export * from "./createSelectSettingsItem.mjs";
3
+ export * from "./createSwitchSettingsItem.mjs";
4
+ export * from "./createTextSettingsItem.mjs";
@@ -0,0 +1,12 @@
1
+ import { ISchema } from '@tachybase/schema';
2
+ type IGetNewSchema = {
3
+ fieldSchema: ISchema;
4
+ schemaKey?: string;
5
+ parentSchemaKey?: string;
6
+ value: any;
7
+ valueKeys?: string[];
8
+ };
9
+ export declare function getNewSchema(options: IGetNewSchema): any;
10
+ export declare const useHookDefault: (defaultValues?: any) => any;
11
+ export declare const useSchemaByType: (type?: "common" | "field") => any;
12
+ export {};
@@ -0,0 +1,24 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
4
+ function getNewSchema(options) {
5
+ const { fieldSchema, schemaKey, parentSchemaKey, value, valueKeys } = options;
6
+ if (schemaKey) __WEBPACK_EXTERNAL_MODULE_lodash__["default"].set(fieldSchema, schemaKey, value);
7
+ else if (parentSchemaKey) {
8
+ if (void 0 === value) return fieldSchema;
9
+ if ('object' == typeof value) Object.keys(value).forEach((key)=>{
10
+ if (valueKeys && !valueKeys.includes(key)) return;
11
+ __WEBPACK_EXTERNAL_MODULE_lodash__["default"].set(fieldSchema, "".concat(parentSchemaKey, ".").concat(key), value[key]);
12
+ });
13
+ else console.error('value must be object');
14
+ }
15
+ return fieldSchema;
16
+ }
17
+ const useHookDefault = (defaultValues)=>defaultValues;
18
+ const useSchemaByType = function() {
19
+ let type = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 'common';
20
+ const schema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
21
+ const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useColumnSchema)() || {};
22
+ return 'field' === type ? tableColumnSchema || schema : schema;
23
+ };
24
+ export { getNewSchema, useHookDefault, useSchemaByType };
@@ -33,9 +33,12 @@ const useCurrentRoles = ()=>{
33
33
  return options;
34
34
  };
35
35
  const CurrentUserProvider = (props)=>{
36
- const result = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useRequest)({
37
- url: 'auth:check'
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', {}, 'string' == typeof item ? item : item.message))
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
- service(uid) {
89
- return this.services[uid];
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 appName = this.app ? (0, sdk_namespaceObject.getSubAppName)(this.app.getPublicPath()) : null;
104
- if (appName) config.headers['X-App'] = appName;
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
- var _error_response_data, _error_response;
111
- const errs = (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.errors) || [
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: 'Server error'
152
+ message: tempElement.textContent || tempElement.innerText
114
153
  }
115
154
  ];
116
- if (errs.find((error)=>'ROLE_NOT_FOUND_ERR' === error.code)) this.auth.setRole(null);
117
- throw error;
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
- }, (error)=>{
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
- this.silence = true;
169
- return this;
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,9 @@ 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
+ }
286
294
  addGlobalVar(key, value) {
287
295
  (0, external_lodash_namespaceObject.set)(this.globalVars, key, value);
288
296
  }
@@ -359,6 +367,9 @@ class Application {
359
367
  this.name = this.options.name || (0, sdk_namespaceObject.getSubAppName)(options.publicPath) || 'main';
360
368
  this.pluginContextMenu = new external_PluginContextMenu_js_namespaceObject.PluginContextMenu(options.pluginMenuItems);
361
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
+ });
362
373
  }
363
374
  }
364
375
  var __webpack_export_target__ = exports;