@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
@@ -91,6 +91,10 @@ const tableBlockSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_set
91
91
  const sortBy = null == data ? void 0 : null === (_data_data = data.data) || void 0 === _data_data ? void 0 : null === (_data_data_ = _data_data[0]) || void 0 === _data_data_ ? void 0 : _data_data_.sortBy;
92
92
  fieldSchema['x-decorator-props'].dragSortBy = sortBy;
93
93
  }
94
+ if (!dragSort) {
95
+ fieldSchema['x-decorator-props'].dragSortBy = null;
96
+ field.decoratorProps.dragSortBy = null;
97
+ }
94
98
  field.decoratorProps.dragSort = dragSort;
95
99
  fieldSchema['x-decorator-props'].dragSort = dragSort;
96
100
  service.run({
@@ -108,6 +108,50 @@ const tableColumnSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_se
108
108
  };
109
109
  }
110
110
  },
111
+ {
112
+ name: 'columnAlign',
113
+ type: 'select',
114
+ useComponentProps () {
115
+ var _fieldSchema_xcomponentprops;
116
+ const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
117
+ const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
118
+ const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
119
+ const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
120
+ return {
121
+ key: 'align',
122
+ title: t('Align'),
123
+ options: [
124
+ {
125
+ label: t('Left'),
126
+ value: 'left'
127
+ },
128
+ {
129
+ label: t('Center'),
130
+ value: 'center'
131
+ },
132
+ {
133
+ label: t('Right'),
134
+ value: 'right'
135
+ }
136
+ ],
137
+ value: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.align) || 'left',
138
+ onChange: (align)=>{
139
+ const props = fieldSchema['x-component-props'] || {};
140
+ props['align'] = align;
141
+ const schema = {
142
+ ['x-uid']: fieldSchema['x-uid']
143
+ };
144
+ schema['x-component-props'] = props;
145
+ fieldSchema['x-component-props'] = props;
146
+ field.componentProps.align = align;
147
+ dn.emit('patch', {
148
+ schema
149
+ });
150
+ dn.refresh();
151
+ }
152
+ };
153
+ }
154
+ },
111
155
  {
112
156
  name: 'sortable',
113
157
  type: 'switch',
@@ -4,6 +4,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__ from "../../../../application/schema-settings/SchemaSettings.mjs";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE__block_provider_index_mjs__ from "../../../../block-provider/index.mjs";
6
6
  import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../../../../collection-manager/index.mjs";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../../data-source/index.mjs";
7
8
  import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../../schema-component/index.mjs";
8
9
  import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__ from "../../../../schema-settings/index.mjs";
9
10
  import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsDataScope_mjs__ from "../../../../schema-settings/SchemaSettingsDataScope.mjs";
@@ -183,6 +184,9 @@ const filterCollapseItemFieldSettings = new __WEBPACK_EXTERNAL_MODULE__applicati
183
184
  onChange: onTitleFieldChange
184
185
  };
185
186
  }
187
+ },
188
+ {
189
+ ...__WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.fieldComponentSettingsItem
186
190
  }
187
191
  ];
188
192
  }
@@ -6,7 +6,9 @@ import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../../..
6
6
  import * as __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__ from "../../../../application/schema-settings/SchemaSettings.mjs";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../../../../collection-manager/index.mjs";
8
8
  import * as __WEBPACK_EXTERNAL_MODULE__common_useFieldComponentName_mjs__ from "../../../../common/useFieldComponentName.mjs";
9
+ import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../../data-source/index.mjs";
9
10
  import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../../schema-component/index.mjs";
