@createcms/core 0.2.0 → 0.2.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/dist/index.d.cts CHANGED
@@ -3856,6 +3856,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
3856
3856
  label: string;
3857
3857
  description?: string;
3858
3858
  previewImageUrl?: string;
3859
+ /**
3860
+ * Editor hint: the block-picker category this block is shown under (e.g.
3861
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
3862
+ * this label; the package never acts on it. Free-form by design; for
3863
+ * consistent, autocompleted group names across blocks, reference a shared
3864
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
3865
+ */
3866
+ group?: string;
3859
3867
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
3860
3868
  events?: TEvents;
3861
3869
  } & ({
package/dist/index.d.ts CHANGED
@@ -3856,6 +3856,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
3856
3856
  label: string;
3857
3857
  description?: string;
3858
3858
  previewImageUrl?: string;
3859
+ /**
3860
+ * Editor hint: the block-picker category this block is shown under (e.g.
3861
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
3862
+ * this label; the package never acts on it. Free-form by design; for
3863
+ * consistent, autocompleted group names across blocks, reference a shared
3864
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
3865
+ */
3866
+ group?: string;
3859
3867
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
3860
3868
  events?: TEvents;
3861
3869
  } & ({
@@ -62,6 +62,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
62
62
  label: string;
63
63
  description?: string;
64
64
  previewImageUrl?: string;
65
+ /**
66
+ * Editor hint: the block-picker category this block is shown under (e.g.
67
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
68
+ * this label; the package never acts on it. Free-form by design; for
69
+ * consistent, autocompleted group names across blocks, reference a shared
70
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
71
+ */
72
+ group?: string;
65
73
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
66
74
  events?: TEvents;
67
75
  } & ({
@@ -62,6 +62,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
62
62
  label: string;
63
63
  description?: string;
64
64
  previewImageUrl?: string;
65
+ /**
66
+ * Editor hint: the block-picker category this block is shown under (e.g.
67
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
68
+ * this label; the package never acts on it. Free-form by design; for
69
+ * consistent, autocompleted group names across blocks, reference a shared
70
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
71
+ */
72
+ group?: string;
65
73
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
66
74
  events?: TEvents;
67
75
  } & ({
@@ -323,6 +323,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
323
323
  label: string;
324
324
  description?: string;
325
325
  previewImageUrl?: string;
326
+ /**
327
+ * Editor hint: the block-picker category this block is shown under (e.g.
328
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
329
+ * this label; the package never acts on it. Free-form by design; for
330
+ * consistent, autocompleted group names across blocks, reference a shared
331
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
332
+ */
333
+ group?: string;
326
334
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
327
335
  events?: TEvents;
328
336
  } & ({
@@ -323,6 +323,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
323
323
  label: string;
324
324
  description?: string;
325
325
  previewImageUrl?: string;
326
+ /**
327
+ * Editor hint: the block-picker category this block is shown under (e.g.
328
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
329
+ * this label; the package never acts on it. Free-form by design; for
330
+ * consistent, autocompleted group names across blocks, reference a shared
331
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
332
+ */
333
+ group?: string;
326
334
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
327
335
  events?: TEvents;
328
336
  } & ({
@@ -226,6 +226,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
226
226
  label: string;
227
227
  description?: string;
228
228
  previewImageUrl?: string;
229
+ /**
230
+ * Editor hint: the block-picker category this block is shown under (e.g.
231
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
232
+ * this label; the package never acts on it. Free-form by design; for
233
+ * consistent, autocompleted group names across blocks, reference a shared
234
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
235
+ */
236
+ group?: string;
229
237
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
230
238
  events?: TEvents;
231
239
  } & ({
@@ -226,6 +226,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
226
226
  label: string;
227
227
  description?: string;
228
228
  previewImageUrl?: string;
229
+ /**
230
+ * Editor hint: the block-picker category this block is shown under (e.g.
231
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
232
+ * this label; the package never acts on it. Free-form by design; for
233
+ * consistent, autocompleted group names across blocks, reference a shared
234
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
235
+ */
236
+ group?: string;
229
237
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
230
238
  events?: TEvents;
231
239
  } & ({
@@ -227,6 +227,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
227
227
  label: string;
228
228
  description?: string;
229
229
  previewImageUrl?: string;
230
+ /**
231
+ * Editor hint: the block-picker category this block is shown under (e.g.
232
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
233
+ * this label; the package never acts on it. Free-form by design; for
234
+ * consistent, autocompleted group names across blocks, reference a shared
235
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
236
+ */
237
+ group?: string;
230
238
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
231
239
  events?: TEvents;
232
240
  } & ({
@@ -227,6 +227,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
227
227
  label: string;
228
228
  description?: string;
229
229
  previewImageUrl?: string;
230
+ /**
231
+ * Editor hint: the block-picker category this block is shown under (e.g.
232
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
233
+ * this label; the package never acts on it. Free-form by design; for
234
+ * consistent, autocompleted group names across blocks, reference a shared
235
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
236
+ */
237
+ group?: string;
230
238
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
231
239
  events?: TEvents;
232
240
  } & ({
@@ -225,6 +225,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
225
225
  label: string;
226
226
  description?: string;
227
227
  previewImageUrl?: string;
228
+ /**
229
+ * Editor hint: the block-picker category this block is shown under (e.g.
230
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
231
+ * this label; the package never acts on it. Free-form by design; for
232
+ * consistent, autocompleted group names across blocks, reference a shared
233
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
234
+ */
235
+ group?: string;
228
236
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
229
237
  events?: TEvents;
230
238
  } & ({
@@ -225,6 +225,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
225
225
  label: string;
226
226
  description?: string;
227
227
  previewImageUrl?: string;
228
+ /**
229
+ * Editor hint: the block-picker category this block is shown under (e.g.
230
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
231
+ * this label; the package never acts on it. Free-form by design; for
232
+ * consistent, autocompleted group names across blocks, reference a shared
233
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
234
+ */
235
+ group?: string;
228
236
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
229
237
  events?: TEvents;
230
238
  } & ({
@@ -52,7 +52,8 @@ function isResolvedReference(value) {
52
52
  return {
53
53
  __brand: 'BlocksMap',
54
54
  _components: components,
55
- _events: extractBlockEvents(collection.blocks)
55
+ _events: extractBlockEvents(collection.blocks),
56
+ _collection: collection
56
57
  };
57
58
  }
58
59
  // ============================================================================
@@ -133,6 +133,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
133
133
  label: string;
134
134
  description?: string;
135
135
  previewImageUrl?: string;
136
+ /**
137
+ * Editor hint: the block-picker category this block is shown under (e.g.
138
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
139
+ * this label; the package never acts on it. Free-form by design; for
140
+ * consistent, autocompleted group names across blocks, reference a shared
141
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
142
+ */
143
+ group?: string;
136
144
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
137
145
  events?: TEvents;
138
146
  } & ({
@@ -233,24 +241,33 @@ type BlockComponentProps<TProps extends Record<string, BlockProperty> = Record<s
233
241
  blockId: string;
234
242
  node: BlockTreeNode;
235
243
  };
236
- /** Shorthand to derive block component props from a collection definition. */
244
+ /** Shorthand to derive block component props from a collection definition.
245
+ * `blocks` is optional on `CollectionDefinition`, so the constraint accepts the
246
+ * optional shape and `NonNullable` resolves it — passing `typeof myCollection`
247
+ * directly works, and `TBlock` autocompletes the collection's block names. */
237
248
  type BlockProps<TCollection extends {
238
- blocks: Record<string, AnyBlockDefinition>;
239
- }, TBlock extends keyof TCollection['blocks'] & string> = BlockComponentProps<TCollection['blocks'][TBlock]['properties']>;
249
+ blocks?: Record<string, AnyBlockDefinition>;
250
+ }, TBlock extends keyof NonNullable<TCollection['blocks']> & string> = BlockComponentProps<NonNullable<TCollection['blocks']>[TBlock]['properties']>;
240
251
  type BlockComponentMap<TBlocks extends Record<string, AnyBlockDefinition>> = {
241
252
  [K in keyof TBlocks & string]: (props: BlockComponentProps<TBlocks[K]['properties']>) => ReactNode;
242
253
  };
243
254
  declare function isResolvedReference(value: unknown): value is ResolvedReference;
244
255
  /**
245
256
  * Opaque handle returned by `createBlocksMap`. Pass it to `<BlocksRenderer>`.
246
- * Carries the React component map AND the per-block-type event declarations
247
- * (the runtime half of the M2a typed-events seam) so the renderer can tell a
248
- * functional block (one that declared `events`) from a presentational one.
257
+ * Carries the React component map, the per-block-type event declarations (the
258
+ * runtime half of the M2a typed-events seam, so the renderer can tell a
259
+ * functional block from a presentational one), AND the collection definition
260
+ * itself. Bundling the collection means an editor can consume a single object
261
+ * for both rendering (`_components`) and schema/placement/grouping
262
+ * (`_collection`) — no separate `collection` handoff. The type parameter is
263
+ * preserved so that consumption stays typed; it defaults to the erased
264
+ * `AnyCollectionDefinition` for plain `BlocksMap` annotations.
249
265
  */
250
- type BlocksMap = {
266
+ type BlocksMap<TCollection = AnyCollectionDefinition> = {
251
267
  readonly __brand: 'BlocksMap';
252
268
  readonly _components: Record<string, (props: any) => ReactNode>;
253
269
  readonly _events: Record<string, Record<string, EventDeclaration>>;
270
+ readonly _collection: TCollection;
254
271
  };
255
272
  /**
256
273
  * Extracts the per-block-type event declarations from a collection definition —
@@ -282,7 +299,7 @@ declare function extractBlockEvents(blocks: Record<string, AnyBlockDefinition> |
282
299
  * });
283
300
  * ```
284
301
  */
285
- declare function createBlocksMap<TProps extends Record<string, BlockProperty>, TBlocks extends Record<string, AnyBlockDefinition>>(collection: CollectionDefinition<TProps, TBlocks>, components: BlockComponentMap<TBlocks>): BlocksMap;
302
+ declare function createBlocksMap<TProps extends Record<string, BlockProperty>, TBlocks extends Record<string, AnyBlockDefinition>>(collection: CollectionDefinition<TProps, TBlocks>, components: BlockComponentMap<TBlocks>): BlocksMap<CollectionDefinition<TProps, TBlocks>>;
286
303
  /**
287
304
  * Renders a `BlockTreeNode` tree using a block component map.
288
305
  *
@@ -133,6 +133,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
133
133
  label: string;
134
134
  description?: string;
135
135
  previewImageUrl?: string;
136
+ /**
137
+ * Editor hint: the block-picker category this block is shown under (e.g.
138
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
139
+ * this label; the package never acts on it. Free-form by design; for
140
+ * consistent, autocompleted group names across blocks, reference a shared
141
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
142
+ */
143
+ group?: string;
136
144
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
137
145
  events?: TEvents;
138
146
  } & ({
@@ -233,24 +241,33 @@ type BlockComponentProps<TProps extends Record<string, BlockProperty> = Record<s
233
241
  blockId: string;
234
242
  node: BlockTreeNode;
235
243
  };
236
- /** Shorthand to derive block component props from a collection definition. */
244
+ /** Shorthand to derive block component props from a collection definition.
245
+ * `blocks` is optional on `CollectionDefinition`, so the constraint accepts the
246
+ * optional shape and `NonNullable` resolves it — passing `typeof myCollection`
247
+ * directly works, and `TBlock` autocompletes the collection's block names. */
237
248
  type BlockProps<TCollection extends {
238
- blocks: Record<string, AnyBlockDefinition>;
239
- }, TBlock extends keyof TCollection['blocks'] & string> = BlockComponentProps<TCollection['blocks'][TBlock]['properties']>;
249
+ blocks?: Record<string, AnyBlockDefinition>;
250
+ }, TBlock extends keyof NonNullable<TCollection['blocks']> & string> = BlockComponentProps<NonNullable<TCollection['blocks']>[TBlock]['properties']>;
240
251
  type BlockComponentMap<TBlocks extends Record<string, AnyBlockDefinition>> = {
241
252
  [K in keyof TBlocks & string]: (props: BlockComponentProps<TBlocks[K]['properties']>) => ReactNode;
242
253
  };
243
254
  declare function isResolvedReference(value: unknown): value is ResolvedReference;
244
255
  /**
245
256
  * Opaque handle returned by `createBlocksMap`. Pass it to `<BlocksRenderer>`.
246
- * Carries the React component map AND the per-block-type event declarations
247
- * (the runtime half of the M2a typed-events seam) so the renderer can tell a
248
- * functional block (one that declared `events`) from a presentational one.
257
+ * Carries the React component map, the per-block-type event declarations (the
258
+ * runtime half of the M2a typed-events seam, so the renderer can tell a
259
+ * functional block from a presentational one), AND the collection definition
260
+ * itself. Bundling the collection means an editor can consume a single object
261
+ * for both rendering (`_components`) and schema/placement/grouping
262
+ * (`_collection`) — no separate `collection` handoff. The type parameter is
263
+ * preserved so that consumption stays typed; it defaults to the erased
264
+ * `AnyCollectionDefinition` for plain `BlocksMap` annotations.
249
265
  */
250
- type BlocksMap = {
266
+ type BlocksMap<TCollection = AnyCollectionDefinition> = {
251
267
  readonly __brand: 'BlocksMap';
252
268
  readonly _components: Record<string, (props: any) => ReactNode>;
253
269
  readonly _events: Record<string, Record<string, EventDeclaration>>;
270
+ readonly _collection: TCollection;
254
271
  };
255
272
  /**
256
273
  * Extracts the per-block-type event declarations from a collection definition —
@@ -282,7 +299,7 @@ declare function extractBlockEvents(blocks: Record<string, AnyBlockDefinition> |
282
299
  * });
283
300
  * ```
284
301
  */
285
- declare function createBlocksMap<TProps extends Record<string, BlockProperty>, TBlocks extends Record<string, AnyBlockDefinition>>(collection: CollectionDefinition<TProps, TBlocks>, components: BlockComponentMap<TBlocks>): BlocksMap;
302
+ declare function createBlocksMap<TProps extends Record<string, BlockProperty>, TBlocks extends Record<string, AnyBlockDefinition>>(collection: CollectionDefinition<TProps, TBlocks>, components: BlockComponentMap<TBlocks>): BlocksMap<CollectionDefinition<TProps, TBlocks>>;
286
303
  /**
287
304
  * Renders a `BlockTreeNode` tree using a block component map.
288
305
  *
@@ -50,7 +50,8 @@ function isResolvedReference(value) {
50
50
  return {
51
51
  __brand: 'BlocksMap',
52
52
  _components: components,
53
- _events: extractBlockEvents(collection.blocks)
53
+ _events: extractBlockEvents(collection.blocks),
54
+ _collection: collection
54
55
  };
55
56
  }
56
57
  // ============================================================================
@@ -229,6 +229,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
229
229
  label: string;
230
230
  description?: string;
231
231
  previewImageUrl?: string;
232
+ /**
233
+ * Editor hint: the block-picker category this block is shown under (e.g.
234
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
235
+ * this label; the package never acts on it. Free-form by design; for
236
+ * consistent, autocompleted group names across blocks, reference a shared
237
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
238
+ */
239
+ group?: string;
232
240
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
233
241
  events?: TEvents;
234
242
  } & ({
@@ -229,6 +229,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
229
229
  label: string;
230
230
  description?: string;
231
231
  previewImageUrl?: string;
232
+ /**
233
+ * Editor hint: the block-picker category this block is shown under (e.g.
234
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
235
+ * this label; the package never acts on it. Free-form by design; for
236
+ * consistent, autocompleted group names across blocks, reference a shared
237
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
238
+ */
239
+ group?: string;
232
240
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
233
241
  events?: TEvents;
234
242
  } & ({
@@ -147,6 +147,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
147
147
  label: string;
148
148
  description?: string;
149
149
  previewImageUrl?: string;
150
+ /**
151
+ * Editor hint: the block-picker category this block is shown under (e.g.
152
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
153
+ * this label; the package never acts on it. Free-form by design; for
154
+ * consistent, autocompleted group names across blocks, reference a shared
155
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
156
+ */
157
+ group?: string;
150
158
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
151
159
  events?: TEvents;
152
160
  } & ({
@@ -147,6 +147,14 @@ type BlockDefinition<TProps extends Record<string, BlockProperty> = Record<strin
147
147
  label: string;
148
148
  description?: string;
149
149
  previewImageUrl?: string;
150
+ /**
151
+ * Editor hint: the block-picker category this block is shown under (e.g.
152
+ * `'Forms'`, `'Layout'`). Purely presentational — the editor groups blocks by
153
+ * this label; the package never acts on it. Free-form by design; for
154
+ * consistent, autocompleted group names across blocks, reference a shared
155
+ * `as const` object (e.g. `group: BLOCK_GROUPS.forms`).
156
+ */
157
+ group?: string;
150
158
  /** Events this (functional) block can emit — see {@link EventDeclaration}. */
151
159
  events?: TEvents;
152
160
  } & ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@createcms/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "[Work in progress · pre-1.0 · not production-ready] Composable, block-based headless CMS powered by better-call and Drizzle ORM (Postgres). Database-native versioning with Git-like branches, copy-on-write drafts, visual diffs, merges, reusable blocks, nested pages, and a fully type-safe API.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/weepaho3/createCMS#readme",