@rokkit/data 1.1.1 → 1.1.4

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.
@@ -8,3 +8,4 @@ export { parseFilters } from "./parser";
8
8
  export { innerJoin, leftJoin, rightJoin, fullJoin, crossJoin, antiJoin, semiJoin } from "./join";
9
9
  export { deriveColumns, deriveMetadata, deriveSortableColumn, inferScale, addScales, deriveColumnDefs, mergeColumnEnhancements } from "./infer";
10
10
  export { filterData, filterObjectArray } from "./filter";
11
+ export { nestByPath, nestByColumns } from "./nest";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Nesting helpers
3
+ *
4
+ * Convert flat tabular shapes into the nested children-array shape consumed
5
+ * by hierarchical components (TreeTable, Tree).
6
+ *
7
+ * nestByPath — rows with a separator-delimited path field
8
+ * nestByColumns — rows with one or more group-by columns
9
+ */
10
+ /**
11
+ * Convert flat rows that carry a separator-delimited path string into
12
+ * nested rows with a `children` array.
13
+ *
14
+ * Synthesizes intermediate parent rows when a path segment has no own row
15
+ * — the synthetic row carries only the path-field set to the partial path.
16
+ *
17
+ * @param {Array<Record<string, unknown>>} rows
18
+ * @param {{ column: string, separator?: string, keepPath?: boolean }} options
19
+ * @returns {Array<Record<string, unknown>>}
20
+ */
21
+ export function nestByPath(rows: Array<Record<string, unknown>>, { column, separator, keepPath }: {
22
+ column: string;
23
+ separator?: string;
24
+ keepPath?: boolean;
25
+ }): Array<Record<string, unknown>>;
26
+ /**
27
+ * Convert flat rows into nested rows by grouping on one or more columns.
28
+ *
29
+ * Each entry in `columns` produces a level of grouping. Synthesized group
30
+ * rows carry `__group: true`, the grouped column name on a `__column` key,
31
+ * and the column value under the column's own field name so cell snippets
32
+ * can read it normally.
33
+ *
34
+ * @param {Array<Record<string, unknown>>} rows
35
+ * @param {string[]} columns
36
+ * @param {{ groupRowFactory?: (col: string, value: unknown, children: Array) => Record<string, unknown> }} [options]
37
+ * @returns {Array<Record<string, unknown>>}
38
+ */
39
+ export function nestByColumns(rows: Array<Record<string, unknown>>, columns: string[], options?: {
40
+ groupRowFactory?: (col: string, value: unknown, children: any[]) => Record<string, unknown>;
41
+ }): Array<Record<string, unknown>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/data",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "description": "Contains generic data manipulation functions that can be used in various components.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@lukeed/uuid": "^2.0.1",
41
- "@rokkit/core": "1.1.1",
41
+ "@rokkit/core": "1.1.4",
42
42
  "d3-array": "^3.2.4",
43
43
  "d3-collection": "^1.0.7",
44
44
  "ramda": "^0.32.0",
package/src/index.js CHANGED
@@ -17,3 +17,4 @@ export {
17
17
  } from './infer'
18
18
  export { parseFilters } from './parser'
19
19
  export { filterData, filterObjectArray } from './filter'
20
+ export { nestByPath, nestByColumns } from './nest'
package/src/nest.js ADDED
Binary file