11
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__ from "../../../../schema-settings/index.mjs";
10
12
  const filterFormItemFieldSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__.SchemaSettings({
11
13
  name: 'fieldSettings:FilterFormItem',
12
14
  items: [
@@ -308,6 +310,13 @@ const filterFormItemFieldSettings = new __WEBPACK_EXTERNAL_MODULE__application_s
308
310
  {
309
311
  name: 'operator',
310
312
  Component: __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.EditOperator
313
+ },
314
+ {
315
+ ...__WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.fieldComponentSettingsItem
316
+ },
317
+ {
318
+ name: 'editDefaultValue',
319
+ Component: __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__.SchemaSettingsDefaultValue
311
320
  }
312
321
  ];
313
322
  }
@@ -0,0 +1,11 @@
1
+ import { type SelectProps } from 'antd';
2
+ import { FieldNames } from '../../../../schema-component';
3
+ export declare const SecondLevelSelect: import("react").ForwardRefExoticComponent<SelectProps<any, any> & {
4
+ objectValue?: boolean;
5
+ onChange?: (v: any) => void;
6
+ multiple: boolean;
7
+ rawOptions: any[];
8
+ fieldNames: FieldNames;
9
+ firstLevelValue: string;
10
+ collectionField: string;
11
+ } & import("react").RefAttributes<never>>;
@@ -0,0 +1,102 @@
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__tachybase_schema__ from "@tachybase/schema";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__ant_design_icons__ from "@ant-design/icons";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../../data-source/index.mjs";
8
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../../schema-component/index.mjs";
9
+ import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_select_ReadPretty_mjs__ from "../../../../schema-component/antd/select/ReadPretty.mjs";
10
+ const filterOption = (input, option)=>{
11
+ var _option_label;
12
+ return (null !== (_option_label = null == option ? void 0 : option.label) && void 0 !== _option_label ? _option_label : '').toLowerCase().includes((input || '').toLowerCase());
13
+ };
14
+ const SecondLevelSelect = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.connect)((props)=>{
15
+ const { objectValue, loading, value, rawOptions, defaultValue, firstLevelValue, collectionField, ...others } = props;
16
+ const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
17
+ const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
18
+ const cm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionManager)();
19
+ let mode = props.multiple ? 'multiple' : props.mode;
20
+ if (mode && ![
21
+ 'multiple',
22
+ 'tags'
23
+ ].includes(mode)) mode = void 0;
24
+ const toValue = (v)=>{
25
+ if ([
26
+ 'tags',
27
+ 'multiple'
28
+ ].includes(props.mode) || props.multiple) {
29
+ if (v) return (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.toArr)(v);
30
+ return;
31
+ }
32
+ return v;
33
+ };
34
+ const Parentoptions = cm.getCollectionFields("".concat(collectionField, ".").concat(firstLevelValue));
35
+ const fieldParentTabsOptions = Parentoptions.map((item)=>{
36
+ if ('m2o' === item.interface) return {
37
+ ...item,
38
+ label: compile(item.uiSchema.title),
39
+ value: item.name
40
+ };
41
+ }).filter(Boolean);
42
+ fieldParentTabsOptions.unshift({
43
+ label: t('none'),
44
+ value: 'none'
45
+ });
46
+ const matchedOption = fieldParentTabsOptions.find((option)=>option.value === value);
47
+ const newValue = matchedOption ? value : 'none';
48
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
49
+ if (!matchedOption) {
50
+ var _props_onChange;
51
+ null === (_props_onChange = props.onChange) || void 0 === _props_onChange || _props_onChange.call(props, 'none');
52
+ }
53
+ }, [
54
+ value,
55
+ fieldParentTabsOptions
56
+ ]);
57
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Select, {
58
+ role: "button",
59
+ "data-testid": "select-".concat(mode || 'single'),
60
+ showSearch: true,
61
+ filterOption: filterOption,
62
+ allowClear: {
63
+ clearIcon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__ant_design_icons__.CloseCircleFilled, {
64
+ role: "button",
65
+ "aria-label": "icon-close-select"
66
+ })
67
+ },
68
+ popupMatchSelectWidth: false,
69
+ notFoundContent: loading ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Spin, {}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Empty, {
70
+ image: __WEBPACK_EXTERNAL_MODULE_antd__.Empty.PRESENTED_IMAGE_SIMPLE
71
+ }),
72
+ value: toValue(newValue),
73
+ defaultValue: toValue(defaultValue),
74
+ tagRender: (props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Tag, {
75
+ role: "button",
76
+ "aria-label": props.label,
77
+ closeIcon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__ant_design_icons__.CloseOutlined, {
78
+ role: "button",
79
+ "aria-label": "icon-close-tag"
80
+ }),
81
+ ...props,
82
+ children: props.label
83
+ }),
84
+ options: fieldParentTabsOptions,
85
+ ...others,
86
+ onChange: (changed)=>{
87
+ var _props_onChange;
88
+ null === (_props_onChange = props.onChange) || void 0 === _props_onChange || _props_onChange.call(props, void 0 === changed ? null : changed);
89
+ },
90
+ mode: mode
91
+ });
92
+ }, (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.mapProps)({
93
+ dataSource: 'options'
94
+ }, (props, field)=>({
95
+ ...props,
96
+ fieldNames: {
97
+ ...__WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.defaultFieldNames,
98
+ ...props.fieldNames
99
+ },
100
+ suffixIcon: (null == field ? void 0 : field['loading']) || (null == field ? void 0 : field['validating']) ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__ant_design_icons__.LoadingOutlined, {}) : props.suffixIcon
101
+ })), (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.mapReadPretty)(__WEBPACK_EXTERNAL_MODULE__schema_component_antd_select_ReadPretty_mjs__.ReadPretty));
102
+ export { SecondLevelSelect };
@@ -1,5 +1,6 @@
1
1
  import { ISchema } from '@tachybase/schema';
