@constructive-io/sheets 0.6.0 → 0.8.0

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.cts CHANGED
@@ -6,7 +6,7 @@ import { StoreApi } from 'zustand';
6
6
  import { R as RelationInfo, d as RelationInfoSlice, E as EditorProps, F as FieldMetadata, S as SheetsCell, e as CellRegistryEntry, b as CellType, f as CellRenderer, g as CellPlugin, h as ColumnSchema } from './grid-cell-types-C3ARj148.cjs';
7
7
  export { B as BaseCellProps, c as CellCategory, i as CellValue, j as FieldMetadata, k as RelationKind, l as RowData, a as SheetsCellKind, T as TableSchema, m as buildRelationInfoFromMeta, n as isImageField, r as resolveCellType } from './grid-cell-types-C3ARj148.cjs';
8
8
  import { RowIdentityValue, TableWriteCapability, MetaTable as MetaTable$1, FieldSelection, MutationOptions, PageInfo, MetaQuery, QueryOptions, Filter } from '@constructive-io/data';
9
- export { DataError } from '@constructive-io/data';
9
+ export { ConstructiveError } from '@constructive-io/data';
10
10
  import * as _tanstack_react_query from '@tanstack/react-query';
11
11
  import { UseQueryResult } from '@tanstack/react-query';
12
12
  import { z } from 'zod';
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import { StoreApi } from 'zustand';
6
6
  import { R as RelationInfo, d as RelationInfoSlice, E as EditorProps, F as FieldMetadata, S as SheetsCell, e as CellRegistryEntry, b as CellType, f as CellRenderer, g as CellPlugin, h as ColumnSchema } from './grid-cell-types-C3ARj148.js';
7
7
  export { B as BaseCellProps, c as CellCategory, i as CellValue, j as FieldMetadata, k as RelationKind, l as RowData, a as SheetsCellKind, T as TableSchema, m as buildRelationInfoFromMeta, n as isImageField, r as resolveCellType } from './grid-cell-types-C3ARj148.js';
8
8
  import { RowIdentityValue, TableWriteCapability, MetaTable as MetaTable$1, FieldSelection, MutationOptions, PageInfo, MetaQuery, QueryOptions, Filter } from '@constructive-io/data';
9
- export { DataError } from '@constructive-io/data';
9
+ export { ConstructiveError } from '@constructive-io/data';
10
10
  import * as _tanstack_react_query from '@tanstack/react-query';
11
11
  import { UseQueryResult } from '@tanstack/react-query';
12
12
  import { z } from 'zod';
package/dist/index.js CHANGED
@@ -24,25 +24,26 @@ import {
24
24
  useSheetsTable,
25
25
  useSheetsTableCursor,
26
26
  validateOrderByVariables
27
- } from "./chunk-LR64FLWO.js";
27
+ } from "./chunk-6FMKFRJY.js";
28
28
  import {
29
29
  SheetsAuthGate,
30
30
  useSheetsForgotPassword,
31
31
  useSheetsLogin,
32
32
  useSheetsRegister,
33
33
  useSheetsResetPassword
34
- } from "./chunk-KKAWMVEG.js";
34
+ } from "./chunk-FNWOEA5F.js";
35
35
  import {
36
36
  SheetsProvider
37
- } from "./chunk-KVPVEXWB.js";
37
+ } from "./chunk-HETVHNMD.js";
38
38
  import {
39
- DataError,
39
+ ConstructiveError,
40
40
  createSheetsExecute,
41
41
  createSheetsUpload,
42
42
  isSheetsScopeKey,
43
43
  resolveDownloadUrl,
44
+ reuseSheetsPlaceholderData,
44
45
  sheetsQueryKeys
45
- } from "./chunk-ZETPUEXH.js";
46
+ } from "./chunk-26J3DVW7.js";
46
47
  import "./chunk-4EZ6A23C.js";
