@chronocide/hyper 1.1.3 → 1.2.1

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/hyper.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  type CellOptions<T> = {
2
- /** If empty, equal to container width */
2
+ /** If null, equal to container width */
3
3
  width?: number | ((data: T, i: number, arr: T[]) => number | null) | null;
4
4
  /** If true, cells do not fill container width */
5
5
  gap?: boolean;
6
- height: number | ((data: T, i: number, arr: T[]) => number);
6
+ /** If null, equal to item height (1:1) */
7
+ height: number | ((data: T, i: number, arr: T[]) => number | null) | null;
7
8
  };
8
9
 
9
10
  type Json = string | number | boolean | null | Json[] | {
package/dist/hyper.js CHANGED
@@ -72,7 +72,6 @@ const bisectRight = (arr) => (n) => {
72
72
 
73
73
  const cells = (cell) => (container) => (data) => fill(data.length)((i, arr) => {
74
74
  const prev = get(arr)(i - 1);
75
- const height2 = typeof cell.height === "number" ? cell.height : cell.height(data[i], i, data);
76
75
  let width = container.width;
77
76
  if (typeof cell.width === "number") width = cell.width;
78
77
  if (typeof cell.width === "function") width = cell.width(data[i], i, data) ?? container.width;
@@ -80,6 +79,9 @@ const cells = (cell) => (container) => (data) => fill(data.length)((i, arr) => {
80
79
  const rows = Math.max(1, Math.floor(container.width / width));
81
80
  width = Math.floor(container.width / rows);
82
81
  }
82
+ let height2 = width;
83
+ if (typeof cell.height === "number") height2 = cell.height;
84
+ if (typeof cell.height === "function") height2 = cell.height(data[i], i, data) ?? width;
83
85
  let x = (prev?.x ?? 0) + (prev?.width ?? 0);
84
86
  let y = prev?.y ?? 0;
85
87
  if (x + width > container.width) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chronocide/hyper",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "types": "dist/hyper.d.ts",
6
6
  "exports": {