()
+ const schema = useFieldSchema()
+ const prefixCls = usePrefixCls('formily-logic-diagram')
+ const {
+ relationSchema,
+ ruleSchema,
+ addRuleSchema,
+ addRuleGroupSchema,
+ removeRuleSchema,
+ } = useLogicDiagramSource()
+ const childrenKey = ruleSchema.name as string
+ const data = useDiagramData(childrenKey)
+
+ const renderNode: RenderNodeFN = (nodePath, type, data) => {
+ switch (type) {
+ case NodeTypes.LEAF:
+ if (data[ACTION_NODE]) {
+ return (
+
+
+
+
+
+
+
+
+ )
+ } else {
+ return (
+
+
+
+
+
+
+ )
+ }
+ case NodeTypes.NON_LEAF:
+ return (
+
+
+
+
+
+ )
+ default:
+ return null
+ }
+ }
+
+ return (
+
+
+
+
+
+ )
+})
+
+LogicDiagram.Relation = () => {
+ return
+}
+
+LogicDiagram.Rule = () => {
+ return
+}
+
+LogicDiagram.AddRule = ({
+ tooltipProps,
+ iconProps,
+ defaultValue,
+ ...buttonProps
+}) => {
+ const self = useField()
+ const logicDiagram = useLogicDiagram()
+ const nodePath = useNodePath()
+ const prefixCls = usePrefixCls('formily-logic-diagram')
+ return (
+ {
+ logicDiagram?.field?.addProperty(nodePath, defaultValue || {})
+ }}
+ >
+
+
+ }
+ >
+ {self.title || tooltipProps?.children || '添加条件'}
+
+ )
+}
+
+LogicDiagram.AddRuleGroup = ({
+ tooltipProps,
+ iconProps,
+ defaultValue,
+ ...buttonProps
+}) => {
+ const self = useField()
+ const logicDiagram = useLogicDiagram()
+ const nodePath = useNodePath()
+ const prefixCls = usePrefixCls('formily-logic-diagram')
+ return (
+ {
+ logicDiagram?.field?.addProperty(
+ nodePath,
+ defaultValue || { [logicDiagram.childrenKey]: [{}] }
+ )
+ }}
+ >
+
+
+ }
+ >
+ {self.title || tooltipProps?.children || '添加条件组'}
+
+ )
+}
+
+LogicDiagram.RemoveRule = ({ iconProps, ...buttonProps }) => {
+ const logicDiagram = useLogicDiagram()
+ const nodePath = useNodePath()
+ const prefixCls = usePrefixCls('formily-logic-diagram')
+
+ return (
+
+
+
+ )
+}
+
+export default LogicDiagram
diff --git a/packages/next/src/logic-diagram/main.scss b/packages/next/src/logic-diagram/main.scss
new file mode 100644
index 00000000000..1645d984acd
--- /dev/null
+++ b/packages/next/src/logic-diagram/main.scss
@@ -0,0 +1,61 @@
+@import '~@alifd/next/lib/core/index-noreset.scss';
+
+$logic-diagram-prefix-cls: $css-prefix + 'formily-logic-diagram';
+
+.#{$logic-diagram-prefix-cls} {
+ .#{$logic-diagram-prefix-cls}-relation {
+ height: 100%;
+ display: flex;
+ align-items: center;
+
+ .#{$css-prefix}form-item {
+ margin-bottom: 0;
+ }
+ }
+
+ .#{$logic-diagram-prefix-cls}-rule {
+ height: 100%;
+ display: flex;
+ align-items: center;
+
+ .#{$logic-diagram-prefix-cls}-remove-action {
+ visibility: hidden;
+ padding-left: 8px;
+ padding-right: 8px;
+ }
+
+ .#{$css-prefix}form-item {
+ margin-bottom: 0;
+
+ .#{$css-prefix}form-item-control {
+ position: relative;
+
+ .#{$css-prefix}form-item-help {
+ margin-top: 0;
+ position: absolute;
+ bottom: -18px;
+ }
+ }
+ }
+ }
+
+ .#{$logic-diagram-prefix-cls}-action {
+ height: 100%;
+ display: flex;
+ align-items: center;
+ .#{$logic-diagram-prefix-cls}-add-rule-btn-icon,
+ .#{$logic-diagram-prefix-cls}-add-rule-group-btn-icon {
+ color: $color-brand1-6;
+ }
+ }
+
+ &:not(.#{$logic-diagram-prefix-cls}-disabled) {
+ .#{$logic-diagram-prefix-cls}-rule:hover {
+ background-color: $color-fill1-2;
+
+ .#{$logic-diagram-prefix-cls}-remove-action {
+ visibility: visible;
+ }
+ }
+ }
+}
diff --git a/packages/next/src/logic-diagram/style.ts b/packages/next/src/logic-diagram/style.ts
new file mode 100644
index 00000000000..516660f1fea
--- /dev/null
+++ b/packages/next/src/logic-diagram/style.ts
@@ -0,0 +1,4 @@
+import '@alifd/next/lib/button/style'
+import '@alifd/next/lib/balloon/style'
+import '@alifd/next/lib/icon/style'
+import './main.scss'
diff --git a/packages/next/src/style.ts b/packages/next/src/style.ts
index 4df57532983..7da99beaab4 100644
--- a/packages/next/src/style.ts
+++ b/packages/next/src/style.ts
@@ -28,3 +28,4 @@ import './form-grid/style'
import './form-step/style'
import './form-tab/style'
import './upload/style'
+import './logic-diagram/style'