@neo4j-ndl/react-graph 2.0.21 → 2.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/cjs/_generated/style-rules/index.js +10 -1
  2. package/lib/cjs/_generated/style-rules/index.js.map +1 -1
  3. package/lib/cjs/_generated/style-rules/literal-schemas.js +16 -1
  4. package/lib/cjs/_generated/style-rules/literal-schemas.js.map +1 -1
  5. package/lib/cjs/_generated/style-rules/numeric-utils.js +163 -0
  6. package/lib/cjs/_generated/style-rules/numeric-utils.js.map +1 -0
  7. package/lib/cjs/index.js.map +1 -1
  8. package/lib/cjs/stories/graph-visualization-range-styling.story.js +35 -35
  9. package/lib/cjs/stories/graph-visualization-range-styling.story.js.map +1 -1
  10. package/lib/cjs/styling/compile-graph-styles.js +68 -22
  11. package/lib/cjs/styling/compile-graph-styles.js.map +1 -1
  12. package/lib/cjs/styling/style-types.js +21 -12
  13. package/lib/cjs/styling/style-types.js.map +1 -1
  14. package/lib/esm/_generated/style-rules/index.js +2 -1
  15. package/lib/esm/_generated/style-rules/index.js.map +1 -1
  16. package/lib/esm/_generated/style-rules/literal-schemas.js +15 -0
  17. package/lib/esm/_generated/style-rules/literal-schemas.js.map +1 -1
  18. package/lib/esm/_generated/style-rules/numeric-utils.js +155 -0
  19. package/lib/esm/_generated/style-rules/numeric-utils.js.map +1 -0
  20. package/lib/esm/index.js.map +1 -1
  21. package/lib/esm/stories/graph-visualization-range-styling.story.js +35 -35
  22. package/lib/esm/stories/graph-visualization-range-styling.story.js.map +1 -1
  23. package/lib/esm/styling/compile-graph-styles.js +69 -23
  24. package/lib/esm/styling/compile-graph-styles.js.map +1 -1
  25. package/lib/esm/styling/style-types.js +21 -12
  26. package/lib/esm/styling/style-types.js.map +1 -1
  27. package/lib/types/_generated/style-rules/index.d.ts +4 -2
  28. package/lib/types/_generated/style-rules/index.d.ts.map +1 -1
  29. package/lib/types/_generated/style-rules/literal-schemas.d.ts +13 -0
  30. package/lib/types/_generated/style-rules/literal-schemas.d.ts.map +1 -1
  31. package/lib/types/_generated/style-rules/numeric-utils.d.ts +45 -0
  32. package/lib/types/_generated/style-rules/numeric-utils.d.ts.map +1 -0
  33. package/lib/types/index.d.ts +1 -1
  34. package/lib/types/index.d.ts.map +1 -1
  35. package/lib/types/styling/compile-graph-styles.d.ts.map +1 -1
  36. package/lib/types/styling/style-types.d.ts +87 -26
  37. package/lib/types/styling/style-types.d.ts.map +1 -1
  38. package/package.json +3 -3
@@ -5,7 +5,7 @@
5
5
  * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.TimeLiteralSchema = exports.LocalDatetimeLiteralSchema = exports.DatetimeLiteralSchema = exports.parseTimeString = exports.parseLocalDateString = exports.parseDateString = exports.lerpColor = exports.getWeight = void 0;
8
+ exports.resolveNumericLiteral = exports.numericValuesEqual = exports.isBigintLiteral = exports.getNumericWeight = exports.compareNumericValues = exports.clampNumericValue = exports.TimeLiteralSchema = exports.NumericLiteralSchema = exports.LocalDatetimeLiteralSchema = exports.DatetimeLiteralSchema = exports.BigintLiteralSchema = exports.parseTimeString = exports.parseLocalDateString = exports.parseDateString = exports.lerpColor = exports.getWeight = void 0;
9
9
  /**
10
10
  *
11
11
  * Copyright (c) "Neo4j"
@@ -34,7 +34,16 @@ Object.defineProperty(exports, "parseDateString", { enumerable: true, get: funct
34
34
  Object.defineProperty(exports, "parseLocalDateString", { enumerable: true, get: function () { return date_utils_1.parseLocalDateString; } });
35
35
  Object.defineProperty(exports, "parseTimeString", { enumerable: true, get: function () { return date_utils_1.parseTimeString; } });
36
36
  var literal_schemas_1 = require("./literal-schemas");
37
+ Object.defineProperty(exports, "BigintLiteralSchema", { enumerable: true, get: function () { return literal_schemas_1.BigintLiteralSchema; } });
37
38
  Object.defineProperty(exports, "DatetimeLiteralSchema", { enumerable: true, get: function () { return literal_schemas_1.DatetimeLiteralSchema; } });
38
39
  Object.defineProperty(exports, "LocalDatetimeLiteralSchema", { enumerable: true, get: function () { return literal_schemas_1.LocalDatetimeLiteralSchema; } });
40
+ Object.defineProperty(exports, "NumericLiteralSchema", { enumerable: true, get: function () { return literal_schemas_1.NumericLiteralSchema; } });
39
41
  Object.defineProperty(exports, "TimeLiteralSchema", { enumerable: true, get: function () { return literal_schemas_1.TimeLiteralSchema; } });
42
+ var numeric_utils_1 = require("./numeric-utils");
43
+ Object.defineProperty(exports, "clampNumericValue", { enumerable: true, get: function () { return numeric_utils_1.clampNumericValue; } });
44
+ Object.defineProperty(exports, "compareNumericValues", { enumerable: true, get: function () { return numeric_utils_1.compareNumericValues; } });
45
+ Object.defineProperty(exports, "getNumericWeight", { enumerable: true, get: function () { return numeric_utils_1.getNumericWeight; } });
46
+ Object.defineProperty(exports, "isBigintLiteral", { enumerable: true, get: function () { return numeric_utils_1.isBigintLiteral; } });
47
+ Object.defineProperty(exports, "numericValuesEqual", { enumerable: true, get: function () { return numeric_utils_1.numericValuesEqual; } });
48
+ Object.defineProperty(exports, "resolveNumericLiteral", { enumerable: true, get: function () { return numeric_utils_1.resolveNumericLiteral; } });
40
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/_generated/style-rules/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,6CAAqD;AAA5C,wGAAA,SAAS,OAAA;AAAE,wGAAA,SAAS,OAAA;AAC7B,2CAIsB;AAHpB,6GAAA,eAAe,OAAA;AACf,kHAAA,oBAAoB,OAAA;AACpB,6GAAA,eAAe,OAAA;AAEjB,qDAI2B;AAHzB,wHAAA,qBAAqB,OAAA;AACrB,6HAAA,0BAA0B,OAAA;AAC1B,oHAAA,iBAAiB,OAAA","sourcesContent":["/*\n * AUTO-GENERATED FILE — DO NOT EDIT.\n * Source of truth: packages/style-rules/src/\n * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).\n */\n\n/**\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 */\nexport { getWeight, lerpColor } from './color-utils';\nexport {\n parseDateString,\n parseLocalDateString,\n parseTimeString,\n} from './date-utils';\nexport {\n DatetimeLiteralSchema,\n LocalDatetimeLiteralSchema,\n TimeLiteralSchema,\n} from './literal-schemas';\nexport type {\n DatetimeLiteral,\n LocalDatetimeLiteral,\n TimeLiteral,\n} from './literal-schemas';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/_generated/style-rules/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,6CAAqD;AAA5C,wGAAA,SAAS,OAAA;AAAE,wGAAA,SAAS,OAAA;AAC7B,2CAIsB;AAHpB,6GAAA,eAAe,OAAA;AACf,kHAAA,oBAAoB,OAAA;AACpB,6GAAA,eAAe,OAAA;AAEjB,qDAM2B;AALzB,sHAAA,mBAAmB,OAAA;AACnB,wHAAA,qBAAqB,OAAA;AACrB,6HAAA,0BAA0B,OAAA;AAC1B,uHAAA,oBAAoB,OAAA;AACpB,oHAAA,iBAAiB,OAAA;AASnB,iDAOyB;AANvB,kHAAA,iBAAiB,OAAA;AACjB,qHAAA,oBAAoB,OAAA;AACpB,iHAAA,gBAAgB,OAAA;AAChB,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,sHAAA,qBAAqB,OAAA","sourcesContent":["/*\n * AUTO-GENERATED FILE — DO NOT EDIT.\n * Source of truth: packages/style-rules/src/\n * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).\n */\n\n/**\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 */\nexport { getWeight, lerpColor } from './color-utils';\nexport {\n parseDateString,\n parseLocalDateString,\n parseTimeString,\n} from './date-utils';\nexport {\n BigintLiteralSchema,\n DatetimeLiteralSchema,\n LocalDatetimeLiteralSchema,\n NumericLiteralSchema,\n TimeLiteralSchema,\n} from './literal-schemas';\nexport type {\n BigintLiteral,\n DatetimeLiteral,\n LocalDatetimeLiteral,\n NumericLiteral,\n TimeLiteral,\n} from './literal-schemas';\nexport {\n clampNumericValue,\n compareNumericValues,\n getNumericWeight,\n isBigintLiteral,\n numericValuesEqual,\n resolveNumericLiteral,\n} from './numeric-utils';\nexport type { NumericValue } from './numeric-utils';\n"]}
@@ -5,7 +5,7 @@
5
5
  * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.TimeLiteralSchema = exports.LocalDatetimeLiteralSchema = exports.DatetimeLiteralSchema = void 0;
