@nocobase/client 0.7.2-alpha.5 → 0.7.3-alpha.1

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 (93) hide show
  1. package/es/block-provider/FormBlockProvider.js +8 -3
  2. package/es/block-provider/TableSelectorProvider.js +41 -13
  3. package/es/block-provider/hooks/index.d.ts +6 -0
  4. package/es/block-provider/hooks/index.js +145 -63
  5. package/es/collection-manager/CollectionField.js +5 -3
  6. package/es/collection-manager/interfaces/input.js +103 -0
  7. package/es/collection-manager/interfaces/integer.js +63 -0
  8. package/es/collection-manager/interfaces/markdown.js +34 -0
  9. package/es/collection-manager/interfaces/number.js +55 -0
  10. package/es/collection-manager/interfaces/password.js +35 -1
  11. package/es/collection-manager/interfaces/percent.js +97 -0
  12. package/es/collection-manager/interfaces/richText.js +34 -0
  13. package/es/collection-manager/interfaces/textarea.js +34 -0
  14. package/es/file-manager/FileStorageShortcut.js +2 -2
  15. package/es/locale/en_US.d.ts +5 -0
  16. package/es/locale/en_US.js +6 -1
  17. package/es/locale/zh_CN.d.ts +23 -0
  18. package/es/locale/zh_CN.js +24 -1
  19. package/es/plugin-manager/PluginManager.js +8 -4
  20. package/es/schema-component/antd/action/Action.Modal.js +1 -1
  21. package/es/schema-component/antd/form-item/FormItem.js +156 -3
  22. package/es/schema-component/antd/grid/Grid.js +72 -6
  23. package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  24. package/es/schema-component/antd/input-number/InputNumber.js +25 -1
  25. package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  26. package/es/schema-component/antd/menu/Menu.js +6 -3
  27. package/es/schema-component/antd/percent/Percent.js +2 -2
  28. package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
  29. package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
  30. package/es/schema-component/antd/table/Table.Array.js +2 -2
  31. package/es/schema-component/antd/table/Table.Void.js +11 -1
  32. package/es/schema-component/antd/table-v2/Table.js +1 -4
  33. package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
  34. package/es/schema-component/hooks/useDesignable.js +21 -21
  35. package/es/schema-component/hooks/useProps.js +1 -1
  36. package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
  37. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  38. package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
  39. package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
  40. package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
  41. package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  42. package/es/schema-initializer/components/assigned-field/AssignedField.js +253 -69
  43. package/es/schema-initializer/items/index.d.ts +2 -0
  44. package/es/schema-initializer/items/index.js +46 -1
  45. package/es/schema-initializer/utils.js +6 -2
  46. package/es/system-settings/SystemSettingsShortcut.js +35 -12
  47. package/lib/block-provider/FormBlockProvider.js +7 -2
  48. package/lib/block-provider/TableSelectorProvider.js +41 -13
  49. package/lib/block-provider/hooks/index.d.ts +6 -0
  50. package/lib/block-provider/hooks/index.js +154 -65
  51. package/lib/collection-manager/CollectionField.js +5 -2
  52. package/lib/collection-manager/interfaces/input.js +104 -0
  53. package/lib/collection-manager/interfaces/integer.js +65 -0
  54. package/lib/collection-manager/interfaces/markdown.js +35 -0
  55. package/lib/collection-manager/interfaces/number.js +56 -0
  56. package/lib/collection-manager/interfaces/password.js +36 -1
  57. package/lib/collection-manager/interfaces/percent.js +99 -0
  58. package/lib/collection-manager/interfaces/richText.js +35 -0
  59. package/lib/collection-manager/interfaces/textarea.js +35 -0
  60. package/lib/file-manager/FileStorageShortcut.js +1 -1
  61. package/lib/locale/en_US.d.ts +5 -0
  62. package/lib/locale/en_US.js +6 -1
  63. package/lib/locale/zh_CN.d.ts +23 -0
  64. package/lib/locale/zh_CN.js +24 -1
  65. package/lib/plugin-manager/PluginManager.js +8 -3
  66. package/lib/schema-component/antd/action/Action.Modal.js +1 -1
  67. package/lib/schema-component/antd/form-item/FormItem.js +165 -5
  68. package/lib/schema-component/antd/grid/Grid.js +69 -3
  69. package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  70. package/lib/schema-component/antd/input-number/InputNumber.js +29 -2
  71. package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  72. package/lib/schema-component/antd/menu/Menu.js +6 -3
  73. package/lib/schema-component/antd/percent/Percent.js +2 -2
  74. package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
  75. package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  76. package/lib/schema-component/antd/table/Table.Array.js +2 -2
  77. package/lib/schema-component/antd/table/Table.Void.js +11 -1
  78. package/lib/schema-component/antd/table-v2/Table.js +1 -4
  79. package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
  80. package/lib/schema-component/hooks/useDesignable.js +21 -21
  81. package/lib/schema-component/hooks/useProps.js +1 -1
  82. package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
  83. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  84. package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
  85. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
  86. package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
  87. package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  88. package/lib/schema-initializer/components/assigned-field/AssignedField.js +254 -66
  89. package/lib/schema-initializer/items/index.d.ts +2 -0
  90. package/lib/schema-initializer/items/index.js +52 -1
  91. package/lib/schema-initializer/utils.js +6 -2
  92. package/lib/system-settings/SystemSettingsShortcut.js +37 -13
  93. package/package.json +6 -4
