@constructive-io/sheets 0.4.1 → 0.6.1
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 +19 -24
- package/dist/advanced.cjs +250 -405
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +9 -10
- package/dist/advanced.d.ts +9 -10
- package/dist/advanced.js +3 -3
- package/dist/auth.cjs +10 -10
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +5 -4
- package/dist/auth.d.ts +5 -4
- package/dist/auth.js +3 -3
- package/dist/{chunk-GLVZSPV2.js → chunk-4EZ6A23C.js} +4 -3
- package/dist/chunk-4EZ6A23C.js.map +1 -0
- package/dist/{chunk-3BNOZQIJ.js → chunk-KKAWMVEG.js} +11 -11
- package/dist/chunk-KKAWMVEG.js.map +1 -0
- package/dist/{chunk-FG2LRZP5.js → chunk-KOZAW264.js} +4 -3
- package/dist/chunk-KOZAW264.js.map +1 -0
- package/dist/{chunk-BWJVRYJT.js → chunk-KVPVEXWB.js} +40 -17
- package/dist/chunk-KVPVEXWB.js.map +1 -0
- package/dist/{chunk-BWKB52JB.js → chunk-LR64FLWO.js} +231 -379
- package/dist/chunk-LR64FLWO.js.map +1 -0
- package/dist/{chunk-SDKHWE7G.js → chunk-ZETPUEXH.js} +27 -2
- package/dist/chunk-ZETPUEXH.js.map +1 -0
- package/dist/{date-editor-CXKKGNL6.js → date-editor-QT47WY5T.js} +5 -3
- package/dist/date-editor-QT47WY5T.js.map +1 -0
- package/dist/{editor-props-M6Dh0P9f.d.ts → grid-cell-types-C3ARj148.d.cts} +70 -62
- package/dist/{editor-props-M6Dh0P9f.d.cts → grid-cell-types-C3ARj148.d.ts} +70 -62
- package/dist/index.cjs +564 -493
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -35
- package/dist/index.d.ts +86 -35
- package/dist/index.js +264 -72
- package/dist/index.js.map +1 -1
- package/dist/{sheets-context-9u9r7Bs0.d.ts → sheets-context-B03WDhZ9.d.cts} +13 -6
- package/dist/{sheets-context-BjGIHocT.d.cts → sheets-context-DmVCOgiX.d.ts} +13 -6
- package/dist/styles.css +6 -0
- package/dist/testing.cjs +99 -33
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +11 -7
- package/dist/testing.d.ts +11 -7
- package/dist/testing.js +34 -8
- package/dist/testing.js.map +1 -1
- package/package.json +15 -16
- package/dist/chunk-3BNOZQIJ.js.map +0 -1
- package/dist/chunk-BWJVRYJT.js.map +0 -1
- package/dist/chunk-BWKB52JB.js.map +0 -1
- package/dist/chunk-FG2LRZP5.js.map +0 -1
- package/dist/chunk-GLVZSPV2.js.map +0 -1
- package/dist/chunk-SDKHWE7G.js.map +0 -1
- package/dist/date-editor-CXKKGNL6.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
# @constructive-io/sheets
|
|
2
2
|
|
|
3
|
-
Portable spreadsheet-like CRUD editor for PostGraphile backends.
|
|
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
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
|
-
- **Backend**: Constructive server (`cnc server`)
|
|
7
|
+
- **Backend**: Constructive server (`cnc server`) exposing the `2026-07` `_meta` contract
|
|
8
8
|
- **Frontend**: React 18+, Tailwind CSS v4
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
13
|
npm install @constructive-io/sheets @constructive-io/data @constructive-io/ui \
|
|
14
|
-
@
|
|
14
|
+
@tanstack/react-query @tanstack/react-form
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
`lucide-react` and `@remixicon/react` are runtime dependencies of Sheets and
|
|
18
|
+
are installed transitively.
|
|
19
|
+
|
|
17
20
|
### Optional peer dependencies
|
|
18
21
|
|
|
19
22
|
| Package | For |
|
|
20
23
|
|---------|-----|
|
|
21
24
|
| `leaflet` + `react-leaflet` | Geometry/map editors |
|
|
22
25
|
| `react-aria-components` + `@internationalized/date` | Date picker editors |
|
|
23
|
-
| `lucide-react` | Icons |
|
|
24
|
-
| `@remixicon/react` | Icons |
|
|
25
26
|
|
|
26
27
|
## Quick Start
|
|
27
28
|
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
SheetsProvider, Sheets, SheetsTableSelector,
|
|
33
34
|
SheetsAuthGate, useSheetsMeta,
|
|
34
35
|
} from '@constructive-io/sheets';
|
|
36
|
+
import { selectConsoleDataTables } from '@constructive-io/data';
|
|
35
37
|
|
|
36
38
|
function SpreadsheetApp() {
|
|
37
39
|
const [activeTable, setActiveTable] = useState('');
|
|
@@ -40,10 +42,7 @@ function SpreadsheetApp() {
|
|
|
40
42
|
const tables = useMemo(() => {
|
|
41
43
|
const metaTables = meta?._meta?.tables;
|
|
42
44
|
if (!metaTables?.length) return [];
|
|
43
|
-
return metaTables
|
|
44
|
-
.filter((t): t is NonNullable<typeof t> => Boolean(t?.name))
|
|
45
|
-
.map((t) => ({ name: t.name }))
|
|
46
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
45
|
+
return selectConsoleDataTables(metaTables).map(({ name }) => ({ name }));
|
|
47
46
|
}, [meta?._meta?.tables]);
|
|
48
47
|
|
|
49
48
|
return (
|
|
@@ -85,6 +84,9 @@ function MySpreadsheet() {
|
|
|
85
84
|
auth: {
|
|
86
85
|
mode: 'embedded',
|
|
87
86
|
getToken: () => localStorage.getItem('my-jwt-token'),
|
|
87
|
+
// A stable user/session id isolates the React Query cache without
|
|
88
|
+
// putting the bearer token into query keys or devtools.
|
|
89
|
+
getIdentityKey: () => currentUser.id,
|
|
88
90
|
},
|
|
89
91
|
onAuthError: () => {
|
|
90
92
|
// Handle 401 — clear tokens, redirect to login, etc.
|
|
@@ -98,7 +100,7 @@ function MySpreadsheet() {
|
|
|
98
100
|
|
|
99
101
|
## CSS Setup
|
|
100
102
|
|
|
101
|
-
Sheets requires Tailwind CSS v4
|
|
103
|
+
Sheets requires Tailwind CSS v4.
|
|
102
104
|
|
|
103
105
|
### 1. Install Tailwind v4
|
|
104
106
|
|
|
@@ -112,22 +114,14 @@ npm install tailwindcss @tailwindcss/postcss
|
|
|
112
114
|
/* globals.css */
|
|
113
115
|
@import 'tailwindcss';
|
|
114
116
|
@import '@constructive-io/ui/globals.css';
|
|
115
|
-
|
|
116
|
-
/* Scan sheets + ui packages for Tailwind classes */
|
|
117
|
-
@source "../node_modules/@constructive-io/ui/src";
|
|
118
|
-
@source "../node_modules/@constructive-io/sheets/src";
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Then import the glide-data-grid CSS in your layout or entry component (not in the Tailwind CSS file):
|
|
122
|
-
|
|
123
|
-
```tsx
|
|
124
|
-
// app/layout.tsx
|
|
125
|
-
import '@glideapps/glide-data-grid/dist/index.css';
|
|
117
|
+
@import '@constructive-io/sheets/styles.css';
|
|
126
118
|
```
|
|
127
119
|
|
|
128
|
-
|
|
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.
|
|
129
123
|
|
|
130
|
-
|
|
124
|
+
Overlay editors render into a portal. Add this as the last child of `<body>` in your root layout:
|
|
131
125
|
|
|
132
126
|
```tsx
|
|
133
127
|
// app/layout.tsx
|
|
@@ -137,7 +131,7 @@ Glide Data Grid renders overlay editors into a portal. Add this as the last chil
|
|
|
137
131
|
</body>
|
|
138
132
|
```
|
|
139
133
|
|
|
140
|
-
Without this,
|
|
134
|
+
Without this, overlay editors such as date, relation, and JSON editors won't open.
|
|
141
135
|
|
|
142
136
|
## Configuration
|
|
143
137
|
|
|
@@ -147,6 +141,7 @@ The `SheetsConfig` object passed to `<SheetsProvider>`:
|
|
|
147
141
|
|------|------|----------|-------------|
|
|
148
142
|
| `endpoint` | `string` | Yes | PostGraphile GraphQL endpoint URL |
|
|
149
143
|
| `auth` | `SheetsAuthEmbedded \| SheetsAuthStandalone` | Yes | Auth mode |
|
|
144
|
+
| `auth.getIdentityKey` | `() => string \| null` | Embedded | Stable non-secret user/session cache identity; an opaque token-generation key is used when omitted |
|
|
150
145
|
| `authEndpoint` | `string` | No | Separate auth GraphQL endpoint |
|
|
151
146
|
| `databaseId` | `string` | No | Multi-tenant database scope |
|
|
152
147
|
| `fieldTypeOverrides` | `Record<string, string>` | No | Override detected field types |
|