{"version":3,"file":"schemas.mjs","names":[],"sources":["../../../../../src/data-grid/style-rules/internal/schemas.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 { z } from 'zod';\n\nimport {\n  BigintLiteralSchema,\n  DatetimeLiteralSchema,\n  LocalDatetimeLiteralSchema,\n  NumericLiteralSchema,\n  RangeLiteralSchema,\n  TimeLiteralSchema,\n} from '../../../_generated/style-rules/literal-schemas';\nimport type {\n  DataGridCellStyle,\n  DataGridColorRange,\n  DataGridColumnRef,\n  DataGridDisableableColor,\n  DataGridStyleRule,\n  DataGridStyleRuleLiteral,\n  DataGridStyleRuleOperand,\n  DataGridStyleRuleWhere,\n} from '../types';\n\n/*\n * Internal only. Do NOT re-export these schemas. They are only the runtime\n * backing for `isDataGridStyleRule`; the public contract is the hand-written\n * types in `../types.ts`. We should never export a Zod schema since it would\n * force consumers onto our Zod version.\n *\n * Every schema is anchored to its type with `satisfies` so editing one without\n * the other fails the build.\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 const DataGridStyleRuleLiteralSchema = z.union([\n  z.string(),\n  NumericLiteralSchema,\n  z.boolean(),\n  z.null(),\n  DatetimeLiteralSchema,\n  LocalDatetimeLiteralSchema,\n  TimeLiteralSchema,\n]) satisfies z.ZodType<DataGridStyleRuleLiteral>;\n\n/** A JSON-safe bigint literal represented by a signed decimal string. */\nexport const DataGridBigintLiteralSchema = BigintLiteralSchema;\n\n/** A number, native bigint, or JSON-safe bigint literal. */\nexport const DataGridNumericLiteralSchema = NumericLiteralSchema;\n\n/** A numeric, datetime, localdatetime, or time literal used as a range boundary. */\nexport const DataGridRangeLiteralSchema = RangeLiteralSchema;\n\n/** A reference to a column whose cell value is resolved at evaluation time. */\nexport const DataGridColumnRefSchema = z.object({\n  column: z.string(),\n}) satisfies z.ZodType<DataGridColumnRef>;\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 const DataGridDatetimeLiteralSchema = DatetimeLiteralSchema;\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 const DataGridLocalDatetimeLiteralSchema = LocalDatetimeLiteralSchema;\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 const DataGridTimeLiteralSchema = TimeLiteralSchema;\n\n/** An operand in a style-rule where clause -- either a literal value or a column reference. */\nexport const DataGridStyleRuleOperandSchema = z.union([\n  DataGridColumnRefSchema,\n  DataGridStyleRuleLiteralSchema,\n]) satisfies z.ZodType<DataGridStyleRuleOperand>;\n\nexport const DataGridStyleRuleWhereSchema: z.ZodType<DataGridStyleRuleWhere> =\n  z.lazy(() =>\n    z.union([\n      z.object({ not: DataGridStyleRuleWhereSchema }),\n      z.object({ and: z.array(DataGridStyleRuleWhereSchema) }),\n      z.object({ or: z.array(DataGridStyleRuleWhereSchema) }),\n      z.object({\n        equal: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({\n        lessThan: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({\n        lessThanOrEqual: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({\n        greaterThan: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({\n        greaterThanOrEqual: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({\n        contains: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({\n        startsWith: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({\n        endsWith: z.tuple([\n          DataGridStyleRuleOperandSchema,\n          DataGridStyleRuleOperandSchema,\n        ]),\n      }),\n      z.object({ isNull: DataGridStyleRuleOperandSchema }),\n    ]),\n  );\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 const DataGridColorRangeSchema = z.object({\n  /** Disable this color range without removing it. */\n  isDisabled: z.boolean().optional(),\n  /** Hex color (#rrggbb) at the maximum value. */\n  maxColor: z.string(),\n  /** The high end of the range. Values above this clamp to maxColor. */\n  maxValue: DataGridRangeLiteralSchema,\n  /** Hex color (#rrggbb) at the optional mid-point for a 3-stop gradient. */\n  midColor: z.string().optional(),\n  /** Optional inflection point between minValue and maxValue for a 3-stop gradient. */\n  midValue: DataGridRangeLiteralSchema.optional(),\n  /** Hex color (#rrggbb) at the minimum value. */\n  minColor: z.string(),\n  /** The low end of the range. Values below this clamp to minColor. */\n  minValue: DataGridRangeLiteralSchema,\n  /** The column whose orderable value drives the interpolation. */\n  onColumn: z.string(),\n}) satisfies z.ZodType<DataGridColorRange>;\n\n/** A disable-able static color value. */\nexport const DataGridDisableableColorSchema = z.object({\n  /** Disable this style without removing it. */\n  isDisabled: z.boolean().optional(),\n  /** The CSS color value (e.g. '#fee2e2'). */\n  value: z.string(),\n}) satisfies z.ZodType<DataGridDisableableColor>;\n\n/** Visual properties that a style rule can apply to a cell or row. */\nexport const DataGridCellStyleSchema = z.object({\n  /** CSS background color / cell fill (e.g. '#fee2e2'). Matches the graph `Style.color`. */\n  color: DataGridDisableableColorSchema.optional(),\n  /** Gradient color interpolation applied to the cell fill. Matches the graph `Style.colorRange`. */\n  colorRange: DataGridColorRangeSchema.optional(),\n  /** CSS text color (e.g. '#991b1b'). Grid-only; no graph equivalent. */\n  textColor: DataGridDisableableColorSchema.optional(),\n  /** Gradient color interpolation applied to the text color. Grid-only; no graph equivalent. */\n  textColorRange: DataGridColorRangeSchema.optional(),\n}) satisfies z.ZodType<DataGridCellStyle>;\n\n/**\n * metaData is an free-form object that can be used to store additional information about a style rule.\n * The data is not taken into account when evaluating the rule.\n */\nconst metaDataSchema = z.record(z.string(), z.unknown());\n\n/** A single declarative rule that conditionally applies styles to DataGrid cells. */\nexport const DataGridStyleRuleSchema = z.object({\n  /** Style properties to apply when the rule matches. */\n  apply: DataGridCellStyleSchema,\n  /** Which column this rule targets. Set to null to apply styles to all columns (row-level effect). */\n  column: z.string().nullable(),\n  /** Disable this rule without removing it. */\n  isDisabled: z.boolean().optional(),\n  /** Additional metadata about the rule. */\n  metaData: metaDataSchema.optional(),\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: z.number().nonnegative().optional(),\n  /** Condition to evaluate. If omitted, rule always applies to matched column(s). */\n  where: DataGridStyleRuleWhereSchema.optional(),\n}) satisfies z.ZodType<DataGridStyleRule>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,iCAAiC,EAAE,MAAM;CACpD,EAAE,OAAO;CACT;CACA,EAAE,QAAQ;CACV,EAAE,KAAK;CACP;CACA;CACA;AACF,CAAC;;AAGD,MAAa,8BAA8B;;AAG3C,MAAa,+BAA+B;;AAG5C,MAAa,6BAA6B;;AAG1C,MAAa,0BAA0B,EAAE,OAAO,EAC9C,QAAQ,EAAE,OAAO,EACnB,CAAC;;;;;;;;;;;;;AAcD,MAAa,gCAAgC;;;;;;;;;;;;;AAc7C,MAAa,qCAAqC;;;;;;;;AASlD,MAAa,4BAA4B;;AAGzC,MAAa,iCAAiC,EAAE,MAAM,CACpD,yBACA,8BACF,CAAC;AAED,MAAa,+BACX,EAAE,WACA,EAAE,MAAM;CACN,EAAE,OAAO,EAAE,KAAK,6BAA6B,CAAC;CAC9C,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,EAAE,CAAC;CACvD,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,EAAE,CAAC;CACtD,EAAE,OAAO,EACP,OAAO,EAAE,MAAM,CACb,g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