@xwiki/cristal-uiextension-api 0.22.0 → 0.23.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @xwiki/cristal-uiextension-api
2
2
 
3
+ ## 0.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Cristal 0.23 Release
8
+
3
9
  ## 0.22.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
19
  */
20
20
  import type { Component } from "vue";
21
+ import type { ComposerTranslation } from "vue-i18n";
21
22
  /**
22
23
  * Define the information held by a UI Extension (UIX).
23
24
  *
@@ -65,5 +66,24 @@ interface UIExtensionsManager {
65
66
  */
66
67
  list(name: string): Promise<UIExtension[]>;
67
68
  }
69
+ /**
70
+ * Abstract class helping with localization of UI extensions.
71
+ *
72
+ * @since 0.23
73
+ * @beta
74
+ */
75
+ declare abstract class AbstractUIExtension implements UIExtension {
76
+ protected t: ComposerTranslation;
77
+ constructor(messages: Record<string, Record<string, string>>);
78
+ abstract id: string;
79
+ abstract uixpName: string;
80
+ abstract order: number;
81
+ abstract parameters: {
82
+ [key: string]: unknown;
83
+ };
84
+ abstract enabled(): Promise<boolean>;
85
+ abstract component(): Promise<Component>;
86
+ }
87
+ export { AbstractUIExtension };
68
88
  export type { UIExtension, UIExtensionsManager };
69
89
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC;;;;;GAKG;AACH,UAAU,WAAW;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,QAAQ,EAAE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AW;IACvD,SAAS,CAAC,CAAC,EAAE,mBAAmB,CAAC;gBAER,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAQzE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAEhD,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;CACzC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC"}
@@ -5,6 +5,28 @@
5
5
  ```ts
6
6
 
7
7
  import type { Component } from 'vue';
8
+ import type { ComposerTranslation } from 'vue-i18n';
9
+
10
+ // @beta
11
+ export abstract class AbstractUIExtension implements UIExtension {
12
+ constructor(messages: Record<string, Record<string, string>>);
13
+ // (undocumented)
14
+ abstract component(): Promise<Component>;
15
+ // (undocumented)
16
+ abstract enabled(): Promise<boolean>;
17
+ // (undocumented)
18
+ abstract id: string;
19
+ // (undocumented)
20
+ abstract order: number;
21
+ // (undocumented)
22
+ abstract parameters: {
23
+ [key: string]: unknown;
24
+ };
25
+ // (undocumented)
26
+ protected t: ComposerTranslation;
27
+ // (undocumented)
28
+ abstract uixpName: string;
29
+ }
8
30
 
9
31
  // @beta
10
32
  export interface UIExtension {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-uiextension-api",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
@@ -15,18 +15,24 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/index.d.ts"
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./src/index.ts"
19
20
  }
20
21
  },
22
+ "main": "./src/index.ts",
21
23
  "types": "./dist/index.d.ts",
24
+ "dependencies": {
25
+ "vue-i18n": "11.1.12"
26
+ },
22
27
  "peerDependencies": {
28
+ "inversify": "7.x",
23
29
  "reflect-metadata": "0.x",
24
30
  "vue": "3.x"
25
31
  },
26
32
  "devDependencies": {
27
- "typescript": "5.9.2",
28
- "vue": "3.5.20",
29
- "@xwiki/cristal-dev-config": "0.22.0"
33
+ "typescript": "5.9.3",
34
+ "vue": "3.5.22",
35
+ "@xwiki/cristal-dev-config": "0.23.0"
30
36
  },
31
37
  "scripts": {
32
38
  "api-extractor:local": "api-extractor run --local",
package/src/index.ts CHANGED
@@ -18,7 +18,10 @@
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
19
  */
20
20
 
21
+ import { injectable, unmanaged } from "inversify";
22
+ import { useI18n } from "vue-i18n";
21
23
  import type { Component } from "vue";
24
+ import type { ComposerTranslation } from "vue-i18n";
22
25
 
23
26
  /**
24
27
  * Define the information held by a UI Extension (UIX).
@@ -72,4 +75,32 @@ interface UIExtensionsManager {
72
75
  list(name: string): Promise<UIExtension[]>;
73
76
  }
74
77
 
78
+ /**
79
+ * Abstract class helping with localization of UI extensions.
80
+ *
81
+ * @since 0.23
82
+ * @beta
83
+ */
84
+ @injectable()
85
+ abstract class AbstractUIExtension implements UIExtension {
86
+ protected t: ComposerTranslation;
87
+
88
+ constructor(@unmanaged() messages: Record<string, Record<string, string>>) {
89
+ const { t, mergeLocaleMessage } = useI18n();
90
+ for (const messagesKey in messages) {
91
+ mergeLocaleMessage(messagesKey, messages[messagesKey]);
92
+ }
93
+ this.t = t;
94
+ }
95
+
96
+ abstract id: string;
97
+ abstract uixpName: string;
98
+ abstract order: number;
99
+ abstract parameters: { [key: string]: unknown };
100
+
101
+ abstract enabled(): Promise<boolean>;
102
+ abstract component(): Promise<Component>;
103
+ }
104
+
105
+ export { AbstractUIExtension };
75
106
  export type { UIExtension, UIExtensionsManager };