@@ -1,9 +1,3 @@
1
- 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; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
2
 
9
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -16,81 +10,271 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
10
 
17
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
12
 
19
- import { useField, useFieldSchema } from '@formily/react'; // import { Select, Space } from 'antd';
13
+ 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; }
14
+
15
+ 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; }
20
16
 
21
- import React, { useState } from 'react';
17
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+
19
+ import { connect, useField, useFieldSchema } from '@formily/react';
20
+ import { Cascader, Select, Space } from 'antd';
21
+ import React, { useEffect, useState } from 'react';
22
22
  import { useTranslation } from 'react-i18next';
23
- import { CollectionField } from '../../../collection-manager';
24
- import { useCompile } from '../../../schema-component';
23
+ import { useFormBlockContext } from '../../../block-provider';
24
+ import { CollectionFieldProvider, useCollection, useCollectionField, useCollectionFilterOptions } from '../../../collection-manager';
25
+ import { useCompile, useComponent } from '../../../schema-component';
26
+ var DYNAMIC_RECORD_REG = /\{\{\s*currentRecord\.(.*)\s*\}\}/;
27
+ var DYNAMIC_USER_REG = /\{\{\s*currentUser\.(.*)\s*\}\}/;
28
+ var DYNAMIC_TIME_REG = /\{\{\s*currentTime\s*\}\}/;
29
+
30
+ var InternalField = function InternalField(props) {
31
+ var field = useField();
32
+ var fieldSchema = useFieldSchema();
33
+
34
+ var _useCollectionField = useCollectionField(),
35
+ name = _useCollectionField.name,
36
+ interfaceType = _useCollectionField.interface,
37
+ uiSchema = _useCollectionField.uiSchema;
38
+
39
+ var component = useComponent(uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['x-component']);
40
+ var compile = useCompile();
41
+
42
+ var setFieldProps = function setFieldProps(key, value) {
43
+ field[key] = typeof field[key] === 'undefined' ? value : field[key];
44
+ };
45
+
46
+ var setRequired = function setRequired() {
47
+ if (typeof fieldSchema['required'] === 'undefined') {
48
+ field.required = !!uiSchema['required'];
49
+ }
50
+ };
51
+
52
+ var ctx = useFormBlockContext();
53
+ useEffect(function () {
54
+ if (ctx === null || ctx === void 0 ? void 0 : ctx.field) {
55
+ ctx.field.added = ctx.field.added || new Set();
56
+ ctx.field.added.add(fieldSchema.name);
57
+ }
58
+ });
59
+ useEffect(function () {
60
+ if (!uiSchema) {
61
+ return;
62
+ }
63
+
64
+ setFieldProps('content', uiSchema['x-content']);
65
+ setFieldProps('title', uiSchema.title);
66
+ setFieldProps('description', uiSchema.description);
67
+ setFieldProps('initialValue', uiSchema.default);
68
+
69
+ if (!field.validator && uiSchema['x-validator']) {
70
+ field.validator = uiSchema['x-validator'];
71
+ }
72
+
73
+ if (fieldSchema['x-disabled'] === true) {
74
+ field.disabled = true;
75
+ }
76
+
77
+ if (fieldSchema['x-read-pretty'] === true) {
78
+ field.readPretty = true;
79
+ }
80
+
81
+ setRequired(); // @ts-ignore
82
+ // field.dataSource = uiSchema.enum;
83
+ // const originalProps = compile(uiSchema['x-component-props']) || {};
84
+ // const componentProps = merge(originalProps, field.componentProps || {});
85
+ // field.component = [component, componentProps];
86
+ }, [JSON.stringify(uiSchema)]);
87
+
88
+ if (!uiSchema) {
89
+ return null;
90
+ }
91
+
92
+ return /*#__PURE__*/React.createElement(component, props, props.children);
93
+ };
94
+
95
+ var CollectionField = connect(function (props) {
96
+ var fieldSchema = useFieldSchema();
97
+ return /*#__PURE__*/React.createElement(CollectionFieldProvider, {
98
+ name: fieldSchema.name
99
+ }, /*#__PURE__*/React.createElement(InternalField, _objectSpread({}, props)));
100
+ });
101
+ export var AssignedFieldValueType;
102
+
103
+ (function (AssignedFieldValueType) {
104
+ AssignedFieldValueType["ConstantValue"] = "constantValue";
105
+ AssignedFieldValueType["DynamicValue"] = "dynamicValue";
106
+ })(AssignedFieldValueType || (AssignedFieldValueType = {}));
107
+
25
108
  export var AssignedField = function AssignedField(props) {
26
- var _field$value$value, _field$value;
109
+ var _initFieldType, _DYNAMIC_RECORD_REG$e, _DYNAMIC_RECORD_REG$e2, _DYNAMIC_RECORD_REG$e3, _DYNAMIC_USER_REG$exe, _DYNAMIC_USER_REG$exe2, _DYNAMIC_USER_REG$exe3;
27
110
 
28
111
  var _useTranslation = useTranslation(),
29
112
  t = _useTranslation.t;
30
113
 
31
114
  var compile = useCompile();
32
115
  var field = useField();
33
- var fieldSchema = useFieldSchema(); // const [type, setType] = useState<string>('constantValue');
116
+ var fieldSchema = useFieldSchema();
117
+ var isDynamicValue = DYNAMIC_RECORD_REG.test(field.value) || DYNAMIC_USER_REG.test(field.value) || DYNAMIC_TIME_REG.test(field.value);
118
+ var initType = isDynamicValue ? AssignedFieldValueType.DynamicValue : AssignedFieldValueType.ConstantValue;
34
119
 
35
- var _useState = useState((_field$value$value = field === null || field === void 0 ? void 0 : (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.value) !== null && _field$value$value !== void 0 ? _field$value$value : ''),
120
+ var _useState = useState(initType),
36
121
  _useState2 = _slicedToArray(_useState, 2),
37
- value = _useState2[0],
38
- setValue = _useState2[1]; // const [options, setOptions] = useState<any[]>([]);
39
- // const { getField } = useCollection();
40
- // const collectionField = getField(fieldSchema.name);
41
- // const { uiSchema } = collectionField;
42
- // const currentUser = useFilterOptions('users');
43
- // const currentRecord = useFilterOptions(collectionField.collectionName);
44
- // useEffect(() => {
45
- // const opt = [
46
- // {
47
- // name: 'currentUser',
48
- // title: t('Current user'),
49
- // children: [...currentUser],
50
- // },
51
- // {
52
- // name: 'currentRecord',
53
- // title: t('Current record'),
54
- // children: [...currentRecord],
55
- // },
56
- // ];
57
- // setOptions(compile(opt));
58
- // }, []);
122
+ type = _useState2[0],
123
+ setType = _useState2[1];
124
+
125
+ var initFieldType = (_initFieldType = {}, _defineProperty(_initFieldType, "".concat(DYNAMIC_TIME_REG.test(field.value)), 'currentTime'), _defineProperty(_initFieldType, "".concat(DYNAMIC_USER_REG.test(field.value)), 'currentUser'), _defineProperty(_initFieldType, "".concat(DYNAMIC_RECORD_REG.test(field.value)), 'currentRecord'), _initFieldType);
126
+
127
+ var _useState3 = useState(initFieldType['true']),
128
+ _useState4 = _slicedToArray(_useState3, 2),
129
+ fieldType = _useState4[0],
130
+ setFieldType = _useState4[1];
131
+
132
+ var initRecordValue = (_DYNAMIC_RECORD_REG$e = (_DYNAMIC_RECORD_REG$e2 = DYNAMIC_RECORD_REG.exec(field.value)) === null || _DYNAMIC_RECORD_REG$e2 === void 0 ? void 0 : (_DYNAMIC_RECORD_REG$e3 = _DYNAMIC_RECORD_REG$e2[1]) === null || _DYNAMIC_RECORD_REG$e3 === void 0 ? void 0 : _DYNAMIC_RECORD_REG$e3.split('.')) !== null && _DYNAMIC_RECORD_REG$e !== void 0 ? _DYNAMIC_RECORD_REG$e : [];
133
+
134
+ var _useState5 = useState(initRecordValue),
135
+ _useState6 = _slicedToArray(_useState5, 2),
136
+ recordValue = _useState6[0],
137
+ setRecordValue = _useState6[1];
138
+
139
+ var initUserValue = (_DYNAMIC_USER_REG$exe = (_DYNAMIC_USER_REG$exe2 = DYNAMIC_USER_REG.exec(field.value)) === null || _DYNAMIC_USER_REG$exe2 === void 0 ? void 0 : (_DYNAMIC_USER_REG$exe3 = _DYNAMIC_USER_REG$exe2[1]) === null || _DYNAMIC_USER_REG$exe3 === void 0 ? void 0 : _DYNAMIC_USER_REG$exe3.split('.')) !== null && _DYNAMIC_USER_REG$exe !== void 0 ? _DYNAMIC_USER_REG$exe : [];
140
+
141
+ var _useState7 = useState(initUserValue),
142
+ _useState8 = _slicedToArray(_useState7, 2),
143
+ userValue = _useState8[0],
144
+ setUserValue = _useState8[1];
145
+
146
+ var initValue = isDynamicValue ? '' : field.value;
59
147
 
148
+ var _useState9 = useState(initValue),
149
+ _useState10 = _slicedToArray(_useState9, 2),
150
+ value = _useState10[0],
151
+ setValue = _useState10[1];
152
+
153
+ var _useState11 = useState([]),
154
+ _useState12 = _slicedToArray(_useState11, 2),
155
+ options = _useState12[0],
156
+ setOptions = _useState12[1];
157
+
158
+ var _useCollection = useCollection(),
159
+ getField = _useCollection.getField;
160
+
161
+ var collectionField = getField(fieldSchema.name);
162
+ var fields = useCollectionFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.collectionName);
163
+ var userFields = useCollectionFilterOptions('users');
164
+ var dateTimeFields = ['createdAt', 'datetime', 'time', 'updatedAt'];
165
+ useEffect(function () {
166
+ var opt = [{
167
+ name: 'currentRecord',
168
+ title: t('Current record')
169
+ }, {
170
+ name: 'currentUser',
171
+ title: t('Current user')
172
+ }];
173
+
174
+ if (dateTimeFields.includes(collectionField.interface)) {
175
+ opt.unshift({
176
+ name: 'currentTime',
177
+ title: t('Current time')
178
+ });
179
+ } else {}
180
+
181
+ setOptions(compile(opt));
182
+ }, []);
183
+ useEffect(function () {
184
+ if (type === AssignedFieldValueType.ConstantValue) {
185
+ field.value = value;
186
+ } else {
187
+ if (fieldType === 'currentTime') {
188
+ field.value = '{{currentTime}}';
189
+ } else if (fieldType === 'currentUser') {
190
+ (userValue === null || userValue === void 0 ? void 0 : userValue.length) > 0 && (field.value = "{{currentUser.".concat(userValue.join('.'), "}}"));
191
+ } else if (fieldType === 'currentRecord') {
192
+ (recordValue === null || recordValue === void 0 ? void 0 : recordValue.length) > 0 && (field.value = "{{currentRecord.".concat(recordValue.join('.'), "}}"));
193
+ }
194
+ }
195
+ }, [type, value, fieldType, userValue, recordValue]);
196
+ useEffect(function () {
197
+ if (type === AssignedFieldValueType.ConstantValue) {
198
+ setFieldType(null);
199
+ setUserValue([]);
200
+ setRecordValue([]);
201
+ }
202
+ }, [type]);
203
+
204
+ var typeChangeHandler = function typeChangeHandler(val) {
205
+ setType(val);
206
+ };
60
207
 
61
208
  var valueChangeHandler = function valueChangeHandler(val) {
62
- setValue(val);
63
- }; // const typeChangeHandler = (val) => {
64
- // setType(val);
65
- // };
66
-
67
-
68
- return /*#__PURE__*/React.createElement(CollectionField, _objectSpread(_objectSpread({}, props), {}, {
69
- value: field.value,
70
- onChange: valueChangeHandler
71
- })); // return (
72
- // <Space>
73
- // <Select defaultValue={type} value={type} style={{ width: 120 }} onChange={typeChangeHandler}>
74
- // <Select.Option value="constantValue">{t('Constant value')}</Select.Option>
75
- // <Select.Option value="dynamicValue">{t('Dynamic value')}</Select.Option>
76
- // </Select>
77
- // {type === 'constantValue' ? (
78
- // <CollectionField {...props} onChange={valueChangeHandler} />
79
- // ) : (
80
- // <Cascader
81
- // fieldNames={{
82
- // label: 'title',
83
- // value: 'name',
84
- // children: 'children',
85
- // }}
86
- // style={{
87
- // width: 150,
88
- // }}
89
- // options={options}
90
- // onChange={valueChangeHandler}
91
- // defaultValue={value}
92
- // />
93
- // )}
94
- // </Space>
95
- // );
209
+ var _val$target$value, _val$target;
210
+
211
+ setValue((_val$target$value = val === null || val === void 0 ? void 0 : (_val$target = val.target) === null || _val$target === void 0 ? void 0 : _val$target.value) !== null && _val$target$value !== void 0 ? _val$target$value : val);
212
+ };
213
+
214
+ var fieldTypeChangeHandler = function fieldTypeChangeHandler(val) {
215
+ setFieldType(val);
216
+ };
217
+
218
+ var recordChangeHandler = function recordChangeHandler(val) {
219
+ setRecordValue(val);
220
+ };
221
+
222
+ var userChangeHandler = function userChangeHandler(val) {
223
+ setUserValue(val);
224
+ };
225
+
226
+ return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Select, {
227
+ defaultValue: type,
228
+ value: type,
229
+ style: {
230
+ width: 150
231
+ },
232
+ onChange: typeChangeHandler
233
+ }, /*#__PURE__*/React.createElement(Select.Option, {
234
+ value: AssignedFieldValueType.ConstantValue
235
+ }, t('Constant value')), /*#__PURE__*/React.createElement(Select.Option, {
236
+ value: AssignedFieldValueType.DynamicValue
237
+ }, t('Dynamic value'))), type === AssignedFieldValueType.ConstantValue ? /*#__PURE__*/React.createElement(CollectionField, _objectSpread(_objectSpread({}, props), {}, {
238
+ value: value,
239
+ onChange: valueChangeHandler,
240
+ style: {
241
+ minWidth: 150
242
+ }
243
+ })) : /*#__PURE__*/React.createElement(Select, {
244
+ defaultValue: fieldType,
245
+ value: fieldType,
246
+ style: {
247
+ minWidth: 150
248
+ },
249
+ onChange: fieldTypeChangeHandler
250
+ }, options === null || options === void 0 ? void 0 : options.map(function (opt) {
251
+ return /*#__PURE__*/React.createElement(Select.Option, {
252
+ key: opt.name,
253
+ value: opt.name
254
+ }, opt.title);
255
+ })), fieldType === 'currentRecord' && /*#__PURE__*/React.createElement(Cascader, {
256
+ fieldNames: {
257
+ label: 'title',
258
+ value: 'name',
259
+ children: 'children'
260
+ },
261
+ style: {
262
+ minWidth: 150
263
+ },
264
+ options: compile(fields),
265
+ onChange: recordChangeHandler,
266
+ defaultValue: recordValue
267
+ }), fieldType === 'currentUser' && /*#__PURE__*/React.createElement(Cascader, {
268
+ fieldNames: {
269
+ label: 'title',
270
+ value: 'name',
271
+ children: 'children'
272
+ },
273
+ style: {
274
+ minWidth: 150
275
+ },
276
+ options: compile(userFields),
277
+ onChange: userChangeHandler,
278
+ defaultValue: userValue
279
+ }));
96
280
  };
