kirby-types 1.3.1 → 1.4.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/index.d.ts CHANGED
@@ -10,26 +10,7 @@ export type {
10
10
  } from "./src/blocks";
11
11
 
12
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";
13
+ export type * from "./src/blueprint";
33
14
 
34
15
  // KQL types
35
16
  export type {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kirby-types",
3
3
  "type": "module",
4
- "version": "1.3.1",
4
+ "version": "1.4.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>",
@@ -110,12 +110,12 @@ export interface KirbyFieldProps {
110
110
  // =============================================================================
111
111
 
112
112
  /**
113
- * Props for text and textarea fields.
113
+ * Props for text fields.
114
114
  *
115
115
  * @see https://getkirby.com/docs/reference/panel/fields/text
116
116
  */
117
117
  export interface KirbyTextFieldProps extends KirbyFieldProps {
118
- type: "text" | "textarea" | "slug" | "url" | "email" | "tel";
118
+ type: "text" | "slug" | "url" | "email" | "tel";
119
119
  /** Value converter: `lower`, `upper`, `ucfirst`, `slug` */
120
120
  converter?: "lower" | "upper" | "ucfirst" | "slug";
121
121
  /** Whether to show character counter */
@@ -133,6 +133,34 @@ export interface KirbyTextFieldProps extends KirbyFieldProps {
133
133
  value?: string;
134
134
  }
135
135
 
136
+ /**
137
+ * Props for textarea fields.
138
+ *
139
+ * @see https://getkirby.com/docs/reference/panel/fields/textarea
140
+ */
141
+ export interface KirbyTextareaFieldProps extends KirbyFieldProps {
142
+ type: "textarea";
143
+ /** Format buttons: true/false or array of allowed buttons (headlines, italic, bold, link, email, file, code, ul, ol) */
144
+ buttons?: boolean | string[];
145
+ /** Whether to show character counter */
146
+ counter: boolean;
147
+ /** File picker options (query string or config object) */
148
+ files?: string | Record<string, any>;
149
+ /** Font family: `sans-serif` or `monospace` */
150
+ font: "sans-serif" | "monospace";
151
+ /** Maximum character length */
152
+ maxlength?: number;
153
+ /** Minimum character length */
154
+ minlength?: number;
155
+ /** Textarea size */
156
+ size?: "small" | "medium" | "large" | "huge";
157
+ /** Whether spellcheck is enabled */
158
+ spellcheck: boolean;
159
+ /** Upload configuration */
160
+ uploads?: false | string | Record<string, any>;
161
+ value?: string;
162
+ }
163
+
136
164
  /**
137
165
  * Props for number fields.
138
166
  *
@@ -200,6 +228,8 @@ export interface KirbyDateFieldProps extends KirbyFieldProps {
200
228
  calendar?: boolean;
201
229
  /** Date/time display format (dayjs tokens) */
202
230
  display?: string;
231
+ /** Storage format for the value (from datetime mixin) */
232
+ format?: string;
203
233
  /** Maximum date/time */
204
234
  max?: string;
205
235
  /** Minimum date/time */
@@ -243,6 +273,8 @@ export interface KirbyFilesFieldProps extends KirbyFieldProps {
243
273
  image?: Record<string, any>;
244
274
  /** Info text template for each item */
245
275
  info?: string;
276
+ /** Display layout for selected items */
277
+ layout?: "list" | "cardlets" | "cards";
246
278
  /** Whether each item should be clickable */
247
279
  link?: boolean;
248
280
  /** Maximum number of items */
@@ -255,10 +287,16 @@ export interface KirbyFilesFieldProps extends KirbyFieldProps {
255
287
  query?: string;
256
288
  /** Whether to show search field in picker */
257
289
  search?: boolean;
290
+ /** Layout size for cards */
291
+ size?: "tiny" | "small" | "medium" | "large" | "huge" | "full" | "auto";
258
292
  /** Whether to store `"uuid"` or `"id"` in content file */
259
293
  store?: "uuid" | "id";
294
+ /** Include subpages in picker (pages field only) */
295
+ subpages?: boolean;
260
296
  /** Text template for each item */
261
297
  text?: string;
298
+ /** Upload configuration (files field only) */
299
+ uploads?: false | string | Record<string, any>;
262
300
  /** Selected items (transformed picker data, not raw IDs) */
263
301
  value?: KirbyPickerItem[];
264
302
  }
@@ -446,6 +484,8 @@ export interface KirbyBlocksFieldProps extends KirbyFieldProps {
446
484
  max?: number;
447
485
  /** Minimum number of blocks */
448
486
  min?: number;
487
+ /** Format JSON output with indentation */
488
+ pretty?: boolean;
449
489
  value?: KirbyBlockValue[];
450
490
  }
451
491
 
@@ -488,7 +528,7 @@ export interface KirbyLayoutFieldProps extends KirbyFieldProps {
488
528
  export interface KirbyWriterFieldProps extends KirbyFieldProps {
489
529
  type: "writer";
490
530
  /** Whether to show character counter */
491
- counter?: boolean;
531
+ counter: boolean;
492
532
  /** Available heading levels (1-6) */
493
533
  headings?: number[];
494
534
  /** Whether only inline formatting is allowed */
@@ -506,6 +546,61 @@ export interface KirbyWriterFieldProps extends KirbyFieldProps {
506
546
  value?: string;
507
547
  }
508
548
 
549
+ /**
550
+ * Props for entries fields.
551
+ * A simplified structure field for single-field entries.
552
+ *
553
+ * @since Kirby 5.0.0
554
+ * @see https://getkirby.com/docs/reference/panel/fields/entries
555
+ */
556
+ export interface KirbyEntriesFieldProps extends KirbyFieldProps {
557
+ type: "entries";
558
+ /** Placeholder text when no entries exist */
559
+ empty?: string;
560
+ /** Single field definition for entry items */
561
+ field: KirbyFieldProps;
562
+ /** Maximum number of entries */
563
+ max?: number;
564
+ /** Minimum number of entries */
565
+ min?: number;
566
+ /** Whether entries are sortable via drag & drop */
567
+ sortable?: boolean;
568
+ value?: any[];
569
+ }
570
+
571
+ /**
572
+ * Stats report item for the stats field.
573
+ */
574
+ export interface KirbyStatsReport {
575
+ /** Report label */
576
+ label: string;
577
+ /** Report value */
578
+ value: string | number;
579
+ /** Additional info text */
580
+ info?: string;
581
+ /** Link URL */
582
+ link?: string;
583
+ /** Icon identifier */
584
+ icon?: string;
585
+ /** Color theme */
586
+ theme?: string;
587
+ }
588
+
589
+ /**
590
+ * Props for stats fields.
591
+ * Display stats/metrics as cards.
592
+ *
593
+ * @since Kirby 5.1.0
594
+ * @see https://getkirby.com/docs/reference/panel/fields/stats
595
+ */
596
+ export interface KirbyStatsFieldProps extends KirbyFieldProps {
597
+ type: "stats";
598
+ /** Array of report objects or query string */
599
+ reports: KirbyStatsReport[] | string;
600
+ /** Card size */
601
+ size?: "tiny" | "small" | "medium" | "large";
602
+ }
603
+
509
604
  // =============================================================================
510
605
  // Block & Layout Values
511
606
  // =============================================================================
@@ -644,6 +739,7 @@ export interface KirbyFieldsetGroup {
644
739
  export type KirbyAnyFieldProps =
645
740
  | KirbyFieldProps
646
741
  | KirbyTextFieldProps
742
+ | KirbyTextareaFieldProps
647
743
  | KirbyNumberFieldProps
648
744
  | KirbyOptionsFieldProps
649
745
  | KirbyToggleFieldProps
@@ -655,6 +751,8 @@ export type KirbyAnyFieldProps =
655
751
  | KirbyLinkFieldProps
656
752
  | KirbyStructureFieldProps
657
753
  | KirbyObjectFieldProps
754
+ | KirbyEntriesFieldProps
658
755
  | KirbyBlocksFieldProps
659
756
  | KirbyLayoutFieldProps
660
- | KirbyWriterFieldProps;
757
+ | KirbyWriterFieldProps
758
+ | KirbyStatsFieldProps;
@@ -18,7 +18,15 @@
18
18
  * @since 4.0.0
19
19
  */
20
20
 
21
- import type { ComponentPublicInstance, VueConstructor } from "vue";
21
+ import type {
22
+ ComponentOptions,
23
+ DefineComponent,
24
+ PluginFunction,
25
+ PluginObject,
26
+ VNode,
27
+ VueConstructor,
28
+ h as VueH,
29
+ } from "vue";
22
30
  import type { PanelApi } from "./api";
23
31
  import type {
24
32
  PanelContext,
@@ -222,6 +230,32 @@ export type PanelApp = InstanceType<VueConstructor> & {
222
230
  $esc: (string: string) => string;
223
231
  };
224
232
 
233
+ // =============================================================================
234
+ // Plugin Component Types
235
+ // =============================================================================
236
+
237
+ /**
238
+ * Vue component options for Panel plugin extensions.
239
+ *
240
+ * Components can be defined as:
241
+ * - Vue component options object with template or render function
242
+ * - Component that extends another component by name
243
+ */
244
+ export type PanelComponentExtension =
245
+ | DefineComponent
246
+ | ComponentOptions<any>
247
+ | {
248
+ /** Extend another component by name (e.g., `"k-text-field"`) */
249
+ extends?: string | DefineComponent;
250
+ /** Named mixins (e.g., `"dialog"`, `"drawer"`, `"section"`) or component objects */
251
+ mixins?: (string | ComponentOptions<any>)[];
252
+ /** Template string */
253
+ template?: string;
254
+ /** Render function */
255
+ render?: (h: typeof VueH) => VNode;
256
+ [key: string]: any;
257
+ };
258
+
225
259
  // =============================================================================
226
260
  // Panel Configuration
227
261
  // =============================================================================
@@ -421,6 +455,175 @@ export interface PanelRequestResponse {
421
455
  };
422
456
  }
423
457
 
458
+ // =============================================================================
459
+ // Panel Plugin Extensions (window.panel.plugin)
460
+ // =============================================================================
461
+
462
+ /**
463
+ * Extensions object passed to `window.panel.plugin()`.
464
+ *
465
+ * @example
466
+ * ```ts
467
+ * window.panel.plugin("my-plugin", {
468
+ * // Custom block types
469
+ * blocks: {
470
+ * video: `<k-block-video :source="content.source" />`
471
+ * },
472
+ *
473
+ * // Custom field types
474
+ * fields: {
475
+ * "color-picker": {
476
+ * extends: "k-text-field",
477
+ * template: `<k-field v-bind="$props">...</k-field>`
478
+ * }
479
+ * },
480
+ *
481
+ * // Custom sections
482
+ * sections: {
483
+ * stats: {
484
+ * template: `<div>{{ data }}</div>`
485
+ * }
486
+ * },
487
+ *
488
+ * // Textarea toolbar buttons
489
+ * textareaButtons: {
490
+ * timestamp: {
491
+ * label: "Insert Timestamp",
492
+ * icon: "clock",
493
+ * click() {
494
+ * this.command("insert", () => new Date().toISOString());
495
+ * }
496
+ * }
497
+ * },
498
+ *
499
+ * // Writer marks and nodes
500
+ * writerMarks: {
501
+ * highlight: {
502
+ * button: { icon: "highlight", label: "Highlight" },
503
+ * schema: {
504
+ * parseDOM: [{ tag: "mark" }],
505
+ * toDOM: () => ["mark", 0]
506
+ * }
507
+ * }
508
+ * }
509
+ * });
510
+ * ```
511
+ *
512
+ * @see https://getkirby.com/docs/reference/plugins/extensions
513
+ */
514
+ export interface PanelPluginExtensions {
515
+ /**
516
+ * Custom block types for the blocks field.
517
+ *
518
+ * Can be either a template string (shorthand) or a component options object.
519
+ * Registered as `k-block-type-${name}` components that automatically
520
+ * extend `k-block-type-default`.
521
+ *
522
+ * @see https://getkirby.com/docs/reference/plugins/extensions/blocks
523
+ */
524
+ blocks?: Record<string, string | PanelComponentExtension>;
525
+
526
+ /**
527
+ * Vue components to register globally in the Panel.
528
+ *
529
+ * @see https://getkirby.com/docs/reference/plugins/extensions/components
530
+ */
531
+ components?: Record<string, PanelComponentExtension>;
532
+
533
+ /**
534
+ * Custom field types.
535
+ *
536
+ * Registered as `k-${name}-field` components.
537
+ *
538
+ * @see https://getkirby.com/docs/reference/plugins/extensions/fields
539
+ */
540
+ fields?: Record<string, PanelComponentExtension>;
541
+
542
+ /**
543
+ * SVG icon definitions.
544
+ *
545
+ * @see https://getkirby.com/docs/reference/plugins/extensions/icons
546
+ */
547
+ icons?: Record<string, string>;
548
+
549
+ /**
550
+ * Custom section types.
551
+ *
552
+ * Registered as `k-${name}-section` components.
553
+ * The `section` mixin is automatically prepended to the mixins array.
554
+ *
555
+ * @see https://getkirby.com/docs/reference/plugins/extensions/sections
556
+ */
557
+ sections?: Record<string, PanelComponentExtension>;
558
+
559
+ /**
560
+ * View button components.
561
+ *
562
+ * Registered as `k-${name}-view-button` components.
563
+ *
564
+ * @see https://getkirby.com/docs/reference/plugins/extensions/view-buttons
565
+ */
566
+ viewButtons?: Record<string, PanelComponentExtension>;
567
+
568
+ /**
569
+ * Vue plugins to install via `Vue.use()`.
570
+ *
571
+ * Can be used to add global methods, directives, or mixins.
572
+ */
573
+ use?: Record<string, PluginObject<any> | PluginFunction<any>>;
574
+
575
+ /**
576
+ * Callback executed after the Panel Vue app is created.
577
+ *
578
+ * Receives the Vue app instance as parameter.
579
+ *
580
+ * @example
581
+ * ```ts
582
+ * window.panel.plugin("my-plugin", {
583
+ * created(app) {
584
+ * console.log("Panel app created", app);
585
+ * }
586
+ * });
587
+ * ```
588
+ */
589
+ created?: (app: PanelApp) => void;
590
+
591
+ /**
592
+ * Custom login form component.
593
+ *
594
+ * Replaces the default login form with a custom implementation.
595
+ */
596
+ login?: PanelComponentExtension;
597
+
598
+ /**
599
+ * Custom textarea toolbar buttons.
600
+ *
601
+ * @see https://getkirby.com/docs/reference/plugins/extensions/textarea-buttons
602
+ */
603
+ textareaButtons?: Record<string, TextareaButton>;
604
+
605
+ /**
606
+ * Arbitrary third-party plugin data.
607
+ *
608
+ * Can be used to pass configuration to other plugins.
609
+ */
610
+ thirdParty?: Record<string, any>;
611
+
612
+ /**
613
+ * Custom Writer inline formatting marks.
614
+ *
615
+ * @see https://getkirby.com/docs/reference/plugins/extensions/writer-marks
616
+ */
617
+ writerMarks?: Record<string, WriterMarkExtension>;
618
+
619
+ /**
620
+ * Custom Writer block-level nodes.
621
+ *
622
+ * @see https://getkirby.com/docs/reference/plugins/extensions/writer-nodes
623
+ */
624
+ writerNodes?: Record<string, WriterNodeExtension>;
625
+ }
626
+
424
627
  // =============================================================================
425
628
  // Panel Plugins
426
629
  // =============================================================================
@@ -465,11 +668,11 @@ export interface PanelPlugins {
465
668
  resolveComponentRender: (component: any) => any;
466
669
 
467
670
  // ---------------------------------------------------------------------------
468
- // Plugin Data (ordered as in panel/public/js/plugins.js)
671
+ // Plugin Data
469
672
  // ---------------------------------------------------------------------------
470
673
 
471
674
  /** Registered Vue components */
472
- components: Record<string, ComponentPublicInstance>;
675
+ components: Record<string, DefineComponent>;
473
676
 
474
677
  /** Callbacks to run after Panel creation */
475
678
  created: (() => void)[];
@@ -478,7 +681,7 @@ export interface PanelPlugins {
478
681
  icons: Record<string, string>;
479
682
 
480
683
  /** Custom login component (set dynamically by plugins) */
481
- login: ComponentPublicInstance | null;
684
+ login: DefineComponent | null;
482
685
 
483
686
  /** Registered Panel routes */
484
687
  routes: Record<string, any>[];
@@ -496,7 +699,7 @@ export interface PanelPlugins {
496
699
  use: any[];
497
700
 
498
701
  /** Registered view buttons */
499
- viewButtons: Record<string, ComponentPublicInstance | Record<string, any>>;
702
+ viewButtons: Record<string, DefineComponent | Record<string, any>>;
500
703
 
501
704
  /** Registered Panel views */
502
705
  views: Record<string, Record<string, any>>;
@@ -769,6 +972,37 @@ export interface Panel {
769
972
  */
770
973
  overlays: () => ("drawer" | "dialog")[];
771
974
 
975
+ /**
976
+ * Registers a Panel plugin with its extensions.
977
+ *
978
+ * @param name - Unique plugin identifier (typically vendor/plugin-name)
979
+ * @param extensions - Plugin extensions to register
980
+ *
981
+ * @example
982
+ * ```ts
983
+ * window.panel.plugin("my-plugin", {
984
+ * fields: {
985
+ * "color-picker": {
986
+ * extends: "k-text-field",
987
+ * template: `<k-field v-bind="$props">...</k-field>`
988
+ * }
989
+ * },
990
+ * textareaButtons: {
991
+ * timestamp: {
992
+ * label: "Insert Timestamp",
993
+ * icon: "clock",
994
+ * click() {
995
+ * this.command("insert", () => new Date().toISOString());
996
+ * }
997
+ * }
998
+ * }
999
+ * });
1000
+ * ```
1001
+ *
1002
+ * @see https://getkirby.com/docs/reference/plugins/extensions
1003
+ */
1004
+ plugin: (name: string, extensions: PanelPluginExtensions) => void;
1005
+
772
1006
  /**
773
1007
  * Sends a POST request through the Panel router.
774
1008
  *
@@ -268,7 +268,7 @@ export interface WriterToolbarButton {
268
268
  command?: string;
269
269
  /** Icon name from Kirby's icon set */
270
270
  icon: string;
271
- /** Display label (usually translated via `window.panel.$t()`) */
271
+ /** Display label (usually translated via `window.panel.t()`) */
272
272
  label: string;
273
273
  /** Extension name this button belongs to */
274
274
  name?: string;