@constructive-io/sheets 0.6.1 → 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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @constructive-io/sheets
1
+ # Sheets
2
2
 
3
3
  Portable spreadsheet-like CRUD editor for Constructive/PostGraphile backends. The package provides a native DOM grid with filtering, pagination, cell editing, draft rows, relation handling, and standalone authentication.
4
4
 
@@ -7,23 +7,37 @@ Portable spreadsheet-like CRUD editor for Constructive/PostGraphile backends. Th
7
7
  - **Backend**: Constructive server (`cnc server`) exposing the `2026-07` `_meta` contract
8
8
  - **Frontend**: React 18+, Tailwind CSS v4
9
9
 
10
- ## Install
10
+ ## Install from the Constructive registry
11
+
12
+ Configure the `@constructive` registry in `components.json`, then copy the
13
+ complete source-owned grid into your application:
14
+
15
+ ```json
16
+ {
17
+ "registries": {
18
+ "@constructive": "https://constructive-io.github.io/blocks/r/{name}.json"
19
+ }
20
+ }
21
+ ```
11
22
 
12
23
  ```bash
13
- npm install @constructive-io/sheets @constructive-io/data @constructive-io/ui \
14
- @tanstack/react-query @tanstack/react-form
24
+ pnpm dlx shadcn@latest add @constructive/sheets
15
25
  ```
16
26
 
17
- `lucide-react` and `@remixicon/react` are runtime dependencies of Sheets and
18
- are installed transitively.
27
+ The command installs editable Sheets source and local Constructive primitives,
28
+ plus the headless `@constructive-io/data` runtime. It does not install the npm
29
+ UI or Sheets packages.
19
30
 
20
- ### Optional peer dependencies
31
+ ### Editor dependencies
21
32
 
22
33
  | Package | For |
23
34
  |---------|-----|
24
35
  | `leaflet` + `react-leaflet` | Geometry/map editors |
25
36
  | `react-aria-components` + `@internationalized/date` | Date picker editors |
26
37
 
38
+ The registry command installs these so every built-in editor typechecks out of
39
+ the box, even when an application hides those field types.
40
+
27
41
  ## Quick Start
28
42
 
29
43
  ### Standalone mode (built-in login UI)
@@ -32,7 +46,7 @@ are installed transitively.
32
46
  import {
33
47
  SheetsProvider, Sheets, SheetsTableSelector,
34
48
  SheetsAuthGate, useSheetsMeta,
35
- } from '@constructive-io/sheets';
49
+ } from '@/components/ui/sheets';
36
50
  import { selectConsoleDataTables } from '@constructive-io/data';
37
51
 