@@ -15,7 +15,9 @@ export declare const CreateActionInitializer: (props: any) => JSX.Element;
15
15
  export declare const ViewActionInitializer: (props: any) => JSX.Element;
16
16
  export declare const UpdateActionInitializer: (props: any) => JSX.Element;
17
17
  export declare const DestroyActionInitializer: (props: any) => JSX.Element;
18
+ export declare const PrintActionInitializer: (props: any) => JSX.Element;
18
19
  export declare const BulkDestroyActionInitializer: (props: any) => JSX.Element;
20
+ export declare const RefreshActionInitializer: (props: any) => JSX.Element;
19
21
  export declare const SubmitActionInitializer: (props: any) => JSX.Element;
20
22
  export declare const CreateSubmitActionInitializer: (props: any) => JSX.Element;
21
23
  export declare const UpdateSubmitActionInitializer: (props: any) => JSX.Element;
@@ -31,7 +31,7 @@ import { merge } from '@formily/shared';
31
31
  import React, { useContext } from 'react';
32
32
  import { useTranslation } from 'react-i18next';
33
33
  import { useAPIClient } from '../../api-client';
34
- import { useBlockAssociationContext } from '../../block-provider';
34
+ import { useBlockAssociationContext, useBlockRequestContext } from '../../block-provider';
35
35
  import { useCollection, useCollectionManager } from '../../collection-manager';
