@nocobase/client 0.7.2-alpha.7 → 0.7.4-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 (175) hide show
  1. package/es/application/Application.d.ts +1 -0
  2. package/es/application/Application.js +7 -1
  3. package/es/block-provider/FormBlockProvider.js +15 -3
  4. package/es/block-provider/TableFieldProvider.d.ts +1 -0
  5. package/es/block-provider/TableFieldProvider.js +5 -2
  6. package/es/block-provider/TableSelectorProvider.js +42 -14
  7. package/es/block-provider/hooks/index.d.ts +6 -0
  8. package/es/block-provider/hooks/index.js +159 -65
  9. package/es/collection-manager/CollectionField.js +11 -4
  10. package/es/collection-manager/Configuration/AddFieldAction.js +6 -0
  11. package/es/collection-manager/Configuration/EditFieldAction.js +7 -0
  12. package/es/collection-manager/Configuration/index.js +5 -1
  13. package/es/collection-manager/Configuration/schemas/collections.js +2 -1
  14. package/es/collection-manager/interfaces/checkbox.js +1 -0
  15. package/es/collection-manager/interfaces/checkboxGroup.js +1 -0
  16. package/es/collection-manager/interfaces/datetime.js +1 -0
  17. package/es/collection-manager/interfaces/email.js +1 -0
  18. package/es/collection-manager/interfaces/icon.js +1 -0
  19. package/es/collection-manager/interfaces/input.js +104 -0
  20. package/es/collection-manager/interfaces/integer.js +64 -0
  21. package/es/collection-manager/interfaces/m2m.js +2 -0
  22. package/es/collection-manager/interfaces/m2o.js +1 -0
  23. package/es/collection-manager/interfaces/markdown.js +35 -0
  24. package/es/collection-manager/interfaces/multipleSelect.js +1 -0
  25. package/es/collection-manager/interfaces/number.js +56 -0
  26. package/es/collection-manager/interfaces/o2m.js +1 -0
  27. package/es/collection-manager/interfaces/o2o.js +3 -0
  28. package/es/collection-manager/interfaces/password.js +37 -1
  29. package/es/collection-manager/interfaces/percent.js +98 -0
  30. package/es/collection-manager/interfaces/phone.js +1 -0
  31. package/es/collection-manager/interfaces/properties/index.d.ts +1 -0
  32. package/es/collection-manager/interfaces/properties/index.js +1 -0
  33. package/es/collection-manager/interfaces/properties/operators.js +4 -4
  34. package/es/collection-manager/interfaces/radioGroup.js +1 -0
  35. package/es/collection-manager/interfaces/richText.js +35 -0
  36. package/es/collection-manager/interfaces/select.js +1 -0
  37. package/es/collection-manager/interfaces/textarea.js +35 -0
  38. package/es/collection-manager/interfaces/time.js +1 -0
  39. package/es/file-manager/FileStorageShortcut.js +2 -2
  40. package/es/locale/en_US.d.ts +8 -2
  41. package/es/locale/en_US.js +9 -3
  42. package/es/locale/zh_CN.d.ts +28 -2
  43. package/es/locale/zh_CN.js +29 -3
  44. package/es/plugin-manager/PluginManager.d.ts +1 -0
  45. package/es/plugin-manager/PluginManager.js +20 -6
  46. package/es/schema-component/antd/action/Action.Modal.js +1 -1
  47. package/es/schema-component/antd/calendar/Calendar.Designer.js +16 -10
  48. package/es/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
  49. package/es/schema-component/antd/date-picker/DatePicker.js +1 -1
  50. package/es/schema-component/antd/date-picker/ReadPretty.js +1 -1
  51. package/es/schema-component/antd/date-picker/util.d.ts +0 -10
  52. package/es/schema-component/antd/date-picker/util.js +1 -79
  53. package/es/schema-component/antd/form-item/FormItem.js +193 -10
  54. package/es/schema-component/antd/grid/Grid.js +72 -6
  55. package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  56. package/es/schema-component/antd/input-number/InputNumber.js +25 -1
  57. package/es/schema-component/antd/input-number/ReadPretty.js +2 -4
  58. package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  59. package/es/schema-component/antd/menu/Menu.js +6 -3
  60. package/es/schema-component/antd/percent/Percent.js +2 -2
  61. package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
  62. package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +5 -3
  63. package/es/schema-component/antd/table/Table.Array.js +2 -2
  64. package/es/schema-component/antd/table/Table.Void.js +11 -1
  65. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
  66. package/es/schema-component/antd/table-v2/Table.d.ts +0 -11
  67. package/es/schema-component/antd/table-v2/Table.js +163 -92
  68. package/es/schema-component/antd/table-v2/TableField.js +3 -0
  69. package/es/schema-component/antd/tabs/Tabs.Designer.js +23 -12
  70. package/es/schema-component/antd/tabs/Tabs.js +7 -1
  71. package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
  72. package/es/schema-component/core/DesignableSwitch.js +7 -1
  73. package/es/schema-component/hooks/useDesignable.js +21 -21
  74. package/es/schema-component/hooks/useProps.js +1 -1
  75. package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
  76. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  77. package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
  78. package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
  79. package/es/schema-initializer/buttons/TabPaneInitializers.js +11 -3
  80. package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
  81. package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  82. package/es/schema-initializer/components/assigned-field/AssignedField.js +255 -69
  83. package/es/schema-initializer/items/index.d.ts +2 -0
  84. package/es/schema-initializer/items/index.js +48 -2
  85. package/es/schema-initializer/utils.js +22 -2
  86. package/es/schema-settings/SchemaSettings.js +7 -0
  87. package/es/system-settings/SystemSettingsShortcut.js +35 -12
  88. package/lib/application/Application.d.ts +1 -0
  89. package/lib/application/Application.js +11 -2
  90. package/lib/block-provider/FormBlockProvider.js +15 -2
  91. package/lib/block-provider/TableFieldProvider.d.ts +1 -0
  92. package/lib/block-provider/TableFieldProvider.js +4 -1
  93. package/lib/block-provider/TableSelectorProvider.js +42 -14
  94. package/lib/block-provider/hooks/index.d.ts +6 -0
  95. package/lib/block-provider/hooks/index.js +168 -67
  96. package/lib/collection-manager/CollectionField.js +12 -4
  97. package/lib/collection-manager/Configuration/AddFieldAction.js +6 -0
  98. package/lib/collection-manager/Configuration/EditFieldAction.js +7 -0
  99. package/lib/collection-manager/Configuration/index.js +5 -0
  100. package/lib/collection-manager/Configuration/schemas/collections.js +2 -1
  101. package/lib/collection-manager/interfaces/checkbox.js +1 -0
  102. package/lib/collection-manager/interfaces/checkboxGroup.js +1 -0
  103. package/lib/collection-manager/interfaces/datetime.js +1 -0
  104. package/lib/collection-manager/interfaces/email.js +1 -0
  105. package/lib/collection-manager/interfaces/icon.js +1 -0
  106. package/lib/collection-manager/interfaces/input.js +105 -0
  107. package/lib/collection-manager/interfaces/integer.js +66 -0
  108. package/lib/collection-manager/interfaces/m2m.js +2 -0
  109. package/lib/collection-manager/interfaces/m2o.js +1 -0
  110. package/lib/collection-manager/interfaces/markdown.js +36 -0
  111. package/lib/collection-manager/interfaces/multipleSelect.js +1 -0
  112. package/lib/collection-manager/interfaces/number.js +57 -0
  113. package/lib/collection-manager/interfaces/o2m.js +1 -0
  114. package/lib/collection-manager/interfaces/o2o.js +3 -0
  115. package/lib/collection-manager/interfaces/password.js +38 -1
  116. package/lib/collection-manager/interfaces/percent.js +100 -0
  117. package/lib/collection-manager/interfaces/phone.js +1 -0
  118. package/lib/collection-manager/interfaces/properties/index.d.ts +1 -0
  119. package/lib/collection-manager/interfaces/properties/index.js +1 -0
  120. package/lib/collection-manager/interfaces/properties/operators.js +4 -4
  121. package/lib/collection-manager/interfaces/radioGroup.js +1 -0
  122. package/lib/collection-manager/interfaces/richText.js +36 -0
  123. package/lib/collection-manager/interfaces/select.js +1 -0
  124. package/lib/collection-manager/interfaces/textarea.js +36 -0
  125. package/lib/collection-manager/interfaces/time.js +1 -0
  126. package/lib/file-manager/FileStorageShortcut.js +1 -1
  127. package/lib/locale/en_US.d.ts +8 -2
  128. package/lib/locale/en_US.js +9 -3
  129. package/lib/locale/zh_CN.d.ts +28 -2
  130. package/lib/locale/zh_CN.js +29 -3
  131. package/lib/plugin-manager/PluginManager.d.ts +1 -0
  132. package/lib/plugin-manager/PluginManager.js +23 -5
  133. package/lib/schema-component/antd/action/Action.Modal.js +1 -1
  134. package/lib/schema-component/antd/calendar/Calendar.Designer.js +16 -10
  135. package/lib/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
  136. package/lib/schema-component/antd/date-picker/DatePicker.js +2 -2
  137. package/lib/schema-component/antd/date-picker/ReadPretty.js +6 -6
  138. package/lib/schema-component/antd/date-picker/util.d.ts +0 -10
  139. package/lib/schema-component/antd/date-picker/util.js +6 -89
  140. package/lib/schema-component/antd/form-item/FormItem.js +196 -12
  141. package/lib/schema-component/antd/grid/Grid.js +69 -3
  142. package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  143. package/lib/schema-component/antd/input-number/InputNumber.js +28 -1
  144. package/lib/schema-component/antd/input-number/ReadPretty.js +2 -5
  145. package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  146. package/lib/schema-component/antd/menu/Menu.js +6 -3
  147. package/lib/schema-component/antd/percent/Percent.js +2 -2
  148. package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
  149. package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
  150. package/lib/schema-component/antd/table/Table.Array.js +2 -2
  151. package/lib/schema-component/antd/table/Table.Void.js +11 -1
  152. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
  153. package/lib/schema-component/antd/table-v2/Table.d.ts +0 -11
  154. package/lib/schema-component/antd/table-v2/Table.js +172 -94
  155. package/lib/schema-component/antd/table-v2/TableField.js +3 -0
  156. package/lib/schema-component/antd/tabs/Tabs.Designer.js +23 -12
  157. package/lib/schema-component/antd/tabs/Tabs.js +8 -1
  158. package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
  159. package/lib/schema-component/core/DesignableSwitch.js +8 -1
  160. package/lib/schema-component/hooks/useDesignable.js +21 -21
  161. package/lib/schema-component/hooks/useProps.js +1 -1
  162. package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
  163. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  164. package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
  165. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
  166. package/lib/schema-initializer/buttons/TabPaneInitializers.js +11 -3
  167. package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
  168. package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  169. package/lib/schema-initializer/components/assigned-field/AssignedField.js +257 -66
  170. package/lib/schema-initializer/items/index.d.ts +2 -0
  171. package/lib/schema-initializer/items/index.js +54 -2
  172. package/lib/schema-initializer/utils.js +22 -2
  173. package/lib/schema-settings/SchemaSettings.js +7 -0
  174. package/lib/system-settings/SystemSettingsShortcut.js +37 -13
  175. package/package.json +7 -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,273 @@ 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 { merge } from '@formily/shared';
