@nocobase/client 0.9.0-alpha.2 → 0.9.1-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.
- package/es/acl/ACLProvider.js +4 -7
- package/es/api-client/APIClient.js +6 -0
- package/es/block-provider/BlockProvider.js +9 -6
- package/es/block-provider/FormBlockProvider.js +3 -1
- package/es/block-provider/KanbanBlockProvider.js +1 -1
- package/es/block-provider/SharedFilterProvider.js +9 -1
- package/es/block-provider/TableBlockProvider.js +1 -1
- package/es/block-provider/TableSelectorProvider.js +2 -2
- package/es/block-provider/hooks/index.js +22 -7
- package/es/collection-manager/CollectionManagerProvider.d.ts +1 -0
- package/es/collection-manager/CollectionManagerProvider.js +71 -9
- package/es/collection-manager/CollectionManagerShortcut.js +36 -23
- package/es/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
- package/es/collection-manager/Configuration/AddCategoryAction.js +117 -0
- package/es/collection-manager/Configuration/AddCollectionAction.js +8 -3
- package/es/collection-manager/Configuration/AddFieldAction.js +1 -0
- package/es/collection-manager/Configuration/ConfigurationTable.js +33 -4
- package/es/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
- package/es/collection-manager/Configuration/ConfigurationTabs.js +381 -0
- package/es/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
- package/es/collection-manager/Configuration/EditCategoryAction.js +150 -0
- package/es/collection-manager/Configuration/EditCollectionAction.js +6 -2
- package/es/collection-manager/Configuration/OverridingCollectionField.js +17 -8
- package/es/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
- package/es/collection-manager/Configuration/components/CollectionCategory.js +13 -0
- package/es/collection-manager/Configuration/index.d.ts +3 -0
- package/es/collection-manager/Configuration/index.js +3 -0
- package/es/collection-manager/Configuration/schemas/collections.d.ts +3 -0
- package/es/collection-manager/Configuration/schemas/collections.js +309 -176
- package/es/collection-manager/Configuration/templates.d.ts +1 -0
- package/es/collection-manager/Configuration/templates.js +1 -1
- package/es/collection-manager/action-hooks.js +3 -1
- package/es/collection-manager/context.d.ts +4 -0
- package/es/collection-manager/context.js +5 -1
- package/es/collection-manager/hooks/useCollectionManager.d.ts +7 -0
- package/es/collection-manager/hooks/useCollectionManager.js +51 -6
- package/es/collection-manager/interfaces/m2m.js +2 -2
- package/es/collection-manager/interfaces/properties/index.d.ts +0 -56
- package/es/collection-manager/interfaces/properties/index.js +1 -2
- package/es/collection-manager/templates/calendar.js +1 -1
- package/es/collection-manager/templates/general.js +1 -1
- package/es/collection-manager/templates/properties/index.d.ts +12 -1
- package/es/collection-manager/templates/properties/index.js +11 -0
- package/es/i18n/i18n.js +3 -1
- package/es/locale/en_US.d.ts +23 -0
- package/es/locale/en_US.js +23 -0
- package/es/locale/ja_JP.d.ts +23 -0
- package/es/locale/ja_JP.js +24 -1
- package/es/locale/ru_RU.d.ts +1 -0
- package/es/locale/ru_RU.js +1 -0
- package/es/locale/zh_CN.d.ts +43 -4
- package/es/locale/zh_CN.js +44 -5
- package/es/route-switch/antd/admin-layout/index.js +13 -33
- package/es/schema-component/antd/action/Action.Designer.js +22 -15
- package/es/schema-component/antd/action/Action.js +25 -3
- package/es/schema-component/antd/action/utils.d.ts +1 -0
- package/es/schema-component/antd/action/utils.js +49 -0
- package/es/schema-component/antd/association-filter/AssociationFilter.js +4 -4
- package/es/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
- package/es/schema-component/antd/association-select/useServiceOptions.js +47 -6
- package/es/schema-component/antd/calendar/Calendar.Designer.js +17 -36
- package/es/schema-component/antd/checkbox/Checkbox.js +9 -8
- package/es/schema-component/antd/date-picker/util.d.ts +1 -1
- package/es/schema-component/antd/date-picker/util.js +1 -1
- package/es/schema-component/antd/filter/DynamicComponent.js +3 -1
- package/es/schema-component/antd/filter/Filter.js +2 -1
- package/es/schema-component/antd/filter/FilterGroup.js +7 -4
- package/es/schema-component/antd/filter/FilterItem.js +3 -2
- package/es/schema-component/antd/filter/context.d.ts +1 -0
- package/es/schema-component/antd/filter/useValues.js +14 -11
- package/es/schema-component/antd/form/Form.js +11 -5
- package/es/schema-component/antd/form-item/FormItem.js +17 -8
- package/es/schema-component/antd/form-v2/Form.Designer.js +2 -0
- package/es/schema-component/antd/form-v2/Form.js +90 -7
- package/es/schema-component/antd/form-v2/utils.d.ts +5 -0
- package/es/schema-component/antd/form-v2/utils.js +161 -0
- package/es/schema-component/antd/grid/Grid.js +10 -5
- package/es/schema-component/antd/icon-picker/IconPicker.js +1 -0
- package/es/schema-component/antd/index.d.ts +1 -0
- package/es/schema-component/antd/index.js +1 -0
- package/es/schema-component/antd/input/Input.d.ts +2 -1
- package/es/schema-component/antd/input/Json.d.ts +5 -3
- package/es/schema-component/antd/input/Json.js +3 -2
- package/es/schema-component/antd/input-number/InputNumber.js +3 -1
- package/es/schema-component/antd/page/FixedBlock.js +3 -1
- package/es/schema-component/antd/page/Page.js +11 -5
- package/es/schema-component/antd/page/PageTabDesigner.js +3 -3
- package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
- package/es/schema-component/antd/record-picker/RecordPicker.js +1 -2
- package/es/schema-component/antd/record-picker/util.js +7 -0
- package/es/schema-component/antd/remote-select/RemoteSelect.js +76 -36
- package/es/schema-component/antd/rich-text/RichText.js +4 -2
- package/es/schema-component/antd/select/Select.js +14 -4
- package/es/schema-component/antd/table/Table.Array.js +10 -3
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
- package/es/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
- package/es/schema-component/antd/tabs/Tabs.Designer.js +1 -0
- package/es/schema-component/antd/time-picker/TimePicker.js +1 -1
- package/es/schema-component/antd/variable/Input.d.ts +2 -0
- package/es/schema-component/antd/variable/Input.js +244 -0
- package/es/schema-component/antd/variable/JSONInput.d.ts +2 -0
- package/es/schema-component/antd/variable/JSONInput.js +82 -0
- package/es/schema-component/antd/variable/TextArea.d.ts +2 -0
- package/es/schema-component/antd/variable/TextArea.js +322 -0
- package/es/schema-component/antd/variable/Variable.d.ts +8 -0
- package/es/schema-component/antd/variable/Variable.js +11 -0
- package/es/schema-component/antd/variable/index.d.ts +1 -0
- package/es/schema-component/antd/variable/index.js +1 -0
- package/es/schema-component/common/sortable-item/SortableItem.js +36 -6
- package/es/schema-component/common/utils/logic.js +523 -0
- package/es/schema-component/common/utils/uitls.d.ts +1 -0
- package/es/schema-component/common/utils/uitls.js +89 -0
- package/es/schema-initializer/SchemaInitializer.js +0 -1
- package/es/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
- package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -3
- package/es/schema-initializer/index.d.ts +2 -1
- package/es/schema-initializer/index.js +2 -1
- package/es/schema-initializer/items/CalendarBlockInitializer.js +24 -41
- package/es/schema-initializer/utils.js +22 -7
- package/es/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
- package/es/schema-settings/LinkageRules/DynamicComponent.js +113 -0
- package/es/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
- package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +15 -0
- package/es/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
- package/es/schema-settings/LinkageRules/LinkageRuleAction.js +162 -0
- package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
- package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.js +71 -0
- package/es/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
- package/es/schema-settings/LinkageRules/ValueDynamicComponent.js +82 -0
- package/es/schema-settings/LinkageRules/Variables.d.ts +7 -0
- package/es/schema-settings/LinkageRules/Variables.js +115 -0
- package/es/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
- package/es/schema-settings/LinkageRules/action-hooks.js +115 -0
- package/es/schema-settings/LinkageRules/context.d.ts +13 -0
- package/es/schema-settings/LinkageRules/context.js +4 -0
- package/es/schema-settings/LinkageRules/index.d.ts +2 -0
- package/es/schema-settings/LinkageRules/index.js +132 -0
- package/es/schema-settings/LinkageRules/type.d.ts +13 -0
- package/es/schema-settings/LinkageRules/type.js +15 -0
- package/es/schema-settings/LinkageRules/useValues.d.ts +1 -0
- package/es/schema-settings/LinkageRules/useValues.js +84 -0
- package/es/schema-settings/SchemaSettings.d.ts +4 -1
- package/es/schema-settings/SchemaSettings.js +153 -26
- package/es/schema-templates/BlockTemplate.js +9 -1
- package/es/system-settings/SystemSettingsShortcut.js +1 -1
- package/lib/acl/ACLProvider.js +4 -7
- package/lib/api-client/APIClient.js +6 -0
- package/lib/block-provider/BlockProvider.js +9 -6
- package/lib/block-provider/FormBlockProvider.js +3 -1
- package/lib/block-provider/KanbanBlockProvider.js +1 -1
- package/lib/block-provider/SharedFilterProvider.js +9 -3
- package/lib/block-provider/TableBlockProvider.js +1 -1
- package/lib/block-provider/TableSelectorProvider.js +2 -2
- package/lib/block-provider/hooks/index.js +23 -7
- package/lib/collection-manager/CollectionManagerProvider.d.ts +1 -0
- package/lib/collection-manager/CollectionManagerProvider.js +81 -16
- package/lib/collection-manager/CollectionManagerShortcut.js +36 -23
- package/lib/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
- package/lib/collection-manager/Configuration/AddCategoryAction.js +145 -0
- package/lib/collection-manager/Configuration/AddCollectionAction.js +8 -3
- package/lib/collection-manager/Configuration/AddFieldAction.js +1 -0
- package/lib/collection-manager/Configuration/ConfigurationTable.js +34 -4
- package/lib/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
- package/lib/collection-manager/Configuration/ConfigurationTabs.js +407 -0
- package/lib/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
- package/lib/collection-manager/Configuration/EditCategoryAction.js +178 -0
- package/lib/collection-manager/Configuration/EditCollectionAction.js +6 -2
- package/lib/collection-manager/Configuration/OverridingCollectionField.js +17 -8
- package/lib/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
- package/lib/collection-manager/Configuration/components/CollectionCategory.js +27 -0
- package/lib/collection-manager/Configuration/index.d.ts +3 -0
- package/lib/collection-manager/Configuration/index.js +39 -0
- package/lib/collection-manager/Configuration/schemas/collections.d.ts +3 -0
- package/lib/collection-manager/Configuration/schemas/collections.js +316 -178
- package/lib/collection-manager/Configuration/templates.d.ts +1 -0
- package/lib/collection-manager/Configuration/templates.js +2 -0
- package/lib/collection-manager/action-hooks.js +3 -1
- package/lib/collection-manager/context.d.ts +4 -0
- package/lib/collection-manager/context.js +7 -2
- package/lib/collection-manager/hooks/useCollectionManager.d.ts +7 -0
- package/lib/collection-manager/hooks/useCollectionManager.js +52 -6
- package/lib/collection-manager/interfaces/m2m.js +2 -2
- package/lib/collection-manager/interfaces/properties/index.d.ts +0 -56
- package/lib/collection-manager/interfaces/properties/index.js +1 -2
- package/lib/collection-manager/templates/calendar.js +1 -1
- package/lib/collection-manager/templates/general.js +1 -1
- package/lib/collection-manager/templates/properties/index.d.ts +12 -1
- package/lib/collection-manager/templates/properties/index.js +11 -0
- package/lib/i18n/i18n.js +3 -1
- package/lib/locale/en_US.d.ts +23 -0
- package/lib/locale/en_US.js +23 -0
- package/lib/locale/ja_JP.d.ts +23 -0
- package/lib/locale/ja_JP.js +24 -1
- package/lib/locale/ru_RU.d.ts +1 -0
- package/lib/locale/ru_RU.js +1 -0
- package/lib/locale/zh_CN.d.ts +43 -4
- package/lib/locale/zh_CN.js +44 -5
- package/lib/route-switch/antd/admin-layout/index.js +13 -33
- package/lib/schema-component/antd/action/Action.Designer.js +24 -14
- package/lib/schema-component/antd/action/Action.js +27 -2
- package/lib/schema-component/antd/action/utils.d.ts +1 -0
- package/lib/schema-component/antd/action/utils.js +58 -2
- package/lib/schema-component/antd/association-filter/AssociationFilter.js +3 -3
- package/lib/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
- package/lib/schema-component/antd/association-select/useServiceOptions.js +47 -4
- package/lib/schema-component/antd/calendar/Calendar.Designer.js +15 -33
- package/lib/schema-component/antd/checkbox/Checkbox.js +8 -7
- package/lib/schema-component/antd/date-picker/util.d.ts +1 -1
- package/lib/schema-component/antd/date-picker/util.js +1 -1
- package/lib/schema-component/antd/filter/DynamicComponent.js +3 -1
- package/lib/schema-component/antd/filter/Filter.js +2 -1
- package/lib/schema-component/antd/filter/FilterGroup.js +7 -4
- package/lib/schema-component/antd/filter/FilterItem.js +3 -2
- package/lib/schema-component/antd/filter/context.d.ts +1 -0
- package/lib/schema-component/antd/filter/useValues.js +15 -11
- package/lib/schema-component/antd/form/Form.js +9 -3
- package/lib/schema-component/antd/form-item/FormItem.js +21 -7
- package/lib/schema-component/antd/form-v2/Form.Designer.js +2 -0
- package/lib/schema-component/antd/form-v2/Form.js +89 -5
- package/lib/schema-component/antd/form-v2/utils.d.ts +5 -0
- package/lib/schema-component/antd/form-v2/utils.js +181 -0
- package/lib/schema-component/antd/grid/Grid.js +10 -5
- package/lib/schema-component/antd/icon-picker/IconPicker.js +1 -0
- package/lib/schema-component/antd/index.d.ts +1 -0
- package/lib/schema-component/antd/index.js +13 -0
- package/lib/schema-component/antd/input/Input.d.ts +2 -1
- package/lib/schema-component/antd/input/Json.d.ts +5 -3
- package/lib/schema-component/antd/input/Json.js +6 -3
- package/lib/schema-component/antd/input-number/InputNumber.js +2 -0
- package/lib/schema-component/antd/page/FixedBlock.js +3 -1
- package/lib/schema-component/antd/page/Page.js +14 -5
- package/lib/schema-component/antd/page/PageTabDesigner.js +1 -1
- package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
- package/lib/schema-component/antd/record-picker/RecordPicker.js +1 -2
- package/lib/schema-component/antd/record-picker/util.js +7 -0
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +76 -37
- package/lib/schema-component/antd/rich-text/RichText.js +4 -2
- package/lib/schema-component/antd/select/Select.js +14 -4
- package/lib/schema-component/antd/table/Table.Array.js +8 -1
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
- package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
- package/lib/schema-component/antd/tabs/Tabs.Designer.js +1 -0
- package/lib/schema-component/antd/time-picker/TimePicker.js +1 -1
- package/lib/schema-component/antd/variable/Input.d.ts +2 -0
- package/lib/schema-component/antd/variable/Input.js +262 -0
- package/lib/schema-component/antd/variable/JSONInput.d.ts +2 -0
- package/lib/schema-component/antd/variable/JSONInput.js +100 -0
- package/lib/schema-component/antd/variable/TextArea.d.ts +2 -0
- package/lib/schema-component/antd/variable/TextArea.js +341 -0
- package/lib/schema-component/antd/variable/Variable.d.ts +8 -0
- package/lib/schema-component/antd/variable/Variable.js +25 -0
- package/lib/schema-component/antd/variable/index.d.ts +1 -0
- package/lib/schema-component/antd/variable/index.js +18 -0
- package/lib/schema-component/common/sortable-item/SortableItem.js +36 -6
- package/lib/schema-component/common/utils/logic.js +525 -0
- package/lib/schema-component/common/utils/uitls.d.ts +1 -0
- package/lib/schema-component/common/utils/uitls.js +103 -0
- package/lib/schema-initializer/SchemaInitializer.js +0 -1
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +3 -1
- package/lib/schema-initializer/index.d.ts +2 -1
- package/lib/schema-initializer/index.js +51 -2
- package/lib/schema-initializer/items/CalendarBlockInitializer.js +16 -33
- package/lib/schema-initializer/utils.js +22 -6
- package/lib/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/DynamicComponent.js +139 -0
- package/lib/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
- package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +27 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleAction.js +190 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.js +90 -0
- package/lib/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/ValueDynamicComponent.js +104 -0
- package/lib/schema-settings/LinkageRules/Variables.d.ts +7 -0
- package/lib/schema-settings/LinkageRules/Variables.js +124 -0
- package/lib/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/action-hooks.js +127 -0
- package/lib/schema-settings/LinkageRules/context.d.ts +13 -0
- package/lib/schema-settings/LinkageRules/context.js +15 -0
- package/lib/schema-settings/LinkageRules/index.d.ts +2 -0
- package/lib/schema-settings/LinkageRules/index.js +149 -0
- package/lib/schema-settings/LinkageRules/type.d.ts +13 -0
- package/lib/schema-settings/LinkageRules/type.js +22 -0
- package/lib/schema-settings/LinkageRules/useValues.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/useValues.js +95 -0
- package/lib/schema-settings/SchemaSettings.d.ts +4 -1
- package/lib/schema-settings/SchemaSettings.js +176 -48
- package/lib/schema-templates/BlockTemplate.js +9 -1
- package/lib/system-settings/SystemSettingsShortcut.js +1 -1
- package/package.json +4 -4
|
@@ -63,7 +63,8 @@ var Filter = (0, _react.observer)(function (props) {
|
|
|
63
63
|
field: field,
|
|
64
64
|
fieldSchema: fieldSchema,
|
|
65
65
|
dynamicComponent: dynamicComponent,
|
|
66
|
-
options: options || field.dataSource || []
|
|
66
|
+
options: options || field.dataSource || [],
|
|
67
|
+
disabled: props.disabled
|
|
67
68
|
}
|
|
68
69
|
}, /*#__PURE__*/_react2.default.createElement(_FilterGroup.FilterGroup, _objectSpread(_objectSpread({}, props), {}, {
|
|
69
70
|
bordered: false
|
|
@@ -41,7 +41,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
41
41
|
|
|
42
42
|
var FilterGroup = (0, _react.connect)(function (props) {
|
|
43
43
|
var _props$bordered = props.bordered,
|
|
44
|
-
bordered = _props$bordered === void 0 ? true : _props$bordered
|
|
44
|
+
bordered = _props$bordered === void 0 ? true : _props$bordered,
|
|
45
|
+
disabled = props.disabled;
|
|
45
46
|
var field = (0, _react.useField)();
|
|
46
47
|
var remove = (0, _react2.useContext)(_context.RemoveConditionContext);
|
|
47
48
|
|
|
@@ -56,6 +57,7 @@ var FilterGroup = (0, _react.connect)(function (props) {
|
|
|
56
57
|
field.value = _defineProperty({}, value, _toConsumableArray(obj[logic] || []));
|
|
57
58
|
};
|
|
58
59
|
|
|
60
|
+
var mergedDisabled = disabled || field.disabled;
|
|
59
61
|
return /*#__PURE__*/_react2.default.createElement(_context.FilterLogicContext.Provider, {
|
|
60
62
|
value: logic
|
|
61
63
|
}, /*#__PURE__*/_react2.default.createElement("div", {
|
|
@@ -68,7 +70,7 @@ var FilterGroup = (0, _react.connect)(function (props) {
|
|
|
68
70
|
position: 'relative',
|
|
69
71
|
marginBottom: 8
|
|
70
72
|
}
|
|
71
|
-
}, remove && /*#__PURE__*/_react2.default.createElement("a", null, /*#__PURE__*/_react2.default.createElement(_icons.CloseCircleOutlined, {
|
|
73
|
+
}, remove && !mergedDisabled && /*#__PURE__*/_react2.default.createElement("a", null, /*#__PURE__*/_react2.default.createElement(_icons.CloseCircleOutlined, {
|
|
72
74
|
style: {
|
|
73
75
|
position: 'absolute',
|
|
74
76
|
right: 10,
|
|
@@ -96,8 +98,9 @@ var FilterGroup = (0, _react.connect)(function (props) {
|
|
|
96
98
|
value: '$or'
|
|
97
99
|
}, "Any")), ' conditions in the group')), /*#__PURE__*/_react2.default.createElement("div", null, /*#__PURE__*/_react2.default.createElement(_react.ArrayField, {
|
|
98
100
|
name: logic,
|
|
99
|
-
component: [_FilterItems.FilterItems]
|
|
100
|
-
|
|
101
|
+
component: [_FilterItems.FilterItems],
|
|
102
|
+
disabled: mergedDisabled
|
|
103
|
+
})), !mergedDisabled && /*#__PURE__*/_react2.default.createElement(_antd.Space, {
|
|
101
104
|
size: 16,
|
|
102
105
|
style: {
|
|
103
106
|
marginTop: 8,
|
|
@@ -27,7 +27,7 @@ var _DynamicComponent = require("./DynamicComponent");
|
|
|
27
27
|
|
|
28
28
|
var _useValues2 = require("./useValues");
|
|
29
29
|
|
|
30
|
-
var _templateObject;
|
|
30
|
+
var _templateObject, _templateObject2;
|
|
31
31
|
|
|
32
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
33
|
|
|
@@ -72,6 +72,7 @@ var FilterItem = (0, _react.observer)(function (props) {
|
|
|
72
72
|
},
|
|
73
73
|
placeholder: t('Select Field')
|
|
74
74
|
}), /*#__PURE__*/_react2.default.createElement(_antd.Select, {
|
|
75
|
+
className: (0, _css.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 110px;\n "]))),
|
|
75
76
|
value: operator === null || operator === void 0 ? void 0 : operator.value,
|
|
76
77
|
options: compile(operators),
|
|
77
78
|
onChange: function onChange(value) {
|
|
@@ -84,7 +85,7 @@ var FilterItem = (0, _react.observer)(function (props) {
|
|
|
84
85
|
onChange: function onChange(value) {
|
|
85
86
|
setValue(value);
|
|
86
87
|
}
|
|
87
|
-
}), /*#__PURE__*/_react2.default.createElement("a", null, /*#__PURE__*/_react2.default.createElement(_icons.CloseCircleOutlined, {
|
|
88
|
+
}), !props.disabled && /*#__PURE__*/_react2.default.createElement("a", null, /*#__PURE__*/_react2.default.createElement(_icons.CloseCircleOutlined, {
|
|
88
89
|
onClick: function onClick() {
|
|
89
90
|
return remove();
|
|
90
91
|
},
|
|
@@ -6,6 +6,7 @@ export interface FilterContextProps {
|
|
|
6
6
|
fieldSchema?: Schema;
|
|
7
7
|
dynamicComponent?: any;
|
|
8
8
|
options?: any[];
|
|
9
|
+
disabled?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const RemoveConditionContext: import("react").Context<any>;
|
|
11
12
|
export declare const FilterContext: import("react").Context<FilterContextProps>;
|
|
@@ -11,6 +11,8 @@ var _shared = require("@formily/shared");
|
|
|
11
11
|
|
|
12
12
|
var _flat = _interopRequireDefault(require("flat"));
|
|
13
13
|
|
|
14
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
15
|
+
|
|
14
16
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
15
17
|
|
|
16
18
|
var _react2 = require("react");
|
|
@@ -75,6 +77,7 @@ var useValues = function useValues() {
|
|
|
75
77
|
var value2data = function value2data() {
|
|
76
78
|
var _operators$find;
|
|
77
79
|
|
|
80
|
+
field.data = field.data || {};
|
|
78
81
|
var values = (0, _flat.default)(field.value);
|
|
79
82
|
var path = Object.keys(values).shift() || '';
|
|
80
83
|
|
|
@@ -84,8 +87,10 @@ var useValues = function useValues() {
|
|
|
84
87
|
|
|
85
88
|
var _path$split = path.split('.$'),
|
|
86
89
|
_path$split2 = _slicedToArray(_path$split, 2),
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
_path$split2$ = _path$split2[0],
|
|
91
|
+
fieldPath = _path$split2$ === void 0 ? '' : _path$split2$,
|
|
92
|
+
_path$split2$2 = _path$split2[1],
|
|
93
|
+
otherPath = _path$split2$2 === void 0 ? '' : _path$split2$2;
|
|
89
94
|
|
|
90
95
|
var _otherPath$split = otherPath.split('.', 2),
|
|
91
96
|
_otherPath$split2 = _slicedToArray(_otherPath$split, 1),
|
|
@@ -97,7 +102,6 @@ var useValues = function useValues() {
|
|
|
97
102
|
var operator = operators === null || operators === void 0 ? void 0 : (_operators$find = operators.find) === null || _operators$find === void 0 ? void 0 : _operators$find.call(operators, function (item) {
|
|
98
103
|
return item.value === "$".concat(operatorValue);
|
|
99
104
|
});
|
|
100
|
-
field.data = field.data || {};
|
|
101
105
|
field.data.dataIndex = dataIndex;
|
|
102
106
|
field.data.operators = operators;
|
|
103
107
|
field.data.operator = operator;
|
|
@@ -105,9 +109,7 @@ var useValues = function useValues() {
|
|
|
105
109
|
field.data.value = (0, _get.default)(field.value, "".concat(fieldPath, ".$").concat(operatorValue));
|
|
106
110
|
};
|
|
107
111
|
|
|
108
|
-
(0, _react2.useEffect)(
|
|
109
|
-
value2data();
|
|
110
|
-
}, [logic]);
|
|
112
|
+
(0, _react2.useEffect)(value2data, [logic]);
|
|
111
113
|
return _objectSpread(_objectSpread({
|
|
112
114
|
fields: options
|
|
113
115
|
}, field.data), {}, {
|
|
@@ -119,11 +121,12 @@ var useValues = function useValues() {
|
|
|
119
121
|
field.data = field.data || {};
|
|
120
122
|
field.data.operators = option === null || option === void 0 ? void 0 : option.operators;
|
|
121
123
|
field.data.operator = operator;
|
|
122
|
-
|
|
124
|
+
var s1 = (0, _cloneDeep.default)(option === null || option === void 0 ? void 0 : option.schema);
|
|
125
|
+
var s2 = (0, _cloneDeep.default)(operator === null || operator === void 0 ? void 0 : operator.schema);
|
|
126
|
+
field.data.schema = (0, _shared.merge)(s1, s2);
|
|
123
127
|
field.data.dataIndex = dataIndex;
|
|
124
128
|
field.data.value = null;
|
|
125
129
|
data2value();
|
|
126
|
-
console.log('setDataIndex', field.data);
|
|
127
130
|
},
|
|
128
131
|
setOperator: function setOperator(operatorValue) {
|
|
129
132
|
var _field$data3, _field$data3$operator, _field$data3$operator2;
|
|
@@ -132,15 +135,16 @@ var useValues = function useValues() {
|
|
|
132
135
|
return item.value === operatorValue;
|
|
133
136
|
});
|
|
134
137
|
field.data.operator = operator;
|
|
135
|
-
|
|
138
|
+
var option = findOption(field.data.dataIndex, options);
|
|
139
|
+
var s1 = (0, _cloneDeep.default)(option === null || option === void 0 ? void 0 : option.schema);
|
|
140
|
+
var s2 = (0, _cloneDeep.default)(operator === null || operator === void 0 ? void 0 : operator.schema);
|
|
141
|
+
field.data.schema = (0, _shared.merge)(s1, s2);
|
|
136
142
|
field.data.value = operator.noValue ? operator.default || true : null;
|
|
137
143
|
data2value();
|
|
138
|
-
console.log('setOperator', field.data);
|
|
139
144
|
},
|
|
140
145
|
setValue: function setValue(value) {
|
|
141
146
|
field.data.value = value;
|
|
142
147
|
data2value();
|
|
143
|
-
console.log('setValue', field.data);
|
|
144
148
|
}
|
|
145
149
|
});
|
|
146
150
|
};
|
|
@@ -28,7 +28,7 @@ var _schemaSettings = require("../../../schema-settings");
|
|
|
28
28
|
var _schemaTemplates = require("../../../schema-templates");
|
|
29
29
|
|
|
30
30
|
var _excluded = ["form", "children"],
|
|
31
|
-
_excluded2 = ["form", "children"],
|
|
31
|
+
_excluded2 = ["form", "children", "disabled"],
|
|
32
32
|
_excluded3 = ["request", "effects", "initialValue", "useValues"];
|
|
33
33
|
|
|
34
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -80,6 +80,7 @@ var Def = function Def(props) {
|
|
|
80
80
|
var FormDecorator = function FormDecorator(props) {
|
|
81
81
|
var form = props.form,
|
|
82
82
|
children = props.children,
|
|
83
|
+
disabled = props.disabled,
|
|
83
84
|
others = _objectWithoutProperties(props, _excluded2);
|
|
84
85
|
|
|
85
86
|
var field = (0, _react.useField)();
|
|
@@ -89,7 +90,12 @@ var FormDecorator = function FormDecorator(props) {
|
|
|
89
90
|
basePath: ''
|
|
90
91
|
})));
|
|
91
92
|
var Component = (0, _.useComponent)(fieldSchema['x-component'], Def);
|
|
92
|
-
|
|
93
|
+
(0, _react2.useEffect)(function () {
|
|
94
|
+
form.disabled = disabled || field.disabled;
|
|
95
|
+
}, [disabled, field.disabled]);
|
|
96
|
+
return /*#__PURE__*/_react2.default.createElement(_antd2.ConfigProvider, {
|
|
97
|
+
componentDisabled: disabled
|
|
98
|
+
}, /*#__PURE__*/_react2.default.createElement(_react.FieldContext.Provider, {
|
|
93
99
|
value: undefined
|
|
94
100
|
}, /*#__PURE__*/_react2.default.createElement(_react.FormContext.Provider, {
|
|
95
101
|
value: form
|
|
@@ -101,7 +107,7 @@ var FormDecorator = function FormDecorator(props) {
|
|
|
101
107
|
basePath: f.address,
|
|
102
108
|
schema: fieldSchema,
|
|
103
109
|
onlyRenderProperties: true
|
|
104
|
-
}))))));
|
|
110
|
+
})))))));
|
|
105
111
|
};
|
|
106
112
|
|
|
107
113
|
var useRequestProps = function useRequestProps(props) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
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); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -15,7 +17,7 @@ var _shared = require("@formily/shared");
|
|
|
15
17
|
|
|
16
18
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
17
19
|
|
|
18
|
-
var _react2 =
|
|
20
|
+
var _react2 = _interopRequireWildcard(require("react"));
|
|
19
21
|
|
|
20
22
|
var _reactI18next = require("react-i18next");
|
|
21
23
|
|
|
@@ -35,6 +37,10 @@ var _shared2 = require("../input/shared");
|
|
|
35
37
|
|
|
36
38
|
var _templateObject;
|
|
37
39
|
|
|
40
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
41
|
+
|
|
42
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
|
+
|
|
38
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
45
|
|
|
40
46
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -59,8 +65,17 @@ var divWrap = function divWrap(schema) {
|
|
|
59
65
|
};
|
|
60
66
|
};
|
|
61
67
|
|
|
62
|
-
var FormItem = function
|
|
68
|
+
var FormItem = (0, _react.observer)(function (props) {
|
|
63
69
|
var field = (0, _react.useField)();
|
|
70
|
+
var ctx = (0, _react2.useContext)(_blockProvider.BlockRequestContext);
|
|
71
|
+
var schema = (0, _react.useFieldSchema)();
|
|
72
|
+
(0, _react2.useEffect)(function () {
|
|
73
|
+
if ((ctx === null || ctx === void 0 ? void 0 : ctx.block) === 'form') {
|
|
74
|
+
ctx.field.data = ctx.field.data || {};
|
|
75
|
+
ctx.field.data.activeFields = ctx.field.data.activeFields || new Set();
|
|
76
|
+
ctx.field.data.activeFields.add(schema.name);
|
|
77
|
+
}
|
|
78
|
+
}, []);
|
|
64
79
|
return /*#__PURE__*/_react2.default.createElement(_ACLProvider.ACLCollectionFieldProvider, null, /*#__PURE__*/_react2.default.createElement(_blockItem.BlockItem, {
|
|
65
80
|
className: 'nb-form-item'
|
|
66
81
|
}, /*#__PURE__*/_react2.default.createElement(_antd.FormItem, _objectSpread(_objectSpread({
|
|
@@ -72,12 +87,11 @@ var FormItem = function FormItem(props) {
|
|
|
72
87
|
}
|
|
73
88
|
}) : field.description
|
|
74
89
|
}))));
|
|
75
|
-
};
|
|
76
|
-
|
|
90
|
+
});
|
|
77
91
|
exports.FormItem = FormItem;
|
|
78
92
|
|
|
79
93
|
FormItem.Designer = function (props) {
|
|
80
|
-
var _interfaceConfig$vali, _collectionField$uiSc, _collectionField$uiSc2, _fieldSchema$xDecora, _collectionField$uiSc4, _fieldSchema$xCompon, _field$componentProps, _field$componentProps2;
|
|
94
|
+
var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _collectionField$uiSc2, _fieldSchema$xDecora, _collectionField$uiSc4, _fieldSchema$xCompon, _field$componentProps, _field$componentProps2;
|
|
81
95
|
|
|
82
96
|
var _useCollectionManager = (0, _collectionManager.useCollectionManager)(),
|
|
83
97
|
getCollectionFields = _useCollectionManager.getCollectionFields,
|
|
@@ -109,7 +123,7 @@ FormItem.Designer = function (props) {
|
|
|
109
123
|
var interfaceConfig = getInterface(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
|
|
110
124
|
var validateSchema = interfaceConfig === null || interfaceConfig === void 0 ? void 0 : (_interfaceConfig$vali = interfaceConfig['validateSchema']) === null || _interfaceConfig$vali === void 0 ? void 0 : _interfaceConfig$vali.call(interfaceConfig, fieldSchema);
|
|
111
125
|
var originalTitle = collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc = collectionField.uiSchema) === null || _collectionField$uiSc === void 0 ? void 0 : _collectionField$uiSc.title;
|
|
112
|
-
var targetFields = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) ? getCollectionFields(collectionField.target) : [];
|
|
126
|
+
var targetFields = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) ? getCollectionFields(collectionField.target) : (_getCollectionFields = getCollectionFields(collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetCollection)) !== null && _getCollectionFields !== void 0 ? _getCollectionFields : [];
|
|
113
127
|
var fieldComponentOptions = (0, _hooks.useFieldComponentOptions)();
|
|
114
128
|
var isSubFormAssocitionField = field.address.segments.includes('__form_grid');
|
|
115
129
|
var initialValue = {
|
|
@@ -515,7 +529,7 @@ FormItem.Designer = function (props) {
|
|
|
515
529
|
});
|
|
516
530
|
dn.refresh();
|
|
517
531
|
}
|
|
518
|
-
}),
|
|
532
|
+
}), options.length > 0 && fieldSchema['x-component'] === 'CollectionField' && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SelectItem, {
|
|
519
533
|
key: "title-field",
|
|
520
534
|
title: t('Title field'),
|
|
521
535
|
options: options,
|
|
@@ -66,6 +66,8 @@ var FormDesigner = function FormDesigner() {
|
|
|
66
66
|
componentName: 'FormItem',
|
|
67
67
|
collectionName: name,
|
|
68
68
|
resourceName: defaultResource
|
|
69
|
+
}), /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.LinkageRules, {
|
|
70
|
+
collectionName: name
|
|
69
71
|
}), /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.Divider, null), /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.Remove, {
|
|
70
72
|
removeParentsIfNoChildren: true,
|
|
71
73
|
breakRemoveOn: {
|
|
@@ -25,9 +25,11 @@ var _2 = require("../..");
|
|
|
25
25
|
|
|
26
26
|
var _useProps2 = require("../../hooks/useProps");
|
|
27
27
|
|
|
28
|
+
var _utils = require("./utils");
|
|
29
|
+
|
|
28
30
|
var _excluded = ["form", "children"],
|
|
29
|
-
_excluded2 = ["form", "children"],
|
|
30
|
-
_excluded3 = ["form"];
|
|
31
|
+
_excluded2 = ["form", "children", "disabled"],
|
|
32
|
+
_excluded3 = ["form", "disabled"];
|
|
31
33
|
|
|
32
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
35
|
|
|
@@ -74,6 +76,7 @@ var Def = function Def(props) {
|
|
|
74
76
|
var FormDecorator = function FormDecorator(props) {
|
|
75
77
|
var form = props.form,
|
|
76
78
|
children = props.children,
|
|
79
|
+
disabled = props.disabled,
|
|
77
80
|
others = _objectWithoutProperties(props, _excluded2);
|
|
78
81
|
|
|
79
82
|
var field = (0, _react.useField)();
|
|
@@ -98,13 +101,26 @@ var FormDecorator = function FormDecorator(props) {
|
|
|
98
101
|
}))))));
|
|
99
102
|
};
|
|
100
103
|
|
|
104
|
+
var getLinkageRules = function getLinkageRules(fieldSchema) {
|
|
105
|
+
var linkageRules = null;
|
|
106
|
+
fieldSchema.mapProperties(function (schema) {
|
|
107
|
+
if (schema['x-linkage-rules']) {
|
|
108
|
+
linkageRules = schema['x-linkage-rules'];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return linkageRules;
|
|
112
|
+
};
|
|
113
|
+
|
|
101
114
|
var WithForm = function WithForm(props) {
|
|
115
|
+
var _fieldSchema$parent;
|
|
116
|
+
|
|
102
117
|
var form = props.form;
|
|
103
118
|
var fieldSchema = (0, _react.useFieldSchema)();
|
|
104
119
|
|
|
105
120
|
var _useActionContext = (0, _.useActionContext)(),
|
|
106
121
|
setFormValueChanged = _useActionContext.setFormValueChanged;
|
|
107
122
|
|
|
123
|
+
var linkageRules = getLinkageRules(fieldSchema) || ((_fieldSchema$parent = fieldSchema.parent) === null || _fieldSchema$parent === void 0 ? void 0 : _fieldSchema$parent['x-linkage-rules']) || [];
|
|
108
124
|
(0, _react2.useEffect)(function () {
|
|
109
125
|
var id = (0, _shared.uid)();
|
|
110
126
|
form.addEffects(id, function () {
|
|
@@ -112,10 +128,69 @@ var WithForm = function WithForm(props) {
|
|
|
112
128
|
setFormValueChanged === null || setFormValueChanged === void 0 ? void 0 : setFormValueChanged(true);
|
|
113
129
|
});
|
|
114
130
|
});
|
|
131
|
+
form.disabled = props.disabled;
|
|
115
132
|
return function () {
|
|
116
133
|
form.removeEffects(id);
|
|
117
134
|
};
|
|
118
135
|
}, []);
|
|
136
|
+
(0, _react2.useEffect)(function () {
|
|
137
|
+
var id = (0, _shared.uid)();
|
|
138
|
+
form.addEffects(id, function () {
|
|
139
|
+
return linkageRules.map(function (v) {
|
|
140
|
+
var _v$actions;
|
|
141
|
+
|
|
142
|
+
return (_v$actions = v.actions) === null || _v$actions === void 0 ? void 0 : _v$actions.map(function (h) {
|
|
143
|
+
if (h.targetFields) {
|
|
144
|
+
var fields = h.targetFields.join(',');
|
|
145
|
+
(0, _core.onFieldInit)("*(".concat(fields, ")"), function (field, form) {
|
|
146
|
+
field['initProperty'] = {
|
|
147
|
+
display: field.display,
|
|
148
|
+
required: field.required,
|
|
149
|
+
pattern: field.pattern,
|
|
150
|
+
value: field.value || field.initialValue
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
(0, _core.onFieldChange)("*(".concat(fields, ")"), ['value', 'required', 'pattern', 'display'], function (field) {
|
|
154
|
+
field.linkageProperty = {};
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
return function () {
|
|
161
|
+
form.removeEffects(id);
|
|
162
|
+
};
|
|
163
|
+
}, []);
|
|
164
|
+
(0, _react2.useEffect)(function () {
|
|
165
|
+
var id = (0, _shared.uid)();
|
|
166
|
+
form.addEffects(id, function () {
|
|
167
|
+
var linkagefields = [];
|
|
168
|
+
return linkageRules.map(function (v, index) {
|
|
169
|
+
var _v$actions2;
|
|
170
|
+
|
|
171
|
+
return (_v$actions2 = v.actions) === null || _v$actions2 === void 0 ? void 0 : _v$actions2.map(function (h) {
|
|
172
|
+
if (h.targetFields) {
|
|
173
|
+
var fields = h.targetFields.join(',');
|
|
174
|
+
return (0, _core.onFieldReact)("*(".concat(fields, ")"), function (field, form) {
|
|
175
|
+
linkagefields.push(field);
|
|
176
|
+
(0, _utils.linkageMergeAction)(h, field, v.condition, form === null || form === void 0 ? void 0 : form.values);
|
|
177
|
+
|
|
178
|
+
if (index === linkageRules.length - 1) {
|
|
179
|
+
setTimeout(function () {
|
|
180
|
+
return linkagefields.map(function (v) {
|
|
181
|
+
v.linkageProperty = {};
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
return function () {
|
|
191
|
+
form.removeEffects(id);
|
|
192
|
+
};
|
|
193
|
+
}, [linkageRules]);
|
|
119
194
|
return fieldSchema['x-decorator'] === 'Form' ? /*#__PURE__*/_react2.default.createElement(FormDecorator, _objectSpread({}, props)) : /*#__PURE__*/_react2.default.createElement(FormComponent, _objectSpread({}, props));
|
|
120
195
|
};
|
|
121
196
|
|
|
@@ -127,6 +202,7 @@ var WithoutForm = function WithoutForm(props) {
|
|
|
127
202
|
|
|
128
203
|
var form = (0, _react2.useMemo)(function () {
|
|
129
204
|
return (0, _core.createForm)({
|
|
205
|
+
disabled: props.disabled,
|
|
130
206
|
effects: function effects() {
|
|
131
207
|
(0, _core.onFormInputChange)(function (form) {
|
|
132
208
|
setFormValueChanged === null || setFormValueChanged === void 0 ? void 0 : setFormValueChanged(true);
|
|
@@ -146,12 +222,20 @@ var Form = (0, _react.observer)(function (props) {
|
|
|
146
222
|
|
|
147
223
|
var _useProps = (0, _useProps2.useProps)(props),
|
|
148
224
|
form = _useProps.form,
|
|
225
|
+
disabled = _useProps.disabled,
|
|
149
226
|
others = _objectWithoutProperties(_useProps, _excluded3);
|
|
150
227
|
|
|
151
|
-
|
|
228
|
+
var formDisabled = disabled || field.disabled;
|
|
229
|
+
return /*#__PURE__*/_react2.default.createElement(_antd2.ConfigProvider, {
|
|
230
|
+
componentDisabled: formDisabled
|
|
231
|
+
}, /*#__PURE__*/_react2.default.createElement("form", null, /*#__PURE__*/_react2.default.createElement(_antd2.Spin, {
|
|
152
232
|
spinning: field.loading || false
|
|
153
|
-
}, form ? /*#__PURE__*/_react2.default.createElement(WithForm, _objectSpread({
|
|
233
|
+
}, form ? /*#__PURE__*/_react2.default.createElement(WithForm, _objectSpread(_objectSpread({
|
|
154
234
|
form: form
|
|
155
|
-
}, others)
|
|
235
|
+
}, others), {}, {
|
|
236
|
+
disabled: formDisabled
|
|
237
|
+
})) : /*#__PURE__*/_react2.default.createElement(WithoutForm, _objectSpread(_objectSpread({}, others), {}, {
|
|
238
|
+
disabled: formDisabled
|
|
239
|
+
})))));
|
|
156
240
|
});
|
|
157
241
|
exports.Form = Form;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.evaluate = evaluate;
|
|
9
|
+
exports.linkageMergeAction = void 0;
|
|
10
|
+
|
|
11
|
+
var _lodash = require("lodash");
|
|
12
|
+
|
|
13
|
+
var functions = _interopRequireWildcard(require("@formulajs/formulajs"));
|
|
14
|
+
|
|
15
|
+
var _uitls = require("../../common/utils/uitls");
|
|
16
|
+
|
|
17
|
+
var _type = require("../../../schema-settings/LinkageRules/type");
|
|
18
|
+
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
|
+
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
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; }
|
|
26
|
+
|
|
27
|
+
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; }
|
|
28
|
+
|
|
29
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
30
|
+
|
|
31
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
32
|
+
|
|
33
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
34
|
+
|
|
35
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
36
|
+
|
|
37
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
38
|
+
|
|
39
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
40
|
+
|
|
41
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
42
|
+
|
|
43
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
44
|
+
|
|
45
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
46
|
+
|
|
47
|
+
function now() {
|
|
48
|
+
return new Date();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var fnNames = Object.keys(functions).filter(function (key) {
|
|
52
|
+
return key !== 'default';
|
|
53
|
+
});
|
|
54
|
+
var fns = fnNames.map(function (key) {
|
|
55
|
+
return functions[key];
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
function formula(expression) {
|
|
59
|
+
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
var fn = _construct(Function, _toConsumableArray(fnNames).concat(_toConsumableArray(Object.keys(scope)), ["return ".concat(expression)]));
|
|
63
|
+
|
|
64
|
+
var result = fn.apply(void 0, _toConsumableArray(fns).concat(_toConsumableArray(Object.values(scope))));
|
|
65
|
+
|
|
66
|
+
if (typeof result === 'number') {
|
|
67
|
+
if (Number.isNaN(result) || !Number.isFinite(result)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return functions.ROUND(result, 9);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (typeof result === 'function') {
|
|
75
|
+
return result();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return result;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function evaluate(expression) {
|
|
85
|
+
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
86
|
+
|
|
87
|
+
var mergeScope = _objectSpread(_objectSpread({}, scope), {}, {
|
|
88
|
+
now: now
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
var exp = expression.trim().replace(/{{\s*([^{}]+)\s*}}/g, function (_, v) {
|
|
92
|
+
var item = (0, _lodash.get)(scope, v);
|
|
93
|
+
var key = v.replace(/\.(\d+)/g, '["$1"]');
|
|
94
|
+
return " ".concat(typeof item === 'function' ? item() : key, " ");
|
|
95
|
+
});
|
|
96
|
+
return formula(exp, mergeScope);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var linkageMergeAction = function linkageMergeAction(_ref, field, condition, values) {
|
|
100
|
+
var _field$linkagePropert, _field$initProperty, _field$linkagePropert2, _field$initProperty2, _field$linkagePropert3, _field$initProperty3, _field$linkagePropert4, _field$initProperty4, _field$linkagePropert5, _field$linkagePropert6, _field$linkagePropert7;
|
|
101
|
+
|
|
102
|
+
var operator = _ref.operator,
|
|
103
|
+
value = _ref.value;
|
|
104
|
+
var requiredResult = (field === null || field === void 0 ? void 0 : (_field$linkagePropert = field.linkageProperty) === null || _field$linkagePropert === void 0 ? void 0 : _field$linkagePropert.required) || [(field === null || field === void 0 ? void 0 : (_field$initProperty = field.initProperty) === null || _field$initProperty === void 0 ? void 0 : _field$initProperty.required) || false];
|
|
105
|
+
var displayResult = (field === null || field === void 0 ? void 0 : (_field$linkagePropert2 = field.linkageProperty) === null || _field$linkagePropert2 === void 0 ? void 0 : _field$linkagePropert2.display) || [field === null || field === void 0 ? void 0 : (_field$initProperty2 = field.initProperty) === null || _field$initProperty2 === void 0 ? void 0 : _field$initProperty2.display];
|
|
106
|
+
var patternResult = (field === null || field === void 0 ? void 0 : (_field$linkagePropert3 = field.linkageProperty) === null || _field$linkagePropert3 === void 0 ? void 0 : _field$linkagePropert3.pattern) || [field === null || field === void 0 ? void 0 : (_field$initProperty3 = field.initProperty) === null || _field$initProperty3 === void 0 ? void 0 : _field$initProperty3.pattern];
|
|
107
|
+
var valueResult = (field === null || field === void 0 ? void 0 : (_field$linkagePropert4 = field.linkageProperty) === null || _field$linkagePropert4 === void 0 ? void 0 : _field$linkagePropert4.value) || [field.value || (field === null || field === void 0 ? void 0 : (_field$initProperty4 = field.initProperty) === null || _field$initProperty4 === void 0 ? void 0 : _field$initProperty4.value)];
|
|
108
|
+
|
|
109
|
+
switch (operator) {
|
|
110
|
+
case _type.ActionType.Required:
|
|
111
|
+
if ((0, _uitls.conditionAnalyse)(condition, values)) {
|
|
112
|
+
requiredResult.push(true);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
116
|
+
required: requiredResult
|
|
117
|
+
});
|
|
118
|
+
field.required = (0, _lodash.last)((_field$linkagePropert5 = field.linkageProperty) === null || _field$linkagePropert5 === void 0 ? void 0 : _field$linkagePropert5.required);
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case _type.ActionType.InRequired:
|
|
122
|
+
if ((0, _uitls.conditionAnalyse)(condition, values)) {
|
|
123
|
+
requiredResult.push(false);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
127
|
+
required: requiredResult
|
|
128
|
+
});
|
|
129
|
+
field.required = (0, _lodash.last)((_field$linkagePropert6 = field.linkageProperty) === null || _field$linkagePropert6 === void 0 ? void 0 : _field$linkagePropert6.required);
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case _type.ActionType.Visible:
|
|
133
|
+
case _type.ActionType.None:
|
|
134
|
+
case _type.ActionType.Hidden:
|
|
135
|
+
if ((0, _uitls.conditionAnalyse)(condition, values)) {
|
|
136
|
+
displayResult.push(operator);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
140
|
+
display: displayResult
|
|
141
|
+
});
|
|
142
|
+
field.display = (0, _lodash.last)((_field$linkagePropert7 = field.linkageProperty) === null || _field$linkagePropert7 === void 0 ? void 0 : _field$linkagePropert7.display);
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case _type.ActionType.Editable:
|
|
146
|
+
case _type.ActionType.ReadOnly:
|
|
147
|
+
case _type.ActionType.ReadPretty:
|
|
148
|
+
if ((0, _uitls.conditionAnalyse)(condition, values)) {
|
|
149
|
+
patternResult.push(operator);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
153
|
+
pattern: patternResult
|
|
154
|
+
});
|
|
155
|
+
field.pattern = (0, _lodash.last)(field.linkageProperty.pattern);
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
case _type.ActionType.Value:
|
|
159
|
+
if ((0, _uitls.conditionAnalyse)(condition, values)) {
|
|
160
|
+
if ((value === null || value === void 0 ? void 0 : value.mode) === 'express') {
|
|
161
|
+
var result = evaluate(value.result || value.value, values);
|
|
162
|
+
valueResult.push(result);
|
|
163
|
+
} else {
|
|
164
|
+
valueResult.push((value === null || value === void 0 ? void 0 : value.value) || value);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
169
|
+
value: valueResult
|
|
170
|
+
});
|
|
171
|
+
setTimeout(function () {
|
|
172
|
+
return field.value = (0, _lodash.last)(valueResult) === undefined ? field.value : (0, _lodash.last)(valueResult);
|
|
173
|
+
});
|
|
174
|
+
break;
|
|
175
|
+
|
|
176
|
+
default:
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
exports.linkageMergeAction = linkageMergeAction;
|