@svgrid/grid 1.1.1 → 1.1.2

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 (50) hide show
  1. package/dist/FlexRender.svelte +96 -96
  2. package/dist/SvGrid.controller.svelte.js +17 -6
  3. package/dist/SvGrid.css +2012 -2012
  4. package/dist/SvGrid.svelte +2569 -2346
  5. package/dist/build-api.js +2 -2
  6. package/dist/cell-values.d.ts +1 -1
  7. package/dist/cell-values.js +7 -7
  8. package/dist/column-types.js +1 -1
  9. package/dist/core.d.ts +1 -1
  10. package/dist/core.js +2 -2
  11. package/dist/summaries.js +4 -4
  12. package/package.json +1 -1
  13. package/src/FlexRender.svelte +96 -96
  14. package/src/SvGrid.controller.svelte.ts +2363 -2352
  15. package/src/SvGrid.css +2012 -2012
  16. package/src/SvGrid.svelte +2569 -2346
  17. package/src/SvGrid.types.ts +537 -537
  18. package/src/a11y.contract.test.ts +49 -49
  19. package/src/a11y.test.ts +59 -59
  20. package/src/a11y.ts +59 -59
  21. package/src/build-api.ts +683 -683
  22. package/src/cell-formatting.ts +169 -169
  23. package/src/cell-values.ts +4 -4
  24. package/src/column-types.ts +1 -1
  25. package/src/core.performance.test.ts +30 -30
  26. package/src/core.ts +1077 -1077
  27. package/src/createGrid.svelte.ts +42 -42
  28. package/src/createGrid.test.ts +10 -10
  29. package/src/createGridState.svelte.ts +17 -17
  30. package/src/editing.ts +669 -669
  31. package/src/flex-render.ts +3 -3
  32. package/src/index.ts +208 -208
  33. package/src/keyboard.test.ts +59 -59
  34. package/src/keyboard.ts +97 -97
  35. package/src/merge-objects.ts +48 -48
  36. package/src/render-component.ts +28 -28
  37. package/src/spreadsheet.test.ts +489 -489
  38. package/src/spreadsheet.ts +304 -304
  39. package/src/static-functions.ts +11 -11
  40. package/src/subscribe.ts +38 -38
  41. package/src/summaries.ts +4 -4
  42. package/src/svgrid-wrapper.types.ts +412 -412
  43. package/src/svgrid.features.test.ts +157 -157
  44. package/src/svgrid.wrapper.test.ts +40 -40
  45. package/src/virtualization/column-virtualizer.test.ts +27 -27
  46. package/src/virtualization/column-virtualizer.ts +30 -30
  47. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  48. package/src/virtualization/types.ts +30 -30
  49. package/src/virtualization/virtualizer.test.ts +47 -47
  50. package/src/virtualization/virtualizer.ts +296 -296