21
+ import { Cascader, Select, Space } from 'antd';
22
+ import React, { useEffect, useState } from 'react';
22
23
  import { useTranslation } from 'react-i18next';
23
- import { CollectionField } from '../../../collection-manager';
24
- import { useCompile } from '../../../schema-component';
24
+ import { useFormBlockContext } from '../../../block-provider';
25
+ import { CollectionFieldProvider, useCollection, useCollectionField, useCollectionFilterOptions } from '../../../collection-manager';
26
+ import { useCompile, useComponent } from '../../../schema-component';
27
+ var DYNAMIC_RECORD_REG = /\{\{\s*currentRecord\.(.*)\s*\}\}/;
28
+ var DYNAMIC_USER_REG = /\{\{\s*currentUser\.(.*)\s*\}\}/;
29
+ var DYNAMIC_TIME_REG = /\{\{\s*currentTime\s*\}\}/;
30
+
31
+ var InternalField = function InternalField(props) {
32
+ var field = useField();
33
+ var fieldSchema = useFieldSchema();
34
+
35
+ var _useCollectionField = useCollectionField(),
36
+ name = _useCollectionField.name,
37
+ interfaceType = _useCollectionField.interface,
38
+ uiSchema = _useCollectionField.uiSchema;
39
+
40
+ var component = useComponent(uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['x-component']);
41
+ var compile = useCompile();
42
+
43
+ var setFieldProps = function setFieldProps(key, value) {
44
+ field[key] = typeof field[key] === 'undefined' ? value : field[key];
45
+ };
46
+
47
+ var setRequired = function setRequired() {
48
+ if (typeof fieldSchema['required'] === 'undefined') {
49
+ field.required = !!uiSchema['required'];
50
+ }
51
+ };
52
+
53
+ var ctx = useFormBlockContext();
54
+ useEffect(function () {
55
+ if (ctx === null || ctx === void 0 ? void 0 : ctx.field) {
56
+ ctx.field.added = ctx.field.added || new Set();
57
+ ctx.field.added.add(fieldSchema.name);
58
+ }
59
+ });
60
+ useEffect(function () {
61
+ if (!uiSchema) {
62
+ return;
63
+ }
64
+
65
+ setFieldProps('content', uiSchema['x-content']);
66
+ setFieldProps('title', uiSchema.title);
67
+ setFieldProps('description', uiSchema.description);
68
+ setFieldProps('initialValue', uiSchema.default);
69
+
70
+ if (!field.validator && uiSchema['x-validator']) {
71
+ field.validator = uiSchema['x-validator'];
72
+ }
73
+
74
+ if (fieldSchema['x-disabled'] === true) {
75
+ field.disabled = true;
76
+ }
77
+
78
+ if (fieldSchema['x-read-pretty'] === true) {
79
+ field.readPretty = true;
80
+ }
81
+
82
+ setRequired(); // @ts-ignore
83
+
84
+ field.dataSource = uiSchema.enum;
85
+ var originalProps = compile(uiSchema['x-component-props']) || {};
86
+ var componentProps = merge(originalProps, field.componentProps || {});
87
+ field.componentProps = componentProps; // field.component = [component, componentProps];
88
+ }, [JSON.stringify(uiSchema)]);
89
+
90
+ if (!uiSchema) {
91
+ return null;
92
+ }
93
+
94
+ return /*#__PURE__*/React.createElement(component, props, props.children);
95
+ };
96
+
97
+ var CollectionField = connect(function (props) {
98
+ var fieldSchema = useFieldSchema();
99
+ return /*#__PURE__*/React.createElement(CollectionFieldProvider, {
100
+ name: fieldSchema.name
101
+ }, /*#__PURE__*/React.createElement(InternalField, _objectSpread({}, props)));
102
+ });
103
+ export var AssignedFieldValueType;
104
+
105
+ (function (AssignedFieldValueType) {
106
+ AssignedFieldValueType["ConstantValue"] = "constantValue";
107
+ AssignedFieldValueType["DynamicValue"] = "dynamicValue";
108
+ })(AssignedFieldValueType || (AssignedFieldValueType = {}));
109
+
25
110
  export var AssignedField = function AssignedField(props) {
26
- var _field$value$value, _field$value;
111
+ 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
112
 
28
113
  var _useTranslation = useTranslation(),
29
114
  t = _useTranslation.t;
30
115
 
31
116
  var compile = useCompile();
32
117
  var field = useField();
33
- var fieldSchema = useFieldSchema(); // const [type, setType] = useState<string>('constantValue');
118
+ var fieldSchema = useFieldSchema();
119
+ var isDynamicValue = DYNAMIC_RECORD_REG.test(field.value) || DYNAMIC_USER_REG.test(field.value) || DYNAMIC_TIME_REG.test(field.value);
120
+ var initType = isDynamicValue ? AssignedFieldValueType.DynamicValue : AssignedFieldValueType.ConstantValue;
34
121
 
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 : ''),
122
+ var _useState = useState(initType),
36
123
  _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
