@redhat-cloud-services/types 0.0.4 → 0.0.5

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.
Files changed (2) hide show
  1. package/index.d.ts +30 -2
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -55,6 +55,28 @@ declare type VisibilityFunctions = {
55
55
  /**
56
56
  * TODO: Once chrome is migrated to TS, sychronize with chrome typings
57
57
  */
58
+ export type NavDOMEvent = {
59
+ href: string;
60
+ id: string;
61
+ navId: string;
62
+ type: string;
63
+ target?: HTMLAnchorElement | null;
64
+ };
65
+
66
+ export type AppNavigationCB = (navEvent: { navId?: string; domEvent: NavDOMEvent }) => void;
67
+ export type GenericCB = (...args: unknown[]) => void;
68
+
69
+ export type OnEventCallbacks = {
70
+ APP_NAVIGATION: AppNavigationCB;
71
+ NAVIGATION_TOGGLE: GenericCB;
72
+ GLOBAL_FILTER_UPDATE: GenericCB;
73
+ };
74
+
75
+ declare function OnChromeEvent<K extends 'APP_NAVIGATION' | 'NAVIGATION_TOGGLE' | 'GLOBAL_FILTER_UPDATE'>(
76
+ event: K,
77
+ callback: OnEventCallbacks[K]
78
+ ): () => void;
79
+
58
80
  export interface ChromeAPI {
59
81
  /** @deprecated will be removed from useChrome hook */
60
82
  $internal: any;
@@ -127,8 +149,14 @@ export interface ChromeAPI {
127
149
  mapGlobalFilter: (...args: any[]) => any;
128
150
  /** @deprecated this function has no effect. */
129
151
  navigation: () => void;
130
- /** TODO: Deprecate this function */
131
- on: (...args: any[]) => any;
152
+ /**
153
+ * Example usage
154
+ * on<'APP_NAVIGATION'>('APP_NAVIGATION', (navEvent) => {
155
+ * navEvent.domEvent.href;
156
+ * navEvent.navId;
157
+ * });
158
+ */
159
+ on: typeof OnChromeEvent;
132
160
  registerModule: (module: string, manifest: string) => void;
133
161
  /** @duplicate of "hideGlobalFilter" TODO: deprecate this function */
134
162
  removeGlobalFilter: (isHidden: boolean) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redhat-cloud-services/types",
3
3
  "description": "TypeScript definitions for @redhat-cloud-services common typings",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "main": "",
6
6
  "types": "index.d.ts",
7
7
  "publishConfig": {