build69
build69  /  Components  /  ConditionBuilder /  Source

ConditionBuilder

Predicate builder: repeating rows of field / operator / value joined by and / or, with add and remove per row and one level of grouping (fb_3e0ed14a). The control behind "only send this automation when Department is HR and Status is not Draft". Rules are DATA - a JSON-serialisable ConditionRuleSet, controlled or uncontrolled - and ship with a dependency-free evaluator (evaluateConditionRuleSet) that runs the saved rule against a record, on the server if that is where the automation runs.

3 files2 dependenciestokens resolved ✓
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use client";

import * as React from "react";
import { cn } from "@/lib/utils";
import { surface, type Tone, type Emphasis } from "@/lib/recipes";

// ConditionBuilder — Predicate builder: repeating rows of field / operator / value joined by and / or, with a
export interface ConditionBuilderProps extends React.ComponentProps<"div"> {
  /** Semantic role: which accent the component uses. */
  tone?: Tone;
  /** Visual loudness: how prominent it reads. */
  emphasis?: Emphasis;
}

export function ConditionBuilder({
  className,
  tone = "primary",
  emphasis = "solid",
  ...props
}: ConditionBuilderProps) {
  return (
    <div
      data-slot="condition-builder"
      data-tone={tone}
      data-emphasis={emphasis}
      className={cn(
        "inline-flex items-center gap-2 rounded-lg transition-colors",
        surface(tone, emphasis),
        className,
      )}
      {...props}
    />
  );
}