36
36
  import { SchemaComponent, SchemaComponentOptions } from '../../schema-component';
37
37
  import { useSchemaTemplateManager } from '../../schema-templates';
@@ -693,6 +693,21 @@ export var DestroyActionInitializer = function DestroyActionInitializer(props) {
693
693
  schema: schema
694
694
  }));
695
695
  };
696
+ export var PrintActionInitializer = function PrintActionInitializer(props) {
697
+ var schema = {
698
+ title: '{{ t("Print") }}',
699
+ 'x-action': 'print',
700
+ 'x-component': 'Action',
701
+ 'x-designer': 'Action.Designer',
702
+ 'x-component-props': {
703
+ icon: 'PrinterOutlined',
704
+ useProps: '{{ useDetailPrintActionProps }}'
705
+ }
706
+ };
707
+ return /*#__PURE__*/React.createElement(ActionInitializer, _objectSpread(_objectSpread({}, props), {}, {
708
+ schema: schema
709
+ }));
710
+ };
696
711
  export var BulkDestroyActionInitializer = function BulkDestroyActionInitializer(props) {
697
712
  var schema = {
698
713
  title: '{{ t("Delete") }}',
@@ -712,6 +727,21 @@ export var BulkDestroyActionInitializer = function BulkDestroyActionInitializer(
712
727
  schema: schema
713
728
  }));