8
+ exports.TimeLiteralSchema = exports.LocalDatetimeLiteralSchema = exports.DatetimeLiteralSchema = exports.NumericLiteralSchema = exports.BigintLiteralSchema = void 0;
9
9
  /**
10
10
  *
11
11
  * Copyright (c) "Neo4j"
@@ -28,6 +28,21 @@ exports.TimeLiteralSchema = exports.LocalDatetimeLiteralSchema = exports.Datetim
28
28
  */
29
29
  const zod_1 = require("zod");
30
30
  const date_utils_1 = require("./date-utils");
31
+ /**
32
+ * A JSON-safe bigint literal. Native bigint values cannot be serialized as
33
+ * JSON, so persisted style rules can use a signed decimal string instead.
34
+ */
35
+ exports.BigintLiteralSchema = zod_1.z.object({
36
+ bigint: zod_1.z.string().regex(/^[+-]?\d+$/, {
37
+ message: 'bigint must be a signed decimal integer string',
38
+ }),
39
+ });
40
+ /** A numeric style-rule literal, including native and JSON-safe bigints. */
41
+ exports.NumericLiteralSchema = zod_1.z.union([
42
+ zod_1.z.number(),
43
+ zod_1.z.bigint(),
44
+ exports.BigintLiteralSchema,
45
+ ]);
31
46
  /**
32
47
  * An ISO 8601 or RFC 9557 datetime literal that resolves to a Unix millisecond
33
48
  * timestamp at evaluation time. Supported formats:
@@ -1 +1 @@
1
- {"version":3,"file":"literal-schemas.js","sourceRoot":"","sources":["../../../../src/_generated/style-rules/literal-schemas.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,6BAAwB;AAExB,6CAIsB;AAEtB;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAe,EAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QAC9D,OAAO,EACL,sEAAsE;KACzE,CAAC;CACH,CAAC,CAAC;AAGH;;;;;;;;;;;;GAYG;AACU,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,iCAAoB,EAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QACxE,OAAO,EACL,kGAAkG;KACrG,CAAC;CACH,CAAC,CAAC;AAGH;;;;;;;;;;;;GAYG;AACU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAe,EAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QAC1D,OAAO,EACL,iFAAiF;KACpF,CAAC;CACH,CAAC,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE — DO NOT EDIT.\n * Source of truth: packages/style-rules/src/\n * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).\n */\n\n/**\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 parseDateString,\n parseLocalDateString,\n parseTimeString,\n} from './date-utils';\n\n/**\n * An ISO 8601 or RFC 9557 datetime literal that resolves to a Unix millisecond\n * timestamp at evaluation time. Supported formats:\n * - RFC 9557 with IANA timezone: `\"2024-06-15T14:00:00[Europe/Stockholm]\"` (offset\n * inferred from the named zone, DST-aware) or `\"2024-06-15T14:00:00+02:00[Europe/Stockholm]\"`\n * (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\"`, `\"2024-01-01T14:30:00.500\"`\n * - Date-only (treated as UTC midnight): `\"2024-01-01\"`\n */\nexport const DatetimeLiteralSchema = z.object({\n datetime: z.string().refine((s) => parseDateString(s) !== null, {\n message:\n 'datetime must be a valid ISO 8601 / RFC 9557 date or datetime string',\n }),\n});\nexport type DatetimeLiteral = z.infer<typeof DatetimeLiteralSchema>;\n\n/**\n * A plain (unzoned) ISO 8601 date or datetime literal that resolves to a Unix\n * millisecond timestamp at evaluation time, interpreting the wall-clock time\n * in the browser's local timezone.\n *\n * Only plain date/datetime strings without timezone qualifiers are accepted:\n * - Plain datetime: `\"2024-01-01T14:30:00\"`, `\"2024-01-01T14:30:00.500\"`\n * - Date-only (treated as local midnight): `\"2024-01-01\"`\n *\n * Strings with `Z`, a UTC offset (`+02:00`), or an IANA bracket\n * (`[Europe/Stockholm]`) are **rejected** — use `{ datetime }` for\n * timezone-aware instants. This matches the semantics of Neo4j `LocalDateTime`.\n */\nexport const LocalDatetimeLiteralSchema = z.object({\n localdatetime: z.string().refine((s) => parseLocalDateString(s) !== null, {\n message:\n 'localdatetime must be a valid ISO 8601 plain date or datetime string (no Z, offset, or timezone)',\n }),\n});\nexport type LocalDatetimeLiteral = z.infer<typeof LocalDatetimeLiteralSchema>;\n\n/**\n * An ISO 8601 time literal that resolves to milliseconds since UTC midnight\n * at evaluation time. Supported formats:\n * - Local time (treated as UTC): `\"14:30:00\"`, `\"14:30:00.500\"`\n * - UTC time: `\"14:30:00Z\"` — identical to local form\n * - Offset time (UTC-normalised): `\"14:30:00+02:00\"` → 45,000,000 ms (12:30 UTC)\n *\n * IANA timezone brackets (e.g. `[Europe/Stockholm]`) are **not** accepted — a\n * time-of-day value has no calendar date so DST cannot be resolved. Use\n * `{ datetime }` literals for timezone-aware instants.\n *\n * Full datetime strings (containing `T`) are rejected.\n */\nexport const TimeLiteralSchema = z.object({\n time: z.string().refine((s) => parseTimeString(s) !== null, {\n message:\n 'time must be a valid ISO 8601 time string (e.g. \"14:30:00\" or \"14:30:00+02:00\")',\n }),\n});\nexport type TimeLiteral = z.infer<typeof TimeLiteralSchema>;\n"]}
1
+ {"version":3,"file":"literal-schemas.js","sourceRoot":"","sources":["../../../../src/_generated/style-rules/literal-schemas.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,6BAAwB;AAExB,6CAIsB;AAEtB;;;GAGG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE;QACrC,OAAO,EAAE,gDAAgD;KAC1D,CAAC;CACH,CAAC,CAAC;AAGH,4EAA4E;AAC/D,QAAA,oBAAoB,GAAG,OAAC,CAAC,KAAK,CAAC;IAC1C,OAAC,CAAC,MAAM,EAAE;IACV,OAAC,CAAC,MAAM,EAAE;IACV,2BAAmB;CACpB,CAAC,CAAC;AAGH;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAe,EAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QAC9D,OAAO,EACL,sEAAsE;KACzE,CAAC;CACH,CAAC,CAAC;AAGH;;;;;;;;;;;;GAYG;AACU,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,iCAAoB,EAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QACxE,OAAO,EACL,kGAAkG;KACrG,CAAC;CACH,CAAC,CAAC;AAGH;;;;;;;;;;;;GAYG;AACU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAe,EAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QAC1D,OAAO,EACL,iFAAiF;KACpF,CAAC;CACH,CAAC,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE — DO NOT EDIT.\n * Source of truth: packages/style-rules/src/\n * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).\n */\n\n/**\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 parseDateString,\n parseLocalDateString,\n parseTimeString,\n} from './date-utils';\n\n/**\n * A JSON-safe bigint literal. Native bigint values cannot be serialized as\n * JSON, so persisted style rules can use a signed decimal string instead.\n */\nexport const BigintLiteralSchema = z.object({\n bigint: z.string().regex(/^[+-]?\\d+$/, {\n message: 'bigint must be a signed decimal integer string',\n }),\n});\nexport type BigintLiteral = z.infer<typeof BigintLiteralSchema>;\n\n/** A numeric style-rule literal, including native and JSON-safe bigints. */\nexport const NumericLiteralSchema = z.union([\n z.number(),\n z.bigint(),\n BigintLiteralSchema,\n]);\nexport type NumericLiteral = z.infer<typeof NumericLiteralSchema>;\n\n/**\n * An ISO 8601 or RFC 9557 datetime literal that resolves to a Unix millisecond\n * timestamp at evaluation time. Supported formats:\n * - RFC 9557 with IANA timezone: `\"2024-06-15T14:00:00[Europe/Stockholm]\"` (offset\n * inferred from the named zone, DST-aware) or `\"2024-06-15T14:00:00+02:00[Europe/Stockholm]\"`\n * (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\"`, `\"2024-01-01T14:30:00.500\"`\n * - Date-only (treated as UTC midnight): `\"2024-01-01\"`\n */\nexport const DatetimeLiteralSchema = z.object({\n datetime: z.string().refine((s) => parseDateString(s) !== null, {\n message:\n 'datetime must be a valid ISO 8601 / RFC 9557 date or datetime string',\n }),\n});\nexport type DatetimeLiteral = z.infer<typeof DatetimeLiteralSchema>;\n\n/**\n * A plain (unzoned) ISO 8601 date or datetime literal that resolves to a Unix\n * millisecond timestamp at evaluation time, interpreting the wall-clock time\n * in the browser's local timezone.\n *\n * Only plain date/datetime strings without timezone qualifiers are accepted:\n * - Plain datetime: `\"2024-01-01T14:30:00\"`, `\"2024-01-01T14:30:00.500\"`\n * - Date-only (treated as local midnight): `\"2024-01-01\"`\n *\n * Strings with `Z`, a UTC offset (`+02:00`), or an IANA bracket\n * (`[Europe/Stockholm]`) are **rejected** — use `{ datetime }` for\n * timezone-aware instants. This matches the semantics of Neo4j `LocalDateTime`.\n */\nexport const LocalDatetimeLiteralSchema = z.object({\n localdatetime: z.string().refine((s) => parseLocalDateString(s) !== null, {\n message:\n 'localdatetime must be a valid ISO 8601 plain date or datetime string (no Z, offset, or timezone)',\n }),\n});\nexport type LocalDatetimeLiteral = z.infer<typeof LocalDatetimeLiteralSchema>;\n\n/**\n * An ISO 8601 time literal that resolves to milliseconds since UTC midnight\n * at evaluation time. Supported formats:\n * - Local time (treated as UTC): `\"14:30:00\"`, `\"14:30:00.500\"`\n * - UTC time: `\"14:30:00Z\"` — identical to local form\n * - Offset time (UTC-normalised): `\"14:30:00+02:00\"` → 45,000,000 ms (12:30 UTC)\n *\n * IANA timezone brackets (e.g. `[Europe/Stockholm]`) are **not** accepted — a\n * time-of-day value has no calendar date so DST cannot be resolved. Use\n * `{ datetime }` literals for timezone-aware instants.\n *\n * Full datetime strings (containing `T`) are rejected.\n */\nexport const TimeLiteralSchema = z.object({\n time: z.string().refine((s) => parseTimeString(s) !== null, {\n message:\n 'time must be a valid ISO 8601 time string (e.g. \"14:30:00\" or \"14:30:00+02:00\")',\n }),\n});\nexport type TimeLiteral = z.infer<typeof TimeLiteralSchema>;\n"]}
@@ -0,0 +1,163 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+ "use strict";
23
+ /*
24
+ * AUTO-GENERATED FILE — DO NOT EDIT.
25
+ * Source of truth: packages/style-rules/src/
26
+ * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.resolveNumericLiteral = resolveNumericLiteral;
30
+ exports.isBigintLiteral = isBigintLiteral;
31
+ exports.compareNumericValues = compareNumericValues;
32
+ exports.numericValuesEqual = numericValuesEqual;
33
+ exports.clampNumericValue = clampNumericValue;
34
+ exports.getNumericWeight = getNumericWeight;
35
+ const BIGINT_ZERO = BigInt(0);
36
+ const BIGINT_ONE = BigInt(1);
37
+ const BIGINT_TWO = BigInt(2);
38
+ const BIGINT_RATIO_SCALE = BigInt('1000000000000000000');
39
+ function bigintPowerOfTen(exponent) {
40
+ return BigInt(`1${'0'.repeat(exponent)}`);
41
+ }
42
+ /** Resolves a native or JSON-safe numeric literal without reducing bigints. */
43
+ function resolveNumericLiteral(value) {
44
+ return typeof value === 'object' ? BigInt(value.bigint) : value;
45
+ }
46
+ /** Returns whether a value is the JSON-safe bigint literal shape. */
47
+ function isBigintLiteral(value) {
48
+ return (typeof value === 'object' &&
49
+ value !== null &&
50
+ 'bigint' in value &&
51
+ typeof value.bigint === 'string' &&
52
+ /^[+-]?\d+$/.test(value.bigint));
53
+ }
54
+ /**
55
+ * Compares numeric values without coercing bigint operands to number.
56
+ * Returns null for NaN, otherwise -1, 0, or 1.
57
+ */
58
+ function compareNumericValues(left, right) {
59
+ if ((typeof left === 'number' && Number.isNaN(left)) ||
60
+ (typeof right === 'number' && Number.isNaN(right))) {
61
+ return null;
62
+ }
63
+ if (left < right) {
64
+ return -1;
65
+ }
66
+ if (left > right) {
67
+ return 1;
68
+ }
69
+ return 0;
70
+ }
71
+ /** Numeric equality that treats equivalent number and bigint values as equal. */
72
+ function numericValuesEqual(left, right) {
73
+ return compareNumericValues(left, right) === 0;
74
+ }
75
+ /**
76
+ * Clamps a numeric value between two endpoints. Inverted endpoints are
77
+ * supported, and the original number/bigint representation is retained.
78
+ */
79
+ function clampNumericValue(value, firstBound, secondBound) {
80
+ const boundsOrder = compareNumericValues(firstBound, secondBound);
81
+ if (boundsOrder === null) {
82
+ return null;
83
+ }
84
+ const min = boundsOrder <= 0 ? firstBound : secondBound;
85
+ const max = boundsOrder <= 0 ? secondBound : firstBound;
86
+ const minOrder = compareNumericValues(value, min);
87
+ const maxOrder = compareNumericValues(value, max);
88
+ if (minOrder === null || maxOrder === null) {
89
+ return null;
90
+ }
91
+ if (minOrder < 0) {
92
+ return min;
93
+ }
94
+ if (maxOrder > 0) {
95
+ return max;
96
+ }
97
+ return value;
98
+ }
99
+ function numberToRational(value) {
100
+ if (!Number.isFinite(value)) {
101
+ return null;
102
+ }
103
+ const match = /^([+-]?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/i.exec(value.toString());
104
+ if (!match) {
105
+ return null;
106
+ }
107
+ const [, sign, integer, fraction = '', exponentText = '0'] = match;
108
+ const exponent = Number(exponentText) - fraction.length;
109
+ const digits = BigInt(`${sign}${integer}${fraction}`);
110
+ if (exponent >= 0) {
111
+ return {
112
+ denominator: BIGINT_ONE,
113
+ numerator: digits * bigintPowerOfTen(exponent),
114
+ };
115
+ }
116
+ return {
117
+ denominator: bigintPowerOfTen(-exponent),
118
+ numerator: digits,
119
+ };
120
+ }
121
+ function toRational(value) {
122
+ return typeof value === 'bigint'
123
+ ? { denominator: BIGINT_ONE, numerator: value }
124
+ : numberToRational(value);
125
+ }
126
+ function divideBigints(numerator, denominator) {
127
+ if (denominator === BIGINT_ZERO) {
128
+ return null;
129
+ }
130
+ const isNegative = numerator < BIGINT_ZERO !== denominator < BIGINT_ZERO;
131
+ const absoluteNumerator = numerator < BIGINT_ZERO ? -numerator : numerator;
132
+ const absoluteDenominator = denominator < BIGINT_ZERO ? -denominator : denominator;
133
+ const integer = absoluteNumerator / absoluteDenominator;
134
+ const remainder = absoluteNumerator % absoluteDenominator;
135
+ const fraction = (remainder * BIGINT_RATIO_SCALE + absoluteDenominator / BIGINT_TWO) /
136
+ absoluteDenominator;
137
+ const result = Number(integer) + Number(fraction) / Number(BIGINT_RATIO_SCALE);
138
+ return isNegative ? -result : result;
139
+ }
140
+ /**
141
+ * Computes `(value - startValue) / (endValue - startValue)` while retaining
142
+ * bigint precision. Only the final dimensionless interpolation weight is
143
+ * converted to number.
144
+ */
145
+ function getNumericWeight(startValue, endValue, value) {
146
+ if (typeof startValue === 'number' &&
147
+ typeof endValue === 'number' &&
148
+ typeof value === 'number') {
149
+ const weight = (value - startValue) / (endValue - startValue);
150
+ return Number.isNaN(weight) ? null : weight;
151
+ }
152
+ const start = toRational(startValue);
153
+ const end = toRational(endValue);
154
+ const current = toRational(value);
155
+ if (start === null || end === null || current === null) {
156
+ return null;
157
+ }
158
+ const valueDelta = current.numerator * start.denominator -
159
+ start.numerator * current.denominator;
160
+ const rangeDelta = end.numerator * start.denominator - start.numerator * end.denominator;
161
+ return divideBigints(valueDelta * end.denominator, current.denominator * rangeDelta);
162
+ }
163
+ //# sourceMappingURL=numeric-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-utils.js","sourceRoot":"","sources":["../../../../src/_generated/style-rules/numeric-utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AA0CH,sDAEC;AAGD,0CAQC;AAMD,oDAiBC;AAGD,gDAKC;AAMD,8CAuBC;AA4DD,4CA+BC;AA9KD,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7B,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7B,MAAM,kBAAkB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAEzD,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,+EAA+E;AAC/E,SAAgB,qBAAqB,CAAC,KAAqB;IACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClE,CAAC;AAED,qEAAqE;AACrE,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,QAAQ,IAAI,KAAK;QACjB,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;QAChC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAChC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,IAAkB,EAClB,KAAmB;IAEnB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AG,UAAU,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GACd,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,WAAW;QACrC,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IACxC,MAAM,UAAU,GACd,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC;IAExE,OAAO,aAAa,CAClB,UAAU,GAAG,GAAG,CAAC,WAAW,EAC5B,OAAO,CAAC,WAAW,GAAG,UAAU,CACjC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE — DO NOT EDIT.\n * Source of truth: packages/style-rules/src/\n * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).\n */\n\n/**\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 { BigintLiteral, NumericLiteral } from './literal-schemas';\n\nexport type NumericValue = number | bigint;\n\ntype Rational = {\n denominator: bigint;\n numerator: bigint;\n};\n\nconst BIGINT_ZERO = BigInt(0);\nconst BIGINT_ONE = BigInt(1);\nconst BIGINT_TWO = BigInt(2);\nconst BIGINT_RATIO_SCALE = BigInt('1000000000000000000');\n\nfunction bigintPowerOfTen(exponent: number): bigint {\n return BigInt(`1${'0'.repeat(exponent)}`);\n}\n\n/** Resolves a native or JSON-safe numeric literal without reducing bigints. */\nexport function resolveNumericLiteral(value: NumericLiteral): NumericValue {\n return typeof value === 'object' ? BigInt(value.bigint) : value;\n}\n\n/** Returns whether a value is the JSON-safe bigint literal shape. */\nexport function isBigintLiteral(value: unknown): value is BigintLiteral {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'bigint' in value &&\n typeof value.bigint === 'string' &&\n /^[+-]?\\d+$/.test(value.bigint)\n );\n}\n\n/**\n * Compares numeric values without coercing bigint operands to number.\n * Returns null for NaN, otherwise -1, 0, or 1.\n */\nexport function compareNumericValues(\n left: NumericValue,\n right: NumericValue,\n): -1 | 0 | 1 | null {\n if (\n (typeof left === 'number' && Number.isNaN(left)) ||\n (typeof right === 'number' && Number.isNaN(right))\n ) {\n return null;\n }\n if (left < right) {\n return -1;\n }\n if (left > right) {\n return 1;\n }\n return 0;\n}\n\n/** Numeric equality that treats equivalent number and bigint values as equal. */\nexport function numericValuesEqual(\n left: NumericValue,\n right: NumericValue,\n): boolean {\n return compareNumericValues(left, right) === 0;\n}\n\n/**\n * Clamps a numeric value between two endpoints. Inverted endpoints are\n * supported, and the original number/bigint representation is retained.\n */\nexport function clampNumericValue(\n value: NumericValue,\n firstBound: NumericValue,\n secondBound: NumericValue,\n): NumericValue | null {\n const boundsOrder = compareNumericValues(firstBound, secondBound);\n if (boundsOrder === null) {\n return null;\n }\n const min = boundsOrder <= 0 ? firstBound : secondBound;\n const max = boundsOrder <= 0 ? secondBound : firstBound;\n const minOrder = compareNumericValues(value, min);\n const maxOrder = compareNumericValues(value, max);\n if (minOrder === null || maxOrder === null) {\n return null;\n }\n if (minOrder < 0) {\n return min;\n }\n if (maxOrder > 0) {\n return max;\n }\n return value;\n}\n\nfunction numberToRational(value: number): Rational | null {\n if (!Number.isFinite(value)) {\n return null;\n }\n\n const match = /^([+-]?)(\\d+)(?:\\.(\\d+))?(?:e([+-]?\\d+))?$/i.exec(\n value.toString(),\n );\n if (!match) {\n return null;\n }\n\n const [, sign, integer, fraction = '', exponentText = '0'] = match;\n const exponent = Number(exponentText) - fraction.length;\n const digits = BigInt(`${sign}${integer}${fraction}`);\n if (exponent >= 0) {\n return {\n denominator: BIGINT_ONE,\n numerator: digits * bigintPowerOfTen(exponent),\n };\n }\n return {\n denominator: bigintPowerOfTen(-exponent),\n numerator: digits,\n };\n}\n\nfunction toRational(value: NumericValue): Rational | null {\n return typeof value === 'bigint'\n ? { denominator: BIGINT_ONE, numerator: value }\n : numberToRational(value);\n}\n\nfunction divideBigints(numerator: bigint, denominator: bigint): number | null {\n if (denominator === BIGINT_ZERO) {\n return null;\n }\n\n const isNegative = numerator < BIGINT_ZERO !== denominator < BIGINT_ZERO;\n const absoluteNumerator = numerator < BIGINT_ZERO ? -numerator : numerator;\n const absoluteDenominator =\n denominator < BIGINT_ZERO ? -denominator : denominator;\n const integer = absoluteNumerator / absoluteDenominator;\n const remainder = absoluteNumerator % absoluteDenominator;\n const fraction =\n (remainder * BIGINT_RATIO_SCALE + absoluteDenominator / BIGINT_TWO) /\n absoluteDenominator;\n const result =\n Number(integer) + Number(fraction) / Number(BIGINT_RATIO_SCALE);\n\n return isNegative ? -result : result;\n}\n\n/**\n * Computes `(value - startValue) / (endValue - startValue)` while retaining\n * bigint precision. Only the final dimensionless interpolation weight is\n * converted to number.\n */\nexport function getNumericWeight(\n startValue: NumericValue,\n endValue: NumericValue,\n value: NumericValue,\n): number | null {\n if (\n typeof startValue === 'number' &&\n typeof endValue === 'number' &&\n typeof value === 'number'\n ) {\n const weight = (value - startValue) / (endValue - startValue);\n return Number.isNaN(weight) ? null : weight;\n }\n\n const start = toRational(startValue);\n const end = toRational(endValue);\n const current = toRational(value);\n if (start === null || end === null || current === null) {\n return null;\n }\n\n const valueDelta =\n current.numerator * start.denominator -\n start.numerator * current.denominator;\n const rangeDelta =\n end.numerator * start.denominator - start.numerator * end.denominator;\n\n return divideBigints(\n valueDelta * end.denominator,\n current.denominator * rangeDelta,\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA;AAC3B,6EAgBuC;AAfrC,2IAAA,4BAA4B,OAAA;AAgB9B,qDAAyD;AAAhD,+GAAA,gBAAgB,OAAA;AAkBzB,uEAAwE;AAA/D,8HAAA,sBAAsB,OAAA;AAC/B,iEAA8D;AAArD,oHAAA,eAAe,OAAA","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\nexport { GraphVisualization } from './graph-visualization';\nexport {\n useGraphVisualizationContext,\n type ColorCount,\n type Gesture,\n type GraphItemMetaData,\n type GraphSelection,\n type GraphVisualizationContextData,\n type InteractionMode,\n type MetadataLookupTable,\n type NeoNode,\n type NeoRel,\n type NodeData,\n type NvlGraph,\n type PortableProperty,\n type RelData,\n type Sidepanel,\n} from './graph-visualization-context';\nexport { isGraphStyleRule } from './styling/style-types';\nexport type {\n GraphStyleRule,\n Style as GraphStyle,\n Where as GraphWhere,\n Value as GraphValue,\n CypherValue as GraphCypherValue,\n Caption as GraphCaption,\n CaptionValue as GraphCaptionValue,\n CaptionVariation as GraphCaptionVariation,\n ColorRange as GraphColorRange,\n SizeRange as GraphSizeRange,\n WidthRange as GraphWidthRange,\n UniqueColors as GraphUniqueColors,\n DatetimeLiteral as GraphDatetimeLiteral,\n LocalDatetimeLiteral as GraphLocalDatetimeLiteral,\n TimeLiteral as GraphTimeLiteral,\n} from './styling/style-types';\nexport { compileGraphStyleRules } from './styling/compile-graph-styles';\nexport { parseStyleRules } from './styling/parse-style-rules';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA;AAC3B,6EAgBuC;AAfrC,2IAAA,4BAA4B,OAAA;AAgB9B,qDAAyD;AAAhD,+GAAA,gBAAgB,OAAA;AAoBzB,uEAAwE;AAA/D,8HAAA,sBAAsB,OAAA;AAC/B,iEAA8D;AAArD,oHAAA,eAAe,OAAA","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\nexport { GraphVisualization } from './graph-visualization';\nexport {\n useGraphVisualizationContext,\n type ColorCount,\n type Gesture,\n type GraphItemMetaData,\n type GraphSelection,\n type GraphVisualizationContextData,\n type InteractionMode,\n type MetadataLookupTable,\n type NeoNode,\n type NeoRel,\n type NodeData,\n type NvlGraph,\n type PortableProperty,\n type RelData,\n type Sidepanel,\n} from './graph-visualization-context';\nexport { isGraphStyleRule } from './styling/style-types';\nexport type {\n GraphStyleRule,\n GraphBigintLiteral,\n GraphNumericLiteral,\n Style as GraphStyle,\n Where as GraphWhere,\n Value as GraphValue,\n CypherValue as GraphCypherValue,\n Caption as GraphCaption,\n CaptionValue as GraphCaptionValue,\n CaptionVariation as GraphCaptionVariation,\n ColorRange as GraphColorRange,\n SizeRange as GraphSizeRange,\n WidthRange as GraphWidthRange,\n UniqueColors as GraphUniqueColors,\n DatetimeLiteral as GraphDatetimeLiteral,\n LocalDatetimeLiteral as GraphLocalDatetimeLiteral,\n TimeLiteral as GraphTimeLiteral,\n} from './styling/style-types';\nexport { compileGraphStyleRules } from './styling/compile-graph-styles';\nexport { parseStyleRules } from './styling/parse-style-rules';\n"]}
@@ -26,67 +26,67 @@ const graph_visualization_1 = require("../graph-visualization");
26
26
  const story_data_1 = require("./story-data");
27
27
  const pokemonRules = [
28
28
  {
29
- match: { label: 'Pokemon' },
30
29
  apply: {
30
+ captions: {
31
+ text: [
32
+ { styles: ['bold'], value: { property: 'name' } },
33
+ { styles: [], value: ' Lv' },
34
+ { styles: [], value: { property: 'level' } },
35
+ ],
36
+ },
31
37
  colorRange: {
32
- onProperty: 'level',
33
- minValue: 1,
34
- minColor: '#3498db',
35
- midValue: 45,
36
- midColor: '#f1c40f',
37
- maxValue: 88,
38
38
  maxColor: '#e74c3c',
39
+ maxValue: 88,
40
+ midColor: '#f1c40f',
41
+ midValue: 45,
42
+ minColor: '#3498db',
43
+ minValue: 1,
44
+ onProperty: 'level',
39
45
  },
40
46
  sizeRange: {
41
- onProperty: 'level',
42
- minValue: 1,
47
+ maxSize: 50,
43
48
  maxValue: 88,
44
49
  minSize: 20,
45
- maxSize: 50,
46
- },
47
- captions: {
48
- text: [
49
- { value: { property: 'name' }, styles: ['bold'] },
50
- { value: ' Lv', styles: [] },
51
- { value: { property: 'level' }, styles: [] },
52
- ],
50
+ minValue: 1,
51
+ onProperty: 'level',
53
52
  },
54
53
  },
54
+ match: { label: 'Pokemon' },
55
55
  },
56
56
  ];
57
57
  const caughtRelRules = [
58
58
  {
59
- match: { reltype: 'CAUGHT' },
60
59
  apply: {
60
+ captions: {
61
+ size: 1.5,
62
+ text: [
63
+ { styles: [], value: 'Caught @ Lv' },
64
+ { styles: ['bold'], value: { property: 'level' } },
65
+ ],
66
+ },
61
67
  colorRange: {
62
- onProperty: 'level',
63
- minValue: 1,
64
- minColor: '#00d2ff',
65
- maxValue: 40,
66
68
  maxColor: '#ff2d78',
69
+ maxValue: 40,
70
+ minColor: '#00d2ff',
71
+ minValue: 1,
72
+ onProperty: 'level',
67
73
  },
68
74
  width: { value: 4 },
69
75
  widthRange: {
70
- onProperty: 'level',
71
- minValue: 1,
72
76
  maxValue: 40,
73
- minWidth: 1,
74
77
  maxWidth: 8,
75
- },
76
- captions: {
77
- text: [
78
- { value: 'Caught @ Lv', styles: [] },
79
- { value: { property: 'level' }, styles: ['bold'] },
80
- ],
81
- size: 1.5,
78
+ minValue: 1,
79
+ minWidth: 1,
80
+ onProperty: 'level',
82
81
  },
83
82
  },
83
+ match: { reltype: 'CAUGHT' },
84
84
  },
85
85
  ];
86
86
  const otherNodeRules = [
87
- { match: { label: 'Trainer' }, apply: { color: { value: '#95a5a6' } } },
88
- { match: { label: 'Type' }, apply: { color: { value: '#bdc3c7' } } },
89
- { match: { label: 'Gym' }, apply: { color: { value: '#bdc3c7' } } },
87
+ { apply: { color: { value: '#95a5a6' } }, match: { label: 'Trainer' } },
88
+ { apply: { color: { value: '#bdc3c7' } }, match: { label: 'Type' } },
89
+ { apply: { color: { value: '#bdc3c7' } }, match: { label: 'Gym' } },
90
90
  ];
91
91
  exports.colorRangeStyleRules = [
92
92
  ...pokemonRules,
@@ -1 +1 @@
1
- {"version":3,"file":"graph-visualization-range-styling.story.js","sourceRoot":"","sources":["../../../src/stories/graph-visualization-range-styling.story.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;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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 { GraphVisualization } from '../graph-visualization';\nimport { type GraphStyleRule } from '../styling/style-types';\nimport { advancedStoryGraph, containerClasses } from './story-data';\n\nconst pokemonRules: GraphStyleRule[] = [\n {\n match: { label: 'Pokemon' },\n apply: {\n colorRange: {\n onProperty: 'level',\n minValue: 1,\n minColor: '#3498db',\n midValue: 45,\n midColor: '#f1c40f',\n maxValue: 88,\n maxColor: '#e74c3c',\n },\n sizeRange: {\n onProperty: 'level',\n minValue: 1,\n maxValue: 88,\n minSize: 20,\n maxSize: 50,\n },\n captions: {\n text: [\n { value: { property: 'name' }, styles: ['bold'] },\n { value: ' Lv', styles: [] },\n { value: { property: 'level' }, styles: [] },\n ],\n },\n },\n },\n];\n\nconst caughtRelRules: GraphStyleRule[] = [\n {\n match: { reltype: 'CAUGHT' },\n apply: {\n colorRange: {\n onProperty: 'level',\n minValue: 1,\n minColor: '#00d2ff',\n maxValue: 40,\n maxColor: '#ff2d78',\n },\n width: { value: 4 },\n widthRange: {\n onProperty: 'level',\n minValue: 1,\n maxValue: 40,\n minWidth: 1,\n maxWidth: 8,\n },\n captions: {\n text: [\n { value: 'Caught @ Lv', styles: [] },\n { value: { property: 'level' }, styles: ['bold'] },\n ],\n size: 1.5,\n },\n },\n },\n];\n\nconst otherNodeRules: GraphStyleRule[] = [\n { match: { label: 'Trainer' }, apply: { color: { value: '#95a5a6' } } },\n { match: { label: 'Type' }, apply: { color: { value: '#bdc3c7' } } },\n { match: { label: 'Gym' }, apply: { color: { value: '#bdc3c7' } } },\n];\n\nexport const colorRangeStyleRules: GraphStyleRule[] = [\n ...pokemonRules,\n ...caughtRelRules,\n ...otherNodeRules,\n];\n\nconst Component = () => {\n return (\n <div style={{ height: '600px' }}>\n <GraphVisualization\n nodes={advancedStoryGraph.nodes}\n rels={advancedStoryGraph.rels}\n className={containerClasses}\n styleRules={colorRangeStyleRules}\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"graph-visualization-range-styling.story.js","sourceRoot":"","sources":["../../../src/stories/graph-visualization-range-styling.story.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gEAA4D;AAE5D,6CAAoE;AAEpE,MAAM,YAAY,GAAqB;IACrC;QACE,KAAK,EAAE;YACL,QAAQ,EAAE;gBACR,IAAI,EAAE;oBACJ,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;oBACjD,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;oBAC5B,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;iBAC7C;aACF;YACD,UAAU,EAAE;gBACV,QAAQ,EAAE,SAAS;gBACnB,QAAQ,EAAE,EAAE;gBACZ,QAAQ,EAAE,SAAS;gBACnB,QAAQ,EAAE,EAAE;gBACZ,QAAQ,EAAE,SAAS;gBACnB,QAAQ,EAAE,CAAC;gBACX,UAAU,EAAE,OAAO;aACpB;YACD,SAAS,EAAE;gBACT,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;gBACZ,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,CAAC;gBACX,UAAU,EAAE,OAAO;aACpB;SACF;QACD,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;KAC5B;CACF,CAAC;AAEF,MAAM,cAAc,GAAqB;IACvC;QACE,KAAK,EAAE;YACL,QAAQ,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,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAC7B,uBAAC,wCAAkB,IACjB,KAAK,EAAE,+BAAkB,CAAC,KAAK,EAC/B,IAAI,EAAE,+BAAkB,CAAC,IAAI,EAC7B,SAAS,EAAE,6BAAgB,EAC3B,UAAU,EAAE,4BAAoB,GAChC,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","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 { GraphVisualization } from '../graph-visualization';\nimport { type GraphStyleRule } from '../styling/style-types';\nimport { advancedStoryGraph, containerClasses } from './story-data';\n\nconst pokemonRules: GraphStyleRule[] = [\n {\n apply: {\n captions: {\n text: [\n { styles: ['bold'], value: { property: 'name' } },\n { styles: [], value: ' Lv' },\n { styles: [], value: { property: 'level' } },\n ],\n },\n colorRange: {\n maxColor: '#e74c3c',\n maxValue: 88,\n midColor: '#f1c40f',\n midValue: 45,\n minColor: '#3498db',\n minValue: 1,\n onProperty: 'level',\n },\n sizeRange: {\n maxSize: 50,\n maxValue: 88,\n minSize: 20,\n minValue: 1,\n onProperty: 'level',\n },\n },\n match: { label: 'Pokemon' },\n },\n];\n\nconst caughtRelRules: GraphStyleRule[] = [\n {\n apply: {\n captions: {\n size: 1.5,\n text: [\n { styles: [], value: 'Caught @ Lv' },\n { styles: ['bold'], value: { property: 'level' } },\n ],\n },\n colorRange: {\n maxColor: '#ff2d78',\n maxValue: 40,\n minColor: '#00d2ff',\n minValue: 1,\n onProperty: 'level',\n },\n width: { value: 4 },\n widthRange: {\n maxValue: 40,\n maxWidth: 8,\n minValue: 1,\n minWidth: 1,\n onProperty: 'level',\n },\n },\n match: { reltype: 'CAUGHT' },\n },\n];\n\nconst otherNodeRules: GraphStyleRule[] = [\n { apply: { color: { value: '#95a5a6' } }, match: { label: 'Trainer' } },\n { apply: { color: { value: '#bdc3c7' } }, match: { label: 'Type' } },\n { apply: { color: { value: '#bdc3c7' } }, match: { label: 'Gym' } },\n];\n\nexport const colorRangeStyleRules: GraphStyleRule[] = [\n ...pokemonRules,\n ...caughtRelRules,\n ...otherNodeRules,\n];\n\nconst Component = () => {\n return (\n <div style={{ height: '600px' }}>\n <GraphVisualization\n nodes={advancedStoryGraph.nodes}\n rels={advancedStoryGraph.rels}\n className={containerClasses}\n styleRules={colorRangeStyleRules}\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
@@ -113,13 +113,21 @@ function getInterpolatedColor(colorRange, graphItem) {
113
113
  }
114
114
  const minRgb = (0, react_color_1.color)(minColor).rgb;
115
115
  const maxRgb = (0, react_color_1.color)(maxColor).rgb;
116
- // min/max can be inverted, we need to now which one is bigger
117
- const actualMinValue = Math.min(minValue, maxValue);
118
- const actualMaxValue = Math.max(minValue, maxValue);
116
+ const resolvedMinValue = (0, style_rules_1.resolveNumericLiteral)(minValue);
117
+ const resolvedMaxValue = (0, style_rules_1.resolveNumericLiteral)(maxValue);
118
+ const boundsOrder = (0, style_rules_1.compareNumericValues)(resolvedMinValue, resolvedMaxValue);
119
+ if (boundsOrder === null) {
120
+ return null;
121
+ }
122
+ const actualMinValue = boundsOrder <= 0 ? resolvedMinValue : resolvedMaxValue;
123
+ const actualMaxValue = boundsOrder <= 0 ? resolvedMaxValue : resolvedMinValue;
119
124
  // Validate mid stop if provided
120
125
  let midRgb = undefined;
126
+ const resolvedMidValue = midValue === undefined ? undefined : (0, style_rules_1.resolveNumericLiteral)(midValue);
121
127
  if (midValue !== undefined && midColor !== undefined) {
122
- const isMidInRange = actualMinValue <= midValue && midValue <= actualMaxValue;
128
+ const minToMid = (0, style_rules_1.compareNumericValues)(actualMinValue, resolvedMidValue);
129
+ const midToMax = (0, style_rules_1.compareNumericValues)(resolvedMidValue, actualMaxValue);
130
+ const isMidInRange = minToMid !== null && midToMax !== null && minToMid <= 0 && midToMax <= 0;
123
131
  if (!isMidInRange || !(0, react_color_1.validHex)(midColor)) {
124
132
  return null;
125
133
  }
@@ -130,25 +138,37 @@ function getInterpolatedColor(colorRange, graphItem) {
130
138
  return null;
131
139
  }
132
140
  const rawValue = extractPropertyValue(prop);
133
- if (typeof rawValue !== 'number') {
141
+ if (typeof rawValue !== 'number' && typeof rawValue !== 'bigint') {
142
+ return null;
143
+ }
144
+ const clampedValue = (0, style_rules_1.clampNumericValue)(rawValue, actualMinValue, actualMaxValue);
145
+ if (clampedValue === null) {
134
146
  return null;
135
147
  }
136
- const clampedValue = Math.max(actualMinValue, Math.min(actualMaxValue, rawValue));
137
148
  let rgb;
138
- if (midRgb !== undefined && midValue !== undefined) {
139
- const t = (0, style_rules_1.getWeight)(minValue, midValue, clampedValue);
140
- const isBetweenMinAndMid = t <= 1;
149
+ if (midRgb !== undefined && resolvedMidValue !== undefined) {
150
+ const weight = (0, style_rules_1.getNumericWeight)(resolvedMinValue, resolvedMidValue, clampedValue);
151
+ if (weight === null) {
152
+ return null;
153
+ }
154
+ const isBetweenMinAndMid = weight <= 1;
141
155
  if (isBetweenMinAndMid) {
142
- rgb = (0, style_rules_1.lerpColor)(minRgb, midRgb, t);
156
+ rgb = (0, style_rules_1.lerpColor)(minRgb, midRgb, weight);
143
157
  }
144
158
  else {
145
- const t = (0, style_rules_1.getWeight)(midValue, maxValue, clampedValue);
146
- rgb = (0, style_rules_1.lerpColor)(midRgb, maxRgb, t);
159
+ const secondWeight = (0, style_rules_1.getNumericWeight)(resolvedMidValue, resolvedMaxValue, clampedValue);
160
+ if (secondWeight === null) {
161
+ return null;
162
+ }
163
+ rgb = (0, style_rules_1.lerpColor)(midRgb, maxRgb, secondWeight);
147
164
  }
148
165
  }
149
166
  else {
150
- const t = (0, style_rules_1.getWeight)(minValue, maxValue, clampedValue);
151
- rgb = (0, style_rules_1.lerpColor)(minRgb, maxRgb, t);
167
+ const weight = (0, style_rules_1.getNumericWeight)(resolvedMinValue, resolvedMaxValue, clampedValue);
168
+ if (weight === null) {
169
+ return null;
170
+ }
171
+ rgb = (0, style_rules_1.lerpColor)(minRgb, maxRgb, weight);
152
172
  }
153
173
  return (0, react_color_1.rgbToHex)(rgb);
154
174
  }
@@ -161,14 +181,20 @@ function getInterpolatedSize(prop, minValue, maxValue, minOut, maxOut) {
161
181
  return null;
162
182
  }
163
183
  const rawValue = extractPropertyValue(prop);
164
- if (typeof rawValue !== 'number') {
184
+ if (typeof rawValue !== 'number' && typeof rawValue !== 'bigint') {
165
185
  return null;
166
186
  }
167
- const actualMinValue = Math.min(minValue, maxValue);
168
- const actualMaxValue = Math.max(minValue, maxValue);
169
- const clampedValue = Math.max(actualMinValue, Math.min(actualMaxValue, rawValue));
170
- const t = (0, style_rules_1.getWeight)(minValue, maxValue, clampedValue);
171
- return minOut * (1 - t) + maxOut * t;
187
+ const resolvedMinValue = (0, style_rules_1.resolveNumericLiteral)(minValue);
188
+ const resolvedMaxValue = (0, style_rules_1.resolveNumericLiteral)(maxValue);
189
+ const clampedValue = (0, style_rules_1.clampNumericValue)(rawValue, resolvedMinValue, resolvedMaxValue);
190
+ if (clampedValue === null) {
191
+ return null;
192
+ }
193
+ const weight = (0, style_rules_1.getNumericWeight)(resolvedMinValue, resolvedMaxValue, clampedValue);
194
+ if (weight === null) {
195
+ return null;
196
+ }
197
+ return minOut * (1 - weight) + maxOut * weight;
172
198
  }
173
199
  function extractPropertyValue(prop) {
174
200
  switch (prop.type) {
@@ -176,8 +202,21 @@ function extractPropertyValue(prop) {
176
202
  return JSON.parse(prop.stringified);
177
203
  case 'number':
178
204
  case 'integer':
205
+ case 'Integer':
179
206
  case 'float':
180
207
  return Number(prop.stringified);
208
+ case 'bigint':
209
+ case 'BigInt': {
210
+ try {
211
+ const value = prop.stringified.startsWith('"')
212
+ ? JSON.parse(prop.stringified)
213
+ : prop.stringified;
214
+ return BigInt(value);
215
+ }
216
+ catch (_a) {
217
+ return null;
218
+ }
219
+ }
181
220
  case 'boolean':
182
221
  case 'Boolean':
183
222
  return prop.stringified === 'true';
@@ -234,6 +273,10 @@ function evaluateWhere(node, where) {
234
273
  if (leftVal === null || rightVal === null) {
235
274
  return null;
236
275
  }
276
+ if ((typeof leftVal === 'number' || typeof leftVal === 'bigint') &&
277
+ (typeof rightVal === 'number' || typeof rightVal === 'bigint')) {
278
+ return (0, style_rules_1.numericValuesEqual)(leftVal, rightVal);
279
+ }
237
280
  return leftVal === rightVal;
238
281
  }
239
282
  if ('not' in where) {
@@ -496,6 +539,9 @@ function evaluateValue(value, graphItem) {
496
539
  if ('time' in value) {
497
540
  return (0, style_rules_1.parseTimeString)(value.time);
498
541
  }
542
+ if ((0, style_rules_1.isBigintLiteral)(value)) {
543
+ return (0, style_rules_1.resolveNumericLiteral)(value);
544
+ }
499
545
  }
500
546
  return value;
501
547
  }
@@ -664,11 +710,11 @@ function createByLabelSetFunction(styleMatchers) {
664
710
  };
665
711
  }
666
712
  const DEFAULT_REL_STYLE = {
667
- match: { reltype: null },
668
713
  apply: {
669
- color: { value: exports.DEFAULT_REL_COLOR },
670
714
  captions: { text: [{ value: { useType: true } }] },
715
+ color: { value: exports.DEFAULT_REL_COLOR },
671
716
  },
717
+ match: { reltype: null },
672
718
  };
673
719
  function compileGraphStyleRules(styleRules) {
674
720
  const styleMatchers = collectStyleMatchers(styleRules);