47
48
  import {
48
49
  SheetsContext,
@@ -54,7 +55,7 @@ import {
54
55
  useSheetsContext,
55
56
  useSheetsStore,
56
57
  useSheetsStoreApi
57
- } from "./chunk-KOZAW264.js";
58
+ } from "./chunk-H5HR5HUJ.js";
58
59
  import {
59
60
  BOOLEAN_TYPES,
60
61
  BUILTIN_EDITOR_TYPES,
@@ -80,7 +81,9 @@ import {
80
81
 
81
82
  // src/grid/sheets.tsx
82
83
  import { forwardRef, useCallback as useCallback19, useEffect as useEffect6, useImperativeHandle as useImperativeHandle2, useMemo as useMemo17, useRef as useRef10, useState as useState9 } from "react";
83
- import { functionalUpdate } from "@tanstack/react-table";
84
+ import {
85
+ functionalUpdate
86
+ } from "@tanstack/react-table";
84
87
  import { RiFilterOffLine, RiSearchEyeLine } from "@remixicon/react";
85
88
  import { Button as Button6 } from "@constructive-io/ui/button";
86
89
 
@@ -2698,7 +2701,7 @@ function useCellEditing({
2698
2701
  try {
2699
2702
  result = await update(rowIdentifier, { [patchField]: value });
2700
2703
  } catch (error) {
2701
- revertOptimisticPatch?.();
2704
+ if (typeof revertOptimisticPatch === "function") revertOptimisticPatch();
2702
2705
  throw error;
2703
2706
  }
2704
2707
  onCellEdit?.(rowIdentifier, patchField, value);
@@ -3792,7 +3795,7 @@ import { useCallback as useCallback15, useMemo as useMemo11 } from "react";
3792
3795
 
3793
3796
  // src/hooks/use-sheets-infinite-table.ts
3794
3797
  import { useCallback as useCallback14, useEffect as useEffect3, useMemo as useMemo10, useRef as useRef4, useState as useState5 } from "react";
3795
- import { keepPreviousData, useQueries, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
3798
+ import { useQueries, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
3796
3799
  import {
3797
3800
  cleanTable as cleanTable2
3798
3801
  } from "@constructive-io/data";
@@ -3950,12 +3953,9 @@ function useSheetsInfiniteTable(tableName, options = {}) {
3950
3953
  return pageData;
3951
3954
  },
3952
3955
  enabled: enabled && !!table && canFetch,
3953
- // Keep the previously-fetched page visible while this page's KEY changes
3954
- // (sort/filter/pageSize change `stableOptionsKey`, minting a fresh key per
3955
- // page). Without this the new key has no data → getRowAtIndex returns null
3956
- // for every index → the whole grid flashes to skeletons until the refetch
3957
- // lands. Paginated mode already does this in use-sheets-table.ts.
3958
- placeholderData: keepPreviousData,
3956
+ // Reuse a page across sort/filter/page-size key changes only while the
3957
+ // endpoint, database, and authenticated identity remain unchanged.
3958
+ placeholderData: (previousData, previousQuery) => reuseSheetsPlaceholderData(previousData, previousQuery?.queryKey, scopeKey),
3959
3959
  staleTime: 5 * 60 * 1e3,
3960
3960
  // 5 minutes
3961
3961
  gcTime: 10 * 60 * 1e3
@@ -4506,7 +4506,7 @@ function useSheets(props) {
4506
4506
  allRelationFields: ctx.allRelationFields,
4507
4507
  hasCompletedInitialLoad: !ctx.isLoading,
4508
4508
  dataError: ctx.error,
4509
- // isLoading is true only until first data arrives (keepPreviousData keeps rows on refetch).
4509
+ // isLoading is true only until the active scope receives its first result.
4510
4510
  isInitialLoading: ctx.isLoading && rows.length === 0
4511
4511
  };
4512
4512
  }, [infiniteScroll, infiniteGridData, dataLoadingResult.contextValue]);
@@ -5093,7 +5093,7 @@ function useSheetsTableInstance(params) {
5093
5093
  return columns.map((col) => helper.accessor((row) => row?.[col.key], { id: col.key, header: col.name, size: col.size }));
5094
5094
  }, [columns]);
5095
5095
  const normalizedPinning = useMemo14(
5096
- () => ({ left: columnPinning.left ?? [], right: columnPinning.right ?? [] }),
5096
+ () => ({ start: columnPinning.start ?? [], end: columnPinning.end ?? [] }),
5097
5097
  [columnPinning]
5098
5098
  );
5099
5099
  return useTable({
@@ -5180,7 +5180,7 @@ function hitTestCell(clientX, clientY, geom) {
5180
5180
  return [col, row];
5181
5181
  }
5182
5182
  function findStickyColumnIndex(columns) {
5183
- const pinned = columns.findIndex((col) => col.getIsPinned() === "left");
5183
+ const pinned = columns.findIndex((col) => col.getIsPinned() === "start");
5184
5184
  return pinned >= 0 ? pinned : columns.length > 0 ? 0 : -1;
5185
5185
  }
5186
5186
  function columnTitle(column) {
@@ -6344,7 +6344,7 @@ function OverlayManager({ anchorRect, open, presetClass, onCancel, dismissMode =
6344
6344
  maxHeight,
6345
6345
  // Hidden until measured to avoid a 1-frame flash at an unclamped position.
6346
6346
  visibility: positioned ? "visible" : "hidden",
6347
- // Join the shared overlay layer (@constructive-io/ui z-scale) instead of an
6347
+ // Join the shared design-system overlay layer instead of an
6348
6348
  // arbitrary z, so the editor and any popover/tooltip it opens (e.g. the relation
6349
6349
  // "Record Data" popover, which portals into #portal-root) stack coherently.
6350
6350
  zIndex: "var(--z-layer-floating)"
@@ -7071,7 +7071,7 @@ function SheetsInnerComponent(props, ref) {
7071
7071
  return /* @__PURE__ */ jsx24(FeedbackProvider, { children: /* @__PURE__ */ jsx24(SheetsDomInner, { ...props, forwardedRef: ref }) });
7072
7072
  }
7073
7073
  var Sheets = forwardRef(SheetsInnerComponent);
7074
- var EMPTY_OBJ = {};
7074
+ var EMPTY_ROW_SELECTION = {};
7075
7075
  var noop = () => {
7076
7076
  };
7077
7077
  var OVERLAY_MARGIN_PX = 12;
@@ -7122,7 +7122,7 @@ function SheetsDomInner({
7122
7122
  return sizing;
7123
7123
  }, [columnWidths]);
7124
7124
  const columnPinning = useMemo17(
7125
- () => ({ left: frozenCount > 0 && firstColumnKey ? [firstColumnKey] : [], right: [] }),
7125
+ () => ({ start: frozenCount > 0 && firstColumnKey ? [firstColumnKey] : [], end: [] }),
7126
7126
  [frozenCount, firstColumnKey]
7127
7127
  );
7128
7128
  const onColumnSizingChange = useCallback19(
@@ -7140,7 +7140,7 @@ function SheetsDomInner({
7140
7140
  const setSelection = s.selection.setGridSelection;
7141
7141
  const activeCell = selection?.current?.cell;
7142
7142
  const rowSelection = useMemo17(() => {
7143
- if (!selection) return EMPTY_OBJ;
7143
+ if (!selection) return EMPTY_ROW_SELECTION;
7144
7144
  const map = {};
7145
7145
  for (const index of selection.rows.toArray()) {
7146
7146
  map[getRowId(combinedRows[index], index)] = true;
@@ -8593,8 +8593,8 @@ export {
8593
8593
  BOOLEAN_TYPES,
8594
8594
  BUILTIN_EDITOR_TYPES,
8595
8595
  CellRegistry,
8596
+ ConstructiveError,
8596
8597
  DATE_TIME_TYPES,
8597
- DataError,
8598
8598
  DockStatusBar,
8599
8599
  DockStatusBarCompact,
8600
8600
  ENHANCED_TYPES,