Expression Editor

The expression editor is for editing a filter expression.

Install

Add the component to your project:

Import the component and the CSS:

Use

Properties

Expression Editor uses metadata types from @funnel-io/meld-types.

name type description required default
fields Metadata.Definitions All appropriate fields from account metadata true
groups Metadata.Groups All field groups from account metadata true
sources Metadata.Sources All sources from account metadata true
sourceTypes Metadata.SourceTypes All sources types from account metadata true
expression RootExpression | null A supported filter expression true
onChange (nextExpression: RootExpression | null ) => void Called when the expression changes true
isDisabledField (field:Definition) => { isDisabled:Boolean, disabledReason: string } Should the field be disabled and why true
toDisplayValue <T = string | number>(value: T, fieldId: string) => T; Format raw value for display false
fromDisplayValue <T = string | number>(value: T, fieldId: string) => T; Format input value for use false
getOperatorOptions (fieldId, unit, field?) => [Operators, string][] Restrict operators per field; defaults to built-in rules when omitted false
getValueConstraint (fieldId, field, operator) => ValueConstraint Restrict value input (fixed, number min/max, or default) false
getDefaultCondition (fieldId, field) => BaseExpression Initial operator/value when a field is selected false

Also exported from the package: defaultGetOperatorOptions, normalizeExpression, and related types.

Restricting metrics to “greater than zero”

Use composable callbacks so dimensions keep normal behavior while metrics are forced to { "=gt": 0 }. See the mixed-mode example below.

Examples

Selecting a data source type

Selecting a data source

Using a regex

Fetching dimension values async

Metrics greater than zero (mixed with dimensions)

Search Gunnel

Powered byAlgolia