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