- // }, []);
124
+ type = _useState2[0],
125
+ setType = _useState2[1];
126
+
127
+ 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);
128
+
129
+ var _useState3 = useState(initFieldType['true']),
130
+ _useState4 = _slicedToArray(_useState3, 2),
131
+ fieldType = _useState4[0],
132
+ setFieldType = _useState4[1];
133
+
134
+ 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 : [];
135
+
136
+ var _useState5 = useState(initRecordValue),
137
+ _useState6 = _slicedToArray(_useState5, 2),
138
+ recordValue = _useState6[0],
139
+ setRecordValue = _useState6[1];
140
+
141
+ 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 : [];
142
+
143
+ var _useState7 = useState(initUserValue),
144
+ _useState8 = _slicedToArray(_useState7, 2),
145
+ userValue = _useState8[0],
146
+ setUserValue = _useState8[1];
59
147
 
148
+ var initValue = isDynamicValue ? '' : field.value;
149
+
150
+ var _useState9 = useState(initValue),
151
+ _useState10 = _slicedToArray(_useState9, 2),
152
+ value = _useState10[0],
153
+ setValue = _useState10[1];
154
+
155
+ var _useState11 = useState([]),
156
+ _useState12 = _slicedToArray(_useState11, 2),
157
+ options = _useState12[0],
158
+ setOptions = _useState12[1];
159
+
160
+ var _useCollection = useCollection(),
161
+ getField = _useCollection.getField;
162
+
163
+ var collectionField = getField(fieldSchema.name);
164
+ var fields = useCollectionFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.collectionName);
165
+ var userFields = useCollectionFilterOptions('users');
166
+ var dateTimeFields = ['createdAt', 'datetime', 'time', 'updatedAt'];
167
+ useEffect(function () {
168
+ var opt = [{
169
+ name: 'currentRecord',
170
+ title: t('Current record')
171
+ }, {
172
+ name: 'currentUser',
173
+ title: t('Current user')
174
+ }];
175
+
176
+ if (dateTimeFields.includes(collectionField.interface)) {
177
+ opt.unshift({
178
+ name: 'currentTime',
179
+ title: t('Current time')
180
+ });
181
+ } else {}
182
+
183
+ setOptions(compile(opt));
184
+ }, []);
185
+ useEffect(function () {
186
+ if (type === AssignedFieldValueType.ConstantValue) {
187
+ field.value = value;
188
+ } else {
189
+ if (fieldType === 'currentTime') {
190
+ field.value = '{{currentTime}}';
191
+ } else if (fieldType === 'currentUser') {
192
+ (userValue === null || userValue === void 0 ? void 0 : userValue.length) > 0 && (field.value = "{{currentUser.".concat(userValue.join('.'), "}}"));
193
+ } else if (fieldType === 'currentRecord') {
194
+ (recordValue === null || recordValue === void 0 ? void 0 : recordValue.length) > 0 && (field.value = "{{currentRecord.".concat(recordValue.join('.'), "}}"));
195
+ }
196
+ }
197
+ }, [type, value, fieldType, userValue, recordValue]);
198
+ useEffect(function () {
199
+ if (type === AssignedFieldValueType.ConstantValue) {
200
+ setFieldType(null);
201
+ setUserValue([]);
202
+ setRecordValue([]);
203
+ }
204
+ }, [type]);
205
+
206
+ var typeChangeHandler = function typeChangeHandler(val) {
207
+ setType(val);
208
+ };
60
209
 