2
2
  import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
3
+ import { FieldNames } from '../../../../schema-component';
3
4
  export declare const setDefaultSortingRules: {
4
5
  name: string;
5
6
  type: string;
@@ -29,52 +30,89 @@ export declare const allowAddNewData: {
29
30
  onChange(value: any): void;
30
31
  };
31
32
  };
32
- export declare const isQuickAddTabs: {
33
+ export declare const clickToSelect: {
33
34
  name: string;
34
35
  type: string;
35
36
  useVisible(): boolean;
36
37
  useComponentProps(): {
38
+ components: {
39
+ Switch: import("react").ForwardRefExoticComponent<Omit<import("antd").SwitchProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
40
+ SecondLevelSelect: import("react").ForwardRefExoticComponent<import("antd").SelectProps<any, any> & {
41
+ objectValue?: boolean;
42
+ onChange?: (v: any) => void;
43
+ multiple: boolean;
44
+ rawOptions: any[];
45
+ fieldNames: FieldNames;
46
+ firstLevelValue: string;
47
+ collectionField: string;
48
+ } & import("react").RefAttributes<never>>;
49
+ };
37
50
  title: string;
38
- checked: any;
39
- onChange(value: any): void;
40
- };
41
- };
42
- export declare const setQuickAddTabs: {
43
- name: string;
44
- type: string;
45
- useComponentProps(): {
46
- title: string;
47
- options: {
48
- label: any;
49
- value: any;
50
- name?: any;
51
- collectionName?: string;
52
- sourceKey?: string;
53
- uiSchema?: any;
54
- target?: string;
55
- }[];
56
- value: any;
57
- onChange(mode: any): void;
58
- };
59
- useVisible(): any;
60
- };
61
- export declare const setQuickAddParentTabs: {
62
- name: string;
63
- type: string;
64
- useComponentProps(): {
65
- title: string;
66
- options: {
67
- label: any;
68
- value: any;
69
- name?: any;
70
- collectionName?: string;
71
- sourceKey?: string;
72
- uiSchema?: any;
73
- target?: string;
74
- }[];
75
- value: any;
76
- onChange(mode: any): void;
51
+ schema: {
52
+ type: string;
53
+ title: string;
54
+ properties: {
55
+ isquickaddtabs: {
56
+ title: string;
57
+ type: string;
58
+ default: any;
59
+ 'x-decorator': string;
60
+ 'x-component': string;
61
+ 'x-component-props': {};
62
+ };
63
+ firstLevelselection: {
64
+ title: string;
65
+ default: any;
66
+ 'x-decorator': string;
67
+ 'x-component': string;
68
+ enum: {
69
+ label: any;
70
+ value: any;
71
+ name?: any;
72
+ collectionName?: string;
73
+ sourceKey?: string;
74
+ uiSchema?: any;
75
+ target?: string;
76
+ }[];
77
+ 'x-reactions': {
78
+ dependencies: string[];
79
+ fulfill: {
80
+ state: {
81
+ visible: string;
82
+ };
83
+ };
84
+ }[];
85
+ 'x-component-props': {
86
+ onChange(value: any): void;
87
+ };
88
+ };
89
+ secondLevelselection: {
90
+ title: string;
91
+ default: any;
92
+ 'x-decorator': string;
93
+ 'x-component': string;
94
+ 'x-reactions': {
95
+ dependencies: string[];
96
+ fulfill: {
97
+ state: {
98
+ visible: string;
99
+ };
100
+ schema: {
101
+ 'x-component-props': {
102
+ firstLevelValue: string;
103
+ collectionField: any;
104
+ };
105
+ };
106
+ };
107
+ }[];
108
+ };
109
+ };
110
+ };
111
+ onSubmit: ({ isquickaddtabs, firstLevelselection, secondLevelselection }: {
112
+ isquickaddtabs: any;
113
+ firstLevelselection: any;
114
+ secondLevelselection: any;
115
+ }) => Promise<void>;
77
116
  };
78
- useVisible(): boolean;
79
117
  };
80
118
  export declare const subTablePopoverComponentFieldSettings: SchemaSettings<{}>;
@@ -1,3 +1,4 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
1
2
  import * as __WEBPACK_EXTERNAL_MODULE__tachybase_components__ from "@tachybase/components";
2
3
  import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
3
4
  import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
@@ -8,6 +9,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../..
8
9
  import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../../schema-component/index.mjs";
9
10
  import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_association_field_util_mjs__ from "../../../../schema-component/antd/association-field/util.mjs";
10
11
  import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_index_mjs__ from "../../../../schema-component/antd/form-item/index.mjs";
12
+ import * as __WEBPACK_EXTERNAL_MODULE__secondLevelSelect_mjs__ from "./secondLevelSelect.mjs";
11
13
  const fieldComponent = {
12
14
  name: 'fieldComponent',
13
15
  type: 'select',
@@ -233,51 +235,24 @@ const allowAddNewData = {
233
235
  };
234
236
  }
235
237
  };
