Skip to content

Commit 223c06d

Browse files
authored
Merge pull request #109 from UW-Macrostrat/fix-data-sheet-error
Fix data sheet error
2 parents 4e9e66f + 70c250b commit 223c06d

File tree

7 files changed

+18
-11
lines changed

7 files changed

+18
-11
lines changed

packages/data-sheet/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.1.1] - 2025-06-25
8+
9+
- Fix issue with exports and Parcel
10+
- Improve some types
11+
712
## [2.1.0] - 2025-06-25
813

914
- Add filtering to PostgREST table

packages/data-sheet/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/data-sheet",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Scalable data sheet with optional editing capabilities",
55
"type": "module",
66
"source": "src/index.ts",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from "./editor-popup";
22
export * from "./colors";
33
export * from "./text-areas";
4+
export * from "./actions";

packages/data-sheet/src/core.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import "@blueprintjs/table/lib/css/table.css";
1616
import hyper from "@macrostrat/hyper";
1717
import update from "immutability-helper";
1818
import { ReactNode, useCallback, useEffect, useMemo, useState } from "react";
19-
import { EditorPopup, handleSpecialKeys } from "./components";
19+
import { EditorPopup, handleSpecialKeys, DataSheetAction } from "./components";
2020
import styles from "./main.module.sass";
2121
import {
2222
ColumnSpec,
23-
ColumnSpecOptions,
2423
DataSheetProvider,
2524
DataSheetProviderProps,
2625
DataSheetStore,
@@ -29,10 +28,6 @@ import {
2928
useStoreAPI,
3029
VisibleCells,
3130
} from "./provider";
32-
import { DataSheetAction } from "./components/actions";
33-
34-
export type { ColumnSpec, ColumnSpecOptions };
35-
export * from "./components";
3631

3732
const h = hyper.styled(styles);
3833

@@ -157,7 +152,7 @@ function _DataSheet<T>({
157152
);
158153

159154
const onAddRow = useCallback(() => {
160-
setUpdatedData((updatedData) => {
155+
setUpdatedData((updatedData: any[]): any[] => {
161156
const ix = Math.max(updatedData.length, data.length);
162157
const addRowSpec = { [ix]: { $set: {} } };
163158
const newUpdatedData = update(updatedData, addRowSpec);

packages/data-sheet/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export * from "./core";
22
export * from "./postgrest-table";
3+
export * from "./components";
4+
export * from "./provider";

packages/data-sheet/src/provider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ export interface DataSheetComputedStore {
6161

6262
type DataSheetVals<T> = DataSheetState<T> & DataSheetCoreProps<T>;
6363

64+
type StateUpdater<T> = T[] | ((state: T[]) => T[]);
65+
6466
export interface DataSheetStore<T> extends DataSheetVals<T> {
6567
setSelection(selection: Region[]): void;
6668
onDragValue(cell: FocusedCellCoordinates | null): void;
67-
setUpdatedData(data: T[]): void;
69+
setUpdatedData(data: StateUpdater<T>): void;
6870
onCellEdited(rowIndex: number, columnName: string, value: any): void;
6971
onColumnsReordered(oldIndex: number, newIndex: number, length: number): void;
7072
moveFocusedCell(direction: "up" | "down" | "left" | "right"): void;
@@ -178,7 +180,7 @@ export function DataSheetProvider<T>({
178180
};
179181
});
180182
},
181-
setUpdatedData(data: T[] | ((state: T[]) => T[])) {
183+
setUpdatedData(data: StateUpdater<T>) {
182184
if (Array.isArray(data)) {
183185
set({ updatedData: data });
184186
} else {

packages/data-sheet/src/utils/column-spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ColumnSpec, ColumnSpecOptions } from "../provider";
2+
13
const defaultRenderers = {
24
string: (d) => d,
35
number: (d) => d?.toFixed(2),
@@ -104,7 +106,7 @@ export function generateDefaultColumnSpec<T>(
104106

105107
export function generateColumnSpec<T>(
106108
data: T[],
107-
options: ColumnSpecOptions,
109+
options: ColumnSpecOptions<T>,
108110
): ColumnSpec[] {
109111
/** Generate a column spec from a dataset */
110112
const { overrides = {}, nRows = 10, omitColumns, includeColumns } = options;

0 commit comments

Comments
 (0)