package/dist/build-api.js CHANGED
@@ -9,8 +9,8 @@ export function createGridApi(ctx) {
9
9
  const column = findColumn(columnId);
10
10
  if (!row || !column)
11
11
  return undefined;
12
- if (column.columnDef.accessorFn)
13
- return column.columnDef.accessorFn(row);
12
+ if (column.columnDef.fieldFn)
13
+ return column.columnDef.fieldFn(row);
14
14
  if (column.columnDef.field)
15
15
  return row[column.columnDef.field];
16
16
  return undefined;
@@ -20,7 +20,7 @@ export declare function getColumnAlign<TData extends RowData>(column: Column<TDa
20
20
  /**
21
21
  * Read a cell value from a PINNED row. Pinned rows aren't bound to a
22
22
  * TanStack Row<TData>, so we resolve the value directly off the raw
23
- * TData via `accessorFn` or `field`. Mirrors `getColumnBaseValue`'s
23
+ * TData via `fieldFn` or `field`. Mirrors `getColumnBaseValue`'s
24
24
  * lookup path minus the Row indirection.
25
25
  */
26
26
  export declare function getPinnedCellValue<TData extends RowData>(rowData: TData, column: Column<TData>): unknown;
@@ -1,8 +1,8 @@
1
1
  import { formatNumericWithConfig } from "./cell-formatting";
2
2
  export function getColumnBaseValue(row, column) {
3
3
  const def = column.columnDef;
4
- if (def.accessorFn)
5
- return def.accessorFn(row.original);
4
+ if (def.fieldFn)
5
+ return def.fieldFn(row.original);
6
6
  if (def.field)
7
7
  return row.original[def.field];
8
8
  return row.getCellValueByColumnId(column.id);
@@ -64,13 +64,13 @@ export function getColumnAlign(column) {
64
64
  /**
65
65
  * Read a cell value from a PINNED row. Pinned rows aren't bound to a
66
66
  * TanStack Row<TData>, so we resolve the value directly off the raw
67
- * TData via `accessorFn` or `field`. Mirrors `getColumnBaseValue`'s
67
+ * TData via `fieldFn` or `field`. Mirrors `getColumnBaseValue`'s
68
68
  * lookup path minus the Row indirection.
69
69
  */
70
70
  export function getPinnedCellValue(rowData, column) {
71
71
  const def = column.columnDef;
72
- if (def.accessorFn)
73
- return def.accessorFn(rowData);
72
+ if (def.fieldFn)
73
+ return def.fieldFn(rowData);
74
74
  const field = def.field;
75
75
  if (!field)
76
76
  return undefined;
@@ -78,8 +78,8 @@ export function getPinnedCellValue(rowData, column) {
78
78
  }
79
79
  export function getColumnAccessorValue(rowData, column) {
80
80
  const def = column.columnDef;
81
- if (def.accessorFn)
82
- return def.accessorFn(rowData);
81
+ if (def.fieldFn)
82
+ return def.fieldFn(rowData);
83
83
  if (def.field)
84
84
  return rowData[def.field];
85
85
  return undefined;
@@ -47,7 +47,7 @@ export function resolveColumnTypes(columns, sampleRow, infer) {
47
47
  let dt = col.cellDataType;
48
48
  if (!dt && infer && !hasExplicitEditor && sampleRow != null) {
49
49
  const field = col.field;
50
- const raw = col.accessorFn?.(sampleRow) ??
50
+ const raw = col.fieldFn?.(sampleRow) ??
51
51
  (typeof field === "string" ? sampleRow[field] : undefined);
52
52
  dt = inferCellDataType(raw);
53
53
  }
package/dist/core.d.ts CHANGED
@@ -129,7 +129,7 @@ export declare function applyGroupAggregate<TData extends RowData>(agg: GroupAgg
129
129
  export type ColumnDef<TFeatures extends TableFeatures, TData extends RowData> = {
130
130
  id?: string;
131
131
  field?: keyof TData & string;
132
- accessorFn?: (row: TData) => unknown;
132
+ fieldFn?: (row: TData) => unknown;
133
133
  header?: ColumnDefTemplate<HeaderContext<TData>>;
134
134
  footer?: ColumnDefTemplate<HeaderContext<TData>>;
135
135
  cell?: ColumnDefTemplate<CellContext<TData>>;
package/dist/core.js CHANGED
@@ -454,8 +454,8 @@ export function createSvGridCore(options) {
454
454
  const values = new Array(columnCount);
455
455
  for (let i = 0; i < columnCount; i++) {
456
456
  const column = columns[i];
457
- if (column.columnDef.accessorFn) {
458
- values[i] = column.columnDef.accessorFn(original);
457
+ if (column.columnDef.fieldFn) {
458
+ values[i] = column.columnDef.fieldFn(original);
459
459
  }
460
460
  else if (column.columnDef.field) {
461
461
  values[i] = original[column.columnDef.field];
package/dist/summaries.js CHANGED
@@ -13,7 +13,7 @@ export function createSummaries(ctx) {
13
13
  * trap for every cell otherwise - 5M no-op trap calls on a
14
14
  * 100k x 50 grid. Skipping it when the map is empty is the single
15
15
  * biggest win here.
16
- * 2. The column's accessor (`accessorFn` / `field`) is resolved once
16
+ * 2. The column's accessor (`fieldFn` / `field`) is resolved once
17
17
  * per column, not re-read off `columnDef` for every cell.
18
18
  */
19
19
  function computeSummaries(rows, columns) {
@@ -22,7 +22,7 @@ export function createSummaries(ctx) {
22
22
  const hasEdits = Object.keys(ctx.editedCellValues).length > 0;
23
23
  for (const column of columns) {
24
24
  const def = column.columnDef;
25
- const accessorFn = def.accessorFn;
25
+ const fieldFn = def.fieldFn;
26
26
  const field = def.field;
27
27
  const columnId = column.id;
28
28
  let numericSum = 0;
@@ -30,8 +30,8 @@ export function createSummaries(ctx) {
30
30
  for (let i = 0; i < rowCount; i += 1) {
31
31
  const row = rows[i];
32
32
  let value;
33
- const base = accessorFn
34
- ? accessorFn(row.original)
33
+ const base = fieldFn
34
+ ? fieldFn(row.original)
35
35
  : field
36
36
  ? row.original[field]
37
37
  : row.getCellValueByColumnId(columnId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svgrid/grid",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "SvGrid - a headless-first, Svelte 5-native data grid engine and render component.",
5
5
  "author": "jQWidgets <boikom@jqwidgets.com>",
6
6
  "license": "MIT",
@@ -1,96 +1,96 @@
1
- <script
2
- lang="ts"
3
- generics="TData extends RowData"
4
- >
5
- import { isFunction } from './core'
6
- import {
7
- RenderComponentConfig,
8
- RenderSnippetConfig,
9
- } from './render-component'
10
- import type {
11
- Cell,
12
- CellContext,
13
- ColumnDefTemplate,
14
- Header,
15
- HeaderContext,
16
- RowData,
17
- } from './core'
18
-
19
- type Props =
20
- | {
21
- content?: ColumnDefTemplate<
22
- | HeaderContext<TData>
23
- | CellContext<TData>
24
- >
25
- context:
26
- | HeaderContext<TData>
27
- | CellContext<TData>
28
- cell?: never
29
- header?: never
30
- footer?: never
31
- }
32
- | {
33
- cell: Cell<TData>
34
- content?: never
35
- context?: never
36
- header?: never
37
- footer?: never
38
- }
39
- | {
40
- header: Header<TData>
41
- content?: never
42
- context?: never
43
- cell?: never
44
- footer?: never
45
- }
46
- | {
47
- footer: Header<TData>
48
- content?: never
49
- context?: never
50
- cell?: never
51
- header?: never
52
- }
53
-
54
- let props: Props = $props()
55
-
56
- const resolved = $derived.by(() => {
57
- if ('cell' in props && props.cell) {
58
- return {
59
- content: props.cell.column.columnDef.cell,
60
- context: props.cell.getContext(),
61
- }
62
- }
63
- if ('header' in props && props.header) {
64
- return {
65
- content: props.header.column.columnDef.header,
66
- context: props.header.getContext(),
67
- }
68
- }
69
- if ('footer' in props && props.footer) {
70
- return {
71
- content: props.footer.column.columnDef.footer,
72
- context: props.footer.getContext(),
73
- }
74
- }
75
- return {
76
- content: props.content,
77
- context: props.context,
78
- }
79
- })
80
-
81
- const result = $derived(
82
- isFunction(resolved.content)
83
- ? resolved.content(resolved.context as any)
84
- : undefined,
85
- )
86
- </script>
87
-
88
- {#if typeof resolved.content === 'string'}
89
- {resolved.content}
90
- {:else if result instanceof RenderComponentConfig}
91
- <result.component {...result.props} />
92
- {:else if result instanceof RenderSnippetConfig}
93
- {@render result.snippet(result.params)}
94
- {:else if result !== undefined}
95
- {result}
96
- {/if}
1
+ <script
2
+ lang="ts"
3
+ generics="TData extends RowData"
4
+ >
5
+ import { isFunction } from './core'
6
+ import {
7
+ RenderComponentConfig,
8
+ RenderSnippetConfig,
9
+ } from './render-component'
10
+ import type {
11
+ Cell,
12
+ CellContext,
13
+ ColumnDefTemplate,
14
+ Header,
15
+ HeaderContext,
16
+ RowData,
17
+ } from './core'
18
+
19
+ type Props =
20
+ | {
21
+ content?: ColumnDefTemplate<
22
+ | HeaderContext<TData>
23
+ | CellContext<TData>
24
+ >
25
+ context:
26
+ | HeaderContext<TData>
27
+ | CellContext<TData>
28
+ cell?: never
29
+ header?: never
30
+ footer?: never
31
+ }
32
+ | {
33
+ cell: Cell<TData>
34
+ content?: never
35
+ context?: never
36
+ header?: never
37
+ footer?: never
38
+ }
39
+ | {
40
+ header: Header<TData>
41
+ content?: never
42
+ context?: never
43
+ cell?: never
44
+ footer?: never
45
+ }
46
+ | {
47
+ footer: Header<TData>
48
+ content?: never
49
+ context?: never
50
+ cell?: never
51
+ header?: never
52
+ }
53
+
54
+ let props: Props = $props()
55
+
56
+ const resolved = $derived.by(() => {
57
+ if ('cell' in props && props.cell) {
58
+ return {
59
+ content: props.cell.column.columnDef.cell,
60
+ context: props.cell.getContext(),
61
+ }
62
+ }
63
+ if ('header' in props && props.header) {
64
+ return {
65
+ content: props.header.column.columnDef.header,
66
+ context: props.header.getContext(),
67
+ }
68
+ }
69
+ if ('footer' in props && props.footer) {
70
+ return {
71
+ content: props.footer.column.columnDef.footer,
72
+ context: props.footer.getContext(),
73
+ }
74
+ }
75
+ return {
76
+ content: props.content,
77
+ context: props.context,
78
+ }
79
+ })
80
+
81
+ const result = $derived(
82
+ isFunction(resolved.content)
83
+ ? resolved.content(resolved.context as any)
84
+ : undefined,
85
+ )
86
+ </script>
87
+
88
+ {#if typeof resolved.content === 'string'}
89
+ {resolved.content}
90
+ {:else if result instanceof RenderComponentConfig}
91
+ <result.component {...result.props} />
92
+ {:else if result instanceof RenderSnippetConfig}
93
+ {@render result.snippet(result.params)}
94
+ {:else if result !== undefined}
95
+ {result}
96
+ {/if}