236
- const isQuickAddTabs = {
237
- name: 'isquickaddtabs',
238
- type: 'switch',
238
+ const clickToSelect = {
239
+ name: 'clicktoselect',
240
+ type: 'modal',
239
241
  useVisible () {
240
242
  const readPretty = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_index_mjs__.useIsFieldReadPretty)();
241
243
  const isAssociationField = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_index_mjs__.useIsAssociationField)();
242
244
  return !readPretty && isAssociationField;
243
245
  },
244
246
  useComponentProps () {
245
- var _fieldSchema_xcomponentprops;
247
+ var _fieldSchema_xcomponentprops_quickAddField, _fieldSchema_xcomponentprops_quickAddParentCollection, _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1;
246
248
  const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
247
249
  const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
248
250
  const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
249
251
  const { dn, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
250
- return {
251
- title: t('Is Quick Add Tabs'),
252
- checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.isQuickAdd) || false,
253
- onChange (value) {
254
- const schema = {
255
- ['x-uid']: fieldSchema['x-uid']
256
- };
257
- field.componentProps['isQuickAdd'] = value;
258
- fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
259
- fieldSchema['x-component-props']['isQuickAdd'] = value;
260
- schema['x-component-props'] = fieldSchema['x-component-props'];
261
- dn.emit('patch', {
262
- schema
263
- });
264
- refresh();
265
- }
266
- };
267
- }
268
- };
269
- const setQuickAddTabs = {
270
- name: 'setquickaddtabs',
271
- type: 'select',
272
- useComponentProps () {
273
- const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
274
- const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
275
252
  const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
276
- const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
277
253
  const cm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionManager)();
254
+ const [firstLevelValue, setFirstLevelValue] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)((null === (_fieldSchema_xcomponentprops_quickAddField = fieldSchema['x-component-props']['quickAddField']) || void 0 === _fieldSchema_xcomponentprops_quickAddField ? void 0 : _fieldSchema_xcomponentprops_quickAddField.value) || 'none');
278
255
  const options = cm.getCollection(fieldSchema['x-collection-field']);
279
- const defVal = fieldSchema['x-component-props']['quickAddField'] || 'none';
280
- const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
281
256
  const isAddNewForm = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useIsAddNewForm)();
