@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
|
@@ -57,7 +57,8 @@ var VariableCascader = connect(function (props) {
|
|
|
57
57
|
});
|
|
58
58
|
export var DynamicComponent = function DynamicComponent(props) {
|
|
59
59
|
var _useContext = useContext(FilterContext),
|
|
60
|
-
dynamicComponent = _useContext.dynamicComponent
|
|
60
|
+
dynamicComponent = _useContext.dynamicComponent,
|
|
61
|
+
disabled = _useContext.disabled;
|
|
61
62
|
|
|
62
63
|
var component = useComponent(dynamicComponent);
|
|
63
64
|
var form = useMemo(function () {
|
|
@@ -65,6 +66,7 @@ export var DynamicComponent = function DynamicComponent(props) {
|
|
|
65
66
|
values: {
|
|
66
67
|
value: props.value
|
|
67
68
|
},
|
|
69
|
+
disabled: disabled,
|
|
68
70
|
effects: function effects() {
|
|
69
71
|
onFieldValueChange('value', function (field) {
|
|
70
72
|
var _props$onChange;
|
|
@@ -46,7 +46,8 @@ export var Filter = observer(function (props) {
|
|
|
46
46
|
field: field,
|
|
47
47
|
fieldSchema: fieldSchema,
|
|
48
48
|
dynamicComponent: dynamicComponent,
|
|
49
|
-
options: options || field.dataSource || []
|
|
49
|
+
options: options || field.dataSource || [],
|
|
50
|
+
disabled: props.disabled
|
|
50
51
|
}
|
|
51
52
|
}, /*#__PURE__*/React.createElement(FilterGroup, _objectSpread(_objectSpread({}, props), {}, {
|
|
52
53
|
bordered: false
|
|
@@ -21,7 +21,8 @@ import { FilterLogicContext, RemoveConditionContext } from './context';
|
|
|
21
21
|
import { FilterItems } from './FilterItems';
|
|
22
22
|
export var FilterGroup = connect(function (props) {
|
|
23
23
|
var _props$bordered = props.bordered,
|
|
24
|
-
bordered = _props$bordered === void 0 ? true : _props$bordered
|
|
24
|
+
bordered = _props$bordered === void 0 ? true : _props$bordered,
|
|
25
|
+
disabled = props.disabled;
|
|
25
26
|
var field = useField();
|
|
26
27
|
var remove = useContext(RemoveConditionContext);
|
|
27
28
|
|
|
@@ -36,6 +37,7 @@ export var FilterGroup = connect(function (props) {
|
|
|
36
37
|
field.value = _defineProperty({}, value, _toConsumableArray(obj[logic] || []));
|
|
37
38
|
};
|
|
38
39
|
|
|
40
|
+
var mergedDisabled = disabled || field.disabled;
|
|
39
41
|
return /*#__PURE__*/React.createElement(FilterLogicContext.Provider, {
|
|
40
42
|
value: logic
|
|
41
43
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -48,7 +50,7 @@ export var FilterGroup = connect(function (props) {
|
|
|
48
50
|
position: 'relative',
|
|
49
51
|
marginBottom: 8
|
|
50
52
|
}
|
|
51
|
-
}, remove && /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(CloseCircleOutlined, {
|
|
53
|
+
}, remove && !mergedDisabled && /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(CloseCircleOutlined, {
|
|
52
54
|
style: {
|
|
53
55
|
position: 'absolute',
|
|
54
56
|
right: 10,
|
|
@@ -76,8 +78,9 @@ export var FilterGroup = connect(function (props) {
|
|
|
76
78
|
value: '$or'
|
|
77
79
|
}, "Any")), ' conditions in the group')), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ArrayField, {
|
|
78
80
|
name: logic,
|
|
79
|
-
component: [FilterItems]
|
|
80
|
-
|
|
81
|
+
component: [FilterItems],
|
|
82
|
+
disabled: mergedDisabled
|
|
83
|
+
})), !mergedDisabled && /*#__PURE__*/React.createElement(Space, {
|
|
81
84
|
size: 16,
|
|
82
85
|
style: {
|
|
83
86
|
marginTop: 8,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _templateObject;
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
2
2
|
|
|
3
3
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
4
4
|
|
|
@@ -49,6 +49,7 @@ export var FilterItem = observer(function (props) {
|
|
|
49
49
|
},
|
|
50
50
|
placeholder: t('Select Field')
|
|
51
51
|
}), /*#__PURE__*/React.createElement(Select, {
|
|
52
|
+
className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 110px;\n "]))),
|
|
52
53
|
value: operator === null || operator === void 0 ? void 0 : operator.value,
|
|
53
54
|
options: compile(operators),
|
|
54
55
|
onChange: function onChange(value) {
|
|
@@ -61,7 +62,7 @@ export var FilterItem = observer(function (props) {
|
|
|
61
62
|
onChange: function onChange(value) {
|
|
62
63
|
setValue(value);
|
|
63
64
|
}
|
|
64
|
-
}), /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(CloseCircleOutlined, {
|
|
65
|
+
}), !props.disabled && /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(CloseCircleOutlined, {
|
|
65
66
|
onClick: function onClick() {
|
|
66
67
|
return remove();
|
|
67
68
|
},
|
|
@@ -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>;
|
|
@@ -19,6 +19,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
19
19
|
import { useField } from '@formily/react';
|
|
20
20
|
import { merge } from '@formily/shared';
|
|
21
21
|
import flat from 'flat';
|
|
22
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
22
23
|
import get from 'lodash/get';
|
|
23
24
|
import { useContext, useEffect } from 'react';
|
|
24
25
|
import { FilterContext, FilterLogicContext } from './context'; // import { useValues } from './useValues';
|
|
@@ -60,6 +61,7 @@ export var useValues = function useValues() {
|
|
|
60
61
|
var value2data = function value2data() {
|
|
61
62
|
var _operators$find;
|
|
62
63
|
|
|
64
|
+
field.data = field.data || {};
|
|
63
65
|
var values = flat(field.value);
|
|
64
66
|
var path = Object.keys(values).shift() || '';
|
|
65
67
|
|
|
@@ -69,8 +71,10 @@ export var useValues = function useValues() {
|
|
|
69
71
|
|
|
70
72
|
var _path$split = path.split('.$'),
|
|
71
73
|
_path$split2 = _slicedToArray(_path$split, 2),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
_path$split2$ = _path$split2[0],
|
|
75
|
+
fieldPath = _path$split2$ === void 0 ? '' : _path$split2$,
|
|
76
|
+
_path$split2$2 = _path$split2[1],
|
|
77
|
+
otherPath = _path$split2$2 === void 0 ? '' : _path$split2$2;
|
|
74
78
|
|
|
75
79
|
var _otherPath$split = otherPath.split('.', 2),
|
|
76
80
|
_otherPath$split2 = _slicedToArray(_otherPath$split, 1),
|
|
@@ -82,7 +86,6 @@ export var useValues = function useValues() {
|
|
|
82
86
|
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) {
|
|
83
87
|
return item.value === "$".concat(operatorValue);
|
|
84
88
|
});
|
|
85
|
-
field.data = field.data || {};
|
|
86
89
|
field.data.dataIndex = dataIndex;
|
|
87
90
|
field.data.operators = operators;
|
|
88
91
|
field.data.operator = operator;
|
|
@@ -90,9 +93,7 @@ export var useValues = function useValues() {
|
|
|
90
93
|
field.data.value = get(field.value, "".concat(fieldPath, ".$").concat(operatorValue));
|
|
91
94
|
};
|
|
92
95
|
|
|
93
|
-
useEffect(
|
|
94
|
-
value2data();
|
|
95
|
-
}, [logic]);
|
|
96
|
+
useEffect(value2data, [logic]);
|
|
96
97
|
return _objectSpread(_objectSpread({
|
|
97
98
|
fields: options
|
|
98
99
|
}, field.data), {}, {
|
|
@@ -104,11 +105,12 @@ export var useValues = function useValues() {
|
|
|
104
105
|
field.data = field.data || {};
|
|
105
106
|
field.data.operators = option === null || option === void 0 ? void 0 : option.operators;
|
|
106
107
|
field.data.operator = operator;
|
|
107
|
-
|
|
108
|
+
var s1 = cloneDeep(option === null || option === void 0 ? void 0 : option.schema);
|
|
109
|
+
var s2 = cloneDeep(operator === null || operator === void 0 ? void 0 : operator.schema);
|
|
110
|
+
field.data.schema = merge(s1, s2);
|
|
108
111
|
field.data.dataIndex = dataIndex;
|
|
109
112
|
field.data.value = null;
|
|
110
113
|
data2value();
|
|
111
|
-
console.log('setDataIndex', field.data);
|
|
112
114
|
},
|
|
113
115
|
setOperator: function setOperator(operatorValue) {
|
|
114
116
|
var _field$data3, _field$data3$operator, _field$data3$operator2;
|
|
@@ -117,15 +119,16 @@ export var useValues = function useValues() {
|
|
|
117
119
|
return item.value === operatorValue;
|
|
118
120
|
});
|
|
119
121
|
field.data.operator = operator;
|
|
120
|
-
|
|
122
|
+
var option = findOption(field.data.dataIndex, options);
|
|
123
|
+
var s1 = cloneDeep(option === null || option === void 0 ? void 0 : option.schema);
|
|
124
|
+
var s2 = cloneDeep(operator === null || operator === void 0 ? void 0 : operator.schema);
|
|
125
|
+
field.data.schema = merge(s1, s2);
|
|
121
126
|
field.data.value = operator.noValue ? operator.default || true : null;
|
|
122
127
|
data2value();
|
|
123
|
-
console.log('setOperator', field.data);
|
|
124
128
|
},
|
|
125
129
|
setValue: function setValue(value) {
|
|
126
130
|
field.data.value = value;
|
|
127
131
|
data2value();
|
|
128
|
-
console.log('setValue', field.data);
|
|
129
132
|
}
|
|
130
133
|
});
|
|
131
134
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["form", "children"],
|
|
2
|
-
_excluded2 = ["form", "children"],
|
|
2
|
+
_excluded2 = ["form", "children", "disabled"],
|
|
3
3
|
_excluded3 = ["request", "effects", "initialValue", "useValues"];
|
|
4
4
|
|
|
5
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -19,8 +19,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
19
19
|
import { FormLayout } from '@formily/antd';
|
|
20
20
|
import { createForm } from '@formily/core';
|
|
21
21
|
import { FieldContext, FormContext, observer, RecursionField, useField, useFieldSchema } from '@formily/react';
|
|
22
|
-
import { Spin } from 'antd';
|
|
23
|
-
import React, { createContext, useContext, useMemo } from 'react';
|
|
22
|
+
import { ConfigProvider, Spin } from 'antd';
|
|
23
|
+
import React, { createContext, useContext, useEffect, useMemo } from 'react';
|
|
24
24
|
import { useAttach, useComponent } from '../..';
|
|
25
25
|
import { useRequest } from '../../../api-client';
|
|
26
26
|
import { useCollection } from '../../../collection-manager';
|
|
@@ -58,6 +58,7 @@ var Def = function Def(props) {
|
|
|
58
58
|
var FormDecorator = function FormDecorator(props) {
|
|
59
59
|
var form = props.form,
|
|
60
60
|
children = props.children,
|
|
61
|
+
disabled = props.disabled,
|
|
61
62
|
others = _objectWithoutProperties(props, _excluded2);
|
|
62
63
|
|
|
63
64
|
var field = useField();
|
|
@@ -67,7 +68,12 @@ var FormDecorator = function FormDecorator(props) {
|
|
|
67
68
|
basePath: ''
|
|
68
69
|
})));
|
|
69
70
|
var Component = useComponent(fieldSchema['x-component'], Def);
|
|
70
|
-
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
form.disabled = disabled || field.disabled;
|
|
73
|
+
}, [disabled, field.disabled]);
|
|
74
|
+
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
75
|
+
componentDisabled: disabled
|
|
76
|
+
}, /*#__PURE__*/React.createElement(FieldContext.Provider, {
|
|
71
77
|
value: undefined
|
|
72
78
|
}, /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
73
79
|
value: form
|
|
@@ -79,7 +85,7 @@ var FormDecorator = function FormDecorator(props) {
|
|
|
79
85
|
basePath: f.address,
|
|
80
86
|
schema: fieldSchema,
|
|
81
87
|
onlyRenderProperties: true
|
|
82
|
-
}))))));
|
|
88
|
+
})))))));
|
|
83
89
|
};
|
|
84
90
|
|
|
85
91
|
var useRequestProps = function useRequestProps(props) {
|
|
@@ -16,13 +16,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
16
16
|
|
|
17
17
|
import { css } from '@emotion/css';
|
|
18
18
|
import { ArrayCollapse, FormItem as Item, FormLayout } from '@formily/antd';
|
|
19
|
-
import { useField, useFieldSchema } from '@formily/react';
|
|
19
|
+
import { observer, useField, useFieldSchema } from '@formily/react';
|
|
20
20
|
import { uid } from '@formily/shared';
|
|
21
21
|
import _ from 'lodash';
|
|
22
|
-
import React from 'react';
|
|
22
|
+
import React, { useContext, useEffect } from 'react';
|
|
23
23
|
import { useTranslation } from 'react-i18next';
|
|
24
24
|
import { ACLCollectionFieldProvider } from '../../../acl/ACLProvider';
|
|
25
|
-
import { useFilterByTk, useFormBlockContext } from '../../../block-provider';
|
|
25
|
+
import { BlockRequestContext, useFilterByTk, useFormBlockContext } from '../../../block-provider';
|
|
26
26
|
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
|
27
27
|
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
|
|
28
28
|
import { useCompile, useDesignable, useFieldComponentOptions } from '../../hooks';
|
|
@@ -37,8 +37,17 @@ var divWrap = function divWrap(schema) {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export var FormItem = function
|
|
40
|
+
export var FormItem = observer(function (props) {
|
|
41
41
|
var field = useField();
|
|
42
|
+
var ctx = useContext(BlockRequestContext);
|
|
43
|
+
var schema = useFieldSchema();
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
if ((ctx === null || ctx === void 0 ? void 0 : ctx.block) === 'form') {
|
|
46
|
+
ctx.field.data = ctx.field.data || {};
|
|
47
|
+
ctx.field.data.activeFields = ctx.field.data.activeFields || new Set();
|
|
48
|
+
ctx.field.data.activeFields.add(schema.name);
|
|
49
|
+
}
|
|
50
|
+
}, []);
|
|
42
51
|
return /*#__PURE__*/React.createElement(ACLCollectionFieldProvider, null, /*#__PURE__*/React.createElement(BlockItem, {
|
|
43
52
|
className: 'nb-form-item'
|
|
44
53
|
}, /*#__PURE__*/React.createElement(Item, _objectSpread(_objectSpread({
|
|
@@ -50,10 +59,10 @@ export var FormItem = function FormItem(props) {
|
|
|
50
59
|
}
|
|
51
60
|
}) : field.description
|
|
52
61
|
}))));
|
|
53
|
-
};
|
|
62
|
+
});
|
|
54
63
|
|
|
55
64
|
FormItem.Designer = function (props) {
|
|
56
|
-
var _interfaceConfig$vali, _collectionField$uiSc, _collectionField$uiSc2, _fieldSchema$xDecora, _collectionField$uiSc4, _fieldSchema$xCompon, _field$componentProps, _field$componentProps2;
|
|
65
|
+
var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _collectionField$uiSc2, _fieldSchema$xDecora, _collectionField$uiSc4, _fieldSchema$xCompon, _field$componentProps, _field$componentProps2;
|
|
57
66
|
|
|
58
67
|
var _useCollectionManager = useCollectionManager(),
|
|
59
68
|
getCollectionFields = _useCollectionManager.getCollectionFields,
|
|
@@ -85,7 +94,7 @@ FormItem.Designer = function (props) {
|
|
|
85
94
|
var interfaceConfig = getInterface(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
|
|
86
95
|
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);
|
|
87
96
|
var originalTitle = collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc = collectionField.uiSchema) === null || _collectionField$uiSc === void 0 ? void 0 : _collectionField$uiSc.title;
|
|
88
|
-
var targetFields = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) ? getCollectionFields(collectionField.target) : [];
|
|
97
|
+
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 : [];
|
|
89
98
|
var fieldComponentOptions = useFieldComponentOptions();
|
|
90
99
|
var isSubFormAssocitionField = field.address.segments.includes('__form_grid');
|
|
91
100
|
var initialValue = {
|
|
@@ -491,7 +500,7 @@ FormItem.Designer = function (props) {
|
|
|
491
500
|
});
|
|
492
501
|
dn.refresh();
|
|
493
502
|
}
|
|
494
|
-
}),
|
|
503
|
+
}), options.length > 0 && fieldSchema['x-component'] === 'CollectionField' && /*#__PURE__*/React.createElement(SchemaSettings.SelectItem, {
|
|
495
504
|
key: "title-field",
|
|
496
505
|
title: t('Title field'),
|
|
497
506
|
options: options,
|
|
@@ -45,6 +45,8 @@ export var FormDesigner = function FormDesigner() {
|
|
|
45
45
|
componentName: 'FormItem',
|
|
46
46
|
collectionName: name,
|
|
47
47
|
resourceName: defaultResource
|
|
48
|
+
}), /*#__PURE__*/React.createElement(SchemaSettings.LinkageRules, {
|
|
49
|
+
collectionName: name
|
|
48
50
|
}), /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Remove, {
|
|
49
51
|
removeParentsIfNoChildren: true,
|
|
50
52
|
breakRemoveOn: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _excluded = ["form", "children"],
|
|
2
|
-
_excluded2 = ["form", "children"],
|
|
3
|
-
_excluded3 = ["form"];
|
|
2
|
+
_excluded2 = ["form", "children", "disabled"],
|
|
3
|
+
_excluded3 = ["form", "disabled"];
|
|
4
4
|
|
|
5
5
|
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; }
|
|
6
6
|
|
|
@@ -13,14 +13,15 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
13
13
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
14
14
|
|
|
15
15
|
import { FormLayout } from '@formily/antd';
|
|
16
|
-
import { createForm, onFormInputChange } from '@formily/core';
|
|
16
|
+
import { createForm, onFormInputChange, onFieldReact, onFieldInit, onFieldChange } from '@formily/core';
|
|
17
17
|
import { FieldContext, FormContext, observer, RecursionField, useField, useFieldSchema } from '@formily/react';
|
|
18
18
|
import { uid } from '@formily/shared';
|
|
19
|
-
import { Spin } from 'antd';
|
|
19
|
+
import { ConfigProvider, Spin } from 'antd';
|
|
20
20
|
import React, { useEffect, useMemo } from 'react';
|
|
21
21
|
import { useActionContext } from '..';
|
|
22
22
|
import { useAttach, useComponent } from '../..';
|
|
23
23
|
import { useProps } from '../../hooks/useProps';
|
|
24
|
+
import { linkageMergeAction } from './utils';
|
|
24
25
|
|
|
25
26
|
var FormComponent = function FormComponent(props) {
|
|
26
27
|
var form = props.form,
|
|
@@ -53,6 +54,7 @@ var Def = function Def(props) {
|
|
|
53
54
|
var FormDecorator = function FormDecorator(props) {
|
|
54
55
|
var form = props.form,
|
|
55
56
|
children = props.children,
|
|
57
|
+
disabled = props.disabled,
|
|
56
58
|
others = _objectWithoutProperties(props, _excluded2);
|
|
57
59
|
|
|
58
60
|
var field = useField();
|
|
@@ -77,13 +79,26 @@ var FormDecorator = function FormDecorator(props) {
|
|
|
77
79
|
}))))));
|
|
78
80
|
};
|
|
79
81
|
|
|
82
|
+
var getLinkageRules = function getLinkageRules(fieldSchema) {
|
|
83
|
+
var linkageRules = null;
|
|
84
|
+
fieldSchema.mapProperties(function (schema) {
|
|
85
|
+
if (schema['x-linkage-rules']) {
|
|
86
|
+
linkageRules = schema['x-linkage-rules'];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return linkageRules;
|
|
90
|
+
};
|
|
91
|
+
|
|
80
92
|
var WithForm = function WithForm(props) {
|
|
93
|
+
var _fieldSchema$parent;
|
|
94
|
+
|
|
81
95
|
var form = props.form;
|
|
82
96
|
var fieldSchema = useFieldSchema();
|
|
83
97
|
|
|
84
98
|
var _useActionContext = useActionContext(),
|
|
85
99
|
setFormValueChanged = _useActionContext.setFormValueChanged;
|
|
86
100
|
|
|
101
|
+
var linkageRules = getLinkageRules(fieldSchema) || ((_fieldSchema$parent = fieldSchema.parent) === null || _fieldSchema$parent === void 0 ? void 0 : _fieldSchema$parent['x-linkage-rules']) || [];
|
|
87
102
|
useEffect(function () {
|
|
88
103
|
var id = uid();
|
|
89
104
|
form.addEffects(id, function () {
|
|
@@ -91,10 +106,69 @@ var WithForm = function WithForm(props) {
|
|
|
91
106
|
setFormValueChanged === null || setFormValueChanged === void 0 ? void 0 : setFormValueChanged(true);
|
|
92
107
|
});
|
|
93
108
|
});
|
|
109
|
+
form.disabled = props.disabled;
|
|
110
|
+
return function () {
|
|
111
|
+
form.removeEffects(id);
|
|
112
|
+
};
|
|
113
|
+
}, []);
|
|
114
|
+
useEffect(function () {
|
|
115
|
+
var id = uid();
|
|
116
|
+
form.addEffects(id, function () {
|
|
117
|
+
return linkageRules.map(function (v) {
|
|
118
|
+
var _v$actions;
|
|
119
|
+
|
|
120
|
+
return (_v$actions = v.actions) === null || _v$actions === void 0 ? void 0 : _v$actions.map(function (h) {
|
|
121
|
+
if (h.targetFields) {
|
|
122
|
+
var fields = h.targetFields.join(',');
|
|
123
|
+
onFieldInit("*(".concat(fields, ")"), function (field, form) {
|
|
124
|
+
field['initProperty'] = {
|
|
125
|
+
display: field.display,
|
|
126
|
+
required: field.required,
|
|
127
|
+
pattern: field.pattern,
|
|
128
|
+
value: field.value || field.initialValue
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
onFieldChange("*(".concat(fields, ")"), ['value', 'required', 'pattern', 'display'], function (field) {
|
|
132
|
+
field.linkageProperty = {};
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
94
138
|
return function () {
|
|
95
139
|
form.removeEffects(id);
|
|
96
140
|
};
|
|
97
141
|
}, []);
|
|
142
|
+
useEffect(function () {
|
|
143
|
+
var id = uid();
|
|
144
|
+
form.addEffects(id, function () {
|
|
145
|
+
var linkagefields = [];
|
|
146
|
+
return linkageRules.map(function (v, index) {
|
|
147
|
+
var _v$actions2;
|
|
148
|
+
|
|
149
|
+
return (_v$actions2 = v.actions) === null || _v$actions2 === void 0 ? void 0 : _v$actions2.map(function (h) {
|
|
150
|
+
if (h.targetFields) {
|
|
151
|
+
var fields = h.targetFields.join(',');
|
|
152
|
+
return onFieldReact("*(".concat(fields, ")"), function (field, form) {
|
|
153
|
+
linkagefields.push(field);
|
|
154
|
+
linkageMergeAction(h, field, v.condition, form === null || form === void 0 ? void 0 : form.values);
|
|
155
|
+
|
|
156
|
+
if (index === linkageRules.length - 1) {
|
|
157
|
+
setTimeout(function () {
|
|
158
|
+
return linkagefields.map(function (v) {
|
|
159
|
+
v.linkageProperty = {};
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
return function () {
|
|
169
|
+
form.removeEffects(id);
|
|
170
|
+
};
|
|
171
|
+
}, [linkageRules]);
|
|
98
172
|
return fieldSchema['x-decorator'] === 'Form' ? /*#__PURE__*/React.createElement(FormDecorator, _objectSpread({}, props)) : /*#__PURE__*/React.createElement(FormComponent, _objectSpread({}, props));
|
|
99
173
|
};
|
|
100
174
|
|
|
@@ -106,6 +180,7 @@ var WithoutForm = function WithoutForm(props) {
|
|
|
106
180
|
|
|
107
181
|
var form = useMemo(function () {
|
|
108
182
|
return createForm({
|
|
183
|
+
disabled: props.disabled,
|
|
109
184
|
effects: function effects() {
|
|
110
185
|
onFormInputChange(function (form) {
|
|
111
186
|
setFormValueChanged === null || setFormValueChanged === void 0 ? void 0 : setFormValueChanged(true);
|
|
@@ -125,11 +200,19 @@ export var Form = observer(function (props) {
|
|
|
125
200
|
|
|
126
201
|
var _useProps = useProps(props),
|
|
127
202
|
form = _useProps.form,
|
|
203
|
+
disabled = _useProps.disabled,
|
|
128
204
|
others = _objectWithoutProperties(_useProps, _excluded3);
|
|
129
205
|
|
|
130
|
-
|
|
206
|
+
var formDisabled = disabled || field.disabled;
|
|
207
|
+
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
208
|
+
componentDisabled: formDisabled
|
|
209
|
+
}, /*#__PURE__*/React.createElement("form", null, /*#__PURE__*/React.createElement(Spin, {
|
|
131
210
|
spinning: field.loading || false
|
|
132
|
-
}, form ? /*#__PURE__*/React.createElement(WithForm, _objectSpread({
|
|
211
|
+
}, form ? /*#__PURE__*/React.createElement(WithForm, _objectSpread(_objectSpread({
|
|
133
212
|
form: form
|
|
134
|
-
}, others)
|
|
213
|
+
}, others), {}, {
|
|
214
|
+
disabled: formDisabled
|
|
215
|
+
})) : /*#__PURE__*/React.createElement(WithoutForm, _objectSpread(_objectSpread({}, others), {}, {
|
|
216
|
+
disabled: formDisabled
|
|
217
|
+
})))));
|
|
135
218
|
});
|
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
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); }
|
|
8
|
+
|
|
9
|
+
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; } }
|
|
10
|
+
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
|
|
13
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
+
|
|
15
|
+
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."); }
|
|
16
|
+
|
|
17
|
+
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); }
|
|
18
|
+
|
|
19
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
|
+
|
|
21
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
import { last, get } from 'lodash';
|
|
26
|
+
import * as functions from '@formulajs/formulajs';
|
|
27
|
+
import { conditionAnalyse } from '../../common/utils/uitls';
|
|
28
|
+
import { ActionType } from '../../../schema-settings/LinkageRules/type';
|
|
29
|
+
|
|
30
|
+
function now() {
|
|
31
|
+
return new Date();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var fnNames = Object.keys(functions).filter(function (key) {
|
|
35
|
+
return key !== 'default';
|
|
36
|
+
});
|
|
37
|
+
var fns = fnNames.map(function (key) {
|
|
38
|
+
return functions[key];
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function formula(expression) {
|
|
42
|
+
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
var fn = _construct(Function, _toConsumableArray(fnNames).concat(_toConsumableArray(Object.keys(scope)), ["return ".concat(expression)]));
|
|
46
|
+
|
|
47
|
+
var result = fn.apply(void 0, _toConsumableArray(fns).concat(_toConsumableArray(Object.values(scope))));
|
|
48
|
+
|
|
49
|
+
if (typeof result === 'number') {
|
|
50
|
+
if (Number.isNaN(result) || !Number.isFinite(result)) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return functions.ROUND(result, 9);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof result === 'function') {
|
|
58
|
+
return result();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return result;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function evaluate(expression) {
|
|
68
|
+
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
69
|
+
|
|
70
|
+
var mergeScope = _objectSpread(_objectSpread({}, scope), {}, {
|
|
71
|
+
now: now
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
var exp = expression.trim().replace(/{{\s*([^{}]+)\s*}}/g, function (_, v) {
|
|
75
|
+
var item = get(scope, v);
|
|
76
|
+
var key = v.replace(/\.(\d+)/g, '["$1"]');
|
|
77
|
+
return " ".concat(typeof item === 'function' ? item() : key, " ");
|
|
78
|
+
});
|
|
79
|
+
return formula(exp, mergeScope);
|
|
80
|
+
}
|
|
81
|
+
export var linkageMergeAction = function linkageMergeAction(_ref, field, condition, values) {
|
|
82
|
+
var _field$linkagePropert, _field$initProperty, _field$linkagePropert2, _field$initProperty2, _field$linkagePropert3, _field$initProperty3, _field$linkagePropert4, _field$initProperty4, _field$linkagePropert5, _field$linkagePropert6, _field$linkagePropert7;
|
|
83
|
+
|
|
84
|
+
var operator = _ref.operator,
|
|
85
|
+
value = _ref.value;
|
|
86
|
+
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];
|
|
87
|
+
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];
|
|
88
|
+
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];
|
|
89
|
+
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)];
|
|
90
|
+
|
|
91
|
+
switch (operator) {
|
|
92
|
+
case ActionType.Required:
|
|
93
|
+
if (conditionAnalyse(condition, values)) {
|
|
94
|
+
requiredResult.push(true);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
98
|
+
required: requiredResult
|
|
99
|
+
});
|
|
100
|
+
field.required = last((_field$linkagePropert5 = field.linkageProperty) === null || _field$linkagePropert5 === void 0 ? void 0 : _field$linkagePropert5.required);
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case ActionType.InRequired:
|
|
104
|
+
if (conditionAnalyse(condition, values)) {
|
|
105
|
+
requiredResult.push(false);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
109
|
+
required: requiredResult
|
|
110
|
+
});
|
|
111
|
+
field.required = last((_field$linkagePropert6 = field.linkageProperty) === null || _field$linkagePropert6 === void 0 ? void 0 : _field$linkagePropert6.required);
|
|
112
|
+
break;
|
|
113
|
+
|
|
114
|
+
case ActionType.Visible:
|
|
115
|
+
case ActionType.None:
|
|
116
|
+
case ActionType.Hidden:
|
|
117
|
+
if (conditionAnalyse(condition, values)) {
|
|
118
|
+
displayResult.push(operator);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
122
|
+
display: displayResult
|
|
123
|
+
});
|
|
124
|
+
field.display = last((_field$linkagePropert7 = field.linkageProperty) === null || _field$linkagePropert7 === void 0 ? void 0 : _field$linkagePropert7.display);
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case ActionType.Editable:
|
|
128
|
+
case ActionType.ReadOnly:
|
|
129
|
+
case ActionType.ReadPretty:
|
|
130
|
+
if (conditionAnalyse(condition, values)) {
|
|
131
|
+
patternResult.push(operator);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
135
|
+
pattern: patternResult
|
|
136
|
+
});
|
|
137
|
+
field.pattern = last(field.linkageProperty.pattern);
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case ActionType.Value:
|
|
141
|
+
if (conditionAnalyse(condition, values)) {
|
|
142
|
+
if ((value === null || value === void 0 ? void 0 : value.mode) === 'express') {
|
|
143
|
+
var result = evaluate(value.result || value.value, values);
|
|
144
|
+
valueResult.push(result);
|
|
145
|
+
} else {
|
|
146
|
+
valueResult.push((value === null || value === void 0 ? void 0 : value.value) || value);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
field.linkageProperty = _objectSpread(_objectSpread({}, field.linkageProperty), {}, {
|
|
151
|
+
value: valueResult
|
|
152
|
+
});
|
|
153
|
+
setTimeout(function () {
|
|
154
|
+
return field.value = last(valueResult) === undefined ? field.value : last(valueResult);
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
default:
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
};
|