@kosdev-code/kos-ui-plugin 2.1.11 → 2.1.13
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.
|
@@ -2,12 +2,20 @@ import { ExtensionComponentProps } from './use-extension-component';
|
|
|
2
2
|
import { PluginExtension } from '../../types/plugins';
|
|
3
3
|
import { useKosTranslation } from '@kosdev-code/kos-ui-sdk';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Base properties that all extension data includes
|
|
7
|
+
*/
|
|
8
|
+
export interface ExtensionBaseData {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
namespace: string;
|
|
12
|
+
}
|
|
5
13
|
/**
|
|
6
14
|
* Result from useExtensionI18n hook
|
|
7
15
|
*/
|
|
8
16
|
export interface UseExtensionI18nResult<TData = unknown, TProps = unknown> {
|
|
9
|
-
/** All extensions for this extension point */
|
|
10
|
-
extensions: PluginExtension<TData>[];
|
|
17
|
+
/** All extensions for this extension point - data includes base properties (id, title, namespace) plus custom TData */
|
|
18
|
+
extensions: PluginExtension<ExtensionBaseData & TData>[];
|
|
11
19
|
/** Translation function configured with all unique namespaces from extensions */
|
|
12
20
|
t: ReturnType<typeof useKosTranslation>["t"];
|
|
13
21
|
/** i18n utilities (e.g., exists check) */
|
|
@@ -24,18 +32,16 @@ export interface UseExtensionI18nResult<TData = unknown, TProps = unknown> {
|
|
|
24
32
|
* 3. Configuring i18n with those namespaces
|
|
25
33
|
* 4. Getting the extension component
|
|
26
34
|
*
|
|
27
|
-
* **For type safety:**
|
|
28
|
-
*
|
|
35
|
+
* **For type safety:** Define only the custom properties from your extension schema.
|
|
36
|
+
* The hook automatically merges base properties (id, title, namespace) with your custom type.
|
|
29
37
|
*
|
|
30
38
|
* @example
|
|
31
39
|
* ```tsx
|
|
32
|
-
* // Step 1:
|
|
40
|
+
* // Step 1: Define only your custom extension properties
|
|
33
41
|
* // src/types/nav-link-types.ts
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* const NavLinkSchema = getExtensionPointSchema('app.navigation.link');
|
|
38
|
-
* export type NavLinkData = z.infer<typeof NavLinkSchema>;
|
|
42
|
+
* export interface NavLinkData {
|
|
43
|
+
* viewKey: string; // Only define your custom properties - base props are added automatically!
|
|
44
|
+
* }
|
|
39
45
|
*
|
|
40
46
|
* // Step 2: Use the type with the hook
|
|
41
47
|
* import { NavLinkData } from '../types/nav-link-types';
|
|
@@ -44,11 +50,11 @@ export interface UseExtensionI18nResult<TData = unknown, TProps = unknown> {
|
|
|
44
50
|
* EXTENSION_ID_NAV_LINK
|
|
45
51
|
* );
|
|
46
52
|
*
|
|
47
|
-
* //
|
|
53
|
+
* // extensions.data includes both base properties AND your custom properties
|
|
48
54
|
* const navLinks = extensions.map(link => ({
|
|
49
|
-
* title: t(`${link.data.namespace}:${link.data.title}`),
|
|
50
|
-
* viewKey: link.data.viewKey,
|
|
51
|
-
* icon: <Component module={link.id} navKey={link.data.viewKey} />
|
|
55
|
+
* title: t(`${link.data.namespace}:${link.data.title}`), // namespace and title from base
|
|
56
|
+
* viewKey: link.data.viewKey, // viewKey from your custom NavLinkData
|
|
57
|
+
* icon: <Component module={link.id} navKey={link.data.viewKey} />
|
|
52
58
|
* }));
|
|
53
59
|
* ```
|
|
54
60
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-extension-i18n.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-plugin/src/lib/hooks/use-extension-i18n.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,2BAA2B,CAAC;AAGnC;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IACvE,
|
|
1
|
+
{"version":3,"file":"use-extension-i18n.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-plugin/src/lib/hooks/use-extension-i18n.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,2BAA2B,CAAC;AAGnC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IACvE,uHAAuH;IACvH,UAAU,EAAE,eAAe,CAAC,iBAAiB,GAAG,KAAK,CAAC,EAAE,CAAC;IACzD,iFAAiF;IACjF,CAAC,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7C,0CAA0C;IAC1C,IAAI,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,oHAAoH;IACpH,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,uBAAuB,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;IACxE,kDAAkD;IAClD,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EAChE,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE;IACR,uFAAuF;IACvF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GACA,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAwBvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/kos-ui-plugin",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"kos": {
|
|
23
23
|
"build": {
|
|
24
|
-
"gitHash": "
|
|
24
|
+
"gitHash": "b11908d79cb7e6923c43abbe2d9b43b1eb3e05c5"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|