@nocobase/client 0.12.0-alpha.2 → 0.12.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/es/api-client/hooks/useRequest.js +16 -1
  2. package/es/block-provider/BlockProvider.js +2 -2
  3. package/es/block-provider/hooks/index.js +16 -18
  4. package/es/collection-manager/Configuration/AddCollectionAction.js +2 -2
  5. package/es/collection-manager/Configuration/AddFieldAction.js +2 -1
  6. package/es/collection-manager/Configuration/EditFieldAction.js +2 -1
  7. package/es/collection-manager/action-hooks.js +3 -1
  8. package/es/global-theme/AntdAppProvider.js +5 -1
  9. package/es/locale/en_US.d.ts +4 -0
  10. package/es/locale/en_US.js +4 -0
  11. package/es/locale/ja_JP.d.ts +1 -0
  12. package/es/locale/ja_JP.js +1 -0
  13. package/es/locale/zh_CN.d.ts +6 -0
  14. package/es/locale/zh_CN.js +7 -1
  15. package/es/pm/Card.js +6 -1
  16. package/es/schema-component/antd/action/Action.Designer.js +243 -54
  17. package/es/schema-component/antd/action/Action.Drawer.js +2 -2
  18. package/es/schema-component/antd/action/Action.Modal.js +1 -1
  19. package/es/schema-component/antd/action/Action.js +15 -19
  20. package/es/schema-component/antd/appends-tree-select/AppendsTreeSelect.d.ts +8 -2
  21. package/es/schema-component/antd/appends-tree-select/AppendsTreeSelect.js +67 -36
  22. package/es/schema-component/antd/association-field/AssociationFieldProvider.js +3 -15
  23. package/es/schema-component/antd/association-field/Editable.js +2 -1
  24. package/es/schema-component/antd/association-field/FileManager.js +4 -3
  25. package/es/schema-component/antd/association-field/InternalNester.d.ts +1 -1
  26. package/es/schema-component/antd/association-field/InternalNester.js +6 -4
  27. package/es/schema-component/antd/association-field/InternalPicker.js +2 -1
  28. package/es/schema-component/antd/association-field/InternalPopoverNester.d.ts +2 -0
  29. package/es/schema-component/antd/association-field/InternalPopoverNester.js +95 -0
  30. package/es/schema-component/antd/association-field/InternalSubTable.js +2 -5
  31. package/es/schema-component/antd/association-field/InternalViewer.js +1 -1
  32. package/es/schema-component/antd/association-field/hooks.js +77 -5
  33. package/es/schema-component/antd/association-field/util.d.ts +4 -0
  34. package/es/schema-component/antd/association-field/util.js +32 -1
  35. package/es/schema-component/antd/color-picker/ReadPretty.js +1 -1
  36. package/es/schema-component/antd/form-item/FormItem.js +36 -112
  37. package/es/schema-component/antd/form-v2/Templates.js +12 -5
  38. package/es/schema-component/antd/grid-card/GridCard.Item.js +4 -4
  39. package/es/schema-component/antd/input/EllipsisWithTooltip.js +2 -1
  40. package/es/schema-component/antd/list/List.Item.js +3 -3
  41. package/es/schema-component/antd/markdown/Markdown.Void.js +6 -1
  42. package/es/schema-component/antd/markdown/Markdown.js +6 -1
  43. package/es/schema-component/antd/markdown/style.js +2 -4
  44. package/es/schema-component/antd/quick-edit/QuickEdit.js +5 -3
  45. package/es/schema-component/antd/remote-select/RemoteSelect.js +11 -79
  46. package/es/schema-component/antd/rich-text/RichText.js +7 -2
  47. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +45 -35
  48. package/es/schema-component/antd/table-v2/Table.js +12 -10
  49. package/es/schema-component/antd/table-v2/utils.d.ts +5 -0
  50. package/es/schema-component/antd/table-v2/utils.js +14 -1
  51. package/es/schema-component/antd/variable/Input.js +2 -1
  52. package/es/schema-component/antd/variable/TextArea.js +1 -1
  53. package/es/schema-component/common/utils/uitls.js +19 -2
  54. package/es/schema-component/hooks/useFieldModeOptions.d.ts +1 -1
  55. package/es/schema-component/hooks/useFieldModeOptions.js +23 -9
  56. package/es/schema-initializer/buttons/FormActionInitializers.d.ts +75 -0
  57. package/es/schema-initializer/buttons/FormActionInitializers.js +39 -11
  58. package/es/schema-initializer/buttons/RecordBlockInitializers.js +12 -0
  59. package/es/schema-initializer/items/CreateActionInitializer.js +2 -1
  60. package/es/schema-initializer/items/CreateSubmitActionInitializer.js +3 -0
  61. package/es/schema-initializer/items/RecordAssociationGridCardBlockInitializer.d.ts +2 -0
  62. package/es/schema-initializer/items/RecordAssociationGridCardBlockInitializer.js +74 -0
  63. package/es/schema-initializer/items/RecordAssociationListBlockInitializer.d.ts +2 -0
  64. package/es/schema-initializer/items/RecordAssociationListBlockInitializer.js +74 -0
  65. package/es/schema-initializer/items/RecordFormBlockInitializer.js +3 -2
  66. package/es/schema-initializer/items/RecordReadPrettyFormBlockInitializer.js +3 -2
  67. package/es/schema-initializer/items/UpdateSubmitActionInitializer.js +3 -0
  68. package/es/schema-initializer/items/index.d.ts +2 -0
  69. package/es/schema-initializer/items/index.js +2 -0
  70. package/es/schema-initializer/utils.js +6 -4
  71. package/es/schema-settings/DataTemplates/hooks/useCollectionState.js +2 -2
  72. package/es/schema-settings/DataTemplates/utils.js +1 -1
  73. package/es/schema-settings/LinkageRules/components/LinkageHeader.js +2 -2
  74. package/es/schema-settings/SchemaSettings.js +132 -19
  75. package/es/schema-settings/VariableInput/VariableInput.js +6 -3
  76. package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.d.ts +4 -1
  77. package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.js +22 -5
  78. package/es/schema-templates/SchemaTemplateManagerProvider.js +6 -1
  79. package/lib/api-client/hooks/useRequest.js +16 -1
  80. package/lib/block-provider/BlockProvider.js +2 -2
  81. package/lib/block-provider/hooks/index.js +21 -23
  82. package/lib/collection-manager/Configuration/AddCollectionAction.js +2 -2
  83. package/lib/collection-manager/Configuration/AddFieldAction.js +2 -1
  84. package/lib/collection-manager/Configuration/EditFieldAction.js +2 -1
  85. package/lib/collection-manager/action-hooks.js +3 -1
  86. package/lib/global-theme/AntdAppProvider.js +5 -1
  87. package/lib/locale/en_US.d.ts +4 -0
  88. package/lib/locale/en_US.js +4 -0
  89. package/lib/locale/ja_JP.d.ts +1 -0
  90. package/lib/locale/ja_JP.js +1 -0
  91. package/lib/locale/zh_CN.d.ts +6 -0
  92. package/lib/locale/zh_CN.js +7 -1
  93. package/lib/pm/Card.js +6 -1
  94. package/lib/schema-component/antd/action/Action.Designer.js +242 -53
  95. package/lib/schema-component/antd/action/Action.Drawer.js +2 -2
  96. package/lib/schema-component/antd/action/Action.Modal.js +1 -1
  97. package/lib/schema-component/antd/action/Action.js +15 -19
  98. package/lib/schema-component/antd/appends-tree-select/AppendsTreeSelect.d.ts +8 -2
  99. package/lib/schema-component/antd/appends-tree-select/AppendsTreeSelect.js +66 -35
  100. package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +3 -15
  101. package/lib/schema-component/antd/association-field/Editable.js +2 -1
  102. package/lib/schema-component/antd/association-field/FileManager.js +4 -3
  103. package/lib/schema-component/antd/association-field/InternalNester.d.ts +1 -1
  104. package/lib/schema-component/antd/association-field/InternalNester.js +5 -3
  105. package/lib/schema-component/antd/association-field/InternalPicker.js +2 -1
  106. package/lib/schema-component/antd/association-field/InternalPopoverNester.d.ts +2 -0
  107. package/lib/schema-component/antd/association-field/InternalPopoverNester.js +104 -0
  108. package/lib/schema-component/antd/association-field/InternalSubTable.js +1 -4
  109. package/lib/schema-component/antd/association-field/InternalViewer.js +1 -1
  110. package/lib/schema-component/antd/association-field/hooks.js +76 -4
  111. package/lib/schema-component/antd/association-field/util.d.ts +4 -0
  112. package/lib/schema-component/antd/association-field/util.js +37 -2
  113. package/lib/schema-component/antd/color-picker/ReadPretty.js +1 -1
  114. package/lib/schema-component/antd/form-item/FormItem.js +34 -110
  115. package/lib/schema-component/antd/form-v2/Templates.js +12 -5
  116. package/lib/schema-component/antd/grid-card/GridCard.Item.js +3 -3
  117. package/lib/schema-component/antd/input/EllipsisWithTooltip.js +2 -1
  118. package/lib/schema-component/antd/list/List.Item.js +2 -2
  119. package/lib/schema-component/antd/markdown/Markdown.Void.js +6 -1
  120. package/lib/schema-component/antd/markdown/Markdown.js +6 -1
  121. package/lib/schema-component/antd/markdown/style.js +2 -4
  122. package/lib/schema-component/antd/quick-edit/QuickEdit.js +5 -3
  123. package/lib/schema-component/antd/remote-select/RemoteSelect.js +11 -79
  124. package/lib/schema-component/antd/rich-text/RichText.js +6 -1
  125. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +44 -34
  126. package/lib/schema-component/antd/table-v2/Table.js +11 -9
  127. package/lib/schema-component/antd/table-v2/utils.d.ts +5 -0
  128. package/lib/schema-component/antd/table-v2/utils.js +16 -2
  129. package/lib/schema-component/antd/variable/Input.js +2 -1
  130. package/lib/schema-component/antd/variable/TextArea.js +1 -1
  131. package/lib/schema-component/common/utils/uitls.js +19 -2
  132. package/lib/schema-component/hooks/useFieldModeOptions.d.ts +1 -1
  133. package/lib/schema-component/hooks/useFieldModeOptions.js +23 -9
  134. package/lib/schema-initializer/buttons/FormActionInitializers.d.ts +75 -0
  135. package/lib/schema-initializer/buttons/FormActionInitializers.js +39 -11
  136. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +12 -0
  137. package/lib/schema-initializer/items/CreateActionInitializer.js +2 -1
  138. package/lib/schema-initializer/items/CreateSubmitActionInitializer.js +3 -0
  139. package/lib/schema-initializer/items/RecordAssociationGridCardBlockInitializer.d.ts +2 -0
  140. package/lib/schema-initializer/items/RecordAssociationGridCardBlockInitializer.js +82 -0
  141. package/lib/schema-initializer/items/RecordAssociationListBlockInitializer.d.ts +2 -0
  142. package/lib/schema-initializer/items/RecordAssociationListBlockInitializer.js +82 -0
  143. package/lib/schema-initializer/items/RecordFormBlockInitializer.js +3 -2
  144. package/lib/schema-initializer/items/RecordReadPrettyFormBlockInitializer.js +3 -2
  145. package/lib/schema-initializer/items/UpdateSubmitActionInitializer.js +3 -0
  146. package/lib/schema-initializer/items/index.d.ts +2 -0
  147. package/lib/schema-initializer/items/index.js +22 -0
  148. package/lib/schema-initializer/utils.js +6 -4
  149. package/lib/schema-settings/DataTemplates/hooks/useCollectionState.js +2 -2
  150. package/lib/schema-settings/DataTemplates/utils.js +1 -1
  151. package/lib/schema-settings/LinkageRules/components/LinkageHeader.js +1 -1
  152. package/lib/schema-settings/SchemaSettings.js +131 -18
  153. package/lib/schema-settings/VariableInput/VariableInput.js +5 -2
  154. package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.d.ts +4 -1
  155. package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.js +24 -6
  156. package/lib/schema-templates/SchemaTemplateManagerProvider.js +6 -1
  157. package/package.json +5 -5
  158. package/es/schema-component/antd/remote-select/utils.d.ts +0 -4
  159. package/es/schema-component/antd/remote-select/utils.js +0 -31
  160. package/lib/schema-component/antd/remote-select/utils.d.ts +0 -4
  161. package/lib/schema-component/antd/remote-select/utils.js +0 -41
