kirby-types 1.2.0 → 1.3.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 +114 -10
- package/index.d.ts +22 -0
- package/package.json +7 -3
- package/src/blueprint.d.ts +660 -0
- package/src/panel/features.d.ts +8 -9
- package/src/panel/helpers.d.ts +3 -3
- package/src/panel/index.d.ts +72 -158
- package/src/panel/libraries.d.ts +11 -36
- package/src/panel/textarea.d.ts +254 -0
- package/src/panel/writer.d.ts +820 -13
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ yarn add -D kirby-types
|
|
|
45
45
|
<td>
|
|
46
46
|
|
|
47
47
|
- **API Response**: Type-safe API responses.
|
|
48
|
+
- **Blueprints**: Field definitions, fieldsets, and field options.
|
|
48
49
|
- **Blocks**: All 11 default block types with content structures.
|
|
49
50
|
- **Layouts**: Layout and column types with width unions.
|
|
50
51
|
- **KQL**: Query Language request/response types.
|
|
@@ -125,6 +126,73 @@ const response: KirbyApiResponse<PageData> = {
|
|
|
125
126
|
};
|
|
126
127
|
```
|
|
127
128
|
|
|
129
|
+
### Blueprints
|
|
130
|
+
|
|
131
|
+
Types for field props and fieldsets as returned by Kirby's `Field->toArray()` and `Fieldset->toArray()`:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import type {
|
|
135
|
+
KirbyFieldProps,
|
|
136
|
+
KirbyFieldsetProps,
|
|
137
|
+
KirbyOption,
|
|
138
|
+
KirbyTextFieldProps,
|
|
139
|
+
} from "kirby-types";
|
|
140
|
+
|
|
141
|
+
// Base field props (returned by Field->toArray())
|
|
142
|
+
const field: KirbyFieldProps = {
|
|
143
|
+
name: "title",
|
|
144
|
+
type: "text",
|
|
145
|
+
label: "Title",
|
|
146
|
+
required: true,
|
|
147
|
+
disabled: false,
|
|
148
|
+
hidden: false,
|
|
149
|
+
saveable: true,
|
|
150
|
+
translate: true,
|
|
151
|
+
autofocus: false,
|
|
152
|
+
width: "1/2",
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// Type-specific field props
|
|
156
|
+
const textField: KirbyTextFieldProps = {
|
|
157
|
+
...field,
|
|
158
|
+
type: "text",
|
|
159
|
+
counter: true,
|
|
160
|
+
font: "sans-serif",
|
|
161
|
+
spellcheck: false,
|
|
162
|
+
maxlength: 100,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Fieldset (block type definition from Fieldset->toArray())
|
|
166
|
+
const fieldset: KirbyFieldsetProps = {
|
|
167
|
+
disabled: false,
|
|
168
|
+
editable: true,
|
|
169
|
+
icon: "text",
|
|
170
|
+
label: null,
|
|
171
|
+
name: "Heading",
|
|
172
|
+
preview: "fields",
|
|
173
|
+
tabs: {
|
|
174
|
+
content: {
|
|
175
|
+
name: "content",
|
|
176
|
+
label: "Content",
|
|
177
|
+
fields: { text: field },
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
translate: true,
|
|
181
|
+
type: "heading",
|
|
182
|
+
unset: false,
|
|
183
|
+
wysiwyg: false,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// Option (from Option->render())
|
|
187
|
+
const option: KirbyOption = {
|
|
188
|
+
disabled: false,
|
|
189
|
+
icon: "page",
|
|
190
|
+
info: null,
|
|
191
|
+
text: "Draft",
|
|
192
|
+
value: "draft",
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
128
196
|
### Blocks
|
|
129
197
|
|
|
130
198
|
```ts
|
|
@@ -229,18 +297,25 @@ type Parsed = ParseKirbyQuery<'page.children.filterBy("status", "published")'>;
|
|
|
229
297
|
For ProseMirror-based Writer extensions (requires optional ProseMirror peer dependencies):
|
|
230
298
|
|
|
231
299
|
```ts
|
|
232
|
-
import type {
|
|
300
|
+
import type { WriterMarkExtension } from "kirby-types";
|
|
233
301
|
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
|
|
302
|
+
// Define a custom mark extension
|
|
303
|
+
const highlight: WriterMarkExtension = {
|
|
304
|
+
button: {
|
|
305
|
+
icon: "highlight",
|
|
306
|
+
label: "Highlight",
|
|
307
|
+
},
|
|
308
|
+
commands({ type, utils }) {
|
|
237
309
|
return () => utils.toggleMark(type);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
inputRules({ type, utils }: WriterMarkContext) {
|
|
310
|
+
},
|
|
311
|
+
inputRules({ type, utils }) {
|
|
241
312
|
return [utils.markInputRule(/\*\*([^*]+)\*\*$/, type)];
|
|
242
|
-
}
|
|
243
|
-
|
|
313
|
+
},
|
|
314
|
+
schema: {
|
|
315
|
+
parseDOM: [{ tag: "mark" }],
|
|
316
|
+
toDOM: () => ["mark", 0],
|
|
317
|
+
},
|
|
318
|
+
};
|
|
244
319
|
```
|
|
245
320
|
|
|
246
321
|
## API Reference
|
|
@@ -261,10 +336,15 @@ class Bold {
|
|
|
261
336
|
|
|
262
337
|
| Type | Description |
|
|
263
338
|
| --------------------------------------------------- | ---------------------------------- |
|
|
264
|
-
| [`
|
|
339
|
+
| [`WriterEditor`](./src/panel/writer.d.ts) | Main editor instance |
|
|
340
|
+
| [`WriterExtensions`](./src/panel/writer.d.ts) | Extensions manager |
|
|
341
|
+
| [`WriterExtension`](./src/panel/writer.d.ts) | Generic extension interface |
|
|
342
|
+
| [`WriterMarkExtension`](./src/panel/writer.d.ts) | Mark extension interface |
|
|
343
|
+
| [`WriterNodeExtension`](./src/panel/writer.d.ts) | Node extension interface |
|
|
265
344
|
| [`WriterMarkContext`](./src/panel/writer.d.ts) | Context for mark extensions |
|
|
266
345
|
| [`WriterNodeContext`](./src/panel/writer.d.ts) | Context for node extensions |
|
|
267
346
|
| [`WriterExtensionContext`](./src/panel/writer.d.ts) | Context for generic extensions |
|
|
347
|
+
| [`WriterUtils`](./src/panel/writer.d.ts) | ProseMirror commands and utilities |
|
|
268
348
|
|
|
269
349
|
### API
|
|
270
350
|
|
|
@@ -272,6 +352,30 @@ class Bold {
|
|
|
272
352
|
| --------------------------------------- | ------------------------------------- |
|
|
273
353
|
| [`KirbyApiResponse<T>`](./src/api.d.ts) | Standard Kirby API response structure |
|
|
274
354
|
|
|
355
|
+
### Blueprints
|
|
356
|
+
|
|
357
|
+
| Type | Description |
|
|
358
|
+
| -------------------------------------------------- | ---------------------------------------------- |
|
|
359
|
+
| [`KirbyAnyFieldProps`](./src/blueprint.d.ts) | Union of all field prop types |
|
|
360
|
+
| [`KirbyBlocksFieldProps`](./src/blueprint.d.ts) | Blocks field props with fieldsets |
|
|
361
|
+
| [`KirbyColorFieldProps`](./src/blueprint.d.ts) | Color picker field props |
|
|
362
|
+
| [`KirbyDateFieldProps`](./src/blueprint.d.ts) | Date and time field props |
|
|
363
|
+
| [`KirbyFieldProps`](./src/blueprint.d.ts) | Base field props from `Field->toArray()` |
|
|
364
|
+
| [`KirbyFieldsetProps`](./src/blueprint.d.ts) | Fieldset from `Fieldset->toArray()` |
|
|
365
|
+
| [`KirbyFilesFieldProps`](./src/blueprint.d.ts) | Files/pages/users picker field props |
|
|
366
|
+
| [`KirbyLayoutFieldProps`](./src/blueprint.d.ts) | Layout field props with fieldsets and settings |
|
|
367
|
+
| [`KirbyLinkFieldProps`](./src/blueprint.d.ts) | Link field props |
|
|
368
|
+
| [`KirbyNumberFieldProps`](./src/blueprint.d.ts) | Number field props |
|
|
369
|
+
| [`KirbyObjectFieldProps`](./src/blueprint.d.ts) | Object field props with nested fields |
|
|
370
|
+
| [`KirbyOption`](./src/blueprint.d.ts) | Option from `Option->render()` |
|
|
371
|
+
| [`KirbyOptionsFieldProps`](./src/blueprint.d.ts) | Select/radio/checkboxes/multiselect/toggles |
|
|
372
|
+
| [`KirbyRangeFieldProps`](./src/blueprint.d.ts) | Range slider field props |
|
|
373
|
+
| [`KirbyStructureFieldProps`](./src/blueprint.d.ts) | Structure field props with nested fields |
|
|
374
|
+
| [`KirbyTagsFieldProps`](./src/blueprint.d.ts) | Tags field props |
|
|
375
|
+
| [`KirbyTextFieldProps`](./src/blueprint.d.ts) | Text/textarea field props |
|
|
376
|
+
| [`KirbyToggleFieldProps`](./src/blueprint.d.ts) | Toggle (boolean) field props |
|
|
377
|
+
| [`KirbyWriterFieldProps`](./src/blueprint.d.ts) | Writer (rich text) field props |
|
|
378
|
+
|
|
275
379
|
### Blocks
|
|
276
380
|
|
|
277
381
|
| Type | Description |
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,28 @@ export type {
|
|
|
9
9
|
KirbyDefaultBlockType,
|
|
10
10
|
} from "./src/blocks";
|
|
11
11
|
|
|
12
|
+
// Blueprint types
|
|
13
|
+
export type {
|
|
14
|
+
KirbyAnyFieldProps,
|
|
15
|
+
KirbyBlocksFieldProps,
|
|
16
|
+
KirbyDateFieldProps,
|
|
17
|
+
KirbyFieldProps,
|
|
18
|
+
KirbyFieldsetGroup,
|
|
19
|
+
KirbyFieldsetProps,
|
|
20
|
+
KirbyFieldsetTab,
|
|
21
|
+
KirbyFilesFieldProps,
|
|
22
|
+
KirbyLayoutFieldProps,
|
|
23
|
+
KirbyNumberFieldProps,
|
|
24
|
+
KirbyObjectFieldProps,
|
|
25
|
+
KirbyOption,
|
|
26
|
+
KirbyOptionsFieldProps,
|
|
27
|
+
KirbyStructureColumn,
|
|
28
|
+
KirbyStructureFieldProps,
|
|
29
|
+
KirbyTextFieldProps,
|
|
30
|
+
KirbyToggleFieldProps,
|
|
31
|
+
KirbyWriterFieldProps,
|
|
32
|
+
} from "./src/blueprint";
|
|
33
|
+
|
|
12
34
|
// KQL types
|
|
13
35
|
export type {
|
|
14
36
|
KirbyQueryRequest,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kirby-types",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"packageManager": "pnpm@10.27.0",
|
|
6
6
|
"description": "TypeScript types for Kirby Panel plugins and headless CMS usage",
|
|
7
7
|
"author": "Johann Schopplich <hello@johannschopplich.com>",
|
|
@@ -43,13 +43,14 @@
|
|
|
43
43
|
"test": "tsd -f \"test/**/*.test-d.ts\""
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"dayjs": "^1.
|
|
46
|
+
"dayjs": "^1.11.13",
|
|
47
47
|
"prosemirror-commands": "^1.7.1",
|
|
48
48
|
"prosemirror-inputrules": "^1.5.1",
|
|
49
49
|
"prosemirror-model": "^1.25.4",
|
|
50
50
|
"prosemirror-schema-list": "^1.5.1",
|
|
51
51
|
"prosemirror-state": "^1.4.4",
|
|
52
|
-
"
|
|
52
|
+
"prosemirror-view": "^1.41.4",
|
|
53
|
+
"vue": "^2.7.16"
|
|
53
54
|
},
|
|
54
55
|
"peerDependenciesMeta": {
|
|
55
56
|
"dayjs": {
|
|
@@ -70,6 +71,9 @@
|
|
|
70
71
|
"prosemirror-state": {
|
|
71
72
|
"optional": true
|
|
72
73
|
},
|
|
74
|
+
"prosemirror-view": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
73
77
|
"vue": {
|
|
74
78
|
"optional": true
|
|
75
79
|
}
|