import { AllNonCompoundPredicateOperators, PredicateCompoundOperator, PredicateOperator } from '@standardnotes/snjs' import { observer } from 'mobx-react-lite' import Button from '../Button/Button' import Icon from '../Icon/Icon' import { CompoundPredicateBuilderController } from './CompoundPredicateBuilderController' import { PredicateKeypath, PredicateKeypathLabels, PredicateKeypathTypes } from './PredicateKeypaths' import PredicateValue from './PredicateValue' import { c } from 'ttag' type Props = { controller: CompoundPredicateBuilderController } const CompoundPredicateBuilder = ({ controller }: Props) => { const { operator, setOperator, predicates, setPredicate, changePredicateKeypath, addPredicate, removePredicate } = controller return ( <>
{predicates.map((predicate, index) => (
{index !== 0 && (
{operator === 'and' ? c('B4.Notes.TagsLinkedItems.Label').t`AND` : c('B4.Notes.TagsLinkedItems.Label').t`OR`}
)} {PredicateKeypathTypes[predicate.keypath as PredicateKeypath] === 'tag' ? (
include
) : ( )} {predicate.keypath && ( { setPredicate(index, { value }) }} /> )} {index !== 0 && ( )}
{index === predicates.length - 1 && ( )}
))} {predicates.some((predicate) => PredicateKeypathTypes[predicate.keypath as PredicateKeypath] === 'date') && (
{c('B4.Notes.TagsLinkedItems.Label').t`Date Examples:`}
)} ) } export default observer(CompoundPredicateBuilder)