61
210
  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
- // );
211
+ var _val$target$value, _val$target;
212
+
213
+ 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);
214
+ };
215
+
216
+ var fieldTypeChangeHandler = function fieldTypeChangeHandler(val) {
217
+ setFieldType(val);
218
+ };
219
+
220
+ var recordChangeHandler = function recordChangeHandler(val) {
221
+ setRecordValue(val);
222
+ };
223
+
224
+ var userChangeHandler = function userChangeHandler(val) {
225
+ setUserValue(val);
226
+ };
227
+
228
+ return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Select, {
229
+ defaultValue: type,
230
+ value: type,
231
+ style: {
232
+ width: 150
233
+ },
234
+ onChange: typeChangeHandler
235
+ }, /*#__PURE__*/React.createElement(Select.Option, {
236
+ value: AssignedFieldValueType.ConstantValue
237
+ }, t('Constant value')), /*#__PURE__*/React.createElement(Select.Option, {
238
+ value: AssignedFieldValueType.DynamicValue
239
+ }, t('Dynamic value'))), type === AssignedFieldValueType.ConstantValue ? /*#__PURE__*/React.createElement(CollectionField, _objectSpread(_objectSpread({}, props), {}, {
240
+ value: value,
241
+ onChange: valueChangeHandler,
242
+ style: {
243
+ minWidth: 150
244
+ }
245
+ })) : /*#__PURE__*/React.createElement(Select, {
246
+ defaultValue: fieldType,
247
+ value: fieldType,
248
+ style: {
249
+ minWidth: 150
250
+ },
251
+ onChange: fieldTypeChangeHandler
252
+ }, options === null || options === void 0 ? void 0 : options.map(function (opt) {
253
+ return /*#__PURE__*/React.createElement(Select.Option, {
254
+ key: opt.name,
255
+ value: opt.name
256
+ }, opt.title);
257
+ })), fieldType === 'currentRecord' && /*#__PURE__*/React.createElement(Cascader, {
258
+ fieldNames: {
259
+ label: 'title',
260
+ value: 'name',
261
+ children: 'children'
262
+ },
263
+ style: {
264
+ minWidth: 150
265
+ },
266
+ options: compile(fields),
267
+ onChange: recordChangeHandler,
268
+ defaultValue: recordValue
269
+ }), fieldType === 'currentUser' && /*#__PURE__*/React.createElement(Cascader, {
270
+ fieldNames: {
271
+ label: 'title',
272
+ value: 'name',
273
+ children: 'children'
274
+ },
275
+ style: {
276
+ minWidth: 150
277
+ },
278
+ options: compile(userFields),
279
+ onChange: userChangeHandler,
280
+ defaultValue: userValue
281
+ }));
96
282
  };
