Brush Expressions

The brush is a global filter expression that widgets can read and update.

Hook Usage

import { useBrush } from "@ska-octopus-widget-sdk/widget-sdk";

const { expression, rule, matches, active, setBrush, clearBrush } = useBrush();

Operators

| Operator | Meaning | | —————————— | ——————————— | ———————— | | contains(a,b) or contains(a | b) | Value contains any token | | not_contains(...) | Value contains none of the tokens | | equals(a,b) | Value equals any token | | not_equals(...) | Value equals none of the tokens | | starts_with(token) | Value starts with token | | ends_with(token) | Value ends with token |

Tokens can be quoted with ', ", or `.

Examples:

contains('station_1')
not_contains(test|tmp)
equals(sensor_A,sensor_B)
starts_with('arr_')

Parser Utilities

import {
  parseBrush,
  makeMatcher,
  tokenize,
  parse,
  buildMatcher,
} from "@ska-octopus-widget-sdk/widget-sdk";

const rule = parseBrush(expression);
const matcher = makeMatcher(rule);

Use low level tokenize/parse/buildMatcher only when implementing custom brush builders or validation UIs.