714
729
  };
730
+ export var RefreshActionInitializer = function RefreshActionInitializer(props) {
731
+ var schema = {
732
+ title: '{{ t("Refresh") }}',
733
+ 'x-action': 'refresh',
734
+ 'x-component': 'Action',
735
+ 'x-designer': 'Action.Designer',
736
+ 'x-component-props': {
737
+ icon: 'ReloadOutlined',
738
+ useProps: '{{ useRefreshActionProps }}'
739
+ }
740
+ };
741
+ return /*#__PURE__*/React.createElement(ActionInitializer, _objectSpread(_objectSpread({}, props), {}, {
742
+ schema: schema
743
+ }));
744
+ };
715
745
  export var SubmitActionInitializer = function SubmitActionInitializer(props) {
716
746
  var schema = {
717
747
  title: '{{ t("Submit") }}',
@@ -851,6 +881,7 @@ export var RecordFormBlockInitializer = function RecordFormBlockInitializer(prop
851
881
 
852
882
  var collection = useCollection();
853
883
  var association = useBlockAssociationContext();
884
+ console.log('RecordFormBlockInitializer', collection, association);
854
885
  return /*#__PURE__*/React.createElement(SchemaInitializer.Item, _objectSpread(_objectSpread({
855
886
  icon: /*#__PURE__*/React.createElement(FormOutlined, null)
856
887
  }, others), {}, {
@@ -936,6 +967,11 @@ export var RecordReadPrettyFormBlockInitializer = function RecordReadPrettyFormB
936
967
 
937
968
  var collection = useCollection();
938
969
  var association = useBlockAssociationContext();
970
+
971
+ var _useBlockRequestConte = useBlockRequestContext(),
972
+ block = _useBlockRequestConte.block;
973
+
974
+ var actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null;
939
975
  return /*#__PURE__*/React.createElement(SchemaInitializer.Item, _objectSpread(_objectSpread({
940
976
  icon: /*#__PURE__*/React.createElement(FormOutlined, null)
941
977
  }, others), {}, {
@@ -962,6 +998,7 @@ export var RecordReadPrettyFormBlockInitializer = function RecordReadPrettyFormB
962
998
 
963
999
  if (item.template.componentName === 'ReadPrettyFormItem') {
964
1000
  blockSchema = createReadPrettyFormBlockSchema({
1001
+ actionInitializers: actionInitializers,
965
1002
  association: association,
966
1003
  collection: collection.name,
967
1004
  action: 'get',
@@ -984,6 +1021,7 @@ export var RecordReadPrettyFormBlockInitializer = function RecordReadPrettyFormB
984
1021
 
985
1022
  case 8:
986
1023
  insert(createReadPrettyFormBlockSchema({
1024
+ actionInitializers: actionInitializers,
987
1025
  association: association,
988
1026
  collection: collection.name,
989
1027
  action: 'get',
@@ -1113,6 +1151,11 @@ export var RecordReadPrettyAssociationFormBlockInitializer = function RecordRead
1113
1151
  var field = item.field;
1114
1152
  var collection = field.target;
1115
1153
  var resource = "".concat(field.collectionName, ".").concat(field.name);
1154
+
1155
+ var _useBlockRequestConte2 = useBlockRequestContext(),
1156
+ block = _useBlockRequestConte2.block;
1157
+
1158
+ var actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null;
1116
1159
  return /*#__PURE__*/React.createElement(SchemaInitializer.Item, _objectSpread(_objectSpread({
1117
1160
  icon: /*#__PURE__*/React.createElement(FormOutlined, null)
1118
1161
  }, others), {}, {
@@ -1138,6 +1181,7 @@ export var RecordReadPrettyAssociationFormBlockInitializer = function RecordRead
1138
1181
 
1139
1182
  if (item.template.componentName === 'ReadPrettyFormItem') {
1140
1183
  blockSchema = createReadPrettyFormBlockSchema({
1184
+ actionInitializers: actionInitializers,
1141
1185
  collection: collection,
1142
1186
  resource: resource,
1143
1187
  association: resource,
@@ -1161,6 +1205,7 @@ export var RecordReadPrettyAssociationFormBlockInitializer = function RecordRead
1161
1205
 
1162
1206
  case 8:
1163
1207
  insert(createReadPrettyFormBlockSchema({
1208
+ actionInitializers: actionInitializers,
1164
1209
  collection: collection,
1165
1210
  resource: resource,
1166
1211
  association: resource,
@@ -260,8 +260,9 @@ export var useAssociatedFormItemInitializerFields = function useAssociatedFormIt
260
260
  _ref2$block = _ref2.block,
261
261
  block = _ref2$block === void 0 ? 'Form' : _ref2$block;
262
262
 
263
+ var interfaces = block === 'Form' ? ['m2o'] : ['o2o', 'oho', 'obo', 'm2o'];
263
264
  var groups = fields === null || fields === void 0 ? void 0 : (_fields$filter3 = fields.filter(function (field) {
264
- return ['o2o', 'oho', 'obo', 'm2o'].includes(field.interface);
265
+ return interfaces.includes(field.interface);
265
266
  })) === null || _fields$filter3 === void 0 ? void 0 : _fields$filter3.map(function (field) {
266
267
  var _subFields$filter2, _field$uiSchema4;
267
268
 
@@ -278,7 +279,10 @@ export var useAssociatedFormItemInitializerFields = function useAssociatedFormIt
278
279
  // title: subField?.uiSchema?.title || subField.name,
279
280
  'x-designer': 'FormItem.Designer',
280
281
  'x-component': 'CollectionField',
281
- 'x-component-props': {},
282
+ 'x-read-pretty': readPretty,
283
+ 'x-component-props': {
284
+ 'pattern-disable': block === 'Form' && readPretty
285
+ },
282
286
  'x-decorator': 'FormItem',
283
287
  'x-collection-field': "".concat(name, ".").concat(field.name, ".").concat(subField.name)
284
288
  }; // interfaceConfig?.schemaInitialize?.(schema, { field, block: 'Form', readPretty: form.readPretty });
@@ -23,10 +23,11 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
23
23
  import { SettingOutlined } from '@ant-design/icons';
24
24
  import { useForm } from '@formily/react';
25
25
  import { uid } from '@formily/shared';
26
+ import cloneDeep from 'lodash/cloneDeep';
26
27
  import React, { useState } from 'react';
27
28
  import { useTranslation } from 'react-i18next';
28
29
  import { useSystemSettings } from '.';
29
- import { PluginManager, useAPIClient, useRequest } from '..';
30
+ import { i18n, PluginManager, useAPIClient, useRequest } from '..';
30
31
  import locale from '../locale';
31
32
  import { ActionContext, SchemaComponent, useActionContext } from '../schema-component';
32
33
  var langs = Object.keys(locale).map(function (lang) {
@@ -86,6 +87,9 @@ var useSaveSystemSettingsValues = function useSaveSystemSettingsValues() {
86
87
  return {
87
88
  run: function run() {
88
89
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
90
+ var _values$enabledLangua;
91
+
92
+ var values, lang;
89
93
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
90
94
  while (1) {
91
95
  switch (_context2.prev = _context2.next) {
@@ -94,18 +98,28 @@ var useSaveSystemSettingsValues = function useSaveSystemSettingsValues() {
94
98
  return form.submit();
95
99
 
96
100
  case 2:
97
- setVisible(false);
101
+ values = cloneDeep(form.values);
98
102
  mutate({
99
- data: _objectSpread(_objectSpread({}, data === null || data === void 0 ? void 0 : data.data), form.values)
103
+ data: _objectSpread(_objectSpread({}, data === null || data === void 0 ? void 0 : data.data), values)
100
104
  });
101
105
  _context2.next = 6;
102
106
  return api.request({
103
107
  url: 'systemSettings:update/1',
104
108
  method: 'post',
105
- data: form.values
109
+ data: values
106
110
  });
107
111
 
108
112
  case 6:
113
+ lang = ((_values$enabledLangua = values.enabledLanguages) === null || _values$enabledLangua === void 0 ? void 0 : _values$enabledLangua[0]) || 'en-US';
114
+
115
+ if (values.enabledLanguages.length < 2 && api.auth.getLocale() !== lang) {
116
+ api.auth.setLocale('');
117
+ window.location.reload();
118
+ } else {
119
+ setVisible(false);
120
+ }
121
+
122
+ case 8:
109
123
  case "end":
110
124
  return _context2.stop();
111
125
  }
@@ -153,14 +167,23 @@ var schema = {
153
167
  mode: 'multiple'
154
168
  },
155
169
  'x-decorator': 'FormItem',
156
- enum: langs
157
- },
158
- appLang: {
159
- type: 'string',
160
- title: '{{t("Default language")}}',
161
- 'x-component': 'Select',
162
- 'x-decorator': 'FormItem',
163
- enum: langs
170
+ enum: langs,
171
+ 'x-reactions': function xReactions(field) {
172
+ field.dataSource = langs.map(function (item) {
173
+ var _field$value;
174
+
175
+ var label = item.label;
176
+
177
+ if (((_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value[0]) === item.value) {
178
+ label += "(".concat(i18n.t('Default'), ")");
179
+ }
180
+
181
+ return {
182
+ label: label,
183
+ value: item.value
184
+ };
185
+ });
186
+ }
164
187
  },
165
188
  allowSignUp: {
166
189
  type: 'boolean',
@@ -44,6 +44,8 @@ var InternalFormBlockProvider = function InternalFormBlockProvider(props) {
44
44
  resource = _useBlockRequestConte.resource,
45
45
  service = _useBlockRequestConte.service;
46
46
 
47
+ var formBlockRef = (0, _react2.useRef)();
48
+
47
49
  if (service.loading) {
48
50
  return /*#__PURE__*/_react2.default.createElement(_antd.Spin, null);
49
51
  }
@@ -55,9 +57,12 @@ var InternalFormBlockProvider = function InternalFormBlockProvider(props) {
55
57
  field: field,
56
58
  service: service,
57
59
  resource: resource,
58
- updateAssociationValues: []
60
+ updateAssociationValues: [],
61
+ formBlockRef: formBlockRef
59
62
  }
60
- }, props.children);
63
+ }, /*#__PURE__*/_react2.default.createElement("div", {
64
+ ref: formBlockRef
65
+ }, props.children));
61
66
  };
62
67
 
63
68
  var FormBlockProvider = function FormBlockProvider(props) {