@@ -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';
@@ -415,9 +415,10 @@ export var KanbanBlockInitializer = function KanbanBlockInitializer(props) {
415
415
  schema: {
416
416
  properties: {
417
417
  groupField: {
418
- title: t('Group field'),
418
+ title: t('Grouping field'),
419
419
  enum: fields,
420
420
  required: true,
421
+ description: '{{t("Single select and radio fields can be used as the grouping field")}}',
421
422
  'x-component': 'Select',
422
423
  'x-component-props': {
423
424
  objectValue: true,
@@ -693,6 +694,21 @@ export var DestroyActionInitializer = function DestroyActionInitializer(props) {
693
694
  schema: schema
694
695
  }));
695
696
  };
697
+ export var PrintActionInitializer = function PrintActionInitializer(props) {
698
+ var schema = {
699
+ title: '{{ t("Print") }}',
700
+ 'x-action': 'print',
701
+ 'x-component': 'Action',
702
+ 'x-designer': 'Action.Designer',
703
+ 'x-component-props': {
704
+ icon: 'PrinterOutlined',
705
+ useProps: '{{ useDetailPrintActionProps }}'
706
+ }
707
+ };
708
+ return /*#__PURE__*/React.createElement(ActionInitializer, _objectSpread(_objectSpread({}, props), {}, {
709
+ schema: schema
710
+ }));
711
+ };
696
712
  export var BulkDestroyActionInitializer = function BulkDestroyActionInitializer(props) {
697
713
  var schema = {
698
714
  title: '{{ t("Delete") }}',
@@ -712,6 +728,21 @@ export var BulkDestroyActionInitializer = function BulkDestroyActionInitializer(
712
728
  schema: schema
713
729
  }));
714
730
  };
731
+ export var RefreshActionInitializer = function RefreshActionInitializer(props) {
732
+ var schema = {
733
+ title: '{{ t("Refresh") }}',
734
+ 'x-action': 'refresh',
735
+ 'x-component': 'Action',
736
+ 'x-designer': 'Action.Designer',
737
+ 'x-component-props': {
738
+ icon: 'ReloadOutlined',
739
+ useProps: '{{ useRefreshActionProps }}'
740
+ }
741
+ };
742
+ return /*#__PURE__*/React.createElement(ActionInitializer, _objectSpread(_objectSpread({}, props), {}, {
743
+ schema: schema
744
+ }));
745
+ };
715
746
  export var SubmitActionInitializer = function SubmitActionInitializer(props) {
716
747
  var schema = {
717
748
  title: '{{ t("Submit") }}',
@@ -851,6 +882,7 @@ export var RecordFormBlockInitializer = function RecordFormBlockInitializer(prop
851
882
 
852
883
  var collection = useCollection();
853
884
  var association = useBlockAssociationContext();
885
+ console.log('RecordFormBlockInitializer', collection, association);
854
886
  return /*#__PURE__*/React.createElement(SchemaInitializer.Item, _objectSpread(_objectSpread({
855
887
  icon: /*#__PURE__*/React.createElement(FormOutlined, null)
856
888
  }, others), {}, {
@@ -936,6 +968,11 @@ export var RecordReadPrettyFormBlockInitializer = function RecordReadPrettyFormB
936
968
 
937
969
  var collection = useCollection();
938
970
  var association = useBlockAssociationContext();
971
+
972
+ var _useBlockRequestConte = useBlockRequestContext(),
973
+ block = _useBlockRequestConte.block;
974
+
975
+ var actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null;
939
976
  return /*#__PURE__*/React.createElement(SchemaInitializer.Item, _objectSpread(_objectSpread({
940
977
  icon: /*#__PURE__*/React.createElement(FormOutlined, null)
941
978
  }, others), {}, {
@@ -962,6 +999,7 @@ export var RecordReadPrettyFormBlockInitializer = function RecordReadPrettyFormB
962
999
 
963
1000
  if (item.template.componentName === 'ReadPrettyFormItem') {
964
1001
  blockSchema = createReadPrettyFormBlockSchema({
1002
+ actionInitializers: actionInitializers,
965
1003
  association: association,
966
1004
  collection: collection.name,
967
1005
  action: 'get',
@@ -984,6 +1022,7 @@ export var RecordReadPrettyFormBlockInitializer = function RecordReadPrettyFormB
984
1022
 
985
1023
  case 8:
986
1024
  insert(createReadPrettyFormBlockSchema({
1025
+ actionInitializers: actionInitializers,
987
1026
  association: association,
988
1027
  collection: collection.name,
989
1028
  action: 'get',
@@ -1113,6 +1152,11 @@ export var RecordReadPrettyAssociationFormBlockInitializer = function RecordRead
1113
1152
  var field = item.field;
1114
1153
  var collection = field.target;
1115
1154
  var resource = "".concat(field.collectionName, ".").concat(field.name);
1155
+
1156
+ var _useBlockRequestConte2 = useBlockRequestContext(),
1157
+ block = _useBlockRequestConte2.block;
1158
+
1159
+ var actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null;
1116
1160
  return /*#__PURE__*/React.createElement(SchemaInitializer.Item, _objectSpread(_objectSpread({
1117
1161
  icon: /*#__PURE__*/React.createElement(FormOutlined, null)
1118
1162
  }, others), {}, {
@@ -1138,6 +1182,7 @@ export var RecordReadPrettyAssociationFormBlockInitializer = function RecordRead
1138
1182
 
1139
1183
  if (item.template.componentName === 'ReadPrettyFormItem') {
1140
1184
  blockSchema = createReadPrettyFormBlockSchema({
1185
+ actionInitializers: actionInitializers,
1141
1186
  collection: collection,
1142
1187
  resource: resource,
1143
1188
  association: resource,
@@ -1161,6 +1206,7 @@ export var RecordReadPrettyAssociationFormBlockInitializer = function RecordRead
1161
1206
 
1162
1207
  case 8:
1163
1208
  insert(createReadPrettyFormBlockSchema({
1209
+ actionInitializers: actionInitializers,
1164
1210
  collection: collection,
1165
1211
  resource: resource,
1166
1212
  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 });
@@ -384,11 +388,27 @@ var removeSchema = function removeSchema(schema, cb) {
384
388
  return cb(schema);
385
389
  };
386
390
 
391
+ var recursiveParent = function recursiveParent(schema) {
392
+ if (!schema.parent) return null;
393
+ if (schema.parent['x-initializer']) return schema.parent;
394
+ return recursiveParent(schema.parent);
395
+ };
396
+
387
397
  export var useCurrentSchema = function useCurrentSchema(action, key) {
398
+ var _fieldSchema;
399
+
388
400
  var find = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : findSchema;
389
401
  var rm = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : removeSchema;
390
402
  var fieldSchema = useFieldSchema();
391
403
 
404
+ if (!((_fieldSchema = fieldSchema) === null || _fieldSchema === void 0 ? void 0 : _fieldSchema['x-initializer'])) {
405
+ var recursiveInitializerSchema = recursiveParent(fieldSchema);
406
+
407
+ if (recursiveInitializerSchema) {
408
+ fieldSchema = recursiveInitializerSchema;
409
+ }
410
+ }
411
+
392
412
  var _useDesignable = useDesignable(),
393
413
  _remove = _useDesignable.remove;
394
414
 
@@ -540,6 +540,8 @@ SchemaSettings.Remove = function (props) {
540
540
  var _useTranslation3 = useTranslation(),
541
541
  t = _useTranslation3.t;
542
542
 
543
+ var field = useField();
544
+ var fieldSchema = useFieldSchema();
543
545
  var ctx = useBlockTemplateContext();
544
546
  return /*#__PURE__*/React.createElement(SchemaSettings.Item, {
545
547
  onClick: function onClick() {
@@ -553,6 +555,11 @@ SchemaSettings.Remove = function (props) {
553
555
  breakRemoveOn: breakRemoveOn
554
556
  };
555
557
 
558
+ if (field && field.required) {
559
+ field.required = false;
560
+ fieldSchema['required'] = false;
561
+ }
562
+
556
563
  if (template && (ctx === null || ctx === void 0 ? void 0 : ctx.dn)) {
557
564
  ctx === null || ctx === void 0 ? void 0 : ctx.dn.remove(null, options);
558
565
  } else {
@@ -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',
@@ -5,6 +5,7 @@ export interface ApplicationOptions {
5
5
  i18n?: any;
6
6
  plugins?: any[];
7
7
  }
8
+ export declare const getCurrentTimezone: () => string;
8
9
  export declare type PluginCallback = () => Promise<any>;
9
10
  export declare class Application {
10
11
  providers: any[];