kirby-types 1.0.0 → 1.1.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 +259 -40
- package/index.d.ts +18 -1
- package/package.json +37 -8
- package/src/api.d.ts +40 -0
- package/src/blocks.d.ts +254 -16
- package/src/kql.d.ts +127 -1
- package/src/layout.d.ts +96 -29
- package/src/panel/api.d.ts +1003 -0
- package/src/panel/base.d.ts +789 -0
- package/src/panel/features.d.ts +1543 -0
- package/src/panel/helpers.d.ts +1030 -0
- package/src/panel/index.d.ts +1008 -0
- package/src/panel/libraries.d.ts +456 -0
- package/src/panel/writer.d.ts +280 -0
- package/src/query.d.ts +4 -4
package/src/blocks.d.ts
CHANGED
|
@@ -1,36 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported code languages for the code block.
|
|
3
|
+
* @see https://github.com/getkirby/kirby/blob/main/config/blocks/code/code.yml
|
|
4
|
+
*/
|
|
5
|
+
export type KirbyCodeLanguage =
|
|
6
|
+
| "bash"
|
|
7
|
+
| "basic"
|
|
8
|
+
| "c"
|
|
9
|
+
| "clojure"
|
|
10
|
+
| "cpp"
|
|
11
|
+
| "csharp"
|
|
12
|
+
| "css"
|
|
13
|
+
| "diff"
|
|
14
|
+
| "elixir"
|
|
15
|
+
| "elm"
|
|
16
|
+
| "erlang"
|
|
17
|
+
| "go"
|
|
18
|
+
| "graphql"
|
|
19
|
+
| "haskell"
|
|
20
|
+
| "html"
|
|
21
|
+
| "java"
|
|
22
|
+
| "js"
|
|
23
|
+
| "json"
|
|
24
|
+
| "latext"
|
|
25
|
+
| "less"
|
|
26
|
+
| "lisp"
|
|
27
|
+
| "lua"
|
|
28
|
+
| "makefile"
|
|
29
|
+
| "markdown"
|
|
30
|
+
| "markup"
|
|
31
|
+
| "objectivec"
|
|
32
|
+
| "pascal"
|
|
33
|
+
| "perl"
|
|
34
|
+
| "php"
|
|
35
|
+
| "text"
|
|
36
|
+
| "python"
|
|
37
|
+
| "r"
|
|
38
|
+
| "ruby"
|
|
39
|
+
| "rust"
|
|
40
|
+
| "sass"
|
|
41
|
+
| "scss"
|
|
42
|
+
| "shell"
|
|
43
|
+
| "sql"
|
|
44
|
+
| "swift"
|
|
45
|
+
| "typescript"
|
|
46
|
+
| "vbnet"
|
|
47
|
+
| "xml"
|
|
48
|
+
| "yaml";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Maps each of Kirby's default block types to their corresponding content structure.
|
|
52
|
+
*
|
|
53
|
+
* @see https://getkirby.com/docs/reference/panel/blocks
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* // Access content type for a specific block
|
|
58
|
+
* type CodeContent = KirbyDefaultBlocks["code"];
|
|
59
|
+
* // Result: { code: string; language: KirbyCodeLanguage }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
1
62
|
export interface KirbyDefaultBlocks {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Code block for displaying syntax-highlighted code snippets.
|
|
65
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/code
|
|
66
|
+
*/
|
|
67
|
+
code: {
|
|
68
|
+
code: string;
|
|
69
|
+
language: KirbyCodeLanguage;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gallery block for displaying multiple images.
|
|
74
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/gallery
|
|
75
|
+
*/
|
|
76
|
+
gallery: {
|
|
77
|
+
images: string[];
|
|
78
|
+
caption: string | null;
|
|
79
|
+
ratio: string | null;
|
|
13
80
|
crop: boolean;
|
|
14
81
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Heading block for section titles.
|
|
85
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/heading
|
|
86
|
+
*/
|
|
87
|
+
heading: {
|
|
88
|
+
level: string;
|
|
89
|
+
text: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Image block for displaying a single image.
|
|
94
|
+
* Supports both internal Kirby files and external URLs.
|
|
95
|
+
* Uses a discriminated union based on `location` field.
|
|
96
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/image
|
|
97
|
+
*/
|
|
98
|
+
image:
|
|
99
|
+
| {
|
|
100
|
+
/** Internal Kirby image file. */
|
|
101
|
+
location: "kirby";
|
|
102
|
+
/** Internal Kirby file references. */
|
|
103
|
+
image: string[];
|
|
104
|
+
/** Alternative text for accessibility. */
|
|
105
|
+
alt: string | null;
|
|
106
|
+
/** Image caption (supports inline HTML). */
|
|
107
|
+
caption: string | null;
|
|
108
|
+
/** Link URL when image is clicked. */
|
|
109
|
+
link: string | null;
|
|
110
|
+
/** Aspect ratio constraint (e.g., `"16/9"`, `"1/1"`). */
|
|
111
|
+
ratio: string | null;
|
|
112
|
+
/** Whether to crop the image to fit the ratio. */
|
|
113
|
+
crop: boolean;
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
/** External image URL. */
|
|
117
|
+
location: "web";
|
|
118
|
+
/** External image URL. */
|
|
119
|
+
src: string;
|
|
120
|
+
/** Alternative text for accessibility. */
|
|
121
|
+
alt: string | null;
|
|
122
|
+
/** Image caption (supports inline HTML). */
|
|
123
|
+
caption: string | null;
|
|
124
|
+
/** Link URL when image is clicked. */
|
|
125
|
+
link: string | null;
|
|
126
|
+
/** Aspect ratio constraint (e.g., `"16/9"`, `"1/1"`). */
|
|
127
|
+
ratio: string | null;
|
|
128
|
+
/** Whether to crop the image to fit the ratio. */
|
|
129
|
+
crop: boolean;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Horizontal line/divider block.
|
|
134
|
+
* Has no content fields.
|
|
135
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/line
|
|
136
|
+
*/
|
|
137
|
+
line: Record<string, never>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* List block for bullet or numbered lists.
|
|
141
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/list
|
|
142
|
+
*/
|
|
143
|
+
list: {
|
|
144
|
+
text: string;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Markdown block for raw markdown content.
|
|
149
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/markdown
|
|
150
|
+
*/
|
|
151
|
+
markdown: {
|
|
152
|
+
text: string;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Quote block for blockquotes with optional citation.
|
|
157
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/quote
|
|
158
|
+
*/
|
|
159
|
+
quote: {
|
|
160
|
+
text: string;
|
|
161
|
+
/** Optional citation/attribution for the quote. */
|
|
162
|
+
citation?: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Table block for tabular data.
|
|
167
|
+
* Content structure is dynamic based on rows/columns.
|
|
168
|
+
*/
|
|
169
|
+
table: Record<string, unknown>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Rich text block (WYSIWYG editor).
|
|
173
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/text
|
|
174
|
+
*/
|
|
175
|
+
text: {
|
|
176
|
+
text: string;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Video block for embedding videos.
|
|
181
|
+
* Supports both internal Kirby files and external URLs (YouTube, Vimeo, etc.).
|
|
182
|
+
* Uses a discriminated union based on `location` field.
|
|
183
|
+
* @see https://getkirby.com/docs/reference/panel/blocks/video
|
|
184
|
+
*/
|
|
185
|
+
video:
|
|
186
|
+
| {
|
|
187
|
+
/** External video source. */
|
|
188
|
+
location: "web";
|
|
189
|
+
/** External video URL (YouTube, Vimeo, etc.). */
|
|
190
|
+
url: string;
|
|
191
|
+
/** Video caption (supports inline HTML). */
|
|
192
|
+
caption: string | null;
|
|
193
|
+
}
|
|
194
|
+
| {
|
|
195
|
+
/** Internal Kirby video file. */
|
|
196
|
+
location: "kirby";
|
|
197
|
+
/** Internal Kirby video file references. */
|
|
198
|
+
video: string[];
|
|
199
|
+
/** Poster image file references. */
|
|
200
|
+
poster: string[];
|
|
201
|
+
/** Video caption (supports inline HTML). */
|
|
202
|
+
caption: string | null;
|
|
203
|
+
/** Whether to autoplay the video. */
|
|
204
|
+
autoplay: boolean;
|
|
205
|
+
/** Whether to mute the video. */
|
|
206
|
+
muted: boolean;
|
|
207
|
+
/** Whether to loop the video. */
|
|
208
|
+
loop: boolean;
|
|
209
|
+
/** Whether to show video controls. */
|
|
210
|
+
controls: boolean;
|
|
211
|
+
/** Preload behavior. */
|
|
212
|
+
preload: "auto" | "metadata" | "none";
|
|
213
|
+
};
|
|
20
214
|
}
|
|
21
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Represents a Kirby block with its content, metadata, and type information.
|
|
218
|
+
*
|
|
219
|
+
* @typeParam T - The block type identifier. Defaults to any default block type.
|
|
220
|
+
* @typeParam U - Optional custom content structure. When provided, overrides the default content type.
|
|
221
|
+
*
|
|
222
|
+
* @see https://getkirby.com/docs/guide/page-builder
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* // Using a default block type
|
|
227
|
+
* const textBlock: KirbyBlock<"text"> = {
|
|
228
|
+
* id: "abc123",
|
|
229
|
+
* type: "text",
|
|
230
|
+
* isHidden: false,
|
|
231
|
+
* content: { text: "Hello world" }
|
|
232
|
+
* };
|
|
233
|
+
*
|
|
234
|
+
* // Using a custom block type
|
|
235
|
+
* const customBlock: KirbyBlock<"hero", { title: string; image: string }> = {
|
|
236
|
+
* id: "def456",
|
|
237
|
+
* type: "hero",
|
|
238
|
+
* isHidden: false,
|
|
239
|
+
* content: { title: "Welcome", image: "hero.jpg" }
|
|
240
|
+
* };
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
22
243
|
export interface KirbyBlock<
|
|
23
244
|
T extends string = keyof KirbyDefaultBlocks,
|
|
24
245
|
U extends Record<string, unknown> | undefined = undefined,
|
|
25
246
|
> {
|
|
247
|
+
/**
|
|
248
|
+
* The block's content fields.
|
|
249
|
+
* Structure depends on the block type or custom content definition.
|
|
250
|
+
*/
|
|
26
251
|
content: U extends Record<string, unknown>
|
|
27
252
|
? U
|
|
28
253
|
: T extends keyof KirbyDefaultBlocks
|
|
29
254
|
? KirbyDefaultBlocks[T]
|
|
30
255
|
: Record<string, never>;
|
|
256
|
+
/** Unique identifier for the block (UUID v4). */
|
|
31
257
|
id: string;
|
|
258
|
+
/** Whether the block is hidden in the frontend output. */
|
|
32
259
|
isHidden: boolean;
|
|
260
|
+
/** The block type identifier. */
|
|
33
261
|
type: T;
|
|
34
262
|
}
|
|
35
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Union type of all default Kirby block type names.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* function isDefaultBlock(type: string): type is KirbyDefaultBlockType {
|
|
270
|
+
* return ["code", "gallery", "heading", "image", "line", "list", "markdown", "quote", "table", "text", "video"].includes(type);
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
36
274
|
export type KirbyDefaultBlockType = keyof KirbyDefaultBlocks;
|
package/src/kql.d.ts
CHANGED
|
@@ -1,33 +1,159 @@
|
|
|
1
1
|
import type { KirbyApiResponse } from "./api";
|
|
2
2
|
import type { KirbyQuery } from "./query";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Defines the structure of a KQL (Kirby Query Language) query schema.
|
|
6
|
+
* Used for building nested, structured queries against Kirby content.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/getkirby/kql
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Simple query
|
|
13
|
+
* const schema: KirbyQuerySchema = {
|
|
14
|
+
* query: "site"
|
|
15
|
+
* };
|
|
16
|
+
*
|
|
17
|
+
* // Query with field selection
|
|
18
|
+
* const schemaWithSelect: KirbyQuerySchema = {
|
|
19
|
+
* query: "page",
|
|
20
|
+
* select: ["title", "url", "content"]
|
|
21
|
+
* };
|
|
22
|
+
*
|
|
23
|
+
* // Nested query with sub-selections
|
|
24
|
+
* const nestedSchema: KirbyQuerySchema = {
|
|
25
|
+
* query: "site.children",
|
|
26
|
+
* select: {
|
|
27
|
+
* title: true,
|
|
28
|
+
* url: true,
|
|
29
|
+
* children: {
|
|
30
|
+
* query: "page.children",
|
|
31
|
+
* select: ["title", "url"]
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
4
37
|
export interface KirbyQuerySchema {
|
|
38
|
+
/** The KQL query string to execute. */
|
|
5
39
|
query: KirbyQuery;
|
|
40
|
+
/**
|
|
41
|
+
* Fields to select from the query result.
|
|
42
|
+
* Can be an array of field names or an object for nested queries.
|
|
43
|
+
*/
|
|
6
44
|
select?:
|
|
7
45
|
| string[]
|
|
8
46
|
| Record<string, string | number | boolean | KirbyQuerySchema>;
|
|
9
47
|
}
|
|
10
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Represents a complete KQL request with optional pagination.
|
|
51
|
+
* Extends {@link KirbyQuerySchema} with pagination options.
|
|
52
|
+
*
|
|
53
|
+
* @see https://github.com/getkirby/kql
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* // Paginated request for blog posts
|
|
58
|
+
* const request: KirbyQueryRequest = {
|
|
59
|
+
* query: 'page("blog").children.listed',
|
|
60
|
+
* select: {
|
|
61
|
+
* title: "page.title",
|
|
62
|
+
* date: "page.date.toDate",
|
|
63
|
+
* excerpt: "page.excerpt.kirbytext"
|
|
64
|
+
* },
|
|
65
|
+
* pagination: {
|
|
66
|
+
* limit: 10,
|
|
67
|
+
* page: 1
|
|
68
|
+
* }
|
|
69
|
+
* };
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
11
72
|
export interface KirbyQueryRequest extends KirbyQuerySchema {
|
|
73
|
+
/**
|
|
74
|
+
* Pagination options for limiting and offsetting results.
|
|
75
|
+
*/
|
|
12
76
|
pagination?: {
|
|
13
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Maximum number of items to return.
|
|
79
|
+
* @default 100
|
|
80
|
+
*/
|
|
14
81
|
limit?: number;
|
|
82
|
+
/** Page number to retrieve (1-indexed). */
|
|
15
83
|
page?: number;
|
|
16
84
|
};
|
|
17
85
|
}
|
|
18
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Represents the response from a KQL query.
|
|
89
|
+
* Wraps the result in a {@link KirbyApiResponse} with optional pagination metadata.
|
|
90
|
+
*
|
|
91
|
+
* @typeParam T - The type of the result data.
|
|
92
|
+
* @typeParam Pagination - Whether pagination metadata is included. When `true`, the result is wrapped in `{ data, pagination }`.
|
|
93
|
+
*
|
|
94
|
+
* @see https://github.com/getkirby/kql
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* // Response without pagination
|
|
99
|
+
* interface Page {
|
|
100
|
+
* title: string;
|
|
101
|
+
* url: string;
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* const response: KirbyQueryResponse<Page> = {
|
|
105
|
+
* code: 200,
|
|
106
|
+
* status: "ok",
|
|
107
|
+
* result: { title: "Home", url: "/" }
|
|
108
|
+
* };
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* // Response with pagination
|
|
114
|
+
* interface Post {
|
|
115
|
+
* title: string;
|
|
116
|
+
* date: string;
|
|
117
|
+
* }
|
|
118
|
+
*
|
|
119
|
+
* const paginatedResponse: KirbyQueryResponse<Post[], true> = {
|
|
120
|
+
* code: 200,
|
|
121
|
+
* status: "ok",
|
|
122
|
+
* result: {
|
|
123
|
+
* data: [
|
|
124
|
+
* { title: "Post 1", date: "2024-01-01" },
|
|
125
|
+
* { title: "Post 2", date: "2024-01-02" }
|
|
126
|
+
* ],
|
|
127
|
+
* pagination: {
|
|
128
|
+
* page: 1,
|
|
129
|
+
* pages: 5,
|
|
130
|
+
* offset: 0,
|
|
131
|
+
* limit: 10,
|
|
132
|
+
* total: 50
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* };
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
19
138
|
export type KirbyQueryResponse<
|
|
20
139
|
T = any,
|
|
21
140
|
Pagination extends boolean = false,
|
|
22
141
|
> = KirbyApiResponse<
|
|
23
142
|
Pagination extends true
|
|
24
143
|
? {
|
|
144
|
+
/** The query result data. */
|
|
25
145
|
data: T;
|
|
146
|
+
/** Pagination metadata. */
|
|
26
147
|
pagination: {
|
|
148
|
+
/** Current page number (1-indexed). */
|
|
27
149
|
page: number;
|
|
150
|
+
/** Total number of pages. */
|
|
28
151
|
pages: number;
|
|
152
|
+
/** Number of items skipped (offset). */
|
|
29
153
|
offset: number;
|
|
154
|
+
/** Maximum items per page. */
|
|
30
155
|
limit: number;
|
|
156
|
+
/** Total number of items across all pages. */
|
|
31
157
|
total: number;
|
|
32
158
|
};
|
|
33
159
|
}
|
package/src/layout.d.ts
CHANGED
|
@@ -1,41 +1,108 @@
|
|
|
1
1
|
import type { KirbyBlock } from "./blocks";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Valid column width values for Kirby layouts.
|
|
5
|
+
* Expressed as fractions (e.g., `"1/2"` for half width).
|
|
6
|
+
*
|
|
7
|
+
* @see https://getkirby.com/docs/reference/panel/fields/layout#defining-your-own-layouts__available-widths
|
|
8
|
+
*/
|
|
9
|
+
export type KirbyLayoutColumnWidth =
|
|
10
|
+
| "1/1"
|
|
11
|
+
| "1/2"
|
|
12
|
+
| "1/3"
|
|
13
|
+
| "1/4"
|
|
14
|
+
| "1/6"
|
|
15
|
+
| "1/12"
|
|
16
|
+
| "2/2"
|
|
17
|
+
| "2/3"
|
|
18
|
+
| "2/4"
|
|
19
|
+
| "2/6"
|
|
20
|
+
| "2/12"
|
|
21
|
+
| "3/3"
|
|
22
|
+
| "3/4"
|
|
23
|
+
| "3/6"
|
|
24
|
+
| "3/12"
|
|
25
|
+
| "4/4"
|
|
26
|
+
| "4/6"
|
|
27
|
+
| "4/12"
|
|
28
|
+
| "5/6"
|
|
29
|
+
| "5/12"
|
|
30
|
+
| "6/6"
|
|
31
|
+
| "6/12"
|
|
32
|
+
| "7/12"
|
|
33
|
+
| "8/12"
|
|
34
|
+
| "9/12"
|
|
35
|
+
| "10/12"
|
|
36
|
+
| "11/12"
|
|
37
|
+
| "12/12";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Represents a single column within a Kirby layout row.
|
|
41
|
+
* Each column has a width and contains blocks.
|
|
42
|
+
*
|
|
43
|
+
* @see https://getkirby.com/docs/reference/panel/fields/layout
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const column: KirbyLayoutColumn = {
|
|
48
|
+
* id: "col-abc123",
|
|
49
|
+
* width: "1/2",
|
|
50
|
+
* blocks: [
|
|
51
|
+
* { id: "block-1", type: "text", isHidden: false, content: { text: "Hello" } }
|
|
52
|
+
* ]
|
|
53
|
+
* };
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
3
56
|
export interface KirbyLayoutColumn {
|
|
57
|
+
/** Unique identifier for the column (UUID v4). */
|
|
4
58
|
id: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
| "1/12"
|
|
12
|
-
| "2/2"
|
|
13
|
-
| "2/3"
|
|
14
|
-
| "2/4"
|
|
15
|
-
| "2/6"
|
|
16
|
-
| "2/12"
|
|
17
|
-
| "3/3"
|
|
18
|
-
| "3/4"
|
|
19
|
-
| "3/6"
|
|
20
|
-
| "3/12"
|
|
21
|
-
| "4/4"
|
|
22
|
-
| "4/6"
|
|
23
|
-
| "4/12"
|
|
24
|
-
| "5/6"
|
|
25
|
-
| "5/12"
|
|
26
|
-
| "6/6"
|
|
27
|
-
| "6/12"
|
|
28
|
-
| "7/12"
|
|
29
|
-
| "8/12"
|
|
30
|
-
| "9/12"
|
|
31
|
-
| "10/12"
|
|
32
|
-
| "11/12"
|
|
33
|
-
| "12/12";
|
|
59
|
+
/**
|
|
60
|
+
* Column width as a fraction.
|
|
61
|
+
* Common values: `"1/1"` (full), `"1/2"` (half), `"1/3"` (third), `"1/4"` (quarter).
|
|
62
|
+
*/
|
|
63
|
+
width: KirbyLayoutColumnWidth;
|
|
64
|
+
/** Array of blocks contained within this column. */
|
|
34
65
|
blocks: KirbyBlock[];
|
|
35
66
|
}
|
|
36
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Represents a Kirby layout row containing multiple columns.
|
|
70
|
+
* Layouts are used for flexible page building with a grid-based system.
|
|
71
|
+
*
|
|
72
|
+
* @see https://getkirby.com/docs/reference/panel/fields/layout
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const layout: KirbyLayout = {
|
|
77
|
+
* id: "layout-xyz789",
|
|
78
|
+
* attrs: { class: "highlight" },
|
|
79
|
+
* columns: [
|
|
80
|
+
* { id: "col-1", width: "1/2", blocks: [] },
|
|
81
|
+
* { id: "col-2", width: "1/2", blocks: [] }
|
|
82
|
+
* ]
|
|
83
|
+
* };
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* // Layout with empty attrs (as array)
|
|
89
|
+
* const simpleLayout: KirbyLayout = {
|
|
90
|
+
* id: "layout-abc",
|
|
91
|
+
* attrs: [],
|
|
92
|
+
* columns: [
|
|
93
|
+
* { id: "col-1", width: "1/1", blocks: [] }
|
|
94
|
+
* ]
|
|
95
|
+
* };
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
37
98
|
export interface KirbyLayout {
|
|
99
|
+
/** Unique identifier for the layout row (UUID v4). */
|
|
38
100
|
id: string;
|
|
101
|
+
/**
|
|
102
|
+
* Custom attributes for the layout row.
|
|
103
|
+
* Can be a key-value object or an empty array when no attrs are set.
|
|
104
|
+
*/
|
|
39
105
|
attrs: Record<string, any> | string[];
|
|
106
|
+
/** Array of columns in this layout row. */
|
|
40
107
|
columns: KirbyLayoutColumn[];
|
|
41
108
|
}
|