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.
@@ -17,7 +17,7 @@
17
17
  export interface PanelArraySearchOptions {
18
18
  /** Minimum query length (default: 0) */
19
19
  min?: number;
20
- /** Field to search in (default: `'text'`) */
20
+ /** Field to search in (default: `"text"`) */
21
21
  field?: string;
22
22
  /** Maximum results to return */
23
23
  limit?: number;
@@ -45,7 +45,7 @@ export interface PanelHelpersArray {
45
45
  * @param options - Search options
46
46
  * @returns Filtered array
47
47
  */
48
- search: <T extends Record<string, unknown>>(
48
+ search: <T extends Record<string, any>>(
49
49
  array: T[],
50
50
  query: string,
51
51
  options?: PanelArraySearchOptions,
@@ -58,10 +58,7 @@ export interface PanelHelpersArray {
58
58
  * @param sortBy - Sort specification (e.g., `'name asc'`, `'date desc'`)
59
59
  * @returns Sorted array
60
60
  */
61
- sortBy: <T extends Record<string, unknown>>(
62
- array: T[],
63
- sortBy: string,
64
- ) => T[];
61
+ sortBy: <T extends Record<string, any>>(array: T[], sortBy: string) => T[];
65
62
 
66
63
  /**
67
64
  * Splits array into subarrays using delimiter element.
@@ -176,8 +173,8 @@ export interface PanelHelpersString {
176
173
  *
177
174
  * @param string - String to convert
178
175
  * @param rules - Language/ASCII conversion rules
179
- * @param allowed - Allowed characters (default: `'a-z0-9'`)
180
- * @param separator - Separator character (default: `'-'`)
176
+ * @param allowed - Allowed characters (default: `"a-z0-9"`)
177
+ * @param separator - Separator character (default: `"-"`)
181
178
  * @returns Slug string
182
179
  */
183
180
  slug: (
@@ -203,7 +200,7 @@ export interface PanelHelpersString {
203
200
  * @param values - Replacement values
204
201
  * @returns Interpolated string
205
202
  */
206
- template: (string: string, values?: Record<string, unknown>) => string;
203
+ template: (string: string, values?: Record<string, any>) => string;
207
204
 
208
205
  /**
209
206
  * Converts first letter to uppercase.
@@ -262,7 +259,7 @@ export interface PanelHelpersObject {
262
259
  * @param predicate - Filter function
263
260
  * @returns Filtered object
264
261
  */
265
- filter: <T extends Record<string, unknown>>(
262
+ filter: <T extends Record<string, any>>(
266
263
  object: T,
267
264
  predicate: (value: T[keyof T], key: string) => boolean,
268
265
  ) => Partial<T>;
@@ -273,7 +270,7 @@ export interface PanelHelpersObject {
273
270
  * @param value - Value to check
274
271
  * @returns True if empty
275
272
  */
276
- isEmpty: (value: unknown) => boolean;
273
+ isEmpty: (value: any) => boolean;
277
274
 
278
275
  /**
279
276
  * Checks if input is a plain object (not array, null, etc.).
@@ -281,7 +278,7 @@ export interface PanelHelpersObject {
281
278
  * @param input - Value to check
282
279
  * @returns True if plain object
283
280
  */
284
- isObject: (input: unknown) => input is Record<string, unknown>;
281
+ isObject: (input: any) => input is Record<string, any>;
285
282
 
286
283
  /**
287
284
  * Counts keys in an object.
@@ -289,7 +286,7 @@ export interface PanelHelpersObject {
289
286
  * @param object - Object to count
290
287
  * @returns Number of keys
291
288
  */
292
- length: (object: Record<string, unknown>) => number;
289
+ length: (object: Record<string, any>) => number;
293
290
 
294
291
  /**
295
292
  * Recursively merges source into target.
@@ -298,10 +295,7 @@ export interface PanelHelpersObject {
298
295
  * @param source - Source object
299
296
  * @returns Merged object
300
297
  */
301
- merge: <T extends Record<string, unknown>>(
302
- target: T,
303
- source?: Partial<T>,
304
- ) => T;
298
+ merge: <T extends Record<string, any>>(target: T, source?: Partial<T>) => T;
305
299
 
306
300
  /**
307
301
  * Compares objects by JSON stringification.
@@ -310,7 +304,7 @@ export interface PanelHelpersObject {
310
304
  * @param b - Second object
311
305
  * @returns True if identical
312
306
  */
313
- same: (a: unknown, b: unknown) => boolean;
307
+ same: (a: any, b: any) => boolean;
314
308
 
315
309
  /**
316
310
  * Converts all object keys to lowercase.
@@ -423,17 +417,18 @@ export interface PanelHelpersClipboard {
423
417
  *
424
418
  * @param event - ClipboardEvent or string
425
419
  * @param plain - Read as plain text only
426
- * @returns Clipboard content
420
+ * @returns Clipboard content or null if empty
427
421
  */
428
- read: (event: ClipboardEvent | string, plain?: boolean) => string;
422
+ read: (event: ClipboardEvent | string, plain?: boolean) => string | null;
429
423
 
430
424
  /**
431
425
  * Writes to clipboard. Objects are auto-JSONified.
432
426
  *
433
427
  * @param value - Value to write
434
428
  * @param event - ClipboardEvent for event-based writing
429
+ * @returns True if successful
435
430
  */
436
- write: (value: unknown, event?: ClipboardEvent) => void;
431
+ write: (value: any, event?: ClipboardEvent) => boolean;
437
432
  }
438
433
 
439
434
  // -----------------------------------------------------------------------------
@@ -451,27 +446,27 @@ export interface PanelHelpersEmbed {
451
446
  *
452
447
  * @param url - YouTube video URL
453
448
  * @param doNotTrack - Enable privacy-enhanced mode
454
- * @returns Embed URL or null
449
+ * @returns Embed URL or false if not valid
455
450
  */
456
- youtube: (url: string, doNotTrack?: boolean) => string | null;
451
+ youtube: (url: string, doNotTrack?: boolean) => string | false;
457
452
 
458
453
  /**
459
454
  * Converts Vimeo URL to embed URL.
460
455
  *
461
456
  * @param url - Vimeo video URL
462
457
  * @param doNotTrack - Enable do-not-track mode
463
- * @returns Embed URL or null
458
+ * @returns Embed URL or false if not valid
464
459
  */
465
- vimeo: (url: string, doNotTrack?: boolean) => string | null;
460
+ vimeo: (url: string, doNotTrack?: boolean) => string | false;
466
461
 
467
462
  /**
468
463
  * Auto-detects provider and converts to embed URL.
469
464
  *
470
465
  * @param url - Video URL
471
466
  * @param doNotTrack - Privacy mode
472
- * @returns Embed URL or null
467
+ * @returns Embed URL or false if not valid
473
468
  */
474
- video: (url: string, doNotTrack?: boolean) => string | null;
469
+ video: (url: string, doNotTrack?: boolean) => string | false;
475
470
  }
476
471
 
477
472
  // -----------------------------------------------------------------------------
@@ -485,17 +480,17 @@ export interface PanelFieldDefinition {
485
480
  /** Field type */
486
481
  type?: string;
487
482
  /** Default value */
488
- default?: unknown;
483
+ default?: any;
489
484
  /** Whether field is disabled */
490
485
  disabled?: boolean;
491
486
  /** Conditional visibility */
492
- when?: Record<string, unknown>;
487
+ when?: Record<string, any>;
493
488
  /** API endpoint */
494
- endpoints?: { field?: string; section?: string };
489
+ endpoints?: { field?: string; section?: string; model?: string };
495
490
  /** Nested fields */
496
491
  fields?: Record<string, PanelFieldDefinition>;
497
492
  /** Additional properties */
498
- [key: string]: unknown;
493
+ [key: string]: any;
499
494
  }
500
495
 
501
496
  /**
@@ -510,7 +505,7 @@ export interface PanelHelpersField {
510
505
  * @param field - Field definition
511
506
  * @returns Default value
512
507
  */
513
- defaultValue: (field: PanelFieldDefinition) => unknown;
508
+ defaultValue: (field: PanelFieldDefinition) => any;
514
509
 
515
510
  /**
516
511
  * Creates form values object from field definitions.
@@ -518,9 +513,7 @@ export interface PanelHelpersField {
518
513
  * @param fields - Field definitions
519
514
  * @returns Form values object
520
515
  */
521
- form: (
522
- fields: Record<string, PanelFieldDefinition>,
523
- ) => Record<string, unknown>;
516
+ form: (fields: Record<string, PanelFieldDefinition>) => Record<string, any>;
524
517
 
525
518
  /**
526
519
  * Checks if field is visible based on 'when' conditions.
@@ -531,7 +524,7 @@ export interface PanelHelpersField {
531
524
  */
532
525
  isVisible: (
533
526
  field: PanelFieldDefinition,
534
- values: Record<string, unknown>,
527
+ values: Record<string, any>,
535
528
  ) => boolean;
536
529
 
537
530
  /**
@@ -577,7 +570,7 @@ export interface PanelHelpersFile {
577
570
  * Formats byte size as human-readable string.
578
571
  *
579
572
  * @param size - Size in bytes
580
- * @returns Formatted size (e.g., `'1.2 MB'`)
573
+ * @returns Formatted size (e.g., `"1.2 MB"`)
581
574
  */
582
575
  niceSize: (size: number) => string;
583
576
  }
@@ -595,7 +588,7 @@ export interface PanelHelpersKeyboard {
595
588
  /**
596
589
  * Returns the meta key name for the current OS.
597
590
  *
598
- * @returns 'cmd' on Mac, 'ctrl' on other OS
591
+ * @returns `"cmd"` on Mac, `"ctrl"` on other OS
599
592
  */
600
593
  metaKey: () => "cmd" | "ctrl";
601
594
  }
@@ -645,7 +638,7 @@ export interface PanelLinkPreview {
645
638
  /** Display label */
646
639
  label: string;
647
640
  /** Preview image */
648
- image?: { url: string; [key: string]: unknown };
641
+ image?: { url: string; [key: string]: any };
649
642
  }
650
643
 
651
644
  /**
@@ -659,12 +652,12 @@ export interface PanelHelpersLink {
659
652
  *
660
653
  * @param value - Link value to detect
661
654
  * @param types - Custom type definitions
662
- * @returns Detection result
655
+ * @returns Detection result or undefined if no match
663
656
  */
664
657
  detect: (
665
658
  value: string,
666
659
  types?: Record<string, PanelLinkType>,
667
- ) => PanelLinkDetection;
660
+ ) => PanelLinkDetection | undefined;
668
661
 
669
662
  /**
670
663
  * Converts file permalink to file:// UUID.
@@ -727,14 +720,18 @@ export interface PanelHelpersLink {
727
720
  * Page status button props.
728
721
  */
729
722
  export interface PanelPageStatusProps {
730
- /** Status text */
731
- text: string;
723
+ /** Status title */
724
+ title: string;
732
725
  /** Status icon */
733
726
  icon: string;
734
727
  /** Status color */
735
728
  theme?: string;
736
729
  /** Whether disabled */
737
730
  disabled?: boolean;
731
+ /** Button size */
732
+ size: string;
733
+ /** Button style */
734
+ style: string;
738
735
  }
739
736
 
740
737
  /**
@@ -772,7 +769,7 @@ export type PanelUploadProgressCallback = (
772
769
  export type PanelUploadCompleteCallback = (
773
770
  xhr: XMLHttpRequest,
774
771
  file: File,
775
- response: unknown,
772
+ response: any,
776
773
  ) => void;
777
774
 
778
775
  /**
@@ -783,16 +780,16 @@ export type PanelUploadCompleteCallback = (
783
780
  export interface PanelUploadParams {
784
781
  /** Upload endpoint URL */
785
782
  url: string;
786
- /** HTTP method (default: `'POST'`) */
783
+ /** HTTP method (default: `"POST"`) */
787
784
  method?: string;
788
- /** Form field name (default: `'file'`) */
785
+ /** Form field name (default: `"file"`) */
789
786
  field?: string;
790
787
  /** Override filename */
791
788
  filename?: string;
792
789
  /** Request headers */
793
790
  headers?: Record<string, string>;
794
791
  /** Additional form attributes */
795
- attributes?: Record<string, unknown>;
792
+ attributes?: Record<string, any>;
796
793
  /** AbortSignal for cancellation */
797
794
  abort?: AbortSignal;
798
795
  /** Progress callback */
@@ -830,11 +827,16 @@ export interface PanelThrottleOptions {
830
827
  }
831
828
 
832
829
  /**
833
- * Debounced/throttled function with cancel method.
830
+ * Debounced function (without cancel method).
834
831
  */
835
- export interface PanelDebouncedFunction<
836
- T extends (...args: unknown[]) => unknown,
837
- > {
832
+ export interface PanelDebouncedFunction<T extends (...args: any[]) => any> {
833
+ (...args: Parameters<T>): ReturnType<T> | undefined;
834
+ }
835
+
836
+ /**
837
+ * Throttled function with cancel method.
838
+ */
839
+ export interface PanelThrottledFunction<T extends (...args: any[]) => any> {
838
840
  (...args: Parameters<T>): ReturnType<T> | undefined;
839
841
  /** Cancels pending invocation */
840
842
  cancel: () => void;
@@ -871,7 +873,7 @@ export type PanelComparator = (a: string, b: string) => number;
871
873
  * @example
872
874
  * ```ts
873
875
  * // In a Vue component
874
- * this.$helper.string.slug('Hello World');
876
+ * this.$helper.string.slug("Hello World");
875
877
  * this.$helper.clone(someObject);
876
878
  * this.$helper.uuid();
877
879
  * ```
@@ -895,9 +897,9 @@ export interface PanelHelpers {
895
897
  * Resolves CSS color to CSS variable.
896
898
  *
897
899
  * @param value - Color name or value
898
- * @returns CSS variable or original value
900
+ * @returns CSS variable or original value, undefined if not a string
899
901
  */
900
- color: (value: string) => string;
902
+ color: (value: string) => string | undefined;
901
903
 
902
904
  /**
903
905
  * Creates a debounced function.
@@ -907,7 +909,7 @@ export interface PanelHelpers {
907
909
  * @param options - Debounce options
908
910
  * @returns Debounced function with cancel method
909
911
  */
910
- debounce: <T extends (...args: unknown[]) => unknown>(
912
+ debounce: <T extends (...args: any[]) => any>(
911
913
  fn: T,
912
914
  delay: number,
913
915
  options?: PanelDebounceOptions,
@@ -927,8 +929,9 @@ export interface PanelHelpers {
927
929
  *
928
930
  * @param element - Selector or element
929
931
  * @param field - Specific input name to focus
932
+ * @returns The focused element, or false if nothing could be focused
930
933
  */
931
- focus: (element: string | HTMLElement, field?: string) => void;
934
+ focus: (element: string | HTMLElement, field?: string) => HTMLElement | false;
932
935
 
933
936
  /**
934
937
  * Checks if component is registered globally.
@@ -967,8 +970,8 @@ export interface PanelHelpers {
967
970
  /**
968
971
  * Converts aspect ratio to percentage.
969
972
  *
970
- * @param fraction - Ratio string (e.g., `'3/2'`)
971
- * @param fallback - Fallback value (default: `'100%'`)
973
+ * @param fraction - Ratio string (e.g., `"3/2"`)
974
+ * @param fallback - Fallback value (default: `"100%"`)
972
975
  * @param vertical - Calculate for vertical orientation
973
976
  * @returns Percentage string
974
977
  */
@@ -1004,11 +1007,11 @@ export interface PanelHelpers {
1004
1007
  * @param options - Throttle options
1005
1008
  * @returns Throttled function with cancel method
1006
1009
  */
1007
- throttle: <T extends (...args: unknown[]) => unknown>(
1010
+ throttle: <T extends (...args: any[]) => any>(
1008
1011
  fn: T,
1009
1012
  delay: number,
1010
1013
  options?: PanelThrottleOptions,
1011
- ) => PanelDebouncedFunction<T>;
1014
+ ) => PanelThrottledFunction<T>;
1012
1015
 
1013
1016
  /**
1014
1017
  * Uploads a file via XMLHttpRequest.
@@ -1017,7 +1020,7 @@ export interface PanelHelpers {
1017
1020
  * @param params - Upload parameters
1018
1021
  * @returns Promise resolving to response
1019
1022
  */
1020
- upload: (file: File, params: PanelUploadParams) => Promise<unknown>;
1023
+ upload: (file: File, params: PanelUploadParams) => Promise<any>;
1021
1024
 
1022
1025
  /** URL utilities */
1023
1026
  url: PanelHelpersUrl;