/*! * * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] * * This file is part of Neo4j. * * Neo4j is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import type { BigintLiteral, DatetimeLiteral, LocalDatetimeLiteral, NumericLiteral, RangeLiteral, TimeLiteral } from '../../_generated/style-rules'; /** * A literal value used in style-rule where clauses, converter return values, * and cell data. Temporal wrappers resolve to numbers at evaluation time. */ export type DataGridStyleRuleLiteral = string | NumericLiteral | boolean | null | DatetimeLiteral | LocalDatetimeLiteral | TimeLiteral; /** A JSON-safe bigint literal represented by a signed decimal string. */ export type DataGridBigintLiteral = BigintLiteral; /** A number, native bigint, or JSON-safe bigint literal. */ export type DataGridNumericLiteral = NumericLiteral; /** A numeric, datetime, localdatetime, or time literal used as a range boundary. */ export type DataGridRangeLiteral = RangeLiteral; /** A reference to a column whose cell value is resolved at evaluation time. */ export type DataGridColumnRef = { column: string; }; /** * An ISO 8601 or RFC 9557 datetime literal that resolves to a Unix millisecond * timestamp at evaluation time. Wraps the shared `DatetimeLiteralSchema` with a * DataGrid-specific name. Supported formats: * - RFC 9557 with IANA timezone: `"2024-06-15T14:00:00[Europe/Stockholm]"` (offset * inferred) or `"2024-06-15T14:00:00+02:00[Europe/Stockholm]"` (offset explicit) * - UTC or offset datetime: `"2024-01-01T00:00:00Z"`, `"2024-01-01T00:00:00+02:00"` * - Plain datetime (treated as UTC): `"2024-01-01T14:30:00"` * - Date-only (treated as UTC midnight): `"2024-01-01"` * * Unzoned datetimes without `Z` or an offset are treated as UTC wall-clock time. */ export type DataGridDatetimeLiteral = DatetimeLiteral; /** * A plain (unzoned) ISO 8601 date or datetime literal that resolves to a Unix * millisecond timestamp in the browser's local timezone at evaluation time. * Wraps the shared `LocalDatetimeLiteralSchema` with a DataGrid-specific name. * * Only plain date/datetime strings without timezone qualifiers are accepted: * - Plain datetime: `"2024-01-01T14:30:00"` * - Date-only (treated as local midnight): `"2024-01-01"` * * Strings with `Z`, a UTC offset, or an IANA bracket are rejected — use * `{ datetime }` for timezone-aware instants. */ export type DataGridLocalDatetimeLiteral = LocalDatetimeLiteral; /** * An ISO 8601 time literal that resolves to milliseconds since UTC midnight at * evaluation time. Wraps the shared `TimeLiteralSchema` with a DataGrid-specific * name. Supported formats: * - Local time (treated as UTC): `"14:30:00"`, `"14:30:00.500"` * - Offset time (UTC-normalised): `"14:30:00+02:00"` */ export type DataGridTimeLiteral = TimeLiteral; /** An operand in a style-rule where clause -- either a literal value or a column reference. */ export type DataGridStyleRuleOperand = DataGridColumnRef | DataGridStyleRuleLiteral; /** * Recursive WHERE clause for conditional expressions. * Inspired by the graph visualization style rule system but adapted for tabular data. * * The type is manually defined for the export, since zod doesn't support * exporting inferred recursive types. */ export type DataGridStyleRuleWhere = { not: DataGridStyleRuleWhere; } | { and: DataGridStyleRuleWhere[]; } | { or: DataGridStyleRuleWhere[]; } | { equal: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { lessThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { lessThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { greaterThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { greaterThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { contains: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { startsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { endsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand]; } | { isNull: DataGridStyleRuleOperand; }; /** * Gradient coloring based on a continuous orderable column value. * Colors should be hex strings (#rrggbb). * Temporal range boundaries resolve to numbers before interpolation. * If the column value is missing or non-orderable, the colorRange is ignored. */ export type DataGridColorRange = { /** Disable this color range without removing it. */ isDisabled?: boolean | undefined; /** Hex color (#rrggbb) at the maximum value. */ maxColor: string; /** The high end of the range. Values above this clamp to maxColor. */ maxValue: DataGridRangeLiteral; /** Hex color (#rrggbb) at the optional mid-point for a 3-stop gradient. */ midColor?: string | undefined; /** Optional inflection point between minValue and maxValue for a 3-stop gradient. */ midValue?: DataGridRangeLiteral | undefined; /** Hex color (#rrggbb) at the minimum value. */ minColor: string; /** The low end of the range. Values below this clamp to minColor. */ minValue: DataGridRangeLiteral; /** The column whose orderable value drives the interpolation. */ onColumn: string; }; /** A disable-able static color value. */ export type DataGridDisableableColor = { /** Disable this style without removing it. */ isDisabled?: boolean | undefined; /** The CSS color value (e.g. '#fee2e2'). */ value: string; }; /** Visual properties that a style rule can apply to a cell or row. */ export type DataGridCellStyle = { /** CSS background color / cell fill (e.g. '#fee2e2'). Matches the graph `Style.color`. */ color?: DataGridDisableableColor | undefined; /** Gradient color interpolation applied to the cell fill. Matches the graph `Style.colorRange`. */ colorRange?: DataGridColorRange | undefined; /** CSS text color (e.g. '#991b1b'). Grid-only; no graph equivalent. */ textColor?: DataGridDisableableColor | undefined; /** Gradient color interpolation applied to the text color. Grid-only; no graph equivalent. */ textColorRange?: DataGridColorRange | undefined; }; /** * A function that converts a complex or non-scalar cell value into a * `DataGridStyleRuleLiteral` so it can participate in where-clause evaluation * and color-range interpolation. * * The function receives the raw cell value (`unknown`) and must return a scalar * (`string | number | bigint | { bigint: string } | boolean | null`) or a * temporal wrapper (`{ datetime: string }`, `{ localdatetime: string }`, * `{ time: string }`). The engine parses temporal wrappers to milliseconds. * Return `null` or `undefined` to signal that the value is missing or cannot * be represented. * * Note: converter functions are TypeScript-only — they cannot be serialized as * JSON, so no Zod schema is provided. */ export type DataGridStyleRuleValueConverter = (value: unknown) => DataGridStyleRuleLiteral | undefined; /** * A map of column id → converter function. * Pass this as the `styleRuleValueConverters` prop on `DataGrid` to teach the * style-rule engine how to interpret complex cell values for specific columns. * * @example * ```ts * const converters: DataGridStyleRuleValueConverters = { * priority: (v) => { * const s = v as { min: number; max: number }; * return s.max - s.min; * }, * }; * ``` */ export type DataGridStyleRuleValueConverters = Record; /** A single declarative rule that conditionally applies styles to DataGrid cells. */ export type DataGridStyleRule = { /** Style properties to apply when the rule matches. */ apply: DataGridCellStyle; /** Which column this rule targets. Set to null to apply styles to all columns (row-level effect). */ column: string | null; /** Disable this rule without removing it. */ isDisabled?: boolean | undefined; /** Additional metadata about the rule. */ metaData?: Record | undefined; /** Higher priority rules are applied later (override lower). Must be `>= 0`; negative values are reserved for internal use. Rules without explicit priority preserve their array order but are always applied before rules with explicit priority. */ priority?: number | undefined; /** Condition to evaluate. If omitted, rule always applies to matched column(s). */ where?: DataGridStyleRuleWhere | undefined; }; //# sourceMappingURL=types.d.ts.map