@@ -20,21 +20,17 @@ import { LoadingOutlined } from '@ant-design/icons';
20
20
  import { connect, mapProps, mapReadPretty, useField, useFieldSchema, useForm } from '@formily/react';
21
21
  import dayjs from 'dayjs';
22
22
  import { Divider, Tag } from 'antd';
23
- import flat from 'flat';
24
- import _, { uniqBy } from 'lodash';
23
+ import { uniqBy } from 'lodash';
25
24
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
26
25
  import { useRequest } from '../../../api-client';
27
- import { useBlockRequestContext } from '../../../block-provider/BlockProvider';
28
26
  import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
29
27
  import { useCollection, useCollectionManager } from '../../../collection-manager';
30
- import { getInnermostKeyAndValue } from '../../common/utils/uitls';
31
28
  import { useCompile } from '../../hooks';
32
29
  import { Select, defaultFieldNames } from '../select';
33
30
  import { ReadPretty } from './ReadPretty';
34
- import { extractFilterfield, extractValuesByPattern, generatePattern, parseVariables } from './utils';
35
31
  var EMPTY = 'N/A';
36
32
  var InternalRemoteSelect = connect(function (props) {
37
- var _fieldSchema$xCompon, _ctx$props, _field$componentProps4, _field$componentProps5, _field$componentProps6, _service$params2;
33
+ var _fieldSchema$xCompon, _service$params;
38
34
  var _props$fieldNames = props.fieldNames,
39
35
  fieldNames = _props$fieldNames === void 0 ? {} : _props$fieldNames,
40
36
  _props$service = props.service,
@@ -59,7 +55,6 @@ var InternalRemoteSelect = connect(function (props) {
59
55
  var fieldSchema = useFieldSchema();
60
56
  var isQuickAdd = ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.addMode) === 'quickAdd';
61
57
  var field = useField();
62
- var ctx = useBlockRequestContext();
63
58
  var _useCollection = useCollection(),
64
59
  getField = _useCollection.getField;
65
60
  var searchData = useRef(null);
@@ -126,80 +121,16 @@ var InternalRemoteSelect = connect(function (props) {
126
121
  return options;
127
122
  }
128
123
  }, [targetField === null || targetField === void 0 ? void 0 : targetField.uiSchema, fieldNames]);
129
- var parseFilter = useCallback(function (rules) {
130
- if (!rules) {
131
- return undefined;
132
- }
133
- if (typeof rules === 'string') {
134
- return rules;
135
- }
136
- var type = Object.keys(rules)[0] || '$and';
137
- var conditions = rules[type];
138
- var results = [];
139
- conditions === null || conditions === void 0 ? void 0 : conditions.forEach(function (c) {
140
- var _jsonlogic$value, _jsonlogic$value$matc;
141
- var jsonlogic = getInnermostKeyAndValue(c);
142
- var regex = /{{(.*?)}}/;
143
- var matches = (_jsonlogic$value = jsonlogic.value) === null || _jsonlogic$value === void 0 ? void 0 : (_jsonlogic$value$matc = _jsonlogic$value.match) === null || _jsonlogic$value$matc === void 0 ? void 0 : _jsonlogic$value$matc.call(_jsonlogic$value, regex);
144
- if (!matches || !matches[1].includes('$form') && !matches[1].includes('$iteration')) {
145
- results.push(c);
146
- return;
147
- }
148
- var associationfield = extractFilterfield(matches[1]);
149
- var filterCollectionField = getCollectionJoinField("".concat(ctx.props.collection, ".").concat(associationfield));
150
- if (['o2m', 'm2m'].includes(filterCollectionField === null || filterCollectionField === void 0 ? void 0 : filterCollectionField.interface)) {
151
- // 对多子表单
152
- var pattern = generatePattern(matches === null || matches === void 0 ? void 0 : matches[1], associationfield);
153
- var parseValue = extractValuesByPattern(flat(form.values), pattern);
154
- var filters = parseValue.map(function (v) {
155
- return JSON.parse(JSON.stringify(c).replace(jsonlogic.value, v));
156
- });
157
- results.push({
158
- $or: filters
159
- });
160
- } else {
161
- var variablesCtx = {
162
- $form: form.values,
163
- $iteration: form.values
164
- };
165
- var str = matches === null || matches === void 0 ? void 0 : matches[1];
166
- if (str.includes('$iteration')) {
167
- var path = field.path.segments.concat([]);
168
- path.pop();
169
- str = str.replace('$iteration.', "$iteration.".concat(path.join('.'), "."));
170
- }
171
- var _parseValue = parseVariables(str, variablesCtx);
172
- if (Array.isArray(_parseValue)) {
173
- var _filters = _parseValue.map(function (v) {
174
- return JSON.parse(JSON.stringify(c).replace(jsonlogic.value, v));
175
- });
176
- results.push({
177
- $or: _filters
178
- });
179
- } else {
180
- var filterObj = JSON.parse(JSON.stringify(c).replace(jsonlogic.value, str.endsWith('id') ? _parseValue !== null && _parseValue !== void 0 ? _parseValue : 0 : _parseValue));
181
- results.push(filterObj);
182
- }
183
- }
184
- });
185
- return _defineProperty({}, type, results);
186
- }, [(_ctx$props = ctx.props) === null || _ctx$props === void 0 ? void 0 : _ctx$props.collection, field.path.segments, form.values, getCollectionJoinField]);
187
- var filter = useMemo(function () {
188
- var _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _field$componentProps, _field$componentProps2, _field$componentProps3, _fieldSchema$xCompon5, _fieldSchema$xCompon6, _fieldSchema$xCompon7, _service$params;
189
- var filterFromSchema = _.isString(fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : (_fieldSchema$xCompon3 = _fieldSchema$xCompon2.service) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : (_fieldSchema$xCompon4 = _fieldSchema$xCompon3.params) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.filter) ? (_field$componentProps = field.componentProps) === null || _field$componentProps === void 0 ? void 0 : (_field$componentProps2 = _field$componentProps.service) === null || _field$componentProps2 === void 0 ? void 0 : (_field$componentProps3 = _field$componentProps2.params) === null || _field$componentProps3 === void 0 ? void 0 : _field$componentProps3.filter : fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon5 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : (_fieldSchema$xCompon6 = _fieldSchema$xCompon5.service) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : (_fieldSchema$xCompon7 = _fieldSchema$xCompon6.params) === null || _fieldSchema$xCompon7 === void 0 ? void 0 : _fieldSchema$xCompon7.filter;
190
- return mergeFilter([parseFilter(filterFromSchema) || (service === null || service === void 0 ? void 0 : (_service$params = service.params) === null || _service$params === void 0 ? void 0 : _service$params.filter)]);
191
- }, [(_field$componentProps4 = field.componentProps) === null || _field$componentProps4 === void 0 ? void 0 : (_field$componentProps5 = _field$componentProps4.service) === null || _field$componentProps5 === void 0 ? void 0 : (_field$componentProps6 = _field$componentProps5.params) === null || _field$componentProps6 === void 0 ? void 0 : _field$componentProps6.filter, fieldSchema, parseFilter, service === null || service === void 0 ? void 0 : (_service$params2 = service.params) === null || _service$params2 === void 0 ? void 0 : _service$params2.filter]);
192
124
  var _useRequest = useRequest(_objectSpread(_objectSpread({
193
125
  action: 'list'
194
126
  }, service), {}, {
195
127
  params: _objectSpread(_objectSpread({
196
128
  pageSize: 200
197
129
  }, service === null || service === void 0 ? void 0 : service.params), {}, {
198
- // search needs
199
- filter: filter
130
+ filter: service === null || service === void 0 ? void 0 : (_service$params = service.params) === null || _service$params === void 0 ? void 0 : _service$params.filter
200
131
  })
201
132
  }), {
202
- manual: manual,
133
+ manual: manual && Object.prototype.toString.call(value) === '[object Object]',
203
134
  debounceWait: wait
204
135
  }),
205
136
  data = _useRequest.data,
@@ -230,12 +161,13 @@ var InternalRemoteSelect = connect(function (props) {
230
161
  }
231
162
  }, [runDep]);
232
163
  var onSearch = /*#__PURE__*/function () {
233
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(search) {
164
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(search) {
165
+ var _service$params2;
234
166
  return _regeneratorRuntime().wrap(function _callee$(_context) {
235
167
  while (1) switch (_context.prev = _context.next) {
236
168
  case 0:
237
169
  run({
238
- filter: mergeFilter([search ? _defineProperty({}, fieldNames.label, _defineProperty({}, operator, search)) : {}, filter])
170
+ filter: mergeFilter([search ? _defineProperty({}, fieldNames.label, _defineProperty({}, operator, search)) : {}, service === null || service === void 0 ? void 0 : (_service$params2 = service.params) === null || _service$params2 === void 0 ? void 0 : _service$params2.filter])
239
171
  });
240
172
  searchData.current = search;
241
173
  case 2:
@@ -245,7 +177,7 @@ var InternalRemoteSelect = connect(function (props) {
245
177
  }, _callee);
246
178
  }));
247
179
  return function onSearch(_x2) {
248
- return _ref2.apply(this, arguments);
180
+ return _ref.apply(this, arguments);
249
181
  };
250
182
  }();
251
183
  var options = useMemo(function () {
@@ -254,7 +186,7 @@ var InternalRemoteSelect = connect(function (props) {
254
186
  if (!(data !== null && data !== void 0 && (_data$data = data.data) !== null && _data$data !== void 0 && _data$data.length)) {
255
187
  return v != null ? Array.isArray(v) ? v : [v] : [];
256
188
  }
257
- var valueOptions = v != null && (Array.isArray(v) ? v : [v]) || [];
189
+ var valueOptions = v != null && (Array.isArray(v) ? v : [_objectSpread(_objectSpread({}, v), {}, _defineProperty({}, fieldNames.value, v[fieldNames.value] || v))]) || [];
258
190
  return uniqBy((data === null || data === void 0 ? void 0 : (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.concat(valueOptions)) || [], fieldNames.value);
259
191
  }, [value, defaultValue, data === null || data === void 0 ? void 0 : data.data, fieldNames.value]);
260
192
  var onDropdownVisibleChange = function onDropdownVisibleChange(visible) {
@@ -295,10 +227,10 @@ var InternalRemoteSelect = connect(function (props) {
295
227
  }, mapProps({
296
228
  dataSource: 'options'
297
229
  }, function (props, field) {
298
- var _fieldSchema$xCompon8;
230
+ var _fieldSchema$xCompon2;
299
231
  var fieldSchema = useFieldSchema();
300
232
  return _objectSpread(_objectSpread({}, props), {}, {
301
- fieldNames: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultFieldNames), props.fieldNames), field.componentProps.fieldNames), (_fieldSchema$xCompon8 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon8 === void 0 ? void 0 : _fieldSchema$xCompon8.fieldNames),
233
+ fieldNames: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultFieldNames), props.fieldNames), field.componentProps.fieldNames), (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.fieldNames),
302
234
  suffixIcon: field !== null && field !== void 0 && field['loading'] || field !== null && field !== void 0 && field['validating'] ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : props.suffixIcon
303
235
  });
304
236
  }), mapReadPretty(ReadPretty));
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- import { connect, mapReadPretty } from '@formily/react';
7
+ import { connect, mapReadPretty, mapProps } from '@formily/react';
8
8
  import React from 'react';
9
9
  import ReactQuill from 'react-quill';
10
10
  import { ReadPretty as InputReadPretty } from '../input';
@@ -33,6 +33,11 @@ export var RichText = connect(function (props) {
33
33
  onChange: onChange,
34
34
  readOnly: disabled
35
35
  }));