282
257
  const fieldTabsOptions = options.fields.map((item)=>{
283
258
  if ('m2o' === item.interface || 'select' === item.interface) {
@@ -293,84 +268,117 @@ const setQuickAddTabs = {
293
268
  label: 'none',
294
269
  value: 'none'
295
270
  });
296
- return {
297
- title: t('Set Quick Add Tabs'),
298
- options: fieldTabsOptions,
299
- value: defVal,
300
- onChange (mode) {
301
- const schema = {
302
- ['x-uid']: fieldSchema['x-uid']
303
- };
304
- fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
305
- fieldSchema['x-component-props']['quickAddField'] = {
306
- fieldInterface: fieldTabsOptions.find((item)=>item.value === mode)['interface'] || 'none',
307
- value: mode
308
- };
309
- schema['x-component-props'] = fieldSchema['x-component-props'];
310
- field.componentProps = field.componentProps || {};
311
- field.componentProps['quickAddField'] = fieldSchema['x-component-props']['quickAddField'];
312
- if ((0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_association_field_util_mjs__.isSubMode)(fieldSchema) && isAddNewForm) {
313
- schema.default = null;
314
- fieldSchema.default = null;
315
- field.setInitialValue(null);
316
- field.setValue(null);
317
- }
318
- dn.emit('patch', {
319
- schema
320
- });
321
- dn.refresh();
322
- }
323
- };
324
- },
325
- useVisible () {
326
- const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
327
- return fieldSchema['x-component-props']['isQuickAdd'];
328
- }
329
- };
330
- const setQuickAddParentTabs = {
331
- name: 'setquickaddparenttabs',
332
- type: 'select',
333
- useComponentProps () {
334
- var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops_quickAddParentCollection, _fieldSchema_xcomponentprops1;
335
- const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
336
- const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
337
- const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
338
- const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
339
- const cm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionManager)();
340
- const { value: quickField } = (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['quickAddField']) || {};
341
- const options = cm.getCollectionFields("".concat(fieldSchema['x-collection-field'], ".").concat(quickField));
342
- const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
343
- const isAddNewForm = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useIsAddNewForm)();
344
- const fieldTabsOptions = options.map((item)=>{
271
+ const Parentoptions = cm.getCollectionFields("".concat(fieldSchema['x-collection-field'], ".").concat(firstLevelValue));
272
+ const fieldParentTabsOptions = Parentoptions.map((item)=>{
345
273
  if ('m2o' === item.interface) return {
346
274
  ...item,
347
275
  label: compile(item.uiSchema.title),
348
276
  value: item.name
349
277
  };
350
278
  }).filter(Boolean);
351
- fieldTabsOptions.unshift({
279
+ fieldParentTabsOptions.unshift({
352
280
  label: t('none'),
353
281
  value: 'none'
354
282
  });
355
- const defValue = (null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : null === (_fieldSchema_xcomponentprops_quickAddParentCollection = _fieldSchema_xcomponentprops1['quickAddParentCollection']) || void 0 === _fieldSchema_xcomponentprops_quickAddParentCollection ? void 0 : _fieldSchema_xcomponentprops_quickAddParentCollection.value) || 'none';
283
+ const defParentVal = (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : null === (_fieldSchema_xcomponentprops_quickAddParentCollection = _fieldSchema_xcomponentprops['quickAddParentCollection']) || void 0 === _fieldSchema_xcomponentprops_quickAddParentCollection ? void 0 : _fieldSchema_xcomponentprops_quickAddParentCollection.value) || 'none';
284
+ const schema = {
285
+ type: 'object',
286
+ title: t('Click to select'),
287
+ properties: {
288
+ isquickaddtabs: {
289
+ title: t('Enable quick create'),
290
+ type: 'boolean',
291
+ default: (null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1.isQuickAdd) || false,
292
+ 'x-decorator': 'FormItem',
293
+ 'x-component': 'Switch',
294
+ 'x-component-props': {}
295
+ },
296
+ firstLevelselection: {
297
+ title: t('Set Quick Add Tabs'),
298
+ default: firstLevelValue,
299
+ 'x-decorator': 'FormItem',
300
+ 'x-component': 'Select',
301
+ enum: fieldTabsOptions,
302
+ 'x-reactions': [
303
+ {
304
+ dependencies: [
305
+ 'isquickaddtabs'
306
+ ],
307
+ fulfill: {
308
+ state: {
309
+ visible: '{{$deps[0] === true}}'
310
+ }
311
+ }
312
+ }
313
+ ],
314
+ 'x-component-props': {
315
+ onChange (value) {
316
+ setFirstLevelValue(value);
317
+ }
318
+ }
319
+ },
320
+ secondLevelselection: {
321
+ title: t('Set Quick Add Parent Tabs'),
322
+ default: defParentVal,
323
+ 'x-decorator': 'FormItem',
324
+ 'x-component': 'SecondLevelSelect',
325
+ 'x-reactions': [
326
+ {
327
+ dependencies: [
328
+ 'firstLevelselection',
329
+ 'isquickaddtabs'
330
+ ],
331
+ fulfill: {
332
+ state: {
333
+ visible: '{{$deps[0] !== "none" && $deps[1] === true}}'
334
+ },
335
+ schema: {
336
+ 'x-component-props': {
337
+ firstLevelValue: '{{$deps[0]}}',
338
+ collectionField: fieldSchema['x-collection-field']
339
+ }
340
+ }
341
+ }
342
+ }
343
+ ]
344
+ }
345
+ }
346
+ };
356
347
  return {
357
- title: t('Set Quick Add Parent Tabs'),
358
- options: fieldTabsOptions,
359
- value: defValue,
360
- onChange (mode) {
348
+ components: {
349
+ Switch: __WEBPACK_EXTERNAL_MODULE__tachybase_components__.Switch,
350
+ SecondLevelSelect: __WEBPACK_EXTERNAL_MODULE__secondLevelSelect_mjs__.SecondLevelSelect
351
+ },
352
+ title: t('Quick create'),
353
+ schema,
354
+ onSubmit: async (param)=>{
355
+ let { isquickaddtabs, firstLevelselection, secondLevelselection } = param;
356
+ var _fieldTabsOptions_find;
361
357
  const schema = {
362
358
  ['x-uid']: fieldSchema['x-uid']
363
359
  };
360
+ field.componentProps['isQuickAdd'] = isquickaddtabs;
361
+ fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
362
+ fieldSchema['x-component-props']['isQuickAdd'] = isquickaddtabs;
363
+ schema['x-component-props'] = fieldSchema['x-component-props'];
364
+ fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
365
+ fieldSchema['x-component-props']['quickAddField'] = {
366
+ fieldInterface: (null === (_fieldTabsOptions_find = fieldTabsOptions.find((item)=>item.value === firstLevelselection)) || void 0 === _fieldTabsOptions_find ? void 0 : _fieldTabsOptions_find['interface']) || 'none',
367
+ value: firstLevelselection
368
+ };
369
+ schema['x-component-props'] = fieldSchema['x-component-props'];
370
+ field.componentProps = field.componentProps || {};
371
+ field.componentProps['quickAddField'] = fieldSchema['x-component-props']['quickAddField'];
364
372
  fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
365
373
  fieldSchema['x-component-props']['quickAddParentCollection'] = {
366
- collectionField: "".concat(fieldSchema['x-collection-field'], ".").concat(quickField, ".").concat(mode),
367
- value: mode
374
+ collectionField: "".concat(fieldSchema['x-collection-field'], ".").concat(firstLevelselection, ".").concat(secondLevelselection),
375
+ value: secondLevelselection
368
376
  };
369
377
  schema['x-component-props'] = fieldSchema['x-component-props'];
370
378
  field.componentProps = field.componentProps || {};
371
379
  field.componentProps['quickAddParentCollection'] = {
372
- collectionField: "".concat(fieldSchema['x-collection-field'], ".").concat(quickField, ".").concat(mode),
373
- value: mode
380
+ collectionField: "".concat(fieldSchema['x-collection-field'], ".").concat(firstLevelselection, ".").concat(secondLevelselection),
381
+ value: secondLevelselection
374
382
  };
375
383
  if ((0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_association_field_util_mjs__.isSubMode)(fieldSchema) && isAddNewForm) {
376
384
  schema.default = null;
@@ -379,15 +387,12 @@ const setQuickAddParentTabs = {
379
387
  field.setValue(null);
380
388
  }
381
389
  dn.emit('patch', {
382
- schema
390
+ schema: schema
383
391
  });
392
+ refresh();
384
393
  dn.refresh();
385
394
  }
386
395
  };
387
- },
388
- useVisible () {
389
- const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
390
- return fieldSchema['x-component-props']['isQuickAdd'] && fieldSchema['x-component-props']['quickAddField'] && 'none' !== fieldSchema['x-component-props']['quickAddField'];
391
396
  }
392
397
  };
393
398
  const subTablePopoverComponentFieldSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__.SchemaSettings({
@@ -397,9 +402,7 @@ const subTablePopoverComponentFieldSettings = new __WEBPACK_EXTERNAL_MODULE__app
397
402
  allowAddNewData,
398
403
  allowSelectExistingRecord,
399
404
  setDefaultSortingRules,
400
- isQuickAddTabs,
401
- setQuickAddTabs,
402
- setQuickAddParentTabs
405
+ clickToSelect
403
406
  ]
404
407
  });
405
- export { allowAddNewData, isQuickAddTabs, setDefaultSortingRules, setQuickAddParentTabs, setQuickAddTabs, subTablePopoverComponentFieldSettings };
408
+ export { allowAddNewData, clickToSelect, setDefaultSortingRules, subTablePopoverComponentFieldSettings };