@gridkitjs/core 0.0.0-dev-20261106222533 → 0.0.0-dev-20261107195236

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.
package/dist/index.d.ts CHANGED
@@ -2078,8 +2078,9 @@ interface ColumnDefinition<Row, Node = string> {
2078
2078
  */
2079
2079
  footerTemplate?: ((context: FooterTemplateContext<Row>) => Node) | undefined;
2080
2080
  /**
2081
- * The value type of this column's cells. This package is framework-agnostic so it
2082
- * defaults to `string`;
2081
+ * The value type of this column's cells. Absent, the column has none: it
2082
+ * sorts as `compareValues` does without a type, two numbers or two `Date`s
2083
+ * by value and any other pair as text.
2083
2084
  */
2084
2085
  type?: ColumnType;
2085
2086
  /**
@@ -3411,8 +3412,8 @@ declare function revertColumnSize(current: ColumnSizingState, base: ColumnSizing
3411
3412
  /**
3412
3413
  * Compares two cell values the way `type` implies — numerically for the
3413
3414
  * numeric types, chronologically for the date/time types, lexically
3414
- * otherwise. Defaults to string comparison when `type` is absent, mirroring
3415
- * `ColumnDefinition.type`'s own default.
3415
+ * otherwise. With no `type`, two numbers or two `Date`s compare by value and
3416
+ * anything else as text; see `compareUntyped`.
3416
3417
  *
3417
3418
  * `null`/`undefined` sort after every value on both sides. Used directly,
3418
3419
  * that ordering is fixed; `sortRows` applies it directionally without
package/dist/index.js CHANGED
@@ -116,6 +116,21 @@ function isEmpty(value) {
116
116
  function toTime(value) {
117
117
  return value instanceof Date ? value.getTime() : new Date(String(value)).getTime();
118
118
  }
119
+ function isFiniteNumber(value) {
120
+ return typeof value === "number" && Number.isFinite(value);
121
+ }
122
+ function isValidDate(value) {
123
+ return value instanceof Date && !Number.isNaN(value.getTime());
124
+ }
125
+ function compareUntyped(a, b) {
126
+ if (isFiniteNumber(a) && isFiniteNumber(b)) {
127
+ return a - b;
128
+ }
129
+ if (isValidDate(a) && isValidDate(b)) {
130
+ return a.getTime() - b.getTime();
131
+ }
132
+ return String(a).localeCompare(String(b));
133
+ }
119
134
  function compareValues(a, b, type) {
120
135
  if (isEmpty(a)) {
121
136
  return isEmpty(b) ? 0 : 1;
@@ -135,6 +150,8 @@ function compareValues(a, b, type) {
135
150
  case "dateTime":
136
151
  case "time":
137
152
  return toTime(a) - toTime(b);
153
+ case void 0:
154
+ return compareUntyped(a, b);
138
155
  default:
139
156
  return String(a).localeCompare(String(b));
140
157
  }