36
- }, mapReadPretty(function (props) {
36
+ }, mapProps(function (props) {
37
+ var value = props.value;
38
+ return _objectSpread(_objectSpread({}, props), {}, {
39
+ value: _typeof(value) === 'object' ? value === null || value === void 0 ? void 0 : value.default : value
40
+ });
41
+ }), mapReadPretty(function (props) {
37
42
  return /*#__PURE__*/React.createElement(InputReadPretty.Html, _objectSpread({}, props));
38
43
  }));
@@ -10,7 +10,7 @@ import React from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import { useCollectionFilterOptions, useCollectionManager } from '../../../collection-manager';
12
12
  import { GeneralSchemaDesigner, SchemaSettings, isPatternDisabled, isShowDefaultValue } from '../../../schema-settings';
13
- import { useCompile, useDesignable } from '../../hooks';
13
+ import { useCompile, useDesignable, useFieldModeOptions } from '../../hooks';
14
14
  import { useAssociationFieldContext } from '../association-field/hooks';
15
15
  import { removeNullCondition } from '../filter';
16
16
  import { FilterDynamicComponent } from './FilterDynamicComponent';
@@ -75,11 +75,14 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
75
75
  var isFileField = isFileCollection(targetCollection);
76
76
  var isSubTableColumn = ['QuickEdit', 'FormItem'].includes(fieldSchema['x-decorator']);
