kirby-types 1.1.1 → 1.2.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,10 +1,15 @@
1
+ <div align="center">
2
+ <img src="./.github/favicon.svg" alt="kirby-types logo" width="144">
3
+
1
4
  # kirby-types
2
5
 
3
- A collection of TypeScript types for [Kirby CMS](https://getkirby.com), covering:
6
+ A collection of TypeScript types for [Kirby CMS](https://getkirby.com).
7
+
8
+ [Panel types](#panel-types) •
9
+ [Backend API types](#backend-types) •
10
+ [Block and layout types](#layouts)
4
11
 
5
- - 🪟 **Panel types** for Kirby Panel plugin development
6
- - 🔌 **Backend API types** for headless Kirby usage and KQL
7
- - 🧱 **Block and layout types** for page builder content
12
+ </div>
8
13
 
9
14
  ## Setup
10
15
 
@@ -21,7 +26,13 @@ yarn add -D kirby-types
21
26
 
22
27
  ## Features
23
28
 
24
- ### Panel Types
29
+ <table>
30
+ <tr>
31
+ <th>🪟 Panel Types</th>
32
+ <th>🔌 Backend Types</th>
33
+ </tr>
34
+ <tr>
35
+ <td>
25
36
 
26
37
  - **Panel API**: Complete API client method types.
27
38
  - **State Management**: State, Feature, and Modal hierarchies.
@@ -30,7 +41,8 @@ yarn add -D kirby-types
30
41
  - **Libraries**: Color manipulation, dayjs, and autosize types.
31
42
  - **Writer**: ProseMirror-based rich text editor utilities.
32
43
 
33
- ### Backend Types
44
+ </td>
45
+ <td>
34
46
 
35
47
  - **API Response**: Type-safe API responses.
36
48
  - **Blocks**: All 11 default block types with content structures.
@@ -38,6 +50,10 @@ yarn add -D kirby-types
38
50
  - **KQL**: Query Language request/response types.
39
51
  - **Query Parsing**: Parse query strings into structured objects at the type level.
40
52
 
53
+ </td>
54
+ </tr>
55
+ </table>
56
+
41
57
  ## Basic Usage
42
58
 
43
59
  ### Panel Types
@@ -87,25 +103,6 @@ const user = window.panel.user;
87
103
  console.log(user.email, user.role);
88
104
  ```
89
105
 
90
- ### Writer Extensions
91
-
92
- For ProseMirror-based Writer extensions (requires optional ProseMirror peer dependencies):
93
-
94
- ```ts
95
- import type { WriterMarkContext } from "kirby-types";
96
-
97
- // In a Writer mark extension
98
- class Bold {
99
- commands({ type, utils }: WriterMarkContext) {
100
- return () => utils.toggleMark(type);
101
- }
102
-
103
- inputRules({ type, utils }: WriterMarkContext) {
104
- return [utils.markInputRule(/\*\*([^*]+)\*\*$/, type)];
105
- }
106
- }
107
- ```
108
-
109
106
  ### API Responses
110
107
 
111
108
  ```ts
@@ -227,6 +224,25 @@ type Parsed = ParseKirbyQuery<'page.children.filterBy("status", "published")'>;
227
224
  // }
228
225
  ```
229
226
 
227
+ ### Writer Extensions
228
+
229
+ For ProseMirror-based Writer extensions (requires optional ProseMirror peer dependencies):
230
+
231
+ ```ts
232
+ import type { WriterMarkContext } from "kirby-types";
233
+
234
+ // In a Writer mark extension
235
+ class Bold {
236
+ commands({ type, utils }: WriterMarkContext) {
237
+ return () => utils.toggleMark(type);
238
+ }
239
+
240
+ inputRules({ type, utils }: WriterMarkContext) {
241
+ return [utils.markInputRule(/\*\*([^*]+)\*\*$/, type)];
242
+ }
243
+ }
244
+ ```
245
+
230
246
  ## API Reference
231
247
 
232
248
  ### Panel
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "kirby-types",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "packageManager": "pnpm@10.27.0",
6
- "description": "A collection of TypeScript types for the Kirby CMS",
6
+ "description": "TypeScript types for Kirby Panel plugins and headless CMS usage",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",
8
8
  "license": "MIT",
9
9
  "homepage": "https://github.com/johannschopplich/kirby-types#readme",
@@ -43,14 +43,18 @@
43
43
  "test": "tsd -f \"test/**/*.test-d.ts\""
44
44
  },
45
45
  "peerDependencies": {
46
- "prosemirror-commands": "^1.0.0",
47
- "prosemirror-inputrules": "^1.0.0",
48
- "prosemirror-model": "^1.0.0",
49
- "prosemirror-schema-list": "^1.0.0",
50
- "prosemirror-state": "^1.0.0",
46
+ "dayjs": "^1.0.0",
47
+ "prosemirror-commands": "^1.7.1",
48
+ "prosemirror-inputrules": "^1.5.1",
49
+ "prosemirror-model": "^1.25.4",
50
+ "prosemirror-schema-list": "^1.5.1",
51
+ "prosemirror-state": "^1.4.4",
51
52
  "vue": "^2.7.0"
52
53
  },
53
54
  "peerDependenciesMeta": {
55
+ "dayjs": {
56
+ "optional": true
57
+ },
54
58
  "prosemirror-commands": {
55
59
  "optional": true
56
60
  },
@@ -73,6 +77,7 @@
73
77
  "devDependencies": {
74
78
  "@antfu/eslint-config": "^6.7.3",
75
79
  "bumpp": "^10.3.2",
80
+ "dayjs": "^1.11.13",
76
81
  "eslint": "^9.39.2",
77
82
  "prettier": "^3.7.4",
78
83
  "tsd": "^0.33.0",
package/src/blocks.d.ts CHANGED
@@ -166,7 +166,7 @@ export interface KirbyDefaultBlocks {
166
166
  * Table block for tabular data.
167
167
  * Content structure is dynamic based on rows/columns.
168
168
  */
169
- table: Record<string, unknown>;
169
+ table: Record<string, any>;
170
170
 
171
171
  /**
172
172
  * Rich text block (WYSIWYG editor).
@@ -242,13 +242,13 @@ export interface KirbyDefaultBlocks {
242
242
  */
243
243
  export interface KirbyBlock<
244
244
  T extends string = keyof KirbyDefaultBlocks,
245
- U extends Record<string, unknown> | undefined = undefined,
245
+ U extends Record<string, any> | undefined = undefined,
246
246
  > {
247
247
  /**
248
248
  * The block's content fields.
249
249
  * Structure depends on the block type or custom content definition.
250
250
  */
251
- content: U extends Record<string, unknown>
251
+ content: U extends Record<string, any>
252
252
  ? U
253
253
  : T extends keyof KirbyDefaultBlocks
254
254
  ? KirbyDefaultBlocks[T]