38
52
  function SpreadsheetApp() {
@@ -75,7 +89,7 @@ function App() {
75
89
  ### Embedded mode (bring your own auth)
76
90
 
77
91
  ```tsx
78
- import { SheetsProvider, Sheets } from '@constructive-io/sheets';
92
+ import { SheetsProvider, Sheets } from '@/components/ui/sheets';
79
93
 
80
94
  function MySpreadsheet() {
81
95
  return (
@@ -113,25 +127,24 @@ npm install tailwindcss @tailwindcss/postcss
113
127
  ```css
114
128
  /* globals.css */
115
129
  @import 'tailwindcss';
116
- @import '@constructive-io/ui/globals.css';
117
- @import '@constructive-io/sheets/styles.css';
118
130
  ```
119
131
 
120
- The Sheets stylesheet is a Tailwind v4 source contract: it scans the shipped
121
- JavaScript in `dist`, so consumers do not depend on unpublished package source.
122
- The UI stylesheet carries its own source and theme contract.
132
+ The shadcn install adds the Constructive theme and places the component source
133
+ under your configured aliases, so Tailwind scans it as application code.
123
134
 
124
- Overlay editors render into a portal. Add this as the last child of `<body>` in your root layout:
135
+ Overlay editors use the shared Constructive portal host. Mount it once as the last child of `<body>` in your root layout:
125
136
 
126
137
  ```tsx
127
138
  // app/layout.tsx
139
+ import { PortalRoot } from '@/components/ui/portal';
140
+
128
141
  <body>
129
142
  {children}
130
- <div id="portal" />
143
+ <PortalRoot />
131
144
  </body>
132
145
  ```
133
146
 
134
- Without this, overlay editors such as date, relation, and JSON editors won't open.
147
+ `PortalRoot` renders the managed `#portal-root` layer used by date, relation, JSON, and other overlay editors. Editors fall back to `document.body` while the host is unavailable, but mounting the shared root keeps application overlays in one predictable stack.
135
148
 
136
149
  ## Configuration
137
150
 
package/dist/advanced.cjs CHANGED
@@ -1641,6 +1641,19 @@ var import_data5 = require("@constructive-io/data");
1641
1641
  var import_data6 = require("@constructive-io/data");
1642
1642
 
1643
1643
  // src/hooks/query-keys.ts
1644
+ function isSheetsScopeKey(value) {
1645
+ if (!value || typeof value !== "object") return false;
1646
+ const candidate = value;
1647
+ return "databaseId" in candidate && "endpoint" in candidate && "identityKey" in candidate;
1648
+ }
1649
+ function reuseSheetsPlaceholderData(previousData, previousQueryKey, currentScope) {
1650
+ const previousScope = previousQueryKey?.[1];
1651
+ if (!isSheetsScopeKey(previousScope)) return void 0;
1652
+ if (previousScope.databaseId !== currentScope.databaseId) return void 0;
1653
+ if (previousScope.endpoint !== currentScope.endpoint) return void 0;
1654
+ if (previousScope.identityKey !== currentScope.identityKey) return void 0;
1655
+ return previousData;
1656
+ }
1644
1657
  var sheetsQueryKeys = {
1645
1658
  root: ["sheets"],
1646
1659
  scope: (scope) => ["sheets", scope],
@@ -2051,7 +2064,7 @@ function useSheetsTable(tableName, options = {}) {
2051
2064
  return { rows, totalCount: totalCount2 };
2052
2065
  },
2053
2066
  enabled: enabled && !!table,
2054
- placeholderData: import_react_query.keepPreviousData,
2067
+ placeholderData: (previousData, previousQuery) => reuseSheetsPlaceholderData(previousData, previousQuery?.queryKey, scopeKey),
2055
2068
  staleTime: 5 * 60 * 1e3
2056
2069
  // 5 minutes
2057
2070
  });
@@ -2245,7 +2258,7 @@ function hasDeclaredEnums(meta) {
2245
2258
  }
2246
2259
  function schemaCompatibilityError(missingPaths) {
2247
2260
  const detail = missingPaths.length > 0 ? ` Missing: ${missingPaths.join(", ")}.` : "";
2248
- return import_data7.createError.badRequest(
2261
+ return import_data7.createError.graphql(
2249
2262
  `The GraphQL schema does not match the enum values declared by Constructive _meta.${detail}`,
2250
2263
  "SCHEMA_INTROSPECTION_INCOMPATIBLE"
2251
2264
  );
@@ -2257,7 +2270,7 @@ function normalizeMutationEnums(ctx, input, execute) {
2257
2270
  if (!hasEnumInput) return input;
2258
2271
  const mappings = enumMappings.get(execute);
2259
2272
  if (!mappings) {
2260
- throw import_data7.createError.badRequest(
2273
+ throw import_data7.createError.graphql(
2261
2274
  "Enum schema mappings are unavailable. Load table metadata before mutating enum fields.",
2262
2275
  "ENUM_MAPPING_UNAVAILABLE"
2263
2276
  );
@@ -2800,7 +2813,7 @@ function createSheetsExecute(config, getToken) {
2800
2813
  throw import_data9.createError.graphql(body.errors[0].message || `Request failed: ${status}`, body.errors[0].extensions?.code);
2801
2814
  }
2802
2815
  } catch (e) {
2803
- if (e instanceof import_data9.DataError) throw e;
2816
+ if (e instanceof import_data9.ConstructiveError) throw e;
2804
2817
  }
2805
2818
  throw import_data9.createError.badRequest(`Request failed: ${status} ${statusText}`);
2806
2819
  }