77
77
  var _useAssociationFieldC = useAssociationFieldContext(),
78
- currentMode = _useAssociationFieldC.currentMode,
79
- tableField = _useAssociationFieldC.field;
78
+ currentMode = _useAssociationFieldC.currentMode;
80
79
  var defaultFilter = (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : (_fieldSchema$xCompon3 = _fieldSchema$xCompon2.service) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : (_fieldSchema$xCompon4 = _fieldSchema$xCompon3.params) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.filter) || {};
81
80
  var dataSource = useCollectionFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
82
81
  var isDateField = ['datetime', 'createdAt', 'updatedAt'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
82
+ var isAssociationField = ['obo', 'oho', 'o2o', 'o2m', 'm2m', 'm2o', 'snapshot'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
83
+ var fieldModeOptions = useFieldModeOptions({
84
+ fieldSchema: fieldSchema
85
+ });
83
86
  var fieldMode = (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon5 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : _fieldSchema$xCompon5['mode']) || 'Select';
84
87
  var readOnlyMode = 'editable';
85
88
  if (fieldSchema['x-disabled'] === true) {
@@ -88,6 +91,7 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
88
91
  if (fieldSchema['x-read-pretty'] === true) {
89
92
  readOnlyMode = 'read-pretty';
90
93
  }
94
+ var isSelectFieldMode = isAssociationField && fieldMode === 'Select';
91
95
  return /*#__PURE__*/React.createElement(GeneralSchemaDesigner, {
92
96
  disableInitializer: true
93
97
  }, /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
@@ -120,7 +124,7 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
120
124
  }
121
125
  dn.refresh();
122
126
  }
123
- }), currentMode && !field.readPretty && /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
127
+ }), isSelectFieldMode && !field.readPretty && !(uiSchema !== null && uiSchema !== void 0 && uiSchema['x-read-pretty']) && /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
124
128
  title: t('Set the data scope'),
125
129
  schema: {
126
130
  type: 'object',
@@ -145,10 +149,11 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
145
149
  set(field.componentProps, 'service.params.filter', filter);
146
150
  fieldSchema['x-component-props'] = field.componentProps;
147
151
  var path = (_field$path = field.path) === null || _field$path === void 0 ? void 0 : _field$path.splice(((_field$path2 = field.path) === null || _field$path2 === void 0 ? void 0 : _field$path2.length) - 1, 1);
148
- tableField === null || tableField === void 0 ? void 0 : tableField.value.map(function (_, index) {
149
- field.form.query("".concat(path.concat("".concat(index, ".") + fieldSchema.name))).take(function (f) {
150
- set(f.componentProps, 'service.params.filter', filter);
151
- });
152
+ field.form.query("".concat(path.concat("*." + fieldSchema.name))).forEach(function (f) {
153
+ f.componentProps.service = f.componentProps.service || {
154
+ params: {}
155
+ };
156
+ f.componentProps.service.params.filter = filter;
152
157
  });
153
158
  dn.emit('patch', {
154
159
  schema: (_schema = {}, _defineProperty(_schema, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema, 'x-component-props', field.componentProps), _schema)
@@ -219,12 +224,13 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
219
224
  options: options,
220
225
  value: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames['label'],
221
226
  onChange: function onChange(label) {
222
- var _collectionField$uiSc2, _fieldSchema$xCompon7;
227
+ var _collectionField$uiSc2, _fieldSchema$xCompon7, _field$path3, _field$path4;
223
228
  var fieldNames = _objectSpread(_objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2['x-component-props']['fieldNames']), fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon7 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon7 === void 0 ? void 0 : _fieldSchema$xCompon7['fieldNames']), {}, {
224
229
  label: label
225
230
  });
226
231
  fieldSchema['x-component-props']['fieldNames'] = fieldNames;
227
- field.query(".*.".concat(fieldSchema.name)).take(function (f) {
232
+ var path = (_field$path3 = field.path) === null || _field$path3 === void 0 ? void 0 : _field$path3.splice(((_field$path4 = field.path) === null || _field$path4 === void 0 ? void 0 : _field$path4.length) - 1, 1);
233
+ field.form.query("".concat(path.concat("*." + fieldSchema.name))).forEach(function (f) {
228
234
  f.componentProps.fieldNames = fieldNames;
229
235
  });
230
236
  dn.emit('patch', {
@@ -235,16 +241,16 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
235
241
  });
236
242
  dn.refresh();
237
243
  }
238
- }), readOnlyMode === 'read-pretty' && ['linkTo', 'm2m', 'm2o', 'o2m', 'obo', 'oho', 'snapshot'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) && /*#__PURE__*/React.createElement(SchemaSettings.SelectItem, {
244
+ }), isAssociationField && /*#__PURE__*/React.createElement(SchemaSettings.SelectItem, {
239
245
  key: "field-mode",
240
246
  title: t('Field component'),
241
- options: [{
247
+ options: readOnlyMode === 'read-pretty' ? [{
242
248
  label: t('Title'),
243
249
  value: 'Select'
244
250
  }, {
245
251
  label: t('Tag'),
246
252
  value: 'Tag'
247
- }],
253
+ }] : fieldModeOptions,
248
254
  value: fieldMode,
249
255
  onChange: function onChange(mode) {
250
256
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
@@ -279,15 +285,13 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
279
285
  title: t('Required'),
280
286
  checked: fieldSchema.required,
281
287
  onChange: function onChange(required) {
282
- var _field$path3, _field$path4;
288
+ var _field$path5, _field$path6;
283
289
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
284
290
  fieldSchema['required'] = required;
285
291
  schema['required'] = required;
286
- var path = (_field$path3 = field.path) === null || _field$path3 === void 0 ? void 0 : _field$path3.splice(((_field$path4 = field.path) === null || _field$path4 === void 0 ? void 0 : _field$path4.length) - 1, 1);
287
- tableField === null || tableField === void 0 ? void 0 : tableField.value.map(function (_, index) {
288
- field.form.query("".concat(path.concat("".concat(index, ".") + fieldSchema.name))).take(function (f) {
289
- f.required = required;
290
- });
292
+ var path = (_field$path5 = field.path) === null || _field$path5 === void 0 ? void 0 : _field$path5.splice(((_field$path6 = field.path) === null || _field$path6 === void 0 ? void 0 : _field$path6.length) - 1, 1);
293
+ field.form.query("".concat(path.concat("*." + fieldSchema.name))).forEach(function (f) {
294
+ f.required = required;
291
295
  });
292
296
  dn.emit('patch', {
293
297
  schema: schema
@@ -309,9 +313,9 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
309
313
  }],
310
314
  value: readOnlyMode,
311
315
  onChange: function onChange(v) {
312
- var _field$path5, _field$path6;
316
+ var _field$path7, _field$path8;
313
317
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
314
- var path = (_field$path5 = field.path) === null || _field$path5 === void 0 ? void 0 : _field$path5.splice(((_field$path6 = field.path) === null || _field$path6 === void 0 ? void 0 : _field$path6.length) - 1, 1);
318
+ var path = (_field$path7 = field.path) === null || _field$path7 === void 0 ? void 0 : _field$path7.splice(((_field$path8 = field.path) === null || _field$path8 === void 0 ? void 0 : _field$path8.length) - 1, 1);
315
319
  switch (v) {
316
320
  case 'readonly':
317
321
  {
@@ -319,11 +323,9 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
319
323
  fieldSchema['x-disabled'] = true;
320
324
  schema['x-read-pretty'] = false;
321
325
  schema['x-disabled'] = true;
322
- tableField === null || tableField === void 0 ? void 0 : tableField.value.map(function (_, index) {
323
- field.form.query("".concat(path.concat("".concat(index, ".") + fieldSchema.name))).take(function (f) {
324
- f.readonly = true;
325
- f.disabled = true;
326
- });
326
+ field.form.query("".concat(path.concat("*." + fieldSchema.name))).forEach(function (f) {
327
+ f.readonly = true;
328
+ f.disabled = true;
327
329
  });
328
330
  break;
329
331
  }
@@ -333,10 +335,8 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
333
335
  fieldSchema['x-disabled'] = false;
334
336
  schema['x-read-pretty'] = true;
335
337
  schema['x-disabled'] = false;
336
- tableField === null || tableField === void 0 ? void 0 : tableField.value.map(function (_, index) {
337
- field.form.query("".concat(path.concat("".concat(index, ".") + fieldSchema.name))).take(function (f) {
338
- f.readPretty = true;
339
- });
338
+ field.form.query("".concat(path.concat("*." + fieldSchema.name))).forEach(function (f) {
339
+ f.readPretty = true;
340
340
  });
341
341
  break;
342
342
  }
@@ -346,11 +346,9 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
346
346
  fieldSchema['x-disabled'] = false;
347
347
  schema['x-read-pretty'] = false;
348
348
  schema['x-disabled'] = false;
349
- tableField === null || tableField === void 0 ? void 0 : tableField.value.map(function (_, index) {
350
- field.form.query("".concat(path.concat("".concat(index, ".") + fieldSchema.name))).take(function (f) {
351
- f.readPretty = false;
352
- f.disabled + false;
353
- });
349
+ field.form.query("".concat(path.concat("*." + fieldSchema.name))).forEach(function (f) {
350
+ f.readPretty = false;
351
+ f.disabled + false;
354
352
  });
355
353
  break;
356
354
  }
@@ -362,6 +360,18 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
362
360
  }
363
361
  }), isDateField && /*#__PURE__*/React.createElement(SchemaSettings.DataFormat, {
364
362
  fieldSchema: fieldSchema
363
+ }), isSubTableColumn && !(field !== null && field !== void 0 && field.readPretty) && ['obo', 'oho', 'o2o', 'o2m', 'm2m', 'm2o'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) && /*#__PURE__*/React.createElement(SchemaSettings.SortingRule, {
364
+ fieldSchema: fieldSchema,
365
+ onSubmitCallBack: function onSubmitCallBack(sortArr) {
366
+ var _field$path9, _field$path10;
367
+ var path = (_field$path9 = field.path) === null || _field$path9 === void 0 ? void 0 : _field$path9.splice(((_field$path10 = field.path) === null || _field$path10 === void 0 ? void 0 : _field$path10.length) - 1, 1);
368
+ field.form.query("".concat(path.concat("*." + fieldSchema.name))).forEach(function (f) {
369
+ f.componentProps.service = f.componentProps.service || {
370
+ params: {}
371
+ };
372
+ f.componentProps.service.params.sort = sortArr;
373
+ });
374
+ }
365
375
  }), isSubTableColumn && !(field !== null && field !== void 0 && field.readPretty) && isShowDefaultValue(collectionField, getInterface) && /*#__PURE__*/React.createElement(SchemaSettings.DefaultValue, {
366
376
  fieldSchema: fieldSchema
367
377
  }), /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Remove, {
@@ -38,7 +38,7 @@ import { RecordIndexProvider, RecordProvider, useSchemaInitializer, useTableBloc
38
38
  import { useACLFieldWhitelist } from '../../../acl/ACLProvider';
39
39
  import { useToken } from '../__builtins__';
40
40
  import { ColumnFieldProvider } from './components/ColumnFieldProvider';
41
- import { extractIndex, isCollectionFieldComponent, isColumnComponent } from './utils';
41
+ import { extractIndex, isCollectionFieldComponent, isColumnComponent, isPortalInBody } from './utils';
42
42
  var useArrayField = function useArrayField(props) {
43
43
  var field = useField();
44
44
  return props.field || field;
@@ -274,8 +274,11 @@ export var Table = observer(function (props) {
274
274
  if (onClickRow) {
275
275
  onRow = function onRow(record) {
276
276
  return {
277
- onClick: function onClick() {
278
- return onClickRow(record, setSelectedRow, selectedRow);
277
+ onClick: function onClick(e) {
278
+ if (isPortalInBody(e.target)) {
279
+ return;
280
+ }
281
+ onClickRow(record, setSelectedRow, selectedRow);
279
282
  }
280
283
  };
281
284
  };
@@ -328,7 +331,7 @@ export var Table = observer(function (props) {
328
331
  },
329
332
  cell: function cell(props) {
330
333
  return /*#__PURE__*/React.createElement("td", _objectSpread(_objectSpread({}, props), {}, {
331
- className: classNames(props.className, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n .nb-read-pretty-input-number {\n text-align: right;\n }\n .ant-color-picker-trigger{\n position:absolute;\n top:50%;\n transform: translateY(-50%);\n }\n "]))))
334
+ className: classNames(props.className, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n .nb-read-pretty-input-number {\n text-align: right;\n }\n .ant-color-picker-trigger {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n }\n "]))))
332
335
  }));
333
336
  }
334
337
  }
@@ -390,11 +393,8 @@ export var Table = observer(function (props) {
390
393
  var _field$value4, _field$value4$map;
391
394
  var children = _ref3.children;
392
395
  return dragSort ? /*#__PURE__*/React.createElement(SortableContext, {
393
- items: ((_field$value4 = field.value) === null || _field$value4 === void 0 ? void 0 : (_field$value4$map = _field$value4.map) === null || _field$value4$map === void 0 ? void 0 : _field$value4$map.call(_field$value4, getRowKey)) || [],
394
- children: children
395
- }) : /*#__PURE__*/React.createElement(React.Fragment, {
396
- children: children
397
- });
396
+ items: ((_field$value4 = field.value) === null || _field$value4 === void 0 ? void 0 : (_field$value4$map = _field$value4.map) === null || _field$value4$map === void 0 ? void 0 : _field$value4$map.call(_field$value4, getRowKey)) || []
397
+ }, children) : /*#__PURE__*/React.createElement(React.Fragment, {}, children);
398
398
  }, [field, dragSort]);
399
399
  var fieldSchema = useFieldSchema();
400
400
  var fixedBlock = fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$parent = fieldSchema.parent) === null || _fieldSchema$parent === void 0 ? void 0 : (_fieldSchema$parent$x = _fieldSchema$parent['x-decorator-props']) === null || _fieldSchema$parent$x === void 0 ? void 0 : _fieldSchema$parent$x.fixedBlock;
@@ -442,7 +442,9 @@ export var Table = observer(function (props) {
442
442
  className: "ant-formily-item-error-help ant-formily-item-help ant-formily-item-help-enter ant-formily-item-help-enter-active"
443
443
  }, field.errors.map(function (error) {
444
444
  return error.messages.map(function (message) {
445
- return /*#__PURE__*/React.createElement("div", null, message);
445
+ return /*#__PURE__*/React.createElement("div", {
446
+ key: message
447
+ }, message);
446
448
  });
447
449
  })));
448
450
  }, {
@@ -2,3 +2,8 @@ import { ISchema, Schema } from '@formily/react';
2
2
  export declare const isCollectionFieldComponent: (schema: ISchema) => boolean;
3
3
  export declare const isColumnComponent: (schema: Schema) => boolean;
4
4
  export declare function extractIndex(str: any): string;
5
+ /**
6
+ * 判断一个 DOM 对象是否是由 createPortal 挂在到了 body 上
7
+ * @param domNode DOM 对象
8
+ */
9
+ export declare const isPortalInBody: (dom: HTMLElement) => boolean;
@@ -13,4 +13,17 @@ export function extractIndex(str) {
13
13
  }
14
14
  });
15
15
  return numbers.join('.');
16
- }
16
+ }
17
+ /**
18
+ * 判断一个 DOM 对象是否是由 createPortal 挂在到了 body 上
19
+ * @param domNode DOM 对象
20
+ */
21
+ export var isPortalInBody = function isPortalInBody(dom) {
22
+ while (dom) {
23
+ if (dom.id === 'root') {
24
+ return false;
25
+ }
26
+ dom = dom.parentNode;
27
+ }
28
+ return true;
29
+ };
@@ -226,12 +226,13 @@ export function Input(props) {
226
226
  }, [scope]);
227
227
  var loadData = /*#__PURE__*/function () {
228
228
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(selectedOptions) {
229
+ var _option$children;
229
230
  var option;
230
231
  return _regeneratorRuntime().wrap(function _callee$(_context) {
231
232
  while (1) switch (_context.prev = _context.next) {
232
233
  case 0:
233
234
  option = selectedOptions[selectedOptions.length - 1];
234
- if (!(!option.children && !option.isLeaf && option.loadChildren)) {
235
+ if (!(!((_option$children = option.children) !== null && _option$children !== void 0 && _option$children.length) && !option.isLeaf && option.loadChildren)) {
235
236
  _context.next = 5;
236
237
  break;
237
238
  }
@@ -383,7 +383,7 @@ export function TextArea(props) {
383
383
  var disabled = props.disabled || form.disabled;
384
384
  return wrapSSR( /*#__PURE__*/React.createElement(Input.Group, {
385
385
  compact: true,
386
- className: cx(componentCls, hashId, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.ant-input-group.ant-input-group-compact {\n display: flex;\n .ant-input {\n flex-grow: 1;\n min-width: 200px;\n }\n .ant-input-disabled {\n .ant-tag {\n color: #bfbfbf;\n border-color: #d9d9d9;\n }\n }\n }\n "]))))
386
+ className: cx(componentCls, hashId, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.ant-input-group.ant-input-group-compact {\n display: flex;\n .ant-input {\n flex-grow: 1;\n min-width: 200px;\n }\n .ant-input-disabled {\n .ant-tag {\n color: #bfbfbf;\n border-color: #d9d9d9;\n }\n }\n }\n\n > .x-button {\n height: min-content;\n }\n "]))))
387
387
  }, /*#__PURE__*/React.createElement("div", {
388
388
  onInput: onInput,
389
389
  onBlur: onBlur,
@@ -1,9 +1,12 @@
1
+ var _excluded = ["children"];
1
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
7
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
10
  import dayjs from 'dayjs';
8
11
  import flat from 'flat';
9
12
  import _, { every, findIndex, isArray, some } from 'lodash';
@@ -11,14 +14,28 @@ import { useMemo } from 'react';
11
14
  import { useTableBlockContext } from '../../../block-provider';
12
15
  import { useCurrentUserContext } from '../../../user';
13
16
  import jsonLogic from '../../common/utils/logic';
17
+ function flattenDeep(data) {
18
+ var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
19
+ for (var i = 0; i < (data === null || data === void 0 ? void 0 : data.length); i++) {
20
+ var _data$i = data[i],
21
+ children = _data$i.children,
22
+ rest = _objectWithoutProperties(_data$i, _excluded);
23
+ result.push(rest);
24
+ if (children) {
25
+ flattenDeep(children, result);
26
+ }
27
+ }
28
+ return result;
29
+ }
14
30
  export var useVariablesCtx = function useVariablesCtx() {
15
- var _service$data, _service$data$data, _currentUser$data2;
31
+ var _service$data, _currentUser$data2;
16
32
  var currentUser = useCurrentUserContext();
17
33
  var _useTableBlockContext = useTableBlockContext(),
18
34
  field = _useTableBlockContext.field,
19
35
  service = _useTableBlockContext.service,
20
36
  rowKey = _useTableBlockContext.rowKey;
21
- var contextData = service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : (_service$data$data = _service$data.data) === null || _service$data$data === void 0 ? void 0 : _service$data$data.filter(function (v) {
37
+ var tableData = flattenDeep(service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : _service$data.data);
38
+ var contextData = tableData === null || tableData === void 0 ? void 0 : tableData.filter(function (v) {
22
39
  var _ref, _field$data;
23
40
  return (_ref = (field === null || field === void 0 ? void 0 : (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.selectedRowKeys) || []) === null || _ref === void 0 ? void 0 : _ref.includes(v[rowKey]);
24
41
  });
@@ -1,4 +1,4 @@
1
- export declare const useFieldModeOptions: () => {
1
+ export declare const useFieldModeOptions: (props?: any) => {
2
2
  label: string;
3
3
  value: string;
4
4
  }[];
@@ -2,14 +2,16 @@ import { useField, useFieldSchema } from '@formily/react';
2
2
  import { useMemo } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useCollection, useCollectionManager } from '../../collection-manager';
5
- export var useFieldModeOptions = function useFieldModeOptions() {
5
+ export var useFieldModeOptions = function useFieldModeOptions(props) {
6
6
  var _fieldSchema$xCompon;
7
7
  var _useCollectionManager = useCollectionManager(),
8
8
  getCollectionJoinField = _useCollectionManager.getCollectionJoinField,
9
9
  getCollection = _useCollectionManager.getCollection;
10
- var fieldSchema = useFieldSchema();
10
+ var currentFieldSchema = useFieldSchema();
11
+ var fieldSchema = (props === null || props === void 0 ? void 0 : props.fieldSchema) || currentFieldSchema;
11
12
  var field = useField();
12
13
  var isReadPretty = field.readPretty;
14
+ var isSubTableField = props === null || props === void 0 ? void 0 : props.fieldSchema;
13
15
  var _useCollection = useCollection(),
14
16
  getField = _useCollection.getField;
15
17
  var collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
@@ -39,7 +41,7 @@ export var useFieldModeOptions = function useFieldModeOptions() {
39
41
  }, {
40
42
  label: t('Record picker'),
41
43
  value: 'Picker'
42
- }, {
44
+ }, !isSubTableField && {
43
45
  label: t('File manager'),
44
46
  value: 'FileManager'
45
47
  }];
@@ -64,10 +66,13 @@ export var useFieldModeOptions = function useFieldModeOptions() {
64
66
  }, {
65
67
  label: t('Record picker'),
66
68
  value: 'Picker'
67
- }, {
69
+ }, !isSubTableField && {
68
70
  label: t('Sub-form'),
69
71
  value: 'Nester'
70
72
  }, {
73
+ label: t('Sub-form(Popover)'),
74
+ value: 'PopoverNester'
75
+ }, !isSubTableField && {
71
76
  label: t('Sub-table'),
72
77
  value: 'SubTable'
73
78
  }];
@@ -90,12 +95,15 @@ export var useFieldModeOptions = function useFieldModeOptions() {
90
95
  }, {
91
96
  label: t('Record picker'),
92
97
  value: 'Picker'
93
- }, {
98
+ }, !isSubTableField && {
94
99
  label: t('Sub-table'),
95
100
  value: 'SubTable'
96
- }, {
101
+ }, !isSubTableField && {
97
102
  label: t('Sub-form'),
98
103
  value: 'Nester'
104
+ }, {
105
+ label: t('Sub-form(Popover)'),
106
+ value: 'PopoverNester'
99
107
  }];
100
108
  case 'm2o':
101
109
  case 'linkTo':
@@ -114,9 +122,12 @@ export var useFieldModeOptions = function useFieldModeOptions() {
114
122
  }, {
115
123
  label: t('Record picker'),
116
124
  value: 'Picker'
117
- }, {
125
+ }, !isSubTableField && {
118
126
  label: t('Sub-form'),
119
127
  value: 'Nester'
128
+ }, {
129
+ label: t('Sub-form(Popover)'),
130
+ value: 'PopoverNester'
120
131
  }];
121
132
  default:
122
133
  return isReadPretty ? [{
@@ -134,11 +145,14 @@ export var useFieldModeOptions = function useFieldModeOptions() {
134
145
  }, {
135
146
  label: t('Record picker'),
136
147
  value: 'Picker'
137
- }, {
148
+ }, !isSubTableField && {
138
149
  label: t('Sub-form'),
139
150
  value: 'Nester'
151
+ }, {
152
+ label: t('Sub-form(Popover)'),
153
+ value: 'PopoverNester'
140
154
  }];
141
155
  }
142
156
  }, [t, collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface, label]);
143
- return fieldModeOptions;
157
+ return (fieldModeOptions || []).filter(Boolean);
144
158
  };